@fluentui-react-native/use-tokens 0.6.11 → 0.7.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 (74) hide show
  1. package/CHANGELOG.json +15 -0
  2. package/CHANGELOG.md +45 -1
  3. package/README.md +1 -1
  4. package/babel.config.js +1 -1
  5. package/lib/applyPropsToTokens.d.ts +7 -2
  6. package/lib/applyPropsToTokens.js +7 -7
  7. package/lib/applyPropsToTokens.js.map +1 -1
  8. package/lib/applyPropsToTokens.test.d.ts +1 -1
  9. package/lib/applyPropsToTokens.test.js +19 -19
  10. package/lib/applyPropsToTokens.test.js.map +1 -1
  11. package/lib/applyTokenLayers.d.ts +7 -2
  12. package/lib/applyTokenLayers.js +16 -13
  13. package/lib/applyTokenLayers.js.map +1 -1
  14. package/lib/applyTokenLayers.test.d.ts +1 -1
  15. package/lib/applyTokenLayers.test.js +42 -42
  16. package/lib/applyTokenLayers.test.js.map +1 -1
  17. package/lib/buildUseTokens.d.ts +6 -3
  18. package/lib/buildUseTokens.js +22 -22
  19. package/lib/buildUseTokens.js.map +1 -1
  20. package/lib/buildUseTokens.test.d.ts +1 -1
  21. package/lib/buildUseTokens.test.js +68 -68
  22. package/lib/buildUseTokens.test.js.map +1 -1
  23. package/lib/customizable.d.ts +9 -5
  24. package/lib/customizable.d.ts.map +1 -1
  25. package/lib/customizable.js +8 -8
  26. package/lib/customizable.js.map +1 -1
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.js +1 -1
  29. package/lib/patchTokens.d.ts +6 -2
  30. package/lib/patchTokens.js +12 -12
  31. package/lib/patchTokens.js.map +1 -1
  32. package/lib/patchTokens.test.d.ts +1 -1
  33. package/lib/patchTokens.test.js +32 -32
  34. package/lib/patchTokens.test.js.map +1 -1
  35. package/lib/useTokens.samples.test.d.ts +1 -1
  36. package/lib/useTokens.samples.test.js +134 -111
  37. package/lib/useTokens.samples.test.js.map +1 -1
  38. package/lib-commonjs/applyPropsToTokens.d.ts +7 -2
  39. package/lib-commonjs/applyPropsToTokens.js +10 -11
  40. package/lib-commonjs/applyPropsToTokens.js.map +1 -1
  41. package/lib-commonjs/applyPropsToTokens.test.d.ts +1 -1
  42. package/lib-commonjs/applyPropsToTokens.test.js +23 -23
  43. package/lib-commonjs/applyPropsToTokens.test.js.map +1 -1
  44. package/lib-commonjs/applyTokenLayers.d.ts +7 -2
  45. package/lib-commonjs/applyTokenLayers.js +20 -18
  46. package/lib-commonjs/applyTokenLayers.js.map +1 -1
  47. package/lib-commonjs/applyTokenLayers.test.d.ts +1 -1
  48. package/lib-commonjs/applyTokenLayers.test.js +46 -46
  49. package/lib-commonjs/applyTokenLayers.test.js.map +1 -1
  50. package/lib-commonjs/buildUseTokens.d.ts +6 -3
  51. package/lib-commonjs/buildUseTokens.js +30 -28
  52. package/lib-commonjs/buildUseTokens.js.map +1 -1
  53. package/lib-commonjs/buildUseTokens.test.d.ts +1 -1
  54. package/lib-commonjs/buildUseTokens.test.js +71 -71
  55. package/lib-commonjs/buildUseTokens.test.js.map +1 -1
  56. package/lib-commonjs/customizable.d.ts +9 -5
  57. package/lib-commonjs/customizable.d.ts.map +1 -1
  58. package/lib-commonjs/customizable.js +11 -12
  59. package/lib-commonjs/customizable.js.map +1 -1
  60. package/lib-commonjs/index.d.ts +1 -1
  61. package/lib-commonjs/index.js +38 -13
  62. package/lib-commonjs/index.js.map +1 -1
  63. package/lib-commonjs/patchTokens.d.ts +6 -2
  64. package/lib-commonjs/patchTokens.js +15 -16
  65. package/lib-commonjs/patchTokens.js.map +1 -1
  66. package/lib-commonjs/patchTokens.test.d.ts +1 -1
  67. package/lib-commonjs/patchTokens.test.js +36 -36
  68. package/lib-commonjs/patchTokens.test.js.map +1 -1
  69. package/lib-commonjs/useTokens.samples.test.d.ts +1 -1
  70. package/lib-commonjs/useTokens.samples.test.js +195 -119
  71. package/lib-commonjs/useTokens.samples.test.js.map +1 -1
  72. package/package.json +49 -43
  73. package/src/customizable.ts +3 -2
  74. package/src/useTokens.samples.test.tsx +24 -15
