@rific/auto-paper 0.1.3 → 0.2.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 +44 -2
- package/dist/index.d.mts +38 -6
- package/dist/index.d.ts +38 -6
- package/dist/index.js +99 -37
- package/dist/index.mjs +72 -22
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Adaptive theming for [`react-native-paper`](https://callstack.github.io/react-na
|
|
|
8
8
|
- System/light/dark appearance with live updates via `Appearance` API
|
|
9
9
|
- Tinted surface, surfaceVariant, outline, and elevation levels derived from the seed
|
|
10
10
|
- Optional Redux slice for wiring appearance and color into your store
|
|
11
|
-
- Wrapper components (`Button`, `Chip`, `FAB`, `IconButton`, `TextInput`) with prop defaults via context
|
|
11
|
+
- Wrapper components (`Appbar`, `BottomNavigation`, `Button`, `Chip`, `FAB`, `IconButton`, `TextInput`) with prop defaults via context
|
|
12
12
|
- All color utilities exported for standalone use
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
@@ -23,6 +23,12 @@ Peer dependencies:
|
|
|
23
23
|
npm install react-native react-native-paper
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
Optional — needed only if you use `BottomNavigation` on Android (syncs the system navigation bar color):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install expo-navigation-bar
|
|
30
|
+
```
|
|
31
|
+
|
|
26
32
|
## Usage
|
|
27
33
|
|
|
28
34
|
### Provider (simplest)
|
|
@@ -61,6 +67,8 @@ import { Button, Chip, Provider as AutoPaperProvider } from '@rific/auto-paper'
|
|
|
61
67
|
appearance={appearance}
|
|
62
68
|
color={color}
|
|
63
69
|
defaults={{
|
|
70
|
+
AppbarHeader: { elevated: true },
|
|
71
|
+
BottomNavigation: { labeled: false },
|
|
64
72
|
Button: { mode: 'contained' },
|
|
65
73
|
Chip: { compact: true },
|
|
66
74
|
}}
|
|
@@ -71,7 +79,7 @@ import { Button, Chip, Provider as AutoPaperProvider } from '@rific/auto-paper'
|
|
|
71
79
|
</AutoPaperProvider>
|
|
72
80
|
```
|
|
73
81
|
|
|
74
|
-
Available wrapper components: `Button`, `Chip`, `FAB`, `IconButton`, `TextInput`. Each is a thin wrapper around the matching `react-native-paper` component and accepts the same props.
|
|
82
|
+
Available wrapper components: `Appbar`, `BottomNavigation`, `Button`, `Chip`, `FAB`, `IconButton`, `TextInput`. Each is a thin wrapper around the matching `react-native-paper` component and accepts the same props.
|
|
75
83
|
|
|
76
84
|
### With Redux
|
|
77
85
|
|
|
@@ -169,12 +177,46 @@ Returns `MD3Theme | null`. `null` on the first render while the theme computes.
|
|
|
169
177
|
const theme = useComputedTheme('system', '#6750a4')
|
|
170
178
|
```
|
|
171
179
|
|
|
180
|
+
### `Appbar`
|
|
181
|
+
|
|
182
|
+
A thin wrapper around `react-native-paper`'s `Appbar` that automatically syncs `StatusBar` background color and bar style to the current theme surface color.
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { Appbar } from '@rific/auto-paper'
|
|
186
|
+
|
|
187
|
+
<Appbar.Header>
|
|
188
|
+
<Appbar.BackAction onPress={router.back} />
|
|
189
|
+
<Appbar.Content title="Settings" />
|
|
190
|
+
<Appbar.Action icon="magnify" onPress={onSearch} />
|
|
191
|
+
</Appbar.Header>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`Appbar.Content`, `Appbar.Action`, and `Appbar.BackAction` are re-exported directly from `react-native-paper`. Only `Appbar.Header` is wrapped — it applies `AppbarHeader` defaults from context and renders the synced `StatusBar`.
|
|
195
|
+
|
|
196
|
+
### `BottomNavigation`
|
|
197
|
+
|
|
198
|
+
A thin wrapper around `react-native-paper`'s `BottomNavigation` that automatically syncs the Android system navigation bar color and button style to the current theme surface color (requires `expo-navigation-bar`; silently no-ops when not installed).
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import { BottomNavigation } from '@rific/auto-paper'
|
|
202
|
+
|
|
203
|
+
<BottomNavigation
|
|
204
|
+
navigationState={{ index, routes }}
|
|
205
|
+
onIndexChange={setIndex}
|
|
206
|
+
renderScene={BottomNavigation.SceneMap({ home: HomeScreen, settings: SettingsScreen })}
|
|
207
|
+
/>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
`BottomNavigation.Bar` and `BottomNavigation.SceneMap` are also available and both sync the navigation bar.
|
|
211
|
+
|
|
172
212
|
### `PaperDefaults` / `usePaperDefaults`
|
|
173
213
|
|
|
174
214
|
`PaperDefaults` is the type for the `defaults` prop on `Provider`:
|
|
175
215
|
|
|
176
216
|
```ts
|
|
177
217
|
type PaperDefaults = {
|
|
218
|
+
AppbarHeader?: Partial<AppbarHeaderProps>
|
|
219
|
+
BottomNavigation?: Partial<BottomNavigationProps<BottomNavigationRoute>>
|
|
178
220
|
Button?: Partial<ButtonProps>
|
|
179
221
|
Chip?: Partial<ChipProps>
|
|
180
222
|
FAB?: Partial<FABProps>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
export { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
|
|
4
|
-
import * as react from 'react';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import * as react_native_paper_lib_typescript_utils_forwardRef from 'react-native-paper/lib/typescript/utils/forwardRef';
|
|
2
|
+
import * as react_native from 'react-native';
|
|
6
3
|
import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import react__default, { ReactNode } from 'react';
|
|
6
|
+
import * as react_native_paper from 'react-native-paper';
|
|
7
|
+
import { AppbarHeaderProps, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps, MD3Theme } from 'react-native-paper';
|
|
8
|
+
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
|
|
9
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
10
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
8
11
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
9
12
|
import * as redux from 'redux';
|
|
10
13
|
|
|
14
|
+
declare function Header({ style, ...props }: AppbarHeaderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare const Appbar: {
|
|
16
|
+
Header: typeof Header;
|
|
17
|
+
Content: {
|
|
18
|
+
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props): react.JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Action: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarActionProps>;
|
|
22
|
+
BackAction: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarBackActionProps>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react_jsx_runtime.JSX.Element;
|
|
26
|
+
declare namespace BottomNavigationComponent {
|
|
27
|
+
var Bar: (props: BarProps) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
var SceneMap: <Route extends BottomNavigationRoute>(scenes: {
|
|
29
|
+
[key: string]: react__default.ComponentType<{
|
|
30
|
+
route: Route;
|
|
31
|
+
jumpTo: (key: string) => void;
|
|
32
|
+
}>;
|
|
33
|
+
}) => ({ route, jumpTo, }: {
|
|
34
|
+
route: Route;
|
|
35
|
+
jumpTo: (key: string) => void;
|
|
36
|
+
}) => react__default.JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
type BarProps = react__default.ComponentProps<typeof BottomNavigation$1.Bar>;
|
|
39
|
+
declare const BottomNavigation: typeof BottomNavigationComponent;
|
|
40
|
+
|
|
11
41
|
declare function Button(props: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
12
42
|
|
|
13
43
|
declare function Chip(props: ChipProps): react_jsx_runtime.JSX.Element;
|
|
@@ -19,6 +49,8 @@ declare function IconButton(props: IconButtonProps): react_jsx_runtime.JSX.Eleme
|
|
|
19
49
|
declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
|
|
20
50
|
|
|
21
51
|
type PaperDefaults = {
|
|
52
|
+
AppbarHeader?: Partial<AppbarHeaderProps>;
|
|
53
|
+
BottomNavigation?: Partial<BottomNavigationProps<BottomNavigationRoute>>;
|
|
22
54
|
Button?: Partial<ButtonProps>;
|
|
23
55
|
Chip?: Partial<ChipProps>;
|
|
24
56
|
FAB?: Partial<FABProps>;
|
|
@@ -88,4 +120,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
|
|
|
88
120
|
|
|
89
121
|
declare const isDarkColor: (value: string) => boolean;
|
|
90
122
|
|
|
91
|
-
export { Button, Chip, FAB, IconButton, type PaperDefaults, Provider, type ProviderProps, type RGB, TextInput, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme, usePaperDefaults };
|
|
123
|
+
export { Appbar, BottomNavigation, Button, Chip, FAB, IconButton, type PaperDefaults, Provider, type ProviderProps, type RGB, TextInput, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme, usePaperDefaults };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
export { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
|
|
4
|
-
import * as react from 'react';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import * as react_native_paper_lib_typescript_utils_forwardRef from 'react-native-paper/lib/typescript/utils/forwardRef';
|
|
2
|
+
import * as react_native from 'react-native';
|
|
6
3
|
import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import react__default, { ReactNode } from 'react';
|
|
6
|
+
import * as react_native_paper from 'react-native-paper';
|
|
7
|
+
import { AppbarHeaderProps, BottomNavigationRoute, BottomNavigationProps, BottomNavigation as BottomNavigation$1, ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps, MD3Theme } from 'react-native-paper';
|
|
8
|
+
export { AppbarHeaderProps, BottomNavigationProps, BottomNavigationRoute, ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
|
|
9
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
10
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
8
11
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
9
12
|
import * as redux from 'redux';
|
|
10
13
|
|
|
14
|
+
declare function Header({ style, ...props }: AppbarHeaderProps): react_jsx_runtime.JSX.Element;
|
|
15
|
+
declare const Appbar: {
|
|
16
|
+
Header: typeof Header;
|
|
17
|
+
Content: {
|
|
18
|
+
({ color: titleColor, subtitle, subtitleStyle, onPress, disabled, style, titleRef, titleStyle, title, titleMaxFontSizeMultiplier, mode, theme: themeOverrides, testID, ...rest }: react_native_paper.Props): react.JSX.Element;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Action: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarActionProps>;
|
|
22
|
+
BackAction: react_native_paper_lib_typescript_utils_forwardRef.ForwardRefComponent<react_native.View, react_native_paper.AppbarBackActionProps>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react_jsx_runtime.JSX.Element;
|
|
26
|
+
declare namespace BottomNavigationComponent {
|
|
27
|
+
var Bar: (props: BarProps) => react_jsx_runtime.JSX.Element;
|
|
28
|
+
var SceneMap: <Route extends BottomNavigationRoute>(scenes: {
|
|
29
|
+
[key: string]: react__default.ComponentType<{
|
|
30
|
+
route: Route;
|
|
31
|
+
jumpTo: (key: string) => void;
|
|
32
|
+
}>;
|
|
33
|
+
}) => ({ route, jumpTo, }: {
|
|
34
|
+
route: Route;
|
|
35
|
+
jumpTo: (key: string) => void;
|
|
36
|
+
}) => react__default.JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
type BarProps = react__default.ComponentProps<typeof BottomNavigation$1.Bar>;
|
|
39
|
+
declare const BottomNavigation: typeof BottomNavigationComponent;
|
|
40
|
+
|
|
11
41
|
declare function Button(props: ButtonProps): react_jsx_runtime.JSX.Element;
|
|
12
42
|
|
|
13
43
|
declare function Chip(props: ChipProps): react_jsx_runtime.JSX.Element;
|
|
@@ -19,6 +49,8 @@ declare function IconButton(props: IconButtonProps): react_jsx_runtime.JSX.Eleme
|
|
|
19
49
|
declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
|
|
20
50
|
|
|
21
51
|
type PaperDefaults = {
|
|
52
|
+
AppbarHeader?: Partial<AppbarHeaderProps>;
|
|
53
|
+
BottomNavigation?: Partial<BottomNavigationProps<BottomNavigationRoute>>;
|
|
22
54
|
Button?: Partial<ButtonProps>;
|
|
23
55
|
Chip?: Partial<ChipProps>;
|
|
24
56
|
FAB?: Partial<FABProps>;
|
|
@@ -88,4 +120,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
|
|
|
88
120
|
|
|
89
121
|
declare const isDarkColor: (value: string) => boolean;
|
|
90
122
|
|
|
91
|
-
export { Button, Chip, FAB, IconButton, type PaperDefaults, Provider, type ProviderProps, type RGB, TextInput, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme, usePaperDefaults };
|
|
123
|
+
export { Appbar, BottomNavigation, Button, Chip, FAB, IconButton, type PaperDefaults, Provider, type ProviderProps, type RGB, TextInput, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme, usePaperDefaults };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -16,12 +18,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
31
|
|
|
22
32
|
// src/index.ts
|
|
23
33
|
var index_exports = {};
|
|
24
34
|
__export(index_exports, {
|
|
35
|
+
Appbar: () => Appbar,
|
|
36
|
+
BottomNavigation: () => BottomNavigation,
|
|
25
37
|
Button: () => Button,
|
|
26
38
|
Chip: () => Chip,
|
|
27
39
|
FAB: () => FAB,
|
|
@@ -43,7 +55,8 @@ __export(index_exports, {
|
|
|
43
55
|
});
|
|
44
56
|
module.exports = __toCommonJS(index_exports);
|
|
45
57
|
|
|
46
|
-
// src/components/
|
|
58
|
+
// src/components/Appbar.tsx
|
|
59
|
+
var import_react_native = require("react-native");
|
|
47
60
|
var import_react_native_paper = require("react-native-paper");
|
|
48
61
|
|
|
49
62
|
// src/PaperDefaultsContext.tsx
|
|
@@ -53,44 +66,91 @@ function usePaperDefaults() {
|
|
|
53
66
|
return (0, import_react.useContext)(PaperDefaultsContext);
|
|
54
67
|
}
|
|
55
68
|
|
|
56
|
-
// src/components/
|
|
69
|
+
// src/components/Appbar.tsx
|
|
57
70
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
58
|
-
function
|
|
71
|
+
function Header({ style, ...props }) {
|
|
59
72
|
const defaults = usePaperDefaults();
|
|
60
|
-
|
|
73
|
+
const theme = (0, import_react_native_paper.useTheme)();
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.StatusBar, { backgroundColor: theme.colors.surface, barStyle: theme.dark ? "light-content" : "dark-content" }),
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_paper.Appbar.Header, { ...defaults.AppbarHeader, ...props, style })
|
|
77
|
+
] });
|
|
61
78
|
}
|
|
79
|
+
var Appbar = {
|
|
80
|
+
Header,
|
|
81
|
+
Content: import_react_native_paper.Appbar.Content,
|
|
82
|
+
Action: import_react_native_paper.Appbar.Action,
|
|
83
|
+
BackAction: import_react_native_paper.Appbar.BackAction
|
|
84
|
+
};
|
|
62
85
|
|
|
63
|
-
// src/components/
|
|
86
|
+
// src/components/BottomNavigation.tsx
|
|
87
|
+
var import_react2 = require("react");
|
|
88
|
+
var import_react_native2 = require("react-native");
|
|
64
89
|
var import_react_native_paper2 = require("react-native-paper");
|
|
65
90
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
66
|
-
function
|
|
91
|
+
function useNavigationBarSync() {
|
|
92
|
+
const theme = (0, import_react_native_paper2.useTheme)();
|
|
93
|
+
(0, import_react2.useEffect)(() => {
|
|
94
|
+
if (import_react_native2.Platform.OS !== "android") return;
|
|
95
|
+
import("expo-navigation-bar").then(({ setBackgroundColorAsync, setButtonStyleAsync }) => {
|
|
96
|
+
setBackgroundColorAsync(theme.colors.surface);
|
|
97
|
+
setButtonStyleAsync(theme.dark ? "light" : "dark");
|
|
98
|
+
}).catch(() => {
|
|
99
|
+
});
|
|
100
|
+
}, [theme]);
|
|
101
|
+
}
|
|
102
|
+
function BottomNavigationComponent(props) {
|
|
67
103
|
const defaults = usePaperDefaults();
|
|
68
|
-
|
|
104
|
+
useNavigationBarSync();
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.BottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
106
|
+
}
|
|
107
|
+
function Bar(props) {
|
|
108
|
+
useNavigationBarSync();
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.BottomNavigation.Bar, { ...props });
|
|
69
110
|
}
|
|
111
|
+
BottomNavigationComponent.Bar = Bar;
|
|
112
|
+
BottomNavigationComponent.SceneMap = import_react_native_paper2.BottomNavigation.SceneMap;
|
|
113
|
+
var BottomNavigation = BottomNavigationComponent;
|
|
70
114
|
|
|
71
|
-
// src/components/
|
|
115
|
+
// src/components/Button.tsx
|
|
72
116
|
var import_react_native_paper3 = require("react-native-paper");
|
|
73
117
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
74
|
-
function
|
|
118
|
+
function Button(props) {
|
|
75
119
|
const defaults = usePaperDefaults();
|
|
76
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper3.
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper3.Button, { ...defaults.Button, ...props });
|
|
77
121
|
}
|
|
78
122
|
|
|
79
|
-
// src/components/
|
|
123
|
+
// src/components/Chip.tsx
|
|
80
124
|
var import_react_native_paper4 = require("react-native-paper");
|
|
81
125
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
82
|
-
function
|
|
126
|
+
function Chip(props) {
|
|
83
127
|
const defaults = usePaperDefaults();
|
|
84
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper4.
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper4.Chip, { ...defaults.Chip, ...props });
|
|
85
129
|
}
|
|
86
130
|
|
|
87
|
-
// src/components/
|
|
88
|
-
var import_react2 = require("react");
|
|
131
|
+
// src/components/FAB.tsx
|
|
89
132
|
var import_react_native_paper5 = require("react-native-paper");
|
|
90
133
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
91
|
-
|
|
134
|
+
function FAB(props) {
|
|
92
135
|
const defaults = usePaperDefaults();
|
|
93
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper5.
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper5.FAB, { ...defaults.FAB, ...props });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/components/IconButton.tsx
|
|
140
|
+
var import_react_native_paper6 = require("react-native-paper");
|
|
141
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
142
|
+
function IconButton(props) {
|
|
143
|
+
const defaults = usePaperDefaults();
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native_paper6.IconButton, { ...defaults.IconButton, ...props });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/components/TextInput.tsx
|
|
148
|
+
var import_react3 = require("react");
|
|
149
|
+
var import_react_native_paper7 = require("react-native-paper");
|
|
150
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
151
|
+
var TextInput = (0, import_react3.forwardRef)(function TextInput2(props, ref) {
|
|
152
|
+
const defaults = usePaperDefaults();
|
|
153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native_paper7.TextInput, { ref, ...defaults.TextInput, ...props });
|
|
94
154
|
});
|
|
95
155
|
|
|
96
156
|
// node_modules/redux/dist/redux.mjs
|
|
@@ -1659,14 +1719,14 @@ var selectThemeAppearance = (state) => state.appearance;
|
|
|
1659
1719
|
var selectThemeColor = (state) => state.color;
|
|
1660
1720
|
|
|
1661
1721
|
// src/ThemeProvider.tsx
|
|
1662
|
-
var
|
|
1663
|
-
var
|
|
1664
|
-
var
|
|
1722
|
+
var import_react5 = require("react");
|
|
1723
|
+
var import_react_native4 = require("react-native");
|
|
1724
|
+
var import_react_native_paper9 = require("react-native-paper");
|
|
1665
1725
|
|
|
1666
1726
|
// src/useComputedTheme.ts
|
|
1667
|
-
var
|
|
1668
|
-
var
|
|
1669
|
-
var
|
|
1727
|
+
var import_react4 = require("react");
|
|
1728
|
+
var import_react_native3 = require("react-native");
|
|
1729
|
+
var import_react_native_paper8 = require("react-native-paper");
|
|
1670
1730
|
|
|
1671
1731
|
// src/utils/colorNames.ts
|
|
1672
1732
|
var colorNames = {
|
|
@@ -1977,12 +2037,12 @@ var isDarkColor = (value) => {
|
|
|
1977
2037
|
|
|
1978
2038
|
// src/useComputedTheme.ts
|
|
1979
2039
|
function useComputedTheme(appearance, color) {
|
|
1980
|
-
const [theme, setTheme] = (0,
|
|
1981
|
-
const computeTheme = (0,
|
|
2040
|
+
const [theme, setTheme] = (0, import_react4.useState)(null);
|
|
2041
|
+
const computeTheme = (0, import_react4.useCallback)(() => {
|
|
1982
2042
|
let resolved = appearance;
|
|
1983
|
-
if (resolved === "system") resolved =
|
|
2043
|
+
if (resolved === "system") resolved = import_react_native3.Appearance.getColorScheme();
|
|
1984
2044
|
if (resolved === "no-preference" || !resolved) resolved = "light";
|
|
1985
|
-
const base = resolved === "dark" ?
|
|
2045
|
+
const base = resolved === "dark" ? import_react_native_paper8.MD3DarkTheme : import_react_native_paper8.MD3LightTheme;
|
|
1986
2046
|
const _theme = {
|
|
1987
2047
|
...base,
|
|
1988
2048
|
colors: {
|
|
@@ -2021,38 +2081,40 @@ function useComputedTheme(appearance, color) {
|
|
|
2021
2081
|
};
|
|
2022
2082
|
setTheme(_theme);
|
|
2023
2083
|
}, [appearance, color]);
|
|
2024
|
-
(0,
|
|
2084
|
+
(0, import_react4.useEffect)(() => {
|
|
2025
2085
|
computeTheme();
|
|
2026
2086
|
}, [computeTheme]);
|
|
2027
|
-
(0,
|
|
2028
|
-
const subscription =
|
|
2087
|
+
(0, import_react4.useEffect)(() => {
|
|
2088
|
+
const subscription = import_react_native3.Appearance.addChangeListener(computeTheme);
|
|
2029
2089
|
return subscription.remove;
|
|
2030
2090
|
}, [computeTheme]);
|
|
2031
2091
|
return theme;
|
|
2032
2092
|
}
|
|
2033
2093
|
|
|
2034
2094
|
// src/ThemeProvider.tsx
|
|
2035
|
-
var
|
|
2095
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2036
2096
|
function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
|
|
2037
2097
|
const theme = useComputedTheme(appearance, color);
|
|
2038
|
-
const called = (0,
|
|
2039
|
-
(0,
|
|
2098
|
+
const called = (0, import_react5.useRef)(false);
|
|
2099
|
+
(0, import_react5.useEffect)(() => {
|
|
2040
2100
|
if (theme && !called.current) {
|
|
2041
2101
|
called.current = true;
|
|
2042
2102
|
onReady?.();
|
|
2043
2103
|
}
|
|
2044
2104
|
}, [theme, onReady]);
|
|
2045
2105
|
if (!theme) return null;
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2048
|
-
/* @__PURE__ */ (0,
|
|
2106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_native_paper9.Provider, { theme, children: [
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native4.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
|
|
2108
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native4.View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) })
|
|
2049
2109
|
] });
|
|
2050
2110
|
}
|
|
2051
|
-
var styles =
|
|
2111
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
2052
2112
|
flex: { flex: 1 }
|
|
2053
2113
|
});
|
|
2054
2114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2055
2115
|
0 && (module.exports = {
|
|
2116
|
+
Appbar,
|
|
2117
|
+
BottomNavigation,
|
|
2056
2118
|
Button,
|
|
2057
2119
|
Chip,
|
|
2058
2120
|
FAB,
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,9 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
|
-
// src/components/
|
|
6
|
-
import {
|
|
5
|
+
// src/components/Appbar.tsx
|
|
6
|
+
import { StatusBar } from "react-native";
|
|
7
|
+
import { Appbar as PaperAppbar, useTheme } from "react-native-paper";
|
|
7
8
|
|
|
8
9
|
// src/PaperDefaultsContext.tsx
|
|
9
10
|
import { createContext, useContext } from "react";
|
|
@@ -12,44 +13,91 @@ function usePaperDefaults() {
|
|
|
12
13
|
return useContext(PaperDefaultsContext);
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
// src/components/Appbar.tsx
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
function Header({ style, ...props }) {
|
|
19
|
+
const defaults = usePaperDefaults();
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ jsx(StatusBar, { backgroundColor: theme.colors.surface, barStyle: theme.dark ? "light-content" : "dark-content" }),
|
|
23
|
+
/* @__PURE__ */ jsx(PaperAppbar.Header, { ...defaults.AppbarHeader, ...props, style })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
var Appbar = {
|
|
27
|
+
Header,
|
|
28
|
+
Content: PaperAppbar.Content,
|
|
29
|
+
Action: PaperAppbar.Action,
|
|
30
|
+
BackAction: PaperAppbar.BackAction
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/components/BottomNavigation.tsx
|
|
34
|
+
import { useEffect } from "react";
|
|
35
|
+
import { Platform } from "react-native";
|
|
36
|
+
import { BottomNavigation as PaperBottomNavigation, useTheme as useTheme2 } from "react-native-paper";
|
|
37
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
38
|
+
function useNavigationBarSync() {
|
|
39
|
+
const theme = useTheme2();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (Platform.OS !== "android") return;
|
|
42
|
+
import("expo-navigation-bar").then(({ setBackgroundColorAsync, setButtonStyleAsync }) => {
|
|
43
|
+
setBackgroundColorAsync(theme.colors.surface);
|
|
44
|
+
setButtonStyleAsync(theme.dark ? "light" : "dark");
|
|
45
|
+
}).catch(() => {
|
|
46
|
+
});
|
|
47
|
+
}, [theme]);
|
|
48
|
+
}
|
|
49
|
+
function BottomNavigationComponent(props) {
|
|
50
|
+
const defaults = usePaperDefaults();
|
|
51
|
+
useNavigationBarSync();
|
|
52
|
+
return /* @__PURE__ */ jsx2(PaperBottomNavigation, { ...defaults.BottomNavigation, ...props });
|
|
53
|
+
}
|
|
54
|
+
function Bar(props) {
|
|
55
|
+
useNavigationBarSync();
|
|
56
|
+
return /* @__PURE__ */ jsx2(PaperBottomNavigation.Bar, { ...props });
|
|
57
|
+
}
|
|
58
|
+
BottomNavigationComponent.Bar = Bar;
|
|
59
|
+
BottomNavigationComponent.SceneMap = PaperBottomNavigation.SceneMap;
|
|
60
|
+
var BottomNavigation = BottomNavigationComponent;
|
|
61
|
+
|
|
15
62
|
// src/components/Button.tsx
|
|
16
|
-
import {
|
|
63
|
+
import { Button as PaperButton } from "react-native-paper";
|
|
64
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
17
65
|
function Button(props) {
|
|
18
66
|
const defaults = usePaperDefaults();
|
|
19
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ jsx3(PaperButton, { ...defaults.Button, ...props });
|
|
20
68
|
}
|
|
21
69
|
|
|
22
70
|
// src/components/Chip.tsx
|
|
23
71
|
import { Chip as PaperChip } from "react-native-paper";
|
|
24
|
-
import { jsx as
|
|
72
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
25
73
|
function Chip(props) {
|
|
26
74
|
const defaults = usePaperDefaults();
|
|
27
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ jsx4(PaperChip, { ...defaults.Chip, ...props });
|
|
28
76
|
}
|
|
29
77
|
|
|
30
78
|
// src/components/FAB.tsx
|
|
31
79
|
import { FAB as PaperFAB } from "react-native-paper";
|
|
32
|
-
import { jsx as
|
|
80
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
33
81
|
function FAB(props) {
|
|
34
82
|
const defaults = usePaperDefaults();
|
|
35
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsx5(PaperFAB, { ...defaults.FAB, ...props });
|
|
36
84
|
}
|
|
37
85
|
|
|
38
86
|
// src/components/IconButton.tsx
|
|
39
87
|
import { IconButton as PaperIconButton } from "react-native-paper";
|
|
40
|
-
import { jsx as
|
|
88
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
41
89
|
function IconButton(props) {
|
|
42
90
|
const defaults = usePaperDefaults();
|
|
43
|
-
return /* @__PURE__ */
|
|
91
|
+
return /* @__PURE__ */ jsx6(PaperIconButton, { ...defaults.IconButton, ...props });
|
|
44
92
|
}
|
|
45
93
|
|
|
46
94
|
// src/components/TextInput.tsx
|
|
47
95
|
import { forwardRef } from "react";
|
|
48
96
|
import { TextInput as PaperTextInput } from "react-native-paper";
|
|
49
|
-
import { jsx as
|
|
97
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
50
98
|
var TextInput = forwardRef(function TextInput2(props, ref) {
|
|
51
99
|
const defaults = usePaperDefaults();
|
|
52
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ jsx7(PaperTextInput, { ref, ...defaults.TextInput, ...props });
|
|
53
101
|
});
|
|
54
102
|
|
|
55
103
|
// node_modules/redux/dist/redux.mjs
|
|
@@ -1618,12 +1666,12 @@ var selectThemeAppearance = (state) => state.appearance;
|
|
|
1618
1666
|
var selectThemeColor = (state) => state.color;
|
|
1619
1667
|
|
|
1620
1668
|
// src/ThemeProvider.tsx
|
|
1621
|
-
import { useEffect as
|
|
1622
|
-
import { StatusBar, StyleSheet, View } from "react-native";
|
|
1669
|
+
import { useEffect as useEffect3, useRef } from "react";
|
|
1670
|
+
import { StatusBar as StatusBar2, StyleSheet, View } from "react-native";
|
|
1623
1671
|
import { Provider as PaperProvider } from "react-native-paper";
|
|
1624
1672
|
|
|
1625
1673
|
// src/useComputedTheme.ts
|
|
1626
|
-
import { useCallback, useEffect, useState } from "react";
|
|
1674
|
+
import { useCallback, useEffect as useEffect2, useState } from "react";
|
|
1627
1675
|
import { Appearance } from "react-native";
|
|
1628
1676
|
import { MD3DarkTheme, MD3LightTheme } from "react-native-paper";
|
|
1629
1677
|
|
|
@@ -1980,10 +2028,10 @@ function useComputedTheme(appearance, color) {
|
|
|
1980
2028
|
};
|
|
1981
2029
|
setTheme(_theme);
|
|
1982
2030
|
}, [appearance, color]);
|
|
1983
|
-
|
|
2031
|
+
useEffect2(() => {
|
|
1984
2032
|
computeTheme();
|
|
1985
2033
|
}, [computeTheme]);
|
|
1986
|
-
|
|
2034
|
+
useEffect2(() => {
|
|
1987
2035
|
const subscription = Appearance.addChangeListener(computeTheme);
|
|
1988
2036
|
return subscription.remove;
|
|
1989
2037
|
}, [computeTheme]);
|
|
@@ -1991,26 +2039,28 @@ function useComputedTheme(appearance, color) {
|
|
|
1991
2039
|
}
|
|
1992
2040
|
|
|
1993
2041
|
// src/ThemeProvider.tsx
|
|
1994
|
-
import { jsx as
|
|
2042
|
+
import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1995
2043
|
function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
|
|
1996
2044
|
const theme = useComputedTheme(appearance, color);
|
|
1997
2045
|
const called = useRef(false);
|
|
1998
|
-
|
|
2046
|
+
useEffect3(() => {
|
|
1999
2047
|
if (theme && !called.current) {
|
|
2000
2048
|
called.current = true;
|
|
2001
2049
|
onReady?.();
|
|
2002
2050
|
}
|
|
2003
2051
|
}, [theme, onReady]);
|
|
2004
2052
|
if (!theme) return null;
|
|
2005
|
-
return /* @__PURE__ */
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
/* @__PURE__ */
|
|
2053
|
+
return /* @__PURE__ */ jsxs2(PaperProvider, { theme, children: [
|
|
2054
|
+
/* @__PURE__ */ jsx8(StatusBar2, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
|
|
2055
|
+
/* @__PURE__ */ jsx8(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ jsx8(View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) })
|
|
2008
2056
|
] });
|
|
2009
2057
|
}
|
|
2010
2058
|
var styles = StyleSheet.create({
|
|
2011
2059
|
flex: { flex: 1 }
|
|
2012
2060
|
});
|
|
2013
2061
|
export {
|
|
2062
|
+
Appbar,
|
|
2063
|
+
BottomNavigation,
|
|
2014
2064
|
Button,
|
|
2015
2065
|
Chip,
|
|
2016
2066
|
FAB,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rific/auto-paper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test": "jest",
|
|
55
55
|
"test:watch": "jest --watchAll",
|
|
56
56
|
"typecheck": "tsc --noEmit",
|
|
57
|
-
"preversion": "npm run lint && npm test"
|
|
57
|
+
"preversion": "npm run lint && npm test && npm run build"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@reduxjs/toolkit": "^2.0.0",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"eslint-plugin-prettier": "^5.5.5",
|
|
71
71
|
"eslint-plugin-react-native": "^5.0.0",
|
|
72
72
|
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
73
|
+
"expo-navigation-bar": "^56.0.3",
|
|
73
74
|
"jest": "^30.0.0",
|
|
74
75
|
"jest-environment-jsdom": "^30.0.0",
|
|
75
76
|
"prettier": "^3.8.3",
|
|
@@ -84,10 +85,16 @@
|
|
|
84
85
|
"typescript-eslint": "^8.59.3"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
88
|
+
"expo-navigation-bar": ">=4.0.0",
|
|
87
89
|
"react": ">=18.0.0",
|
|
88
90
|
"react-native": ">=0.73.0",
|
|
89
91
|
"react-native-paper": ">=5.0.0"
|
|
90
92
|
},
|
|
93
|
+
"peerDependenciesMeta": {
|
|
94
|
+
"expo-navigation-bar": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
97
|
+
},
|
|
91
98
|
"optionalDependencies": {
|
|
92
99
|
"@reduxjs/toolkit": "^2.0.0"
|
|
93
100
|
},
|