@fluentui-react-native/text 0.24.21 → 0.25.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/SPEC.md +1 -1
  3. package/lib/Text.d.ts +1 -1
  4. package/lib/Text.d.ts.map +1 -1
  5. package/lib/Text.js +10 -10
  6. package/lib/Text.js.map +1 -1
  7. package/lib/Variants.android.d.ts +12 -12
  8. package/lib/Variants.android.d.ts.map +1 -1
  9. package/lib/Variants.d.ts +17 -17
  10. package/lib/Variants.d.ts.map +1 -1
  11. package/lib/Variants.ios.d.ts +12 -12
  12. package/lib/Variants.ios.d.ts.map +1 -1
  13. package/lib/Variants.win32.d.ts +13 -13
  14. package/lib/Variants.win32.d.ts.map +1 -1
  15. package/lib/Variants.windows.d.ts +13 -13
  16. package/lib/Variants.windows.d.ts.map +1 -1
  17. package/lib/__tests__/Text.test.js +22 -9
  18. package/lib/__tests__/Text.test.js.map +1 -1
  19. package/lib-commonjs/Text.d.ts +1 -1
  20. package/lib-commonjs/Text.d.ts.map +1 -1
  21. package/lib-commonjs/Text.js +9 -9
  22. package/lib-commonjs/Text.js.map +1 -1
  23. package/lib-commonjs/Variants.android.d.ts +12 -12
  24. package/lib-commonjs/Variants.android.d.ts.map +1 -1
  25. package/lib-commonjs/Variants.d.ts +17 -17
  26. package/lib-commonjs/Variants.d.ts.map +1 -1
  27. package/lib-commonjs/Variants.ios.d.ts +12 -12
  28. package/lib-commonjs/Variants.ios.d.ts.map +1 -1
  29. package/lib-commonjs/Variants.win32.d.ts +13 -13
  30. package/lib-commonjs/Variants.win32.d.ts.map +1 -1
  31. package/lib-commonjs/Variants.windows.d.ts +13 -13
  32. package/lib-commonjs/Variants.windows.d.ts.map +1 -1
  33. package/lib-commonjs/__tests__/Text.test.js +39 -16
  34. package/lib-commonjs/__tests__/Text.test.js.map +1 -1
  35. package/lib-commonjs/deprecated/Text.js.map +1 -1
  36. package/lib-commonjs/index.js +5 -5
  37. package/lib-commonjs/index.js.map +1 -1
  38. package/package.json +64 -62
  39. package/src/Text.tsx +14 -15
  40. package/src/__tests__/Text.test.tsx +25 -13
package/src/Text.tsx CHANGED
@@ -1,10 +1,9 @@
1
- /** @jsxRuntime classic */
2
- /** @jsx withSlots */
1
+ /** @jsxImportSource @fluentui-react-native/framework-base */
3
2
  import React from 'react';
4
3
  import { I18nManager, Platform, Text as RNText } from 'react-native';
5
4
 
6
5
  import type { UseTokens, FontWeightValue } from '@fluentui-react-native/framework';
7
- import { fontStyles, withSlots, useFluentTheme, mergeStyles, compressible, patchTokens } from '@fluentui-react-native/framework';
6
+ import { fontStyles, useFluentTheme, mergeStyles, compressible, patchTokens } from '@fluentui-react-native/framework';
8
7
  import { useKeyProps } from '@fluentui-react-native/interactive-hooks';
9
8
  import { globalTokens } from '@fluentui-react-native/theme-tokens';
10
9
 
