@fluentui-react-native/text 0.12.0 → 0.14.0

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 (103) hide show
  1. package/CHANGELOG.json +46 -1
  2. package/CHANGELOG.md +26 -2
  3. package/MIGRATION.md +98 -0
  4. package/README.md +5 -0
  5. package/SPEC.md +235 -0
  6. package/assets/Text_example_block_win32.png +0 -0
  7. package/assets/Text_example_customized_win32.png +0 -0
  8. package/assets/Text_example_inline_win32.png +0 -0
  9. package/assets/Text_example_pressable_win32.png +0 -0
  10. package/assets/Text_example_underlined_win32.png +0 -0
  11. package/assets/Text_example_variants_win32.png +0 -0
  12. package/lib/Text.d.ts +2 -3
  13. package/lib/Text.d.ts.map +1 -1
  14. package/lib/Text.js +79 -15
  15. package/lib/Text.js.map +1 -1
  16. package/lib/Text.types.d.ts +79 -13
  17. package/lib/Text.types.d.ts.map +1 -1
  18. package/lib/Text.types.js +1 -1
  19. package/lib/Text.types.js.map +1 -1
  20. package/lib/TextTokens.d.ts +3 -0
  21. package/lib/TextTokens.d.ts.map +1 -0
  22. package/lib/TextTokens.js +7 -0
  23. package/lib/TextTokens.js.map +1 -0
  24. package/lib/Variants.d.ts +14 -0
  25. package/lib/Variants.d.ts.map +1 -0
  26. package/lib/Variants.js +16 -0
  27. package/lib/Variants.js.map +1 -0
  28. package/lib/Variants.win32.d.ts +14 -0
  29. package/lib/Variants.win32.d.ts.map +1 -0
  30. package/lib/Variants.win32.js +41 -0
  31. package/lib/Variants.win32.js.map +1 -0
  32. package/lib/__tests__/Text.test.js +42 -40
  33. package/lib/__tests__/Text.test.js.map +1 -1
  34. package/lib/deprecated/Text.d.ts +5 -0
  35. package/lib/deprecated/Text.d.ts.map +1 -0
  36. package/lib/deprecated/Text.js +18 -0
  37. package/lib/deprecated/Text.js.map +1 -0
  38. package/lib/{Text.settings.d.ts → deprecated/Text.settings.d.ts} +0 -0
  39. package/lib/deprecated/Text.settings.d.ts.map +1 -0
  40. package/lib/{Text.settings.js → deprecated/Text.settings.js} +0 -0
  41. package/lib/deprecated/Text.settings.js.map +1 -0
  42. package/lib/deprecated/Text.types.d.ts +17 -0
  43. package/lib/deprecated/Text.types.d.ts.map +1 -0
  44. package/lib/deprecated/Text.types.js +2 -0
  45. package/lib/deprecated/Text.types.js.map +1 -0
  46. package/lib/index.d.ts +6 -3
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +5 -2
  49. package/lib/index.js.map +1 -1
  50. package/lib-commonjs/Text.d.ts +2 -3
  51. package/lib-commonjs/Text.d.ts.map +1 -1
  52. package/lib-commonjs/Text.js +82 -15
  53. package/lib-commonjs/Text.js.map +1 -1
  54. package/lib-commonjs/Text.types.d.ts +79 -13
  55. package/lib-commonjs/Text.types.d.ts.map +1 -1
  56. package/lib-commonjs/Text.types.js +1 -1
  57. package/lib-commonjs/Text.types.js.map +1 -1
  58. package/lib-commonjs/TextTokens.d.ts +3 -0
  59. package/lib-commonjs/TextTokens.d.ts.map +1 -0
  60. package/lib-commonjs/TextTokens.js +10 -0
  61. package/lib-commonjs/TextTokens.js.map +1 -0
  62. package/lib-commonjs/Variants.d.ts +14 -0
  63. package/lib-commonjs/Variants.d.ts.map +1 -0
  64. package/lib-commonjs/Variants.js +19 -0
  65. package/lib-commonjs/Variants.js.map +1 -0
  66. package/lib-commonjs/Variants.win32.d.ts +14 -0
  67. package/lib-commonjs/Variants.win32.d.ts.map +1 -0
  68. package/lib-commonjs/Variants.win32.js +44 -0
  69. package/lib-commonjs/Variants.win32.js.map +1 -0
  70. package/lib-commonjs/__tests__/Text.test.js +41 -39
  71. package/lib-commonjs/__tests__/Text.test.js.map +1 -1
  72. package/lib-commonjs/deprecated/Text.d.ts +5 -0
  73. package/lib-commonjs/deprecated/Text.d.ts.map +1 -0
  74. package/lib-commonjs/deprecated/Text.js +21 -0
  75. package/lib-commonjs/deprecated/Text.js.map +1 -0
  76. package/lib-commonjs/{Text.settings.d.ts → deprecated/Text.settings.d.ts} +0 -0
  77. package/lib-commonjs/deprecated/Text.settings.d.ts.map +1 -0
  78. package/lib-commonjs/{Text.settings.js → deprecated/Text.settings.js} +0 -0
  79. package/lib-commonjs/deprecated/Text.settings.js.map +1 -0
  80. package/lib-commonjs/deprecated/Text.types.d.ts +17 -0
  81. package/lib-commonjs/deprecated/Text.types.d.ts.map +1 -0
  82. package/lib-commonjs/deprecated/Text.types.js +5 -0
  83. package/lib-commonjs/deprecated/Text.types.js.map +1 -0
  84. package/lib-commonjs/index.d.ts +6 -3
  85. package/lib-commonjs/index.d.ts.map +1 -1
  86. package/lib-commonjs/index.js +21 -4
  87. package/lib-commonjs/index.js.map +1 -1
  88. package/package.json +6 -3
  89. package/src/Text.tsx +106 -16
  90. package/src/Text.types.ts +91 -15
  91. package/src/TextTokens.ts +10 -0
  92. package/src/Variants.ts +16 -0
  93. package/src/Variants.win32.ts +41 -0
  94. package/src/__tests__/Text.test.tsx +55 -60
  95. package/src/__tests__/__snapshots__/Text.test.tsx.snap +39 -4
  96. package/src/{Text.settings.ts → deprecated/Text.settings.ts} +0 -0
  97. package/src/deprecated/Text.tsx +19 -0
  98. package/src/deprecated/Text.types.ts +21 -0
  99. package/src/index.ts +22 -3
  100. package/lib/Text.settings.d.ts.map +0 -1
  101. package/lib/Text.settings.js.map +0 -1
  102. package/lib-commonjs/Text.settings.d.ts.map +0 -1
  103. package/lib-commonjs/Text.settings.js.map +0 -1
