@fluentui-react-native/apple-theme 0.29.8 → 0.29.11

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.
Files changed (47) hide show
  1. package/.cache/tsconfig.tsbuildinfo +1 -1
  2. package/CHANGELOG.md +36 -0
  3. package/lib/appleColors.ios.d.ts +2 -2
  4. package/lib/appleColors.ios.d.ts.map +1 -1
  5. package/lib/appleColors.ios.js +1 -8
  6. package/lib/appleColors.ios.js.map +1 -1
  7. package/lib/appleColors.macos.d.ts +1 -1
  8. package/lib/appleColors.macos.d.ts.map +1 -1
  9. package/lib/appleColors.macos.js +2 -3
  10. package/lib/appleColors.macos.js.map +1 -1
  11. package/lib/appleShadows.ios.d.ts +2 -2
  12. package/lib/appleShadows.ios.d.ts.map +1 -1
  13. package/lib/appleShadows.ios.js +1 -5
  14. package/lib/appleShadows.ios.js.map +1 -1
  15. package/lib/appleShadows.macos.d.ts +1 -1
  16. package/lib/appleShadows.macos.d.ts.map +1 -1
  17. package/lib/appleShadows.macos.js +2 -3
  18. package/lib/appleShadows.macos.js.map +1 -1
  19. package/lib/appleTheme.ios.d.ts.map +1 -1
  20. package/lib/appleTheme.ios.js +3 -2
  21. package/lib/appleTheme.ios.js.map +1 -1
  22. package/lib/appleTheme.macos.js +3 -3
  23. package/lib/appleTheme.macos.js.map +1 -1
  24. package/lib/createAppleTheme.ios.d.ts.map +1 -1
  25. package/lib/createAppleTheme.ios.js +29 -12
  26. package/lib/createAppleTheme.ios.js.map +1 -1
  27. package/lib/createAppleTheme.macos.d.ts.map +1 -1
  28. package/lib/createAppleTheme.macos.js +15 -23
  29. package/lib/createAppleTheme.macos.js.map +1 -1
  30. package/lib/createFontAliasTokens.ios.js +1 -1
  31. package/lib/createFontAliasTokens.ios.js.map +1 -1
  32. package/lib/createMacOSAliasTokens.js +1 -1
  33. package/lib/createMacOSAliasTokens.js.map +1 -1
  34. package/lib/createiOSAliasTokens.js +2 -2
  35. package/lib/createiOSAliasTokens.js.map +1 -1
  36. package/package.json +5 -7
  37. package/src/appleColors.ios.ts +2 -11
  38. package/src/appleColors.macos.ts +2 -3
  39. package/src/appleShadows.ios.ts +2 -7
  40. package/src/appleShadows.macos.ts +2 -3
  41. package/src/appleTheme.ios.ts +3 -2
  42. package/src/appleTheme.macos.ts +3 -3
  43. package/src/createAppleTheme.ios.ts +33 -16
  44. package/src/createAppleTheme.macos.ts +15 -26
  45. package/src/createFontAliasTokens.ios.ts +1 -1
  46. package/src/createMacOSAliasTokens.ts +1 -1
  47. package/src/createiOSAliasTokens.ts +2 -2
@@ -130,10 +130,11 @@ const appleComponents = {
130
130
  };
131
131
 
