@umituz/react-native-design-system 2.8.34 → 2.8.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-design-system",
3
- "version": "2.8.34",
3
+ "version": "2.8.35",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, and onboarding utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * Displays a banner-style alert at the top or bottom of the screen.
5
5
  * Full-width notification bar for important messages.
6
+ * Auto-dismisses after duration (default 3 seconds).
6
7
  */
7
8
 
8
- import React from 'react';
9
+ import React, { useEffect } from 'react';
9
10
  import { StyleSheet, View, Pressable } from 'react-native';
10
11
  import { useSafeAreaInsets } from '../../safe-area';
11
12
  import { AtomicText, AtomicIcon } from '../../atoms';
@@ -13,6 +14,8 @@ import { useAppDesignTokens } from '../../theme';
13
14
  import { Alert, AlertType, AlertPosition } from './AlertTypes';
14
15
  import { useAlertStore } from './AlertStore';
15
16
 
17
+ const DEFAULT_DURATION = 3000;
18
+
16
19
  interface AlertBannerProps {
17
20
  alert: Alert;
18
21
  }
@@ -23,12 +26,19 @@ export function AlertBanner({ alert }: AlertBannerProps) {
23
26
  const tokens = useAppDesignTokens();
24
27
 
25
28
  const handleDismiss = () => {
26
- if (alert.dismissible) {
27
- dismissAlert(alert.id);
28
- alert.onDismiss?.();
29
- }
29
+ dismissAlert(alert.id);
30
+ alert.onDismiss?.();
30
31
  };
31
32
 
33
+ // Auto-dismiss after duration
34
+ useEffect(() => {
35
+ const duration = alert.duration ?? DEFAULT_DURATION;
36
+ if (duration > 0) {
37
+ const timer = setTimeout(handleDismiss, duration);
38
+ return () => clearTimeout(timer);
39
+ }
40
+ }, [alert.id, alert.duration]);
41
+
32
42
  const getBackgroundColor = (type: AlertType): string => {
33
43
  switch (type) {
34
44
  case AlertType.SUCCESS:
@@ -5,13 +5,15 @@
5
5
  * Floats on top of content.
6
6
  */
7
7
 
8
- import React from 'react';
8
+ import React, { useEffect } from 'react';
9
9
  import { StyleSheet, View, Pressable, StyleProp, ViewStyle } from 'react-native';
10
10
  import { AtomicText, AtomicIcon } from '../../atoms';
11
11
  import { useAppDesignTokens } from '../../theme';
12
12
  import { Alert, AlertType } from './AlertTypes';
13
13
  import { useAlertStore } from './AlertStore';
14
14
 
15
+ const DEFAULT_DURATION = 3000;
16
+
15
17
  interface AlertToastProps {
16
18
  alert: Alert;
17
19
  }
@@ -20,13 +22,26 @@ export function AlertToast({ alert }: AlertToastProps) {
20
22
  const dismissAlert = useAlertStore((state: { dismissAlert: (id: string) => void }) => state.dismissAlert);
21
23
  const tokens = useAppDesignTokens();
22
24
 
25
+ const dismiss = () => {
26
+ dismissAlert(alert.id);
27
+ alert.onDismiss?.();
28
+ };
29
+
23
30
  const handleDismiss = () => {
24
31
  if (alert.dismissible) {
25
- dismissAlert(alert.id);
26
- alert.onDismiss?.();
32
+ dismiss();
27
33
  }
28
34
  };
29
35
 
36
+ // Auto-dismiss after duration
37
+ useEffect(() => {
38
+ const duration = alert.duration ?? DEFAULT_DURATION;
39
+ if (duration > 0) {
40
+ const timer = setTimeout(dismiss, duration);
41
+ return () => clearTimeout(timer);
42
+ }
43
+ }, [alert.id, alert.duration]);
44
+
30
45
  const getBackgroundColor = (type: AlertType): string => {
31
46
  const colors = {
32
47
  [AlertType.SUCCESS]: tokens.colors.success,
@@ -125,7 +140,7 @@ export function AlertToast({ alert }: AlertToastProps) {
125
140
  onPress={async () => {
126
141
  await action.onPress();
127
142
  if (action.closeOnPress ?? true) {
128
- handleDismiss();
143
+ dismiss();
129
144
  }
130
145
  }}
131
146
  style={[
@@ -22,7 +22,7 @@ export function FilterGroup<T = string>({
22
22
  },
23
23
  content: {
24
24
  paddingHorizontal: tokens.spacing.md,
25
- gap: tokens.spacing.sm,
25
+ gap: tokens.spacing.md,
26
26
  alignItems: 'center',
27
27
  },
28
28
  item: {
@@ -3,10 +3,7 @@ import type {
3
3
  BottomTabNavigationOptions,
4
4
  BottomTabScreenProps,
5
5
  } from "@react-navigation/bottom-tabs";
6
- import type {
7
- StackNavigationOptions,
8
- StackScreenProps,
9
- } from "@react-navigation/stack";
6
+ import type { StackNavigationOptions } from "@react-navigation/stack";
10
7
  import type { IconName } from "../../atoms/AtomicIcon";
11
8
 
12
9
  export type NavigationParams = Record<string, unknown>;