@xaui/native 0.0.9 → 0.0.11

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.
@@ -0,0 +1,123 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, ImageStyle, TextStyle } from 'react-native';
3
+ import { S as Size, R as Radius, T as ThemeColor } from '../index-BOw6tbkc.cjs';
4
+
5
+ type AvatarSize = Size | number;
6
+ type AvatarCustomAppearance = {
7
+ /**
8
+ * Custom styles for the container
9
+ */
10
+ container?: ViewStyle;
11
+ /**
12
+ * Custom styles for the image
13
+ */
14
+ image?: ImageStyle;
15
+ /**
16
+ * Custom styles for the fallback text
17
+ */
18
+ text?: TextStyle;
19
+ };
20
+ type AvatarProps = {
21
+ /**
22
+ * Avatar image source URL.
23
+ */
24
+ src?: string;
25
+ /**
26
+ * Avatar name used for initials fallback.
27
+ */
28
+ name?: string;
29
+ /**
30
+ * Custom icon rendered when no image is available.
31
+ */
32
+ icon?: ReactNode;
33
+ /**
34
+ * Custom fallback rendered when no image is available.
35
+ */
36
+ fallback?: ReactNode;
37
+ /**
38
+ * Avatar size preset or custom number.
39
+ * @default 'md'
40
+ */
41
+ size?: AvatarSize;
42
+ /**
43
+ * Avatar radius.
44
+ * @default 'full'
45
+ */
46
+ radius?: Radius;
47
+ /**
48
+ * Theme color for avatar background and text.
49
+ */
50
+ themeColor?: ThemeColor;
51
+ /**
52
+ * Show border around avatar.
53
+ */
54
+ isBordered?: boolean;
55
+ /**
56
+ * Disabled state.
57
+ */
58
+ isDisabled?: boolean;
59
+ /**
60
+ * Show fallback content when image is missing or fails.
61
+ * @default false
62
+ */
63
+ showFallback?: boolean;
64
+ /**
65
+ * Custom initials generator.
66
+ */
67
+ getInitials?: (name: string) => string;
68
+ /**
69
+ * Custom appearance styles for avatar parts
70
+ */
71
+ customAppearance?: AvatarCustomAppearance;
72
+ };
73
+ type AvatarGroupProps = {
74
+ children?: ReactNode;
75
+ /**
76
+ * Max avatars to display before showing count.
77
+ */
78
+ max?: number;
79
+ /**
80
+ * Total avatars count if different from children length.
81
+ */
82
+ total?: number;
83
+ /**
84
+ * Shared avatar size.
85
+ */
86
+ size?: AvatarSize;
87
+ /**
88
+ * Shared avatar radius.
89
+ */
90
+ radius?: Radius;
91
+ /**
92
+ * Shared theme color.
93
+ */
94
+ themeColor?: ThemeColor;
95
+ /**
96
+ * Show border around avatars.
97
+ */
98
+ isBordered?: boolean;
99
+ /**
100
+ * Disabled state for all avatars.
101
+ */
102
+ isDisabled?: boolean;
103
+ /**
104
+ * Render avatars in a grid layout.
105
+ */
106
+ isGrid?: boolean;
107
+ /**
108
+ * Custom renderer for the count avatar.
109
+ */
110
+ renderCount?: (count: number) => ReactNode;
111
+ /**
112
+ * Custom appearance styles for group container
113
+ */
114
+ customAppearance?: {
115
+ container?: ViewStyle;
116
+ };
117
+ };
118
+
119
+ declare const Avatar: React.FC<AvatarProps>;
120
+
121
+ declare const AvatarGroup: React.FC<AvatarGroupProps>;
122
+
123
+ export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps };
@@ -0,0 +1,123 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, ImageStyle, TextStyle } from 'react-native';
3
+ import { S as Size, R as Radius, T as ThemeColor } from '../index-BOw6tbkc.js';
4
+
5
+ type AvatarSize = Size | number;
6
+ type AvatarCustomAppearance = {
7
+ /**
8
+ * Custom styles for the container
9
+ */
10
+ container?: ViewStyle;
11
+ /**
12
+ * Custom styles for the image
13
+ */
14
+ image?: ImageStyle;
15
+ /**
16
+ * Custom styles for the fallback text
17
+ */
18
+ text?: TextStyle;
19
+ };
20
+ type AvatarProps = {
21
+ /**
22
+ * Avatar image source URL.
23
+ */
24
+ src?: string;
25
+ /**
26
+ * Avatar name used for initials fallback.
27
+ */
28
+ name?: string;
29
+ /**
30
+ * Custom icon rendered when no image is available.
31
+ */
32
+ icon?: ReactNode;
33
+ /**
34
+ * Custom fallback rendered when no image is available.
35
+ */
36
+ fallback?: ReactNode;
37
+ /**
38
+ * Avatar size preset or custom number.
39
+ * @default 'md'
40
+ */
41
+ size?: AvatarSize;
42
+ /**
43
+ * Avatar radius.
44
+ * @default 'full'
45
+ */
46
+ radius?: Radius;
47
+ /**
48
+ * Theme color for avatar background and text.
49
+ */
50
+ themeColor?: ThemeColor;
51
+ /**
52
+ * Show border around avatar.
53
+ */
54
+ isBordered?: boolean;
55
+ /**
56
+ * Disabled state.
57
+ */
58
+ isDisabled?: boolean;
59
+ /**
60
+ * Show fallback content when image is missing or fails.
61
+ * @default false
62
+ */
63
+ showFallback?: boolean;
64
+ /**
65
+ * Custom initials generator.
66
+ */
67
+ getInitials?: (name: string) => string;
68
+ /**
69
+ * Custom appearance styles for avatar parts
70
+ */
71
+ customAppearance?: AvatarCustomAppearance;
72
+ };
73
+ type AvatarGroupProps = {
74
+ children?: ReactNode;
75
+ /**
76
+ * Max avatars to display before showing count.
77
+ */
78
+ max?: number;
79
+ /**
80
+ * Total avatars count if different from children length.
81
+ */
82
+ total?: number;
83
+ /**
84
+ * Shared avatar size.
85
+ */
86
+ size?: AvatarSize;
87
+ /**
88
+ * Shared avatar radius.
89
+ */
90
+ radius?: Radius;
91
+ /**
92
+ * Shared theme color.
93
+ */
94
+ themeColor?: ThemeColor;
95
+ /**
96
+ * Show border around avatars.
97
+ */
98
+ isBordered?: boolean;
99
+ /**
100
+ * Disabled state for all avatars.
101
+ */
102
+ isDisabled?: boolean;
103
+ /**
104
+ * Render avatars in a grid layout.
105
+ */
106
+ isGrid?: boolean;
107
+ /**
108
+ * Custom renderer for the count avatar.
109
+ */
110
+ renderCount?: (count: number) => ReactNode;
111
+ /**
112
+ * Custom appearance styles for group container
113
+ */
114
+ customAppearance?: {
115
+ container?: ViewStyle;
116
+ };
117
+ };
118
+
119
+ declare const Avatar: React.FC<AvatarProps>;
120
+
121
+ declare const AvatarGroup: React.FC<AvatarGroupProps>;
122
+
123
+ export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps };
@@ -0,0 +1,9 @@
1
+ import {
2
+ Avatar,
3
+ AvatarGroup
4
+ } from "../chunk-4LFRYVSR.js";
5
+ import "../chunk-NBRASCX4.js";
6
+ export {
7
+ Avatar,
8
+ AvatarGroup
9
+ };
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/badge/index.ts
31
+ var badge_exports = {};
32
+ __export(badge_exports, {
33
+ Badge: () => Badge
34
+ });
35
+ module.exports = __toCommonJS(badge_exports);
36
+
37
+ // src/components/badge/badge.tsx
38
+ var import_react7 = __toESM(require("react"), 1);
39
+ var import_react_native5 = require("react-native");
40
+
41
+ // src/components/badge/badge.style.ts
42
+ var import_react_native = require("react-native");
43
+ var styles = import_react_native.StyleSheet.create({
44
+ container: {
45
+ position: "relative",
46
+ alignSelf: "flex-start"
47
+ },
48
+ badge: {
49
+ position: "absolute",
50
+ alignItems: "center",
51
+ justifyContent: "center"
52
+ },
53
+ text: {
54
+ textAlign: "center",
55
+ fontWeight: "600",
56
+ includeFontPadding: false,
57
+ textAlignVertical: "center"
58
+ }
59
+ });
60
+
61
+ // src/components/badge/badge.hook.ts
62
+ var import_react6 = require("react");
63
+ var import_core = require("@xaui/core");
64
+
65
+ // src/core/theme-context.tsx
66
+ var import_react4 = __toESM(require("react"), 1);
67
+ var import_react_native3 = require("react-native");
68
+ var import_theme = require("@xaui/core/theme");
69
+ var import_palette = require("@xaui/core/palette");
70
+
71
+ // src/core/portal/portal.tsx
72
+ var import_react2 = require("react");
73
+
74
+ // src/core/portal/portal-context.ts
75
+ var import_react = require("react");
76
+ var PortalContext = (0, import_react.createContext)(null);
77
+
78
+ // src/core/portal/portal-host.tsx
79
+ var import_react3 = __toESM(require("react"), 1);
80
+ var import_react_native2 = require("react-native");
81
+ var hostStyles = import_react_native2.StyleSheet.create({
82
+ container: {
83
+ flex: 1
84
+ }
85
+ });
86
+
87
+ // src/core/theme-context.tsx
88
+ var XUIThemeContext = (0, import_react4.createContext)(null);
89
+
90
+ // src/core/theme-hooks.ts
91
+ var import_react5 = require("react");
92
+ var import_react_native4 = require("react-native");
93
+ function useXUITheme() {
94
+ const theme = (0, import_react5.useContext)(XUIThemeContext);
95
+ if (!theme) {
96
+ throw new Error("useXUITheme must be used within XUIProvider");
97
+ }
98
+ return theme;
99
+ }
100
+
101
+ // src/core/index.ts
102
+ var import_theme2 = require("@xaui/core/theme");
103
+
104
+ // src/components/badge/badge.hook.ts
105
+ var sizeMap = {
106
+ sm: { height: 16, minWidth: 16, dot: 8 },
107
+ md: { height: 20, minWidth: 20, dot: 10 },
108
+ lg: { height: 24, minWidth: 24, dot: 12 }
109
+ };
110
+ var fontSizeMap = {
111
+ sm: 9,
112
+ md: 10,
113
+ lg: 12
114
+ };
115
+ function useBadgeSizeStyles(size, isDot, isOneChar) {
116
+ const theme = useXUITheme();
117
+ return (0, import_react6.useMemo)(() => {
118
+ const { height, minWidth, dot } = sizeMap[size];
119
+ const fontSize = fontSizeMap[size];
120
+ if (isDot) {
121
+ return {
122
+ height: dot,
123
+ minWidth: dot,
124
+ paddingHorizontal: 0,
125
+ fontSize
126
+ };
127
+ }
128
+ if (isOneChar) {
129
+ return {
130
+ height,
131
+ minWidth: height,
132
+ paddingHorizontal: 0,
133
+ fontSize
134
+ };
135
+ }
136
+ const paddingHorizontal = size === "sm" ? theme.spacing.xs : theme.spacing.sm;
137
+ return {
138
+ height,
139
+ minWidth,
140
+ paddingHorizontal,
141
+ fontSize
142
+ };
143
+ }, [isDot, isOneChar, size, theme]);
144
+ }
145
+ function useBadgeVariantStyles(themeColor, variant) {
146
+ const theme = useXUITheme();
147
+ const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
148
+ const colorScheme = theme.colors[safeThemeColor];
149
+ return (0, import_react6.useMemo)(() => {
150
+ if (variant === "flat") {
151
+ return {
152
+ backgroundColor: colorScheme.background,
153
+ color: colorScheme.main
154
+ };
155
+ }
156
+ if (variant === "faded") {
157
+ return {
158
+ backgroundColor: (0, import_core.withOpacity)(colorScheme.background, 0.7),
159
+ color: colorScheme.main
160
+ };
161
+ }
162
+ if (variant === "shadow") {
163
+ return {
164
+ backgroundColor: colorScheme.main,
165
+ color: colorScheme.foreground,
166
+ shadow: theme.shadows.sm
167
+ };
168
+ }
169
+ return {
170
+ backgroundColor: colorScheme.main,
171
+ color: colorScheme.foreground
172
+ };
173
+ }, [colorScheme, theme, variant]);
174
+ }
175
+ function useBadgeRadiusStyles(radius, height) {
176
+ const theme = useXUITheme();
177
+ return (0, import_react6.useMemo)(() => {
178
+ if (radius === "full") {
179
+ return { borderRadius: height / 2 };
180
+ }
181
+ return { borderRadius: theme.borderRadius[radius] };
182
+ }, [height, radius, theme.borderRadius]);
183
+ }
184
+ function useBadgePlacementStyles(placement, height) {
185
+ return (0, import_react6.useMemo)(() => {
186
+ const offset = Math.round(height * 0.3);
187
+ switch (placement) {
188
+ case "top-left":
189
+ return { top: -offset, left: -offset };
190
+ case "bottom-right":
191
+ return { bottom: -offset, right: -offset };
192
+ case "bottom-left":
193
+ return { bottom: -offset, left: -offset };
194
+ case "top-right":
195
+ default:
196
+ return { top: -offset, right: -offset };
197
+ }
198
+ }, [height, placement]);
199
+ }
200
+
201
+ // src/components/badge/badge.tsx
202
+ var Badge = ({
203
+ children,
204
+ content,
205
+ themeColor = "primary",
206
+ variant = "solid",
207
+ size = "md",
208
+ radius = "full",
209
+ placement = "top-right",
210
+ showOutline = true,
211
+ disableOutline = false,
212
+ isInvisible = false,
213
+ isDot = false,
214
+ isOneChar = false,
215
+ disableAnimation = false,
216
+ customAppearance
217
+ }) => {
218
+ const shouldRender = !isInvisible && (isDot || content !== void 0);
219
+ if (!shouldRender && !children) {
220
+ return null;
221
+ }
222
+ const forceOneChar = isOneChar || radius === "full";
223
+ const sizeStyles = useBadgeSizeStyles(size, isDot, forceOneChar);
224
+ const variantStyles = useBadgeVariantStyles(themeColor, variant);
225
+ const radiusStyles = useBadgeRadiusStyles(radius, sizeStyles.height);
226
+ const placementStyles = useBadgePlacementStyles(placement, sizeStyles.height);
227
+ const outlineEnabled = disableOutline ? false : showOutline;
228
+ const outlineStyles = outlineEnabled ? { borderWidth: 1, borderColor: "#FFFFFF" } : { borderWidth: 0, borderColor: "transparent" };
229
+ const badgeContent = isDot ? null : content;
230
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_native5.View, { style: [styles.container, customAppearance?.container] }, children, shouldRender && /* @__PURE__ */ import_react7.default.createElement(
231
+ import_react_native5.View,
232
+ {
233
+ style: [
234
+ styles.badge,
235
+ {
236
+ minWidth: sizeStyles.minWidth,
237
+ height: sizeStyles.height,
238
+ paddingHorizontal: sizeStyles.paddingHorizontal,
239
+ backgroundColor: variantStyles.backgroundColor,
240
+ opacity: disableAnimation ? 1 : 1
241
+ },
242
+ radiusStyles,
243
+ placementStyles,
244
+ outlineStyles,
245
+ variantStyles.shadow,
246
+ customAppearance?.badge
247
+ ],
248
+ accessible: true,
249
+ accessibilityRole: "text"
250
+ },
251
+ badgeContent !== void 0 && badgeContent !== null && /* @__PURE__ */ import_react7.default.createElement(
252
+ import_react_native5.Text,
253
+ {
254
+ style: [
255
+ styles.text,
256
+ {
257
+ fontSize: sizeStyles.fontSize,
258
+ color: variantStyles.color
259
+ },
260
+ customAppearance?.text
261
+ ]
262
+ },
263
+ badgeContent
264
+ )
265
+ ));
266
+ };
267
+ // Annotate the CommonJS export names for ESM import in node:
268
+ 0 && (module.exports = {
269
+ Badge
270
+ });
@@ -0,0 +1,94 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+ import { T as ThemeColor, R as Radius } from '../index-BOw6tbkc.cjs';
4
+
5
+ type BadgeVariant = 'solid' | 'flat' | 'faded' | 'shadow';
6
+ type BadgeSize = 'sm' | 'md' | 'lg';
7
+ type BadgePlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
8
+ type BadgeCustomAppearance = {
9
+ /**
10
+ * Custom styles for the container
11
+ */
12
+ container?: ViewStyle;
13
+ /**
14
+ * Custom styles for the badge
15
+ */
16
+ badge?: ViewStyle;
17
+ /**
18
+ * Custom styles for the text
19
+ */
20
+ text?: TextStyle;
21
+ };
22
+ type BadgeProps = {
23
+ /**
24
+ * Content rendered inside the badge.
25
+ */
26
+ content?: ReactNode;
27
+ /**
28
+ * The badge color.
29
+ * @default 'primary'
30
+ */
31
+ themeColor?: ThemeColor;
32
+ /**
33
+ * The badge variant.
34
+ * @default 'solid'
35
+ */
36
+ variant?: BadgeVariant;
37
+ /**
38
+ * The badge size.
39
+ * @default 'md'
40
+ */
41
+ size?: BadgeSize;
42
+ /**
43
+ * The badge radius.
44
+ * @default 'full'
45
+ */
46
+ radius?: Radius;
47
+ /**
48
+ * Placement relative to children.
49
+ * @default 'top-right'
50
+ */
51
+ placement?: BadgePlacement;
52
+ /**
53
+ * Show outline around badge.
54
+ * @default true
55
+ */
56
+ showOutline?: boolean;
57
+ /**
58
+ * Disable outline around badge.
59
+ * @default false
60
+ */
61
+ disableOutline?: boolean;
62
+ /**
63
+ * Hide the badge.
64
+ * @default false
65
+ */
66
+ isInvisible?: boolean;
67
+ /**
68
+ * Render dot style badge.
69
+ * @default false
70
+ */
71
+ isDot?: boolean;
72
+ /**
73
+ * Render badge as one character size.
74
+ * @default false
75
+ */
76
+ isOneChar?: boolean;
77
+ /**
78
+ * Disable badge animation.
79
+ * @default false
80
+ */
81
+ disableAnimation?: boolean;
82
+ /**
83
+ * Custom appearance styles for badge parts
84
+ */
85
+ customAppearance?: BadgeCustomAppearance;
86
+ /**
87
+ * Wrapped component.
88
+ */
89
+ children?: ReactNode;
90
+ };
91
+
92
+ declare const Badge: React.FC<BadgeProps>;
93
+
94
+ export { Badge, type BadgeProps };
@@ -0,0 +1,94 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+ import { T as ThemeColor, R as Radius } from '../index-BOw6tbkc.js';
4
+
5
+ type BadgeVariant = 'solid' | 'flat' | 'faded' | 'shadow';
6
+ type BadgeSize = 'sm' | 'md' | 'lg';
7
+ type BadgePlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
8
+ type BadgeCustomAppearance = {
9
+ /**
10
+ * Custom styles for the container
11
+ */
12
+ container?: ViewStyle;
13
+ /**
14
+ * Custom styles for the badge
15
+ */
16
+ badge?: ViewStyle;
17
+ /**
18
+ * Custom styles for the text
19
+ */
20
+ text?: TextStyle;
21
+ };
22
+ type BadgeProps = {
23
+ /**
24
+ * Content rendered inside the badge.
25
+ */
26
+ content?: ReactNode;
27
+ /**
28
+ * The badge color.
29
+ * @default 'primary'
30
+ */
31
+ themeColor?: ThemeColor;
32
+ /**
33
+ * The badge variant.
34
+ * @default 'solid'
35
+ */
36
+ variant?: BadgeVariant;
37
+ /**
38
+ * The badge size.
39
+ * @default 'md'
40
+ */
41
+ size?: BadgeSize;
42
+ /**
43
+ * The badge radius.
44
+ * @default 'full'
45
+ */
46
+ radius?: Radius;
47
+ /**
48
+ * Placement relative to children.
49
+ * @default 'top-right'
50
+ */
51
+ placement?: BadgePlacement;
52
+ /**
53
+ * Show outline around badge.
54
+ * @default true
55
+ */
56
+ showOutline?: boolean;
57
+ /**
58
+ * Disable outline around badge.
59
+ * @default false
60
+ */
61
+ disableOutline?: boolean;
62
+ /**
63
+ * Hide the badge.
64
+ * @default false
65
+ */
66
+ isInvisible?: boolean;
67
+ /**
68
+ * Render dot style badge.
69
+ * @default false
70
+ */
71
+ isDot?: boolean;
72
+ /**
73
+ * Render badge as one character size.
74
+ * @default false
75
+ */
76
+ isOneChar?: boolean;
77
+ /**
78
+ * Disable badge animation.
79
+ * @default false
80
+ */
81
+ disableAnimation?: boolean;
82
+ /**
83
+ * Custom appearance styles for badge parts
84
+ */
85
+ customAppearance?: BadgeCustomAppearance;
86
+ /**
87
+ * Wrapped component.
88
+ */
89
+ children?: ReactNode;
90
+ };
91
+
92
+ declare const Badge: React.FC<BadgeProps>;
93
+
94
+ export { Badge, type BadgeProps };