package/package.json CHANGED
@@ -1,77 +1,83 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/use-tokens",
3
- "version": "0.6.11",
3
+ "version": "0.7.0",
4
4
  "description": "Utilities and hook function for getting themed tokens for a component",
5
+ "keywords": [],
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/microsoft/fluentui-react-native",
8
9
  "directory": "packages/framework/use-tokens"
9
10
  },
10
- "main": "lib-commonjs/index.js",
11
- "module": "lib/index.js",
12
- "react-native": "src/index.ts",
11
+ "license": "MIT",
12
+ "author": "",
13
13
  "exports": {
14
14
  ".": {
15
+ "types": "./lib/index.d.ts",
15
16
  "import": "./lib/index.js",
16
- "require": "./lib-commonjs/index.js",
17
- "types": "./lib/index.d.ts"
17
+ "require": "./lib-commonjs/index.js"
18
18
  }
19
19
  },
20
- "typings": "lib/index.d.ts",
20
+ "main": "lib-commonjs/index.js",
21
+ "module": "lib/index.js",
22
+ "types": "lib/index.d.ts",
21
23
  "scripts": {
22
24
  "build": "fluentui-scripts build",
25
+ "build-cjs": "tsgo --outDir lib-commonjs",
26
+ "build-esm": "tsgo --outDir lib --module esnext --moduleResolution bundler",
23
27
  "clean": "fluentui-scripts clean",
24
28
  "depcheck": "fluentui-scripts depcheck",
25
- "just": "fluentui-scripts",
26
29
  "lint": "fluentui-scripts eslint",
30
+ "lint-package": "fluentui-scripts lint-package",
31
+ "prettier": "fluentui-scripts prettier",
27
32
  "start": "fluentui-scripts dev",
28
33
  "start-test": "fluentui-scripts jest-watch",
29
34
  "test": "fluentui-scripts jest",
30
- "update-snapshots": "fluentui-scripts jest -u",
31
- "prettier": "fluentui-scripts prettier",
32
- "prettier-fix": "fluentui-scripts prettier --fix true"
35
+ "update-snapshots": "fluentui-scripts jest -u"
33
36
  },
34
- "keywords": [],
35
- "author": "",
36
- "license": "MIT",
37
37
  "dependencies": {
38
- "@fluentui-react-native/framework-base": "0.2.0",
39
- "tslib": "^2.3.1"
38
+ "@fluentui-react-native/framework-base": "0.3.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@babel/core": "^7.20.0",
43
- "@fluentui-react-native/scripts": "0.1.1",
44
- "@react-native/babel-preset": "^0.74.0",
45
- "@react-native/metro-config": "^0.74.0",
42
+ "@fluentui-react-native/babel-config": "0.1.1",
43
+ "@fluentui-react-native/eslint-config-rules": "0.1.1",
44
+ "@fluentui-react-native/jest-config": "0.1.1",
45
+ "@fluentui-react-native/kit-config": "0.1.2",
46
+ "@fluentui-react-native/scripts": "0.1.2",
47
+ "@react-native-community/cli": "^20.0.0",
48
+ "@react-native-community/cli-platform-android": "^20.0.0",
49
+ "@react-native-community/cli-platform-ios": "^20.0.0",
50
+ "@react-native/babel-preset": "^0.81.0",
51
+ "@react-native/metro-config": "^0.81.0",
46
52
  "@types/jest": "^29.0.0",
47
- "react": "18.2.0",
48
- "react-native": "^0.74.0"
53
+ "@types/react": "~19.1.0",
54
+ "@types/react-test-renderer": "^19.1.0",
55
+ "react": "19.1.0",
56
+ "react-native": "^0.81.0",
57
+ "react-test-renderer": "19.1.0"
58
+ },
59
+ "peerDependencies": {
60
+ "@types/react": "~18.2.0 || ~19.0.0 || ~19.1.0",
61
+ "react": "18.2.0 || 19.0.0 || 19.1.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "@types/react": {
65
+ "optional": true
66
+ }
49
67
  },
50
68
  "rnx-kit": {
51
69
  "kitType": "library",
52
70
  "alignDeps": {
53
- "presets": [
54
- "microsoft/react-native"
55
- ],
56
- "requirements": {
57
- "development": [
58
- "react-native@0.74"
59
- ],
60
- "production": [
61
- "react-native@0.73 || 0.74"
62
- ]
63
- },
64
71
  "capabilities": [
65
- "babel-preset-react-native",
66
- "core",
67
- "core-android",
68
- "core-ios",
69
- "react"
72
+ "core-android-dev-only",
73
+ "core-dev-only",
74
+ "core-ios-dev-only",
75
+ "react",
76
+ "react-test-renderer",
77
+ "tools-core",
78
+ "tools-jest"
70
79
  ]
71
- }
72
- },
73
- "peerDependencies": {
74
- "react": "18.2.0",
75
- "react-native": "^0.73.0 || ^0.74.0"
80
+ },
81
+ "extends": "@fluentui-react-native/kit-config"
76
82
  }