132
132
  function getBaseAppleThemeIOSWorker(isLightMode: boolean, isElevated: boolean): Theme {
133
+ const mode = isLightMode ? 'light' : isElevated ? 'darkElevated' : 'dark';
133
134
  return {
134
- colors: paletteFromAppleColors(isLightMode, isElevated),
135
+ colors: paletteFromAppleColors(isLightMode, mode),
135
136
  typography: appleTypography(),
136
- shadows: iOSShadows(),
137
+ shadows: iOSShadows(mode),
137
138
  spacing: appleSpacing(),
138
139
  components: appleComponents,
139
140
  host: { appearance: isLightMode ? 'light' : 'dark' },
@@ -73,11 +73,11 @@ export const appleComponents = {
73
73
  },
74
74
  };
75
75
 
76
- function getBaseAppleThemeMacOSWorker(mode: AppearanceOptions): Theme {
76
+ function getBaseAppleThemeMacOSWorker(mode: AppearanceOptions, highContrast: boolean): Theme {
77
77
  return {
78
- colors: fallbackApplePalette(mode),
78
+ colors: fallbackApplePalette(mode, highContrast),
79
79
  typography: fallbackAppleTypography(),
80
- shadows: fallbackAppleShadows(mode),
80
+ shadows: fallbackAppleShadows(mode, highContrast),
81
81
  spacing: appleSpacing(),
82
82
  components: appleComponents,
83
83
  host: { appearance: 'dynamic' },
@@ -1,26 +1,43 @@
1
1
  import { Appearance, NativeEventEmitter } from 'react-native';
2
2
 
3
3
  import { NativeAppearanceAdditions } from '@fluentui-react-native/experimental-appearance-additions';
4
- import { ThemeReference } from '@fluentui-react-native/design/theming';
4
+ import { createThemeAppearanceSource, ThemeReference } from '@fluentui-react-native/design/theming';
5
5
  import type { Theme } from '@fluentui-react-native/design/theming';
6
6
 
7
7
  import { getBaseAppleThemeIOS } from './appleTheme.ios';
8
8
 
9
9
  export function createAppleTheme(): ThemeReference {
10
- const appleThemeReference = new ThemeReference({} as Theme, () => {
11
- const isLightMode = Appearance.getColorScheme() === 'light';
12
- const isElevated = NativeAppearanceAdditions.userInterfaceLevel() === 'elevated';
13
- return getBaseAppleThemeIOS(isLightMode, isElevated);
10
+ const appearanceSource = createThemeAppearanceSource(
11
+ () => ({
12
+ colorScheme: Appearance.getColorScheme(),
13
+ interfaceLevel: NativeAppearanceAdditions.userInterfaceLevel() === 'elevated' ? 'elevated' : 'base',
14
+ }),
15
+ (listener) => {
16
+ const appearanceSubscription = Appearance.addChangeListener(listener);
17
+ const eventEmitter = new NativeEventEmitter(NativeAppearanceAdditions);
18
+ const interfaceLevelSubscription = eventEmitter.addListener('appearanceChanged', listener);
19
+ return () => {
20
+ appearanceSubscription.remove();
21
+ interfaceLevelSubscription.remove();
22
+ };
23
+ },
24
+ );
25
+ return new ThemeReference({
26
+ base: {} as Theme,
27
+ appearance: {
28
+ colorScheme: 'system',
29
+ contrast: 'system',
30
+ interfaceLevel: 'system',
31
+ },
32
+ appearanceSource,
33
+ recipes: [
34
+ (_theme, appearance) => {
35
+ const isLightMode = appearance ? appearance.colorScheme === 'light' : Appearance.getColorScheme() === 'light';
36
+ const isElevated = appearance
37
+ ? appearance.interfaceLevel === 'elevated'
38
+ : NativeAppearanceAdditions.userInterfaceLevel() === 'elevated';
39
+ return getBaseAppleThemeIOS(isLightMode, isElevated);
40
+ },
41
+ ],
14
42
  });
15
-
16
- Appearance.addChangeListener(() => {
17
- appleThemeReference.invalidate();
18
- });
19
-
20
- const eventEmitter = new NativeEventEmitter(NativeAppearanceAdditions);
21
- eventEmitter.addListener('appearanceChanged', (_newTraits) => {
22
- appleThemeReference.invalidate();
23
- });
24
-
25
- return appleThemeReference;
26
43
  }
@@ -1,35 +1,24 @@
1
1
  import { Appearance } from 'react-native';
2
2
 
3
- import { getCurrentAppearance, setIsHighContrast, ThemeReference } from '@fluentui-react-native/design/theming';
3
+ import { getCurrentAppearance, isHighContrast, ThemeReference } from '@fluentui-react-native/design/theming';
4
4
  import type { Theme } from '@fluentui-react-native/design/theming';
5
- import { AccessibilityInfo } from 'react-native-macos';
6
5
 
7
6
  import { getBaseAppleThemeMacOS } from './appleTheme.macos';
8
7
 
9
- let appleThemeReference: ThemeReference;
10
-
11
8
  export function createAppleTheme(): ThemeReference {
12
- appleThemeReference = new ThemeReference({} as Theme, () => {
13
- const appearance = Appearance.getColorScheme();
14
- const mode = getCurrentAppearance(appearance, 'light');
15
- return getBaseAppleThemeMacOS(mode);
16
- });
17
- // Fetch initial system settings for high contrast mode
18
- highContrastHandler();
19
- // Invalidate theme and set prop when high contrast setting changes
20
- AccessibilityInfo.addEventListener('highContrastChanged', () => {
21
- highContrastHandler();
22
- });
23
-
24
- Appearance.addChangeListener(() => {
25
- appleThemeReference.invalidate();
26
- });
27
- return appleThemeReference;
28
- }
29
-
30
- function highContrastHandler() {
31
- AccessibilityInfo.isHighContrastEnabled().then((isEnabled) => {
32
- setIsHighContrast(isEnabled);
33
- appleThemeReference.invalidate();
9
+ return new ThemeReference({
10
+ base: {} as Theme,
11
+ appearance: {
12
+ colorScheme: 'system',
13
+ contrast: 'system',
14
+ interfaceLevel: 'base',
15
+ },
16
+ recipes: [
17
+ (_theme, appearance) => {
18
+ const mode = appearance?.colorScheme ?? getCurrentAppearance(Appearance.getColorScheme(), 'light');
19
+ const highContrast = appearance ? appearance.contrast === 'highContrast' : isHighContrast();
20
+ return getBaseAppleThemeMacOS(mode, highContrast);
21
+ },
22
+ ],
34
23
  });
35
24
  }
@@ -1,7 +1,7 @@
1
1
  import aliasTokens from '@fluentui-react-native/design-tokens-ios/light/tokens-aliases.json'; // Font alias tokens should be the same for all color styles
2
2
  import { memoize } from '@fluentui-react-native/framework-base';
3
3
  import type { Variants } from '@fluentui-react-native/design/theming';
4
- import { mapFontPipelineToTheme } from '@fluentui-react-native/theming-utils';
4
+ import { mapFontPipelineToTheme } from '@fluentui-react-native/design/theming';
5
5
 
6
6
  function createFontAliasTokensWorker(): Partial<Variants> {
7
7
  return mapFontPipelineToTheme(aliasTokens);
@@ -1,7 +1,7 @@
1
1
  import { memoize } from '@fluentui-react-native/framework-base';
2
2
  import type { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/design/theming';
3
3
  import type { ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
4
- import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/theming-utils';
4
+ import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/design/theming';
5
5
 
6
6
  import { getMacOSAliasTokens, getMacOSShadowTokens } from './getMacOSTokens';
7
7
 
@@ -1,8 +1,8 @@
1
1
  import { memoize } from '@fluentui-react-native/framework-base';
2
- import { getAliasTokens, getShadowTokens } from '@fluentui-react-native/theme-tokens';
2
+ import { getAliasTokens, getShadowTokens } from '@fluentui-react-native/design/tokens/legacy';
3
3
  import type { AliasColorTokens, AppearanceOptions } from '@fluentui-react-native/design/theming';
4
4
  import type { ThemeShadowDefinition } from '@fluentui-react-native/design/theming';
5
- import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/theming-utils';
5
+ import { mapPipelineToTheme, mapPipelineToShadow } from '@fluentui-react-native/design/theming';
6
6
 
7
7
  function createiOSColorAliasTokensWorker(mode: AppearanceOptions): AliasColorTokens {
8
8
  const aliasTokens = getAliasTokens(mode);