@plexui/react-native 0.2.26 → 0.2.27

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.
@@ -1,8 +1,10 @@
1
1
  import { useState, type ReactNode } from "react"
2
- import { Linking, Platform, Text as RNText, type GestureResponderEvent, type StyleProp, type TextStyle } from "react-native"
2
+ import { Linking, Platform, Pressable, Text as RNText, type GestureResponderEvent, type StyleProp, type TextStyle } from "react-native"
3
3
  import { controlHighlight } from "../../theme/material"
4
4
  import { useTheme } from "../../theme/ThemeProvider"
5
5
  import type { FontWeightName } from "../../theme/types"
6
+ import { Button, buttonColors } from "../Button/Button"
7
+ import { Text } from "../Text/Text"
6
8
 
7
9
  export type TextLinkProps = {
8
10
  /** The link's text; an icon after it (an external link's arrow) stands on the text's line. */
@@ -19,6 +21,12 @@ export type TextLinkProps = {
19
21
  onPress?: (event: GestureResponderEvent) => void
20
22
  /** The weight of the link's text; it takes the text's own around it by default (`--link-font-weight: inherit`). */
21
23
  weight?: FontWeightName
24
+ /**
25
+ * A small action of its own outside running text (Restore Purchases under a store's plans): on iOS the text alone
26
+ * at the subheadline (15/20, regular) in the link color with a 44pt target and the system's pressed fade; on Android
27
+ * Material's small text button. @default false
28
+ */
29
+ standalone?: boolean
22
30
  accessibilityLabel?: string
23
31
  testID?: string
24
32
  style?: StyleProp<TextStyle>
@@ -36,19 +44,54 @@ const underlineOffset = (value: unknown) => (typeof value === "number" ? value :
36
44
  * row in the Plex Android look (the text's ink at 11%, white at 5% at night). With `href` it is a `link` and opens the
37
45
  * URL (an `<a>` on the web, a new tab for an external one); with only `onPress` it is a `button`.
38
46
  */
39
- export function TextLink({ children, href, primary = false, underline = !primary, forceExternal, onPress, weight, accessibilityLabel, testID, style }: TextLinkProps) {
47
+ export function TextLink({ children, href, primary = false, underline = !primary, forceExternal, onPress, weight, standalone = false, accessibilityLabel, testID, style }: TextLinkProps) {
40
48
  const theme = useTheme()
41
49
  const [pressed, setPressed] = useState(false)
42
50
  const external = forceExternal ?? EXTERNAL.test(href ?? "")
43
51
  const web = Platform.OS === "web"
44
52
  const press = (event: GestureResponderEvent) => {
45
53
  onPress?.(event)
54
+ // On the web the link is an anchor the browser opens (a new tab for an external one)
46
55
  if (!href || web || prevented(event)) return
47
56
  void Linking.openURL(href).catch(() => {})
48
57
  }
49
- const actionable = href != null || onPress != null
50
58
  // react-native-web draws a Text with `href` as an anchor: the browser opens it, a new tab for an external one
51
59
  const anchor = web && href ? { href, hrefAttrs: external ? { target: "_blank", rel: "noopener noreferrer" } : undefined } : null
60
+ if (standalone) {
61
+ const role = href ? "link" : "button"
62
+ // A pressable is a View, which react-native-web draws as an anchor with the same `href`
63
+ const link = anchor as object | null
64
+ if (theme.isAndroid)
65
+ return (
66
+ <Button {...link} variant="ghost" color="primary" size="sm" onPress={press} accessibilityRole={role} accessibilityLabel={accessibilityLabel} testID={testID}>
67
+ {weight != null || style != null ? (
68
+ // A caller's face or type over the button's label (14/20 Medium in the primary)
69
+ <Text weight={weight ?? "medium"} color={buttonColors(theme, "primary", "ghost", false, false).text} style={[{ fontSize: 14, lineHeight: 20 }, style]}>
70
+ {children}
71
+ </Text>
72
+ ) : (
73
+ children
74
+ )}
75
+ </Button>
76
+ )
77
+ return (
78
+ // UIButton's plain style: no frame, the text faded while held, the target 44 tall
79
+ <Pressable
80
+ {...link}
81
+ onPress={press}
82
+ accessibilityRole={role}
83
+ accessibilityLabel={accessibilityLabel}
84
+ testID={testID}
85
+ hitSlop={{ left: 8, right: 8 }}
86
+ style={({ pressed: held }) => ({ minHeight: 44, justifyContent: "center", alignSelf: "flex-start", opacity: held ? 0.35 : 1 })}
87
+ >
88
+ <Text weight={weight ?? "regular"} color={theme.color("--link-primary-text-color", theme.colors.textAccent)} style={[{ fontSize: 15, lineHeight: 20 }, style]}>
89
+ {children}
90
+ </Text>
91
+ </Pressable>
92
+ )
93
+ }
94
+ const actionable = href != null || onPress != null
52
95
  // iOS's own Text highlights a press (as UITextView's links); elsewhere the press layer of a row
53
96
  const highlight = theme.isIOS && !web ? null : pressed ? { backgroundColor: controlHighlight(theme.scheme) } : null
54
97
  return (
package/src/index.ts CHANGED
@@ -45,7 +45,7 @@ export {
45
45
  } from "./components/Toolbar/Toolbar"
46
46
  export {
47
47
  TabBar,
48
- useTabBarMinimize,
48
+ useTabBarMetrics, useTabBarMinimize,
49
49
  type TabBarBackground,
50
50
  type TabBarBadgeColor,
51
51
  type TabBarItemProps,
@@ -95,7 +95,7 @@ export { Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVari
95
95
  export { BottomActions, type BottomActionsBackground, type BottomActionsProps } from "./components/BottomActions/BottomActions"
96
96
  export { IntroHeader, type IntroHeaderAlign, type IntroHeaderProps } from "./components/IntroHeader/IntroHeader"
97
97
  export { Card, cardColors, type CardColor, type CardMediaProps, type CardProps, type CardSize, type CardVariant } from "./components/Card/Card"
98
- export { List, ListItem, useListMetrics, type ListItemProps, type ListProps } from "./components/List/List"
98
+ export { List, ListItem, ListStack, useListMetrics, type ListItemProps, type ListProps, type ListStackProps } from "./components/List/List"
99
99
  export { Chip, type ChipProps } from "./components/Chip/Chip"
100
100
  export { Skeleton, type SkeletonProps } from "./components/Skeleton/Skeleton"
101
101
  export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment, type ProgressSize } from "./components/Progress/Progress"