@gnome-ui/react-native 1.10.0 → 1.12.0

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.
@@ -0,0 +1,105 @@
1
+ import { StyleProp, View, ViewStyle } from 'react-native';
2
+ /**
3
+ * Controls when the button is rendered.
4
+ *
5
+ * - `"auto"` — hidden until `scrollY` exceeds `threshold` (default).
6
+ * - `"always"` — always rendered regardless of scroll position.
7
+ */
8
+ export type ScrollToTopVisible = 'always' | 'auto';
9
+ /**
10
+ * Anchor corner or edge for the absolutely-positioned container.
11
+ * The button is inset `theme.space4` (24 dp) from each named edge.
12
+ */
13
+ export type ScrollToTopPosition = 'bottom-right' | 'bottom-left' | 'bottom-center' | 'top-right' | 'top-left' | 'top-center';
14
+ export interface ScrollToTopProps {
15
+ /**
16
+ * Controls when the button is visible.
17
+ *
18
+ * - `"auto"` (default) — shown only once `scrollY` exceeds `threshold`.
19
+ * - `"always"` — permanently visible.
20
+ */
21
+ visible?: ScrollToTopVisible;
22
+ /**
23
+ * Corner or edge where the button is anchored. Default: `"bottom-right"`.
24
+ */
25
+ position?: ScrollToTopPosition;
26
+ /**
27
+ * Offset the user must scroll past before the button appears.
28
+ * Only relevant when `visible="auto"`. Default: `300`.
29
+ */
30
+ threshold?: number;
31
+ /**
32
+ * The observed `ScrollView`/`FlatList`'s current vertical scroll offset —
33
+ * pass `nativeEvent.contentOffset.y` from its `onScroll` handler. Only
34
+ * relevant when `visible="auto"`; ignored (and safe to omit) otherwise.
35
+ * Default: `0`.
36
+ */
37
+ scrollY?: number;
38
+ /**
39
+ * Called when the button is pressed. There's no RN equivalent of the web
40
+ * version's own `scrollTarget.scrollTo({ top: 0, behavior: 'smooth' })` —
41
+ * `ScrollView`/`FlatList` are scrolled through a ref's imperative
42
+ * `scrollTo`/`scrollToOffset`, which this component has no way to hold on
43
+ * a consumer's behalf. Typically
44
+ * `() => scrollViewRef.current?.scrollTo({ y: 0, animated: true })`.
45
+ */
46
+ onPress: () => void;
47
+ /**
48
+ * Extra inset added on top of the base edge spacing when anchored to a
49
+ * `"top-*"` position — pass your own `useSafeAreaInsets().top` so the
50
+ * button clears a notch/status bar. Same "no new peer dependency" call
51
+ * `BottomTabBar`'s `bottomInset` already made. Default: `0`.
52
+ */
53
+ topInset?: number;
54
+ /** Same as `topInset`, for a `"bottom-*"` position. Default: `0`. */
55
+ bottomInset?: number;
56
+ style?: StyleProp<ViewStyle>;
57
+ testID?: string;
58
+ }
59
+ /**
60
+ * Absolutely-positioned OSD button that scrolls a `ScrollView`/`FlatList`
61
+ * back to the top — mirrors `@gnome-ui/react`'s `ScrollToTop`, reimagined
62
+ * rather than ported 1:1 per this package's own ROADMAP note: RN has no
63
+ * page-level scroll event to observe internally the way the web version's
64
+ * `useScrollToTopVisibility` attaches a `window`/element `scroll` listener,
65
+ * so that hook doesn't port at all — `visible="auto"` is instead a pure
66
+ * function of a `scrollY` prop the consumer feeds from their own
67
+ * `ScrollView`'s `onScroll`, re-evaluated on every render with no internal
68
+ * state or listener needed.
69
+ *
70
+ * Same "no `document.body`/portal target" gap `Toaster` already
71
+ * documents — mount this yourself as the last child of the `View` wrapping
72
+ * your scrollable content (left at its default relative positioning) so it
73
+ * paints on top; `pointerEvents="box-none"` (the same technique `Toaster`
74
+ * uses) keeps the empty space around the button from intercepting touches
75
+ * meant for the content underneath.
76
+ *
77
+ * The web version's resting `opacity: 0.5`-until-hover/focus is dropped —
78
+ * the same call `PasswordEntryRow`'s reveal button already made: that
79
+ * effect exists purely so the control can brighten on hover, and touch has
80
+ * no hover, so a permanently dimmed control would just be harder to see.
81
+ *
82
+ * Forwards `ref` to the root positioning `View`, not the inner button —
83
+ * matching the web version's own `forwardRef` target.
84
+ *
85
+ * @example
86
+ * // Minimal — appears once `scrollY` exceeds 300, anchored bottom-right
87
+ * const [scrollY, setScrollY] = useState(0);
88
+ * const scrollRef = useRef<ScrollView>(null);
89
+ * <View style={{ flex: 1 }}>
90
+ * <ScrollView
91
+ * ref={scrollRef}
92
+ * onScroll={(e) => setScrollY(e.nativeEvent.contentOffset.y)}
93
+ * scrollEventThrottle={16}
94
+ * >
95
+ * ...
96
+ * </ScrollView>
97
+ * <ScrollToTop
98
+ * scrollY={scrollY}
99
+ * onPress={() => scrollRef.current?.scrollTo({ y: 0, animated: true })}
100
+ * />
101
+ * </View>
102
+ *
103
+ * @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ScrollToTop.html
104
+ */
105
+ export declare const ScrollToTop: import('react').ForwardRefExoticComponent<ScrollToTopProps & import('react').RefAttributes<View>>;
@@ -0,0 +1,2 @@
1
+ export type { ScrollToTopPosition, ScrollToTopProps, ScrollToTopVisible } from './ScrollToTop';
2
+ export { ScrollToTop } from './ScrollToTop';
@@ -0,0 +1,25 @@
1
+ import { StyleProp, View, ViewProps, ViewStyle } from 'react-native';
2
+ export interface SpacerProps extends Omit<ViewProps, 'style'> {
3
+ style?: StyleProp<ViewStyle>;
4
+ }
5
+ /**
6
+ * Invisible `flex: 1` filler for `Toolbar` and `HeaderBar` — mirrors
7
+ * `@gnome-ui/react`'s `Spacer`. Place between leading and trailing groups
8
+ * to push trailing items to the end.
9
+ *
10
+ * `accessible={false}` mirrors the web version's `aria-hidden="true"` —
11
+ * same "purely decorative, exclude from the accessibility tree entirely"
12
+ * call `Separator` already made, rather than reaching for `role`'s newer
13
+ * `"separator"` value (which exists but implies a divider a screen
14
+ * reader user might care about; a plain flex filler has no such meaning).
15
+ *
16
+ * @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/style-classes.html#spacer
17
+ *
18
+ * @example
19
+ * <Toolbar>
20
+ * <Button variant="flat">Back</Button>
21
+ * <Spacer />
22
+ * <Button variant="flat">Done</Button>
23
+ * </Toolbar>
24
+ */
25
+ export declare const Spacer: import('react').ForwardRefExoticComponent<SpacerProps & import('react').RefAttributes<View>>;
@@ -0,0 +1,2 @@
1
+ export type { SpacerProps } from './Spacer';
2
+ export { Spacer } from './Spacer';
@@ -0,0 +1,56 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ export type StepIndicatorOrientation = 'horizontal' | 'vertical';
3
+ export interface StepIndicatorProps {
4
+ /**
5
+ * Total number of steps, or an array of per-step labels rendered beside
6
+ * (vertical) or beneath (horizontal) each circle. Pass a plain number for
7
+ * an unlabelled sequence (only the "Step X of Y" caption is shown); pass
8
+ * an array of strings to label each step.
9
+ */
10
+ steps: number | string[];
11
+ /** Zero-based index of the current/active step. */
12
+ currentStep: number;
13
+ /** Layout direction. Default: `"horizontal"`. */
14
+ orientation?: StepIndicatorOrientation;
15
+ /**
16
+ * Called when a completed step's circle is pressed, letting the user jump
17
+ * back to a step they've already finished. Omit to make steps
18
+ * non-interactive. The current and upcoming steps are never pressable.
19
+ */
20
+ onStepClick?: (index: number) => void;
21
+ /** Accessible label for the indicator. Default: `"Progress"`. */
22
+ label?: string;
23
+ style?: StyleProp<ViewStyle>;
24
+ testID?: string;
25
+ }
26
+ /**
27
+ * Numbered "Step X of Y" progress indicator for onboarding/wizard flows —
28
+ * mirrors `@gnome-ui/react`'s `StepIndicator`. Directly portable per this
29
+ * package's own ROADMAP note: no web-only APIs are involved, just derived
30
+ * dot/number state from `currentStep`.
31
+ *
32
+ * The outer container sets `role="navigation"` **without** `accessible` —
33
+ * the corrected pattern `ToggleGroup` established over the earlier
34
+ * `BoxedList`/`ViewSwitcher` precedent: `accessible` on a *grouping*
35
+ * container with multiple independently-focusable children (each step
36
+ * circle here) collapses the whole subtree into one VoiceOver stop on iOS.
37
+ * The role still groups on Android, and every step stays individually
38
+ * reachable; assert `element.props.role` on a `testID` in tests instead of
39
+ * `getByRole('navigation')`.
40
+ *
41
+ * The connecting line between circles reuses the exact CSS trick verbatim
42
+ * (`position: absolute; left: 50%; width: 100%` inside each equal-width
43
+ * flex item, so the line runs from one circle's center to the next's) —
44
+ * `left`/`width` percentages are supported for RN position/dimension
45
+ * props, unlike the `transform: translateX('50%')` trick this package has
46
+ * hit real bugs with elsewhere (that limitation is specific to `transform`).
47
+ *
48
+ * The web version's checkmark/number content swap and connector-line color
49
+ * change have no CSS `transition` at all (only `.circle`'s own
50
+ * `background-color`/`border-color` do), so only those two colors animate
51
+ * here — the content swap and connector recolor are instant, matching the
52
+ * source exactly rather than adding an unrequested fade.
53
+ *
54
+ * @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StepIndicator.html
55
+ */
56
+ export declare const StepIndicator: ({ steps, currentStep, orientation, onStepClick, label, style, testID, }: StepIndicatorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { StepIndicatorOrientation, StepIndicatorProps } from './StepIndicator';
2
+ export { StepIndicator } from './StepIndicator';
@@ -0,0 +1,43 @@
1
+ import { ReactNode } from 'react';
2
+ import { PressableProps, StyleProp, View, ViewStyle } from 'react-native';
3
+ export interface SwitchRowProps extends Omit<PressableProps, 'children' | 'style' | 'onPress'> {
4
+ /** Primary label. */
5
+ title: string;
6
+ /** Secondary line below the title. */
7
+ subtitle?: string;
8
+ /** Icon or image placed at the leading edge. */
9
+ leading?: ReactNode;
10
+ /** Controlled checked state. */
11
+ checked?: boolean;
12
+ /** Initial checked state when uncontrolled. Defaults to `false`. */
13
+ defaultChecked?: boolean;
14
+ /** Called with the next value when the row is pressed. */
15
+ onCheckedChange?: (checked: boolean) => void;
16
+ style?: StyleProp<ViewStyle>;
17
+ }
18
+ /**
19
+ * Activatable row with an integrated switch, mirroring `@gnome-ui/react`'s
20
+ * `SwitchRow`. The entire row is a single pressable — pressing anywhere
21
+ * toggles the switch, which is why this isn't `ActionRow` + a trailing
22
+ * `Switch` (the ROADMAP's own guess): `AdwSwitchRow` makes the whole row the
23
+ * interactive element, the same shape `CheckRow` already established for
24
+ * its checkbox. Prefer this over `CheckRow` for a single on/off setting,
25
+ * and `CheckRow` for selecting/deselecting individual items in a list.
26
+ *
27
+ * The switch visual reuses `Switch`'s exact track/thumb `Animated.Value`
28
+ * interpolation, but as plain non-interactive `Animated.View`s rather than
29
+ * importing the real `Switch` component — `Switch` is itself a `Pressable`,
30
+ * and nesting one touchable inside another (the row's own `Pressable`)
31
+ * would create two overlapping tap targets, the same reasoning `CheckRow`
32
+ * already applied to `Checkbox`. `aria-labelledby` (pointing the web
33
+ * button's `role="switch"` at the title/subtitle content) has no RN
34
+ * equivalent — `accessibilityLabel` combining title and subtitle is the
35
+ * substitution, same as `CheckRow`.
36
+ *
37
+ * Supports both controlled (`checked`) and uncontrolled (`defaultChecked`)
38
+ * modes, the same `isControlled`/internal-state-fallback shape already
39
+ * established by `Expander`/`ComboRow`/`Popover`/`CheckRow`.
40
+ *
41
+ * @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.SwitchRow.html
42
+ */
43
+ export declare const SwitchRow: import('react').ForwardRefExoticComponent<SwitchRowProps & import('react').RefAttributes<View>>;
@@ -0,0 +1,2 @@
1
+ export type { SwitchRowProps } from './SwitchRow';
2
+ export { SwitchRow } from './SwitchRow';
@@ -0,0 +1,87 @@
1
+ import { ReactNode } from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ export type TimelineOrientation = 'vertical' | 'horizontal';
4
+ export type TimelineVariant = 'default' | 'dotted' | 'none';
5
+ export interface TimelineItem {
6
+ /** Icon rendered inside the timeline node. Sized/colored by the consumer — see the component doc. */
7
+ icon?: ReactNode;
8
+ /**
9
+ * Content at the leading edge of the node.
10
+ * - **Vertical:** rendered to the left of the connector track.
11
+ * - **Horizontal:** rendered above the node.
12
+ *
13
+ * Typical use: timestamp, badge, short label.
14
+ */
15
+ leading?: ReactNode;
16
+ /** Main event content rendered adjacent to the node (title, description…). */
17
+ content: ReactNode;
18
+ }
19
+ export interface TimelineProps {
20
+ /** Ordered list of timeline events. */
21
+ items: TimelineItem[];
22
+ /**
23
+ * Axis direction of the connector line.
24
+ * - `"vertical"` — events stack top-to-bottom (default).
25
+ * - `"horizontal"` — events flow left-to-right, in a horizontal `ScrollView`.
26
+ */
27
+ orientation?: TimelineOrientation;
28
+ /**
29
+ * Visual style of the connector between nodes.
30
+ * - `"default"` — solid thin line.
31
+ * - `"dotted"` — dotted line; useful for future or pending events.
32
+ * - `"none"` — no connector; each node stands alone.
33
+ */
34
+ variant?: TimelineVariant;
35
+ style?: StyleProp<ViewStyle>;
36
+ testID?: string;
37
+ }
38
+ /**
39
+ * Ordered sequence of events connected by a visual timeline — mirrors
40
+ * `@gnome-ui/react`'s `Timeline`. An original composition (no direct
41
+ * libadwaita widget), following GNOME HIG activity-feed/stepper patterns.
42
+ *
43
+ * The web version aligns every item's `leading` column (vertical) or row
44
+ * (horizontal) via CSS subgrid, so timestamps/labels line up across items
45
+ * regardless of how wide/tall any single one of them is. RN/Yoga has no
46
+ * grid or subgrid at all, so that alignment is reproduced by measurement
47
+ * instead — the same `onLayout` + `Record<index, size>` +
48
+ * "largest-so-far wins" technique `Slider`'s mark labels already
49
+ * established: every item's `leading` cell (always rendered, even when
50
+ * empty, matching the web version's own "same 3 children" comment)
51
+ * reports its own rendered width (vertical) or height (horizontal), and
52
+ * every cell gets a `minWidth`/`minHeight` equal to the largest one
53
+ * measured so far, so the node column/row starts at the same position in
54
+ * every item. The node track itself additionally gets a *fixed*
55
+ * width (vertical, matching the source CSS's literal `24px` column) or
56
+ * height (horizontal, the larger of the dot/icon node sizes, since the
57
+ * source's row there is CSS `auto` with no fixed value to port) — without
58
+ * it, an item with an icon node (28 dp) and one with a plain dot (12 dp)
59
+ * would each size their own track differently, misaligning `content`'s
60
+ * start position between them.
61
+ *
62
+ * `orientation="horizontal"` wraps itself in a horizontal `ScrollView`,
63
+ * reimagining the web CSS's `overflow-x: auto` — the direct native
64
+ * equivalent for "scroll instead of overflow when items don't fit". The
65
+ * web version's `grid-auto-columns: minmax(72px, 1fr)` also grows items
66
+ * to fill leftover space when the row *doesn't* overflow; that half
67
+ * doesn't port (a `ScrollView`'s content isn't bounded the way a CSS grid
68
+ * track is, so there's no "leftover space" to distribute) — each item
69
+ * just gets a flat 72 dp `minWidth` instead, unconditionally scrollable
70
+ * like `overflow-x: auto`'s own fallback path.
71
+ *
72
+ * `icon`/`leading`/`content` are plain `ReactNode`, the same as
73
+ * `PathBar`'s segment `icon` — the consumer sizes and colors their own
74
+ * icon (e.g. `tintColor={theme.accentFgColor}` on their own `<Icon>`),
75
+ * since RN has no `currentColor` for this component to tint an arbitrary
76
+ * child with the way the web version's CSS `color: accent-fg-color`
77
+ * does via inheritance onto the icon's SVG.
78
+ *
79
+ * `role="list"`/`role="listitem"` are set **without** `accessible` — the
80
+ * `ToggleGroup`/`StepIndicator`-established pattern for a grouping role
81
+ * over children that may themselves contain focusable content (an
82
+ * item's `content` is arbitrary `ReactNode` and could include one), so
83
+ * nothing nested inside gets swallowed into a single VoiceOver stop.
84
+ * Assert `element.props.role` on a `testID` in tests instead of
85
+ * `getByRole('list'/'listitem')`.
86
+ */
87
+ export declare const Timeline: ({ items, orientation, variant, style, testID, }: TimelineProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { TimelineItem, TimelineOrientation, TimelineProps, TimelineVariant } from './Timeline';
2
+ export { Timeline } from './Timeline';
@@ -0,0 +1,25 @@
1
+ import { StyleProp, View, ViewProps, ViewStyle } from 'react-native';
2
+ export interface ToolbarProps extends Omit<ViewProps, 'style'> {
3
+ style?: StyleProp<ViewStyle>;
4
+ }
5
+ /**
6
+ * Horizontal action bar following the libadwaita `.toolbar` pattern —
7
+ * mirrors `@gnome-ui/react`'s `Toolbar`. Directly portable: no web-only
8
+ * APIs, just a flex row with fixed padding/gap.
9
+ *
10
+ * Provides `theme.space1` (6 dp) padding and gap — the standard spacing
11
+ * for rows of flat buttons in header bars, action bars, and tool rows.
12
+ * Place a `Spacer` between leading and trailing groups to push trailing
13
+ * items to the end. Use `Button variant="flat"` for buttons that blend
14
+ * into the bar, or `variant="raised"` for one that needs explicit
15
+ * elevation within a flat context.
16
+ *
17
+ * The web CSS's `color`/`font-family` on `.toolbar` are dropped — RN has
18
+ * no style inheritance from a parent `View` down to child `Text`
19
+ * elements the way CSS `color` cascades, so a value here would reach
20
+ * nothing (every child, e.g. `Button`, already sets its own explicit
21
+ * text/icon colors).
22
+ *
23
+ * @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/style-classes.html#toolbar-style-class
24
+ */
25
+ export declare const Toolbar: import('react').ForwardRefExoticComponent<ToolbarProps & import('react').RefAttributes<View>>;
@@ -0,0 +1,2 @@
1
+ export type { ToolbarProps } from './Toolbar';
2
+ export { Toolbar } from './Toolbar';