@@ -51,13 +50,13 @@ export const Text = compressible<TextProps, TextTokens>((props: TextProps, useTo
51
50
  ? align === 'start'
52
51
  ? 'right'
53
52
  : align === 'end'
54
- ? 'left'
55
- : align
53
+ ? 'left'
54
+ : align
56
55
  : align === 'start'
57
- ? 'left'
58
- : align === 'end'
59
- ? 'right'
60
- : align;
56
+ ? 'left'
57
+ : align === 'end'
58
+ ? 'right'
59
+ : align;
61
60
 
62
61
  const textOnPress = React.useCallback(
63
62
  (e) => {
@@ -117,15 +116,15 @@ export const Text = compressible<TextProps, TextTokens>((props: TextProps, useTo
117
116
  };
118
117
  }
119
118
 
120
- const isWinPlatform = Platform.OS === (('win32' as any) || 'windows');
119
+ const isWin32Platform = Platform.OS === ('win32' as any);
121
120
  const filteredProps = {
122
- onKeyUp: isWinPlatform ? onKeyUp : undefined,
123
- keyUpEvents: isWinPlatform ? keyUpEvents : undefined,
121
+ onKeyUp: isWin32Platform ? onKeyUp : undefined,
122
+ keyUpEvents: isWin32Platform ? keyUpEvents : undefined,
124
123
  validKeysUp: undefined,
125
- onKeyDown: isWinPlatform ? onKeyDown : undefined,
126
- keyDownEvents: isWinPlatform ? keyDownEvents : undefined,
124
+ onKeyDown: isWin32Platform ? onKeyDown : undefined,
125
+ keyDownEvents: isWin32Platform ? keyDownEvents : undefined,
127
126
  validKeysDown: undefined,
128
- onAccessibilityTap: isWinPlatform ? onAccTap : undefined,
127
+ onAccessibilityTap: isWin32Platform ? onAccTap : undefined,
129
128
  };
130
129
 
131
130
  // return a continuation function that allows this text to be compressed
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { act } from 'react';
2
2
 
3
3
  import * as renderer from 'react-test-renderer';
4
4
 
@@ -6,13 +6,19 @@ import { Text } from '../Text';
6
6
 
7
7
  describe('Text component tests', () => {
8
8
  it('Text default', () => {
9
- const tree = renderer.create(<Text>Text default</Text>).toJSON();
10
- expect(tree).toMatchSnapshot();
9
+ let component: renderer.ReactTestRenderer;
10
+ act(() => {
11
+ component = renderer.create(<Text>Text default</Text>);
12
+ });
13
+ expect(component!.toJSON()).toMatchSnapshot();
11
14
  });
12
15
 
13
16
  it('Text all props', () => {
14
- const tree = renderer.create(<Text variant="bodyStandard">All props</Text>).toJSON();
15
- expect(tree).toMatchSnapshot();
17
+ let component: renderer.ReactTestRenderer;
18
+ act(() => {
19
+ component = renderer.create(<Text variant="bodyStandard">All props</Text>);
20
+ });
21
+ expect(component!.toJSON()).toMatchSnapshot();
16
22
  });
17
23
 
18
24
  it('Text all tokens', () => {
@@ -21,8 +27,11 @@ describe('Text component tests', () => {
21
27
  fontWeight: '900',
22
28
  fontSize: 20,
23
29
  });
24
- const tree = renderer.create(<BoldText>All tokens</BoldText>).toJSON();
25
- expect(tree).toMatchSnapshot();
30
+ let component: renderer.ReactTestRenderer;
31
+ act(() => {
32
+ component = renderer.create(<BoldText>All tokens</BoldText>);
33
+ });
34
+ expect(component!.toJSON()).toMatchSnapshot();
26
35
  });
27
36
 
28
37
  it('Text variants render correctly with style', () => {
@@ -30,11 +39,14 @@ describe('Text component tests', () => {
30
39
  marginBottom: 8,
31
40
  marginTop: 4,
32
41
  };
33
- const tree = renderer.create(
34
- <Text variant="heroLargeSemibold" color="blue" style={style}>
35
- Header Text
36
- </Text>,
37
- );
38
- expect(tree).toMatchSnapshot();
42
+ let component: renderer.ReactTestRenderer;
43
+ act(() => {
44
+ component = renderer.create(
45
+ <Text variant="heroLargeSemibold" color="blue" style={style}>
46
+ Header Text
47
+ </Text>,
48
+ );
49
+ });
50
+ expect(component!.toJSON()).toMatchSnapshot();
39
51
  });
40
52
  });