@umituz/react-native-design-system 2.6.79 → 2.6.81
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 +1 -1
- package/src/device/infrastructure/services/DeviceExtrasCollector.ts +1 -1
- package/src/layouts/ScreenLayout/ScreenLayout.tsx +2 -2
- package/src/layouts/ScreenLayout/styles/screenLayoutStyles.ts +0 -1
- package/src/molecules/avatar/Avatar.tsx +3 -6
- package/src/molecules/avatar/Avatar.utils.ts +5 -9
- package/src/molecules/avatar/AvatarGroup.tsx +4 -39
- package/src/molecules/avatar/index.ts +3 -8
- package/src/molecules/countdown/components/Countdown.tsx +16 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.81",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -53,7 +53,7 @@ function getDeviceLocale(): string | undefined {
|
|
|
53
53
|
const locales = Localization.getLocales();
|
|
54
54
|
if (locales && locales.length > 0) {
|
|
55
55
|
const locale = locales[0];
|
|
56
|
-
return locale
|
|
56
|
+
return locale?.languageTag || undefined;
|
|
57
57
|
}
|
|
58
58
|
return undefined;
|
|
59
59
|
} catch {
|
|
@@ -43,8 +43,8 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
|
|
|
43
43
|
|
|
44
44
|
// Pre-compute styles
|
|
45
45
|
const styles = useMemo(
|
|
46
|
-
() => getScreenLayoutStyles(
|
|
47
|
-
[
|
|
46
|
+
() => getScreenLayoutStyles({ maxWidth: finalMaxWidth, horizontalPadding, verticalPadding }),
|
|
47
|
+
[finalMaxWidth, horizontalPadding, verticalPadding]
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
const bgColor = backgroundColor || tokens.colors.backgroundPrimary;
|
|
@@ -9,12 +9,9 @@ import React from 'react';
|
|
|
9
9
|
import { View, Image, StyleSheet, type StyleProp, type ViewStyle, type ImageStyle } from 'react-native';
|
|
10
10
|
import { useAppDesignTokens } from '../../theme';
|
|
11
11
|
import { AtomicText, AtomicIcon } from '../../atoms';
|
|
12
|
-
import type { AvatarSize, AvatarShape } from './Avatar.
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
AvatarUtils,
|
|
16
|
-
AVATAR_CONSTANTS,
|
|
17
|
-
} from './Avatar.utils';
|
|
12
|
+
import type { AvatarSize, AvatarShape } from './Avatar.types';
|
|
13
|
+
import { SIZE_CONFIGS, AVATAR_CONSTANTS } from './Avatar.constants';
|
|
14
|
+
import { AvatarUtils } from './Avatar.utils';
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* Avatar component props
|
|
@@ -64,17 +64,17 @@ export class AvatarUtils {
|
|
|
64
64
|
* Same name always returns same color
|
|
65
65
|
*/
|
|
66
66
|
static getColorForName(name: string): string {
|
|
67
|
-
if (!name) return AVATAR_COLORS[0];
|
|
67
|
+
if (!name) return AVATAR_COLORS[0] ?? '#7E57C2';
|
|
68
68
|
|
|
69
69
|
const hash = this.hashString(name);
|
|
70
|
-
return AVATAR_COLORS[hash % AVATAR_COLORS.length];
|
|
70
|
+
return AVATAR_COLORS[hash % AVATAR_COLORS.length] ?? AVATAR_COLORS[0] ?? '#7E57C2';
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Get size config
|
|
75
75
|
*/
|
|
76
76
|
static getSizeConfig(size: AvatarSize): SizeConfig {
|
|
77
|
-
return SIZE_CONFIGS[size];
|
|
77
|
+
return SIZE_CONFIGS[size] ?? SIZE_CONFIGS.md;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -84,14 +84,14 @@ export class AvatarUtils {
|
|
|
84
84
|
if (shape === 'circle') {
|
|
85
85
|
return size / 2;
|
|
86
86
|
}
|
|
87
|
-
return SHAPE_CONFIGS[shape];
|
|
87
|
+
return SHAPE_CONFIGS[shape] ?? 0;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Get status color
|
|
92
92
|
*/
|
|
93
93
|
static getStatusColor(status: 'online' | 'offline' | 'away' | 'busy'): string {
|
|
94
|
-
return STATUS_COLORS[status];
|
|
94
|
+
return STATUS_COLORS[status] ?? STATUS_COLORS.offline;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -132,7 +132,3 @@ export class AvatarUtils {
|
|
|
132
132
|
return config.type === 'icon' && !!config.icon;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
// Re-export types and constants for convenience
|
|
137
|
-
export type { AvatarSize, AvatarShape, AvatarType, AvatarConfig, SizeConfig } from './Avatar.types';
|
|
138
|
-
export { AVATAR_COLORS, STATUS_COLORS, SHAPE_CONFIGS, SIZE_CONFIGS, AVATAR_CONSTANTS } from './Avatar.constants';
|
|
@@ -10,11 +10,8 @@ import { View, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
|
|
|
10
10
|
import { useAppDesignTokens } from '../../theme';
|
|
11
11
|
import { AtomicText } from '../../atoms';
|
|
12
12
|
import { Avatar } from './Avatar';
|
|
13
|
-
import type { AvatarSize, AvatarShape } from './Avatar.
|
|
14
|
-
import {
|
|
15
|
-
SIZE_CONFIGS,
|
|
16
|
-
AVATAR_CONSTANTS,
|
|
17
|
-
} from './Avatar.utils';
|
|
13
|
+
import type { AvatarSize, AvatarShape } from './Avatar.types';
|
|
14
|
+
import { SIZE_CONFIGS, AVATAR_CONSTANTS } from './Avatar.constants';
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* Avatar item for group
|
|
@@ -43,32 +40,6 @@ export interface AvatarGroupProps {
|
|
|
43
40
|
style?: StyleProp<ViewStyle>;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
/**
|
|
47
|
-
* AvatarGroup Component
|
|
48
|
-
*
|
|
49
|
-
* Displays multiple avatars in a horizontal stack.
|
|
50
|
-
* Shows "+N" indicator when exceeding max visible count.
|
|
51
|
-
*
|
|
52
|
-
* USAGE:
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const users = [
|
|
55
|
-
* { name: 'Ümit Uz', uri: 'https://...' },
|
|
56
|
-
* { name: 'John Doe', uri: 'https://...' },
|
|
57
|
-
* { name: 'Jane Smith' },
|
|
58
|
-
* { name: 'Bob Johnson' },
|
|
59
|
-
* { name: 'Alice Brown' },
|
|
60
|
-
* ];
|
|
61
|
-
*
|
|
62
|
-
* // Show 3 avatars + overflow
|
|
63
|
-
* <AvatarGroup items={users} maxVisible={3} />
|
|
64
|
-
*
|
|
65
|
-
* // Custom spacing
|
|
66
|
-
* <AvatarGroup items={users} spacing={-12} />
|
|
67
|
-
*
|
|
68
|
-
* // Different size
|
|
69
|
-
* <AvatarGroup items={users} size="lg" />
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
43
|
export const AvatarGroup: React.FC<AvatarGroupProps> = ({
|
|
73
44
|
items,
|
|
74
45
|
maxVisible = AVATAR_CONSTANTS.MAX_GROUP_VISIBLE,
|
|
@@ -87,7 +58,6 @@ export const AvatarGroup: React.FC<AvatarGroupProps> = ({
|
|
|
87
58
|
|
|
88
59
|
return (
|
|
89
60
|
<View style={[styles.container, style]}>
|
|
90
|
-
{/* Render visible avatars */}
|
|
91
61
|
{visibleItems.map((item, index) => (
|
|
92
62
|
<View
|
|
93
63
|
key={index}
|
|
@@ -113,7 +83,6 @@ export const AvatarGroup: React.FC<AvatarGroupProps> = ({
|
|
|
113
83
|
</View>
|
|
114
84
|
))}
|
|
115
85
|
|
|
116
|
-
{/* Overflow indicator */}
|
|
117
86
|
{hasOverflow && (
|
|
118
87
|
<View
|
|
119
88
|
style={[
|
|
@@ -158,12 +127,8 @@ const styles = StyleSheet.create({
|
|
|
158
127
|
flexDirection: 'row',
|
|
159
128
|
alignItems: 'center',
|
|
160
129
|
},
|
|
161
|
-
avatarWrapper: {
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
avatar: {
|
|
165
|
-
// Avatar styles
|
|
166
|
-
},
|
|
130
|
+
avatarWrapper: {},
|
|
131
|
+
avatar: {},
|
|
167
132
|
overflow: {
|
|
168
133
|
justifyContent: 'center',
|
|
169
134
|
alignItems: 'center',
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export { Avatar, type AvatarProps } from './Avatar';
|
|
2
2
|
export { AvatarGroup, type AvatarGroupProps, type AvatarGroupItem } from './AvatarGroup';
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type AvatarSize,
|
|
7
|
-
type AvatarShape,
|
|
8
|
-
type AvatarConfig,
|
|
9
|
-
type AvatarType
|
|
10
|
-
} from './Avatar.utils';
|
|
3
|
+
export { AvatarUtils } from './Avatar.utils';
|
|
4
|
+
export { AVATAR_CONSTANTS } from './Avatar.constants';
|
|
5
|
+
export type { AvatarSize, AvatarShape, AvatarConfig, AvatarType } from './Avatar.types';
|
|
@@ -42,7 +42,7 @@ export const Countdown: React.FC<CountdownProps> = ({
|
|
|
42
42
|
() => [target, ...alternateTargets],
|
|
43
43
|
[target, alternateTargets]
|
|
44
44
|
);
|
|
45
|
-
const currentTarget = allTargets[currentTargetIndex];
|
|
45
|
+
const currentTarget = allTargets[currentTargetIndex] ?? target;
|
|
46
46
|
|
|
47
47
|
const { timeRemaining, setTarget: updateTarget } = useCountdown(currentTarget, {
|
|
48
48
|
interval,
|
|
@@ -50,25 +50,28 @@ export const Countdown: React.FC<CountdownProps> = ({
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
React.useEffect(() => {
|
|
53
|
-
|
|
53
|
+
if (currentTarget) {
|
|
54
|
+
updateTarget(currentTarget);
|
|
55
|
+
}
|
|
54
56
|
}, [currentTarget, updateTarget]);
|
|
55
57
|
|
|
56
58
|
const handleToggle = () => {
|
|
57
59
|
const nextIndex = (currentTargetIndex + 1) % allTargets.length;
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
60
|
+
const nextTarget = allTargets[nextIndex];
|
|
61
|
+
if (nextTarget) {
|
|
62
|
+
setCurrentTargetIndex(nextIndex);
|
|
63
|
+
onTargetChange?.(nextTarget);
|
|
61
64
|
}
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
const defaultFormatLabel = (unit: 'days' | 'hours' | 'minutes' | 'seconds') => {
|
|
65
|
-
const labels = {
|
|
66
|
-
days: '
|
|
67
|
-
hours: '
|
|
68
|
-
minutes: '
|
|
69
|
-
seconds: '
|
|
68
|
+
const labels: Record<string, string> = {
|
|
69
|
+
days: '',
|
|
70
|
+
hours: '',
|
|
71
|
+
minutes: '',
|
|
72
|
+
seconds: '',
|
|
70
73
|
};
|
|
71
|
-
return labels[unit];
|
|
74
|
+
return labels[unit] ?? '';
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
const labelFormatter = formatLabel || defaultFormatLabel;
|
|
@@ -112,9 +115,9 @@ export const Countdown: React.FC<CountdownProps> = ({
|
|
|
112
115
|
|
|
113
116
|
return (
|
|
114
117
|
<View style={styles.container}>
|
|
115
|
-
{showLabel && (
|
|
118
|
+
{showLabel && currentTarget && (
|
|
116
119
|
<CountdownHeader
|
|
117
|
-
title={currentTarget.label || '
|
|
120
|
+
title={currentTarget.label || ''}
|
|
118
121
|
icon={currentTarget.icon as IconName}
|
|
119
122
|
showToggle={showToggle}
|
|
120
123
|
onToggle={handleToggle}
|