@fluentui-react-native/use-tokens 0.6.12 → 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.
- package/CHANGELOG.json +1 -1
- package/CHANGELOG.md +38 -2
- package/README.md +1 -1
- package/lib/applyPropsToTokens.d.ts +7 -2
- package/lib/applyPropsToTokens.js +7 -7
- package/lib/applyPropsToTokens.js.map +1 -1
- package/lib/applyPropsToTokens.test.d.ts +1 -1
- package/lib/applyPropsToTokens.test.js +19 -19
- package/lib/applyPropsToTokens.test.js.map +1 -1
- package/lib/applyTokenLayers.d.ts +7 -2
- package/lib/applyTokenLayers.js +16 -13
- package/lib/applyTokenLayers.js.map +1 -1
- package/lib/applyTokenLayers.test.d.ts +1 -1
- package/lib/applyTokenLayers.test.js +42 -42
- package/lib/applyTokenLayers.test.js.map +1 -1
- package/lib/buildUseTokens.d.ts +6 -3
- package/lib/buildUseTokens.js +22 -22
- package/lib/buildUseTokens.js.map +1 -1
- package/lib/buildUseTokens.test.d.ts +1 -1
- package/lib/buildUseTokens.test.js +68 -68
- package/lib/buildUseTokens.test.js.map +1 -1
- package/lib/customizable.d.ts +9 -5
- package/lib/customizable.d.ts.map +1 -1
- package/lib/customizable.js +8 -8
- package/lib/customizable.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/patchTokens.d.ts +6 -2
- package/lib/patchTokens.js +12 -12
- package/lib/patchTokens.js.map +1 -1
- package/lib/patchTokens.test.d.ts +1 -1
- package/lib/patchTokens.test.js +32 -32
- package/lib/patchTokens.test.js.map +1 -1
- package/lib/useTokens.samples.test.d.ts +1 -1
- package/lib/useTokens.samples.test.js +134 -111
- package/lib/useTokens.samples.test.js.map +1 -1
- package/lib-commonjs/applyPropsToTokens.d.ts +7 -2
- package/lib-commonjs/applyPropsToTokens.js +10 -11
- package/lib-commonjs/applyPropsToTokens.js.map +1 -1
- package/lib-commonjs/applyPropsToTokens.test.d.ts +1 -1
- package/lib-commonjs/applyPropsToTokens.test.js +23 -23
- package/lib-commonjs/applyPropsToTokens.test.js.map +1 -1
- package/lib-commonjs/applyTokenLayers.d.ts +7 -2
- package/lib-commonjs/applyTokenLayers.js +20 -18
- package/lib-commonjs/applyTokenLayers.js.map +1 -1
- package/lib-commonjs/applyTokenLayers.test.d.ts +1 -1
- package/lib-commonjs/applyTokenLayers.test.js +46 -46
- package/lib-commonjs/applyTokenLayers.test.js.map +1 -1
- package/lib-commonjs/buildUseTokens.d.ts +6 -3
- package/lib-commonjs/buildUseTokens.js +30 -28
- package/lib-commonjs/buildUseTokens.js.map +1 -1
- package/lib-commonjs/buildUseTokens.test.d.ts +1 -1
- package/lib-commonjs/buildUseTokens.test.js +71 -71
- package/lib-commonjs/buildUseTokens.test.js.map +1 -1
- package/lib-commonjs/customizable.d.ts +9 -5
- package/lib-commonjs/customizable.d.ts.map +1 -1
- package/lib-commonjs/customizable.js +11 -12
- package/lib-commonjs/customizable.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js +38 -13
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/patchTokens.d.ts +6 -2
- package/lib-commonjs/patchTokens.js +15 -16
- package/lib-commonjs/patchTokens.js.map +1 -1
- package/lib-commonjs/patchTokens.test.d.ts +1 -1
- package/lib-commonjs/patchTokens.test.js +36 -36
- package/lib-commonjs/patchTokens.test.js.map +1 -1
- package/lib-commonjs/useTokens.samples.test.d.ts +1 -1
- package/lib-commonjs/useTokens.samples.test.js +195 -141
- package/lib-commonjs/useTokens.samples.test.js.map +1 -1
- package/package.json +45 -45
- package/src/customizable.ts +3 -2
- package/src/useTokens.samples.test.tsx +24 -15
package/package.json
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/use-tokens",
|
|
3
|
-
"version": "0.
|
|
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
|
-
"
|
|
11
|
-
"
|
|
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
|
-
"
|
|
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.
|
|
38
|
+
"@fluentui-react-native/framework-base": "0.3.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/core": "^7.20.0",
|
|
42
42
|
"@fluentui-react-native/babel-config": "0.1.1",
|
|
43
43
|
"@fluentui-react-native/eslint-config-rules": "0.1.1",
|
|
44
44
|
"@fluentui-react-native/jest-config": "0.1.1",
|
|
45
|
-
"@fluentui-react-native/
|
|
46
|
-
"@react-native/
|
|
47
|
-
"@react-native/
|
|
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",
|
|
48
52
|
"@types/jest": "^29.0.0",
|
|
49
|
-
"@types/react": "
|
|
50
|
-
"@types/react-test-renderer": "^
|
|
51
|
-
"react": "
|
|
52
|
-
"react-native": "^0.
|
|
53
|
-
"react-test-renderer": "
|
|
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
|
+
}
|
|
54
67
|
},
|
|
55
68
|
"rnx-kit": {
|
|
56
69
|
"kitType": "library",
|
|
57
70
|
"alignDeps": {
|
|
58
|
-
"presets": [
|
|
59
|
-
"microsoft/react-native"
|
|
60
|
-
],
|
|
61
|
-
"requirements": {
|
|
62
|
-
"development": [
|
|
63
|
-
"react-native@0.74"
|
|
64
|
-
],
|
|
65
|
-
"production": [
|
|
66
|
-
"react-native@0.73 || 0.74"
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
71
|
"capabilities": [
|
|
70
|
-
"
|
|
71
|
-
"core",
|
|
72
|
-
"core-
|
|
73
|
-
"core-ios",
|
|
72
|
+
"core-android-dev-only",
|
|
73
|
+
"core-dev-only",
|
|
74
|
+
"core-ios-dev-only",
|
|
74
75
|
"react",
|
|
75
|
-
"react-test-renderer"
|
|
76
|
+
"react-test-renderer",
|
|
77
|
+
"tools-core",
|
|
78
|
+
"tools-jest"
|
|
76
79
|
]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
"peerDependencies": {
|
|
80
|
-
"react": "18.2.0",
|
|
81
|
-
"react-native": "^0.73.0 || ^0.74.0"
|
|
80
|
+
},
|
|
81
|
+
"extends": "@fluentui-react-native/kit-config"
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|
package/src/customizable.ts
CHANGED
|
@@ -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>) =>
|
|
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) =>
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
188
|
-
|
|
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
|
-
|
|
195
|
-
expect(
|
|
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
|
-
|
|
209
|
-
|
|
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
|
-
|
|
216
|
-
expect(
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
expect(component!.toJSON()).toMatchSnapshot();
|
|
217
226
|
});
|
|
218
227
|
});
|