@gnome-ui/react-native 1.0.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.
- package/README.md +714 -0
- package/dist/GnomeProvider/GnomeContext.d.ts +36 -0
- package/dist/GnomeProvider/GnomeProvider.d.ts +69 -0
- package/dist/GnomeProvider/index.d.ts +6 -0
- package/dist/GnomeProvider/resolveContext.d.ts +30 -0
- package/dist/components/ActionRow/ActionRow.d.ts +51 -0
- package/dist/components/ActionRow/index.d.ts +2 -0
- package/dist/components/BoxedList/BoxedList.d.ts +36 -0
- package/dist/components/BoxedList/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +47 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +34 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +44 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/HeaderBar/HeaderBar.d.ts +38 -0
- package/dist/components/HeaderBar/index.d.ts +2 -0
- package/dist/components/Link/Link.d.ts +33 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/PathBar/PathBar.d.ts +43 -0
- package/dist/components/PathBar/index.d.ts +2 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +72 -0
- package/dist/components/ProgressBar/index.d.ts +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +36 -0
- package/dist/components/RadioButton/index.d.ts +2 -0
- package/dist/components/SearchBar/SearchBar.d.ts +51 -0
- package/dist/components/SearchBar/index.d.ts +2 -0
- package/dist/components/Separator/Separator.d.ts +26 -0
- package/dist/components/Separator/index.d.ts +2 -0
- package/dist/components/Sidebar/Sidebar.d.ts +45 -0
- package/dist/components/Sidebar/SidebarItem.d.ts +37 -0
- package/dist/components/Sidebar/SidebarSection.d.ts +42 -0
- package/dist/components/Sidebar/filterUtils.d.ts +11 -0
- package/dist/components/Sidebar/index.d.ts +6 -0
- package/dist/components/Skeleton/Skeleton.d.ts +51 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.d.ts +44 -0
- package/dist/components/Spinner/index.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts +34 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Tabs/TabBar.d.ts +35 -0
- package/dist/components/Tabs/TabItem.d.ts +54 -0
- package/dist/components/Tabs/TabPanel.d.ts +28 -0
- package/dist/components/Tabs/index.d.ts +6 -0
- package/dist/components/Text/Text.d.ts +26 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/TextField/TextField.d.ts +37 -0
- package/dist/components/TextField/index.d.ts +2 -0
- package/dist/components/Toast/Toast.d.ts +58 -0
- package/dist/components/Toast/Toaster.d.ts +45 -0
- package/dist/components/Toast/index.d.ts +4 -0
- package/dist/components/ViewSwitcher/ViewSwitcher.d.ts +32 -0
- package/dist/components/ViewSwitcher/ViewSwitcherItem.d.ts +27 -0
- package/dist/components/ViewSwitcher/index.d.ts +4 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +2906 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/resolveTheme.d.ts +9 -0
- package/dist/theme/tokens.generated.d.ts +714 -0
- package/package.json +56 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GnomeResolvedColorScheme, GnomeResolvedContrast } from '../theme/resolveTheme';
|
|
2
|
+
import { GnomeThemeTokens } from '../theme/tokens.generated';
|
|
3
|
+
import { GnomeAccentColor, GnomeColorScheme, GnomeContrast, GnomeDir } from './resolveContext';
|
|
4
|
+
export interface GnomeContextValue {
|
|
5
|
+
locale: string | undefined;
|
|
6
|
+
dir: GnomeDir;
|
|
7
|
+
numberFormat: Intl.NumberFormatOptions | undefined;
|
|
8
|
+
dateTimeFormat: Intl.DateTimeFormatOptions | undefined;
|
|
9
|
+
colorScheme: GnomeColorScheme;
|
|
10
|
+
resolvedColorScheme: GnomeResolvedColorScheme;
|
|
11
|
+
contrast: GnomeContrast;
|
|
12
|
+
resolvedContrast: GnomeResolvedContrast;
|
|
13
|
+
accentColor: GnomeAccentColor;
|
|
14
|
+
theme: GnomeThemeTokens;
|
|
15
|
+
}
|
|
16
|
+
export declare const GnomeContext: import('react').Context<GnomeContextValue>;
|
|
17
|
+
/** Returns the locale set by the nearest `GnomeProvider`, or `undefined` to use the device locale. */
|
|
18
|
+
export declare function useLocale(): string | undefined;
|
|
19
|
+
/** Returns the text direction set by the nearest `GnomeProvider`. Defaults to the app's `I18nManager.isRTL` state. */
|
|
20
|
+
export declare function useDir(): GnomeDir;
|
|
21
|
+
/** Returns an `Intl.NumberFormat` configured from `GnomeProvider` defaults plus local overrides. */
|
|
22
|
+
export declare function useNumberFormatter(options?: Intl.NumberFormatOptions): Intl.NumberFormat;
|
|
23
|
+
/** Returns an `Intl.DateTimeFormat` configured from `GnomeProvider` defaults plus local overrides. */
|
|
24
|
+
export declare function useDateTimeFormatter(options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
25
|
+
/** Returns the color scheme preference set by the nearest `GnomeProvider`. Defaults to `"system"`. */
|
|
26
|
+
export declare function useColorScheme(): GnomeColorScheme;
|
|
27
|
+
/** Returns the resolved color scheme (`"light"` or `"dark"`), accounting for the OS preference when `colorScheme` is `"system"`. */
|
|
28
|
+
export declare function useResolvedColorScheme(): GnomeResolvedColorScheme;
|
|
29
|
+
/** Returns the contrast preference set by the nearest `GnomeProvider`. Defaults to `"system"`. */
|
|
30
|
+
export declare function useContrast(): GnomeContrast;
|
|
31
|
+
/** Returns the resolved contrast (`"normal"` or `"more"`), accounting for the OS accessibility setting when `contrast` is `"system"`. */
|
|
32
|
+
export declare function useResolvedContrast(): GnomeResolvedContrast;
|
|
33
|
+
/** Returns the accent color set by the nearest `GnomeProvider`. Defaults to `"blue"`. */
|
|
34
|
+
export declare function useAccentColor(): GnomeAccentColor;
|
|
35
|
+
/** Returns the fully-resolved theme tokens (colors, spacing, typography, …) for the nearest `GnomeProvider`, accent-adjusted. */
|
|
36
|
+
export declare function useGnomeTheme(): GnomeThemeTokens;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { GnomeAccentColor, GnomeColorScheme, GnomeContrast, GnomeDir } from './resolveContext';
|
|
3
|
+
export interface GnomeProviderProps {
|
|
4
|
+
/** BCP 47 locale tag (e.g. `"es-ES"`, `"de-DE"`). When omitted, components fall back to the device locale. */
|
|
5
|
+
locale?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Text direction exposed via context for consumers to branch on (e.g.
|
|
8
|
+
* mirroring icons or flipping a row's layout). Defaults to the app's
|
|
9
|
+
* actual `I18nManager.isRTL` state.
|
|
10
|
+
*
|
|
11
|
+
* Unlike the web `GnomeProvider`, this does **not** call
|
|
12
|
+
* `I18nManager.forceRTL()` — RN's layout direction is a single global
|
|
13
|
+
* flag that requires an app reload to take effect and is normally set
|
|
14
|
+
* once at app bootstrap, not scoped per provider tree.
|
|
15
|
+
*/
|
|
16
|
+
dir?: GnomeDir;
|
|
17
|
+
/**
|
|
18
|
+
* Global defaults for number formatting.
|
|
19
|
+
*
|
|
20
|
+
* Use `{ notation: "compact", compactDisplay: "short" }` for compact
|
|
21
|
+
* values such as `1K`; omit it or set `{ notation: "standard" }` for
|
|
22
|
+
* full values such as `1,000`.
|
|
23
|
+
*/
|
|
24
|
+
numberFormat?: Intl.NumberFormatOptions;
|
|
25
|
+
/** Global defaults for date/time formatting. */
|
|
26
|
+
dateTimeFormat?: Intl.DateTimeFormatOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Color scheme preference. `"system"` (default) follows
|
|
29
|
+
* `Appearance`/`useColorScheme()`. `"light"`/`"dark"` force that scheme
|
|
30
|
+
* regardless of the OS setting.
|
|
31
|
+
* @default 'system'
|
|
32
|
+
*/
|
|
33
|
+
colorScheme?: GnomeColorScheme;
|
|
34
|
+
/**
|
|
35
|
+
* High-contrast preference. `"system"` (default) follows the OS
|
|
36
|
+
* accessibility setting where one exists — Android's "High text
|
|
37
|
+
* contrast" (`AccessibilityInfo.isHighTextContrastEnabled`) or iOS's
|
|
38
|
+
* "Increase Contrast" (`AccessibilityInfo.isDarkerSystemColorsEnabled`)
|
|
39
|
+
* — and falls back to `"normal"` where neither is available (e.g. web).
|
|
40
|
+
* @default 'system'
|
|
41
|
+
*/
|
|
42
|
+
contrast?: GnomeContrast;
|
|
43
|
+
/**
|
|
44
|
+
* Accent color. Accepts a named GNOME palette color (`"blue"`, `"green"`,
|
|
45
|
+
* `"yellow"`, `"orange"`, `"red"`, `"purple"`, `"brown"`) or any RN color
|
|
46
|
+
* string (e.g. `"#ff0000"`, `"rgba(0, 0, 0, 0.5)"`). Named colors are
|
|
47
|
+
* theme-aware and use the correct shade for light/dark mode
|
|
48
|
+
* automatically. Defaults to `"blue"`.
|
|
49
|
+
*/
|
|
50
|
+
accentColor?: GnomeAccentColor;
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns `true` when the OS "Reduce Motion" accessibility setting is on
|
|
55
|
+
* (iOS Settings > Accessibility > Motion, Android Settings >
|
|
56
|
+
* Accessibility > Remove animations), for components with a continuously
|
|
57
|
+
* looping `Animated` value (e.g. `Spinner`) to slow down or skip that
|
|
58
|
+
* animation. Unlike `contrast`/`colorScheme`, the web `GnomeProvider` has
|
|
59
|
+
* no corresponding override prop — `prefers-reduced-motion` is a pure CSS
|
|
60
|
+
* media query there, always OS-driven — so this hook mirrors that: it
|
|
61
|
+
* reads `AccessibilityInfo` directly and isn't scoped to `GnomeProvider`'s
|
|
62
|
+
* context, unlike every other hook in this package. `isReduceMotionEnabled`
|
|
63
|
+
* / `reduceMotionChanged` are supported on both iOS and Android (unlike
|
|
64
|
+
* the high-contrast APIs above, which are platform-specific), so no
|
|
65
|
+
* `Platform.OS` branch is needed.
|
|
66
|
+
*/
|
|
67
|
+
export declare function useReducedMotion(): boolean;
|
|
68
|
+
/** Provides locale, text direction, color scheme, contrast, accent color, and resolved theme tokens to all descendant gnome-ui components. */
|
|
69
|
+
export declare const GnomeProvider: ({ locale, dir, numberFormat, dateTimeFormat, colorScheme, contrast, accentColor, children, }: GnomeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { GnomeContextValue } from './GnomeContext';
|
|
2
|
+
export { GnomeContext, useAccentColor, useColorScheme, useContrast, useDateTimeFormatter, useDir, useGnomeTheme, useLocale, useNumberFormatter, useResolvedColorScheme, useResolvedContrast, } from './GnomeContext';
|
|
3
|
+
export type { GnomeProviderProps } from './GnomeProvider';
|
|
4
|
+
export { GnomeProvider, useReducedMotion } from './GnomeProvider';
|
|
5
|
+
export type { GnomeAccentColor, GnomeColorScheme, GnomeContrast, GnomeDir, GnomeNamedAccentColor, } from './resolveContext';
|
|
6
|
+
export { applyAccentColor, NAMED_ACCENT_COLORS, resolveColorScheme, resolveContrast, } from './resolveContext';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GnomeResolvedColorScheme, GnomeResolvedContrast } from '../theme/resolveTheme';
|
|
2
|
+
import { GnomeThemeTokens } from '../theme/tokens.generated';
|
|
3
|
+
export type GnomeColorScheme = GnomeResolvedColorScheme | 'system';
|
|
4
|
+
export type GnomeContrast = GnomeResolvedContrast | 'system';
|
|
5
|
+
export type GnomeDir = 'ltr' | 'rtl';
|
|
6
|
+
export type GnomeNamedAccentColor = 'blue' | 'green' | 'yellow' | 'orange' | 'red' | 'purple' | 'brown';
|
|
7
|
+
export type GnomeAccentColor = GnomeNamedAccentColor | (string & {});
|
|
8
|
+
export declare const NAMED_ACCENT_COLORS: Set<GnomeNamedAccentColor>;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a `'light' | 'dark' | 'system'` preference against the OS color
|
|
11
|
+
* scheme. `systemColorScheme` is typed loosely (rather than as
|
|
12
|
+
* `GnomeResolvedColorScheme`) so RN's `useColorScheme()` — which can also
|
|
13
|
+
* report `'unspecified'` on Android, besides `null`/`undefined` — can be
|
|
14
|
+
* passed straight through; anything other than `'dark'` resolves to light.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveColorScheme(preference: GnomeColorScheme, systemColorScheme: string | null | undefined): GnomeResolvedColorScheme;
|
|
17
|
+
/** Resolves a `'normal' | 'more' | 'system'` preference against the OS high-contrast setting. */
|
|
18
|
+
export declare function resolveContrast(preference: GnomeContrast, systemHighContrast: boolean): GnomeResolvedContrast;
|
|
19
|
+
/**
|
|
20
|
+
* Returns `theme` with `accentColor`/`accentBgColor` (and, outside
|
|
21
|
+
* high-contrast, `focusRingColor`) overridden for a non-default accent.
|
|
22
|
+
*
|
|
23
|
+
* Named palette colors (`"green"`, `"red"`, …) resolve to the matching
|
|
24
|
+
* Adwaita shade for the current color scheme, mirroring
|
|
25
|
+
* `@gnome-ui/react`'s `GnomeProvider`. High-contrast variants keep their
|
|
26
|
+
* own fixed, maximum-contrast focus ring regardless of accent — the same
|
|
27
|
+
* behavior `tokens.css` encodes by not deriving it from `--gnome-accent-color`
|
|
28
|
+
* under `prefers-contrast: more`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyAccentColor(theme: GnomeThemeTokens, accentColor: GnomeAccentColor, resolvedColorScheme: GnomeResolvedColorScheme, resolvedContrast: GnomeResolvedContrast): GnomeThemeTokens;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PressableProps, StyleProp, View, ViewStyle } from 'react-native';
|
|
3
|
+
export type ActionRowVariant = 'default' | 'property';
|
|
4
|
+
export interface ActionRowProps extends Omit<PressableProps, 'children' | 'style'> {
|
|
5
|
+
/** Primary label. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Secondary line below the title. */
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
/** Icon or image placed at the leading edge. Rendered as-is — size/color it yourself. */
|
|
10
|
+
leading?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Widget placed at the trailing edge (`Switch`, `Button`, `Text`…).
|
|
13
|
+
* For interactive end widgets prefer a controlled component and stop
|
|
14
|
+
* event propagation inside it so the row's own `onPress` isn't triggered.
|
|
15
|
+
*/
|
|
16
|
+
trailing?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* When true the entire row becomes pressable (renders as `Pressable`
|
|
19
|
+
* with `accessibilityRole="button"`). Use for rows that navigate or
|
|
20
|
+
* trigger an action.
|
|
21
|
+
*/
|
|
22
|
+
interactive?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* `"property"` flips the visual hierarchy: the subtitle becomes the
|
|
25
|
+
* prominent value and the title shrinks to a dim label above it.
|
|
26
|
+
* Use for read-only property display (e.g. "OS Version / GNOME 50").
|
|
27
|
+
* Mirrors the `.property` style class.
|
|
28
|
+
*/
|
|
29
|
+
variant?: ActionRowVariant;
|
|
30
|
+
style?: StyleProp<ViewStyle>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Standard settings row with title, optional subtitle, and end widget.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors the Adwaita `AdwActionRow` pattern — the fundamental building
|
|
36
|
+
* block inside a `BoxedList`.
|
|
37
|
+
*
|
|
38
|
+
* Rebuilt with `Pressable`/`View`/`Text` rather than ported from
|
|
39
|
+
* `@gnome-ui/react`'s `<button>`/`<div>` — same `interactive` split as
|
|
40
|
+
* `Card`: a pressed-state overlay tinted by `theme.activeOverlay` stands in
|
|
41
|
+
* for the web's `:hover`/`:active` `background-color` transitions, since RN
|
|
42
|
+
* has no hover state on touch devices and no `color-mix()`. `title`/
|
|
43
|
+
* `subtitle` reuse the library's own `Text` component (`variant="body"`/
|
|
44
|
+
* `"caption"`, `color="dim"`) instead of hand-rolled styles, with
|
|
45
|
+
* `numberOfLines={1}` standing in for the web's CSS
|
|
46
|
+
* `text-overflow: ellipsis` truncation.
|
|
47
|
+
*
|
|
48
|
+
* @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ActionRow.html
|
|
49
|
+
* @see https://developer.gnome.org/hig/patterns/containers.html
|
|
50
|
+
*/
|
|
51
|
+
export declare const ActionRow: import('react').ForwardRefExoticComponent<ActionRowProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, View, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
export type BoxedListVariant = 'default' | 'separate';
|
|
4
|
+
export interface BoxedListProps extends Omit<ViewProps, 'style'> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* `"separate"` renders each child as its own standalone rounded card
|
|
8
|
+
* instead of a single joined list — mirrors `.boxed-list-separate`.
|
|
9
|
+
* Use when rows are independent items rather than a continuous group.
|
|
10
|
+
*/
|
|
11
|
+
variant?: BoxedListVariant;
|
|
12
|
+
style?: StyleProp<ViewStyle>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Rounded bordered list — the most common container pattern in GNOME apps.
|
|
16
|
+
*
|
|
17
|
+
* Mirrors the Adwaita `.boxed-list` style applied to a `GtkListBox`.
|
|
18
|
+
* Separators between rows are inserted automatically. Pair with `ActionRow`
|
|
19
|
+
* or any row-shaped element.
|
|
20
|
+
*
|
|
21
|
+
* Rebuilt with `View` rather than ported from `@gnome-ui/react`'s
|
|
22
|
+
* `<ul>`/`<li>` — RN has no list-semantics elements, so the outer `View`
|
|
23
|
+
* gets `accessibilityRole="list"` (there's no RN equivalent of `listitem`
|
|
24
|
+
* for rows), paired with `accessible` — a plain `View` isn't an
|
|
25
|
+
* accessibility element by default, so without it screen readers (and
|
|
26
|
+
* `@testing-library/react-native`'s `getByRole`) would skip over the role
|
|
27
|
+
* entirely. The web version applies `border-radius` directly to each
|
|
28
|
+
* first/last child via a `:first-child > *` CSS selector, since its `<ul>`
|
|
29
|
+
* has no `overflow: hidden` of its own; RN's `overflow: 'hidden'` on the
|
|
30
|
+
* outer `View` clips every row to the container's rounded corners
|
|
31
|
+
* uniformly, so that per-child trick isn't needed here.
|
|
32
|
+
*
|
|
33
|
+
* @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/style-classes.html#boxed-lists-cards
|
|
34
|
+
* @see https://developer.gnome.org/hig/patterns/containers.html
|
|
35
|
+
*/
|
|
36
|
+
export declare const BoxedList: import('react').ForwardRefExoticComponent<BoxedListProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PressableProps, StyleProp, TextStyle, View, ViewStyle } from 'react-native';
|
|
3
|
+
export type ButtonVariant = 'default' | 'suggested' | 'destructive' | 'flat' | 'raised';
|
|
4
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type ButtonShape = 'default' | 'pill' | 'circular';
|
|
6
|
+
export interface ButtonProps extends Omit<PressableProps, 'children' | 'style'> {
|
|
7
|
+
/** Visual style of the button. Follows GNOME HIG button types. */
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
/** Size of the button. */
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
/** Shape of the button. "pill" for primary actions in open space, "circular" for icon-only buttons. */
|
|
12
|
+
shape?: ButtonShape;
|
|
13
|
+
/**
|
|
14
|
+
* Dark semi-transparent overlay style for buttons placed on top of media
|
|
15
|
+
* or images — mirrors `@gnome-ui/react`'s `osd` prop.
|
|
16
|
+
*/
|
|
17
|
+
osd?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Icon placed before the label. Rendered as-is — RN has no CSS
|
|
20
|
+
* `currentColor` equivalent, so size and color it yourself (`theme.*FgColor`
|
|
21
|
+
* from `useGnomeTheme()` matches the resolved label color for each variant).
|
|
22
|
+
*/
|
|
23
|
+
leadingIcon?: ReactNode;
|
|
24
|
+
/** Icon placed after the label. See `leadingIcon` for color/size notes. */
|
|
25
|
+
trailingIcon?: ReactNode;
|
|
26
|
+
/** String children render as a themed `Text` label; other nodes render as-is. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
/** Style applied to the label `Text` when `children` is a string. */
|
|
30
|
+
textStyle?: StyleProp<TextStyle>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Button component following GNOME Human Interface Guidelines.
|
|
34
|
+
*
|
|
35
|
+
* Variants:
|
|
36
|
+
* - `default` — Standard action, flat appearance with subtle border.
|
|
37
|
+
* - `suggested` — Affirmative/primary action (accent color). Use at most once per view.
|
|
38
|
+
* - `destructive` — Dangerous or irreversible action (red). Use sparingly.
|
|
39
|
+
* - `flat` — No border or background; ideal for header bars and toolbars.
|
|
40
|
+
* - `raised` — Explicit raised look inside flat/toolbar contexts.
|
|
41
|
+
*
|
|
42
|
+
* Rebuilt with `Pressable`/`View`/`Text` rather than ported from
|
|
43
|
+
* `@gnome-ui/react`'s DOM-based JSX, but mirrors its prop API.
|
|
44
|
+
*
|
|
45
|
+
* @see https://developer.gnome.org/hig/patterns/controls/buttons.html
|
|
46
|
+
*/
|
|
47
|
+
export declare const Button: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PressableProps, StyleProp, View, ViewStyle } from 'react-native';
|
|
3
|
+
export type CardPadding = 'none' | 'sm' | 'md' | 'lg';
|
|
4
|
+
export interface CardProps extends Omit<PressableProps, 'style' | 'children'> {
|
|
5
|
+
/**
|
|
6
|
+
* When true the card becomes pressable (Adwaita `.activatable`).
|
|
7
|
+
* Renders as `Pressable` with `accessibilityRole="button"`; a plain
|
|
8
|
+
* `View` otherwise. `onPress`/`onLongPress`/etc. only take effect when
|
|
9
|
+
* `interactive` is true — RN's `View` has no touch handling of its own,
|
|
10
|
+
* unlike a DOM `<div>`'s `onClick`.
|
|
11
|
+
*/
|
|
12
|
+
interactive?: boolean;
|
|
13
|
+
/** Internal spacing. Defaults to `"md"`. */
|
|
14
|
+
padding?: CardPadding;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Card component following the GNOME HIG and Adwaita `.card` style class.
|
|
20
|
+
*
|
|
21
|
+
* Use for grouping related content on an elevated surface. Set
|
|
22
|
+
* `interactive` for clickable cards (e.g. grid item, settings shortcut).
|
|
23
|
+
*
|
|
24
|
+
* Rebuilt with `Pressable`/`View` rather than ported from `@gnome-ui/react`'s
|
|
25
|
+
* DOM-based `<button>`/`<div>` + `as` prop — RN has no polymorphic-element
|
|
26
|
+
* equivalent, so `as` is dropped. The web version's `:hover`/`:active`
|
|
27
|
+
* `color-mix()` darken/lighten is reproduced with an absolutely-positioned
|
|
28
|
+
* overlay `View` tinted by `theme.activeOverlay` while pressed, since RN
|
|
29
|
+
* has no `color-mix()` to blend two flat colors directly.
|
|
30
|
+
*
|
|
31
|
+
* @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/style-classes.html
|
|
32
|
+
* @see https://developer.gnome.org/hig/patterns/containers.html
|
|
33
|
+
*/
|
|
34
|
+
export declare const Card: import('react').ForwardRefExoticComponent<CardProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, View, ViewStyle } from 'react-native';
|
|
2
|
+
export interface CheckboxProps extends Omit<PressableProps, 'children' | 'style' | 'onPress'> {
|
|
3
|
+
/** Whether the checkbox is checked. */
|
|
4
|
+
value: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Indeterminate state — shown when only some items in a group are
|
|
7
|
+
* checked. Takes visual precedence over `value`.
|
|
8
|
+
*/
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
/** Called with the next value when the checkbox is pressed. */
|
|
11
|
+
onValueChange?: (value: boolean) => void;
|
|
12
|
+
/** Accessible label. Required when no visible label is associated. */
|
|
13
|
+
accessibilityLabel?: string;
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Checkbox for multi-selection, following the GNOME HIG and Adwaita style.
|
|
18
|
+
*
|
|
19
|
+
* Supports three states: unchecked, checked, and indeterminate (mixed).
|
|
20
|
+
* Use `indeterminate` for "select all" controls when only some items are
|
|
21
|
+
* selected.
|
|
22
|
+
*
|
|
23
|
+
* Rebuilt on `Pressable`/`Animated.View` rather than ported from
|
|
24
|
+
* `@gnome-ui/react`'s `<input type="checkbox">`: RN has no `indeterminate`
|
|
25
|
+
* DOM property to set imperatively (the web version's whole reason for a
|
|
26
|
+
* ref + effect), so it's just a rendering branch here — `indeterminate`
|
|
27
|
+
* draws a short bar, otherwise a checkmark, both fading in via the same
|
|
28
|
+
* `Animated.Value` used for the border/background transition. The
|
|
29
|
+
* checkmark itself is a `✓` glyph in a plain (non-themed) `Text` rather
|
|
30
|
+
* than the web version's `clip-path` polygon — this package has no SVG
|
|
31
|
+
* dependency to draw one exactly, and `Link`'s external-link indicator
|
|
32
|
+
* already established a Unicode glyph as this codebase's fallback for a
|
|
33
|
+
* small decorative mark with no icon library available.
|
|
34
|
+
*
|
|
35
|
+
* `value`/`onValueChange` mirror the same convention as `Switch`, RN's own
|
|
36
|
+
* toggle-control shape, rather than the web version's `checked`/`onChange`.
|
|
37
|
+
* The idle border color is another `Switch`-style case where the source
|
|
38
|
+
* CSS hardcodes a palette swatch per color scheme instead of a token that
|
|
39
|
+
* already resolves per theme, so it branches on `useResolvedColorScheme()`
|
|
40
|
+
* the same way.
|
|
41
|
+
*
|
|
42
|
+
* @see https://developer.gnome.org/hig/patterns/controls/checkboxes.html
|
|
43
|
+
*/
|
|
44
|
+
export declare const Checkbox: import('react').ForwardRefExoticComponent<CheckboxProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, View, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
export interface HeaderBarProps extends Omit<ViewProps, 'style'> {
|
|
4
|
+
/** Centered title. Pass a string or a custom element. */
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
/** Controls placed at the leading (left) edge — back button, menu, etc. */
|
|
7
|
+
start?: ReactNode;
|
|
8
|
+
/** Controls placed at the trailing (right) edge — actions, overflow menu, etc. */
|
|
9
|
+
end?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* When true the header bar blends into the window chrome (no bottom
|
|
12
|
+
* border). Use for the topmost bar of a full-window layout.
|
|
13
|
+
*/
|
|
14
|
+
flat?: boolean;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Title bar with centered title and leading/trailing action slots.
|
|
19
|
+
*
|
|
20
|
+
* Mirrors the Adwaita `AdwHeaderBar` pattern. Use `flat` buttons
|
|
21
|
+
* (`<Button variant="flat">`) inside the header bar per GNOME HIG.
|
|
22
|
+
*
|
|
23
|
+
* Rebuilt with flexbox rather than ported from `@gnome-ui/react`'s CSS
|
|
24
|
+
* Grid (`1fr auto 1fr`) — RN has no grid layout, but the same true-centering
|
|
25
|
+
* effect (the title stays centered in the full width regardless of how
|
|
26
|
+
* wide `start`/`end` are, rather than centering only in the leftover gap
|
|
27
|
+
* between them) comes from giving both side slots `flex: 1` with the title
|
|
28
|
+
* left unflexed in between, since both sides then always claim equal
|
|
29
|
+
* leftover space. The web version's `<header>` element has no RN
|
|
30
|
+
* equivalent; `accessibilityRole="header"` is deliberately *not* applied to
|
|
31
|
+
* the outer `View` since that role means "text heading" in RN's
|
|
32
|
+
* accessibility tree (see `Text`'s heading variants), not "landmark
|
|
33
|
+
* container" the way HTML's `<header>` does.
|
|
34
|
+
*
|
|
35
|
+
* @see https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.HeaderBar.html
|
|
36
|
+
* @see https://developer.gnome.org/hig/patterns/containers/header-bars.html
|
|
37
|
+
*/
|
|
38
|
+
export declare const HeaderBar: import('react').ForwardRefExoticComponent<HeaderBarProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PressableProps, StyleProp, TextStyle, View, ViewStyle } from 'react-native';
|
|
3
|
+
export interface LinkProps extends Omit<PressableProps, 'children' | 'style'> {
|
|
4
|
+
/**
|
|
5
|
+
* Target URL. Passed to `Linking.openURL` when pressed, unless a custom
|
|
6
|
+
* `onPress` is supplied (e.g. to hand internal links to a router like
|
|
7
|
+
* React Navigation instead of the device browser).
|
|
8
|
+
*/
|
|
9
|
+
href: string;
|
|
10
|
+
/**
|
|
11
|
+
* When true the link is treated as external: appends a trailing ↗
|
|
12
|
+
* indicator and an "Opens in browser" accessibility hint. RN has no tab
|
|
13
|
+
* concept, so unlike the web `Link` this doesn't change navigation
|
|
14
|
+
* behaviour — `href` always opens via `Linking.openURL` regardless.
|
|
15
|
+
*/
|
|
16
|
+
external?: boolean;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
/** Style applied to the label `Text`. */
|
|
20
|
+
textStyle?: StyleProp<TextStyle>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Inline hyperlink following GNOME HIG.
|
|
24
|
+
*
|
|
25
|
+
* Rebuilt on `Pressable`/themed `Text` rather than ported from
|
|
26
|
+
* `@gnome-ui/react`'s `<a>`: touch devices have no `:hover`, so the
|
|
27
|
+
* underline that the web version reveals on hover instead reveals on
|
|
28
|
+
* press — the closest native equivalent — alongside the same `0.7`
|
|
29
|
+
* press-opacity dip as `@gnome-ui/react`'s `:active` state.
|
|
30
|
+
*
|
|
31
|
+
* @see https://developer.gnome.org/hig/patterns/controls/links.html
|
|
32
|
+
*/
|
|
33
|
+
export declare const Link: import('react').ForwardRefExoticComponent<LinkProps & import('react').RefAttributes<View>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
export interface PathBarSegment {
|
|
4
|
+
/** Display label for this path segment. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Opaque path value passed to `onNavigate` when the segment is pressed. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** Optional icon placed before the label (e.g. a folder icon). Rendered as-is. */
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export interface PathBarProps extends Omit<ViewProps, 'style'> {
|
|
12
|
+
/**
|
|
13
|
+
* Ordered path segments from root to current location. The last segment
|
|
14
|
+
* is the current folder and is rendered non-interactive.
|
|
15
|
+
*/
|
|
16
|
+
segments: PathBarSegment[];
|
|
17
|
+
/**
|
|
18
|
+
* Called when the user presses a non-current segment. Receives the
|
|
19
|
+
* `path` and zero-based `index` of the pressed segment.
|
|
20
|
+
*/
|
|
21
|
+
onNavigate?: (path: string, index: number) => void;
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Breadcrumb path bar for navigating a hierarchical location.
|
|
26
|
+
*
|
|
27
|
+
* Mirrors the location bar in GNOME Files (Nautilus). Segments are
|
|
28
|
+
* separated by chevron dividers. All segments except the last are
|
|
29
|
+
* interactive — pressing them calls `onNavigate`. The last segment
|
|
30
|
+
* represents the current location and renders as a static, bold label.
|
|
31
|
+
*
|
|
32
|
+
* Rebuilt with `Pressable`/`View`/`Text` rather than ported from
|
|
33
|
+
* `@gnome-ui/react`'s `<nav><ol><li>`: RN's `AccessibilityRole` union has
|
|
34
|
+
* neither a "navigation" landmark nor a breadcrumb-list role (the same gap
|
|
35
|
+
* that dropped `Sidebar`'s `<nav>` role), so those are dropped rather than
|
|
36
|
+
* faked — each interactive segment still gets its own
|
|
37
|
+
* `accessibilityRole="button"` and `accessibilityLabel`. The separator
|
|
38
|
+
* chevron is a Unicode `›` glyph instead of the web version's inline SVG
|
|
39
|
+
* path, matching this package's established no-SVG-dependency convention.
|
|
40
|
+
*
|
|
41
|
+
* @see https://developer.gnome.org/hig/patterns/nav/search.html
|
|
42
|
+
*/
|
|
43
|
+
export declare const PathBar: ({ segments, onNavigate, style, ...viewProps }: PathBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
+
export type ProgressBarVariant = 'accent' | 'success' | 'warning' | 'error';
|
|
3
|
+
export interface ProgressBarProps extends Omit<ViewProps, 'style'> {
|
|
4
|
+
/**
|
|
5
|
+
* Current progress value between `0` and `1` (e.g. `0.6` = 60%). Omit
|
|
6
|
+
* or set to `undefined` for the indeterminate (pulsing) state.
|
|
7
|
+
*/
|
|
8
|
+
value?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Fill color of the progress indicator.
|
|
11
|
+
* - `"accent"` (default) — blue, general-purpose progress.
|
|
12
|
+
* - `"success"` — green, completed or healthy state.
|
|
13
|
+
* - `"warning"` — yellow, approaching a limit.
|
|
14
|
+
* - `"error"` — red, failed or critical state.
|
|
15
|
+
*/
|
|
16
|
+
variant?: ProgressBarVariant;
|
|
17
|
+
/** Accessible label describing what is loading. */
|
|
18
|
+
accessibilityLabel?: string;
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Determinate and indeterminate progress bar following the Adwaita style.
|
|
23
|
+
*
|
|
24
|
+
* - **Determinate** — pass `value` (0–1) to show exact progress; the fill
|
|
25
|
+
* width animates on every change, matching the web version's
|
|
26
|
+
* `transition: width`.
|
|
27
|
+
* - **Indeterminate** — omit `value` for a 40%-wide bar that slides left
|
|
28
|
+
* to right on an `Animated.loop`, matching the web version's CSS
|
|
29
|
+
* `@keyframes pulse`.
|
|
30
|
+
*
|
|
31
|
+
* `useReducedMotion()` is honored per the *source CSS's own* per-state
|
|
32
|
+
* behavior rather than one uniform rule: determinate width changes simply
|
|
33
|
+
* skip the transition (duration `0`, still an immediate jump like the CSS
|
|
34
|
+
* `transition: none`), while the indeterminate pulse stops entirely and
|
|
35
|
+
* freezes as a static, full-width, 50%-opacity bar — exactly what
|
|
36
|
+
* `@media (prefers-reduced-motion: reduce) { .indeterminate { animation:
|
|
37
|
+
* none; left: 0; width: 100%; opacity: 0.5 } }` does. This differs from
|
|
38
|
+
* `Spinner`, whose reduced-motion behavior *slows* its animation instead
|
|
39
|
+
* of stopping it — each component mirrors its own source CSS rather than
|
|
40
|
+
* applying a single reduced-motion policy across the package.
|
|
41
|
+
*
|
|
42
|
+
* Both animated states are driven entirely by `transform` rather than by
|
|
43
|
+
* layout properties (`width`/`left`), so both can run
|
|
44
|
+
* `useNativeDriver: true`: RN's native animation driver can only animate
|
|
45
|
+
* transforms, and a JS-driven (`useNativeDriver: false`) `Animated.timing`
|
|
46
|
+
* or `Animated.loop` schedules its next frame via a plain `setTimeout` —
|
|
47
|
+
* one that routinely fires a tick after a test's `render()` returns but
|
|
48
|
+
* before unmount, outside any `act()` boundary, producing a real (if
|
|
49
|
+
* harmless) "update not wrapped in act()" warning under
|
|
50
|
+
* `@testing-library/react-native` on every render of this component. The
|
|
51
|
+
* determinate fill stays a constant `width: '100%'` and instead animates
|
|
52
|
+
* `transform: [{ scaleX }]` with `transformOrigin: 'left'` (so it grows
|
|
53
|
+
* from the left edge, not from center); the indeterminate pulse similarly
|
|
54
|
+
* animates `transform: [{ translateX }]` from `-0.4 * trackWidth` to
|
|
55
|
+
* `trackWidth` (measured via `onLayout`, since a transform's `translateX`
|
|
56
|
+
* needs a pixel offset, not a percentage) rather than animating `left`.
|
|
57
|
+
* Both reproduce the exact same visual motion as the source CSS's
|
|
58
|
+
* `width`/`left` transitions while running fully off the JS thread, which
|
|
59
|
+
* eliminates the warning at its root rather than suppressing it.
|
|
60
|
+
*
|
|
61
|
+
* `role="progressbar"` maps directly to RN's own `accessibilityRole`
|
|
62
|
+
* (unlike `Spinner`, which had to substitute for the web's `role="status"`
|
|
63
|
+
* — `ProgressBar`'s web role already has a 1:1 RN equivalent).
|
|
64
|
+
* `accessibilityValue` carries `now`/`min`/`max` for the determinate case;
|
|
65
|
+
* the indeterminate case omits all three, RN's equivalent of the web
|
|
66
|
+
* version omitting `aria-valuenow`/`aria-valuemin`/`aria-valuemax`. Web's
|
|
67
|
+
* `aria-labelledby` (an id-relationship prop) has no RN equivalent — RN
|
|
68
|
+
* has no DOM ids — so only `aria-label` (`accessibilityLabel`) is ported.
|
|
69
|
+
*
|
|
70
|
+
* @see https://developer.gnome.org/hig/patterns/feedback/progress.html
|
|
71
|
+
*/
|
|
72
|
+
export declare const ProgressBar: ({ value, variant, accessibilityLabel, style, onLayout, ...viewProps }: ProgressBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PressableProps, StyleProp, View, ViewStyle } from 'react-native';
|
|
2
|
+
export interface RadioButtonProps extends Omit<PressableProps, 'children' | 'style' | 'onPress'> {
|
|
3
|
+
/** Whether this radio button is the selected one in its group. */
|
|
4
|
+
value: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Called when pressed while unselected. RN has no `name`-attribute
|
|
7
|
+
* grouping like the web `<input type="radio">`, so mutual exclusivity
|
|
8
|
+
* within a group is the consumer's responsibility — render one
|
|
9
|
+
* `RadioButton` per option and drive `value` from shared selection
|
|
10
|
+
* state, flipping it in `onSelect`.
|
|
11
|
+
*/
|
|
12
|
+
onSelect?: () => void;
|
|
13
|
+
/** Accessible label. Required when no visible label is associated. */
|
|
14
|
+
accessibilityLabel?: string;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Single-selection radio button following the GNOME HIG and Adwaita style.
|
|
19
|
+
*
|
|
20
|
+
* Rebuilt on `Pressable`/`Animated.View` rather than ported from
|
|
21
|
+
* `@gnome-ui/react`'s `<input type="radio">`: reuses `Checkbox`'s exact
|
|
22
|
+
* border/background transition technique (same `Animated.Value`, same
|
|
23
|
+
* mount-skip guard so it never animates before the user touches it, same
|
|
24
|
+
* `useResolvedColorScheme()`/`useResolvedContrast()` branching for the
|
|
25
|
+
* idle border color, since the source CSS hardcodes those the same way
|
|
26
|
+
* `Checkbox.module.css` does) — just circular, with a filled dot instead
|
|
27
|
+
* of a checkmark, and no indeterminate state.
|
|
28
|
+
*
|
|
29
|
+
* The web version's `name`-attribute grouping has no RN equivalent, so
|
|
30
|
+
* grouping is fully manual here: render one `RadioButton` per option and
|
|
31
|
+
* manage the selected option in the parent, same as any other controlled
|
|
32
|
+
* list of options.
|
|
33
|
+
*
|
|
34
|
+
* @see https://developer.gnome.org/hig/patterns/controls/radio-buttons.html
|
|
35
|
+
*/
|
|
36
|
+
export declare const RadioButton: import('react').ForwardRefExoticComponent<RadioButtonProps & import('react').RefAttributes<View>>;
|