@fluentui-react-native/use-styling 0.7.0 → 0.8.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.json +96 -1
- package/CHANGELOG.md +40 -2
- package/README.md +19 -17
- package/lib/buildProps.d.ts +10 -10
- package/lib/buildProps.d.ts.map +1 -1
- package/lib/buildProps.js +10 -28
- package/lib/buildProps.js.map +1 -1
- package/lib/buildProps.test.js +11 -30
- package/lib/buildProps.test.js.map +1 -1
- package/lib/buildUseStyling.d.ts +1 -1
- package/lib/buildUseStyling.d.ts.map +1 -1
- package/lib/buildUseStyling.js +5 -23
- package/lib/buildUseStyling.js.map +1 -1
- package/lib/buildUseStyling.test.js +1 -11
- package/lib/buildUseStyling.test.js.map +1 -1
- package/lib/useStyling.samples.test.js +2 -19
- package/lib/useStyling.samples.test.js.map +1 -1
- package/lib-commonjs/buildProps.d.ts +10 -10
- package/lib-commonjs/buildProps.d.ts.map +1 -1
- package/lib-commonjs/buildProps.js +11 -28
- package/lib-commonjs/buildProps.js.map +1 -1
- package/lib-commonjs/buildProps.test.js +15 -34
- package/lib-commonjs/buildProps.test.js.map +1 -1
- package/lib-commonjs/buildUseStyling.d.ts +1 -1
- package/lib-commonjs/buildUseStyling.d.ts.map +1 -1
- package/lib-commonjs/buildUseStyling.js +10 -27
- package/lib-commonjs/buildUseStyling.js.map +1 -1
- package/lib-commonjs/buildUseStyling.test.js +5 -15
- package/lib-commonjs/buildUseStyling.test.js.map +1 -1
- package/lib-commonjs/index.js +5 -6
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/useStyling.samples.test.js +18 -45
- package/lib-commonjs/useStyling.samples.test.js.map +1 -1
- package/package.json +7 -6
- package/src/buildProps.test.ts +10 -22
- package/src/buildProps.ts +32 -57
- package/src/buildUseStyling.ts +7 -9
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,102 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/use-styling",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Sat, 18 Dec 2021 04:11:32 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/use-styling_v0.8.1",
|
|
7
|
+
"version": "0.8.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "afoxman@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/use-styling",
|
|
13
|
+
"commit": "38fe241a385ecd1ce4e51b5bcba57a9dd0426789",
|
|
14
|
+
"comment": "Update to TypeScript 4.5.4."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui-react-native/use-styling",
|
|
19
|
+
"comment": "Bump @fluentui-react-native/memo-cache to v1.1.6",
|
|
20
|
+
"commit": "38fe241a385ecd1ce4e51b5bcba57a9dd0426789"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui-react-native/use-styling",
|
|
25
|
+
"comment": "Bump @fluentui-react-native/use-tokens to v0.2.1",
|
|
26
|
+
"commit": "38fe241a385ecd1ce4e51b5bcba57a9dd0426789"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"date": "Wed, 17 Nov 2021 19:28:07 GMT",
|
|
33
|
+
"tag": "@fluentui-react-native/use-styling_v0.8.0",
|
|
34
|
+
"version": "0.8.0",
|
|
35
|
+
"comments": {
|
|
36
|
+
"minor": [
|
|
37
|
+
{
|
|
38
|
+
"comment": "Update to react-native 0.64",
|
|
39
|
+
"author": "afoxman@microsoft.com",
|
|
40
|
+
"commit": "f16d742b5c2d5b97e49ac1ef7b740cbf89fc42e6",
|
|
41
|
+
"package": "@fluentui-react-native/use-styling"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"patch": [
|
|
45
|
+
{
|
|
46
|
+
"comment": "Bump @fluentui-react-native/use-tokens to v0.2.0",
|
|
47
|
+
"author": "afoxman@microsoft.com",
|
|
48
|
+
"commit": "f16d742b5c2d5b97e49ac1ef7b740cbf89fc42e6",
|
|
49
|
+
"package": "@fluentui-react-native/use-styling"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"date": "Thu, 11 Nov 2021 23:17:41 GMT",
|
|
56
|
+
"tag": "@fluentui-react-native/use-styling_v0.7.2",
|
|
57
|
+
"version": "0.7.2",
|
|
58
|
+
"comments": {
|
|
59
|
+
"none": [
|
|
60
|
+
{
|
|
61
|
+
"comment": "Bump @fluentui-react-native/use-tokens to v0.1.7",
|
|
62
|
+
"author": "ruaraki@microsoft.com",
|
|
63
|
+
"commit": "110fba2a1721a914501404f6040f07656307549e",
|
|
64
|
+
"package": "@fluentui-react-native/use-styling"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"date": "Mon, 25 Oct 2021 19:24:43 GMT",
|
|
71
|
+
"tag": "@fluentui-react-native/use-styling_v0.7.2",
|
|
72
|
+
"version": "0.7.2",
|
|
73
|
+
"comments": {
|
|
74
|
+
"patch": [
|
|
75
|
+
{
|
|
76
|
+
"comment": "Use tslib where spreadArray is used",
|
|
77
|
+
"author": "ruaraki@microsoft.com",
|
|
78
|
+
"commit": "f6578742d6c957cf7e346db82f89171f80bedc3b",
|
|
79
|
+
"package": "@fluentui-react-native/use-styling"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"date": "Wed, 20 Oct 2021 03:46:25 GMT",
|
|
86
|
+
"tag": "@fluentui-react-native/use-styling_v0.7.1",
|
|
87
|
+
"version": "0.7.1",
|
|
88
|
+
"comments": {
|
|
89
|
+
"patch": [
|
|
90
|
+
{
|
|
91
|
+
"comment": "Revert \"Add props to buildProps (#1039)\"",
|
|
92
|
+
"author": "ruaraki@microsoft.com",
|
|
93
|
+
"commit": "273f5addbeb5abeaec0b517e5416f52d8878152f",
|
|
94
|
+
"package": "@fluentui-react-native/use-styling"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"date": "Fri, 01 Oct 2021 17:52:17 GMT",
|
|
6
101
|
"tag": "@fluentui-react-native/use-styling_v0.7.0",
|
|
7
102
|
"version": "0.7.0",
|
|
8
103
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/use-styling
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 18 Dec 2021 04:11:32 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.8.1
|
|
8
|
+
|
|
9
|
+
Sat, 18 Dec 2021 04:11:32 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Update to TypeScript 4.5.4. (afoxman@microsoft.com)
|
|
14
|
+
- Bump @fluentui-react-native/memo-cache to v1.1.6
|
|
15
|
+
- Bump @fluentui-react-native/use-tokens to v0.2.1
|
|
16
|
+
|
|
17
|
+
## 0.8.0
|
|
18
|
+
|
|
19
|
+
Wed, 17 Nov 2021 19:28:07 GMT
|
|
20
|
+
|
|
21
|
+
### Minor changes
|
|
22
|
+
|
|
23
|
+
- Update to react-native 0.64 (afoxman@microsoft.com)
|
|
24
|
+
|
|
25
|
+
### Patches
|
|
26
|
+
|
|
27
|
+
- Bump @fluentui-react-native/use-tokens to v0.2.0 (afoxman@microsoft.com)
|
|
28
|
+
|
|
29
|
+
## 0.7.2
|
|
30
|
+
|
|
31
|
+
Mon, 25 Oct 2021 19:24:43 GMT
|
|
32
|
+
|
|
33
|
+
### Patches
|
|
34
|
+
|
|
35
|
+
- Use tslib where spreadArray is used (ruaraki@microsoft.com)
|
|
36
|
+
|
|
37
|
+
## 0.7.1
|
|
38
|
+
|
|
39
|
+
Wed, 20 Oct 2021 03:46:25 GMT
|
|
40
|
+
|
|
41
|
+
### Patches
|
|
42
|
+
|
|
43
|
+
- Revert "Add props to buildProps (#1039)" (ruaraki@microsoft.com)
|
|
44
|
+
|
|
7
45
|
## 0.7.0
|
|
8
46
|
|
|
9
|
-
Fri, 01 Oct 2021 17:
|
|
47
|
+
Fri, 01 Oct 2021 17:52:17 GMT
|
|
10
48
|
|
|
11
49
|
### Minor changes
|
|
12
50
|
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ An extremely simple example might look like:
|
|
|
14
14
|
const useSyling = buildUseStyling(myComponentOptions, themeHelper);
|
|
15
15
|
|
|
16
16
|
// component implementation, consuming the styling hook
|
|
17
|
-
const MyComponent = props => {
|
|
17
|
+
const MyComponent = (props) => {
|
|
18
18
|
// get some default/styled props for the container and content child components
|
|
19
19
|
const { container, content } = useStyling(props);
|
|
20
20
|
// render as normal but mixin those values to pass the props to the sub-components
|
|
@@ -205,7 +205,7 @@ const Button = (props: ButtonProps) => {
|
|
|
205
205
|
// get some state value that figures out whether the button is pressed and/or hovered
|
|
206
206
|
const buttonState: ButtonState = useButtonState(props);
|
|
207
207
|
// get styling values based on props and the current state
|
|
208
|
-
const { container, icon, label } = useStyling(props, stateName => buttonState[stateName]);
|
|
208
|
+
const { container, icon, label } = useStyling(props, (stateName) => buttonState[stateName]);
|
|
209
209
|
|
|
210
210
|
const buttonProps = useButtonMagic(props, container);
|
|
211
211
|
return (
|
|
@@ -257,36 +257,38 @@ const useStyling = buildUseStyling({
|
|
|
257
257
|
The functions are assumed to have the following signature:
|
|
258
258
|
|
|
259
259
|
```ts
|
|
260
|
-
function propBuilder(tokens: Tokens, theme: Theme,
|
|
260
|
+
function propBuilder(tokens: Tokens, theme: Theme, cache: GetMemoValue<Props>): Props;
|
|
261
261
|
```
|
|
262
262
|
|
|
263
263
|
While tokens and theme have been discussed at length above, the cache will be a cache instance keyed on:
|
|
264
264
|
|
|
265
265
|
- The theme
|
|
266
266
|
- The tokens coming from the theme
|
|
267
|
-
- The props that are being passed through from the outer component
|
|
268
267
|
- This slot
|
|
269
268
|
|
|
270
269
|
If there are no tokens which are also props, i.e. if `tokensProps` is falsy, this is sufficient and the function could be written as:
|
|
271
270
|
|
|
272
271
|
```ts
|
|
273
|
-
const slotFn = (tokens: Tokens, theme: Theme,
|
|
274
|
-
cache(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
272
|
+
const slotFn = (tokens: Tokens, theme: Theme, cache: GetMemoValue<Props>) =>
|
|
273
|
+
cache(
|
|
274
|
+
() => {
|
|
275
|
+
return {
|
|
276
|
+
style: {
|
|
277
|
+
backgroundColor: tokens.backgroundColor,
|
|
278
|
+
// etc.
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
[
|
|
283
|
+
/* no keys, just direct cache the function result*/
|
|
284
|
+
],
|
|
285
|
+
)[0];
|
|
284
286
|
```
|
|
285
287
|
|
|
286
288
|
If some all props are tokens then those keys should be considered in the caching. This would then turn into:
|
|
287
289
|
|
|
288
290
|
```ts
|
|
289
|
-
const slotFn = (tokens: Tokens, theme: Theme,
|
|
291
|
+
const slotFn = (tokens: Tokens, theme: Theme, cache: GetMemoValue<Props>) => {
|
|
290
292
|
const { backgroundColor, color, borderRadius } = tokens;
|
|
291
293
|
return cache(
|
|
292
294
|
() => ({
|
|
@@ -303,7 +305,7 @@ The library provides a helper called buildProps to make this more ergonomic. It
|
|
|
303
305
|
|
|
304
306
|
```ts
|
|
305
307
|
const slotFn = buildProps(
|
|
306
|
-
(tokens: Tokens, theme: Theme
|
|
308
|
+
(tokens: Tokens, theme: Theme) => ({
|
|
307
309
|
style: {
|
|
308
310
|
backgroundColor: tokens.backgroundColor,
|
|
309
311
|
color: tokens.color,
|
package/lib/buildProps.d.ts
CHANGED
|
@@ -16,36 +16,36 @@ export declare type TokensThatAreAlsoProps<TTokens> = (keyof TTokens)[] | 'all'
|
|
|
16
16
|
* The provided
|
|
17
17
|
* cache will be scoped to the theme, slot, and tokens that are coming out of the theme.
|
|
18
18
|
*/
|
|
19
|
-
export declare type BuildPropsBase<TProps, TTokens, TTheme
|
|
19
|
+
export declare type BuildPropsBase<TProps, TTokens, TTheme> = (tokens: TTokens, theme: TTheme, cache: GetMemoValue<any>) => Partial<TProps>;
|
|
20
20
|
/**
|
|
21
21
|
* A refine function allows style functions to be updated based on tokens that are also props. Only those tokens that are also
|
|
22
22
|
* props need to be considered as a key for caching
|
|
23
23
|
*/
|
|
24
|
-
export declare type RefineFunctionBase<TProps, TTokens, TTheme
|
|
24
|
+
export declare type RefineFunctionBase<TProps, TTokens, TTheme> = (mask?: TokensThatAreAlsoProps<TTokens>) => BuildPropsBase<TProps, TTokens, TTheme>;
|
|
25
25
|
/**
|
|
26
26
|
* Signature for a style function which can be optionally refined by the styling hook if prop masks are provided
|
|
27
27
|
*/
|
|
28
|
-
export declare type RefinableBuildPropsBase<TProps, TTokens, TTheme
|
|
29
|
-
refine?: RefineFunctionBase<TProps, TTokens, TTheme
|
|
28
|
+
export declare type RefinableBuildPropsBase<TProps, TTokens, TTheme> = BuildPropsBase<TProps, TTokens, TTheme> & {
|
|
29
|
+
refine?: RefineFunctionBase<TProps, TTokens, TTheme>;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Style functions can be plain functions, refinable functions, or just raw props
|
|
33
33
|
*/
|
|
34
|
-
export declare type BuildSlotProps<TSlotProps, TTokens, TTheme
|
|
35
|
-
[K in keyof TSlotProps]?: RefinableBuildPropsBase<TSlotProps[K], TTokens, TTheme
|
|
34
|
+
export declare type BuildSlotProps<TSlotProps, TTokens, TTheme> = {
|
|
35
|
+
[K in keyof TSlotProps]?: RefinableBuildPropsBase<TSlotProps[K], TTokens, TTheme> | TSlotProps[K];
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
38
|
* Standard wrapper for a function that provides props for a component based on tokens and theme.
|
|
39
39
|
*
|
|
40
|
-
* @param fn - function which does the work of producing props for the tokens
|
|
41
|
-
* @param keys - which token
|
|
40
|
+
* @param fn - function which does the work of producing props for the tokens and theme provided
|
|
41
|
+
* @param keys - which token properties are used by this style, this determines the keys to use for caching
|
|
42
42
|
*/
|
|
43
|
-
export declare function buildProps<TProps, TTokens, TTheme
|
|
43
|
+
export declare function buildProps<TProps, TTokens, TTheme>(fn: (tokens: TTokens, theme: TTheme) => TProps, keys?: (keyof TTokens)[]): RefinableBuildPropsBase<TProps, TTokens, TTheme>;
|
|
44
44
|
/**
|
|
45
45
|
* Utility function to check the type and refinement capabilities of a styleFunction and refine it if appropriate
|
|
46
46
|
*
|
|
47
47
|
* @param fn - function or props to potentially refine
|
|
48
48
|
* @param mask - prop mask to use for refinement
|
|
49
49
|
*/
|
|
50
|
-
export declare function refinePropsFunctions<TSlotProps, TTokens, TTheme
|
|
50
|
+
export declare function refinePropsFunctions<TSlotProps, TTokens, TTheme>(styles: BuildSlotProps<TSlotProps, TTokens, TTheme>, mask: TokensThatAreAlsoProps<TTokens>): BuildSlotProps<TSlotProps, TTokens, TTheme>;
|
|
51
51
|
//# sourceMappingURL=buildProps.d.ts.map
|
package/lib/buildProps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProps.d.ts","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE;;;;;;;GAOG;AACH,oBAAY,sBAAsB,CAAC,OAAO,IAAI,CAAC,MAAM,OAAO,CAAC,EAAE,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjF;;;;;;;GAOG;AACH,oBAAY,cAAc,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AC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,EAC9C,IAAI,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,GACvB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAclD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAC9D,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EACnD,IAAI,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACpC,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAQ7C"}
|
package/lib/buildProps.js
CHANGED
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Caches and returns the function based on the current keys.
|
|
3
|
-
*
|
|
4
|
-
* @param fn Function which does the work of producing props for the tokens, theme, and props provided
|
|
5
|
-
* @param keys Set of input values the function is dependent on
|
|
6
|
-
* @returns Cached function
|
|
7
|
-
*/
|
|
8
1
|
function cacheStyleClosure(fn, keys) {
|
|
9
|
-
return function (tokens, theme,
|
|
10
|
-
return cache(function () { return fn(tokens, theme
|
|
11
|
-
if (Object.keys(tokens).includes(key)) {
|
|
12
|
-
return tokens[key];
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return props[key];
|
|
16
|
-
}
|
|
17
|
-
}))[0];
|
|
2
|
+
return function (tokens, theme, cache) {
|
|
3
|
+
return cache(function () { return fn(tokens, theme); }, (keys || []).map(function (key) { return tokens[key]; }))[0];
|
|
18
4
|
};
|
|
19
5
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Reduce keys to the set that are also part of the mask.
|
|
22
|
-
*
|
|
23
|
-
* @param keys - which token and prop properties are used by this style, this determines the keys to use for caching
|
|
24
|
-
* @param mask - the set of tokens that are also props
|
|
25
|
-
* @returns An array of keys that are part of the mask to be used as a caching key
|
|
26
|
-
*/
|
|
27
6
|
function refineKeys(keys, mask) {
|
|
28
|
-
return typeof mask === 'object' && Array.isArray(mask)
|
|
7
|
+
return typeof mask === 'object' && Array.isArray(mask)
|
|
8
|
+
? keys.filter(function (key) { return mask.findIndex(function (val) { return val === key; }) !== -1; })
|
|
9
|
+
: mask
|
|
10
|
+
? keys
|
|
11
|
+
: [];
|
|
29
12
|
}
|
|
30
13
|
/**
|
|
31
14
|
* Standard wrapper for a function that provides props for a component based on tokens and theme.
|
|
32
15
|
*
|
|
33
|
-
* @param fn - function which does the work of producing props for the tokens
|
|
34
|
-
* @param keys - which token
|
|
16
|
+
* @param fn - function which does the work of producing props for the tokens and theme provided
|
|
17
|
+
* @param keys - which token properties are used by this style, this determines the keys to use for caching
|
|
35
18
|
*/
|
|
36
19
|
export function buildProps(fn, keys) {
|
|
37
20
|
// wrap the provided function in the standard caching layer, basing it upon the provided keys
|
|
@@ -55,8 +38,7 @@ export function buildProps(fn, keys) {
|
|
|
55
38
|
export function refinePropsFunctions(styles, mask) {
|
|
56
39
|
var result = {};
|
|
57
40
|
Object.keys(styles).forEach(function (key) {
|
|
58
|
-
var refine = typeof styles[key] === 'function' &&
|
|
59
|
-
styles[key].refine;
|
|
41
|
+
var refine = typeof styles[key] === 'function' && styles[key].refine;
|
|
60
42
|
result[key] = refine ? refine(mask) : styles[key];
|
|
61
43
|
});
|
|
62
44
|
return result;
|
package/lib/buildProps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":"AA4CA,SAAS,iBAAiB,CACxB,EAA8C,EAC9C,IAAwB;IAExB,OAAO,UAAC,MAAe,EAAE,KAAa,EAAE,KAA2B;QACjE,OAAA,KAAK,CACH,cAAM,OAAA,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAjB,CAAiB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MAAM,CAAC,GAAG,CAAC,KAAK,UAAU,IAAK,MAAM,CAAC,GAAG,CAA4E,CAAC,MAAM,CAAC;QACtI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/lib/buildProps.test.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
import { __assign } from "tslib";
|
|
12
2
|
import { getMemoCache } from '@fluentui-react-native/memo-cache';
|
|
13
3
|
import { buildProps } from './buildProps';
|
|
14
4
|
var theme = { foo: 'foo', bar: 'bar' };
|
|
15
5
|
var instanceCount = 0;
|
|
16
|
-
function munge(tokens, theme
|
|
17
|
-
return __assign(__assign(__assign(
|
|
6
|
+
function munge(tokens, theme) {
|
|
7
|
+
return __assign(__assign(__assign({}, theme), tokens), { instance: instanceCount++ });
|
|
18
8
|
}
|
|
19
9
|
describe('props function tests', function () {
|
|
20
10
|
test('basic build props function caches as expected', function () {
|
|
21
11
|
var cache = getMemoCache();
|
|
22
12
|
var styleFn = buildProps(munge, ['a', 'b']);
|
|
23
|
-
var p1 = styleFn({ a: 'a', b: 'b', c: 'c' }, theme,
|
|
24
|
-
expect(styleFn({ a: 'a', b: 'b', c: 'foo' }, theme,
|
|
25
|
-
var p2 = styleFn({ a: 'b', b: 'b' }, theme,
|
|
13
|
+
var p1 = styleFn({ a: 'a', b: 'b', c: 'c' }, theme, cache);
|
|
14
|
+
expect(styleFn({ a: 'a', b: 'b', c: 'foo' }, theme, cache)).toBe(p1);
|
|
15
|
+
var p2 = styleFn({ a: 'b', b: 'b' }, theme, cache);
|
|
26
16
|
expect(p2).not.toBe(p1);
|
|
27
|
-
expect(styleFn({ a: 'b', b: 'b', c: 'bar' }, theme,
|
|
17
|
+
expect(styleFn({ a: 'b', b: 'b', c: 'bar' }, theme, cache)).toBe(p2);
|
|
28
18
|
});
|
|
29
19
|
test('build props function refinement works with explicit keys', function () {
|
|
30
20
|
var cache = getMemoCache();
|
|
@@ -32,21 +22,12 @@ describe('props function tests', function () {
|
|
|
32
22
|
var refinedFn = styleFn.refine(['a', 'b']);
|
|
33
23
|
var t1 = { a: 'a', b: 'b', c: 'c', d: 'd' };
|
|
34
24
|
var t2 = { a: 'a', b: 'b', c: 'foo', d: 'bar' };
|
|
35
|
-
var p1 = styleFn(t1, theme,
|
|
36
|
-
var p2 = styleFn(t2, theme,
|
|
25
|
+
var p1 = styleFn(t1, theme, cache);
|
|
26
|
+
var p2 = styleFn(t2, theme, cache);
|
|
37
27
|
expect(p2).not.toBe(p1);
|
|
38
|
-
var rp1 = refinedFn(t1, theme,
|
|
39
|
-
var rp2 = refinedFn(t2, theme,
|
|
28
|
+
var rp1 = refinedFn(t1, theme, cache);
|
|
29
|
+
var rp2 = refinedFn(t2, theme, cache);
|
|
40
30
|
expect(rp2).toBe(rp1);
|
|
41
31
|
});
|
|
42
|
-
test('build props with outer props function caches as expected', function () {
|
|
43
|
-
var cache = getMemoCache();
|
|
44
|
-
var styleFn = buildProps(munge, ['a', 'b', 'banana']);
|
|
45
|
-
var p1 = styleFn({ a: 'a', b: 'b', c: 'c' }, theme, { banana: 'banana' }, cache);
|
|
46
|
-
expect(styleFn({ a: 'a', b: 'b', c: 'foo' }, theme, { banana: 'banana', potato: 'potato' }, cache)).toBe(p1);
|
|
47
|
-
var p2 = styleFn({ a: 'b', b: 'b' }, theme, { banana: 'potato' }, cache);
|
|
48
|
-
expect(p2).not.toBe(p1);
|
|
49
|
-
expect(styleFn({ a: 'b', b: 'b', c: 'bar' }, theme, { banana: 'potato', potato: 'potato' }, cache)).toBe(p2);
|
|
50
|
-
});
|
|
51
32
|
});
|
|
52
33
|
//# sourceMappingURL=buildProps.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProps.test.js","sourceRoot":"","sources":["../src/buildProps.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildProps.test.js","sourceRoot":"","sources":["../src/buildProps.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,IAAM,KAAK,GAAW,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AAEjD,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,SAAS,KAAK,CAAC,MAAe,EAAE,KAAa;IAC3C,sCACK,KAAK,GACL,MAAM,KACT,QAAQ,EAAE,aAAa,EAAE,IACzB;AACJ,CAAC;AAED,QAAQ,CAAC,sBAAsB,EAAE;IAC/B,IAAI,CAAC,+CAA+C,EAAE;QACpD,IAAM,KAAK,GAAG,YAAY,EAAE,CAAC;QAC7B,IAAM,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9C,IAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,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B,IAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACxC,IAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/buildUseStyling.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare type UseStylingOptions<TProps, TSlotProps, TTokens, TTheme> = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Functions which build up the props for each slot
|
|
18
18
|
*/
|
|
19
|
-
slotProps?: BuildSlotProps<TSlotProps, TTokens, TTheme
|
|
19
|
+
slotProps?: BuildSlotProps<TSlotProps, TTokens, TTheme>;
|
|
20
20
|
/**
|
|
21
21
|
* Which props should be considered to be tokens.
|
|
22
22
|
* - If an array of keys this will ensure these props are promoted to tokens
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseStyling.d.ts","sourceRoot":"","sources":["../src/buildUseStyling.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAwB,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAwD,QAAQ,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElI;;GAEG;AACH,oBAAY,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI;IACnE;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;IAE1C;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"buildUseStyling.d.ts","sourceRoot":"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E,UAAU,CAAC,CA6BhC"}
|
package/lib/buildUseStyling.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
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 __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
13
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
14
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
15
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
16
|
-
r[k] = a[j];
|
|
17
|
-
return r;
|
|
18
|
-
};
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
19
2
|
import { refinePropsFunctions } from './buildProps';
|
|
20
3
|
import { applyPropsToTokens, applyTokenLayers, buildUseTokens } from '@fluentui-react-native/use-tokens';
|
|
21
4
|
/**
|
|
@@ -24,14 +7,13 @@ import { applyPropsToTokens, applyTokenLayers, buildUseTokens } from '@fluentui-
|
|
|
24
7
|
* @param styles - refined style functions or props to use for processing
|
|
25
8
|
* @param tokens - token inputs for the style functions
|
|
26
9
|
* @param theme - theme to resolve against
|
|
27
|
-
* @param props - props from outer component
|
|
28
10
|
* @param cache - cache to use for the base of slot caching
|
|
29
11
|
*/
|
|
30
|
-
function resolveToSlotProps(styles, tokens, theme,
|
|
12
|
+
function resolveToSlotProps(styles, tokens, theme, cache) {
|
|
31
13
|
var slotProps = {};
|
|
32
14
|
Object.keys(styles).forEach(function (key) {
|
|
33
15
|
var style = styles[key];
|
|
34
|
-
slotProps[key] = typeof style === 'function' ? style(tokens, theme,
|
|
16
|
+
slotProps[key] = typeof style === 'function' ? style(tokens, theme, cache(null, [key])[1]) : style;
|
|
35
17
|
});
|
|
36
18
|
return slotProps;
|
|
37
19
|
}
|
|
@@ -46,7 +28,7 @@ export function buildUseStyling(options, themeHelper) {
|
|
|
46
28
|
var useTheme = themeHelper.useTheme, getComponentInfo = themeHelper.getComponentInfo;
|
|
47
29
|
var tokens = options.tokens, tokenProps = options.tokensThatAreAlsoProps;
|
|
48
30
|
var styles = refinePropsFunctions(options.slotProps || {}, tokenProps);
|
|
49
|
-
var useTokens = buildUseTokens.apply(void 0,
|
|
31
|
+
var useTokens = buildUseTokens.apply(void 0, __spreadArray([getComponentInfo], tokens, false));
|
|
50
32
|
return function (props, lookup) {
|
|
51
33
|
var _a, _b;
|
|
52
34
|
// query the theme
|
|
@@ -65,7 +47,7 @@ export function buildUseStyling(options, themeHelper) {
|
|
|
65
47
|
mergedTokens = __assign(__assign({}, mergedTokens), props);
|
|
66
48
|
}
|
|
67
49
|
// finally produce slotProps from calling the style functions on each entry
|
|
68
|
-
return resolveToSlotProps(styles, mergedTokens, theme,
|
|
50
|
+
return resolveToSlotProps(styles, mergedTokens, theme, cache);
|
|
69
51
|
};
|
|
70
52
|
}
|
|
71
53
|
//# sourceMappingURL=buildUseStyling.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseStyling.js","sourceRoot":"","sources":["../src/buildUseStyling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildUseStyling.js","sourceRoot":"","sources":["../src/buildUseStyling.ts"],"names":[],"mappings":";AACA,OAAO,EAA0C,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAA2B,MAAM,mCAAmC,CAAC;AAiDlI;;;;;;;GAOG;AACH,SAAS,kBAAkB,CACzB,MAAmD,EACnD,MAAe,EACf,KAAa,EACb,KAA4B;IAE5B,IAAM,SAAS,GAAG,EAAE,C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,CAAC,EAAzH,YAAY,QAAA,EAAE,KAAK,QAAA,CAAuG;SAC5H;QAED,qBAAqB;QACrB,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC/D,KAAwB,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,CAAC,EAAjF,YAAY,QAAA,EAAE,KAAK,QAAA,CAA+D;SACpF;aAAM,IAAI,UAAU,KAAK,KAAK,EAAE;YAC/B,YAAY,yBAAQ,YAAY,GAAK,KAAK,CAAE,CAAC;SAC9C;QAED,2EAA2E;QAC3E,OAAO,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
import { __assign } from "tslib";
|
|
12
2
|
import { buildUseStyling } from './buildUseStyling';
|
|
13
3
|
import { getMemoCache } from '@fluentui-react-native/memo-cache';
|
|
14
4
|
import { buildProps } from './buildProps';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseStyling.test.js","sourceRoot":"","sources":["../src/buildUseStyling.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildUseStyling.test.js","sourceRoot":"","sources":["../src/buildUseStyling.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAkC,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,M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|
-
|
|
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 __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
13
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
14
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
15
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
16
|
-
r[k] = a[j];
|
|
17
|
-
return r;
|
|
18
|
-
};
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
19
2
|
import { buildUseStyling } from './buildUseStyling';
|
|
20
3
|
import { Text, View } from 'react-native';
|
|
21
4
|
import { buildProps } from './buildProps';
|
|
@@ -139,7 +122,7 @@ describe('useStyling samples', function () {
|
|
|
139
122
|
* If we didn't want to add the extra 'Sample2' lookup this line would be omitted. If we didn't want to look up 'Sample1' first
|
|
140
123
|
* that could be filtered out of the array that is being copied
|
|
141
124
|
*/
|
|
142
|
-
tokens:
|
|
125
|
+
tokens: __spreadArray(__spreadArray([], sample1StylingOptions.tokens, true), ['Sample2'], false),
|
|
143
126
|
/**
|
|
144
127
|
* This is the final bit of magic. The tokens will already have values set from the global theme, they will then be patched with
|
|
145
128
|
* any customizations set into Sample1 and/or Sample2.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyling.samples.test.js","sourceRoot":"","sources":["../src/useStyling.samples.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStyling.samples.test.js","sourceRoot":"","sources":["../src/useStyling.samples.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,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