@streamplace/components 0.7.26 → 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.
Files changed (61) hide show
  1. package/dist/components/chat/chat-box.js +2 -2
  2. package/dist/components/chat/chat.js +1 -1
  3. package/dist/components/mobile-player/ui/autoplay-button.js +1 -0
  4. package/dist/components/mobile-player/ui/viewer-context-menu.js +1 -1
  5. package/dist/components/mobile-player/ui/viewer-loading-overlay.js +2 -2
  6. package/dist/components/mobile-player/use-webrtc.js +37 -1
  7. package/dist/components/mobile-player/video.native.js +10 -1
  8. package/dist/components/ui/button.js +107 -155
  9. package/dist/components/ui/dialog.js +83 -116
  10. package/dist/components/ui/dropdown.js +41 -18
  11. package/dist/components/ui/input.js +53 -128
  12. package/dist/components/ui/primitives/button.js +0 -2
  13. package/dist/components/ui/primitives/modal.js +2 -2
  14. package/dist/components/ui/primitives/text.js +48 -8
  15. package/dist/components/ui/text.js +37 -66
  16. package/dist/components/ui/toast.js +78 -40
  17. package/dist/components/ui/view.js +28 -41
  18. package/dist/crypto-polyfill.js +0 -0
  19. package/dist/crypto-polyfill.native.js +24 -0
  20. package/dist/index.js +1 -0
  21. package/dist/lib/theme/index.js +1 -2
  22. package/dist/lib/theme/theme.js +106 -54
  23. package/dist/lib/theme/tokens.js +94 -1
  24. package/dist/livestream-store/chat.js +0 -2
  25. package/dist/livestream-store/stream-key.js +1 -1
  26. package/dist/player-store/player-provider.js +10 -2
  27. package/dist/player-store/single-player-provider.js +1 -1
  28. package/dist/streamplace-store/stream.js +1 -1
  29. package/dist/ui/index.js +2 -3
  30. package/node-compile-cache/v22.15.0-x64-efe9a9df-0/37be0eec +0 -0
  31. package/package.json +3 -2
  32. package/src/components/chat/chat-box.tsx +6 -3
  33. package/src/components/chat/chat.tsx +1 -0
  34. package/src/components/mobile-player/ui/autoplay-button.tsx +1 -0
  35. package/src/components/mobile-player/ui/viewer-context-menu.tsx +2 -2
  36. package/src/components/mobile-player/ui/viewer-loading-overlay.tsx +2 -2
  37. package/src/components/mobile-player/use-webrtc.tsx +41 -1
  38. package/src/components/mobile-player/video.native.tsx +19 -4
  39. package/src/components/ui/button.tsx +110 -172
  40. package/src/components/ui/dialog.tsx +96 -138
  41. package/src/components/ui/dropdown.tsx +60 -22
  42. package/src/components/ui/input.tsx +57 -144
  43. package/src/components/ui/primitives/button.tsx +0 -2
  44. package/src/components/ui/primitives/modal.tsx +0 -2
  45. package/src/components/ui/primitives/text.tsx +51 -8
  46. package/src/components/ui/text.tsx +42 -67
  47. package/src/components/ui/toast.tsx +108 -90
  48. package/src/components/ui/view.tsx +27 -41
  49. package/src/crypto-polyfill.native.tsx +24 -0
  50. package/src/crypto-polyfill.tsx +0 -0
  51. package/src/index.tsx +2 -0
  52. package/src/lib/theme/index.ts +0 -2
  53. package/src/lib/theme/theme.tsx +179 -72
  54. package/src/lib/theme/tokens.ts +97 -0
  55. package/src/livestream-store/chat.tsx +0 -3
  56. package/src/livestream-store/stream-key.tsx +1 -1
  57. package/src/player-store/player-provider.tsx +13 -1
  58. package/src/player-store/single-player-provider.tsx +1 -1
  59. package/src/streamplace-store/stream.tsx +1 -1
  60. package/src/ui/index.ts +0 -2
  61. package/tsconfig.tsbuildinfo +1 -1
