@streamplace/components 0.7.18 → 0.7.21
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/assets/emoji-data.json +19371 -0
- package/dist/components/chat/chat-box.js +319 -0
- package/dist/components/chat/chat-message.js +87 -0
- package/dist/components/chat/chat.js +150 -0
- package/dist/components/chat/emoji-suggestions.js +35 -0
- package/dist/components/chat/mention-suggestions.js +42 -0
- package/dist/components/chat/mod-view.js +112 -0
- package/dist/components/chat/system-message.js +19 -0
- package/dist/components/dashboard/chat-panel.js +38 -0
- package/dist/components/dashboard/header.js +80 -0
- package/dist/components/dashboard/index.js +14 -0
- package/dist/components/dashboard/information-widget.js +234 -0
- package/dist/components/dashboard/mod-actions.js +71 -0
- package/dist/components/dashboard/problems.js +74 -0
- package/dist/components/icons/bluesky-icon.js +9 -0
- package/dist/components/keep-awake.js +7 -0
- package/dist/components/keep-awake.native.js +16 -0
- package/dist/components/mobile-player/fullscreen.js +76 -0
- package/dist/components/mobile-player/fullscreen.native.js +141 -0
- package/dist/components/mobile-player/player.js +94 -0
- package/dist/components/mobile-player/props.js +2 -0
- package/dist/components/mobile-player/shared.js +54 -0
- package/dist/components/mobile-player/ui/autoplay-button.js +68 -0
- package/dist/components/mobile-player/ui/countdown.js +83 -0
- package/dist/components/mobile-player/ui/index.js +12 -0
- package/dist/components/mobile-player/ui/input.js +42 -0
- package/dist/components/mobile-player/ui/metrics.js +44 -0
- package/dist/components/mobile-player/ui/report-modal.js +90 -0
- package/dist/components/mobile-player/ui/streamer-context-menu.js +7 -0
- package/dist/components/mobile-player/ui/streamer-loading-overlay.js +104 -0
- package/dist/components/mobile-player/ui/viewer-context-menu.js +51 -0
- package/dist/components/mobile-player/ui/viewer-loading-overlay.js +49 -0
- package/dist/components/mobile-player/ui/viewers.js +23 -0
- package/dist/components/mobile-player/use-webrtc.js +243 -0
- package/dist/components/mobile-player/video-async.native.js +276 -0
- package/dist/components/mobile-player/video-retry.js +29 -0
- package/dist/components/mobile-player/video.js +475 -0
- package/dist/components/mobile-player/video.native.js +56 -0
- package/dist/components/mobile-player/webrtc-diagnostics.js +110 -0
- package/dist/components/mobile-player/webrtc-primitives.js +27 -0
- package/dist/components/mobile-player/webrtc-primitives.native.js +8 -0
- package/dist/components/share/sharesheet.js +91 -0
- package/dist/components/ui/button.js +223 -0
- package/dist/components/ui/dialog.js +206 -0
- package/dist/components/ui/dropdown.js +172 -0
- package/dist/components/ui/icons.js +25 -0
- package/dist/components/ui/index.js +34 -0
- package/dist/components/ui/info-box.js +31 -0
- package/dist/components/ui/info-row.js +23 -0
- package/dist/components/ui/input.js +205 -0
- package/dist/components/ui/loader.js +10 -0
- package/dist/components/ui/primitives/button.js +125 -0
- package/dist/components/ui/primitives/input.js +206 -0
- package/dist/components/ui/primitives/modal.js +206 -0
- package/dist/components/ui/primitives/text.js +292 -0
- package/dist/components/ui/resizeable.js +121 -0
- package/dist/components/ui/slider.js +5 -0
- package/dist/components/ui/text.js +177 -0
- package/dist/components/ui/textarea.js +19 -0
- package/dist/components/ui/toast.js +175 -0
- package/dist/components/ui/view.js +252 -0
- package/dist/hooks/index.js +14 -0
- package/dist/hooks/useAvatars.js +35 -0
- package/dist/hooks/useCameraToggle.js +12 -0
- package/dist/hooks/useKeyboard.js +36 -0
- package/dist/hooks/useKeyboardSlide.js +14 -0
- package/dist/hooks/useLivestreamInfo.js +69 -0
- package/dist/hooks/useOuterAndInnerDimensions.js +30 -0
- package/dist/hooks/usePlayerDimensions.js +22 -0
- package/dist/hooks/usePointerDevice.js +71 -0
- package/dist/hooks/useSegmentDimensions.js +17 -0
- package/dist/hooks/useSegmentTiming.js +65 -0
- package/dist/index.js +34 -0
- package/dist/lib/browser.js +35 -0
- package/dist/lib/facet.js +92 -0
- package/dist/lib/system-messages.js +101 -0
- package/dist/lib/theme/atoms.js +646 -0
- package/dist/lib/theme/atoms.types.js +6 -0
- package/dist/lib/theme/index.js +35 -0
- package/dist/lib/theme/theme.js +256 -0
- package/dist/lib/theme/tokens.js +659 -0
- package/dist/lib/utils.js +105 -0
- package/dist/livestream-provider/index.js +30 -0
- package/dist/livestream-provider/websocket.js +45 -0
- package/dist/livestream-store/chat.js +308 -0
- package/dist/livestream-store/context.js +5 -0
- package/dist/livestream-store/index.js +7 -0
- package/dist/livestream-store/livestream-state.js +2 -0
- package/dist/livestream-store/livestream-store.js +58 -0
- package/dist/livestream-store/problems.js +76 -0
- package/dist/livestream-store/stream-key.js +88 -0
- package/dist/livestream-store/websocket-consumer.js +94 -0
- package/dist/player-store/context.js +5 -0
- package/dist/player-store/index.js +9 -0
- package/dist/player-store/player-provider.js +58 -0
- package/dist/player-store/player-state.js +25 -0
- package/dist/player-store/player-store.js +201 -0
- package/dist/player-store/single-player-provider.js +121 -0
- package/dist/streamplace-provider/context.js +5 -0
- package/dist/streamplace-provider/index.js +20 -0
- package/dist/streamplace-provider/poller.js +49 -0
- package/dist/streamplace-provider/xrpc.js +0 -0
- package/dist/streamplace-store/block.js +65 -0
- package/dist/streamplace-store/index.js +6 -0
- package/dist/streamplace-store/stream.js +247 -0
- package/dist/streamplace-store/streamplace-store.js +47 -0
- package/dist/streamplace-store/user.js +52 -0
- package/dist/streamplace-store/xrpc.js +15 -0
- package/dist/ui/index.js +79 -0
- package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
- package/package.json +5 -4
- package/src/components/chat/chat-box.tsx +3 -0
- package/src/components/chat/mod-view.tsx +39 -5
- package/src/components/mobile-player/fullscreen.tsx +2 -0
- package/src/components/mobile-player/ui/autoplay-button.tsx +86 -0
- package/src/components/mobile-player/ui/index.ts +1 -0
- package/src/components/mobile-player/video.tsx +11 -1
- package/src/livestream-store/chat.tsx +22 -0
- package/src/player-store/player-provider.tsx +2 -1
- package/src/player-store/player-state.tsx +6 -0
- package/src/player-store/player-store.tsx +4 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resizable = Resizable;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const lucide_react_native_1 = require("lucide-react-native");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
|
|
10
|
+
const react_native_reanimated_1 = tslib_1.__importStar(require("react-native-reanimated"));
|
|
11
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
12
|
+
const hooks_1 = require("../../hooks");
|
|
13
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
14
|
+
const view_1 = require("./view");
|
|
15
|
+
const AnimatedView = react_native_reanimated_1.default.createAnimatedComponent(view_1.View);
|
|
16
|
+
const { height: SCREEN_HEIGHT } = react_native_1.Dimensions.get("window");
|
|
17
|
+
const SPRING_CONFIG = { damping: 20, stiffness: 100 };
|
|
18
|
+
function Resizable({ startingPercentage, isPlayerRatioGreater, style = {}, children, }) {
|
|
19
|
+
const { slideKeyboard } = (0, hooks_1.useKeyboardSlide)();
|
|
20
|
+
const { bottom: safeBottom } = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
21
|
+
const MAX_HEIGHT = (SCREEN_HEIGHT - safeBottom) * 0.5;
|
|
22
|
+
const MIN_HEIGHT = -(SCREEN_HEIGHT - safeBottom) * 0.2;
|
|
23
|
+
const COLLAPSE_HEIGHT = (SCREEN_HEIGHT - safeBottom) * 0.1;
|
|
24
|
+
const sheetHeight = (0, react_native_reanimated_1.useSharedValue)(MIN_HEIGHT);
|
|
25
|
+
const startHeight = (0, react_native_reanimated_1.useSharedValue)(MIN_HEIGHT);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
sheetHeight.value = (0, react_native_reanimated_1.withSpring)(startingPercentage ? startingPercentage * SCREEN_HEIGHT : MIN_HEIGHT, SPRING_CONFIG);
|
|
29
|
+
}, 1000);
|
|
30
|
+
}, []);
|
|
31
|
+
const panGesture = react_native_gesture_handler_1.Gesture.Pan()
|
|
32
|
+
.onStart(() => {
|
|
33
|
+
startHeight.value = sheetHeight.value;
|
|
34
|
+
})
|
|
35
|
+
.onUpdate((event) => {
|
|
36
|
+
let newHeight = startHeight.value - event.translationY;
|
|
37
|
+
if (newHeight > MAX_HEIGHT)
|
|
38
|
+
newHeight = MAX_HEIGHT;
|
|
39
|
+
if (newHeight < MIN_HEIGHT)
|
|
40
|
+
newHeight = MIN_HEIGHT;
|
|
41
|
+
sheetHeight.value = newHeight;
|
|
42
|
+
if (newHeight < COLLAPSE_HEIGHT) {
|
|
43
|
+
sheetHeight.value = (0, react_native_reanimated_1.withSpring)(MIN_HEIGHT, SPRING_CONFIG);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
|
|
47
|
+
height: sheetHeight.value < COLLAPSE_HEIGHT ? 0 : sheetHeight.value,
|
|
48
|
+
opacity: (0, react_native_reanimated_1.interpolate)(sheetHeight.value, [MIN_HEIGHT, COLLAPSE_HEIGHT], [0, 1], react_native_reanimated_1.Extrapolation.CLAMP),
|
|
49
|
+
transform: [
|
|
50
|
+
{
|
|
51
|
+
translateY: slideKeyboard +
|
|
52
|
+
Math.max(0, -sheetHeight.value) +
|
|
53
|
+
(slideKeyboard < 0 ? 0 : -safeBottom),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
}));
|
|
57
|
+
const handleAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
|
|
58
|
+
opacity: sheetHeight.value < COLLAPSE_HEIGHT ? 1 : 0,
|
|
59
|
+
transform: [
|
|
60
|
+
{
|
|
61
|
+
translateY: sheetHeight.value < COLLAPSE_HEIGHT ? 0 : (0, react_native_reanimated_1.withSpring)(20),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
}));
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [
|
|
66
|
+
handleAnimatedStyle,
|
|
67
|
+
atoms_1.layout.position.absolute,
|
|
68
|
+
atoms_1.bottom[4],
|
|
69
|
+
atoms_1.w.percent[100],
|
|
70
|
+
atoms_1.layout.flex.center,
|
|
71
|
+
atoms_1.zIndex[1],
|
|
72
|
+
], children: (0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.Pressable, { onPress: () => {
|
|
73
|
+
sheetHeight.value =
|
|
74
|
+
sheetHeight.value === MIN_HEIGHT
|
|
75
|
+
? (0, react_native_reanimated_1.withSpring)(MAX_HEIGHT, SPRING_CONFIG)
|
|
76
|
+
: (0, react_native_reanimated_1.withSpring)(MIN_HEIGHT, SPRING_CONFIG);
|
|
77
|
+
}, children: (0, jsx_runtime_1.jsx)(view_1.View, { style: [
|
|
78
|
+
atoms_1.p[1],
|
|
79
|
+
{
|
|
80
|
+
borderRadius: 999,
|
|
81
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
82
|
+
overflow: "hidden",
|
|
83
|
+
},
|
|
84
|
+
], children: (0, jsx_runtime_1.jsx)(lucide_react_native_1.ChevronUp, { size: 32, color: "white", style: { marginBottom: 1, marginTop: -1 } }) }) }) }), (0, jsx_runtime_1.jsxs)(AnimatedView, { style: [
|
|
85
|
+
animatedStyle,
|
|
86
|
+
isPlayerRatioGreater
|
|
87
|
+
? atoms_1.layout.position.relative
|
|
88
|
+
: atoms_1.layout.position.absolute,
|
|
89
|
+
atoms_1.bottom[0],
|
|
90
|
+
atoms_1.zIndex[1],
|
|
91
|
+
atoms_1.w.percent[100],
|
|
92
|
+
{
|
|
93
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
94
|
+
overflow: "visible",
|
|
95
|
+
borderTopLeftRadius: 16,
|
|
96
|
+
borderTopRightRadius: 16,
|
|
97
|
+
minWidth: "100%",
|
|
98
|
+
},
|
|
99
|
+
style,
|
|
100
|
+
], children: [(0, jsx_runtime_1.jsx)(view_1.View, { style: [atoms_1.layout.flex.row, atoms_1.layout.flex.justifyCenter, atoms_1.h[2]], children: (0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureDetector, { gesture: panGesture, children: (0, jsx_runtime_1.jsx)(view_1.View
|
|
101
|
+
// Make the touch area much larger, but keep the visible handle small
|
|
102
|
+
, {
|
|
103
|
+
// Make the touch area much larger, but keep the visible handle small
|
|
104
|
+
style: {
|
|
105
|
+
height: 30, // Large touch area
|
|
106
|
+
width: 120, // Wide enough for thumbs
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
justifyContent: "center",
|
|
109
|
+
//backgroundColor: "rgba(0,255,255,0.1)",
|
|
110
|
+
transform: [{ translateY: -30 }],
|
|
111
|
+
}, children: (0, jsx_runtime_1.jsx)(view_1.View, { style: [
|
|
112
|
+
atoms_1.w[32],
|
|
113
|
+
{
|
|
114
|
+
height: 6,
|
|
115
|
+
backgroundColor: "#eeeeee66",
|
|
116
|
+
borderRadius: 999,
|
|
117
|
+
transform: [{ translateY: 5 }],
|
|
118
|
+
},
|
|
119
|
+
] }) }) }) }), children] })] }));
|
|
120
|
+
}
|
|
121
|
+
Resizable.displayName = "ResizableChatSheet";
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextPrimitive = exports.textVariants = exports.Span = exports.Code = exports.Label = exports.Caption = exports.Body = exports.Subtitle = exports.Heading = exports.Text = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const class_variance_authority_1 = require("class-variance-authority");
|
|
7
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
10
|
+
const text_1 = require("./primitives/text");
|
|
11
|
+
Object.defineProperty(exports, "TextPrimitive", { enumerable: true, get: function () { return text_1.TextPrimitive; } });
|
|
12
|
+
// Text variants using class-variance-authority pattern
|
|
13
|
+
const textVariants = (0, class_variance_authority_1.cva)("", {
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
h1: "h1",
|
|
17
|
+
h2: "h2",
|
|
18
|
+
h3: "h3",
|
|
19
|
+
h4: "h4",
|
|
20
|
+
h5: "h5",
|
|
21
|
+
h6: "h6",
|
|
22
|
+
subtitle1: "subtitle1",
|
|
23
|
+
subtitle2: "subtitle2",
|
|
24
|
+
body1: "body1",
|
|
25
|
+
body2: "body2",
|
|
26
|
+
caption: "caption",
|
|
27
|
+
overline: "overline",
|
|
28
|
+
},
|
|
29
|
+
size: {
|
|
30
|
+
xs: "xs",
|
|
31
|
+
sm: "sm",
|
|
32
|
+
base: "base",
|
|
33
|
+
lg: "lg",
|
|
34
|
+
xl: "xl",
|
|
35
|
+
"2xl": "2xl",
|
|
36
|
+
"3xl": "3xl",
|
|
37
|
+
"4xl": "4xl",
|
|
38
|
+
},
|
|
39
|
+
weight: {
|
|
40
|
+
thin: "thin",
|
|
41
|
+
light: "light",
|
|
42
|
+
normal: "normal",
|
|
43
|
+
medium: "medium",
|
|
44
|
+
semibold: "semibold",
|
|
45
|
+
bold: "bold",
|
|
46
|
+
extrabold: "extrabold",
|
|
47
|
+
black: "black",
|
|
48
|
+
},
|
|
49
|
+
color: {
|
|
50
|
+
default: "default",
|
|
51
|
+
muted: "muted",
|
|
52
|
+
primary: "primary",
|
|
53
|
+
secondary: "secondary",
|
|
54
|
+
destructive: "destructive",
|
|
55
|
+
success: "success",
|
|
56
|
+
warning: "warning",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
variant: "body1",
|
|
61
|
+
size: "base",
|
|
62
|
+
weight: "normal",
|
|
63
|
+
color: "default",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
exports.textVariants = textVariants;
|
|
67
|
+
exports.Text = (0, react_1.forwardRef)(({ variant = undefined, size = undefined, weight = undefined, color = undefined, muted = false, bold = false, italic = false, underline = false, strikethrough = false, uppercase = false, lowercase = false, capitalize = false, center = false, right = false, justify = false, customColor, style, children, ...props }, ref) => {
|
|
68
|
+
// Create dynamic styles based on atoms
|
|
69
|
+
const styles = react_1.default.useMemo(() => createStyles(), []);
|
|
70
|
+
// Override props based on convenience props
|
|
71
|
+
const finalColor = customColor ? customColor : muted ? "muted" : color;
|
|
72
|
+
const finalTransform = uppercase
|
|
73
|
+
? "uppercase"
|
|
74
|
+
: lowercase
|
|
75
|
+
? "lowercase"
|
|
76
|
+
: capitalize
|
|
77
|
+
? "capitalize"
|
|
78
|
+
: "none";
|
|
79
|
+
const finalDecoration = underline && strikethrough
|
|
80
|
+
? "underline line-through"
|
|
81
|
+
: underline
|
|
82
|
+
? "underline"
|
|
83
|
+
: strikethrough
|
|
84
|
+
? "line-through"
|
|
85
|
+
: "none";
|
|
86
|
+
const finalAlign = center
|
|
87
|
+
? "center"
|
|
88
|
+
: right
|
|
89
|
+
? "right"
|
|
90
|
+
: justify
|
|
91
|
+
? "justify"
|
|
92
|
+
: "left";
|
|
93
|
+
// Get variant-specific styles
|
|
94
|
+
const variantStyle = styles[`${variant}Style`] || {};
|
|
95
|
+
const styleArr = (Array.isArray(style) ? style : [style || undefined]).filter((s) => s !== undefined);
|
|
96
|
+
return ((0, jsx_runtime_1.jsx)(text_1.TextPrimitive.Root, { ref: ref, variant: variant || "body1", size: size || "base", color: finalColor || "default", align: finalAlign, transform: finalTransform, decoration: finalDecoration, italic: italic, style: [variantStyle, ...styleArr], ...props, children: children }));
|
|
97
|
+
});
|
|
98
|
+
exports.Text.displayName = "Text";
|
|
99
|
+
// Convenience components for common text elements
|
|
100
|
+
exports.Heading = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: `h${level}`, ...props })));
|
|
101
|
+
exports.Heading.displayName = "Heading";
|
|
102
|
+
exports.Subtitle = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: level === 1 ? "subtitle1" : "subtitle2", ...props })));
|
|
103
|
+
exports.Subtitle.displayName = "Subtitle";
|
|
104
|
+
exports.Body = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: level === 1 ? "body1" : "body2", ...props })));
|
|
105
|
+
exports.Body.displayName = "Body";
|
|
106
|
+
exports.Caption = (0, react_1.forwardRef)((props, ref) => (0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: "caption", ...props }));
|
|
107
|
+
exports.Caption.displayName = "Caption";
|
|
108
|
+
exports.Label = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: "subtitle1", weight: "medium", ...props })));
|
|
109
|
+
exports.Label.displayName = "Label";
|
|
110
|
+
exports.Code = (0, react_1.forwardRef)(({ style, ...props }, ref) => {
|
|
111
|
+
const styles = react_1.default.useMemo(() => createStyles(), []);
|
|
112
|
+
// if style is not an array, convert it to an array
|
|
113
|
+
const styleArr = (Array.isArray(style) ? style : [style || undefined]).filter((s) => s !== undefined);
|
|
114
|
+
return (0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, style: [styles.codeStyle, ...styleArr], ...props });
|
|
115
|
+
});
|
|
116
|
+
exports.Code.displayName = "Code";
|
|
117
|
+
// Span component for inline text styling (inherits from parent)
|
|
118
|
+
exports.Span = (0, react_1.forwardRef)(({ children, ...props }, ref) => ((0, jsx_runtime_1.jsx)(text_1.TextPrimitive.Span, { ref: ref, ...props, children: children })));
|
|
119
|
+
exports.Span.displayName = "Span";
|
|
120
|
+
// Create atom-based styles
|
|
121
|
+
function createStyles() {
|
|
122
|
+
return react_native_1.StyleSheet.create({
|
|
123
|
+
// Variant-specific styles
|
|
124
|
+
h1Style: {
|
|
125
|
+
marginBottom: atoms_1.spacing[4],
|
|
126
|
+
},
|
|
127
|
+
h2Style: {
|
|
128
|
+
marginBottom: atoms_1.spacing[3],
|
|
129
|
+
},
|
|
130
|
+
h3Style: {
|
|
131
|
+
marginBottom: atoms_1.spacing[3],
|
|
132
|
+
},
|
|
133
|
+
h4Style: {
|
|
134
|
+
marginBottom: atoms_1.spacing[2],
|
|
135
|
+
},
|
|
136
|
+
h5Style: {
|
|
137
|
+
marginBottom: atoms_1.spacing[2],
|
|
138
|
+
},
|
|
139
|
+
h6Style: {
|
|
140
|
+
marginBottom: atoms_1.spacing[2],
|
|
141
|
+
},
|
|
142
|
+
subtitle1Style: {
|
|
143
|
+
marginBottom: atoms_1.spacing[2],
|
|
144
|
+
},
|
|
145
|
+
subtitle2Style: {
|
|
146
|
+
marginBottom: atoms_1.spacing[1],
|
|
147
|
+
},
|
|
148
|
+
body1Style: {
|
|
149
|
+
marginBottom: atoms_1.spacing[3],
|
|
150
|
+
},
|
|
151
|
+
body2Style: {
|
|
152
|
+
marginBottom: atoms_1.spacing[2],
|
|
153
|
+
},
|
|
154
|
+
captionStyle: {
|
|
155
|
+
marginBottom: atoms_1.spacing[1],
|
|
156
|
+
},
|
|
157
|
+
overlineStyle: {
|
|
158
|
+
marginBottom: atoms_1.spacing[1],
|
|
159
|
+
textTransform: "uppercase",
|
|
160
|
+
letterSpacing: 1,
|
|
161
|
+
},
|
|
162
|
+
labelStyle: {
|
|
163
|
+
marginBottom: atoms_1.spacing[1],
|
|
164
|
+
},
|
|
165
|
+
buttonStyle: {
|
|
166
|
+
textAlign: "center",
|
|
167
|
+
},
|
|
168
|
+
codeStyle: {
|
|
169
|
+
fontFamily: "monospace",
|
|
170
|
+
backgroundColor: atoms_1.colors["muted"],
|
|
171
|
+
paddingHorizontal: atoms_1.spacing[1],
|
|
172
|
+
paddingVertical: 2,
|
|
173
|
+
borderRadius: atoms_1.borderRadius.sm,
|
|
174
|
+
fontSize: 14,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Textarea = Textarea;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const atoms_1 = require("../../lib/theme/atoms");
|
|
7
|
+
function Textarea({ style, multiline = true, numberOfLines = 4, ...props }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { style: [
|
|
9
|
+
atoms_1.flex.values[1],
|
|
10
|
+
atoms_1.borders.width.thin,
|
|
11
|
+
atoms_1.borders.color.gray[400],
|
|
12
|
+
atoms_1.bg.gray[900],
|
|
13
|
+
atoms_1.p[3],
|
|
14
|
+
atoms_1.text.gray[200],
|
|
15
|
+
props.editable === false && { opacity: 0.5 },
|
|
16
|
+
{ borderRadius: 10 },
|
|
17
|
+
style,
|
|
18
|
+
], multiline: multiline, numberOfLines: numberOfLines, textAlignVertical: "top", ...props }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToast = useToast;
|
|
4
|
+
exports.Toast = Toast;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const portal_1 = require("@rn-primitives/portal");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
10
|
+
const theme_1 = require("../../lib/theme/theme");
|
|
11
|
+
const react_2 = require("react");
|
|
12
|
+
/**
|
|
13
|
+
* useToast - a hook to manage Toast state and provide a toastController.
|
|
14
|
+
* Returns a ready-to-render ToastComponent.
|
|
15
|
+
*/
|
|
16
|
+
function useToast(initial = {}) {
|
|
17
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
18
|
+
const [title, setTitle] = (0, react_1.useState)(initial.title ?? "");
|
|
19
|
+
const [description, setDescription] = (0, react_1.useState)(initial.description ?? "");
|
|
20
|
+
const [duration, setDuration] = (0, react_1.useState)(initial.duration ?? 3);
|
|
21
|
+
const [actionLabel, setActionLabel] = (0, react_1.useState)(initial.actionLabel ?? "Action");
|
|
22
|
+
const [onAction, setOnAction] = (0, react_1.useState)(initial.onAction);
|
|
23
|
+
const show = (0, react_2.useCallback)((toastTitle, toastDescription, options) => {
|
|
24
|
+
setTitle(toastTitle);
|
|
25
|
+
setDescription(toastDescription ?? "");
|
|
26
|
+
setDuration(options?.duration ?? 3);
|
|
27
|
+
setActionLabel(options?.actionLabel ?? "Action");
|
|
28
|
+
setOnAction(options?.onAction);
|
|
29
|
+
setOpen(true);
|
|
30
|
+
}, []);
|
|
31
|
+
const hide = (0, react_2.useCallback)(() => {
|
|
32
|
+
setOpen(false);
|
|
33
|
+
}, []);
|
|
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
|
+
return {
|
|
37
|
+
open,
|
|
38
|
+
title,
|
|
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,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function Toast({ open, onOpenChange, title, description, actionLabel = "Action", onAction, duration = 3, }) {
|
|
54
|
+
const [seconds, setSeconds] = (0, react_1.useState)(duration);
|
|
55
|
+
const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
56
|
+
const { theme } = (0, theme_1.useTheme)();
|
|
57
|
+
const [fadeAnim] = (0, react_1.useState)(new react_native_1.Animated.Value(0));
|
|
58
|
+
const { width } = (0, react_native_1.useWindowDimensions)();
|
|
59
|
+
const isWeb = react_native_1.Platform.OS === "web";
|
|
60
|
+
const isDesktop = isWeb && width >= 768;
|
|
61
|
+
const containerPosition = isDesktop
|
|
62
|
+
? {
|
|
63
|
+
top: undefined,
|
|
64
|
+
bottom: theme.spacing[4],
|
|
65
|
+
right: theme.spacing[4], // <-- use spacing, not 1
|
|
66
|
+
alignItems: "flex-end",
|
|
67
|
+
minWidth: 400,
|
|
68
|
+
width: 400,
|
|
69
|
+
// Do NOT set left at all
|
|
70
|
+
}
|
|
71
|
+
: {
|
|
72
|
+
bottom: insets.bottom + theme.spacing[1],
|
|
73
|
+
left: 0,
|
|
74
|
+
right: 0,
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
width: "100%",
|
|
77
|
+
maxWidth: undefined,
|
|
78
|
+
};
|
|
79
|
+
(0, react_1.useEffect)(() => {
|
|
80
|
+
let interval = null;
|
|
81
|
+
if (open) {
|
|
82
|
+
setSeconds(duration);
|
|
83
|
+
react_native_1.Animated.timing(fadeAnim, {
|
|
84
|
+
toValue: 1,
|
|
85
|
+
duration: 200,
|
|
86
|
+
useNativeDriver: true,
|
|
87
|
+
}).start();
|
|
88
|
+
interval = setInterval(() => {
|
|
89
|
+
setSeconds((prev) => {
|
|
90
|
+
if (prev <= 1) {
|
|
91
|
+
onOpenChange(false);
|
|
92
|
+
if (interval)
|
|
93
|
+
clearInterval(interval);
|
|
94
|
+
return duration;
|
|
95
|
+
}
|
|
96
|
+
return prev - 1;
|
|
97
|
+
});
|
|
98
|
+
}, 1000);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (interval)
|
|
102
|
+
clearInterval(interval);
|
|
103
|
+
react_native_1.Animated.timing(fadeAnim, {
|
|
104
|
+
toValue: 0,
|
|
105
|
+
duration: 150,
|
|
106
|
+
useNativeDriver: true,
|
|
107
|
+
}).start();
|
|
108
|
+
setSeconds(duration);
|
|
109
|
+
}
|
|
110
|
+
return () => {
|
|
111
|
+
if (interval)
|
|
112
|
+
clearInterval(interval);
|
|
113
|
+
};
|
|
114
|
+
// eslint-disable-next-line
|
|
115
|
+
}, [open, duration]);
|
|
116
|
+
if (!open)
|
|
117
|
+
return null;
|
|
118
|
+
return ((0, jsx_runtime_1.jsx)(portal_1.Portal, { name: "toast", children: (0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { style: [styles.container, containerPosition, { opacity: fadeAnim }], pointerEvents: "box-none", children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [
|
|
119
|
+
styles.toast,
|
|
120
|
+
{
|
|
121
|
+
backgroundColor: theme.colors.secondary,
|
|
122
|
+
borderColor: theme.colors.border,
|
|
123
|
+
borderRadius: theme.borderRadius.xl,
|
|
124
|
+
flexDirection: "column",
|
|
125
|
+
justifyContent: "space-between",
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
padding: theme.spacing[4],
|
|
128
|
+
width: isDesktop ? "100%" : "95%",
|
|
129
|
+
},
|
|
130
|
+
], children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { gap: theme.spacing[1], width: "100%" }, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [
|
|
131
|
+
{
|
|
132
|
+
color: theme.colors.foreground,
|
|
133
|
+
fontSize: 16,
|
|
134
|
+
fontWeight: "500",
|
|
135
|
+
},
|
|
136
|
+
], children: title }), description ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [{ color: theme.colors.foreground, fontSize: 14 }], children: description })) : null] }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: {
|
|
137
|
+
gap: theme.spacing[1],
|
|
138
|
+
flexDirection: "row",
|
|
139
|
+
justifyContent: "flex-end",
|
|
140
|
+
width: "100%",
|
|
141
|
+
}, children: [onAction && ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { style: [
|
|
142
|
+
styles.button,
|
|
143
|
+
{
|
|
144
|
+
borderColor: theme.colors.primary,
|
|
145
|
+
paddingHorizontal: theme.spacing[4],
|
|
146
|
+
paddingVertical: theme.spacing[2],
|
|
147
|
+
},
|
|
148
|
+
], onPress: onAction, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { color: theme.colors.foreground }, children: actionLabel }) })), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { style: [
|
|
149
|
+
styles.button,
|
|
150
|
+
{
|
|
151
|
+
borderColor: theme.colors.primary,
|
|
152
|
+
paddingHorizontal: theme.spacing[4],
|
|
153
|
+
paddingVertical: theme.spacing[2],
|
|
154
|
+
},
|
|
155
|
+
], onPress: () => onOpenChange(false), children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { color: theme.colors.foreground }, children: "Close" }) })] })] }) }) }));
|
|
156
|
+
}
|
|
157
|
+
const styles = react_native_1.StyleSheet.create({
|
|
158
|
+
container: {
|
|
159
|
+
position: "absolute",
|
|
160
|
+
zIndex: 1000,
|
|
161
|
+
paddingHorizontal: 16,
|
|
162
|
+
},
|
|
163
|
+
toast: {
|
|
164
|
+
opacity: 0.95,
|
|
165
|
+
borderWidth: 1,
|
|
166
|
+
gap: 8,
|
|
167
|
+
},
|
|
168
|
+
button: {
|
|
169
|
+
borderWidth: 1,
|
|
170
|
+
borderRadius: 8,
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
justifyContent: "center",
|
|
173
|
+
backgroundColor: "transparent",
|
|
174
|
+
},
|
|
175
|
+
});
|