@rific/auto-paper 0.9.3 → 0.9.4

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
@@ -11,7 +11,7 @@ Adaptive theming for [`react-native-paper`](https://callstack.github.io/react-na
11
11
  - Tinted surface, surfaceVariant, outline, and elevation levels derived from the seed
12
12
  - Fixed `success`/`warning`/`danger` semantic color roles (each with `on*`/`*Container` variants) alongside MD3's built-in `error`
13
13
  - Optional Redux slice for wiring appearance and color into your store
14
- - Wrapper components (`Appbar`, `AppearancePicker`, `BlurView`, `BottomNavigation`, `Button`, `Chip`, `ColorPicker`, `Dialog`, `FAB`, `HarmonyPicker`, `IconButton`, `Menu`, `PalettePicker`, `TextInput`) with prop defaults via context
14
+ - Wrapper components (`Appbar`, `AppearancePicker`, `AutoAppearancePicker`, `AutoPalettePicker`, `BlurView`, `BottomNavigation`, `Button`, `Chip`, `ColorPicker`, `Dialog`, `FAB`, `HarmonyPicker`, `IconButton`, `Menu`, `PalettePicker`, `TextInput`) with prop defaults via context
15
15
  - All color utilities exported for standalone use
16
16
 
17
17
  ## Installation
@@ -327,6 +327,18 @@ function SettingsScreen() {
327
327
  | `showLabels` | `boolean` | Set `false` for icon-only segments, useful in tight layouts where "System" would truncate. `accessibilityLabel` is always set regardless, so screen readers still announce the full word. Defaults to `true` |
328
328
  | `icons` | `AppearanceIcons` | Per-value icon overrides: pass just the ones you want to change (e.g. `{ system: 'theme-light-dark' }`), merged over the defaults (`monitor` / `white-balance-sunny` / `weather-night`) |
329
329
 
330
+ ### `AutoAppearancePicker`
331
+
332
+ `AppearancePicker` wired straight to the `Provider`'s own `ThemeSettings` — for the common case where the appearance being edited IS the whole app's own theme. Reads/writes `useThemeSettings()` internally, so it takes neither `value` nor `onChange`; every other `AppearancePicker` prop still passes through. Reach for the plain `AppearancePicker` instead when it needs to be controlled by something other than the global theme (a local preview before committing, one-off UI unrelated to `Provider`).
333
+
334
+ ```tsx
335
+ import { AutoAppearancePicker } from '@rific/auto-paper'
336
+
337
+ function SettingsScreen() {
338
+ return <AutoAppearancePicker showLabels={false} />
339
+ }
340
+ ```
341
+
330
342
  ### `HarmonyPicker`
331
343
 
332
344
  Switches between the 6 `ColorHarmony` modes (`triadic`, `split-complementary`, `analogous`, `square`, `complementary`, `double-split`) via `react-native-paper`'s `SegmentedButtons`. `PalettePicker` can embed this same picker in its own dialog instead of standing alone — see `onHarmonyChange` below.
@@ -474,6 +486,18 @@ function SettingsScreen() {
474
486
  | `colors` | `SeedColor[]` | Seed color swatches to offer. Defaults to the same set as `ColorPicker` |
475
487
  | `blur` | `boolean` | Overrides the ambient blur setting for this component's dialog |
476
488
 
489
+ ### `AutoPalettePicker`
490
+
491
+ `PalettePicker` wired straight to the `Provider`'s own `ThemeSettings` — both color AND harmony — for the common case where the palette being edited IS the whole app's own theme. Reads/writes `useThemeSettings()` internally (narrowing `ThemeSettings.color`'s `string | TriadicPalette` down to a plain string via `resolveSeedColor`), so it takes none of `value`/`onChange`/`harmony`/`onHarmonyChange`; `weights`/`colors`/`blur` still pass through. Reach for the plain `PalettePicker` instead when it needs to be controlled by something other than the global theme.
492
+
493
+ ```tsx
494
+ import { AutoPalettePicker } from '@rific/auto-paper'
495
+
496
+ function SettingsScreen() {
497
+ return <AutoPalettePicker />
498
+ }
499
+ ```
500
+
477
501
  ### `PaperDefaults` / `usePaperDefaults`
478
502
 
479
503
  `PaperDefaults` is the type for the `defaults` prop on `Provider`:
@@ -530,7 +554,7 @@ const appearance = useSelector((state: RootState) => selectThemeAppearance(state
530
554
  ### Color utilities
531
555
 
532
556
  ```ts
533
- import { getTriadicPalette, getThirdColor, getBlendedColor, getColorRoles, getContrastColor, isDarkColor, getRgb, getHex, getTonalColor, getTintTextColor } from '@rific/auto-paper'
557
+ import { getTriadicPalette, getThirdColor, getBlendedColor, getColorRoles, getContrastColor, isDarkColor, getRgb, getHex, getTonalColor, getTintTextColor, resolveSeedColor } from '@rific/auto-paper'
534
558
  import type { ColorHarmony, TriadicPalette } from '@rific/auto-paper'
535
559
 
536
560
  getTriadicPalette('#6750a4') // split-complementary (default)
@@ -548,6 +572,9 @@ getContrastColor('#6750a4') // → '#ffffff' (black/white pick
548
572
  isDarkColor('#6750a4') // → true
549
573
  getRgb('coral') // → { r: 255, g: 127, b: 80 }
550
574
  getHex('rgb(255, 0, 0)') // → '#ff0000'
575
+
576
+ resolveSeedColor('#6750a4') // → '#6750a4' (already a plain string)
577
+ resolveSeedColor({ primary: '#6750a4', secondary: '#a4916c', tertiary: '#916ca4' }) // → '#6750a4' (a ThemeSettings.color explicit triad narrows to its own primary)
551
578
  ```
552
579
 
553
580
  ## License
package/dist/index.d.mts CHANGED
@@ -54,13 +54,55 @@ type AutoPaperTheme = Omit<MD3Theme, 'colors'> & {
54
54
  declare function useComputedTheme(appearance: ThemeAppearance, color: string | TriadicPalette, harmony?: ColorHarmony): AutoPaperTheme | null;
55
55
 
56
56
  type AppearanceIcons = Partial<Record<ThemeAppearance, string>>;
57
- type Props$3 = {
57
+ type Props$5 = {
58
58
  value: ThemeAppearance;
59
59
  onChange: (appearance: ThemeAppearance) => void;
60
60
  showLabels?: boolean;
61
61
  icons?: AppearanceIcons;
62
62
  };
63
- declare const AppearancePicker: ({ value, onChange, showLabels, icons }: Props$3) => react.JSX.Element;
63
+ declare const AppearancePicker: ({ value, onChange, showLabels, icons }: Props$5) => react.JSX.Element;
64
+
65
+ type Props$4 = {
66
+ showLabels?: boolean;
67
+ icons?: AppearanceIcons;
68
+ };
69
+ declare const AutoAppearancePicker: (props: Props$4) => react.JSX.Element;
70
+
71
+ type SeedColor = {
72
+ label: string;
73
+ value: string;
74
+ };
75
+ declare const defaultColors: SeedColor[];
76
+ type Props$3 = {
77
+ value: string;
78
+ onChange: (color: string) => void;
79
+ colors?: SeedColor[];
80
+ blur?: boolean;
81
+ };
82
+ declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$3) => react.JSX.Element;
83
+
84
+ type PaletteWeights = {
85
+ primary: number;
86
+ secondary: number;
87
+ tertiary: number;
88
+ };
89
+ type Props$2 = {
90
+ value: string;
91
+ onChange: (color: string) => void;
92
+ harmony?: ColorHarmony;
93
+ onHarmonyChange?: (harmony: ColorHarmony) => void;
94
+ weights?: PaletteWeights;
95
+ colors?: SeedColor[];
96
+ blur?: boolean;
97
+ };
98
+ declare const PalettePicker: ({ value, onChange, harmony, onHarmonyChange, weights, colors, blur: blurProp }: Props$2) => react.JSX.Element;
99
+
100
+ type Props$1 = {
101
+ weights?: PaletteWeights;
102
+ colors?: SeedColor[];
103
+ blur?: boolean;
104
+ };
105
+ declare const AutoPalettePicker: (props: Props$1) => react.JSX.Element;
64
106
 
65
107
  interface ExpoBlurModule {
66
108
  BlurView: ComponentType<{
@@ -114,19 +156,6 @@ type ChipProps = ChipProps$1 & {
114
156
  };
115
157
  declare function Chip({ variant, style, selectedColor, ...props }: ChipProps): react.JSX.Element;
116
158
 
117
- type SeedColor = {
118
- label: string;
119
- value: string;
120
- };
121
- declare const defaultColors: SeedColor[];
122
- type Props$2 = {
123
- value: string;
124
- onChange: (color: string) => void;
125
- colors?: SeedColor[];
126
- blur?: boolean;
127
- };
128
- declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$2) => react.JSX.Element;
129
-
130
159
  interface ReanimatedModule {
131
160
  View: ComponentType<{
132
161
  children?: ReactNode;
@@ -150,7 +179,7 @@ declare const Dialog: typeof DialogComponent;
150
179
 
151
180
  declare function FAB(props: FABProps): react.JSX.Element;
152
181
 
153
- type Props$1 = {
182
+ type Props = {
154
183
  value: ColorHarmony;
155
184
  onChange: (harmony: ColorHarmony) => void;
156
185
  showLabels?: boolean;
@@ -159,7 +188,7 @@ type Props$1 = {
159
188
  checkedContainerColor?: string;
160
189
  uncheckedContainerColor?: string;
161
190
  };
162
- declare const HarmonyPicker: ({ value, onChange, showLabels, checkedColor, uncheckedColor, checkedContainerColor, uncheckedContainerColor }: Props$1) => react.JSX.Element;
191
+ declare const HarmonyPicker: ({ value, onChange, showLabels, checkedColor, uncheckedColor, checkedContainerColor, uncheckedContainerColor }: Props) => react.JSX.Element;
163
192
 
164
193
  type IconButtonProps = IconButtonProps$1 & {
165
194
  variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
@@ -173,22 +202,6 @@ declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) => reac
173
202
  Item: react__default.FC<MenuItemProps>;
174
203
  };
175
204
 
176
- type PaletteWeights = {
177
- primary: number;
178
- secondary: number;
179
- tertiary: number;
180
- };
181
- type Props = {
182
- value: string;
183
- onChange: (color: string) => void;
184
- harmony?: ColorHarmony;
185
- onHarmonyChange?: (harmony: ColorHarmony) => void;
186
- weights?: PaletteWeights;
187
- colors?: SeedColor[];
188
- blur?: boolean;
189
- };
190
- declare const PalettePicker: ({ value, onChange, harmony, onHarmonyChange, weights, colors, blur: blurProp }: Props) => react.JSX.Element;
191
-
192
205
  declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
193
206
 
194
207
  interface ExpoNavigationBarModule {
@@ -339,4 +352,6 @@ declare const getTonalColor: (color: string, lightness: number) => string;
339
352
 
340
353
  declare const isDarkColor: (value: string) => boolean;
341
354
 
342
- export { Appbar, type AppearanceIcons, AppearancePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };
355
+ declare const resolveSeedColor: (color: string | TriadicPalette) => string;
356
+
357
+ export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };
package/dist/index.d.ts CHANGED
@@ -54,13 +54,55 @@ type AutoPaperTheme = Omit<MD3Theme, 'colors'> & {
54
54
  declare function useComputedTheme(appearance: ThemeAppearance, color: string | TriadicPalette, harmony?: ColorHarmony): AutoPaperTheme | null;
55
55
 
56
56
  type AppearanceIcons = Partial<Record<ThemeAppearance, string>>;
57
- type Props$3 = {
57
+ type Props$5 = {
58
58
  value: ThemeAppearance;
59
59
  onChange: (appearance: ThemeAppearance) => void;
60
60
  showLabels?: boolean;
61
61
  icons?: AppearanceIcons;
62
62
  };
63
- declare const AppearancePicker: ({ value, onChange, showLabels, icons }: Props$3) => react.JSX.Element;
63
+ declare const AppearancePicker: ({ value, onChange, showLabels, icons }: Props$5) => react.JSX.Element;
64
+
65
+ type Props$4 = {
66
+ showLabels?: boolean;
67
+ icons?: AppearanceIcons;
68
+ };
69
+ declare const AutoAppearancePicker: (props: Props$4) => react.JSX.Element;
70
+
71
+ type SeedColor = {
72
+ label: string;
73
+ value: string;
74
+ };
75
+ declare const defaultColors: SeedColor[];
76
+ type Props$3 = {
77
+ value: string;
78
+ onChange: (color: string) => void;
79
+ colors?: SeedColor[];
80
+ blur?: boolean;
81
+ };
82
+ declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$3) => react.JSX.Element;
83
+
84
+ type PaletteWeights = {
85
+ primary: number;
86
+ secondary: number;
87
+ tertiary: number;
88
+ };
89
+ type Props$2 = {
90
+ value: string;
91
+ onChange: (color: string) => void;
92
+ harmony?: ColorHarmony;
93
+ onHarmonyChange?: (harmony: ColorHarmony) => void;
94
+ weights?: PaletteWeights;
95
+ colors?: SeedColor[];
96
+ blur?: boolean;
97
+ };
98
+ declare const PalettePicker: ({ value, onChange, harmony, onHarmonyChange, weights, colors, blur: blurProp }: Props$2) => react.JSX.Element;
99
+
100
+ type Props$1 = {
101
+ weights?: PaletteWeights;
102
+ colors?: SeedColor[];
103
+ blur?: boolean;
104
+ };
105
+ declare const AutoPalettePicker: (props: Props$1) => react.JSX.Element;
64
106
 
65
107
  interface ExpoBlurModule {
66
108
  BlurView: ComponentType<{
@@ -114,19 +156,6 @@ type ChipProps = ChipProps$1 & {
114
156
  };
115
157
  declare function Chip({ variant, style, selectedColor, ...props }: ChipProps): react.JSX.Element;
116
158
 
117
- type SeedColor = {
118
- label: string;
119
- value: string;
120
- };
121
- declare const defaultColors: SeedColor[];
122
- type Props$2 = {
123
- value: string;
124
- onChange: (color: string) => void;
125
- colors?: SeedColor[];
126
- blur?: boolean;
127
- };
128
- declare const ColorPicker: ({ value, onChange, colors, blur: blurProp }: Props$2) => react.JSX.Element;
129
-
130
159
  interface ReanimatedModule {
131
160
  View: ComponentType<{
132
161
  children?: ReactNode;
@@ -150,7 +179,7 @@ declare const Dialog: typeof DialogComponent;
150
179
 
151
180
  declare function FAB(props: FABProps): react.JSX.Element;
152
181
 
153
- type Props$1 = {
182
+ type Props = {
154
183
  value: ColorHarmony;
155
184
  onChange: (harmony: ColorHarmony) => void;
156
185
  showLabels?: boolean;
@@ -159,7 +188,7 @@ type Props$1 = {
159
188
  checkedContainerColor?: string;
160
189
  uncheckedContainerColor?: string;
161
190
  };
162
- declare const HarmonyPicker: ({ value, onChange, showLabels, checkedColor, uncheckedColor, checkedContainerColor, uncheckedContainerColor }: Props$1) => react.JSX.Element;
191
+ declare const HarmonyPicker: ({ value, onChange, showLabels, checkedColor, uncheckedColor, checkedContainerColor, uncheckedContainerColor }: Props) => react.JSX.Element;
163
192
 
164
193
  type IconButtonProps = IconButtonProps$1 & {
165
194
  variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
@@ -173,22 +202,6 @@ declare const Menu: (({ blur: blurProp, children, ...props }: MenuProps) => reac
173
202
  Item: react__default.FC<MenuItemProps>;
174
203
  };
175
204
 
176
- type PaletteWeights = {
177
- primary: number;
178
- secondary: number;
179
- tertiary: number;
180
- };
181
- type Props = {
182
- value: string;
183
- onChange: (color: string) => void;
184
- harmony?: ColorHarmony;
185
- onHarmonyChange?: (harmony: ColorHarmony) => void;
186
- weights?: PaletteWeights;
187
- colors?: SeedColor[];
188
- blur?: boolean;
189
- };
190
- declare const PalettePicker: ({ value, onChange, harmony, onHarmonyChange, weights, colors, blur: blurProp }: Props) => react.JSX.Element;
191
-
192
205
  declare const TextInput: react.ForwardRefExoticComponent<Omit<TextInputProps, "ref"> & react.RefAttributes<TextInput$1>>;
193
206
 
194
207
  interface ExpoNavigationBarModule {
@@ -339,4 +352,6 @@ declare const getTonalColor: (color: string, lightness: number) => string;
339
352
 
340
353
  declare const isDarkColor: (value: string) => boolean;
341
354
 
342
- export { Appbar, type AppearanceIcons, AppearancePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };
355
+ declare const resolveSeedColor: (color: string | TriadicPalette) => string;
356
+
357
+ export { Appbar, type AppearanceIcons, AppearancePicker, AutoAppearancePicker, AutoPalettePicker, type AutoPaperTheme, BlurView, type BlurViewProps, BottomNavigation, Button, Chip, type ChipProps, type ColorHarmony, ColorPicker, type ColorRoles, Dialog, type DialogProps, type ExpoBlurModule, type ExpoNavigationBarModule, FAB, HarmonyPicker, IconButton, type IconButtonProps, Menu, type MenuProps, PalettePicker, type PaletteWeights, type PaperDefaults, Provider, type ProviderProps, type RGB, type ReanimatedModule, SEMANTIC_BASE_COLORS, type SeedColor, type SemanticColorRoles, TextInput, type ThemeAppearance, type ThemeSettings, ThemeSettingsContext, type ThemeSettingsContextType, type ThemeState, type TriadicPalette, createThemeReducer, defaultColors, defaultThemeSettings, getBlendedColor, getColorRoles, getContrastColor, getHex, getRgb, getThirdColor, getTintTextColor, getTonalColor, getTriadicPalette, isDarkColor, resolveSeedColor, selectThemeAppearance, selectThemeBlur, selectThemeColor, selectThemeHarmony, themeActions, themeReducer, useAutoPaperTheme, useBlur, useBlurModule, useComputedTheme, useNavBarContext, usePaperDefaults, useReanimatedModule, useThemeSettings };