@@ -1,7 +1,8 @@
1
1
  import { cva, type VariantProps } from "class-variance-authority";
2
2
  import React, { forwardRef } from "react";
3
- import { Platform, StyleSheet, TouchableWithoutFeedback } from "react-native";
3
+ import { TouchableWithoutFeedback } from "react-native";
4
4
  import { useTheme } from "../../lib/theme/theme";
5
+ import * as zero from "../../ui";
5
6
  import { InputPrimitive, InputPrimitiveProps } from "./primitives/input";
6
7
 
7
8
  const inputVariants = cva("", {
@@ -54,26 +55,66 @@ export const Input = forwardRef<any, InputProps>(
54
55
  },
55
56
  ref,
56
57
  ) => {
57
- const { theme } = useTheme();
58
+ const { zero: zt, theme } = useTheme();
58
59
  const [isFocused, setIsFocused] = React.useState(false);
59
60
  const inputRef = React.useRef<any>(null);
60
61
 
61
- // Create dynamic styles based on theme
62
- const styles = React.useMemo(() => createStyles(theme), [theme]);
63
-
64
- // Get variant and size styles
62
+ // Get variant and size styles using theme.zero
65
63
  const containerStyles = React.useMemo(() => {
66
- const variantStyle = styles[`${variant}Container` as keyof typeof styles];
67
- const sizeStyle = styles[`${size}Container` as keyof typeof styles];
68
- const focusStyle = isFocused ? styles.focusedContainer : null;
69
- return [variantStyle, sizeStyle, focusStyle];
70
- }, [variant, size, styles, isFocused]);
64
+ const variantStyle = (() => {
65
+ switch (variant) {
66
+ case "filled":
67
+ return [zt.bg.muted];
68
+ case "underlined":
69
+ return [
70
+ zt.bg.transparent,
71
+ zt.border.bottom.default,
72
+ { borderRadius: 0, paddingHorizontal: 0 },
73
+ ];
74
+ default:
75
+ return [zt.bg.background, zt.border.default];
76
+ }
77
+ })();
78
+
79
+ const sizeStyle = (() => {
80
+ switch (size) {
81
+ case "sm":
82
+ return [
83
+ zero.px[3],
84
+ zero.py[2],
85
+ { borderRadius: zero.borderRadius.md },
86
+ ];
87
+ case "lg":
88
+ return [
89
+ zero.px[4],
90
+ zero.py[3],
91
+ { borderRadius: zero.borderRadius.md },
92
+ ];
93
+ default:
94
+ return [
95
+ zero.px[3],
96
+ zero.py[2],
97
+ { borderRadius: zero.borderRadius.md },
98
+ ];
99
+ }
100
+ })();
101
+
102
+ const focusStyle = isFocused ? zt.border.primary : null;
103
+ return [variantStyle, sizeStyle, focusStyle].filter(Boolean);
104
+ }, [variant, size, zt, isFocused]);
71
105
 
72
106
  const textStyles = React.useMemo(() => {
73
- const variantTextStyle = styles[`${variant}Input` as keyof typeof styles];
74
- const sizeTextStyle = styles[`${size}Input` as keyof typeof styles];
75
- return [variantTextStyle, sizeTextStyle];
76
- }, [variant, size, styles]);
107
+ const baseTextStyle = [zt.text.foreground, zt.bg.transparent];
108
+
109
+ switch (size) {
110
+ case "sm":
111
+ return [...baseTextStyle, zt.text.sm];
112
+ case "lg":
113
+ return [...baseTextStyle, zt.text.lg];
114
+ default:
115
+ return [...baseTextStyle, zt.text.md];
116
+ }
117
+ }, [size, zt]);
77
118
 
