@streamplace/components 0.7.27 → 0.7.29
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/components/chat/chat-box.js +2 -2
- package/dist/components/chat/chat.js +1 -1
- package/dist/components/mobile-player/ui/autoplay-button.js +1 -0
- package/dist/components/mobile-player/ui/viewer-context-menu.js +1 -1
- package/dist/components/mobile-player/ui/viewer-loading-overlay.js +2 -2
- package/dist/components/mobile-player/use-webrtc.js +30 -0
- package/dist/components/ui/button.js +107 -155
- package/dist/components/ui/dialog.js +83 -116
- package/dist/components/ui/dropdown.js +41 -18
- package/dist/components/ui/input.js +53 -128
- package/dist/components/ui/primitives/button.js +0 -2
- package/dist/components/ui/primitives/modal.js +2 -2
- package/dist/components/ui/primitives/text.js +48 -8
- package/dist/components/ui/text.js +37 -66
- package/dist/components/ui/toast.js +78 -40
- package/dist/components/ui/view.js +28 -41
- package/dist/lib/theme/index.js +1 -2
- package/dist/lib/theme/theme.js +106 -54
- package/dist/lib/theme/tokens.js +94 -1
- package/dist/ui/index.js +2 -3
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/package.json +3 -2
- package/src/components/chat/chat-box.tsx +6 -3
- package/src/components/chat/chat.tsx +1 -0
- package/src/components/mobile-player/ui/autoplay-button.tsx +1 -0
- package/src/components/mobile-player/ui/viewer-context-menu.tsx +2 -2
- package/src/components/mobile-player/ui/viewer-loading-overlay.tsx +2 -2
- package/src/components/mobile-player/use-webrtc.tsx +31 -0
- package/src/components/ui/button.tsx +110 -172
- package/src/components/ui/dialog.tsx +96 -138
- package/src/components/ui/dropdown.tsx +60 -22
- package/src/components/ui/input.tsx +57 -144
- package/src/components/ui/primitives/button.tsx +0 -2
- package/src/components/ui/primitives/modal.tsx +0 -2
- package/src/components/ui/primitives/text.tsx +51 -8
- package/src/components/ui/text.tsx +42 -67
- package/src/components/ui/toast.tsx +108 -90
- package/src/components/ui/view.tsx +27 -41
- package/src/lib/theme/index.ts +0 -2
- package/src/lib/theme/theme.tsx +179 -72
- package/src/lib/theme/tokens.ts +97 -0
- package/src/ui/index.ts +0 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,59 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toast = void 0;
|
|
3
4
|
exports.useToast = useToast;
|
|
5
|
+
exports.ToastProvider = ToastProvider;
|
|
4
6
|
exports.Toast = Toast;
|
|
5
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
8
|
const portal_1 = require("@rn-primitives/portal");
|
|
7
9
|
const react_1 = require("react");
|
|
8
10
|
const react_native_1 = require("react-native");
|
|
9
11
|
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
const ui_1 = require("../../ui");
|
|
13
|
+
class ToastManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.listeners = new Set();
|
|
16
|
+
this.currentToast = null;
|
|
17
|
+
this.timeoutId = null;
|
|
18
|
+
}
|
|
19
|
+
show(config) {
|
|
20
|
+
if (this.timeoutId) {
|
|
21
|
+
clearTimeout(this.timeoutId);
|
|
22
|
+
}
|
|
23
|
+
const toast = {
|
|
24
|
+
id: Math.random().toString(36).substr(2, 9),
|
|
25
|
+
open: true,
|
|
26
|
+
title: config.title,
|
|
27
|
+
description: config.description,
|
|
28
|
+
duration: config.duration ?? 3,
|
|
29
|
+
actionLabel: config.actionLabel,
|
|
30
|
+
onAction: config.onAction,
|
|
31
|
+
};
|
|
32
|
+
this.currentToast = toast;
|
|
33
|
+
this.notifyListeners();
|
|
34
|
+
if (toast.duration > 0) {
|
|
35
|
+
this.timeoutId = setTimeout(() => {
|
|
36
|
+
this.hide();
|
|
37
|
+
}, toast.duration * 1000);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
hide() {
|
|
41
|
+
if (this.timeoutId) {
|
|
42
|
+
clearTimeout(this.timeoutId);
|
|
43
|
+
this.timeoutId = null;
|
|
44
|
+
}
|
|
45
|
+
this.currentToast = null;
|
|
46
|
+
this.notifyListeners();
|
|
47
|
+
}
|
|
48
|
+
subscribe(listener) {
|
|
49
|
+
this.listeners.add(listener);
|
|
50
|
+
return () => {
|
|
51
|
+
this.listeners.delete(listener);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
notifyListeners() {
|
|
55
|
+
this.listeners.forEach((listener) => listener(this.currentToast));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const toastManager = new ToastManager();
|
|
59
|
+
exports.toast = {
|
|
60
|
+
show: (title, description, options) => {
|
|
61
|
+
toastManager.show({
|
|
62
|
+
title,
|
|
63
|
+
description,
|
|
64
|
+
...options,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
hide: () => toastManager.hide(),
|
|
68
|
+
};
|
|
69
|
+
function useToast() {
|
|
70
|
+
const [toastState, setToastState] = (0, react_1.useState)(null);
|
|
71
|
+
(0, react_1.useEffect)(() => {
|
|
72
|
+
return toastManager.subscribe(setToastState);
|
|
33
73
|
}, []);
|
|
34
|
-
// Ready-to-render Toast component
|
|
35
|
-
const ToastComponent = ((0, jsx_runtime_1.jsx)(Toast, { open: open, onOpenChange: setOpen, title: title, description: description, actionLabel: actionLabel, onAction: onAction, duration: duration }));
|
|
36
74
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
description,
|
|
40
|
-
actionLabel,
|
|
41
|
-
onAction,
|
|
42
|
-
duration,
|
|
43
|
-
setOpen,
|
|
44
|
-
setTitle,
|
|
45
|
-
setDescription,
|
|
46
|
-
setActionLabel,
|
|
47
|
-
setOnAction,
|
|
48
|
-
setDuration,
|
|
49
|
-
toastController: { show, hide },
|
|
50
|
-
ToastComponent,
|
|
75
|
+
toast: toastState,
|
|
76
|
+
...exports.toast,
|
|
51
77
|
};
|
|
52
78
|
}
|
|
79
|
+
function ToastProvider() {
|
|
80
|
+
const [toastState, setToastState] = (0, react_1.useState)(null);
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
return toastManager.subscribe(setToastState);
|
|
83
|
+
}, []);
|
|
84
|
+
if (!toastState?.open)
|
|
85
|
+
return null;
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(Toast, { open: toastState.open, onOpenChange: (open) => {
|
|
87
|
+
if (!open)
|
|
88
|
+
toastManager.hide();
|
|
89
|
+
}, title: toastState.title, description: toastState.description, actionLabel: toastState.actionLabel, onAction: toastState.onAction, duration: toastState.duration }));
|
|
90
|
+
}
|
|
53
91
|
function Toast({ open, onOpenChange, title, description, actionLabel = "Action", onAction, duration = 3, }) {
|
|
54
92
|
const [seconds, setSeconds] = (0, react_1.useState)(duration);
|
|
55
93
|
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
56
|
-
const { theme } = (0,
|
|
94
|
+
const { theme } = (0, ui_1.useTheme)();
|
|
57
95
|
const [fadeAnim] = (0, react_1.useState)(new react_native_1.Animated.Value(0));
|
|
58
96
|
const { width } = (0, react_native_1.useWindowDimensions)();
|
|
59
97
|
const isWeb = react_native_1.Platform.OS === "web";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.viewVariants = exports.Center = exports.Column = exports.Row = exports.Overlay = exports.Surface = exports.Container = exports.Card = exports.View = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const class_variance_authority_1 = require("class-variance-authority");
|
|
6
7
|
const react_1 = require("react");
|
|
7
8
|
const react_native_1 = require("react-native");
|
|
8
|
-
const atoms_1 = require("../../lib/theme/atoms");
|
|
9
9
|
const theme_1 = require("../../lib/theme/theme");
|
|
10
|
+
const zero = tslib_1.__importStar(require("../../ui"));
|
|
10
11
|
// View variants using class-variance-authority pattern
|
|
11
12
|
const viewVariants = (0, class_variance_authority_1.cva)("", {
|
|
12
13
|
variants: {
|
|
@@ -72,69 +73,61 @@ const viewVariants = (0, class_variance_authority_1.cva)("", {
|
|
|
72
73
|
});
|
|
73
74
|
exports.viewVariants = viewVariants;
|
|
74
75
|
exports.View = (0, react_1.forwardRef)(({ variant = "default", padding = "none", margin = "none", direction = "column", align = "stretch", justify = "start", flex = "none", fullWidth = false, fullHeight = false, centered = false, backgroundColor, borderColor, borderWidth, borderRadius, shadow = false, style, ...props }, ref) => {
|
|
75
|
-
const {
|
|
76
|
-
// Map variant to styles
|
|
76
|
+
const { zero: zt } = (0, theme_1.useTheme)();
|
|
77
|
+
// Map variant to styles using theme.zero
|
|
77
78
|
const variantStyles = (() => {
|
|
78
79
|
switch (variant) {
|
|
79
80
|
case "card":
|
|
80
81
|
return {
|
|
81
|
-
|
|
82
|
-
borderRadius:
|
|
83
|
-
|
|
84
|
-
shadowOffset: { width: 0, height: 2 },
|
|
85
|
-
shadowOpacity: 0.1,
|
|
86
|
-
shadowRadius: 4,
|
|
87
|
-
elevation: 3,
|
|
82
|
+
...zt.bg.card,
|
|
83
|
+
borderRadius: zero.borderRadius.lg,
|
|
84
|
+
...zero.shadows.md,
|
|
88
85
|
};
|
|
89
86
|
case "overlay":
|
|
90
|
-
return
|
|
91
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
92
|
-
};
|
|
87
|
+
return zt.bg.overlay;
|
|
93
88
|
case "surface":
|
|
94
|
-
return
|
|
95
|
-
backgroundColor: theme.colors.background,
|
|
96
|
-
};
|
|
89
|
+
return zt.bg.background;
|
|
97
90
|
case "container":
|
|
98
91
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
...zt.bg.background,
|
|
93
|
+
...zero.p[8],
|
|
101
94
|
};
|
|
102
95
|
default:
|
|
103
96
|
return {};
|
|
104
97
|
}
|
|
105
98
|
})();
|
|
106
|
-
// Map padding to
|
|
99
|
+
// Map padding to zero tokens
|
|
107
100
|
const paddingValue = (() => {
|
|
108
101
|
switch (padding) {
|
|
109
102
|
case "xs":
|
|
110
|
-
return
|
|
103
|
+
return zero.p[1];
|
|
111
104
|
case "sm":
|
|
112
|
-
return
|
|
105
|
+
return zero.p[2];
|
|
113
106
|
case "md":
|
|
114
|
-
return
|
|
107
|
+
return zero.p[4];
|
|
115
108
|
case "lg":
|
|
116
|
-
return
|
|
109
|
+
return zero.p[6];
|
|
117
110
|
case "xl":
|
|
118
|
-
return
|
|
111
|
+
return zero.p[8];
|
|
119
112
|
default:
|
|
120
|
-
return
|
|
113
|
+
return {};
|
|
121
114
|
}
|
|
122
115
|
})();
|
|
123
|
-
// Map margin to
|
|
116
|
+
// Map margin to zero tokens
|
|
124
117
|
const marginValue = (() => {
|
|
125
118
|
switch (margin) {
|
|
126
119
|
case "xs":
|
|
127
|
-
return
|
|
120
|
+
return zero.m[1];
|
|
128
121
|
case "sm":
|
|
129
|
-
return
|
|
122
|
+
return zero.m[2];
|
|
130
123
|
case "md":
|
|
131
|
-
return
|
|
124
|
+
return zero.m[4];
|
|
132
125
|
case "lg":
|
|
133
|
-
return
|
|
126
|
+
return zero.m[6];
|
|
134
127
|
case "xl":
|
|
135
|
-
return
|
|
128
|
+
return zero.m[8];
|
|
136
129
|
default:
|
|
137
|
-
return
|
|
130
|
+
return {};
|
|
138
131
|
}
|
|
139
132
|
})();
|
|
140
133
|
// Map flex direction
|
|
@@ -205,8 +198,8 @@ exports.View = (0, react_1.forwardRef)(({ variant = "default", padding = "none",
|
|
|
205
198
|
})();
|
|
206
199
|
const computedStyle = {
|
|
207
200
|
...variantStyles,
|
|
208
|
-
...
|
|
209
|
-
...
|
|
201
|
+
...paddingValue,
|
|
202
|
+
...marginValue,
|
|
210
203
|
flexDirection,
|
|
211
204
|
alignItems,
|
|
212
205
|
justifyContent,
|
|
@@ -221,13 +214,7 @@ exports.View = (0, react_1.forwardRef)(({ variant = "default", padding = "none",
|
|
|
221
214
|
...(borderColor && { borderColor }),
|
|
222
215
|
...(borderWidth !== undefined && { borderWidth }),
|
|
223
216
|
...(borderRadius !== undefined && { borderRadius }),
|
|
224
|
-
...(shadow &&
|
|
225
|
-
shadowColor: "#000",
|
|
226
|
-
shadowOffset: { width: 0, height: 2 },
|
|
227
|
-
shadowOpacity: 0.1,
|
|
228
|
-
shadowRadius: 4,
|
|
229
|
-
elevation: 3,
|
|
230
|
-
}),
|
|
217
|
+
...(shadow && zero.shadows.md),
|
|
231
218
|
};
|
|
232
219
|
const finalStyle = Array.isArray(style)
|
|
233
220
|
? [computedStyle, ...style]
|
package/dist/lib/theme/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tokens = exports.atoms = exports.typographyAtoms = exports.layout = exports.iconSizes = exports.getPlatformTypography = exports.borders = exports.typography = exports.touchTargets = exports.spacing = exports.shadows = exports.colors = exports.breakpoints = exports.borderRadius = exports.animations = exports.useTheme = exports.usePlatformTypography = exports.lightTheme = exports.darkTheme = exports.createThemedStyles = exports.
|
|
3
|
+
exports.tokens = exports.atoms = exports.typographyAtoms = exports.layout = exports.iconSizes = exports.getPlatformTypography = exports.borders = exports.typography = exports.touchTargets = exports.spacing = exports.shadows = exports.colors = exports.breakpoints = exports.borderRadius = exports.animations = exports.useTheme = exports.usePlatformTypography = exports.lightTheme = exports.darkTheme = exports.createThemedStyles = exports.createThemeIcons = exports.createThemeColors = exports.ThemeProvider = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// Main theme system exports
|
|
6
6
|
var theme_1 = require("./theme");
|
|
7
7
|
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return theme_1.ThemeProvider; } });
|
|
8
8
|
Object.defineProperty(exports, "createThemeColors", { enumerable: true, get: function () { return theme_1.createThemeColors; } });
|
|
9
9
|
Object.defineProperty(exports, "createThemeIcons", { enumerable: true, get: function () { return theme_1.createThemeIcons; } });
|
|
10
|
-
Object.defineProperty(exports, "createThemeStyles", { enumerable: true, get: function () { return theme_1.createThemeStyles; } });
|
|
11
10
|
Object.defineProperty(exports, "createThemedStyles", { enumerable: true, get: function () { return theme_1.createThemedStyles; } });
|
|
12
11
|
Object.defineProperty(exports, "darkTheme", { enumerable: true, get: function () { return theme_1.darkTheme; } });
|
|
13
12
|
Object.defineProperty(exports, "lightTheme", { enumerable: true, get: function () { return theme_1.lightTheme; } });
|
package/dist/lib/theme/theme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createThemeZero = exports.createThemeIcons = exports.createThemeColors = exports.darkTheme = exports.lightTheme = void 0;
|
|
4
4
|
exports.ThemeProvider = ThemeProvider;
|
|
5
5
|
exports.useTheme = useTheme;
|
|
6
6
|
exports.usePlatformTypography = usePlatformTypography;
|
|
@@ -11,44 +11,69 @@ const react_1 = require("react");
|
|
|
11
11
|
const react_native_1 = require("react-native");
|
|
12
12
|
const tokens_1 = require("./tokens");
|
|
13
13
|
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
|
|
14
|
+
const ui_1 = require("../../components/ui");
|
|
15
|
+
// Import pairify function for generating theme tokens
|
|
16
|
+
function pairify(obj, styleKeyPrefix) {
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
19
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
20
|
+
// For nested objects (like color scales), create another level
|
|
21
|
+
result[key] = {};
|
|
22
|
+
for (const [nestedKey, nestedValue] of Object.entries(value)) {
|
|
23
|
+
result[key][nestedKey] = { [styleKeyPrefix]: nestedValue };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// For simple values, create the style object directly
|
|
28
|
+
result[key] = { [styleKeyPrefix]: value };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
14
33
|
// Create theme colors based on dark mode
|
|
15
|
-
const createThemeColors = (isDark) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
textMuted: isDark ? tokens_1.colors.gray[400] : tokens_1.colors.gray[500],
|
|
41
|
-
textDisabled: isDark ? tokens_1.colors.gray[600] : tokens_1.colors.gray[400],
|
|
42
|
-
});
|
|
34
|
+
const createThemeColors = (isDark, lightTheme, darkTheme, colorTheme) => {
|
|
35
|
+
let baseColors;
|
|
36
|
+
if (isDark && darkTheme) {
|
|
37
|
+
// Use dark theme
|
|
38
|
+
baseColors = isColorPalette(darkTheme)
|
|
39
|
+
? generateThemeColorsFromPalette(darkTheme, true)
|
|
40
|
+
: darkTheme;
|
|
41
|
+
}
|
|
42
|
+
else if (!isDark && lightTheme) {
|
|
43
|
+
// Use light theme
|
|
44
|
+
baseColors = isColorPalette(lightTheme)
|
|
45
|
+
? generateThemeColorsFromPalette(lightTheme, false)
|
|
46
|
+
: lightTheme;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Fall back to default gray theme
|
|
50
|
+
const defaultPalette = tokens_1.colors.neutral;
|
|
51
|
+
baseColors = generateThemeColorsFromPalette(defaultPalette, isDark);
|
|
52
|
+
}
|
|
53
|
+
// Merge with custom color overrides if provided
|
|
54
|
+
return {
|
|
55
|
+
...baseColors,
|
|
56
|
+
...colorTheme,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
43
59
|
exports.createThemeColors = createThemeColors;
|
|
44
|
-
// Create theme
|
|
45
|
-
const
|
|
60
|
+
// Create theme-aware zero tokens using pairify
|
|
61
|
+
const createThemeZero = (themeColors) => ({
|
|
62
|
+
// Theme-aware colors using pairify
|
|
63
|
+
bg: pairify(themeColors, "backgroundColor"),
|
|
64
|
+
text: pairify(themeColors, "color"),
|
|
65
|
+
border: {
|
|
66
|
+
...pairify(themeColors, "borderColor"),
|
|
67
|
+
default: { borderColor: themeColors.border },
|
|
68
|
+
},
|
|
69
|
+
// Static design tokens
|
|
46
70
|
shadow: {
|
|
47
71
|
sm: tokens_1.shadows.sm,
|
|
48
72
|
md: tokens_1.shadows.md,
|
|
49
73
|
lg: tokens_1.shadows.lg,
|
|
50
74
|
xl: tokens_1.shadows.xl,
|
|
51
75
|
},
|
|
76
|
+
// Common button styles
|
|
52
77
|
button: {
|
|
53
78
|
primary: {
|
|
54
79
|
backgroundColor: themeColors.primary,
|
|
@@ -69,17 +94,7 @@ const createThemeStyles = (themeColors) => ({
|
|
|
69
94
|
borderWidth: 0,
|
|
70
95
|
},
|
|
71
96
|
},
|
|
72
|
-
|
|
73
|
-
primary: {
|
|
74
|
-
color: themeColors.text,
|
|
75
|
-
},
|
|
76
|
-
muted: {
|
|
77
|
-
color: themeColors.textMuted,
|
|
78
|
-
},
|
|
79
|
-
disabled: {
|
|
80
|
-
color: themeColors.textDisabled,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
97
|
+
// Input styles
|
|
83
98
|
input: {
|
|
84
99
|
base: {
|
|
85
100
|
backgroundColor: themeColors.background,
|
|
@@ -99,6 +114,7 @@ const createThemeStyles = (themeColors) => ({
|
|
|
99
114
|
borderWidth: 2,
|
|
100
115
|
},
|
|
101
116
|
},
|
|
117
|
+
// Card styles
|
|
102
118
|
card: {
|
|
103
119
|
base: {
|
|
104
120
|
backgroundColor: themeColors.card,
|
|
@@ -107,7 +123,7 @@ const createThemeStyles = (themeColors) => ({
|
|
|
107
123
|
},
|
|
108
124
|
},
|
|
109
125
|
});
|
|
110
|
-
exports.
|
|
126
|
+
exports.createThemeZero = createThemeZero;
|
|
111
127
|
// Create theme icons based on colors
|
|
112
128
|
const createThemeIcons = (themeColors) => ({
|
|
113
129
|
color: {
|
|
@@ -129,8 +145,44 @@ const createThemeIcons = (themeColors) => ({
|
|
|
129
145
|
exports.createThemeIcons = createThemeIcons;
|
|
130
146
|
// Create the theme context
|
|
131
147
|
const ThemeContext = (0, react_1.createContext)(null);
|
|
148
|
+
// Helper function to check if input is a ColorPalette or Theme["colors"]
|
|
149
|
+
function isColorPalette(input) {
|
|
150
|
+
return "50" in input && "100" in input && "950" in input;
|
|
151
|
+
}
|
|
152
|
+
// Helper function to generate Theme["colors"] from ColorPalette
|
|
153
|
+
function generateThemeColorsFromPalette(palette, isDark) {
|
|
154
|
+
return {
|
|
155
|
+
background: isDark ? palette[950] : tokens_1.colors.white,
|
|
156
|
+
foreground: isDark ? palette[50] : palette[950],
|
|
157
|
+
card: isDark ? palette[900] : tokens_1.colors.white,
|
|
158
|
+
cardForeground: isDark ? palette[50] : palette[950],
|
|
159
|
+
popover: isDark ? palette[900] : tokens_1.colors.white,
|
|
160
|
+
popoverForeground: isDark ? palette[50] : palette[950],
|
|
161
|
+
primary: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemBlue : tokens_1.colors.primary[500],
|
|
162
|
+
primaryForeground: tokens_1.colors.white,
|
|
163
|
+
secondary: isDark ? palette[800] : palette[100],
|
|
164
|
+
secondaryForeground: isDark ? palette[50] : palette[900],
|
|
165
|
+
muted: isDark ? palette[800] : palette[100],
|
|
166
|
+
mutedForeground: isDark ? palette[400] : palette[500],
|
|
167
|
+
accent: isDark ? palette[800] : palette[100],
|
|
168
|
+
accentForeground: isDark ? palette[50] : palette[900],
|
|
169
|
+
destructive: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemRed : tokens_1.colors.destructive[500],
|
|
170
|
+
destructiveForeground: tokens_1.colors.white,
|
|
171
|
+
success: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemGreen : tokens_1.colors.success[500],
|
|
172
|
+
successForeground: tokens_1.colors.white,
|
|
173
|
+
warning: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemOrange : tokens_1.colors.warning[500],
|
|
174
|
+
warningForeground: tokens_1.colors.white,
|
|
175
|
+
border: isDark ? palette[500] + "30" : palette[200] + "30",
|
|
176
|
+
input: isDark ? palette[800] : palette[200],
|
|
177
|
+
ring: react_native_1.Platform.OS === "ios" ? tokens_1.colors.ios.systemBlue : tokens_1.colors.primary[500],
|
|
178
|
+
text: isDark ? palette[50] : palette[950],
|
|
179
|
+
textMuted: isDark ? palette[400] : palette[500],
|
|
180
|
+
textDisabled: isDark ? palette[600] : palette[400],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
132
183
|
// Theme provider component
|
|
133
|
-
|
|
184
|
+
// Should be surrounded by SafeAreaProvider at the root
|
|
185
|
+
function ThemeProvider({ children, defaultTheme = "system", forcedTheme, colorTheme, lightTheme, darkTheme, }) {
|
|
134
186
|
const systemColorScheme = (0, react_native_1.useColorScheme)();
|
|
135
187
|
const [currentTheme, setCurrentTheme] = (0, react_1.useState)(defaultTheme);
|
|
136
188
|
// Determine if dark mode should be active
|
|
@@ -149,7 +201,7 @@ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
|
|
|
149
201
|
}, [forcedTheme, currentTheme, systemColorScheme]);
|
|
150
202
|
// Create theme based on dark mode
|
|
151
203
|
const theme = (0, react_1.useMemo)(() => {
|
|
152
|
-
const themeColors = createThemeColors(isDark);
|
|
204
|
+
const themeColors = createThemeColors(isDark, lightTheme, darkTheme, colorTheme);
|
|
153
205
|
return {
|
|
154
206
|
colors: themeColors,
|
|
155
207
|
spacing: tokens_1.spacing,
|
|
@@ -159,10 +211,10 @@ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
|
|
|
159
211
|
touchTargets: tokens_1.touchTargets,
|
|
160
212
|
animations: tokens_1.animations,
|
|
161
213
|
};
|
|
162
|
-
}, [isDark]);
|
|
163
|
-
// Create
|
|
164
|
-
const
|
|
165
|
-
return
|
|
214
|
+
}, [isDark, lightTheme, darkTheme, colorTheme]);
|
|
215
|
+
// Create theme-aware zero tokens
|
|
216
|
+
const zero = (0, react_1.useMemo)(() => {
|
|
217
|
+
return createThemeZero(theme.colors);
|
|
166
218
|
}, [theme.colors]);
|
|
167
219
|
// Create icon utilities
|
|
168
220
|
const icons = (0, react_1.useMemo)(() => {
|
|
@@ -187,7 +239,7 @@ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
|
|
|
187
239
|
};
|
|
188
240
|
const value = (0, react_1.useMemo)(() => ({
|
|
189
241
|
theme,
|
|
190
|
-
|
|
242
|
+
zero,
|
|
191
243
|
icons,
|
|
192
244
|
isDark,
|
|
193
245
|
currentTheme: forcedTheme || currentTheme,
|
|
@@ -196,7 +248,7 @@ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
|
|
|
196
248
|
toggleTheme,
|
|
197
249
|
}), [
|
|
198
250
|
theme,
|
|
199
|
-
|
|
251
|
+
zero,
|
|
200
252
|
icons,
|
|
201
253
|
isDark,
|
|
202
254
|
forcedTheme,
|
|
@@ -205,7 +257,7 @@ function ThemeProvider({ children, defaultTheme = "system", forcedTheme, }) {
|
|
|
205
257
|
setTheme,
|
|
206
258
|
toggleTheme,
|
|
207
259
|
]);
|
|
208
|
-
return ((0, jsx_runtime_1.jsx)(ThemeContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)(react_native_gesture_handler_1.GestureHandlerRootView, { children: [children, (0, jsx_runtime_1.jsx)(portal_1.PortalHost, {})] }) }));
|
|
260
|
+
return ((0, jsx_runtime_1.jsx)(ThemeContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)(react_native_gesture_handler_1.GestureHandlerRootView, { children: [children, (0, jsx_runtime_1.jsx)(portal_1.PortalHost, {}), (0, jsx_runtime_1.jsx)(ui_1.ToastProvider, {})] }) }));
|
|
209
261
|
}
|
|
210
262
|
// Hook to use theme
|
|
211
263
|
function useTheme() {
|
|
@@ -231,8 +283,8 @@ function usePlatformTypography() {
|
|
|
231
283
|
// Utility function to create theme-aware styles
|
|
232
284
|
function createThemedStyles(styleCreator) {
|
|
233
285
|
return function useThemedStyles() {
|
|
234
|
-
const { theme,
|
|
235
|
-
return (0, react_1.useMemo)(() => styleCreator(theme,
|
|
286
|
+
const { theme, zero, icons } = useTheme();
|
|
287
|
+
return (0, react_1.useMemo)(() => styleCreator(theme, zero, icons), [theme, zero, icons]);
|
|
236
288
|
};
|
|
237
289
|
}
|
|
238
290
|
// Create light and dark theme instances for external use
|