package/CHANGELOG.json CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui-react-native/text",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 14 Jul 2022 18:07:20 GMT",
5
+ "date": "Fri, 05 Aug 2022 23:21:34 GMT",
6
+ "tag": "@fluentui-react-native/text_v0.14.0",
7
+ "version": "0.14.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "email not defined",
12
+ "package": "@fluentui-react-native/text",
13
+ "commit": "4716cf81c971eed5f609a861c128dcfc4b2f0b46",
14
+ "comment": "Update out of date documentation (#1964)"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 29 Jul 2022 21:04:39 GMT",
21
+ "tag": "@fluentui-react-native/text_v0.13.0",
22
+ "version": "0.13.0",
23
+ "comments": {
24
+ "minor": [
25
+ {
26
+ "author": "email not defined",
27
+ "package": "@fluentui-react-native/text",
28
+ "commit": "bee467a2f783a35346bcb76687c200bd372a6086",
29
+ "comment": "move text from experimental to components dir"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Tue, 26 Jul 2022 19:30:23 GMT",
36
+ "tag": "@fluentui-react-native/text_v0.12.1",
37
+ "version": "0.12.1",
38
+ "comments": {
39
+ "patch": [
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui-react-native/text",
43
+ "comment": "Bump @uifabricshared/foundation-compose to v1.12.1",
44
+ "commit": "138a3ae19c80f405dd69525b808c627ef83ee0a0"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Thu, 14 Jul 2022 18:09:49 GMT",
6
51
  "tag": "@fluentui-react-native/text_v0.12.0",
7
52
  "version": "0.12.0",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,36 @@
1
1
  # Change Log - @fluentui-react-native/text
2
2
 
3
- This log was last generated on Thu, 14 Jul 2022 18:07:20 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 05 Aug 2022 23:21:34 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.14.0
8
+
9
+ Fri, 05 Aug 2022 23:21:34 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Update out of date documentation (#1964) (email not defined)
14
+
15
+ ## 0.13.0
16
+
17
+ Fri, 29 Jul 2022 21:04:39 GMT
18
+
19
+ ### Minor changes
20
+
21
+ - move text from experimental to components dir (email not defined)
22
+
23
+ ## 0.12.1
24
+
25
+ Tue, 26 Jul 2022 19:30:23 GMT
26
+
27
+ ### Patches
28
+
29
+ - Bump @uifabricshared/foundation-compose to v1.12.1
30
+
7
31
  ## 0.12.0
8
32
 
9
- Thu, 14 Jul 2022 18:07:20 GMT
33
+ Thu, 14 Jul 2022 18:09:49 GMT
10
34
 
11
35
  ### Minor changes
12
36
 
package/MIGRATION.md ADDED
@@ -0,0 +1,98 @@
1
+ # Text Migration
2
+
3
+ ## Migration from v0 Text
4
+
5
+ In the short term, the new `Text` control is named `TextV1` while it clashes with the existing older control. Once we deprecate the old control, it will be renamed to `Text`. It may be useful to rename the control to `Text` using the import syntax to simplify the rename:
6
+
7
+ ```ts
8
+ import { TextV1 as Text } from '@fluentui-react-native/text';
9
+ ```
10
+
11
+ ### Component renames
12
+
13
+ | v0 `Text` | v1 `Text` |
14
+ | --------------------------- | --------------------------- |
15
+ | `<Text>Hello, World</Text>` | `<Text>Hello, World</Text>` |
16
+
17
+ ### Props unchanged
18
+
19
+ - Any props that are part of `ViewProps` and `TextProps` from `react-native`
20
+ - `color`
21
+
22
+ ### Props changed
23
+
24
+ - `variant` => Prop name remains identical, but will support a different collection of named font variants. Newly defined v1 variants can be found in [Typography.types](../../theming/theme-types/src/Typography.types.ts) under theme-types.
25
+
26
+ ### Props added
27
+
28
+ - `align`
29
+ - `block`
30
+ - `font`
31
+ - `italic`
32
+ - `strikethrough`
33
+ - `size`
34
+ - `truncate`
35
+ - `underline`
36
+ - `weight`
37
+ - `wrap`
38
+
39
+ ### Props removed
40
+
41
+ - `disabled` is not supported in the v1 Text
42
+
43
+ ### Tokens unchanged
44
+
45
+ - Any props that are part of `FontTokens`, `IForegroundColorTokens`
46
+
47
+ ### Tokens changed
48
+
49
+ - Global font tokens have been editted according to design token redlines
50
+
51
+ | Token | Win32 |
52
+ | ----------- | ------------- |
53
+ | Family | |
54
+ | `Base` | `SegoeUI` |
55
+ | `Monospace` | `Consolas` |
56
+ | `Numeric` | `Bahnschrift` |
57
+ | Size | |
58
+ | `100` | `10px`/`14px` |
59
+ | `200` | `12px`/`16px` |
60
+ | `300` | `14px`/`20px` |
61
+ | `400` | `16px`/`22px` |
62
+ | `500` | `20px`/`26px` |
63
+ | `600` | `24px`/`32px` |
64
+ | `700` | `28px`/`36px` |
65
+ | `800` | `32px`/`40px` |
66
+ | `900` | `40px`/`52px` |
67
+ | `1000` | `68px`/`92px` |
68
+ | Weight | |
69
+ | `Regular` | `400` |
70
+ | `Medium` | `500` |
71
+ | `Semibold` | `600` |
72
+ | `Bold` | `700` |
73
+
74
+ ### Tokens not supported natively on win32
75
+
76
+ - `lineHeight`
77
+ - `letterSpacing`
78
+ - `textDecorationColor`
79
+ - `textShadowColor`
80
+ - `textShadowOffset`
81
+ - `textShadowRadius`
82
+ - `textTransform`
83
+
84
+ ### Updating ThemeProvider
85
+
86
+ If you are using the older theme provider `ThemeProvider` from `@uifabricshared/theming-react-native`, you will need to update the `ThemeProvider` to pull from `@fluentui-react-native/theme` to have the control work properly with themes. Please see [this page](../../../docs/pages/Guides/UpdateThemeProvider.md) for guidance.
87
+
88
+ ### Migrating customized Text
89
+
90
+ Please see [this page](../../../docs/pages/Guides/UpdatingCustomize.md) for guidance on how to move from the old `customize` API to the new one.
91
+
92
+ ### Other Prop differences
93
+
94
+ - `block` => On win32, instead of setting it as a boolean prop, block display is applied by default, and is overridden as inline when `<Text>` is wrapped by a parent `<Text>`.
95
+
96
+ ### Slot differences
97
+
98
+ There are no slot differences for FURN `Text`
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Text
2
+
3
+ A cross-platform Text component using the Fluent Design System.
4
+
5
+ Text V1 supported platforms: win32
package/SPEC.md ADDED
@@ -0,0 +1,235 @@
1
+ # Text
2
+
3
+ In the short term, the new `Text` control is named `TextV1` while it clashes with the existing older control. Once we deprecate the old control, it will be renamed to `Text`. It may be useful to rename the control to `Text` using the import syntax to simplify the rename:
4
+
5
+ ```ts
6
+ import { TextV1 as Text } from '@fluentui-react-native/text';
7
+ ```
8
+
9
+ FURN components that have imported from experimental-text now use the above syntax to use `TextV1`.
10
+
11
+ ## Background
12
+
13
+ The `Text` component is for displaying text, and supports nesting, styling, and touch handling.
14
+
15
+ ## Requirements
16
+
17
+ If using FURN's theming, the `Text` requires use of the `ThemeProvider` from `@fluentui-react-native/theme` to work properly with themes. Please see [this page](../../../docs/pages/Guides/UpdateThemeProvider.md) for information on updating your `ThemeProvider` if using the version from `@uifabricshared/theming-react-native`.
18
+
19
+ ## Sample Code
20
+
21
+ Basic example:
22
+
23
+ ```jsx
24
+ <Text>Hello World</Text>
25
+ ```
26
+ More examples on the [Test pages for Text](../../../apps/fluent-tester/src/TestComponents/TextExperimental). Instructions on running the tester app can be found [here](../../../apps/fluent-tester/README.md).
27
+
28
+ ## Visual Examples
29
+
30
+ Win32:
31
+
32
+ ![Underlined Text on win32 example](./assets/Text_example_underlined_win32.png)
33
+
34
+ ```jsx
35
+ <Text underline>This line has been underlined and striked through</Text>
36
+ ```
37
+
38
+ ![Block Text on win32 example](./assets/Text_example_block_win32.png)
39
+
40
+ ```jsx
41
+ <>
42
+ <Text>Every block of text gets its own line.</Text>
43
+ <Text>This is a new block</Text>
44
+ </>
45
+ ```
46
+
47
+ ![Inline Text on win32 example](./assets/Text_example_inline_win32.png)
48
+
49
+ ```jsx
50
+ <Text>
51
+ <Text>Text components inside a parent text component is inline text</Text>
52
+ <Text>This entire block is a RichLabel.</Text>
53
+ </Text>
54
+ ```
55
+
56
+ ![Customized Text on win32 example](./assets/Text_example_customized_win32.png)
57
+
58
+ ```jsx
59
+ const RedCaptionBold = Text.customize({ variant: 'captionStandard', fontWeight: '700', color: '#ff0000' });
60
+ <RedCaptionBold>RedCaptionBold</RedCaptionBold>
61
+ ```
62
+
63
+ ![Text Variants on win32 example](./assets/Text_example_variants_win32.png)
64
+ V1 `Text` component supports variant types that have preset font family, size, and weight values.
65
+
66
+ ```jsx
67
+ <Caption1>Caption1</Caption1>
68
+ <Body1>Body1</Body1>
69
+ <Body1Strong>Body1Strong</Body1Strong>
70
+ <Body2>Body2</Body2>
71
+ <Body2Strong>Body2Strong</Body2Strong>
72
+ <Subtitle2>Subtitle2</Subtitle2>
73
+ <Subtitle2Strong>Subtitle2Strong</Subtitle2Strong>
74
+ <Subtitle1>Subtitle1</Subtitle1>
75
+ <Subtitle1Strong>Subtitle1Strong</Subtitle1Strong>
76
+ <Title1>Title1</Title1>
77
+ <Title1Strong>Title1Strong</Title1Strong>
78
+ <LargeTitle>LargeTitle</LargeTitle>
79
+ <Display>Display</Display>
80
+ ```
81
+
82
+ ![Pressable Text on win32 example](./assets/Text_example_pressable_win32.png)
83
+
84
+ ```jsx
85
+ <Text variant={'bodyStandard'}>
86
+ Press{' '}
87
+ <Text
88
+ variant={'bodyStandard'}
89
+ color="blue"
90
+ keyDownEvents={handledNativeKeyboardEvents}
91
+ onPress={_onPress2}
92
+ onKeyDown={_onKeyDown2}
93
+ >
94
+ here
95
+ </Text>{' '}
96
+ to view an alert.
97
+ </Text>
98
+ ```
99
+
100
+ ## API
101
+
102
+ The `Text` control is rendered as a `react-native` Text(`RNText`). However, `RNText`and `Text` do not align in their set of props entirely.
103
+
104
+ ### Props
105
+
106
+ Below is the set of props the Text supports:
107
+
108
+ ```ts
109
+ export type TextProps<TBase = ITextProps> = TBase &
110
+ FontVariantTokens & {
111
+ /**
112
+ * foreground text color
113
+ */
114
+ color?: ColorValue;
115
+
116
+ /**
117
+ * Aligns text based on the parent container.
118
+ *
119
+ * @defaultValue start
120
+ */
121
+ align?: TextAlign;
122
+
123
+ /**
124
+ * Applies a block display for the content.
125
+ *
126
+ * @defaultValue false
127
+ */
128
+ block?: boolean;
129
+
130
+ /**
131
+ * Applies the font family to the content.
132
+ *
133
+ * @defaultValue base
134
+ */
135
+ font?: TextFont;
136
+
137
+ /**
138
+ * Applies the italic font style to the content.
139
+ *
140
+ * @defaultValue false
141
+ */
142
+ italic?: boolean;
143
+
144
+ /**
145
+ * Applies the strikethrough text decoration to the content.
146
+ *
147
+ * @defaultValue false
148
+ */
149
+ strikethrough?: boolean;
150
+
151
+ /**
152
+ * Applies font size and line height based on the theme tokens.
153
+ *
154
+ * @defaultValue 300
155
+ */
156
+ size?: TextSize;
157
+
158
+ /**
159
+ * Truncate overflowing text for block displays.
160
+ *
161
+ * @defaultValue false
162
+ */
163
+ truncate?: boolean;
164
+
165
+ /**
166
+ * Applies the underline text decoration to the content.
167
+ *
168
+ * @defaultValue false
169
+ */
170
+ underline?: boolean;
171
+
172
+ /**
173
+ * Applies font weight to the content.
174
+ *
175
+ * @defaultValue regular
176
+ */
177
+ weight?: TextWeight;
178
+
179
+ /**
180
+ * Wraps the text content on white spaces.
181
+ *
182
+ * @defaultValue true
183
+ */
184
+ wrap?: boolean;
185
+ };
186
+
187
+ 8/1/22 Notes:
188
+
189
+ - `block` => On win32, instead of setting it as a boolean prop, block display is applied by default, and is overridden as inline when `<Text>` is wrapped by a parent `<Text>`.
190
+
191
+ - `font` => According to design token redlines, `font` prop is given a giant string with a delimiter of font families for each enum type (`base`/`numeric`/`monospace`), We currently don't have a way to deal with this fontFamily format. We only support a single font family for each font type.
192
+ ```
193
+
194
+ ### Styling Tokens
195
+
196
+ Tokens can be used to customize the styling of the control by using the `customize` function on the `Text`. For more information on using the `customize` API, please see [this page](../../framework/composition/README.md). The `Text` has the following tokens:
197
+
198
+ ```ts
199
+ export type TextTokens = FontTokens & IForegroundColorTokens & TextStyle;
200
+ ```
201
+
202
+ ## Behaviors
203
+
204
+ ### Pressable Text
205
+
206
+ `Text` can be rendered as pressable.
207
+
208
+ ### Interaction
209
+
210
+ #### Keyboard interaction
211
+
212
+ The following is a set of keys that interact with the `Text` component:
213
+
214
+ | Key | Description |
215
+ | ------- | --------------------------------------------------------------- |
216
+ | `Tab` | If `onPress` or `focusable` is set, component will gain focus. |
217
+ | `Space` | Executes the function passed into the `onPress` prop. |
218
+
219
+ #### Cursor interaction for Pressable Text
220
+
221
+ - Cursor moves onto pressable text: Should immediately change the styling of the `Text` so that it appears to be hovered.
222
+ - Cursor moves out of pressable text: Should immediately remove the hovered styling of the `Text`.
223
+ - Mouse click: Should handle `onPress` event of `Text` and move focus to its target.
224
+
225
+ #### Touch interaction
226
+
227
+ The same behavior as above translated for touch events. This means that there is no equivalent for `onHoverIn` and `onHoverOut`, which makes it so that the hovered state cannot be accessed.
228
+
229
+ ## Accessibility
230
+
231
+ ### Expected behavior
232
+
233
+ - Should mix in the accessibility props expected for a `Text` component.
234
+ - Should be keyboard tabbable and focusable.
235
+ - onAccessibilityTap defaults to onPress unless set otherwise
package/lib/Text.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export declare const Text: import("@uifabricshared/foundation-compose").IComposeReturnType<import("./Text.types").ITextProps<import("@fluentui-react-native/adapters").ITextProps>, {
2
- root: import("@fluentui-react-native/adapters").ITextProps;
3
- }, import("@fluentui-react-native/tokens").FontStyleTokens & import("@fluentui-react-native/tokens").FontVariantTokens & import("@fluentui-react-native/tokens").IForegroundColorTokens & import("@fluentui-react-native/tokens").IBackgroundColorTokens, object, object>;
1
+ import { TextProps, TextTokens } from './Text.types';
2
+ export declare const Text: import("@fluentui-react-native/use-tokens").CustomizableComponent<TextProps<import("@fluentui-react-native/adapters").ITextProps>, TextTokens, import("@fluentui-react-native/framework").Theme>;
4
3
  export default Text;
5
4
  //# sourceMappingURL=Text.d.ts.map
package/lib/Text.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI;;yQASf,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/D,eAAO,MAAM,IAAI,kMAwFA,CAAC;AAGlB,eAAe,IAAI,CAAC"}
package/lib/Text.js CHANGED
@@ -1,18 +1,82 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
+ if (ar || !(i in from)) {
26
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
+ ar[i] = from[i];
28
+ }
29
+ }
30
+ return to.concat(ar || Array.prototype.slice.call(from));
31
+ };
32
+ /** @jsx withSlots */
33
+ import { fontStyles, withSlots, useFluentTheme, mergeStyles, compressible, patchTokens, } from '@fluentui-react-native/framework';
34
+ import { globalTokens } from '@fluentui-react-native/theme-tokens';
35
+ import { I18nManager, Platform, Text as RNText } from 'react-native';
1
36
  import { textName } from './Text.types';
2
- import { compose } from '@uifabricshared/foundation-compose';
3
- import { Text as RNText } from 'react-native';
4
- import { filterTextProps } from '@fluentui-react-native/adapters';
5
- import { foregroundColorTokens, textTokens } from '@fluentui-react-native/tokens';
6
- import { settings } from './Text.settings';
7
- export var Text = compose({
8
- displayName: textName,
9
- settings: settings,
10
- slots: {
11
- root: { slotType: RNText, filter: filterTextProps },
12
- },
13
- styles: {
14
- root: [textTokens, foregroundColorTokens],
15
- },
16
- });
37
+ import { useTextTokens } from './TextTokens';
38
+ import React from 'react';
39
+ export var Text = compressible(function (props, useTokens) {
40
+ var _a;
41
+ // split out color and variant from props
42
+ var align = props.align, block = props.block, color = props.color, font = props.font, italic = props.italic, onAccessibilityTap = props.onAccessibilityTap, onKeyDown = props.onKeyDown, onPress = props.onPress, size = props.size, strikethrough = props.strikethrough, style = props.style, _b = props.truncate, truncate = _b === void 0 ? false : _b, underline = props.underline, variant = props.variant, weight = props.weight, _c = props.wrap, wrap = _c === void 0 ? true : _c, rest = __rest(props, ["align", "block", "color", "font", "italic", "onAccessibilityTap", "onKeyDown", "onPress", "size", "strikethrough", "style", "truncate", "underline", "variant", "weight", "wrap"]);
43
+ var theme = useFluentTheme();
44
+ // get the tokens from the theme
45
+ var _d = useTokens(theme), tokens = _d[0], cache = _d[1];
46
+ var textAlign = I18nManager.isRTL
47
+ ? align === 'start'
48
+ ? 'right'
49
+ : align === 'end'
50
+ ? 'left'
51
+ : align
52
+ : align === 'start'
53
+ ? 'left'
54
+ : align === 'end'
55
+ ? 'right'
56
+ : align;
57
+ var onAccTap = React.useCallback(function (event) {
58
+ onAccessibilityTap ? onAccessibilityTap() : onPress(event);
59
+ }, [onPress, onAccessibilityTap]);
60
+ // override tokens from props
61
+ _a = patchTokens(tokens, cache, {
62
+ color: color,
63
+ variant: variant,
64
+ fontFamily: font == 'base' ? 'primary' : font,
65
+ fontSize: globalTokens.font.size[size],
66
+ fontWeight: globalTokens.font.weight[weight],
67
+ // leave it undefined for tokens to be set by user
68
+ fontStyle: italic ? 'italic' : undefined,
69
+ textAlign: textAlign,
70
+ textDecorationLine: underline && strikethrough ? 'underline line-through' : underline ? 'underline' : strikethrough ? 'line-through' : undefined,
71
+ }), tokens = _a[0], cache = _a[1];
72
+ // now build the text style from tokens that can be shared between different Text instances
73
+ var tokenStyle = cache(function () { return (__assign({ margin: 0, color: tokens.color, fontStyle: tokens.fontStyle, textAlign: tokens.textAlign, textDecorationLine: tokens.textDecorationLine }, fontStyles.from(tokens, theme))); }, __spreadArray(['color', 'fontStyle', 'textAlign', 'textDecorationLine'], fontStyles.keys, true))[0];
74
+ // return a continuation function that allows this text to be compressed
75
+ return function (extra, children) {
76
+ var mergedProps = __assign(__assign(__assign(__assign(__assign({ numberOfLines: truncate || !wrap ? 1 : 0, onKeyDown: Platform.OS === ('win32' || 'windows') ? onKeyDown : undefined }, (Platform.OS === ('win32' || 'windows') && { onAccessibilityTap: onAccTap })), { onPress: onPress }), rest), extra), { style: mergeStyles(tokenStyle, props.style, extra === null || extra === void 0 ? void 0 : extra.style) });
77
+ return (withSlots(RNText, __assign({ ellipsizeMode: !wrap && !truncate ? 'clip' : 'tail' }, mergedProps), children));
78
+ };
79
+ }, useTextTokens);
80
+ Text.displayName = textName;
17
81
  export default Text;
18
82
  //# sourceMappingURL=Text.js.map
package/lib/Text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,CAAC,IAAM,IAAI,GAAG,OAAO,CAAY;IACrC,WAAW,EAAE,QAAQ;IACrB,QAAQ,UAAA;IACR,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE;KACpD;IACD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC;KAC1C;CACF,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC"}
1
+ {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;AACJ,CAAC,EAAE,aAAa,CAAC,CAAC;AAClB,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE5B,eAAe,IAAI,CAAC"}
@@ -1,17 +1,83 @@
1
- import { FontTokens, FontVariantTokens, IForegroundColorTokens, IColorTokens } from '@fluentui-react-native/tokens';
2
- import { ITextProps as INativeTextProps } from '@fluentui-react-native/adapters';
3
- export declare const textName = "RNFText";
1
+ import { FontTokens, FontVariantTokens, IForegroundColorTokens } from '@fluentui-react-native/framework';
2
+ import { ITextProps } from '@fluentui-react-native/adapters';
3
+ import { ColorValue, TextStyle } from 'react-native';
4
+ export declare const textName = "Text";
4
5
  /**
5
- * Properties for fabric native text field, these extend the default props for text
6
+ * Text tokens, these are the internally configurable values for Text elements. In particular these
7
+ * drive decisions on how to build the styles
6
8
  */
7
- export declare type ITextProps<TBase = INativeTextProps> = TBase & FontVariantTokens & IForegroundColorTokens & {
8
- disabled?: boolean;
9
- };
10
- export declare type ITextType<TBase = INativeTextProps> = {
11
- props: ITextProps<TBase>;
12
- tokens: FontTokens & IColorTokens;
13
- slotProps: {
14
- root: TBase;
15
- };
9
+ export declare type TextTokens = Omit<FontTokens, 'fontFamily'> & IForegroundColorTokens & Omit<TextStyle, 'fontSize' | 'fontWeight' | 'color'>;
10
+ export declare type TextAlign = 'start' | 'center' | 'end' | 'justify';
11
+ export declare type TextFont = 'base' | 'monospace' | 'numeric';
12
+ export declare type TextSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000;
13
+ export declare type TextWeight = 'regular' | 'medium' | 'semibold' | 'bold';
14
+ /**
15
+ * Text props, based off of the standard react-native TextProps with some new extensions
16
+ */
17
+ export declare type TextProps<TBase = ITextProps> = TBase & FontVariantTokens & {
18
+ /**
19
+ * foreground text color
20
+ */
21
+ color?: ColorValue;
22
+ /**
23
+ * Aligns text based on the parent container.
24
+ *
25
+ * @defaultValue start
26
+ */
27
+ align?: TextAlign;
28
+ /**
29
+ * Applies a block display for the content.
30
+ *
31
+ * @defaultValue false
32
+ */
33
+ block?: boolean;
34
+ /**
35
+ * Applies the font family to the content.
36
+ *
37
+ * @defaultValue base
38
+ */
39
+ font?: TextFont;
40
+ /**
41
+ * Applies the italic font style to the content.
42
+ *
43
+ * @defaultValue false
44
+ */
45
+ italic?: boolean;
46
+ /**
47
+ * Applies the strikethrough text decoration to the content.
48
+ *
49
+ * @defaultValue false
50
+ */
51
+ strikethrough?: boolean;
52
+ /**
53
+ * Applies font size and line height based on the theme tokens.
54
+ *
55
+ * @defaultValue 300
56
+ */
57
+ size?: TextSize;
58
+ /**
59
+ * Truncate overflowing text for block displays.
60
+ *
61
+ * @defaultValue false
62
+ */
63
+ truncate?: boolean;
64
+ /**
65
+ * Applies the underline text decoration to the content.
66
+ *
67
+ * @defaultValue false
68
+ */
69
+ underline?: boolean;
70
+ /**
71
+ * Applies font weight to the content.
72
+ *
73
+ * @defaultValue regular
74
+ */
75
+ weight?: TextWeight;
76
+ /**
77
+ * Wraps the text content on white spaces.
78
+ *
79
+ * @defaultValue true
80
+ */
81
+ wrap?: boolean;
16
82
  };
17
83
  //# sourceMappingURL=Text.types.d.ts.map