@rific/auto-paper 0.3.1 → 0.5.1
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 +89 -12
- package/dist/index.d.mts +46 -34
- package/dist/index.d.ts +46 -34
- package/dist/index.js +44 -22
- package/dist/index.mjs +46 -26
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -37,11 +37,8 @@ npm install expo-navigation-bar
|
|
|
37
37
|
import { Provider as AutoPaperProvider } from '@rific/auto-paper'
|
|
38
38
|
|
|
39
39
|
export default function App() {
|
|
40
|
-
const [appearance, setAppearance] = useState<'system' | 'light' | 'dark'>('system')
|
|
41
|
-
const [color, setColor] = useState('#6750a4')
|
|
42
|
-
|
|
43
40
|
return (
|
|
44
|
-
<AutoPaperProvider
|
|
41
|
+
<AutoPaperProvider initialValue={{ appearance: 'system', color: '#6750a4' }}>
|
|
45
42
|
{/* your app */}
|
|
46
43
|
</AutoPaperProvider>
|
|
47
44
|
)
|
|
@@ -51,17 +48,33 @@ export default function App() {
|
|
|
51
48
|
`Provider` renders `null` on the first render while the theme computes, then wraps your app in `PaperProvider` with the computed theme, a matching `StatusBar`, and a background `View`. Use `onReady` to hook into that moment — e.g. to dismiss a splash screen:
|
|
52
49
|
|
|
53
50
|
```tsx
|
|
54
|
-
<AutoPaperProvider
|
|
51
|
+
<AutoPaperProvider initialValue={{ appearance: 'system', color: '#6750a4' }} onReady={SplashScreen.hideAsync}>
|
|
55
52
|
{/* your app */}
|
|
56
53
|
</AutoPaperProvider>
|
|
57
54
|
```
|
|
58
55
|
|
|
56
|
+
Update theme settings from anywhere inside the tree using `useThemeSettings`:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { useThemeSettings } from '@rific/auto-paper'
|
|
60
|
+
|
|
61
|
+
function SettingsScreen() {
|
|
62
|
+
const { settings, set } = useThemeSettings()
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<Button onPress={() => set({ appearance: 'dark' })}>Dark mode</Button>
|
|
66
|
+
<Button onPress={() => set({ color: '#e91e63' })}>Change color</Button>
|
|
67
|
+
</>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
59
72
|
### Choosing a color harmony
|
|
60
73
|
|
|
61
74
|
The `harmony` prop controls how secondary and tertiary colors are derived from your seed. The default is `split-complementary`, which works well for most apps — it keeps secondary and tertiary close together in hue so they feel like a family of accents rather than three competing dominant colors.
|
|
62
75
|
|
|
63
76
|
```tsx
|
|
64
|
-
<AutoPaperProvider
|
|
77
|
+
<AutoPaperProvider initialValue={{ appearance: 'system', color: '#6750a4', harmony: 'split-complementary' }}>
|
|
65
78
|
```
|
|
66
79
|
|
|
67
80
|
| Harmony | Offsets | Character |
|
|
@@ -81,8 +94,7 @@ Pass a `defaults` object to `Provider` to set prop defaults for any of the inclu
|
|
|
81
94
|
import { Button, Chip, Provider as AutoPaperProvider } from '@rific/auto-paper'
|
|
82
95
|
|
|
83
96
|
<AutoPaperProvider
|
|
84
|
-
|
|
85
|
-
color={color}
|
|
97
|
+
initialValue={{ appearance: 'system', color: '#6750a4' }}
|
|
86
98
|
defaults={{
|
|
87
99
|
AppbarHeader: { elevated: true },
|
|
88
100
|
BottomNavigation: { labeled: false },
|
|
@@ -124,7 +136,7 @@ import { Provider as AutoPaperProvider } from '@rific/auto-paper'
|
|
|
124
136
|
export default function App() {
|
|
125
137
|
const { appearance, color } = useSelector((state: RootState) => state.theme)
|
|
126
138
|
return (
|
|
127
|
-
<AutoPaperProvider
|
|
139
|
+
<AutoPaperProvider initialValue={{ appearance, color }} onReady={SplashScreen.hideAsync}>
|
|
128
140
|
{/* your app */}
|
|
129
141
|
</AutoPaperProvider>
|
|
130
142
|
)
|
|
@@ -178,15 +190,38 @@ export default function App() {
|
|
|
178
190
|
|
|
179
191
|
| Prop | Type | Description |
|
|
180
192
|
|---|---|---|
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `harmony` | `ColorHarmony` | Color harmony mode (default: `'split-complementary'`) |
|
|
193
|
+
| `initialValue` | `Partial<ThemeSettings>` | Initial theme settings — `appearance`, `color`, `harmony`, `blur`, `blurTint`. Defaults from `defaultThemeSettings` fill any omitted fields. |
|
|
194
|
+
| `onChange` | `(settings: ThemeSettings) => void` | Called whenever settings change via `useThemeSettings().set()` |
|
|
184
195
|
| `children` | `ReactNode` | |
|
|
185
196
|
| `defaults` | `PaperDefaults` | Prop defaults for wrapper components (see below) |
|
|
186
197
|
| `onReady` | `() => void` | Called once when the theme first resolves |
|
|
187
198
|
| `statusBarProps` | `StatusBarProps` | Spread over the auto-derived `StatusBar` defaults |
|
|
188
199
|
| `style` | `StyleProp<ViewStyle>` | Applied to the wrapper `View` |
|
|
189
200
|
|
|
201
|
+
`ThemeSettings` fields:
|
|
202
|
+
|
|
203
|
+
| Field | Type | Default |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `appearance` | `'system' \| 'light' \| 'dark'` | `'system'` |
|
|
206
|
+
| `color` | `string` | `'#6750a4'` |
|
|
207
|
+
| `harmony` | `ColorHarmony` | `'split-complementary'` |
|
|
208
|
+
| `blur` | `boolean` | `true` |
|
|
209
|
+
| `blurTint` | `number` | `0.2` |
|
|
210
|
+
|
|
211
|
+
### `useThemeSettings()`
|
|
212
|
+
|
|
213
|
+
Returns `{ settings: ThemeSettings, set: (patch: Partial<ThemeSettings>) => void }`. Use this hook from any component inside `Provider` to read or update the current theme settings.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { useThemeSettings } from '@rific/auto-paper'
|
|
217
|
+
|
|
218
|
+
const { settings, set } = useThemeSettings()
|
|
219
|
+
|
|
220
|
+
set({ appearance: 'dark' })
|
|
221
|
+
set({ color: '#e91e63' })
|
|
222
|
+
set({ harmony: 'triadic' })
|
|
223
|
+
```
|
|
224
|
+
|
|
190
225
|
### `useComputedTheme(appearance, color, harmony?)`
|
|
191
226
|
|
|
192
227
|
Returns `MD3Theme | null`. `null` on the first render while the theme computes.
|
|
@@ -228,6 +263,48 @@ import { BottomNavigation } from '@rific/auto-paper'
|
|
|
228
263
|
|
|
229
264
|
`BottomNavigation.Bar` and `BottomNavigation.SceneMap` are also available and both sync the navigation bar.
|
|
230
265
|
|
|
266
|
+
### `Chip`
|
|
267
|
+
|
|
268
|
+
A thin wrapper around `react-native-paper`'s `Chip` that adds a `variant` prop for applying theme-derived container colors.
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import { Chip } from '@rific/auto-paper'
|
|
272
|
+
|
|
273
|
+
<Chip>Default</Chip>
|
|
274
|
+
<Chip variant="primary">Primary</Chip>
|
|
275
|
+
<Chip variant="secondary">Secondary</Chip>
|
|
276
|
+
<Chip variant="tertiary">Tertiary</Chip>
|
|
277
|
+
<Chip variant="surface">Surface</Chip>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
| Prop | Type | Description |
|
|
281
|
+
|---|---|---|
|
|
282
|
+
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'surface'` | Applies the matching container color as background and its `on*` counterpart as `selectedColor` |
|
|
283
|
+
| ...all `ChipProps` | | All props from `react-native-paper`'s `Chip` are supported |
|
|
284
|
+
|
|
285
|
+
`ChipProps` is exported from `@rific/auto-paper` and extends `react-native-paper`'s `ChipProps` with the `variant` field. Use `PaperChipProps` if you need the base paper type.
|
|
286
|
+
|
|
287
|
+
### `IconButton`
|
|
288
|
+
|
|
289
|
+
A thin wrapper around `react-native-paper`'s `IconButton` that adds a `variant` prop for applying theme-derived container and icon colors.
|
|
290
|
+
|
|
291
|
+
```tsx
|
|
292
|
+
import { IconButton } from '@rific/auto-paper'
|
|
293
|
+
|
|
294
|
+
<IconButton icon="pencil" />
|
|
295
|
+
<IconButton icon="pencil" variant="primary" />
|
|
296
|
+
<IconButton icon="pencil" variant="secondary" />
|
|
297
|
+
<IconButton icon="pencil" variant="tertiary" />
|
|
298
|
+
<IconButton icon="pencil" variant="surface" />
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
| Prop | Type | Description |
|
|
302
|
+
|---|---|---|
|
|
303
|
+
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'surface'` | Sets `containerColor` and `iconColor` from the matching theme color pair |
|
|
304
|
+
| ...all `IconButtonProps` | | All props from `react-native-paper`'s `IconButton` are supported — explicit `containerColor` or `iconColor` override the variant |
|
|
305
|
+
|
|
306
|
+
`IconButtonProps` is exported from `@rific/auto-paper` and extends `react-native-paper`'s `IconButtonProps` with the `variant` field. Use `PaperIconButtonProps` if you need the base paper type.
|
|
307
|
+
|
|
231
308
|
### `PaperDefaults` / `usePaperDefaults`
|
|
232
309
|
|
|
233
310
|
`PaperDefaults` is the type for the `defaults` prop on `Provider`:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as react_native_paper_lib_typescript_utils_forwardRef from 'react-native-paper/lib/typescript/utils/forwardRef';
|
|
2
2
|
import * as react_native from 'react-native';
|
|
3
3
|
import { StyleProp, ViewStyle, TextInput as TextInput$1, StatusBarProps } from 'react-native';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import React__default, { ReactNode } from 'react';
|
|
6
4
|
import * as react_native_paper from 'react-native-paper';
|
|
7
|
-
import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps, DialogProps as DialogProps$1, DialogTitleProps, DialogContentProps, DialogActionsProps, DialogScrollAreaProps, FABProps, IconButtonProps, MenuProps as MenuProps$1, MenuItemProps, TextInputProps } from 'react-native-paper';
|
|
8
|
-
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps,
|
|
9
|
-
import * as
|
|
5
|
+
import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps as ChipProps$1, DialogProps as DialogProps$1, DialogTitleProps, DialogContentProps, DialogActionsProps, DialogScrollAreaProps, FABProps, IconButtonProps as IconButtonProps$1, MenuProps as MenuProps$1, MenuItemProps, TextInputProps } from 'react-native-paper';
|
|
6
|
+
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, FABProps, ChipProps as PaperChipProps, DialogProps as PaperDialogProps, IconButtonProps as PaperIconButtonProps, MenuProps as PaperMenuProps, TextInputProps } from 'react-native-paper';
|
|
7
|
+
import * as react from 'react';
|
|
8
|
+
import react__default, { ReactNode } from 'react';
|
|
10
9
|
import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
|
|
11
10
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
12
11
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
@@ -14,11 +13,11 @@ import * as redux from 'redux';
|
|
|
14
13
|
|
|
15
14
|
declare function useBlur(override?: boolean): boolean;
|
|
16
15
|
|
|
17
|
-
declare function Header({ style, ...props }: AppbarHeaderProps):
|
|
16
|
+
declare function Header({ style, ...props }: AppbarHeaderProps): react.JSX.Element;
|
|
18
17
|
declare const Appbar: {
|
|
19
18
|
Header: typeof Header;
|
|
20
19
|
Content: {
|
|
21
|
-
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props):
|
|
20
|
+
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props): react.JSX.Element;
|
|
22
21
|
displayName: string;
|
|
23
22
|
};
|
|
24
23
|
Action: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarActionProps>;
|
|
@@ -40,35 +39,41 @@ type Props$2 = {
|
|
|
40
39
|
value: ThemeAppearance;
|
|
41
40
|
onChange: (appearance: ThemeAppearance) => void;
|
|
42
41
|
};
|
|
43
|
-
declare const AppearancePicker: ({ value, onChange }: Props$2) =>
|
|
42
|
+
declare const AppearancePicker: ({ value, onChange }: Props$2) => react.JSX.Element;
|
|
44
43
|
|
|
45
44
|
type BlurViewProps = BlurViewProps$1 & {
|
|
46
45
|
blur?: boolean;
|
|
47
46
|
children?: ReactNode;
|
|
48
47
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
49
48
|
style?: StyleProp<ViewStyle>;
|
|
49
|
+
tintColor?: string;
|
|
50
|
+
tintOpacity?: number;
|
|
51
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
50
52
|
};
|
|
51
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) =>
|
|
53
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
52
54
|
|
|
53
|
-
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>):
|
|
55
|
+
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
54
56
|
declare namespace BottomNavigationComponent {
|
|
55
|
-
var Bar: (props: BarProps) =>
|
|
57
|
+
var Bar: (props: BarProps) => react__default.JSX.Element;
|
|
56
58
|
var SceneMap: <Route extends BottomNavigationRoute>(scenes: {
|
|
57
|
-
[key: string]:
|
|
59
|
+
[key: string]: react__default.ComponentType<{
|
|
58
60
|
route: Route;
|
|
59
61
|
jumpTo: (key: string) => void;
|
|
60
62
|
}>;
|
|
61
63
|
}) => ({ route, jumpTo, }: {
|
|
62
64
|
route: Route;
|
|
63
65
|
jumpTo: (key: string) => void;
|
|
64
|
-
}) =>
|
|
66
|
+
}) => react__default.JSX.Element;
|
|
65
67
|
}
|
|
66
|
-
type BarProps =
|
|
68
|
+
type BarProps = react__default.ComponentProps<typeof BottomNavigation$1.Bar>;
|
|
67
69
|
declare const BottomNavigation: typeof BottomNavigationComponent;
|
|
68
70
|
|
|
69
|
-
declare function Button(props: ButtonProps):
|
|
71
|
+
declare function Button(props: ButtonProps): react.JSX.Element;
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
type ChipProps = ChipProps$1 & {
|
|
74
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
75
|
+
};
|
|
76
|
+
declare function Chip({ variant, style, selectedColor, ...props }: ChipProps): react.JSX.Element;
|
|
72
77
|
|
|
73
78
|
type SeedColor = {
|
|
74
79
|
label: string;
|
|
@@ -81,47 +86,50 @@ type Props$1 = {
|
|
|
81
86
|
colors?: SeedColor[];
|
|
82
87
|
blur?: boolean;
|
|
83
88
|
};
|
|
84
|
-
declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$1) =>
|
|
89
|
+
declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$1) => react.JSX.Element;
|
|
85
90
|
|
|
86
91
|
type DialogProps = DialogProps$1 & {
|
|
87
92
|
blur?: boolean;
|
|
88
93
|
};
|
|
89
|
-
declare function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }: DialogProps):
|
|
94
|
+
declare function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }: DialogProps): react__default.JSX.Element | null;
|
|
90
95
|
declare namespace DialogComponent {
|
|
91
|
-
var Title:
|
|
92
|
-
var Content:
|
|
93
|
-
var Actions:
|
|
94
|
-
var ScrollArea:
|
|
96
|
+
var Title: react__default.FC<DialogTitleProps>;
|
|
97
|
+
var Content: react__default.FC<DialogContentProps>;
|
|
98
|
+
var Actions: react__default.FC<DialogActionsProps>;
|
|
99
|
+
var ScrollArea: react__default.FC<DialogScrollAreaProps>;
|
|
95
100
|
}
|
|
96
101
|
declare const Dialog: typeof DialogComponent;
|
|
97
102
|
|
|
98
|
-
declare function FAB(props: FABProps):
|
|
103
|
+
declare function FAB(props: FABProps): react.JSX.Element;
|
|
99
104
|
|
|
100
105
|
type Props = {
|
|
101
106
|
value: ColorHarmony;
|
|
102
107
|
onChange: (harmony: ColorHarmony) => void;
|
|
103
108
|
blur?: boolean;
|
|
104
109
|
};
|
|
105
|
-
declare const HarmonyPicker: ({ value, onChange, blur: blurProp }: Props) =>
|
|
110
|
+
declare const HarmonyPicker: ({ value, onChange, blur: blurProp }: Props) => react.JSX.Element;
|
|
106
111
|
|
|
107
|
-
|
|
112
|
+
type IconButtonProps = IconButtonProps$1 & {
|
|
113
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
114
|
+
};
|
|
115
|
+
declare function IconButton({ variant, iconColor, containerColor, ...props }: IconButtonProps): react.JSX.Element;
|
|
108
116
|
|
|
109
117
|
type MenuProps = MenuProps$1 & {
|
|
110
118
|
blur?: boolean;
|
|
111
119
|
};
|
|
112
|
-
declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) =>
|
|
113
|
-
Item:
|
|
120
|
+
declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) => react__default.JSX.Element) & {
|
|
121
|
+
Item: react__default.FC<MenuItemProps>;
|
|
114
122
|
};
|
|
115
123
|
|
|
116
|
-
declare const TextInput:
|
|
124
|
+
declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
|
|
117
125
|
|
|
118
126
|
type PaperDefaults = {
|
|
119
127
|
AppbarHeader?: Partial<AppbarHeaderProps>;
|
|
120
128
|
BottomNavigation?: Partial<BottomNavigationProps<BottomNavigationRoute>>;
|
|
121
129
|
Button?: Partial<ButtonProps>;
|
|
122
|
-
Chip?: Partial<ChipProps>;
|
|
130
|
+
Chip?: Partial<ChipProps$1>;
|
|
123
131
|
FAB?: Partial<FABProps>;
|
|
124
|
-
IconButton?: Partial<IconButtonProps>;
|
|
132
|
+
IconButton?: Partial<IconButtonProps$1>;
|
|
125
133
|
TextInput?: Partial<TextInputProps>;
|
|
126
134
|
};
|
|
127
135
|
declare function usePaperDefaults(): PaperDefaults;
|
|
@@ -188,10 +196,10 @@ type ThemeSettingsContextType = {
|
|
|
188
196
|
settings: ThemeSettings;
|
|
189
197
|
set: (patch: Partial<ThemeSettings>) => void;
|
|
190
198
|
};
|
|
191
|
-
declare const ThemeSettingsContext:
|
|
199
|
+
declare const ThemeSettingsContext: react.Context<ThemeSettingsContextType>;
|
|
192
200
|
|
|
193
201
|
type ProviderProps = {
|
|
194
|
-
|
|
202
|
+
initialValue?: Partial<ThemeSettings>;
|
|
195
203
|
onChange?: (settings: ThemeSettings) => void;
|
|
196
204
|
children: ReactNode;
|
|
197
205
|
defaults?: PaperDefaults;
|
|
@@ -200,7 +208,7 @@ type ProviderProps = {
|
|
|
200
208
|
statusBarProps?: StatusBarProps;
|
|
201
209
|
style?: StyleProp<ViewStyle>;
|
|
202
210
|
};
|
|
203
|
-
declare function Provider({
|
|
211
|
+
declare function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }: ProviderProps): react.JSX.Element | null;
|
|
204
212
|
|
|
205
213
|
declare const useThemeSettings: () => ThemeSettingsContextType;
|
|
206
214
|
|
|
@@ -216,6 +224,10 @@ type RGB = {
|
|
|
216
224
|
};
|
|
217
225
|
declare const getRgb: (value: string) => RGB | null;
|
|
218
226
|
|
|
227
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
228
|
+
|
|
229
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
230
|
+
|
|
219
231
|
declare const isDarkColor: (value: string) => boolean;
|
|
220
232
|
|
|
221
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
233
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as react_native_paper_lib_typescript_utils_forwardRef from 'react-native-paper/lib/typescript/utils/forwardRef';
|
|
2
2
|
import * as react_native from 'react-native';
|
|
3
3
|
import { StyleProp, ViewStyle, TextInput as TextInput$1, StatusBarProps } from 'react-native';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import React__default, { ReactNode } from 'react';
|
|
6
4
|
import * as react_native_paper from 'react-native-paper';
|
|
7
|
-
import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps, DialogProps as DialogProps$1, DialogTitleProps, DialogContentProps, DialogActionsProps, DialogScrollAreaProps, FABProps, IconButtonProps, MenuProps as MenuProps$1, MenuItemProps, TextInputProps } from 'react-native-paper';
|
|
8
|
-
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps,
|
|
9
|
-
import * as
|
|
5
|
+
import { AppbarHeaderProps, MD3Theme, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps as ChipProps$1, DialogProps as DialogProps$1, DialogTitleProps, DialogContentProps, DialogActionsProps, DialogScrollAreaProps, FABProps, IconButtonProps as IconButtonProps$1, MenuProps as MenuProps$1, MenuItemProps, TextInputProps } from 'react-native-paper';
|
|
6
|
+
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, FABProps, ChipProps as PaperChipProps, DialogProps as PaperDialogProps, IconButtonProps as PaperIconButtonProps, MenuProps as PaperMenuProps, TextInputProps } from 'react-native-paper';
|
|
7
|
+
import * as react from 'react';
|
|
8
|
+
import react__default, { ReactNode } from 'react';
|
|
10
9
|
import { BlurViewProps as BlurViewProps$1 } from 'expo-blur';
|
|
11
10
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
12
11
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
@@ -14,11 +13,11 @@ import * as redux from 'redux';
|
|
|
14
13
|
|
|
15
14
|
declare function useBlur(override?: boolean): boolean;
|
|
16
15
|
|
|
17
|
-
declare function Header({ style, ...props }: AppbarHeaderProps):
|
|
16
|
+
declare function Header({ style, ...props }: AppbarHeaderProps): react.JSX.Element;
|
|
18
17
|
declare const Appbar: {
|
|
19
18
|
Header: typeof Header;
|
|
20
19
|
Content: {
|
|
21
|
-
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props):
|
|
20
|
+
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props): react.JSX.Element;
|
|
22
21
|
displayName: string;
|
|
23
22
|
};
|
|
24
23
|
Action: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarActionProps>;
|
|
@@ -40,35 +39,41 @@ type Props$2 = {
|
|
|
40
39
|
value: ThemeAppearance;
|
|
41
40
|
onChange: (appearance: ThemeAppearance) => void;
|
|
42
41
|
};
|
|
43
|
-
declare const AppearancePicker: ({ value, onChange }: Props$2) =>
|
|
42
|
+
declare const AppearancePicker: ({ value, onChange }: Props$2) => react.JSX.Element;
|
|
44
43
|
|
|
45
44
|
type BlurViewProps = BlurViewProps$1 & {
|
|
46
45
|
blur?: boolean;
|
|
47
46
|
children?: ReactNode;
|
|
48
47
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
49
48
|
style?: StyleProp<ViewStyle>;
|
|
49
|
+
tintColor?: string;
|
|
50
|
+
tintOpacity?: number;
|
|
51
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
50
52
|
};
|
|
51
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) =>
|
|
53
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
52
54
|
|
|
53
|
-
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>):
|
|
55
|
+
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
54
56
|
declare namespace BottomNavigationComponent {
|
|
55
|
-
var Bar: (props: BarProps) =>
|
|
57
|
+
var Bar: (props: BarProps) => react__default.JSX.Element;
|
|
56
58
|
var SceneMap: <Route extends BottomNavigationRoute>(scenes: {
|
|
57
|
-
[key: string]:
|
|
59
|
+
[key: string]: react__default.ComponentType<{
|
|
58
60
|
route: Route;
|
|
59
61
|
jumpTo: (key: string) => void;
|
|
60
62
|
}>;
|
|
61
63
|
}) => ({ route, jumpTo, }: {
|
|
62
64
|
route: Route;
|
|
63
65
|
jumpTo: (key: string) => void;
|
|
64
|
-
}) =>
|
|
66
|
+
}) => react__default.JSX.Element;
|
|
65
67
|
}
|
|
66
|
-
type BarProps =
|
|
68
|
+
type BarProps = react__default.ComponentProps<typeof BottomNavigation$1.Bar>;
|
|
67
69
|
declare const BottomNavigation: typeof BottomNavigationComponent;
|
|
68
70
|
|
|
69
|
-
declare function Button(props: ButtonProps):
|
|
71
|
+
declare function Button(props: ButtonProps): react.JSX.Element;
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
type ChipProps = ChipProps$1 & {
|
|
74
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
75
|
+
};
|
|
76
|
+
declare function Chip({ variant, style, selectedColor, ...props }: ChipProps): react.JSX.Element;
|
|
72
77
|
|
|
73
78
|
type SeedColor = {
|
|
74
79
|
label: string;
|
|
@@ -81,47 +86,50 @@ type Props$1 = {
|
|
|
81
86
|
colors?: SeedColor[];
|
|
82
87
|
blur?: boolean;
|
|
83
88
|
};
|
|
84
|
-
declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$1) =>
|
|
89
|
+
declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$1) => react.JSX.Element;
|
|
85
90
|
|
|
86
91
|
type DialogProps = DialogProps$1 & {
|
|
87
92
|
blur?: boolean;
|
|
88
93
|
};
|
|
89
|
-
declare function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }: DialogProps):
|
|
94
|
+
declare function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }: DialogProps): react__default.JSX.Element | null;
|
|
90
95
|
declare namespace DialogComponent {
|
|
91
|
-
var Title:
|
|
92
|
-
var Content:
|
|
93
|
-
var Actions:
|
|
94
|
-
var ScrollArea:
|
|
96
|
+
var Title: react__default.FC<DialogTitleProps>;
|
|
97
|
+
var Content: react__default.FC<DialogContentProps>;
|
|
98
|
+
var Actions: react__default.FC<DialogActionsProps>;
|
|
99
|
+
var ScrollArea: react__default.FC<DialogScrollAreaProps>;
|
|
95
100
|
}
|
|
96
101
|
declare const Dialog: typeof DialogComponent;
|
|
97
102
|
|
|
98
|
-
declare function FAB(props: FABProps):
|
|
103
|
+
declare function FAB(props: FABProps): react.JSX.Element;
|
|
99
104
|
|
|
100
105
|
type Props = {
|
|
101
106
|
value: ColorHarmony;
|
|
102
107
|
onChange: (harmony: ColorHarmony) => void;
|
|
103
108
|
blur?: boolean;
|
|
104
109
|
};
|
|
105
|
-
declare const HarmonyPicker: ({ value, onChange, blur: blurProp }: Props) =>
|
|
110
|
+
declare const HarmonyPicker: ({ value, onChange, blur: blurProp }: Props) => react.JSX.Element;
|
|
106
111
|
|
|
107
|
-
|
|
112
|
+
type IconButtonProps = IconButtonProps$1 & {
|
|
113
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
|
|
114
|
+
};
|
|
115
|
+
declare function IconButton({ variant, iconColor, containerColor, ...props }: IconButtonProps): react.JSX.Element;
|
|
108
116
|
|
|
109
117
|
type MenuProps = MenuProps$1 & {
|
|
110
118
|
blur?: boolean;
|
|
111
119
|
};
|
|
112
|
-
declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) =>
|
|
113
|
-
Item:
|
|
120
|
+
declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) => react__default.JSX.Element) & {
|
|
121
|
+
Item: react__default.FC<MenuItemProps>;
|
|
114
122
|
};
|
|
115
123
|
|
|
116
|
-
declare const TextInput:
|
|
124
|
+
declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
|
|
117
125
|
|
|
118
126
|
type PaperDefaults = {
|
|
119
127
|
AppbarHeader?: Partial<AppbarHeaderProps>;
|
|
120
128
|
BottomNavigation?: Partial<BottomNavigationProps<BottomNavigationRoute>>;
|
|
121
129
|
Button?: Partial<ButtonProps>;
|
|
122
|
-
Chip?: Partial<ChipProps>;
|
|
130
|
+
Chip?: Partial<ChipProps$1>;
|
|
123
131
|
FAB?: Partial<FABProps>;
|
|
124
|
-
IconButton?: Partial<IconButtonProps>;
|
|
132
|
+
IconButton?: Partial<IconButtonProps$1>;
|
|
125
133
|
TextInput?: Partial<TextInputProps>;
|
|
126
134
|
};
|
|
127
135
|
declare function usePaperDefaults(): PaperDefaults;
|
|
@@ -188,10 +196,10 @@ type ThemeSettingsContextType = {
|
|
|
188
196
|
settings: ThemeSettings;
|
|
189
197
|
set: (patch: Partial<ThemeSettings>) => void;
|
|
190
198
|
};
|
|
191
|
-
declare const ThemeSettingsContext:
|
|
199
|
+
declare const ThemeSettingsContext: react.Context<ThemeSettingsContextType>;
|
|
192
200
|
|
|
193
201
|
type ProviderProps = {
|
|
194
|
-
|
|
202
|
+
initialValue?: Partial<ThemeSettings>;
|
|
195
203
|
onChange?: (settings: ThemeSettings) => void;
|
|
196
204
|
children: ReactNode;
|
|
197
205
|
defaults?: PaperDefaults;
|
|
@@ -200,7 +208,7 @@ type ProviderProps = {
|
|
|
200
208
|
statusBarProps?: StatusBarProps;
|
|
201
209
|
style?: StyleProp<ViewStyle>;
|
|
202
210
|
};
|
|
203
|
-
declare function Provider({
|
|
211
|
+
declare function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }: ProviderProps): react.JSX.Element | null;
|
|
204
212
|
|
|
205
213
|
declare const useThemeSettings: () => ThemeSettingsContextType;
|
|
206
214
|
|
|
@@ -216,6 +224,10 @@ type RGB = {
|
|
|
216
224
|
};
|
|
217
225
|
declare const getRgb: (value: string) => RGB | null;
|
|
218
226
|
|
|
227
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
228
|
+
|
|
229
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
230
|
+
|
|
219
231
|
declare const isDarkColor: (value: string) => boolean;
|
|
220
232
|
|
|
221
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
233
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
getBlendedColor: () => getBlendedColor,
|
|
44
44
|
getHex: () => getHex,
|
|
45
45
|
getRgb: () => getRgb,
|
|
46
|
+
getTintTextColor: () => getTintTextColor,
|
|
47
|
+
getTonalColor: () => getTonalColor,
|
|
46
48
|
getTriadicPalette: () => getTriadicPalette,
|
|
47
49
|
isDarkColor: () => isDarkColor,
|
|
48
50
|
selectThemeAppearance: () => selectThemeAppearance,
|
|
@@ -127,18 +129,22 @@ var import_react_native2 = require("react-native");
|
|
|
127
129
|
var import_react_native_paper3 = require("react-native-paper");
|
|
128
130
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
129
131
|
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
130
|
-
var
|
|
132
|
+
var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
|
|
133
|
+
var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
|
|
131
134
|
const { dark, colors } = (0, import_react_native_paper3.useTheme)();
|
|
132
135
|
const { settings } = (0, import_react4.useContext)(ThemeSettingsContext);
|
|
133
|
-
const
|
|
134
|
-
const
|
|
136
|
+
const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
|
|
137
|
+
const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
|
|
138
|
+
const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
|
|
139
|
+
const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
|
|
140
|
+
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
|
|
135
141
|
if (blur)
|
|
136
142
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_expo_blur.BlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
137
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor:
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
|
|
138
144
|
tint,
|
|
139
145
|
children
|
|
140
146
|
] });
|
|
141
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor:
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor: surfaceColor }, style], children: [
|
|
142
148
|
tint,
|
|
143
149
|
children
|
|
144
150
|
] });
|
|
@@ -589,18 +595,20 @@ function useComputedTheme(appearance, color, harmony = "split-complementary") {
|
|
|
589
595
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
590
596
|
var NavBarContext = (0, import_react6.createContext)({});
|
|
591
597
|
var useNavBarContext = () => (0, import_react6.useContext)(NavBarContext);
|
|
592
|
-
function Provider({
|
|
593
|
-
const [settings, setSettings] = (0, import_react6.useState)(() => ({ ...defaultThemeSettings, ...
|
|
594
|
-
const set2 = (0, import_react6.useCallback)(
|
|
595
|
-
(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
598
|
+
function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
|
|
599
|
+
const [settings, setSettings] = (0, import_react6.useState)(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
600
|
+
const set2 = (0, import_react6.useCallback)((patch) => {
|
|
601
|
+
setSettings((prev) => ({ ...prev, ...patch }));
|
|
602
|
+
}, []);
|
|
603
|
+
const onChangeRef = (0, import_react6.useRef)(onChange);
|
|
604
|
+
onChangeRef.current = onChange;
|
|
605
|
+
const prevSettings = (0, import_react6.useRef)(settings);
|
|
606
|
+
(0, import_react6.useEffect)(() => {
|
|
607
|
+
if (prevSettings.current !== settings) {
|
|
608
|
+
prevSettings.current = settings;
|
|
609
|
+
onChangeRef.current?.(settings);
|
|
610
|
+
}
|
|
611
|
+
}, [settings]);
|
|
604
612
|
const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
|
|
605
613
|
const called = (0, import_react6.useRef)(false);
|
|
606
614
|
(0, import_react6.useEffect)(() => {
|
|
@@ -639,7 +647,7 @@ function Bar(props) {
|
|
|
639
647
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper6.BottomNavigation.Bar, { ...props });
|
|
640
648
|
}
|
|
641
649
|
BottomNavigationComponent.Bar = Bar;
|
|
642
|
-
BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation
|
|
650
|
+
BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation?.SceneMap;
|
|
643
651
|
var BottomNavigation = BottomNavigationComponent;
|
|
644
652
|
|
|
645
653
|
// src/components/Button.tsx
|
|
@@ -653,9 +661,12 @@ function Button(props) {
|
|
|
653
661
|
// src/components/Chip.tsx
|
|
654
662
|
var import_react_native_paper8 = require("react-native-paper");
|
|
655
663
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
656
|
-
function Chip(props) {
|
|
664
|
+
function Chip({ variant, style, selectedColor, ...props }) {
|
|
657
665
|
const defaults = usePaperDefaults();
|
|
658
|
-
|
|
666
|
+
const { colors } = (0, import_react_native_paper8.useTheme)();
|
|
667
|
+
const variantStyle = variant === "primary" ? { backgroundColor: colors.primaryContainer } : variant === "secondary" ? { backgroundColor: colors.secondaryContainer } : variant === "tertiary" ? { backgroundColor: colors.tertiaryContainer } : variant === "surface" ? { backgroundColor: colors.surface } : void 0;
|
|
668
|
+
const variantSelectedColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper8.Chip, { ...defaults.Chip, selectedColor: selectedColor ?? variantSelectedColor, ...props, style: [variantStyle, style] });
|
|
659
670
|
}
|
|
660
671
|
|
|
661
672
|
// src/components/ColorPicker.tsx
|
|
@@ -815,9 +826,12 @@ var HarmonyPicker = ({ value, onChange, blur: blurProp }) => {
|
|
|
815
826
|
// src/components/IconButton.tsx
|
|
816
827
|
var import_react_native_paper14 = require("react-native-paper");
|
|
817
828
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
818
|
-
function IconButton(props) {
|
|
829
|
+
function IconButton({ variant, iconColor, containerColor, ...props }) {
|
|
819
830
|
const defaults = usePaperDefaults();
|
|
820
|
-
|
|
831
|
+
const { colors } = (0, import_react_native_paper14.useTheme)();
|
|
832
|
+
const variantContainerColor = variant === "primary" ? colors.primaryContainer : variant === "secondary" ? colors.secondaryContainer : variant === "tertiary" ? colors.tertiaryContainer : variant === "surface" ? colors.surface : void 0;
|
|
833
|
+
const variantIconColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native_paper14.IconButton, { ...defaults.IconButton, containerColor: containerColor ?? variantContainerColor, iconColor: iconColor ?? variantIconColor, ...props });
|
|
821
835
|
}
|
|
822
836
|
|
|
823
837
|
// src/components/TextInput.tsx
|
|
@@ -2403,6 +2417,12 @@ var selectThemeHarmony = (state) => state.harmony;
|
|
|
2403
2417
|
// src/useThemeSettings.ts
|
|
2404
2418
|
var import_react12 = require("react");
|
|
2405
2419
|
var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext);
|
|
2420
|
+
|
|
2421
|
+
// src/utils/getTintTextColor.ts
|
|
2422
|
+
var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
|
|
2423
|
+
const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
|
|
2424
|
+
return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
|
|
2425
|
+
};
|
|
2406
2426
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2407
2427
|
0 && (module.exports = {
|
|
2408
2428
|
Appbar,
|
|
@@ -2426,6 +2446,8 @@ var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext
|
|
|
2426
2446
|
getBlendedColor,
|
|
2427
2447
|
getHex,
|
|
2428
2448
|
getRgb,
|
|
2449
|
+
getTintTextColor,
|
|
2450
|
+
getTonalColor,
|
|
2429
2451
|
getTriadicPalette,
|
|
2430
2452
|
isDarkColor,
|
|
2431
2453
|
selectThemeAppearance,
|
package/dist/index.mjs
CHANGED
|
@@ -71,18 +71,22 @@ import { StyleSheet, View } from "react-native";
|
|
|
71
71
|
import { useTheme as useTheme2 } from "react-native-paper";
|
|
72
72
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
73
73
|
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
74
|
-
var
|
|
74
|
+
var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
|
|
75
|
+
var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
|
|
75
76
|
const { dark, colors } = useTheme2();
|
|
76
77
|
const { settings } = useContext3(ThemeSettingsContext);
|
|
77
|
-
const
|
|
78
|
-
const
|
|
78
|
+
const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
|
|
79
|
+
const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
|
|
80
|
+
const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
|
|
81
|
+
const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
|
|
82
|
+
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
|
|
79
83
|
if (blur)
|
|
80
84
|
return /* @__PURE__ */ jsxs2(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
81
|
-
/* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor:
|
|
85
|
+
/* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
|
|
82
86
|
tint,
|
|
83
87
|
children
|
|
84
88
|
] });
|
|
85
|
-
return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor:
|
|
89
|
+
return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor: surfaceColor }, style], children: [
|
|
86
90
|
tint,
|
|
87
91
|
children
|
|
88
92
|
] });
|
|
@@ -533,18 +537,20 @@ function useComputedTheme(appearance, color, harmony = "split-complementary") {
|
|
|
533
537
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
534
538
|
var NavBarContext = createContext3({});
|
|
535
539
|
var useNavBarContext = () => useContext4(NavBarContext);
|
|
536
|
-
function Provider({
|
|
537
|
-
const [settings, setSettings] = useState2(() => ({ ...defaultThemeSettings, ...
|
|
538
|
-
const set2 = useCallback2(
|
|
539
|
-
(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
540
|
+
function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
|
|
541
|
+
const [settings, setSettings] = useState2(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
542
|
+
const set2 = useCallback2((patch) => {
|
|
543
|
+
setSettings((prev) => ({ ...prev, ...patch }));
|
|
544
|
+
}, []);
|
|
545
|
+
const onChangeRef = useRef(onChange);
|
|
546
|
+
onChangeRef.current = onChange;
|
|
547
|
+
const prevSettings = useRef(settings);
|
|
548
|
+
useEffect2(() => {
|
|
549
|
+
if (prevSettings.current !== settings) {
|
|
550
|
+
prevSettings.current = settings;
|
|
551
|
+
onChangeRef.current?.(settings);
|
|
552
|
+
}
|
|
553
|
+
}, [settings]);
|
|
548
554
|
const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
|
|
549
555
|
const called = useRef(false);
|
|
550
556
|
useEffect2(() => {
|
|
@@ -583,7 +589,7 @@ function Bar(props) {
|
|
|
583
589
|
return /* @__PURE__ */ jsx5(PaperBottomNavigation.Bar, { ...props });
|
|
584
590
|
}
|
|
585
591
|
BottomNavigationComponent.Bar = Bar;
|
|
586
|
-
BottomNavigationComponent.SceneMap = PaperBottomNavigation
|
|
592
|
+
BottomNavigationComponent.SceneMap = PaperBottomNavigation?.SceneMap;
|
|
587
593
|
var BottomNavigation = BottomNavigationComponent;
|
|
588
594
|
|
|
589
595
|
// src/components/Button.tsx
|
|
@@ -595,11 +601,14 @@ function Button(props) {
|
|
|
595
601
|
}
|
|
596
602
|
|
|
597
603
|
// src/components/Chip.tsx
|
|
598
|
-
import { Chip as PaperChip } from "react-native-paper";
|
|
604
|
+
import { Chip as PaperChip, useTheme as useTheme4 } from "react-native-paper";
|
|
599
605
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
600
|
-
function Chip(props) {
|
|
606
|
+
function Chip({ variant, style, selectedColor, ...props }) {
|
|
601
607
|
const defaults = usePaperDefaults();
|
|
602
|
-
|
|
608
|
+
const { colors } = useTheme4();
|
|
609
|
+
const variantStyle = variant === "primary" ? { backgroundColor: colors.primaryContainer } : variant === "secondary" ? { backgroundColor: colors.secondaryContainer } : variant === "tertiary" ? { backgroundColor: colors.tertiaryContainer } : variant === "surface" ? { backgroundColor: colors.surface } : void 0;
|
|
610
|
+
const variantSelectedColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
611
|
+
return /* @__PURE__ */ jsx7(PaperChip, { ...defaults.Chip, selectedColor: selectedColor ?? variantSelectedColor, ...props, style: [variantStyle, style] });
|
|
603
612
|
}
|
|
604
613
|
|
|
605
614
|
// src/components/ColorPicker.tsx
|
|
@@ -610,11 +619,11 @@ import { Icon, TouchableRipple } from "react-native-paper";
|
|
|
610
619
|
// src/components/Dialog.tsx
|
|
611
620
|
import { useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
|
|
612
621
|
import { Animated, StyleSheet as StyleSheet3, TouchableWithoutFeedback, View as View3 } from "react-native";
|
|
613
|
-
import { Dialog as PaperDialog, Portal, useTheme as
|
|
622
|
+
import { Dialog as PaperDialog, Portal, useTheme as useTheme5 } from "react-native-paper";
|
|
614
623
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
615
624
|
function DialogComponent({ blur: blurProp, visible, onDismiss, children, style, ...rest }) {
|
|
616
625
|
const blur = useBlur(blurProp);
|
|
617
|
-
const { roundness, colors } =
|
|
626
|
+
const { roundness, colors } = useTheme5();
|
|
618
627
|
const opacity = useRef2(new Animated.Value(0)).current;
|
|
619
628
|
const [mounted, setMounted] = useState3(visible);
|
|
620
629
|
useEffect4(() => {
|
|
@@ -757,11 +766,14 @@ var HarmonyPicker = ({ value, onChange, blur: blurProp }) => {
|
|
|
757
766
|
};
|
|
758
767
|
|
|
759
768
|
// src/components/IconButton.tsx
|
|
760
|
-
import { IconButton as PaperIconButton } from "react-native-paper";
|
|
769
|
+
import { IconButton as PaperIconButton, useTheme as useTheme6 } from "react-native-paper";
|
|
761
770
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
762
|
-
function IconButton(props) {
|
|
771
|
+
function IconButton({ variant, iconColor, containerColor, ...props }) {
|
|
763
772
|
const defaults = usePaperDefaults();
|
|
764
|
-
|
|
773
|
+
const { colors } = useTheme6();
|
|
774
|
+
const variantContainerColor = variant === "primary" ? colors.primaryContainer : variant === "secondary" ? colors.secondaryContainer : variant === "tertiary" ? colors.tertiaryContainer : variant === "surface" ? colors.surface : void 0;
|
|
775
|
+
const variantIconColor = variant === "primary" ? colors.onPrimaryContainer : variant === "secondary" ? colors.onSecondaryContainer : variant === "tertiary" ? colors.onTertiaryContainer : variant === "surface" ? colors.onSurface : void 0;
|
|
776
|
+
return /* @__PURE__ */ jsx13(PaperIconButton, { ...defaults.IconButton, containerColor: containerColor ?? variantContainerColor, iconColor: iconColor ?? variantIconColor, ...props });
|
|
765
777
|
}
|
|
766
778
|
|
|
767
779
|
// src/components/TextInput.tsx
|
|
@@ -2347,6 +2359,12 @@ var selectThemeHarmony = (state) => state.harmony;
|
|
|
2347
2359
|
// src/useThemeSettings.ts
|
|
2348
2360
|
import { useContext as useContext5 } from "react";
|
|
2349
2361
|
var useThemeSettings = () => useContext5(ThemeSettingsContext);
|
|
2362
|
+
|
|
2363
|
+
// src/utils/getTintTextColor.ts
|
|
2364
|
+
var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
|
|
2365
|
+
const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
|
|
2366
|
+
return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
|
|
2367
|
+
};
|
|
2350
2368
|
export {
|
|
2351
2369
|
Appbar,
|
|
2352
2370
|
AppearancePicker,
|
|
@@ -2369,6 +2387,8 @@ export {
|
|
|
2369
2387
|
getBlendedColor,
|
|
2370
2388
|
getHex,
|
|
2371
2389
|
getRgb,
|
|
2390
|
+
getTintTextColor,
|
|
2391
|
+
getTonalColor,
|
|
2372
2392
|
getTriadicPalette,
|
|
2373
2393
|
isDarkColor,
|
|
2374
2394
|
selectThemeAppearance,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rific/auto-paper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Adaptive react-native-paper theming: triadic palette from a seed color + system/light/dark appearance",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -56,6 +56,9 @@
|
|
|
56
56
|
"typecheck": "tsc --noEmit",
|
|
57
57
|
"preversion": "npm run lint && npm test && npm run build"
|
|
58
58
|
},
|
|
59
|
+
"overrides": {
|
|
60
|
+
"esbuild": "0.28.1"
|
|
61
|
+
},
|
|
59
62
|
"devDependencies": {
|
|
60
63
|
"@reduxjs/toolkit": "^2.0.0",
|
|
61
64
|
"@testing-library/dom": "^10.4.1",
|