@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.
- package/CHANGELOG.md +69 -1
- package/SPEC.md +1 -1
- package/lib/Text.d.ts +1 -1
- package/lib/Text.d.ts.map +1 -1
- package/lib/Text.js +10 -10
- package/lib/Text.js.map +1 -1
- package/lib/Variants.android.d.ts +12 -12
- package/lib/Variants.android.d.ts.map +1 -1
- package/lib/Variants.d.ts +17 -17
- package/lib/Variants.d.ts.map +1 -1
- package/lib/Variants.ios.d.ts +12 -12
- package/lib/Variants.ios.d.ts.map +1 -1
- package/lib/Variants.win32.d.ts +13 -13
- package/lib/Variants.win32.d.ts.map +1 -1
- package/lib/Variants.windows.d.ts +13 -13
- package/lib/Variants.windows.d.ts.map +1 -1
- package/lib/__tests__/Text.test.js +22 -9
- package/lib/__tests__/Text.test.js.map +1 -1
- package/lib-commonjs/Text.d.ts +1 -1
- package/lib-commonjs/Text.d.ts.map +1 -1
- package/lib-commonjs/Text.js +9 -9
- package/lib-commonjs/Text.js.map +1 -1
- package/lib-commonjs/Variants.android.d.ts +12 -12
- package/lib-commonjs/Variants.android.d.ts.map +1 -1
- package/lib-commonjs/Variants.d.ts +17 -17
- package/lib-commonjs/Variants.d.ts.map +1 -1
- package/lib-commonjs/Variants.ios.d.ts +12 -12
- package/lib-commonjs/Variants.ios.d.ts.map +1 -1
- package/lib-commonjs/Variants.win32.d.ts +13 -13
- package/lib-commonjs/Variants.win32.d.ts.map +1 -1
- package/lib-commonjs/Variants.windows.d.ts +13 -13
- package/lib-commonjs/Variants.windows.d.ts.map +1 -1
- package/lib-commonjs/__tests__/Text.test.js +39 -16
- package/lib-commonjs/__tests__/Text.test.js.map +1 -1
- package/lib-commonjs/deprecated/Text.js.map +1 -1
- package/lib-commonjs/index.js +5 -5
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +64 -62
- package/src/Text.tsx +14 -15
- package/src/__tests__/Text.test.tsx +25 -13
package/src/Text.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/** @
|
|
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,
|
|
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
|
-
|
|
55
|
-
|
|
53
|
+
? 'left'
|
|
54
|
+
: align
|
|
56
55
|
: align === 'start'
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
119
|
+
const isWin32Platform = Platform.OS === ('win32' as any);
|
|
121
120
|
const filteredProps = {
|
|
122
|
-
onKeyUp:
|
|
123
|
-
keyUpEvents:
|
|
121
|
+
onKeyUp: isWin32Platform ? onKeyUp : undefined,
|
|
122
|
+
keyUpEvents: isWin32Platform ? keyUpEvents : undefined,
|
|
124
123
|
validKeysUp: undefined,
|
|
125
|
-
onKeyDown:
|
|
126
|
-
keyDownEvents:
|
|
124
|
+
onKeyDown: isWin32Platform ? onKeyDown : undefined,
|
|
125
|
+
keyDownEvents: isWin32Platform ? keyDownEvents : undefined,
|
|
127
126
|
validKeysDown: undefined,
|
|
128
|
-
onAccessibilityTap:
|
|
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
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
});
|