77
- }
83
+ }
@@ -1,12 +1,13 @@
1
1
  import type React from 'react';
2
2
 
3
3
  import type { TokenSettings, UseTokens } from './buildUseTokens';
4
+ import type { FurnJSX } from '@fluentui-react-native/framework-base';
4
5
 
5
6
  /**
6
7
  * A component implementation, with a use tokens hook passed in. Implementing it this way allows the useTokens hook to be
7
8
  * modified by the customization handler
8
9
  */
9
- export type InjectableComponent<TProps, TTokens, TTheme> = (props: TProps, useTokens: UseTokens<TTokens, TTheme>) => JSX.Element | null;
10
+ export type InjectableComponent<TProps, TTokens, TTheme> = (props: TProps, useTokens: UseTokens<TTokens, TTheme>) => FurnJSX.Element | null;
10
11
 
11
12
  /**
12
13
  * A component with an attached customize function, used to create alternatively styled versions of the component
@@ -18,7 +19,7 @@ export type CustomizableComponent<TProps, TTokens, TTheme> = React.FunctionCompo
18
19
  /**
19
20
  * Function helper for easily creating a customizable component based on the useTokens hook
20
21
  *
21
- * @param injectable - a function component implementation, written in (props, useTokens) => JSX.Element form
22
+ * @param injectable - a function component implementation, written in (props, useTokens) => FurnJSX.Element form
22
23
  * @param useTokens - a hook function, generally built via buildUseTokens, used to retrieve design tokens for the component
23
24
  *
24
25
  * @returns - a function component that has a static function called customize attached. Customize will return a
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { act } from 'react';
2
3
  import type { TextProps } from 'react-native';
3
4
  import { Text, View } from 'react-native';
4
5
 
@@ -96,7 +97,7 @@ describe('useTokens samples', () => {
96
97
  const [tokens, cache] = useTokensSample1(theme);
97
98
 
98
99
  // build up the text style, or the full props as appropriate
99
- const styleFromTokens = cache(
100
+ const [styleFromTokens] = cache(
100
101
  /**
101
102
  * first build the style object
102
103
  * - this executes once for every unique set of keys.
@@ -131,8 +132,11 @@ describe('useTokens samples', () => {
131
132
 
132
133
  /** first render the component with no updates */
133
134
  it('Sample1Text rendering with no overrides', () => {
134
- const tree = renderer.create(<SampleText1>Sample1a</SampleText1>).toJSON();
135
- expect(tree).toMatchSnapshot();
135
+ let component: renderer.ReactTestRenderer;
136
+ act(() => {
137
+ component = renderer.create(<SampleText1>Sample1a</SampleText1>);
138
+ });
139
+ expect(component!.toJSON()).toMatchSnapshot();
136
140
  });
137
141
 
138
142
  /** now re-theme the component via the components in the theme */
@@ -145,8 +149,11 @@ describe('useTokens samples', () => {
145
149
  },
146
150
  },
147
151
  });
148
- const tree = renderer.create(<SampleText1>Sample1b</SampleText1>).toJSON();
149
- expect(tree).toMatchSnapshot();
152
+ let component: renderer.ReactTestRenderer;
153
+ act(() => {
154
+ component = renderer.create(<SampleText1>Sample1b</SampleText1>);
155
+ });
156
+ expect(component!.toJSON()).toMatchSnapshot();
150
157
  });
151
158
 
152
159
  /**
@@ -184,15 +191,16 @@ describe('useTokens samples', () => {
184
191
 
185
192
  /** rendering the Sample2 component with the base theme */
186
193
  it('Sample2Text rendering with defaults and a color override', () => {
187
- const tree = renderer
188
- .create(
194
+ let component: renderer.ReactTestRenderer;
195
+ act(() => {
196
+ component = renderer.create(
189
197
  <View>
190
198
  <SampleText2>Sample2 with defaults</SampleText2>
191
199
  <SampleText2 color="green">Sample2 with color override via prop</SampleText2>
192
200
  </View>,
193
- )
194
- .toJSON();
195
- expect(tree).toMatchSnapshot();
201
+ );
202
+ });
203
+ expect(component!.toJSON()).toMatchSnapshot();
196
204
  });
197
205
 
198
206
  /** now re-theme the component via the components in the theme */
@@ -205,14 +213,15 @@ describe('useTokens samples', () => {
205
213
  },
206
214
  },
207
215
  });
208
- const tree = renderer
209
- .create(
216
+ let component: renderer.ReactTestRenderer;
217
+ act(() => {
218
+ component = renderer.create(
210
219
  <View>
211
220
  <SampleText2>Sample2 with theme overrides set</SampleText2>
212
221
  <SampleText2 color="purple">Sample2 with theme and color prop override</SampleText2>
213
222
  </View>,
214
- )
215
- .toJSON();
216
- expect(tree).toMatchSnapshot();
223
+ );
224
+ });
225
+ expect(component!.toJSON()).toMatchSnapshot();
217
226
  });
218
227
  });