@plexui/react-native 0.2.26 → 0.2.28

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 (30) hide show
  1. package/dist/es/components/Button/Button.js +9 -5
  2. package/dist/es/components/Chip/Chip.js +19 -11
  3. package/dist/es/components/Dialog/Dialog.js +18 -6
  4. package/dist/es/components/EmptyMessage/EmptyMessage.js +2 -2
  5. package/dist/es/components/Input/Input.js +17 -2
  6. package/dist/es/components/List/List.js +35 -2
  7. package/dist/es/components/ScrollEdge/ScrollEdge.js +12 -6
  8. package/dist/es/components/TabBar/TabBar.js +15 -0
  9. package/dist/es/components/TextLink/TextLink.js +18 -3
  10. package/dist/es/index.js +2 -2
  11. package/dist/types/components/Chip/Chip.d.ts +9 -3
  12. package/dist/types/components/Dialog/Dialog.d.ts +7 -1
  13. package/dist/types/components/EmptyMessage/EmptyMessage.d.ts +4 -2
  14. package/dist/types/components/Input/Input.d.ts +8 -1
  15. package/dist/types/components/List/List.d.ts +26 -1
  16. package/dist/types/components/ScrollEdge/ScrollEdge.d.ts +7 -1
  17. package/dist/types/components/TabBar/TabBar.d.ts +13 -0
  18. package/dist/types/components/TextLink/TextLink.d.ts +7 -1
  19. package/dist/types/index.d.ts +2 -2
  20. package/package.json +2 -2
  21. package/src/components/Button/Button.tsx +10 -5
  22. package/src/components/Chip/Chip.tsx +28 -9
  23. package/src/components/Dialog/Dialog.tsx +30 -6
  24. package/src/components/EmptyMessage/EmptyMessage.tsx +12 -3
  25. package/src/components/Input/Input.tsx +43 -3
  26. package/src/components/List/List.tsx +70 -2
  27. package/src/components/ScrollEdge/ScrollEdge.tsx +19 -6
  28. package/src/components/TabBar/TabBar.tsx +15 -0
  29. package/src/components/TextLink/TextLink.tsx +46 -3
  30. package/src/index.ts +2 -2
@@ -10,6 +10,12 @@ export type ScrollEdgeProps = {
10
10
  scrolled?: boolean
11
11
  /** The color of the screen it fades into (a grouped screen's canvas). @default the theme's background */
12
12
  canvasColor?: string
13
+ /**
14
+ * Top edge under a floating row (filters, tabs): where the fade ends, from the screen's top. Only what went under the
15
+ * row is muted, the content below it stays sharp: pass the row's bottom. On Android, too, the edge then is the row's
16
+ * (iOS 27.2's), not the status bar's alone.
17
+ */
18
+ fadeEnd?: number
13
19
  testID?: string
14
20
  style?: StyleProp<ViewStyle>
15
21
  }
@@ -21,13 +27,17 @@ export type ScrollEdgeProps = {
21
27
  * the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
22
28
  * over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
23
29
  */
24
- export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID, style }: ScrollEdgeProps) {
30
+ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, fadeEnd, testID, style }: ScrollEdgeProps) {
25
31
  const theme = useTheme()
26
32
  const insets = useSafeAreaInsets()
27
33
  const canvas = canvasColor ?? theme.colors.background
28
34
  const top = edge === "top"
29
35
  if (top && !scrolled) return null
30
- if (theme.isAndroid) {
36
+ const height = StyleSheet.flatten(style)?.height
37
+ // A row under the status bar (a height or a fade's end given): Android takes iOS's edge for it, as a row over
38
+ // content reads on neither platform under the status bar's edge alone
39
+ const row = top && (fadeEnd != null || typeof height === "number")
40
+ if (theme.isAndroid && !row) {
31
41
  if (!top) return null
32
42
  return (
33
43
  <View pointerEvents="none" testID={testID} style={[{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style]}>
@@ -36,14 +46,15 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
36
46
  )
37
47
  }
38
48
  // The safe area at that edge, or the height the style gives the top edge (a bar's row of buttons under the status
39
- // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it
40
- const height = StyleSheet.flatten(style)?.height
41
- const reach = top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top
49
+ // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it. A fade's
50
+ // end is where the veil's 34 end, so the content under it shows clear
51
+ const reach =
52
+ top && fadeEnd != null ? fadeEnd - FADE_PAST - FULL_BLUR_SHORTFALL : top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top
42
53
  return (
43
54
  <View
44
55
  pointerEvents="none"
45
56
  testID={testID}
46
- style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style]}
57
+ style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: fadeEnd ?? insets.top } : { bottom: 0, height: insets.bottom }, style]}
47
58
  >
48
59
  {top ? <SoftBottomVeil fill={canvas} bottom={reach} /> : <SoftBottomVeil fill={canvas} top={0} />}
49
60
  </View>
@@ -52,3 +63,5 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
52
63
 
53
64
  /** The veil's blur is full 6 short of the edge it is turned over at (12 to 40 into its 34): a given height adds them. */
54
65
  const FULL_BLUR_SHORTFALL = 6
66
+ /** From the height where the blur is whole, the fade runs on 28 more (the 34 of the veil less its shortfall). */
67
+ const FADE_PAST = 28
@@ -884,6 +884,21 @@ export const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem })
884
884
  /** A scroll of at least this many points in one direction minimizes or expands the bar, as on the web. */
885
885
  const MINIMIZE_AFTER = 8
886
886
 
887
+ /**
888
+ * Where the tab bar's capsule stands, for what floats over it (a screen's floating buttons a set gap above it, a
889
+ * scroll that ends over it): `capsuleHeight`, and `bottom`, from the screen's bottom edge to the capsule's. iOS 26: the
890
+ * 54pt tabs in a capsule 4 above and below (62), 21 over the screen's bottom (or over the home indicator); Android:
891
+ * 56dp, 8 over the gesture bar. The bar itself (its soft edge) reaches higher. Pass the bar's `safeArea`.
892
+ */
893
+ export function useTabBarMetrics({ safeArea = true, minimized = false }: { safeArea?: boolean; minimized?: boolean } = {}): { capsuleHeight: number; bottom: number } {
894
+ const theme = useTheme()
895
+ const insets = useSafeAreaInsets()
896
+ if (theme.isAndroid) return { capsuleHeight: 56, bottom: 8 + (safeArea ? insets.bottom : 0) }
897
+ const padBottom = minimized ? theme.length("--tab-bar-minimized-padding-bottom", 28) : theme.length("--tab-bar-padding-bottom", 21)
898
+ const capsuleHeight = minimized ? theme.length("--tab-bar-minimized-size", 48) : theme.length("--tab-bar-item-height", 54) + 2 * theme.length("--tab-bar-capsule-padding-block", 4)
899
+ return { capsuleHeight, bottom: safeArea ? Math.max(padBottom, insets.bottom - 13) : padBottom }
900
+ }
901
+
887
902
  /**
888
903
  * Minimizes a TabBar while the screen scrolls down and expands it when it scrolls back up, as iOS 26
889
904
  * `tabBarMinimizeBehavior(.onScrollDown)`: pass `onScroll` to the ScrollView and `minimized` and
@@ -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"