@rific/auto-paper 0.1.2 → 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 +47 -0
- package/dist/index.d.mts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +81 -15
- package/dist/index.mjs +63 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +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
12
|
- All color utilities exported for standalone use
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
@@ -49,6 +50,29 @@ export default function App() {
|
|
|
49
50
|
</AutoPaperProvider>
|
|
50
51
|
```
|
|
51
52
|
|
|
53
|
+
### With component defaults
|
|
54
|
+
|
|
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:
|
|
56
|
+
|
|
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>
|
|
72
|
+
```
|
|
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
|
+
|
|
52
76
|
### With Redux
|
|
53
77
|
|
|
54
78
|
The package exports an optional Redux slice. Use `createThemeReducer` to register it in your store with a custom initial color:
|
|
@@ -132,6 +156,7 @@ export default function App() {
|
|
|
132
156
|
| `appearance` | `'system' \| 'light' \| 'dark'` | Appearance mode |
|
|
133
157
|
| `color` | `string` | Seed color (hex, rgb, or CSS name) |
|
|
134
158
|
| `children` | `ReactNode` | |
|
|
159
|
+
| `defaults` | `PaperDefaults` | Prop defaults for wrapper components (see below) |
|
|
135
160
|
| `onReady` | `() => void` | Called once when the theme first resolves |
|
|
136
161
|
| `statusBarProps` | `StatusBarProps` | Spread over the auto-derived `StatusBar` defaults |
|
|
137
162
|
| `style` | `StyleProp<ViewStyle>` | Applied to the wrapper `View` |
|
|
@@ -144,6 +169,28 @@ Returns `MD3Theme | null`. `null` on the first render while the theme computes.
|
|
|
144
169
|
const theme = useComputedTheme('system', '#6750a4')
|
|
145
170
|
```
|
|
146
171
|
|
|
172
|
+
### `PaperDefaults` / `usePaperDefaults`
|
|
173
|
+
|
|
174
|
+
`PaperDefaults` is the type for the `defaults` prop on `Provider`:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
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
|
+
```
|
|
185
|
+
|
|
186
|
+
Use `usePaperDefaults` if you need to read the defaults in a custom component:
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import { usePaperDefaults } from '@rific/auto-paper'
|
|
190
|
+
|
|
191
|
+
const defaults = usePaperDefaults()
|
|
192
|
+
```
|
|
193
|
+
|
|
147
194
|
### `createThemeReducer(initialState?)`
|
|
148
195
|
|
|
149
196
|
Returns a Redux reducer with an optional initial state override. Useful for setting a custom default color without dispatching an action at startup.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
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';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
|
|
1
7
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
2
8
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
3
9
|
import * as redux from 'redux';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
29
|
|
|
9
30
|
type ThemeAppearance = 'system' | 'light' | 'dark';
|
|
10
31
|
declare function useComputedTheme(appearance: ThemeAppearance, color: string): MD3Theme | null;
|
|
@@ -39,11 +60,12 @@ type ProviderProps = {
|
|
|
39
60
|
appearance: ThemeAppearance;
|
|
40
61
|
color: string;
|
|
41
62
|
children: ReactNode;
|
|
63
|
+
defaults?: PaperDefaults;
|
|
42
64
|
onReady?: () => void;
|
|
43
65
|
statusBarProps?: StatusBarProps;
|
|
44
66
|
style?: StyleProp<ViewStyle>;
|
|
45
67
|
};
|
|
46
|
-
declare function Provider({ appearance, color, children, onReady, statusBarProps, style }: ProviderProps):
|
|
68
|
+
declare function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }: ProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
47
69
|
|
|
48
70
|
declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
|
|
49
71
|
|
|
@@ -66,4 +88,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
|
|
|
66
88
|
|
|
67
89
|
declare const isDarkColor: (value: string) => boolean;
|
|
68
90
|
|
|
69
|
-
export { Provider, type ProviderProps, type RGB, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, 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,10 +1,31 @@
|
|
|
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';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { TextInput as TextInput$1, StatusBarProps, StyleProp, ViewStyle } from 'react-native';
|
|
1
7
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
2
8
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
3
9
|
import * as redux from 'redux';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
29
|
|
|
9
30
|
type ThemeAppearance = 'system' | 'light' | 'dark';
|
|
10
31
|
declare function useComputedTheme(appearance: ThemeAppearance, color: string): MD3Theme | null;
|
|
@@ -39,11 +60,12 @@ type ProviderProps = {
|
|
|
39
60
|
appearance: ThemeAppearance;
|
|
40
61
|
color: string;
|
|
41
62
|
children: ReactNode;
|
|
63
|
+
defaults?: PaperDefaults;
|
|
42
64
|
onReady?: () => void;
|
|
43
65
|
statusBarProps?: StatusBarProps;
|
|
44
66
|
style?: StyleProp<ViewStyle>;
|
|
45
67
|
};
|
|
46
|
-
declare function Provider({ appearance, color, children, onReady, statusBarProps, style }: ProviderProps):
|
|
68
|
+
declare function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }: ProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
47
69
|
|
|
48
70
|
declare const getBlendedColor: (foreground: string, background: string, alpha: number) => string;
|
|
49
71
|
|
|
@@ -66,4 +88,4 @@ declare function getTriadicPalette(primaryColor: string): TriadicPalette;
|
|
|
66
88
|
|
|
67
89
|
declare const isDarkColor: (value: string) => boolean;
|
|
68
90
|
|
|
69
|
-
export { Provider, type ProviderProps, type RGB, type ThemeAppearance, type ThemeState, type TriadicPalette, createThemeReducer, 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,12 @@ 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
|
+
Button: () => Button,
|
|
26
|
+
Chip: () => Chip,
|
|
27
|
+
FAB: () => FAB,
|
|
28
|
+
IconButton: () => IconButton,
|
|
25
29
|
Provider: () => Provider,
|
|
30
|
+
TextInput: () => TextInput,
|
|
26
31
|
createThemeReducer: () => createThemeReducer,
|
|
27
32
|
getBlendedColor: () => getBlendedColor,
|
|
28
33
|
getHex: () => getHex,
|
|
@@ -33,10 +38,61 @@ __export(index_exports, {
|
|
|
33
38
|
selectThemeColor: () => selectThemeColor,
|
|
34
39
|
themeActions: () => themeActions,
|
|
35
40
|
themeReducer: () => themeReducer,
|
|
36
|
-
useComputedTheme: () => useComputedTheme
|
|
41
|
+
useComputedTheme: () => useComputedTheme,
|
|
42
|
+
usePaperDefaults: () => usePaperDefaults
|
|
37
43
|
});
|
|
38
44
|
module.exports = __toCommonJS(index_exports);
|
|
39
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
|
+
|
|
40
96
|
// node_modules/redux/dist/redux.mjs
|
|
41
97
|
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
42
98
|
var ActionTypes = {
|
|
@@ -1603,14 +1659,14 @@ var selectThemeAppearance = (state) => state.appearance;
|
|
|
1603
1659
|
var selectThemeColor = (state) => state.color;
|
|
1604
1660
|
|
|
1605
1661
|
// src/ThemeProvider.tsx
|
|
1606
|
-
var
|
|
1662
|
+
var import_react4 = require("react");
|
|
1607
1663
|
var import_react_native2 = require("react-native");
|
|
1608
|
-
var
|
|
1664
|
+
var import_react_native_paper7 = require("react-native-paper");
|
|
1609
1665
|
|
|
1610
1666
|
// src/useComputedTheme.ts
|
|
1611
|
-
var
|
|
1667
|
+
var import_react3 = require("react");
|
|
1612
1668
|
var import_react_native = require("react-native");
|
|
1613
|
-
var
|
|
1669
|
+
var import_react_native_paper6 = require("react-native-paper");
|
|
1614
1670
|
|
|
1615
1671
|
// src/utils/colorNames.ts
|
|
1616
1672
|
var colorNames = {
|
|
@@ -1921,12 +1977,12 @@ var isDarkColor = (value) => {
|
|
|
1921
1977
|
|
|
1922
1978
|
// src/useComputedTheme.ts
|
|
1923
1979
|
function useComputedTheme(appearance, color) {
|
|
1924
|
-
const [theme, setTheme] = (0,
|
|
1925
|
-
const computeTheme = (0,
|
|
1980
|
+
const [theme, setTheme] = (0, import_react3.useState)(null);
|
|
1981
|
+
const computeTheme = (0, import_react3.useCallback)(() => {
|
|
1926
1982
|
let resolved = appearance;
|
|
1927
1983
|
if (resolved === "system") resolved = import_react_native.Appearance.getColorScheme();
|
|
1928
1984
|
if (resolved === "no-preference" || !resolved) resolved = "light";
|
|
1929
|
-
const base = resolved === "dark" ?
|
|
1985
|
+
const base = resolved === "dark" ? import_react_native_paper6.MD3DarkTheme : import_react_native_paper6.MD3LightTheme;
|
|
1930
1986
|
const _theme = {
|
|
1931
1987
|
...base,
|
|
1932
1988
|
colors: {
|
|
@@ -1965,10 +2021,10 @@ function useComputedTheme(appearance, color) {
|
|
|
1965
2021
|
};
|
|
1966
2022
|
setTheme(_theme);
|
|
1967
2023
|
}, [appearance, color]);
|
|
1968
|
-
(0,
|
|
2024
|
+
(0, import_react3.useEffect)(() => {
|
|
1969
2025
|
computeTheme();
|
|
1970
2026
|
}, [computeTheme]);
|
|
1971
|
-
(0,
|
|
2027
|
+
(0, import_react3.useEffect)(() => {
|
|
1972
2028
|
const subscription = import_react_native.Appearance.addChangeListener(computeTheme);
|
|
1973
2029
|
return subscription.remove;
|
|
1974
2030
|
}, [computeTheme]);
|
|
@@ -1976,24 +2032,33 @@ function useComputedTheme(appearance, color) {
|
|
|
1976
2032
|
}
|
|
1977
2033
|
|
|
1978
2034
|
// src/ThemeProvider.tsx
|
|
1979
|
-
|
|
2035
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2036
|
+
function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
|
|
1980
2037
|
const theme = useComputedTheme(appearance, color);
|
|
1981
|
-
const called = (0,
|
|
1982
|
-
(0,
|
|
2038
|
+
const called = (0, import_react4.useRef)(false);
|
|
2039
|
+
(0, import_react4.useEffect)(() => {
|
|
1983
2040
|
if (theme && !called.current) {
|
|
1984
2041
|
called.current = true;
|
|
1985
2042
|
onReady?.();
|
|
1986
2043
|
}
|
|
1987
2044
|
}, [theme, onReady]);
|
|
1988
2045
|
if (!theme) return null;
|
|
1989
|
-
return /* @__PURE__ */
|
|
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
|
+
] });
|
|
1990
2050
|
}
|
|
1991
2051
|
var styles = import_react_native2.StyleSheet.create({
|
|
1992
2052
|
flex: { flex: 1 }
|
|
1993
2053
|
});
|
|
1994
2054
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1995
2055
|
0 && (module.exports = {
|
|
2056
|
+
Button,
|
|
2057
|
+
Chip,
|
|
2058
|
+
FAB,
|
|
2059
|
+
IconButton,
|
|
1996
2060
|
Provider,
|
|
2061
|
+
TextInput,
|
|
1997
2062
|
createThemeReducer,
|
|
1998
2063
|
getBlendedColor,
|
|
1999
2064
|
getHex,
|
|
@@ -2004,5 +2069,6 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
2004
2069
|
selectThemeColor,
|
|
2005
2070
|
themeActions,
|
|
2006
2071
|
themeReducer,
|
|
2007
|
-
useComputedTheme
|
|
2072
|
+
useComputedTheme,
|
|
2073
|
+
usePaperDefaults
|
|
2008
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 = {
|
|
@@ -1941,7 +1991,8 @@ function useComputedTheme(appearance, color) {
|
|
|
1941
1991
|
}
|
|
1942
1992
|
|
|
1943
1993
|
// src/ThemeProvider.tsx
|
|
1944
|
-
|
|
1994
|
+
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
1995
|
+
function Provider({ appearance, color, children, defaults, onReady, statusBarProps, style }) {
|
|
1945
1996
|
const theme = useComputedTheme(appearance, color);
|
|
1946
1997
|
const called = useRef(false);
|
|
1947
1998
|
useEffect2(() => {
|
|
@@ -1951,13 +2002,21 @@ function Provider({ appearance, color, children, onReady, statusBarProps, style
|
|
|
1951
2002
|
}
|
|
1952
2003
|
}, [theme, onReady]);
|
|
1953
2004
|
if (!theme) return null;
|
|
1954
|
-
return /* @__PURE__ */
|
|
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
|
+
] });
|
|
1955
2009
|
}
|
|
1956
2010
|
var styles = StyleSheet.create({
|
|
1957
2011
|
flex: { flex: 1 }
|
|
1958
2012
|
});
|
|
1959
2013
|
export {
|
|
2014
|
+
Button,
|
|
2015
|
+
Chip,
|
|
2016
|
+
FAB,
|
|
2017
|
+
IconButton,
|
|
1960
2018
|
Provider,
|
|
2019
|
+
TextInput,
|
|
1961
2020
|
createThemeReducer,
|
|
1962
2021
|
getBlendedColor,
|
|
1963
2022
|
getHex,
|
|
@@ -1968,5 +2027,6 @@ export {
|
|
|
1968
2027
|
selectThemeColor,
|
|
1969
2028
|
themeActions,
|
|
1970
2029
|
themeReducer,
|
|
1971
|
-
useComputedTheme
|
|
2030
|
+
useComputedTheme,
|
|
2031
|
+
usePaperDefaults
|
|
1972
2032
|
};
|