78
119
  const handleFocus = React.useCallback(
79
120
  (event: any) => {
@@ -144,12 +185,7 @@ export const Input = forwardRef<any, InputProps>(
144
185
  error={!!error}
145
186
  onFocus={handleFocus}
146
187
  onBlur={handleBlur}
147
- style={[
148
- textStyles,
149
- styles.inputInContainer,
150
- inputStyle,
151
- { outline: "none" },
152
- ]}
188
+ style={[textStyles, inputStyle, { outline: "none" }]}
153
189
  placeholderTextColor={
154
190
  disabled ? theme.colors.textDisabled : theme.colors.textMuted
155
191
  }
@@ -223,128 +259,5 @@ export const Input = forwardRef<any, InputProps>(
223
259
 
224
260
  Input.displayName = "Input";
225
261
 
226
- // Create theme-aware styles
227
- function createStyles(theme: any) {
228
- return StyleSheet.create({
229
- // Variant styles for containers
230
- defaultContainer: {
231
- backgroundColor: theme.colors.background,
232
- borderWidth: 1,
233
- borderColor: theme.colors.border,
234
- borderRadius: theme.borderRadius.md,
235
- },
236
-
237
- filledContainer: {
238
- backgroundColor: theme.colors.muted,
239
- borderWidth: 0,
240
- borderRadius: theme.borderRadius.md,
241
- },
242
-
243
- underlinedContainer: {
244
- backgroundColor: "transparent",
245
- borderWidth: 0,
246
- borderBottomWidth: 1,
247
- borderBottomColor: theme.colors.border,
248
- borderRadius: 0,
249
- paddingHorizontal: 0,
250
- },
251
-
252
- // Variant styles for inputs
253
- defaultInput: {
254
- color: theme.colors.text,
255
- backgroundColor: "transparent",
256
- },
257
-
258
- filledInput: {
259
- color: theme.colors.text,
260
- backgroundColor: "transparent",
261
- },
262
-
263
- underlinedInput: {
264
- color: theme.colors.text,
265
- backgroundColor: "transparent",
266
- },
267
-
268
- // Size styles for containers
269
- smContainer: {
270
- paddingHorizontal: theme.spacing[3],
271
- paddingVertical: theme.spacing[2],
272
- minHeight: theme.touchTargets.minimum - 8,
273
- },
274
-
275
- mdContainer: {
276
- paddingHorizontal: theme.spacing[3],
277
- paddingVertical: theme.spacing[3],
278
- minHeight: theme.touchTargets.minimum,
279
- },
280
-
281
- lgContainer: {
282
- paddingHorizontal: theme.spacing[4],
283
- paddingVertical: theme.spacing[4],
284
- minHeight: theme.touchTargets.comfortable,
285
- },
286
-
287
- // Size styles for inputs
288
- smInput: {
289
- fontSize: 14,
290
- lineHeight: 18,
291
- ...Platform.select({
292
- ios: {
293
- paddingVertical: 0,
294
- },
295
- android: {
296
- paddingVertical: 0,
297
- textAlignVertical: "center",
298
- },
299
- }),
300
- },
301
-
302
- mdInput: {
303
- fontSize: 16,
304
- lineHeight: 20,
305
- ...Platform.select({
306
- ios: {
307
- paddingVertical: 0,
308
- },
309
- android: {
310
- paddingVertical: 0,
311
- textAlignVertical: "center",
312
- },
313
- }),
314
- },
315
-
316
- lgInput: {
317
- fontSize: 18,
318
- lineHeight: 22,
319
- ...Platform.select({
320
- ios: {
321
- paddingVertical: 0,
322
- },
323
- android: {
324
- paddingVertical: 0,
325
- textAlignVertical: "center",
326
- },
327
- }),
328
- },
329
-
330
- // Special style for inputs inside containers
331
- inputInContainer: {
332
- flex: 1,
333
- paddingHorizontal: 0,
334
- paddingVertical: 0,
335
- borderWidth: 0,
336
- backgroundColor: "transparent",
337
- minHeight: "auto",
338
- borderRadius: 0,
339
- },
340
-
341
- // Focus styles
342
- focusedContainer: {
343
- borderColor: theme.colors.primary,
344
- borderWidth: 1,
345
- },
346
- });
347
- }
348
-
349
262
  // Export input variants for external use
350
263
  export { inputVariants };
@@ -245,7 +245,6 @@ const primitiveStyles = StyleSheet.create({
245
245
  alignItems: "center",
246
246
  justifyContent: "center",
247
247
  minHeight: 44, // iOS minimum touch target
248
- minWidth: 44,
249
248
  },
250
249
  disabled: {
251
250
  opacity: 0.5,
@@ -254,7 +253,6 @@ const primitiveStyles = StyleSheet.create({
254
253
  flexDirection: "row",
255
254
  alignItems: "center",
256
255
  justifyContent: "center",
257
- flex: 1,
258
256
  },
259
257
  text: {
260
258
  textAlign: "center" as const,
@@ -33,7 +33,6 @@ export const ModalRoot = forwardRef<View, ModalPrimitiveProps>(
33
33
  onRequestClose,
34
34
  animationType = "fade",
35
35
  presentationStyle = Platform.OS === "ios" ? "pageSheet" : "fullScreen",
36
- transparent = true,
37
36
  statusBarTranslucent = Platform.OS === "android",
38
37
  ...props
39
38
  },
@@ -57,7 +56,6 @@ export const ModalRoot = forwardRef<View, ModalPrimitiveProps>(
57
56
  onRequestClose={handleRequestClose}
58
57
  animationType={animationType}
59
58
  presentationStyle={presentationStyle}
60
- transparent={transparent}
61
59
  statusBarTranslucent={statusBarTranslucent}
62
60
  {...props}
63
61
  >
@@ -129,6 +129,18 @@ const sizeMap = {
129
129
  "4xl": 36,
130
130
  } as const;
131
131
 
132
+ // Size-specific line height mapping (provides better default line heights for each size)
133
+ const sizeLineHeightMap = {
134
+ xs: 16, // 12px * 1.33 = tight but readable
135
+ sm: 20, // 14px * 1.43 = good for small text
136
+ base: 24, // 16px * 1.5 = standard body text
137
+ lg: 28, // 18px * 1.56 = comfortable for larger text
138
+ xl: 30, // 20px * 1.5 = balanced
139
+ "2xl": 32, // 24px * 1.33 = tighter for headings
140
+ "3xl": 36, // 30px * 1.2 = tight for large headings
141
+ "4xl": 40, // 36px * 1.11 = very tight for display text
142
+ } as const;
143
+
132
144
  // Weight mapping
133
145
  const weightMap = {
134
146
  thin: "100",
@@ -199,12 +211,12 @@ const getVariantStyles = () => {
199
211
  };
200
212
  } else if (typographicPlatform === "android") {
201
213
  return {
202
- h1: platformTypography.headline1,
203
- h2: platformTypography.headline2,
204
- h3: platformTypography.headline3,
205
- h4: platformTypography.headline4,
206
- h5: platformTypography.headline5,
207
- h6: platformTypography.headline6,
214
+ h1: platformTypography.headline4, // 34px instead of 96px
215
+ h2: platformTypography.headline5, // 24px instead of 60px
216
+ h3: platformTypography.headline6, // 20px instead of 48px
217
+ h4: platformTypography.subtitle1, // 16px instead of 34px
218
+ h5: platformTypography.subtitle2, // 14px instead of 24px
219
+ h6: platformTypography.subtitle2, // 14px - consistent with h5
208
220
  subtitle1: platformTypography.subtitle1,
209
221
  subtitle2: platformTypography.subtitle2,
210
222
  body1: platformTypography.body1,
@@ -286,9 +298,16 @@ export const TextRoot = forwardRef<RNText, TextPrimitiveProps>(
286
298
 
287
299
  // Apply explicit prop styles (these should override inherited and variant)
288
300
 
289
- // Apply size
301
+ // Apply size (with corresponding line height if not explicitly set)
290
302
  ...(size && {
291
303
  fontSize: typeof size === "number" ? size : sizeMap[size],
304
+ // Apply size-specific line height only if leading is not explicitly set
305
+ ...(leading === undefined && {
306
+ lineHeight:
307
+ typeof size === "number"
308
+ ? size // Auto line height for numeric sizes
309
+ : sizeLineHeightMap[size],
310
+ }),
292
311
  }),
293
312
 
294
313
  // Apply weight
@@ -360,6 +379,23 @@ export const TextRoot = forwardRef<RNText, TextPrimitiveProps>(
360
379
  finalStyles.color = finalStyles.color as ColorValue;
361
380
 
362
381
  // Create context value for children
382
+ // Process custom styles to auto-add line height for fontSize
383
+ const processedStyle = Array.isArray(style)
384
+ ? style
385
+ : [style].filter(Boolean);
386
+ const enhancedStyles = processedStyle.map((styleObj) => {
387
+ if (styleObj && typeof styleObj === "object" && "fontSize" in styleObj) {
388
+ const fontSize = styleObj.fontSize;
389
+ if (typeof fontSize === "number" && !styleObj.lineHeight && !leading) {
390
+ return {
391
+ ...styleObj,
392
+ lineHeight: fontSize * 1.2,
393
+ };
394
+ }
395
+ }
396
+ return styleObj;
397
+ });
398
+
363
399
  const contextValue: TextContextValue = {
364
400
  fontSize:
365
401
  typeof finalStyles.fontSize === "number"
@@ -386,7 +422,7 @@ export const TextRoot = forwardRef<RNText, TextPrimitiveProps>(
386
422
 
387
423
  return (
388
424
  <TextContext.Provider value={contextValue}>
389
- <RNText ref={ref} style={[finalStyles, style]} {...props}>
425
+ <RNText ref={ref} style={[finalStyles, ...enhancedStyles]} {...props}>
390
426
  {children}
391
427
  </RNText>
392
428
  </TextContext.Provider>
@@ -438,6 +474,13 @@ export function createTextStyle(
438
474
  if (props.size) {
439
475
  style.fontSize =
440
476
  typeof props.size === "number" ? props.size : sizeMap[props.size];
477
+ // Apply size-specific line height only if leading is not explicitly set
478
+ if (props.leading === undefined) {
479
+ style.lineHeight =
480
+ typeof props.size === "number"
481
+ ? props.size * 1.2 // Auto line height for numeric sizes
482
+ : sizeLineHeightMap[props.size];
483
+ }
441
484
  }
442
485
 
443
486
  if (props.weight) {
@@ -1,7 +1,8 @@
1
1
  import { cva, type VariantProps } from "class-variance-authority";
2
2
  import React, { forwardRef } from "react";
3
- import { StyleSheet } from "react-native";
4
- import { colors, borderRadius as radius, spacing } from "../../lib/theme/atoms";
3
+ import { useTheme } from "../../lib/theme/theme";
4
+ import { fontFamilies } from "../../lib/theme/tokens";
5
+ import * as zero from "../../ui";
5
6
  import { TextPrimitive, TextPrimitiveProps } from "./primitives/text";
6
7
 
7
8
  // Text variants using class-variance-authority pattern
@@ -103,8 +104,7 @@ export const Text = forwardRef<any, TextProps>(
103
104
  },
104
105
  ref,
105
106
  ) => {
106
- // Create dynamic styles based on atoms
107
- const styles = React.useMemo(() => createStyles(), []);
107
+ const { zero: zt } = useTheme();
108
108
 
109
109
  // Override props based on convenience props
110
110
  const finalColor = customColor ? customColor : muted ? "muted" : color;
@@ -134,8 +134,31 @@ export const Text = forwardRef<any, TextProps>(
134
134
  ? "justify"
135
135
  : "left";
136
136
 
137
- // Get variant-specific styles
138
- const variantStyle = styles[`${variant}Style` as keyof typeof styles] || {};
137
+ // Get variant-specific styles using theme.zero
138
+ const variantStyle = React.useMemo(() => {
139
+ switch (variant) {
140
+ case "h1":
141
+ return zero.my[6];
142
+ case "h2":
143
+ case "h3":
144
+ return zero.my[4];
145
+ case "h4":
146
+ case "h5":
147
+ case "h6":
148
+ case "subtitle1":
149
+ return zero.my[2];
150
+ case "subtitle2":
151
+ case "caption":
152
+ case "overline":
153
+ return zero.my[1];
154
+ case "body1":
155
+ return zero.my[4];
156
+ case "body2":
157
+ return zero.my[2];
158
+ default:
159
+ return {};
160
+ }
161
+ }, [variant, zt]);
139
162
 
140
163
  const styleArr = (
141
164
  Array.isArray(style) ? style : [style || undefined]
@@ -209,13 +232,24 @@ export const Label = forwardRef<any, Omit<TextProps, "variant">>(
209
232
  Label.displayName = "Label";
210
233
 
211
234
  export const Code = forwardRef<any, TextProps>(({ style, ...props }, ref) => {
212
- const styles = React.useMemo(() => createStyles(), []);
235
+ const { zero: zt } = useTheme();
236
+
237
+ const codeStyle = React.useMemo(
238
+ () => [
239
+ {
240
+ borderRadius: zero.borderRadius.sm,
241
+ fontFamily: fontFamilies.monoRegular,
242
+ },
243
+ ],
244
+ [zt],
245
+ );
246
+
213
247
  // if style is not an array, convert it to an array
214
248
  const styleArr = (Array.isArray(style) ? style : [style || undefined]).filter(
215
249
  (s) => s !== undefined,
216
250
  );
217
251
 
218
- return <Text ref={ref} style={[styles.codeStyle, ...styleArr]} {...props} />;
252
+ return <Text ref={ref} style={[...codeStyle, ...styleArr]} {...props} />;
219
253
  });
220
254
 
221
255
  Code.displayName = "Code";
@@ -264,65 +298,6 @@ export const Span = forwardRef<
264
298
 
265
299
  Span.displayName = "Span";
266
300
 
267
- // Create atom-based styles
268
- function createStyles() {
269
- return StyleSheet.create({
270
- // Variant-specific styles
271
- h1Style: {
272
- marginBottom: spacing[4],
273
- },
274
- h2Style: {
275
- marginBottom: spacing[3],
276
- },
277
- h3Style: {
278
- marginBottom: spacing[3],
279
- },
280
- h4Style: {
281
- marginBottom: spacing[2],
282
- },
283
- h5Style: {
284
- marginBottom: spacing[2],
285
- },
286
- h6Style: {
287
- marginBottom: spacing[2],
288
- },
289
- subtitle1Style: {
290
- marginBottom: spacing[2],
291
- },
292
- subtitle2Style: {
293
- marginBottom: spacing[1],
294
- },
295
- body1Style: {
296
- marginBottom: spacing[3],
297
- },
298
- body2Style: {
299
- marginBottom: spacing[2],
300
- },
301
- captionStyle: {
302
- marginBottom: spacing[1],
303
- },
304
- overlineStyle: {
305
- marginBottom: spacing[1],
306
- textTransform: "uppercase",
307
- letterSpacing: 1,
308
- },
309
- labelStyle: {
310
- marginBottom: spacing[1],
311
- },
312
- buttonStyle: {
313
- textAlign: "center",
314
- },
315
- codeStyle: {
316
- fontFamily: "monospace",
317
- backgroundColor: colors["muted"],
318
- paddingHorizontal: spacing[1],
319
- paddingVertical: 2,
320
- borderRadius: radius.sm,
321
- fontSize: 14,
322
- },
323
- });
324
- }
325
-
326
301
  // Export text variants for external use
327
302
  export { textVariants };
328
303