@rific/auto-paper 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +32 -16
- package/dist/index.mjs +30 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -46,8 +46,11 @@ type BlurViewProps = BlurViewProps$1 & {
|
|
|
46
46
|
children?: ReactNode;
|
|
47
47
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
48
48
|
style?: StyleProp<ViewStyle>;
|
|
49
|
+
tintColor?: string;
|
|
50
|
+
tintOpacity?: number;
|
|
51
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
49
52
|
};
|
|
50
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
|
|
53
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
51
54
|
|
|
52
55
|
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
53
56
|
declare namespace BottomNavigationComponent {
|
|
@@ -221,6 +224,10 @@ type RGB = {
|
|
|
221
224
|
};
|
|
222
225
|
declare const getRgb: (value: string) => RGB | null;
|
|
223
226
|
|
|
227
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
228
|
+
|
|
229
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
230
|
+
|
|
224
231
|
declare const isDarkColor: (value: string) => boolean;
|
|
225
232
|
|
|
226
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
233
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
package/dist/index.d.ts
CHANGED
|
@@ -46,8 +46,11 @@ type BlurViewProps = BlurViewProps$1 & {
|
|
|
46
46
|
children?: ReactNode;
|
|
47
47
|
elevation?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
48
48
|
style?: StyleProp<ViewStyle>;
|
|
49
|
+
tintColor?: string;
|
|
50
|
+
tintOpacity?: number;
|
|
51
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'surface' | 'surfaceVariant';
|
|
49
52
|
};
|
|
50
|
-
declare const BlurView: ({ blur, children, elevation, style, ...props }: BlurViewProps) => react.JSX.Element;
|
|
53
|
+
declare const BlurView: ({ blur, children, elevation, style, tintColor, tintOpacity, variant, ...props }: BlurViewProps) => react.JSX.Element;
|
|
51
54
|
|
|
52
55
|
declare function BottomNavigationComponent<Route extends BottomNavigationRoute>(props: BottomNavigationProps<Route>): react__default.JSX.Element;
|
|
53
56
|
declare namespace BottomNavigationComponent {
|
|
@@ -221,6 +224,10 @@ type RGB = {
|
|
|
221
224
|
};
|
|
222
225
|
declare const getRgb: (value: string) => RGB | null;
|
|
223
226
|
|
|
227
|
+
declare const getTintTextColor: (tintColor: string, backdropColor: string, tintOpacity: number) => string;
|
|
228
|
+
|
|
229
|
+
declare const getTonalColor: (color: string, lightness: number) => string;
|
|
230
|
+
|
|
224
231
|
declare const isDarkColor: (value: string) => boolean;
|
|
225
232
|
|
|
226
|
-
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
|
233
|
+
export { Appbar, AppearancePicker, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, Dialog, type DialogProps, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, type PaperDefaults, Provider, type ProviderProps, type RGB, type SeedColor, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getHex, getRgb, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useBlur, useComputedTheme, usePaperDefaults, useThemeSettings };
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
getBlendedColor: () => getBlendedColor,
|
|
44
44
|
getHex: () => getHex,
|
|
45
45
|
getRgb: () => getRgb,
|
|
46
|
+
getTintTextColor: () => getTintTextColor,
|
|
47
|
+
getTonalColor: () => getTonalColor,
|
|
46
48
|
getTriadicPalette: () => getTriadicPalette,
|
|
47
49
|
isDarkColor: () => isDarkColor,
|
|
48
50
|
selectThemeAppearance: () => selectThemeAppearance,
|
|
@@ -127,18 +129,22 @@ var import_react_native2 = require("react-native");
|
|
|
127
129
|
var import_react_native_paper3 = require("react-native-paper");
|
|
128
130
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
129
131
|
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
130
|
-
var
|
|
132
|
+
var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
|
|
133
|
+
var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
|
|
131
134
|
const { dark, colors } = (0, import_react_native_paper3.useTheme)();
|
|
132
135
|
const { settings } = (0, import_react4.useContext)(ThemeSettingsContext);
|
|
133
|
-
const
|
|
134
|
-
const
|
|
136
|
+
const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
|
|
137
|
+
const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
|
|
138
|
+
const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
|
|
139
|
+
const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
|
|
140
|
+
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
|
|
135
141
|
if (blur)
|
|
136
142
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_expo_blur.BlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
137
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor:
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { style: [import_react_native2.StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
|
|
138
144
|
tint,
|
|
139
145
|
children
|
|
140
146
|
] });
|
|
141
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor:
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.View, { style: [{ backgroundColor: surfaceColor }, style], children: [
|
|
142
148
|
tint,
|
|
143
149
|
children
|
|
144
150
|
] });
|
|
@@ -591,16 +597,18 @@ var NavBarContext = (0, import_react6.createContext)({});
|
|
|
591
597
|
var useNavBarContext = () => (0, import_react6.useContext)(NavBarContext);
|
|
592
598
|
function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
|
|
593
599
|
const [settings, setSettings] = (0, import_react6.useState)(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
594
|
-
const set2 = (0, import_react6.useCallback)(
|
|
595
|
-
(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
600
|
+
const set2 = (0, import_react6.useCallback)((patch) => {
|
|
601
|
+
setSettings((prev) => ({ ...prev, ...patch }));
|
|
602
|
+
}, []);
|
|
603
|
+
const onChangeRef = (0, import_react6.useRef)(onChange);
|
|
604
|
+
onChangeRef.current = onChange;
|
|
605
|
+
const prevSettings = (0, import_react6.useRef)(settings);
|
|
606
|
+
(0, import_react6.useEffect)(() => {
|
|
607
|
+
if (prevSettings.current !== settings) {
|
|
608
|
+
prevSettings.current = settings;
|
|
609
|
+
onChangeRef.current?.(settings);
|
|
610
|
+
}
|
|
611
|
+
}, [settings]);
|
|
604
612
|
const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
|
|
605
613
|
const called = (0, import_react6.useRef)(false);
|
|
606
614
|
(0, import_react6.useEffect)(() => {
|
|
@@ -639,7 +647,7 @@ function Bar(props) {
|
|
|
639
647
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native_paper6.BottomNavigation.Bar, { ...props });
|
|
640
648
|
}
|
|
641
649
|
BottomNavigationComponent.Bar = Bar;
|
|
642
|
-
BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation
|
|
650
|
+
BottomNavigationComponent.SceneMap = import_react_native_paper6.BottomNavigation?.SceneMap;
|
|
643
651
|
var BottomNavigation = BottomNavigationComponent;
|
|
644
652
|
|
|
645
653
|
// src/components/Button.tsx
|
|
@@ -2409,6 +2417,12 @@ var selectThemeHarmony = (state) => state.harmony;
|
|
|
2409
2417
|
// src/useThemeSettings.ts
|
|
2410
2418
|
var import_react12 = require("react");
|
|
2411
2419
|
var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext);
|
|
2420
|
+
|
|
2421
|
+
// src/utils/getTintTextColor.ts
|
|
2422
|
+
var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
|
|
2423
|
+
const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
|
|
2424
|
+
return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
|
|
2425
|
+
};
|
|
2412
2426
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2413
2427
|
0 && (module.exports = {
|
|
2414
2428
|
Appbar,
|
|
@@ -2432,6 +2446,8 @@ var useThemeSettings = () => (0, import_react12.useContext)(ThemeSettingsContext
|
|
|
2432
2446
|
getBlendedColor,
|
|
2433
2447
|
getHex,
|
|
2434
2448
|
getRgb,
|
|
2449
|
+
getTintTextColor,
|
|
2450
|
+
getTonalColor,
|
|
2435
2451
|
getTriadicPalette,
|
|
2436
2452
|
isDarkColor,
|
|
2437
2453
|
selectThemeAppearance,
|
package/dist/index.mjs
CHANGED
|
@@ -71,18 +71,22 @@ import { StyleSheet, View } from "react-native";
|
|
|
71
71
|
import { useTheme as useTheme2 } from "react-native-paper";
|
|
72
72
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
73
73
|
var ELEVATION_OPACITY = { 0: 0, 1: 0.05, 2: 0.08, 3: 0.11, 4: 0.12, 5: 0.14 };
|
|
74
|
-
var
|
|
74
|
+
var VARIANT_TINT_OPACITY = { light: 0.12, dark: 0.18 };
|
|
75
|
+
var BlurView = ({ blur = true, children, elevation, style, tintColor, tintOpacity, variant = "surface", ...props }) => {
|
|
75
76
|
const { dark, colors } = useTheme2();
|
|
76
77
|
const { settings } = useContext3(ThemeSettingsContext);
|
|
77
|
-
const
|
|
78
|
-
const
|
|
78
|
+
const surfaceColor = variant === "surfaceVariant" ? colors.surfaceVariant : colors.surface;
|
|
79
|
+
const variantColor = variant === "primary" ? colors.primary : variant === "secondary" ? colors.secondary : variant === "tertiary" ? colors.tertiary : variant === "error" ? colors.error : void 0;
|
|
80
|
+
const resolvedTintColor = tintColor ?? variantColor ?? (elevation !== void 0 ? colors.primary : void 0);
|
|
81
|
+
const resolvedTintOpacity = tintOpacity ?? (tintColor ? dark ? 0.24 : 0.16 : variantColor ? dark ? VARIANT_TINT_OPACITY.dark : VARIANT_TINT_OPACITY.light : elevation !== void 0 ? ELEVATION_OPACITY[elevation] : 0);
|
|
82
|
+
const tint = resolvedTintColor && resolvedTintOpacity > 0 ? /* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: resolvedTintColor, opacity: resolvedTintOpacity }] }) : null;
|
|
79
83
|
if (blur)
|
|
80
84
|
return /* @__PURE__ */ jsxs2(ExpoBlurView, { ...props, tint: dark ? "dark" : "light", style, children: [
|
|
81
|
-
/* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor:
|
|
85
|
+
/* @__PURE__ */ jsx3(View, { style: [StyleSheet.absoluteFill, { backgroundColor: surfaceColor, opacity: settings.blurTint }] }),
|
|
82
86
|
tint,
|
|
83
87
|
children
|
|
84
88
|
] });
|
|
85
|
-
return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor:
|
|
89
|
+
return /* @__PURE__ */ jsxs2(View, { style: [{ backgroundColor: surfaceColor }, style], children: [
|
|
86
90
|
tint,
|
|
87
91
|
children
|
|
88
92
|
] });
|
|
@@ -535,16 +539,18 @@ var NavBarContext = createContext3({});
|
|
|
535
539
|
var useNavBarContext = () => useContext4(NavBarContext);
|
|
536
540
|
function Provider({ initialValue, onChange, children, defaults, onNavBarChange, onReady, statusBarProps, style }) {
|
|
537
541
|
const [settings, setSettings] = useState2(() => ({ ...defaultThemeSettings, ...initialValue }));
|
|
538
|
-
const set2 = useCallback2(
|
|
539
|
-
(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
542
|
+
const set2 = useCallback2((patch) => {
|
|
543
|
+
setSettings((prev) => ({ ...prev, ...patch }));
|
|
544
|
+
}, []);
|
|
545
|
+
const onChangeRef = useRef(onChange);
|
|
546
|
+
onChangeRef.current = onChange;
|
|
547
|
+
const prevSettings = useRef(settings);
|
|
548
|
+
useEffect2(() => {
|
|
549
|
+
if (prevSettings.current !== settings) {
|
|
550
|
+
prevSettings.current = settings;
|
|
551
|
+
onChangeRef.current?.(settings);
|
|
552
|
+
}
|
|
553
|
+
}, [settings]);
|
|
548
554
|
const theme = useComputedTheme(settings.appearance, settings.color, settings.harmony);
|
|
549
555
|
const called = useRef(false);
|
|
550
556
|
useEffect2(() => {
|
|
@@ -583,7 +589,7 @@ function Bar(props) {
|
|
|
583
589
|
return /* @__PURE__ */ jsx5(PaperBottomNavigation.Bar, { ...props });
|
|
584
590
|
}
|
|
585
591
|
BottomNavigationComponent.Bar = Bar;
|
|
586
|
-
BottomNavigationComponent.SceneMap = PaperBottomNavigation
|
|
592
|
+
BottomNavigationComponent.SceneMap = PaperBottomNavigation?.SceneMap;
|
|
587
593
|
var BottomNavigation = BottomNavigationComponent;
|
|
588
594
|
|
|
589
595
|
// src/components/Button.tsx
|
|
@@ -2353,6 +2359,12 @@ var selectThemeHarmony = (state) => state.harmony;
|
|
|
2353
2359
|
// src/useThemeSettings.ts
|
|
2354
2360
|
import { useContext as useContext5 } from "react";
|
|
2355
2361
|
var useThemeSettings = () => useContext5(ThemeSettingsContext);
|
|
2362
|
+
|
|
2363
|
+
// src/utils/getTintTextColor.ts
|
|
2364
|
+
var getTintTextColor = (tintColor, backdropColor, tintOpacity) => {
|
|
2365
|
+
const blended = getBlendedColor(tintColor, backdropColor, tintOpacity);
|
|
2366
|
+
return getTonalColor(tintColor, isDarkColor(blended) ? 0.92 : 0.12);
|
|
2367
|
+
};
|
|
2356
2368
|
export {
|
|
2357
2369
|
Appbar,
|
|
2358
2370
|
AppearancePicker,
|
|
@@ -2375,6 +2387,8 @@ export {
|
|
|
2375
2387
|
getBlendedColor,
|
|
2376
2388
|
getHex,
|
|
2377
2389
|
getRgb,
|
|
2390
|
+
getTintTextColor,
|
|
2391
|
+
getTonalColor,
|
|
2378
2392
|
getTriadicPalette,
|
|
2379
2393
|
isDarkColor,
|
|
2380
2394
|
selectThemeAppearance,
|