@rific/auto-paper 0.1.1 → 0.1.3

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 CHANGED
@@ -7,7 +7,8 @@ Adaptive theming for [`react-native-paper`](https://callstack.github.io/react-na
7
7
  - Triadic color palette from a single seed color (primary → secondary → tertiary, 120° apart on the color wheel)
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
- - Optional Redux slice (`themeReducer`, `themeActions`, `selectThemeAppearance`, `selectThemeColor`) for wiring into your store
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
12
  - All color utilities exported for standalone use
12
13
 
13
14
  ## Installation
@@ -24,85 +25,83 @@ npm install react-native react-native-paper
24
25
 
25
26
  ## Usage
26
27
 
27
- ### ThemeProvider (simplest)
28
+ ### Provider (simplest)
28
29
 
29
30
  ```tsx
30
- import { ThemeProvider } from '@rific/auto-paper'
31
+ import { Provider as AutoPaperProvider } from '@rific/auto-paper'
31
32
 
32
33
  export default function App() {
33
34
  const [appearance, setAppearance] = useState<'system' | 'light' | 'dark'>('system')
34
35
  const [color, setColor] = useState('#6750a4')
35
36
 
36
37
  return (
37
- <ThemeProvider appearance={appearance} color={color}>
38
+ <AutoPaperProvider appearance={appearance} color={color}>
38
39
  {/* your app */}
39
- </ThemeProvider>
40
+ </AutoPaperProvider>
40
41
  )
41
42
  }
42
43
  ```
43
44
 
44
- `ThemeProvider` renders `null` on the first render while the theme computes. If you use `expo-splash-screen`, gate `SplashScreen.hideAsync()` on the theme being ready in your own component.
45
-
46
- ### With React Navigation
47
-
48
- Use the `useComputedTheme` hook directly to integrate with Navigation's `ThemeProvider`:
45
+ `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:
49
46
 
50
47
  ```tsx
51
- import { useComputedTheme } from '@rific/auto-paper'
52
- import { DarkTheme, DefaultTheme, ThemeProvider as NavThemeProvider } from '@react-navigation/native'
53
- import { Provider as PaperProvider } from 'react-native-paper'
48
+ <AutoPaperProvider appearance={appearance} color={color} onReady={SplashScreen.hideAsync}>
49
+ {/* your app */}
50
+ </AutoPaperProvider>
51
+ ```
54
52
 
55
- export default function App() {
56
- const theme = useComputedTheme('system', '#6750a4')
57
- if (!theme) return null
53
+ ### With component defaults
58
54
 
59
- const navTheme = {
60
- ...(theme.dark ? DarkTheme : DefaultTheme),
61
- colors: {
62
- ...(theme.dark ? DarkTheme : DefaultTheme).colors,
63
- background: theme.colors.background,
64
- card: theme.colors.background
65
- }
66
- }
55
+ Pass a `defaults` object to `Provider` to set prop defaults for any of the included wrapper components. Each component merges defaults under its own props, so per-instance props always win:
67
56
 
68
- return (
69
- <NavThemeProvider value={navTheme}>
70
- <PaperProvider theme={theme}>
71
- {/* your app */}
72
- </PaperProvider>
73
- </NavThemeProvider>
74
- )
75
- }
57
+ ```tsx
58
+ import { Button, Chip, Provider as AutoPaperProvider } from '@rific/auto-paper'
59
+
60
+ <AutoPaperProvider
61
+ appearance={appearance}
62
+ color={color}
63
+ defaults={{
64
+ Button: { mode: 'contained' },
65
+ Chip: { compact: true },
66
+ }}
67
+ >
68
+ <Button>Save</Button> {/* mode="contained" from defaults */}
69
+ <Button mode="text">Cancel</Button> {/* overrides default */}
70
+ <Chip>Tag</Chip> {/* compact=true from defaults */}
71
+ </AutoPaperProvider>
76
72
  ```
77
73
 
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.
75
+
78
76
  ### With Redux
79
77
 
80
- The package exports an optional Redux slice. Add it to your store and dispatch actions to update appearance or color from settings screens:
78
+ The package exports an optional Redux slice. Use `createThemeReducer` to register it in your store with a custom initial color:
81
79
 
82
80
  ```ts
83
81
  // store.ts
84
- import { themeReducer } from '@rific/auto-paper'
82
+ import { createThemeReducer, themeActions } from '@rific/auto-paper'
85
83
 
86
84
  export const store = configureStore({
87
85
  reducer: {
88
- theme: themeReducer,
86
+ theme: createThemeReducer({ color: '#4caf50' }),
89
87
  // ...
90
88
  }
91
89
  })
92
90
  ```
93
91
 
92
+ Then read from the store and pass into `Provider`:
93
+
94
94
  ```tsx
95
95
  // App.tsx
96
96
  import { useSelector } from 'react-redux'
97
- import { ThemeProvider, selectThemeAppearance, selectThemeColor } from '@rific/auto-paper'
97
+ import { Provider as AutoPaperProvider } from '@rific/auto-paper'
98
98
 
99
99
  export default function App() {
100
- const appearance = useSelector((state: RootState) => selectThemeAppearance(state.theme))
101
- const color = useSelector((state: RootState) => selectThemeColor(state.theme))
100
+ const { appearance, color } = useSelector((state: RootState) => state.theme)
102
101
  return (
103
- <ThemeProvider appearance={appearance} color={color}>
102
+ <AutoPaperProvider appearance={appearance} color={color} onReady={SplashScreen.hideAsync}>
104
103
  {/* your app */}
105
- </ThemeProvider>
104
+ </AutoPaperProvider>
106
105
  )
107
106
  }
108
107
  ```
@@ -116,21 +115,51 @@ dispatch(themeActions.setColor('#e91e63'))
116
115
  dispatch(themeActions.setAppearance('dark'))
117
116
  ```
118
117
 
119
- The slice's initial color is `#6750a4` (MD3 default purple). Override it at startup:
118
+ ### With `useComputedTheme`
120
119
 
121
- ```ts
122
- store.dispatch(themeActions.initialize({ color: myStoredColor }))
120
+ Use the hook directly when you need to extend the theme before passing it to `PaperProvider` — for example, to merge in a navigation theme or add custom color keys:
121
+
122
+ ```tsx
123
+ import { useComputedTheme } from '@rific/auto-paper'
124
+ import { DarkTheme, DefaultTheme, ThemeProvider as NavThemeProvider } from '@react-navigation/native'
125
+ import { Provider as PaperProvider } from 'react-native-paper'
126
+
127
+ export default function App() {
128
+ const theme = useComputedTheme('system', '#6750a4')
129
+ if (!theme) return null
130
+
131
+ const navTheme = {
132
+ ...(theme.dark ? DarkTheme : DefaultTheme),
133
+ colors: {
134
+ ...(theme.dark ? DarkTheme : DefaultTheme).colors,
135
+ background: theme.colors.background,
136
+ card: theme.colors.background
137
+ }
138
+ }
139
+
140
+ return (
141
+ <NavThemeProvider value={navTheme}>
142
+ <PaperProvider theme={theme}>
143
+ {/* your app */}
144
+ </PaperProvider>
145
+ </NavThemeProvider>
146
+ )
147
+ }
123
148
  ```
124
149
 
125
150
  ## API
126
151
 
127
- ### `ThemeProvider`
152
+ ### `Provider`
128
153
 
129
- | Prop | Type | Default | Description |
130
- |---|---|---|---|
131
- | `appearance` | `'system' \| 'light' \| 'dark'` | — | Appearance mode |
132
- | `color` | `string` | — | Seed color (hex, rgb, or CSS name) |
133
- | `children` | `ReactNode` | — | |
154
+ | Prop | Type | Description |
155
+ |---|---|---|
156
+ | `appearance` | `'system' \| 'light' \| 'dark'` | Appearance mode |
157
+ | `color` | `string` | Seed color (hex, rgb, or CSS name) |
158
+ | `children` | `ReactNode` | |
159
+ | `defaults` | `PaperDefaults` | Prop defaults for wrapper components (see below) |
160
+ | `onReady` | `() => void` | Called once when the theme first resolves |
161
+ | `statusBarProps` | `StatusBarProps` | Spread over the auto-derived `StatusBar` defaults |
162
+ | `style` | `StyleProp<ViewStyle>` | Applied to the wrapper `View` |
134
163
 
135
164
  ### `useComputedTheme(appearance, color)`
136
165
 
@@ -140,24 +169,41 @@ Returns `MD3Theme | null`. `null` on the first render while the theme computes.
140
169
  const theme = useComputedTheme('system', '#6750a4')
141
170
  ```
142
171
 
143
- ### Color utilities
172
+ ### `PaperDefaults` / `usePaperDefaults`
173
+
174
+ `PaperDefaults` is the type for the `defaults` prop on `Provider`:
144
175
 
145
176
  ```ts
146
- import { getTriadicPalette, getBlendedColor, isDarkColor, getRgb, getHex } from '@rific/auto-paper'
177
+ type PaperDefaults = {
178
+ Button?: Partial<ButtonProps>
179
+ Chip?: Partial<ChipProps>
180
+ FAB?: Partial<FABProps>
181
+ IconButton?: Partial<IconButtonProps>
182
+ TextInput?: Partial<TextInputProps>
183
+ }
184
+ ```
147
185
 
148
- getTriadicPalette('#ff0000')
149
- // → { primary: '#ff0000', secondary: '#00ff00', tertiary: '#0000ff' }
186
+ Use `usePaperDefaults` if you need to read the defaults in a custom component:
150
187
 
151
- getBlendedColor('#ff0000', '#0000ff', 0.5) // → '#800080'
152
- isDarkColor('#6750a4') // → true
153
- getRgb('coral') // → { r: 255, g: 127, b: 80 }
154
- getHex('rgb(255, 0, 0)') // → '#ff0000'
188
+ ```ts
189
+ import { usePaperDefaults } from '@rific/auto-paper'
190
+
191
+ const defaults = usePaperDefaults()
192
+ ```
193
+
194
+ ### `createThemeReducer(initialState?)`
195
+
196
+ Returns a Redux reducer with an optional initial state override. Useful for setting a custom default color without dispatching an action at startup.
197
+
198
+ ```ts
199
+ createThemeReducer({ color: '#4caf50' })
155
200
  ```
156
201
 
157
- ### Redux slice
202
+ ### Redux exports
158
203
 
159
204
  ```ts
160
- import { themeReducer, themeActions, selectThemeAppearance, selectThemeColor, ThemeState, ThemeAppearance } from '@rific/auto-paper'
205
+ import { themeReducer, themeActions, selectThemeAppearance, selectThemeColor } from '@rific/auto-paper'
206
+ import type { ThemeState, ThemeAppearance } from '@rific/auto-paper'
161
207
  ```
162
208
 
163
209
  | Action | Payload |
@@ -166,17 +212,26 @@ import { themeReducer, themeActions, selectThemeAppearance, selectThemeColor, Th
166
212
  | `setAppearance` | `ThemeAppearance` |
167
213
  | `setColor` | `string` |
168
214
 
169
- | Selector | Returns |
170
- |---|---|
171
- | `selectThemeAppearance` | `ThemeAppearance` |
172
- | `selectThemeColor` | `string` |
173
-
174
215
  Selectors accept `ThemeState` directly — compose them with your root state selector:
175
216
 
176
217
  ```ts
177
218
  const appearance = useSelector((state: RootState) => selectThemeAppearance(state.theme))
178
219
  ```
179
220
 
221
+ ### Color utilities
222
+
223
+ ```ts
224
+ import { getTriadicPalette, getBlendedColor, isDarkColor, getRgb, getHex } from '@rific/auto-paper'
225
+
226
+ getTriadicPalette('#ff0000')
227
+ // → { primary: '#ff0000', secondary: '#00ff00', tertiary: '#0000ff' }
228
+
229
+ getBlendedColor('#ff0000', '#0000ff', 0.5) // → '#800080'
230
+ isDarkColor('#6750a4') // → true
231
+ getRgb('coral') // → { r: 255, g: 127, b: 80 }
232
+ getHex('rgb(255, 0, 0)') // → '#ff0000'
233
+ ```
234
+
180
235
  ## License
181
236
 
182
237
  MIT
package/dist/index.d.mts CHANGED
@@ -1,9 +1,31 @@
1
- import * as redux from 'redux';
2
- import * as _reduxjs_toolkit from '@reduxjs/toolkit';
3
- import { PayloadAction } from '@reduxjs/toolkit';
4
- import { MD3Theme } from 'react-native-paper';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps, MD3Theme } from 'react-native-paper';
3
+ export { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
5
4
  import * as react from 'react';
6
5
  import { ReactNode } from 'react';
6
+ import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
7
+ import * as _reduxjs_toolkit from '@reduxjs/toolkit';
8
+ import { PayloadAction } from '@reduxjs/toolkit';
9
+ import * as redux from 'redux';
10
+
11
+ declare function Button(props: ButtonProps): react_jsx_runtime.JSX.Element;
12
+
13
+ declare function Chip(props: ChipProps): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function FAB(props: FABProps): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function IconButton(props: IconButtonProps): react_jsx_runtime.JSX.Element;
18
+
19
+ declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
20
+
21
+ type PaperDefaults = {
22
+ Button?: Partial<ButtonProps>;
23
+ Chip?: Partial<ChipProps>;
24
+ FAB?: Partial<FABProps>;
25
+ IconButton?: Partial<IconButtonProps>;
26
+ TextInput?: Partial<TextInputProps>;
27
+ };
28
+ declare function usePaperDefaults(): PaperDefaults;
7
29
 
8
30
  type ThemeAppearance = 'system' | 'light' | 'dark';
9
31
  declare function useComputedTheme(appearance: ThemeAppearance, color: string): MD3Theme | null;
@@ -12,25 +34,20 @@ type ThemeState = {
12
34
  appearance: ThemeAppearance;
13
35
  color: string;
14
36
  };
37
+ declare function createThemeReducer(initialState?: Partial<ThemeState>): redux.Reducer<{
38
+ appearance: ThemeAppearance;
39
+ color: string;
40
+ }>;
15
41
  declare const themeActions: _reduxjs_toolkit.CaseReducerActions<{
16
- initialize: (state: {
17
- appearance: ThemeAppearance;
18
- color: string;
19
- }, action: PayloadAction<Partial<ThemeState>>) => {
42
+ initialize: (state: ThemeState, action: PayloadAction<Partial<ThemeState>>) => {
20
43
  appearance: ThemeAppearance;
21
44
  color: string;
22
45
  };
23
- setAppearance: (state: {
24
- appearance: ThemeAppearance;
25
- color: string;
26
- }, action: PayloadAction<ThemeAppearance>) => {
46
+ setAppearance: (state: ThemeState, action: PayloadAction<ThemeAppearance>) => {
27
47
  appearance: ThemeAppearance;
28
48
  color: string;
29
49
  };
30
- setColor: (state: {
31
- appearance: ThemeAppearance;
32
- color: string;
33
- }, action: PayloadAction<string>) => {
50
+ setColor: (state: ThemeState, action: PayloadAction<string>) => {
34
51
  color: string;
35
52
  appearance: ThemeAppearance;
36
53
  };
@@ -39,12 +56,16 @@ declare const themeReducer: redux.Reducer<ThemeState>;
39
56
  declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
40
57
  declare const selectThemeColor: (state: ThemeState) => string;
41
58
 
42
- type ThemeProviderProps = {
59
+ type ProviderProps = {
43
60
  appearance: ThemeAppearance;
44
61
  color: string;
45
62
  children: ReactNode;
63
+ defaults?: PaperDefaults;
64
+ onReady?: () => void;
65
+ statusBarProps?: StatusBarProps;
66
+ style?: StyleProp<ViewStyle>;
46
67
  };
47
- declare function ThemeProvider({ appearance, color, children }: ThemeProviderProps): react.JSX.Element | null;
68
+ declare function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }: ProviderProps): react_jsx_runtime.JSX.Element | null;
48
69
 
49
70
  declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
50
71
 
@@ -67,4 +88,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
67
88
 
68
89
  declare const isDarkColor: (value: string) => boolean;
69
90
 
70
- export { type RGB, type ThemeAppearance, ThemeProvider, type ThemeProviderProps, type ThemeState, type TriadicPalette, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme };
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 };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,31 @@
1
- import * as redux from 'redux';
2
- import * as _reduxjs_toolkit from '@reduxjs/toolkit';
3
- import { PayloadAction } from '@reduxjs/toolkit';
4
- import { MD3Theme } from 'react-native-paper';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps, MD3Theme } from 'react-native-paper';
3
+ export { ButtonProps, ChipProps, FABProps, IconButtonProps, TextInputProps } from 'react-native-paper';
5
4
  import * as react from 'react';
6
5
  import { ReactNode } from 'react';
6
+ import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
7
+ import * as _reduxjs_toolkit from '@reduxjs/toolkit';
8
+ import { PayloadAction } from '@reduxjs/toolkit';
9
+ import * as redux from 'redux';
10
+
11
+ declare function Button(props: ButtonProps): react_jsx_runtime.JSX.Element;
12
+
13
+ declare function Chip(props: ChipProps): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function FAB(props: FABProps): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function IconButton(props: IconButtonProps): react_jsx_runtime.JSX.Element;
18
+
19
+ declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
20
+
21
+ type PaperDefaults = {
22
+ Button?: Partial<ButtonProps>;
23
+ Chip?: Partial<ChipProps>;
24
+ FAB?: Partial<FABProps>;
25
+ IconButton?: Partial<IconButtonProps>;
26
+ TextInput?: Partial<TextInputProps>;
27
+ };
28
+ declare function usePaperDefaults(): PaperDefaults;
7
29
 
8
30
  type ThemeAppearance = 'system' | 'light' | 'dark';
9
31
  declare function useComputedTheme(appearance: ThemeAppearance, color: string): MD3Theme | null;
@@ -12,25 +34,20 @@ type ThemeState = {
12
34
  appearance: ThemeAppearance;
13
35
  color: string;
14
36
  };
37
+ declare function createThemeReducer(initialState?: Partial<ThemeState>): redux.Reducer<{
38
+ appearance: ThemeAppearance;
39
+ color: string;
40
+ }>;
15
41
  declare const themeActions: _reduxjs_toolkit.CaseReducerActions<{
16
- initialize: (state: {
17
- appearance: ThemeAppearance;
18
- color: string;
19
- }, action: PayloadAction<Partial<ThemeState>>) => {
42
+ initialize: (state: ThemeState, action: PayloadAction<Partial<ThemeState>>) => {
20
43
  appearance: ThemeAppearance;
21
44
  color: string;
22
45
  };
23
- setAppearance: (state: {
24
- appearance: ThemeAppearance;
25
- color: string;
26
- }, action: PayloadAction<ThemeAppearance>) => {
46
+ setAppearance: (state: ThemeState, action: PayloadAction<ThemeAppearance>) => {
27
47
  appearance: ThemeAppearance;
28
48
  color: string;
29
49
  };
30
- setColor: (state: {
31
- appearance: ThemeAppearance;
32
- color: string;
33
- }, action: PayloadAction<string>) => {
50
+ setColor: (state: ThemeState, action: PayloadAction<string>) => {
34
51
  color: string;
35
52
  appearance: ThemeAppearance;
36
53
  };
@@ -39,12 +56,16 @@ declare const themeReducer: redux.Reducer<ThemeState>;
39
56
  declare const selectThemeAppearance: (state: ThemeState) => ThemeAppearance;
40
57
  declare const selectThemeColor: (state: ThemeState) => string;
41
58
 
42
- type ThemeProviderProps = {
59
+ type ProviderProps = {
43
60
  appearance: ThemeAppearance;
44
61
  color: string;
45
62
  children: ReactNode;
63
+ defaults?: PaperDefaults;
64
+ onReady?: () => void;
65
+ statusBarProps?: StatusBarProps;
66
+ style?: StyleProp<ViewStyle>;
46
67
  };
47
- declare function ThemeProvider({ appearance, color, children }: ThemeProviderProps): react.JSX.Element | null;
68
+ declare function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }: ProviderProps): react_jsx_runtime.JSX.Element | null;
48
69
 
49
70
  declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
50
71
 
@@ -67,4 +88,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
67
88
 
68
89
  declare const isDarkColor: (value: string) => boolean;
69
90
 
70
- export { type RGB, type ThemeAppearance, ThemeProvider, type ThemeProviderProps, type ThemeState, type TriadicPalette, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeColor, themeActions, themeReducer, useComputedTheme };
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 };
package/dist/index.js CHANGED
@@ -22,7 +22,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
22
22
  // src/index.ts
23
23
  var index_exports = {};
24
24
  __export(index_exports, {
25
- ThemeProvider: () => ThemeProvider,
25
+ Button: () => Button,
26
+ Chip: () => Chip,
27
+ FAB: () => FAB,
28
+ IconButton: () => IconButton,
29
+ Provider: () => Provider,
30
+ TextInput: () => TextInput,
31
+ createThemeReducer: () => createThemeReducer,
26
32
  getBlendedColor: () => getBlendedColor,
27
33
  getHex: () => getHex,
28
34
  getRgb: () => getRgb,
@@ -32,10 +38,61 @@ __export(index_exports, {
32
38
  selectThemeColor: () => selectThemeColor,
33
39
  themeActions: () => themeActions,
34
40
  themeReducer: () => themeReducer,
35
- useComputedTheme: () => useComputedTheme
41
+ useComputedTheme: () => useComputedTheme,
42
+ usePaperDefaults: () => usePaperDefaults
36
43
  });
37
44
  module.exports = __toCommonJS(index_exports);
38
45
 
46
+ // src/components/Button.tsx
47
+ var import_react_native_paper = require("react-native-paper");
48
+
49
+ // src/PaperDefaultsContext.tsx
50
+ var import_react = require("react");
51
+ var PaperDefaultsContext = (0, import_react.createContext)({});
52
+ function usePaperDefaults() {
53
+ return (0, import_react.useContext)(PaperDefaultsContext);
54
+ }
55
+
56
+ // src/components/Button.tsx
57
+ var import_jsx_runtime = require("react/jsx-runtime");
58
+ function Button(props) {
59
+ const defaults = usePaperDefaults();
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_paper.Button, { ...defaults.Button, ...props });
61
+ }
62
+
63
+ // src/components/Chip.tsx
64
+ var import_react_native_paper2 = require("react-native-paper");
65
+ var import_jsx_runtime2 = require("react/jsx-runtime");
66
+ function Chip(props) {
67
+ const defaults = usePaperDefaults();
68
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_paper2.Chip, { ...defaults.Chip, ...props });
69
+ }
70
+
71
+ // src/components/FAB.tsx
72
+ var import_react_native_paper3 = require("react-native-paper");
73
+ var import_jsx_runtime3 = require("react/jsx-runtime");
74
+ function FAB(props) {
75
+ const defaults = usePaperDefaults();
76
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_paper3.FAB, { ...defaults.FAB, ...props });
77
+ }
78
+
79
+ // src/components/IconButton.tsx
80
+ var import_react_native_paper4 = require("react-native-paper");
81
+ var import_jsx_runtime4 = require("react/jsx-runtime");
82
+ function IconButton(props) {
83
+ const defaults = usePaperDefaults();
84
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_paper4.IconButton, { ...defaults.IconButton, ...props });
85
+ }
86
+
87
+ // src/components/TextInput.tsx
88
+ var import_react2 = require("react");
89
+ var import_react_native_paper5 = require("react-native-paper");
90
+ var import_jsx_runtime5 = require("react/jsx-runtime");
91
+ var TextInput = (0, import_react2.forwardRef)(function TextInput2(props, ref) {
92
+ const defaults = usePaperDefaults();
93
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper5.TextInput, { ref, ...defaults.TextInput, ...props });
94
+ });
95
+
39
96
  // node_modules/redux/dist/redux.mjs
40
97
  var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
41
98
  var ActionTypes = {
@@ -960,18 +1017,18 @@ function executeReducerBuilderCallback(builderCallback) {
960
1017
  actionsMap[type] = reducer;
961
1018
  return builder;
962
1019
  },
963
- addAsyncThunk(asyncThunk, reducers) {
1020
+ addAsyncThunk(asyncThunk, reducers2) {
964
1021
  if (process.env.NODE_ENV !== "production") {
965
1022
  if (defaultCaseReducer) {
966
1023
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
967
1024
  }
968
1025
  }
969
- if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
970
- if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
971
- if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
972
- if (reducers.settled) actionMatchers.push({
1026
+ if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
1027
+ if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
1028
+ if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
1029
+ if (reducers2.settled) actionMatchers.push({
973
1030
  matcher: asyncThunk.settled,
974
- reducer: reducers.settled
1031
+ reducer: reducers2.settled
975
1032
  });
976
1033
  return builder;
977
1034
  },
@@ -1003,7 +1060,7 @@ function executeReducerBuilderCallback(builderCallback) {
1003
1060
  function isStateFunction(x) {
1004
1061
  return typeof x === "function";
1005
1062
  }
1006
- function createReducer(initialState2, mapOrBuilderCallback) {
1063
+ function createReducer(initialState, mapOrBuilderCallback) {
1007
1064
  if (process.env.NODE_ENV !== "production") {
1008
1065
  if (typeof mapOrBuilderCallback === "object") {
1009
1066
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
@@ -1011,10 +1068,10 @@ function createReducer(initialState2, mapOrBuilderCallback) {
1011
1068
  }
1012
1069
  let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
1013
1070
  let getInitialState;
1014
- if (isStateFunction(initialState2)) {
1015
- getInitialState = () => freezeDraftable(initialState2());
1071
+ if (isStateFunction(initialState)) {
1072
+ getInitialState = () => freezeDraftable(initialState());
1016
1073
  } else {
1017
- const frozenInitialState = freezeDraftable(initialState2);
1074
+ const frozenInitialState = freezeDraftable(initialState);
1018
1075
  getInitialState = () => frozenInitialState;
1019
1076
  }
1020
1077
  function reducer(state = getInitialState(), action) {
@@ -1279,8 +1336,8 @@ var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
1279
1336
  var asyncThunkCreator = {
1280
1337
  [asyncThunkSymbol]: createAsyncThunk
1281
1338
  };
1282
- function getType(slice2, actionKey) {
1283
- return `${slice2}/${actionKey}`;
1339
+ function getType(slice, actionKey) {
1340
+ return `${slice}/${actionKey}`;
1284
1341
  }
1285
1342
  function buildCreateSlice({
1286
1343
  creators
@@ -1299,8 +1356,8 @@ function buildCreateSlice({
1299
1356
  console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
1300
1357
  }
1301
1358
  }
1302
- const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1303
- const reducerNames = Object.keys(reducers);
1359
+ const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1360
+ const reducerNames = Object.keys(reducers2);
1304
1361
  const context = {
1305
1362
  sliceCaseReducersByName: {},
1306
1363
  sliceCaseReducersByType: {},
@@ -1336,7 +1393,7 @@ function buildCreateSlice({
1336
1393
  }
1337
1394
  };
1338
1395
  reducerNames.forEach((reducerName) => {
1339
- const reducerDefinition = reducers[reducerName];
1396
+ const reducerDefinition = reducers2[reducerName];
1340
1397
  const reducerDetails = {
1341
1398
  reducerName,
1342
1399
  type: getType(name, reducerName),
@@ -1417,7 +1474,7 @@ function buildCreateSlice({
1417
1474
  selectSlice
1418
1475
  };
1419
1476
  }
1420
- const slice2 = {
1477
+ const slice = {
1421
1478
  name,
1422
1479
  reducer,
1423
1480
  actions: context.actionCreators,
@@ -1434,12 +1491,12 @@ function buildCreateSlice({
1434
1491
  reducer
1435
1492
  }, config);
1436
1493
  return {
1437
- ...slice2,
1494
+ ...slice,
1438
1495
  ...makeSelectorProps(newReducerPath, true)
1439
1496
  };
1440
1497
  }
1441
1498
  };
1442
- return slice2;
1499
+ return slice;
1443
1500
  };
1444
1501
  }
1445
1502
  function wrapSelector(selector, selectState, getInitialState, injected) {
@@ -1575,32 +1632,41 @@ function formatProdErrorMessage(code) {
1575
1632
  }
1576
1633
 
1577
1634
  // src/redux/themeSlice.ts
1578
- var initialState = {
1635
+ var defaultInitialState = {
1579
1636
  appearance: "system",
1580
1637
  color: "#6750a4"
1581
1638
  };
1582
- var slice = createSlice({
1639
+ var reducers = {
1640
+ initialize: (state, action) => ({ ...state, ...action.payload }),
1641
+ setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
1642
+ setColor: (state, action) => ({ ...state, color: action.payload })
1643
+ };
1644
+ function createThemeReducer(initialState) {
1645
+ return createSlice({
1646
+ name: "theme",
1647
+ initialState: { ...defaultInitialState, ...initialState },
1648
+ reducers
1649
+ }).reducer;
1650
+ }
1651
+ var defaultSlice = createSlice({
1583
1652
  name: "theme",
1584
- initialState,
1585
- reducers: {
1586
- initialize: (state, action) => ({ ...state, ...action.payload }),
1587
- setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
1588
- setColor: (state, action) => ({ ...state, color: action.payload })
1589
- }
1653
+ initialState: defaultInitialState,
1654
+ reducers
1590
1655
  });
1591
- var themeActions = slice.actions;
1592
- var themeReducer = slice.reducer;
1656
+ var themeActions = defaultSlice.actions;
1657
+ var themeReducer = defaultSlice.reducer;
1593
1658
  var selectThemeAppearance = (state) => state.appearance;
1594
1659
  var selectThemeColor = (state) => state.color;
1595
1660
 
1596
1661
  // src/ThemeProvider.tsx
1662
+ var import_react4 = require("react");
1597
1663
  var import_react_native2 = require("react-native");
1598
- var import_react_native_paper2 = require("react-native-paper");
1664
+ var import_react_native_paper7 = require("react-native-paper");
1599
1665
 
1600
1666
  // src/useComputedTheme.ts
1601
- var import_react = require("react");
1667
+ var import_react3 = require("react");
1602
1668
  var import_react_native = require("react-native");
1603
- var import_react_native_paper = require("react-native-paper");
1669
+ var import_react_native_paper6 = require("react-native-paper");
1604
1670
 
1605
1671
  // src/utils/colorNames.ts
1606
1672
  var colorNames = {
@@ -1911,12 +1977,12 @@ var isDarkColor = (value) => {
1911
1977
 
1912
1978
  // src/useComputedTheme.ts
1913
1979
  function useComputedTheme(appearance, color) {
1914
- const [theme, setTheme] = (0, import_react.useState)(null);
1915
- const computeTheme = (0, import_react.useCallback)(() => {
1980
+ const [theme, setTheme] = (0, import_react3.useState)(null);
1981
+ const computeTheme = (0, import_react3.useCallback)(() => {
1916
1982
  let resolved = appearance;
1917
1983
  if (resolved === "system") resolved = import_react_native.Appearance.getColorScheme();
1918
1984
  if (resolved === "no-preference" || !resolved) resolved = "light";
1919
- const base = resolved === "dark" ? import_react_native_paper.MD3DarkTheme : import_react_native_paper.MD3LightTheme;
1985
+ const base = resolved === "dark" ? import_react_native_paper6.MD3DarkTheme : import_react_native_paper6.MD3LightTheme;
1920
1986
  const _theme = {
1921
1987
  ...base,
1922
1988
  colors: {
@@ -1955,10 +2021,10 @@ function useComputedTheme(appearance, color) {
1955
2021
  };
1956
2022
  setTheme(_theme);
1957
2023
  }, [appearance, color]);
1958
- (0, import_react.useEffect)(() => {
2024
+ (0, import_react3.useEffect)(() => {
1959
2025
  computeTheme();
1960
2026
  }, [computeTheme]);
1961
- (0, import_react.useEffect)(() => {
2027
+ (0, import_react3.useEffect)(() => {
1962
2028
  const subscription = import_react_native.Appearance.addChangeListener(computeTheme);
1963
2029
  return subscription.remove;
1964
2030
  }, [computeTheme]);
@@ -1966,17 +2032,34 @@ function useComputedTheme(appearance, color) {
1966
2032
  }
1967
2033
 
1968
2034
  // src/ThemeProvider.tsx
1969
- function ThemeProvider({ appearance, color, children }) {
2035
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2036
+ function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
1970
2037
  const theme = useComputedTheme(appearance, color);
2038
+ const called = (0, import_react4.useRef)(false);
2039
+ (0, import_react4.useEffect)(() => {
2040
+ if (theme && !called.current) {
2041
+ called.current = true;
2042
+ onReady?.();
2043
+ }
2044
+ }, [theme, onReady]);
1971
2045
  if (!theme) return null;
1972
- return /* @__PURE__ */ React.createElement(import_react_native_paper2.Provider, { theme }, /* @__PURE__ */ React.createElement(import_react_native2.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content" }), /* @__PURE__ */ React.createElement(import_react_native2.View, { style: styles.flex }, children));
2046
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native_paper7.Provider, { theme, children: [
2047
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native2.StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
2048
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native2.View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) })
2049
+ ] });
1973
2050
  }
1974
2051
  var styles = import_react_native2.StyleSheet.create({
1975
2052
  flex: { flex: 1 }
1976
2053
  });
1977
2054
  // Annotate the CommonJS export names for ESM import in node:
1978
2055
  0 && (module.exports = {
1979
- ThemeProvider,
2056
+ Button,
2057
+ Chip,
2058
+ FAB,
2059
+ IconButton,
2060
+ Provider,
2061
+ TextInput,
2062
+ createThemeReducer,
1980
2063
  getBlendedColor,
1981
2064
  getHex,
1982
2065
  getRgb,
@@ -1986,5 +2069,6 @@ var styles = import_react_native2.StyleSheet.create({
1986
2069
  selectThemeColor,
1987
2070
  themeActions,
1988
2071
  themeReducer,
1989
- useComputedTheme
2072
+ useComputedTheme,
2073
+ usePaperDefaults
1990
2074
  });
package/dist/index.mjs CHANGED
@@ -2,6 +2,56 @@ 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/Button.tsx
6
+ import { Button as PaperButton } from "react-native-paper";
7
+
8
+ // src/PaperDefaultsContext.tsx
9
+ import { createContext, useContext } from "react";
10
+ var PaperDefaultsContext = createContext({});
11
+ function usePaperDefaults() {
12
+ return useContext(PaperDefaultsContext);
13
+ }
14
+
15
+ // src/components/Button.tsx
16
+ import { jsx } from "react/jsx-runtime";
17
+ function Button(props) {
18
+ const defaults = usePaperDefaults();
19
+ return /* @__PURE__ */ jsx(PaperButton, { ...defaults.Button, ...props });
20
+ }
21
+
22
+ // src/components/Chip.tsx
23
+ import { Chip as PaperChip } from "react-native-paper";
24
+ import { jsx as jsx2 } from "react/jsx-runtime";
25
+ function Chip(props) {
26
+ const defaults = usePaperDefaults();
27
+ return /* @__PURE__ */ jsx2(PaperChip, { ...defaults.Chip, ...props });
28
+ }
29
+
30
+ // src/components/FAB.tsx
31
+ import { FAB as PaperFAB } from "react-native-paper";
32
+ import { jsx as jsx3 } from "react/jsx-runtime";
33
+ function FAB(props) {
34
+ const defaults = usePaperDefaults();
35
+ return /* @__PURE__ */ jsx3(PaperFAB, { ...defaults.FAB, ...props });
36
+ }
37
+
38
+ // src/components/IconButton.tsx
39
+ import { IconButton as PaperIconButton } from "react-native-paper";
40
+ import { jsx as jsx4 } from "react/jsx-runtime";
41
+ function IconButton(props) {
42
+ const defaults = usePaperDefaults();
43
+ return /* @__PURE__ */ jsx4(PaperIconButton, { ...defaults.IconButton, ...props });
44
+ }
45
+
46
+ // src/components/TextInput.tsx
47
+ import { forwardRef } from "react";
48
+ import { TextInput as PaperTextInput } from "react-native-paper";
49
+ import { jsx as jsx5 } from "react/jsx-runtime";
50
+ var TextInput = forwardRef(function TextInput2(props, ref) {
51
+ const defaults = usePaperDefaults();
52
+ return /* @__PURE__ */ jsx5(PaperTextInput, { ref, ...defaults.TextInput, ...props });
53
+ });
54
+
5
55
  // node_modules/redux/dist/redux.mjs
6
56
  var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
7
57
  var ActionTypes = {
@@ -926,18 +976,18 @@ function executeReducerBuilderCallback(builderCallback) {
926
976
  actionsMap[type] = reducer;
927
977
  return builder;
928
978
  },
929
- addAsyncThunk(asyncThunk, reducers) {
979
+ addAsyncThunk(asyncThunk, reducers2) {
930
980
  if (process.env.NODE_ENV !== "production") {
931
981
  if (defaultCaseReducer) {
932
982
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
933
983
  }
934
984
  }
935
- if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
936
- if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
937
- if (reducers.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers.fulfilled;
938
- if (reducers.settled) actionMatchers.push({
985
+ if (reducers2.pending) actionsMap[asyncThunk.pending.type] = reducers2.pending;
986
+ if (reducers2.rejected) actionsMap[asyncThunk.rejected.type] = reducers2.rejected;
987
+ if (reducers2.fulfilled) actionsMap[asyncThunk.fulfilled.type] = reducers2.fulfilled;
988
+ if (reducers2.settled) actionMatchers.push({
939
989
  matcher: asyncThunk.settled,
940
- reducer: reducers.settled
990
+ reducer: reducers2.settled
941
991
  });
942
992
  return builder;
943
993
  },
@@ -969,7 +1019,7 @@ function executeReducerBuilderCallback(builderCallback) {
969
1019
  function isStateFunction(x) {
970
1020
  return typeof x === "function";
971
1021
  }
972
- function createReducer(initialState2, mapOrBuilderCallback) {
1022
+ function createReducer(initialState, mapOrBuilderCallback) {
973
1023
  if (process.env.NODE_ENV !== "production") {
974
1024
  if (typeof mapOrBuilderCallback === "object") {
975
1025
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
@@ -977,10 +1027,10 @@ function createReducer(initialState2, mapOrBuilderCallback) {
977
1027
  }
978
1028
  let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
979
1029
  let getInitialState;
980
- if (isStateFunction(initialState2)) {
981
- getInitialState = () => freezeDraftable(initialState2());
1030
+ if (isStateFunction(initialState)) {
1031
+ getInitialState = () => freezeDraftable(initialState());
982
1032
  } else {
983
- const frozenInitialState = freezeDraftable(initialState2);
1033
+ const frozenInitialState = freezeDraftable(initialState);
984
1034
  getInitialState = () => frozenInitialState;
985
1035
  }
986
1036
  function reducer(state = getInitialState(), action) {
@@ -1245,8 +1295,8 @@ var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
1245
1295
  var asyncThunkCreator = {
1246
1296
  [asyncThunkSymbol]: createAsyncThunk
1247
1297
  };
1248
- function getType(slice2, actionKey) {
1249
- return `${slice2}/${actionKey}`;
1298
+ function getType(slice, actionKey) {
1299
+ return `${slice}/${actionKey}`;
1250
1300
  }
1251
1301
  function buildCreateSlice({
1252
1302
  creators
@@ -1265,8 +1315,8 @@ function buildCreateSlice({
1265
1315
  console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
1266
1316
  }
1267
1317
  }
1268
- const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1269
- const reducerNames = Object.keys(reducers);
1318
+ const reducers2 = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
1319
+ const reducerNames = Object.keys(reducers2);
1270
1320
  const context = {
1271
1321
  sliceCaseReducersByName: {},
1272
1322
  sliceCaseReducersByType: {},
@@ -1302,7 +1352,7 @@ function buildCreateSlice({
1302
1352
  }
1303
1353
  };
1304
1354
  reducerNames.forEach((reducerName) => {
1305
- const reducerDefinition = reducers[reducerName];
1355
+ const reducerDefinition = reducers2[reducerName];
1306
1356
  const reducerDetails = {
1307
1357
  reducerName,
1308
1358
  type: getType(name, reducerName),
@@ -1383,7 +1433,7 @@ function buildCreateSlice({
1383
1433
  selectSlice
1384
1434
  };
1385
1435
  }
1386
- const slice2 = {
1436
+ const slice = {
1387
1437
  name,
1388
1438
  reducer,
1389
1439
  actions: context.actionCreators,
@@ -1400,12 +1450,12 @@ function buildCreateSlice({
1400
1450
  reducer
1401
1451
  }, config);
1402
1452
  return {
1403
- ...slice2,
1453
+ ...slice,
1404
1454
  ...makeSelectorProps(newReducerPath, true)
1405
1455
  };
1406
1456
  }
1407
1457
  };
1408
- return slice2;
1458
+ return slice;
1409
1459
  };
1410
1460
  }
1411
1461
  function wrapSelector(selector, selectState, getInitialState, injected) {
@@ -1541,25 +1591,34 @@ function formatProdErrorMessage(code) {
1541
1591
  }
1542
1592
 
1543
1593
  // src/redux/themeSlice.ts
1544
- var initialState = {
1594
+ var defaultInitialState = {
1545
1595
  appearance: "system",
1546
1596
  color: "#6750a4"
1547
1597
  };
1548
- var slice = createSlice({
1598
+ var reducers = {
1599
+ initialize: (state, action) => ({ ...state, ...action.payload }),
1600
+ setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
1601
+ setColor: (state, action) => ({ ...state, color: action.payload })
1602
+ };
1603
+ function createThemeReducer(initialState) {
1604
+ return createSlice({
1605
+ name: "theme",
1606
+ initialState: { ...defaultInitialState, ...initialState },
1607
+ reducers
1608
+ }).reducer;
1609
+ }
1610
+ var defaultSlice = createSlice({
1549
1611
  name: "theme",
1550
- initialState,
1551
- reducers: {
1552
- initialize: (state, action) => ({ ...state, ...action.payload }),
1553
- setAppearance: (state, action) => ({ ...state, appearance: action.payload }),
1554
- setColor: (state, action) => ({ ...state, color: action.payload })
1555
- }
1612
+ initialState: defaultInitialState,
1613
+ reducers
1556
1614
  });
1557
- var themeActions = slice.actions;
1558
- var themeReducer = slice.reducer;
1615
+ var themeActions = defaultSlice.actions;
1616
+ var themeReducer = defaultSlice.reducer;
1559
1617
  var selectThemeAppearance = (state) => state.appearance;
1560
1618
  var selectThemeColor = (state) => state.color;
1561
1619
 
1562
1620
  // src/ThemeProvider.tsx
1621
+ import { useEffect as useEffect2, useRef } from "react";
1563
1622
  import { StatusBar, StyleSheet, View } from "react-native";
1564
1623
  import { Provider as PaperProvider } from "react-native-paper";
1565
1624
 
@@ -1932,16 +1991,33 @@ function useComputedTheme(appearance, color) {
1932
1991
  }
1933
1992
 
1934
1993
  // src/ThemeProvider.tsx
1935
- function ThemeProvider({ appearance, color, children }) {
1994
+ import { jsx as jsx6, jsxs } from "react/jsx-runtime";
1995
+ function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
1936
1996
  const theme = useComputedTheme(appearance, color);
1997
+ const called = useRef(false);
1998
+ useEffect2(() => {
1999
+ if (theme && !called.current) {
2000
+ called.current = true;
2001
+ onReady?.();
2002
+ }
2003
+ }, [theme, onReady]);
1937
2004
  if (!theme) return null;
1938
- return /* @__PURE__ */ React.createElement(PaperProvider, { theme }, /* @__PURE__ */ React.createElement(StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content" }), /* @__PURE__ */ React.createElement(View, { style: styles.flex }, children));
2005
+ return /* @__PURE__ */ jsxs(PaperProvider, { theme, children: [
2006
+ /* @__PURE__ */ jsx6(StatusBar, { backgroundColor: theme.colors.background, barStyle: theme.dark ? "light-content" : "dark-content", ...statusBarProps }),
2007
+ /* @__PURE__ */ jsx6(PaperDefaultsContext.Provider, { value: defaults ?? {}, children: /* @__PURE__ */ jsx6(View, { style: [styles.flex, { backgroundColor: theme.colors.background }, style], children }) })
2008
+ ] });
1939
2009
  }
1940
2010
  var styles = StyleSheet.create({
1941
2011
  flex: { flex: 1 }
1942
2012
  });
1943
2013
  export {
1944
- ThemeProvider,
2014
+ Button,
2015
+ Chip,
2016
+ FAB,
2017
+ IconButton,
2018
+ Provider,
2019
+ TextInput,
2020
+ createThemeReducer,
1945
2021
  getBlendedColor,
1946
2022
  getHex,
1947
2023
  getRgb,
@@ -1951,5 +2027,6 @@ export {
1951
2027
  selectThemeColor,
1952
2028
  themeActions,
1953
2029
  themeReducer,
1954
- useComputedTheme
2030
+ useComputedTheme,
2031
+ usePaperDefaults
1955
2032
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/auto-paper",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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",