@fluentui-react-native/use-styling 0.13.3 → 0.13.4
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 +36 -1
- package/CHANGELOG.md +10 -2
- package/eslint.config.js +3 -0
- package/lib/buildProps.js +7 -9
- package/lib/buildProps.js.map +1 -1
- package/lib/buildProps.test.js +23 -20
- package/lib/buildProps.test.js.map +1 -1
- package/lib/buildUseStyling.js +13 -15
- package/lib/buildUseStyling.js.map +1 -1
- package/lib/buildUseStyling.test.js +27 -22
- package/lib/buildUseStyling.test.js.map +1 -1
- package/lib/useStyling.samples.test.js +43 -34
- package/lib/useStyling.samples.test.js.map +1 -1
- package/lib-commonjs/buildProps.js +7 -9
- package/lib-commonjs/buildProps.js.map +1 -1
- package/lib-commonjs/buildProps.test.js +25 -22
- package/lib-commonjs/buildProps.test.js.map +1 -1
- package/lib-commonjs/buildUseStyling.js +15 -17
- package/lib-commonjs/buildUseStyling.js.map +1 -1
- package/lib-commonjs/buildUseStyling.test.js +30 -25
- package/lib-commonjs/buildUseStyling.test.js.map +1 -1
- package/lib-commonjs/useStyling.samples.test.js +49 -39
- package/lib-commonjs/useStyling.samples.test.js.map +1 -1
- package/package.json +11 -3
- package/.eslintrc.js +0 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,42 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/use-styling",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Thu,
|
|
5
|
+
"date": "Thu, 10 Jul 2025 20:30:28 GMT",
|
|
6
|
+
"version": "0.13.4",
|
|
7
|
+
"tag": "@fluentui-react-native/use-styling_v0.13.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "jasonmo@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/use-styling",
|
|
13
|
+
"commit": "54087dca787180bbf34630470cd0d06e88366b30",
|
|
14
|
+
"comment": "update eslint to 9.x and use new flat config format with security rules"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "ruaraki@microsoft.com",
|
|
18
|
+
"package": "@fluentui-react-native/use-styling",
|
|
19
|
+
"commit": "a245202877ef7f2be9ab5f0e1356b2270957e693",
|
|
20
|
+
"comment": "Run bump-versions"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "4123478+tido64@users.noreply.github.com",
|
|
24
|
+
"package": "@fluentui-react-native/use-styling",
|
|
25
|
+
"commit": "79bb06f6bbfd0a36f9d2ef371f4857be9660f027",
|
|
26
|
+
"comment": "Fixed `align-deps` warnings"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"patch": [
|
|
30
|
+
{
|
|
31
|
+
"author": "jasonmo@microsoft.com",
|
|
32
|
+
"package": "@fluentui-react-native/use-styling",
|
|
33
|
+
"commit": "479b93cea460a26df70c55b5d3335927ed374713",
|
|
34
|
+
"comment": "update builds to use node16 settings and modern export maps"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"date": "Thu, 10 Jul 2025 19:20:13 GMT",
|
|
6
41
|
"version": "0.13.3",
|
|
7
42
|
"tag": "@fluentui-react-native/use-styling_v0.13.3",
|
|
8
43
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/use-styling
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on Thu,
|
|
3
|
+
<!-- This log was last generated on Thu, 10 Jul 2025 20:30:28 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.13.4
|
|
8
|
+
|
|
9
|
+
Thu, 10 Jul 2025 20:30:28 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- update builds to use node16 settings and modern export maps (jasonmo@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.13.3
|
|
8
16
|
|
|
9
|
-
Thu,
|
|
17
|
+
Thu, 10 Jul 2025 19:20:13 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/eslint.config.js
ADDED
package/lib/buildProps.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
function cacheStyleClosure(fn, keys) {
|
|
2
|
-
return
|
|
3
|
-
return cache(function () { return fn(tokens, theme); }, (keys || []).map(function (key) { return tokens[key]; }))[0];
|
|
4
|
-
};
|
|
2
|
+
return (tokens, theme, cache) => cache(() => fn(tokens, theme), (keys || []).map((key) => tokens[key]))[0];
|
|
5
3
|
}
|
|
6
4
|
function refineKeys(keys, mask) {
|
|
7
5
|
return typeof mask === 'object' && Array.isArray(mask)
|
|
8
|
-
? keys.filter(
|
|
6
|
+
? keys.filter((key) => mask.findIndex((val) => val === key) !== -1)
|
|
9
7
|
: mask
|
|
10
8
|
? keys
|
|
11
9
|
: [];
|
|
@@ -18,11 +16,11 @@ function refineKeys(keys, mask) {
|
|
|
18
16
|
*/
|
|
19
17
|
export function buildProps(fn, keys) {
|
|
20
18
|
// wrap the provided function in the standard caching layer, basing it upon the provided keys
|
|
21
|
-
|
|
19
|
+
const result = cacheStyleClosure(fn, keys);
|
|
22
20
|
// if results are being cached on keys, provide the ability to refine the function if a prop mask is specified
|
|
23
21
|
result.refine =
|
|
24
22
|
keys && keys.length > 0
|
|
25
|
-
?
|
|
23
|
+
? (mask) => {
|
|
26
24
|
return cacheStyleClosure(fn, refineKeys(keys, mask));
|
|
27
25
|
}
|
|
28
26
|
: undefined;
|
|
@@ -36,9 +34,9 @@ export function buildProps(fn, keys) {
|
|
|
36
34
|
* @param mask - prop mask to use for refinement
|
|
37
35
|
*/
|
|
38
36
|
export function refinePropsFunctions(styles, mask) {
|
|
39
|
-
|
|
40
|
-
Object.keys(styles).forEach(
|
|
41
|
-
|
|
37
|
+
const result = {};
|
|
38
|
+
Object.keys(styles).forEach((key) => {
|
|
39
|
+
const refine = typeof styles[key] === 'function' && styles[key].refine;
|
|
42
40
|
result[key] = refine ? refine(mask) : styles[key];
|
|
43
41
|
});
|
|
44
42
|
return result;
|
package/lib/buildProps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":"AA4CA,SAAS,iBAAiB,CACxB,EAA8C,EAC9C,IAAwB;IAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":"AA4CA,SAAS,iBAAiB,CACxB,EAA8C,EAC9C,IAAwB;IAExB,OAAO,CAAC,MAAe,EAAE,KAAa,EAAE,KAA2B,EAAE,EAAE,CACrE,KAAK,CACH,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EACvB,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CACvC,CAAC,CAAC,CAAC,CAAC;AACT,CAAC;AAED,SAAS,UAAU,CAAU,IAAuB,EAAE,IAAsC;IAC1F,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACpD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,EAA8C,EAC9C,IAAwB;IAExB,6FAA6F;IAC7F,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAE3C,8GAA8G;IAC9G,MAAM,CAAC,MAAM;QACX,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,CAAC,IAAsC,EAAE,EAAE;gBACzC,OAAO,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IAEhB,+DAA+D;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAmD,EACnD,IAAqC;IAErC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,MAAM,GACV,OAAO,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,32 +1,35 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { getMemoCache } from '@fluentui-react-native/memo-cache';
|
|
3
2
|
import { buildProps } from './buildProps';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const theme = { foo: 'foo', bar: 'bar' };
|
|
4
|
+
let instanceCount = 0;
|
|
6
5
|
function munge(tokens, theme) {
|
|
7
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
...theme,
|
|
8
|
+
...tokens,
|
|
9
|
+
instance: instanceCount++,
|
|
10
|
+
};
|
|
8
11
|
}
|
|
9
|
-
describe('props function tests',
|
|
10
|
-
test('basic build props function caches as expected',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
describe('props function tests', () => {
|
|
13
|
+
test('basic build props function caches as expected', () => {
|
|
14
|
+
const cache = getMemoCache();
|
|
15
|
+
const styleFn = buildProps(munge, ['a', 'b']);
|
|
16
|
+
const p1 = styleFn({ a: 'a', b: 'b', c: 'c' }, theme, cache);
|
|
14
17
|
expect(styleFn({ a: 'a', b: 'b', c: 'foo' }, theme, cache)).toBe(p1);
|
|
15
|
-
|
|
18
|
+
const p2 = styleFn({ a: 'b', b: 'b' }, theme, cache);
|
|
16
19
|
expect(p2).not.toBe(p1);
|
|
17
20
|
expect(styleFn({ a: 'b', b: 'b', c: 'bar' }, theme, cache)).toBe(p2);
|
|
18
21
|
});
|
|
19
|
-
test('build props function refinement works with explicit keys',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
test('build props function refinement works with explicit keys', () => {
|
|
23
|
+
const cache = getMemoCache();
|
|
24
|
+
const styleFn = buildProps(munge, ['a', 'b', 'c', 'd']);
|
|
25
|
+
const refinedFn = styleFn.refine(['a', 'b']);
|
|
26
|
+
const t1 = { a: 'a', b: 'b', c: 'c', d: 'd' };
|
|
27
|
+
const t2 = { a: 'a', b: 'b', c: 'foo', d: 'bar' };
|
|
28
|
+
const p1 = styleFn(t1, theme, cache);
|
|
29
|
+
const p2 = styleFn(t2, theme, cache);
|
|
27
30
|
expect(p2).not.toBe(p1);
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
const rp1 = refinedFn(t1, theme, cache);
|
|
32
|
+
const rp2 = refinedFn(t2, theme, cache);
|
|
30
33
|
expect(rp2).toBe(rp1);
|
|
31
34
|
});
|
|
32
35
|
});
|
|
@@ -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;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,MAAM,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,OAAO;QACL,GAAG,KAAK;QACR,GAAG,MAAM;QACT,QAAQ,EAAE,aAAa,EAAE;KAC1B,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACzD,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9C,MAAM,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,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrE,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACrD,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,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,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/buildUseStyling.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __spreadArray } from "tslib";
|
|
2
1
|
import { applyPropsToTokens, applyTokenLayers, buildUseTokens } from '@fluentui-react-native/use-tokens';
|
|
3
2
|
import { refinePropsFunctions } from './buildProps';
|
|
4
3
|
/**
|
|
@@ -10,9 +9,9 @@ import { refinePropsFunctions } from './buildProps';
|
|
|
10
9
|
* @param cache - cache to use for the base of slot caching
|
|
11
10
|
*/
|
|
12
11
|
function resolveToSlotProps(styles, tokens, theme, cache) {
|
|
13
|
-
|
|
14
|
-
Object.keys(styles).forEach(
|
|
15
|
-
|
|
12
|
+
const slotProps = {};
|
|
13
|
+
Object.keys(styles).forEach((key) => {
|
|
14
|
+
const style = styles[key];
|
|
16
15
|
slotProps[key] = typeof style === 'function' ? style(tokens, theme, cache(null, [key])[1]) : style;
|
|
17
16
|
});
|
|
18
17
|
return slotProps;
|
|
@@ -25,26 +24,25 @@ function resolveToSlotProps(styles, tokens, theme, cache) {
|
|
|
25
24
|
*/
|
|
26
25
|
export function buildUseStyling(options, themeHelper) {
|
|
27
26
|
// create a cache instance for this use styling implementation
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
33
|
-
var _a, _b;
|
|
27
|
+
const { useTheme, getComponentInfo } = themeHelper;
|
|
28
|
+
const { tokens, tokensThatAreAlsoProps: tokenProps } = options;
|
|
29
|
+
const styles = refinePropsFunctions(options.slotProps || {}, tokenProps);
|
|
30
|
+
const useTokens = buildUseTokens(getComponentInfo, ...tokens);
|
|
31
|
+
return (props, lookup) => {
|
|
34
32
|
// query the theme
|
|
35
|
-
|
|
33
|
+
const theme = useTheme();
|
|
36
34
|
// get the merged tokens from the theme
|
|
37
|
-
|
|
35
|
+
let [mergedTokens, cache] = useTokens(theme);
|
|
38
36
|
// resolve overrides as appropriate
|
|
39
37
|
if (options.states) {
|
|
40
|
-
|
|
38
|
+
[mergedTokens, cache] = applyTokenLayers(mergedTokens, options.states, cache, lookup || ((val) => props[val]));
|
|
41
39
|
}
|
|
42
40
|
// now resolve tokens
|
|
43
41
|
if (typeof tokenProps === 'object' && Array.isArray(tokenProps)) {
|
|
44
|
-
|
|
42
|
+
[mergedTokens, cache] = applyPropsToTokens(props, mergedTokens, cache, tokenProps);
|
|
45
43
|
}
|
|
46
44
|
else if (tokenProps === 'all') {
|
|
47
|
-
mergedTokens =
|
|
45
|
+
mergedTokens = { ...mergedTokens, ...props };
|
|
48
46
|
}
|
|
49
47
|
// finally produce slotProps from calling the style functions on each entry
|
|
50
48
|
return resolveToSlotProps(styles, mergedTokens, theme, cache);
|
|
@@ -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":"AAEA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGzG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAiDpD;;;;;;;GAOG;AACH,SAAS,kBAAkB,CACzB,MAAmD,EACnD,MAAe,EACf,KAAa,EACb,KAA4B;IAE5B,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CA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G,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,EAAE,CAAC;SAC9C;QAED,2EAA2E;QAC3E,OAAO,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { getMemoCache } from '@fluentui-react-native/memo-cache';
|
|
3
2
|
import { buildProps } from './buildProps';
|
|
4
3
|
import { buildUseStyling } from './buildUseStyling';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let lastInstance = 0;
|
|
5
|
+
const baseTokens = {
|
|
7
6
|
a: 'a-base',
|
|
8
7
|
b: 'b-base',
|
|
9
8
|
c: 'c-base',
|
|
@@ -14,7 +13,7 @@ var baseTokens = {
|
|
|
14
13
|
c: 'c-base-press',
|
|
15
14
|
},
|
|
16
15
|
};
|
|
17
|
-
|
|
16
|
+
const defaultTheme = {
|
|
18
17
|
vals: {
|
|
19
18
|
foo: 'foo',
|
|
20
19
|
bar: 'bar',
|
|
@@ -30,32 +29,38 @@ var defaultTheme = {
|
|
|
30
29
|
},
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
useTheme:
|
|
35
|
-
getComponentInfo:
|
|
32
|
+
const themeHelper = {
|
|
33
|
+
useTheme: () => defaultTheme,
|
|
34
|
+
getComponentInfo: (theme, name) => theme.components[name],
|
|
36
35
|
};
|
|
37
|
-
|
|
36
|
+
const slotFn1 = (tokens, theme) => {
|
|
38
37
|
return {
|
|
39
|
-
style:
|
|
38
|
+
style: {
|
|
39
|
+
a: tokens.a,
|
|
40
|
+
b: tokens.b,
|
|
41
|
+
c: tokens.c,
|
|
42
|
+
...theme.vals,
|
|
43
|
+
instance: lastInstance++,
|
|
44
|
+
},
|
|
40
45
|
};
|
|
41
46
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return extraCache(
|
|
47
|
+
const extraCache = getMemoCache();
|
|
48
|
+
const slotFn2 = (tokens) => {
|
|
49
|
+
return extraCache(() => ({
|
|
45
50
|
style: {
|
|
46
51
|
a: tokens.a,
|
|
47
52
|
b: tokens.b,
|
|
48
53
|
instance: lastInstance++,
|
|
49
54
|
},
|
|
50
|
-
})
|
|
55
|
+
}), [tokens.a, tokens.b])[0];
|
|
51
56
|
};
|
|
52
|
-
|
|
57
|
+
const baseOptions = {
|
|
53
58
|
tokens: [
|
|
54
59
|
baseTokens,
|
|
55
60
|
'uno',
|
|
56
|
-
|
|
61
|
+
(theme) => ({
|
|
57
62
|
b: theme.vals.foo,
|
|
58
|
-
})
|
|
63
|
+
}),
|
|
59
64
|
],
|
|
60
65
|
states: ['hover', 'press'],
|
|
61
66
|
slotProps: {
|
|
@@ -69,12 +74,12 @@ var baseOptions = {
|
|
|
69
74
|
},
|
|
70
75
|
tokensThatAreAlsoProps: ['b'],
|
|
71
76
|
};
|
|
72
|
-
describe('useStyling test suite',
|
|
73
|
-
test('basic built hook',
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Object.keys(slotProps).forEach(
|
|
77
|
+
describe('useStyling test suite', () => {
|
|
78
|
+
test('basic built hook', () => {
|
|
79
|
+
const useStyling = buildUseStyling(baseOptions, themeHelper);
|
|
80
|
+
const slotProps = useStyling({});
|
|
81
|
+
const slotProps2 = useStyling({ p1: 2, p2: 'bar' });
|
|
82
|
+
Object.keys(slotProps).forEach((key) => {
|
|
78
83
|
expect(slotProps[key]).toBe(slotProps2[key]);
|
|
79
84
|
});
|
|
80
85
|
});
|
|
@@ -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,YAAY,EAAE,MAAM,mCA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AC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __spreadArray } from "tslib";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { Text, View } from 'react-native';
|
|
4
3
|
import * as renderer from 'react-test-renderer';
|
|
@@ -7,7 +6,7 @@ import { buildUseStyling } from './buildUseStyling';
|
|
|
7
6
|
/**
|
|
8
7
|
* The default/base theme just contains base values
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
const baseTheme = {
|
|
11
10
|
globals: {
|
|
12
11
|
backgroundColor: 'white',
|
|
13
12
|
color: 'black',
|
|
@@ -17,20 +16,20 @@ var baseTheme = {
|
|
|
17
16
|
},
|
|
18
17
|
components: {},
|
|
19
18
|
};
|
|
20
|
-
|
|
19
|
+
const current = { theme: baseTheme };
|
|
21
20
|
/**
|
|
22
21
|
* Because the buildUseStyling utility is not opinionated about theming, the theming is injected via
|
|
23
22
|
* a theme helper implementation. This allows for a framework to build an opinionated version with
|
|
24
23
|
* whatever system they desire
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
useTheme:
|
|
28
|
-
getComponentInfo:
|
|
29
|
-
setActive:
|
|
30
|
-
current.theme = theme ?
|
|
25
|
+
const themeHelper = {
|
|
26
|
+
useTheme: () => current.theme,
|
|
27
|
+
getComponentInfo: (theme, name) => theme.components[name],
|
|
28
|
+
setActive: (theme) => {
|
|
29
|
+
current.theme = theme ? { ...baseTheme, ...theme } : baseTheme;
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
|
-
describe('useStyling samples',
|
|
32
|
+
describe('useStyling samples', () => {
|
|
34
33
|
/**
|
|
35
34
|
* Sample #1 - Themeable text element
|
|
36
35
|
*
|
|
@@ -38,17 +37,17 @@ describe('useStyling samples', function () {
|
|
|
38
37
|
* via theming
|
|
39
38
|
*/
|
|
40
39
|
// now create the styling hook, first the options so they can be reused later
|
|
41
|
-
|
|
40
|
+
const sample1StylingOptions = {
|
|
42
41
|
/**
|
|
43
42
|
* tell the styling hook how to build up the tokens
|
|
44
43
|
*/
|
|
45
44
|
tokens: [
|
|
46
45
|
/** first the default values should come from the global theme section */
|
|
47
|
-
|
|
46
|
+
(t) => ({
|
|
48
47
|
color: t.globals.color,
|
|
49
48
|
fontFamily: t.globals.fontFamily,
|
|
50
49
|
fontSize: t.globals.fontSize,
|
|
51
|
-
})
|
|
50
|
+
}),
|
|
52
51
|
/** next we should look for a component reference to overlay */
|
|
53
52
|
'Sample1',
|
|
54
53
|
],
|
|
@@ -61,9 +60,9 @@ describe('useStyling samples', function () {
|
|
|
61
60
|
/**
|
|
62
61
|
* first input for buildProps is a function which takes tokens and a theme and returns props
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
(tokens /*, theme: Theme */) => {
|
|
65
64
|
return {
|
|
66
|
-
style:
|
|
65
|
+
style: { ...tokens },
|
|
67
66
|
};
|
|
68
67
|
},
|
|
69
68
|
/**
|
|
@@ -74,20 +73,20 @@ describe('useStyling samples', function () {
|
|
|
74
73
|
},
|
|
75
74
|
};
|
|
76
75
|
// now build the actual hook from the options and theme helper
|
|
77
|
-
|
|
76
|
+
const useStylingSample1 = buildUseStyling(sample1StylingOptions, themeHelper);
|
|
78
77
|
// now the sample 1 component becomes simple to build, just merge the styled props with the input props
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return React.createElement(Text,
|
|
78
|
+
const Sample1Text = (props) => {
|
|
79
|
+
const styledProps = useStylingSample1(props).content;
|
|
80
|
+
const merged = { ...props, ...styledProps };
|
|
81
|
+
return React.createElement(Text, { ...merged }, props.children);
|
|
83
82
|
};
|
|
84
83
|
/** first render the component with no updates */
|
|
85
|
-
it('Sample1Text rendering with no overrides',
|
|
86
|
-
|
|
84
|
+
it('Sample1Text rendering with no overrides', () => {
|
|
85
|
+
const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1a")).toJSON();
|
|
87
86
|
expect(tree).toMatchSnapshot();
|
|
88
87
|
});
|
|
89
88
|
/** now re-theme the component via the components in the theme */
|
|
90
|
-
it('Sample1Text rendering with some custom settings in the theme',
|
|
89
|
+
it('Sample1Text rendering with some custom settings in the theme', () => {
|
|
91
90
|
themeHelper.setActive({
|
|
92
91
|
components: {
|
|
93
92
|
Sample1: {
|
|
@@ -96,14 +95,23 @@ describe('useStyling samples', function () {
|
|
|
96
95
|
},
|
|
97
96
|
},
|
|
98
97
|
});
|
|
99
|
-
|
|
98
|
+
const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1b")).toJSON();
|
|
100
99
|
expect(tree).toMatchSnapshot();
|
|
101
100
|
});
|
|
102
101
|
/**
|
|
103
102
|
* Build the styling hook for sample2. Because this isn't being recombined this is being specified inline rather
|
|
104
103
|
* than using a separate options object. Both are fine.
|
|
105
104
|
*/
|
|
106
|
-
|
|
105
|
+
const useStylingSample2 = buildUseStyling({
|
|
106
|
+
/**
|
|
107
|
+
* This just starts with the baseline styling from sample1, in particular we are using the recipes of how to turn
|
|
108
|
+
* token values into the props for the internal sub-components. While this example is not super complex, for real-world
|
|
109
|
+
* components, re-using these can be extremely valuable.
|
|
110
|
+
*
|
|
111
|
+
* With that in mind, this copies over the recipes for how to turn tokens into props, the customizations that
|
|
112
|
+
* will be made are about how to ensure the tokens are set up correctly.
|
|
113
|
+
*/
|
|
114
|
+
...sample1StylingOptions,
|
|
107
115
|
/**
|
|
108
116
|
* In sample1 tokens are set to defaults from the global theme section, then patched with any values looked up with
|
|
109
117
|
* the string 'Sample1'
|
|
@@ -115,7 +123,7 @@ describe('useStyling samples', function () {
|
|
|
115
123
|
* 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
|
|
116
124
|
* that could be filtered out of the array that is being copied
|
|
117
125
|
*/
|
|
118
|
-
tokens:
|
|
126
|
+
tokens: [...sample1StylingOptions.tokens, 'Sample2'],
|
|
119
127
|
/**
|
|
120
128
|
* This is the final bit of magic. The tokens will already have values set from the global theme, they will then be patched with
|
|
121
129
|
* any customizations set into Sample1 and/or Sample2.
|
|
@@ -124,20 +132,21 @@ describe('useStyling samples', function () {
|
|
|
124
132
|
* the component props we add a list of the props which need to be passed into tokens. If all props should be spread into the
|
|
125
133
|
* tokens then this value can be set to 'all'. If none should be passed it can be omitted or set to 'none'
|
|
126
134
|
*/
|
|
127
|
-
tokensThatAreAlsoProps: ['color']
|
|
135
|
+
tokensThatAreAlsoProps: ['color'],
|
|
136
|
+
}, themeHelper);
|
|
128
137
|
// the Sample2Text component is built the same way as sample1, just using the new hook that has been created
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
const Sample2Text = (props) => {
|
|
139
|
+
const styledProps = useStylingSample2(props).content;
|
|
140
|
+
const merged = { ...props, ...styledProps };
|
|
132
141
|
// delete the color key to not pass it through to the text props, could be done via destructuring, filtering, or any number of ways
|
|
133
142
|
delete merged.color;
|
|
134
143
|
// render the text
|
|
135
|
-
return React.createElement(Text,
|
|
144
|
+
return React.createElement(Text, { ...merged }, props.children);
|
|
136
145
|
};
|
|
137
146
|
/** rendering the Sample2 component with the base theme */
|
|
138
|
-
it('Sample2Text rendering with defaults and a color override',
|
|
147
|
+
it('Sample2Text rendering with defaults and a color override', () => {
|
|
139
148
|
themeHelper.setActive();
|
|
140
|
-
|
|
149
|
+
const tree = renderer
|
|
141
150
|
.create(React.createElement(View, null,
|
|
142
151
|
React.createElement(Sample2Text, null, "Sample2 with defaults"),
|
|
143
152
|
React.createElement(Sample2Text, { color: "green" }, "Sample2 with color override via prop")))
|
|
@@ -145,7 +154,7 @@ describe('useStyling samples', function () {
|
|
|
145
154
|
expect(tree).toMatchSnapshot();
|
|
146
155
|
});
|
|
147
156
|
/** now re-theme the component via the components in the theme */
|
|
148
|
-
it('Sample2Text rendering with some custom settings in the theme',
|
|
157
|
+
it('Sample2Text rendering with some custom settings in the theme', () => {
|
|
149
158
|
themeHelper.setActive({
|
|
150
159
|
components: {
|
|
151
160
|
Sample1: {
|
|
@@ -158,7 +167,7 @@ describe('useStyling samples', function () {
|
|
|
158
167
|
},
|
|
159
168
|
},
|
|
160
169
|
});
|
|
161
|
-
|
|
170
|
+
const tree = renderer
|
|
162
171
|
.create(React.createElement(View, null,
|
|
163
172
|
React.createElement(Sample2Text, null, "Sample2 with theme overrides set"),
|
|
164
173
|
React.createElement(Sample2Text, { color: "purple" }, "Sample2 with theme and color prop override")))
|
|
@@ -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,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAuBpD;;GAEG;AACH,MAAM,SAAS,GAAU;IACvB,OAAO,EAAE;QACP,eAAe,EAAE,OAAO;QACxB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,EAAE;KACb;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAErC;;;;GAIG;AACH,MAAM,WAAW,GAAyE;IACxF,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK;IAC7B,gBAAgB,EAAE,CAAC,KAAY,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IACxE,SAAS,EAAE,CAAC,KAAsB,EAAE,EAAE;QACpC,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DAA0D;IAC1D,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,WAAW,CAAC,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,IAAI;YACH,oBAAC,WAAW,gCAAoC;YAChD,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO,2CAAmD,CACxE,CACR;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,iEAAiE;IACjE,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,WAAW,CAAC,SAAS,CAAC;YACpB,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,KAAK,EAAE,MAAM;oBACb,QAAQ,EAAE,EAAE;iBACb;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE,EAAE;oBACZ,UAAU,EAAE,WAAW;iBACxB;aACF;SACF,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,IAAI;YACH,oBAAC,WAAW,2CAA+C;YAC3D,oBAAC,WAAW,IAAC,KAAK,EAAC,QAAQ,iDAAyD,CAC/E,CACR;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.refinePropsFunctions = exports.buildProps = void 0;
|
|
4
4
|
function cacheStyleClosure(fn, keys) {
|
|
5
|
-
return
|
|
6
|
-
return cache(function () { return fn(tokens, theme); }, (keys || []).map(function (key) { return tokens[key]; }))[0];
|
|
7
|
-
};
|
|
5
|
+
return (tokens, theme, cache) => cache(() => fn(tokens, theme), (keys || []).map((key) => tokens[key]))[0];
|
|
8
6
|
}
|
|
9
7
|
function refineKeys(keys, mask) {
|
|
10
8
|
return typeof mask === 'object' && Array.isArray(mask)
|
|
11
|
-
? keys.filter(
|
|
9
|
+
? keys.filter((key) => mask.findIndex((val) => val === key) !== -1)
|
|
12
10
|
: mask
|
|
13
11
|
? keys
|
|
14
12
|
: [];
|
|
@@ -21,11 +19,11 @@ function refineKeys(keys, mask) {
|
|
|
21
19
|
*/
|
|
22
20
|
function buildProps(fn, keys) {
|
|
23
21
|
// wrap the provided function in the standard caching layer, basing it upon the provided keys
|
|
24
|
-
|
|
22
|
+
const result = cacheStyleClosure(fn, keys);
|
|
25
23
|
// if results are being cached on keys, provide the ability to refine the function if a prop mask is specified
|
|
26
24
|
result.refine =
|
|
27
25
|
keys && keys.length > 0
|
|
28
|
-
?
|
|
26
|
+
? (mask) => {
|
|
29
27
|
return cacheStyleClosure(fn, refineKeys(keys, mask));
|
|
30
28
|
}
|
|
31
29
|
: undefined;
|
|
@@ -40,9 +38,9 @@ exports.buildProps = buildProps;
|
|
|
40
38
|
* @param mask - prop mask to use for refinement
|
|
41
39
|
*/
|
|
42
40
|
function refinePropsFunctions(styles, mask) {
|
|
43
|
-
|
|
44
|
-
Object.keys(styles).forEach(
|
|
45
|
-
|
|
41
|
+
const result = {};
|
|
42
|
+
Object.keys(styles).forEach((key) => {
|
|
43
|
+
const refine = typeof styles[key] === 'function' && styles[key].refine;
|
|
46
44
|
result[key] = refine ? refine(mask) : styles[key];
|
|
47
45
|
});
|
|
48
46
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":";;;AA4CA,SAAS,iBAAiB,CACxB,EAA8C,EAC9C,IAAwB;IAExB,OAAO,
|
|
1
|
+
{"version":3,"file":"buildProps.js","sourceRoot":"","sources":["../src/buildProps.ts"],"names":[],"mappings":";;;AA4CA,SAAS,iBAAiB,CACxB,EAA8C,EAC9C,IAAwB;IAExB,OAAO,CAAC,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,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,MAAM,GACV,OAAO,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;AAXD,oDAWC"}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var instanceCount = 0;
|
|
3
|
+
const memo_cache_1 = require("@fluentui-react-native/memo-cache");
|
|
4
|
+
const buildProps_1 = require("./buildProps");
|
|
5
|
+
const theme = { foo: 'foo', bar: 'bar' };
|
|
6
|
+
let instanceCount = 0;
|
|
8
7
|
function munge(tokens, theme) {
|
|
9
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...theme,
|
|
10
|
+
...tokens,
|
|
11
|
+
instance: instanceCount++,
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
|
-
describe('props function tests',
|
|
12
|
-
test('basic build props function caches as expected',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
describe('props function tests', () => {
|
|
15
|
+
test('basic build props function caches as expected', () => {
|
|
16
|
+
const cache = (0, memo_cache_1.getMemoCache)();
|
|
17
|
+
const styleFn = (0, buildProps_1.buildProps)(munge, ['a', 'b']);
|
|
18
|
+
const p1 = styleFn({ a: 'a', b: 'b', c: 'c' }, theme, cache);
|
|
16
19
|
expect(styleFn({ a: 'a', b: 'b', c: 'foo' }, theme, cache)).toBe(p1);
|
|
17
|
-
|
|
20
|
+
const p2 = styleFn({ a: 'b', b: 'b' }, theme, cache);
|
|
18
21
|
expect(p2).not.toBe(p1);
|
|
19
22
|
expect(styleFn({ a: 'b', b: 'b', c: 'bar' }, theme, cache)).toBe(p2);
|
|
20
23
|
});
|
|
21
|
-
test('build props function refinement works with explicit keys',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
test('build props function refinement works with explicit keys', () => {
|
|
25
|
+
const cache = (0, memo_cache_1.getMemoCache)();
|
|
26
|
+
const styleFn = (0, buildProps_1.buildProps)(munge, ['a', 'b', 'c', 'd']);
|
|
27
|
+
const refinedFn = styleFn.refine(['a', 'b']);
|
|
28
|
+
const t1 = { a: 'a', b: 'b', c: 'c', d: 'd' };
|
|
29
|
+
const t2 = { a: 'a', b: 'b', c: 'foo', d: 'bar' };
|
|
30
|
+
const p1 = styleFn(t1, theme, cache);
|
|
31
|
+
const p2 = styleFn(t2, theme, cache);
|
|
29
32
|
expect(p2).not.toBe(p1);
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
const rp1 = refinedFn(t1, theme, cache);
|
|
34
|
+
const rp2 = refinedFn(t2, theme, cache);
|
|
32
35
|
expect(rp2).toBe(rp1);
|
|
33
36
|
});
|
|
34
37
|
});
|
|
@@ -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,kEAAiE;AAEjE,6CAA0C;AAM1C,MAAM,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,OAAO;QACL,GA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AG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;QAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;QAElD,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAExB,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACxC,MAAM,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"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildUseStyling = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var buildProps_1 = require("./buildProps");
|
|
4
|
+
const use_tokens_1 = require("@fluentui-react-native/use-tokens");
|
|
5
|
+
const buildProps_1 = require("./buildProps");
|
|
7
6
|
/**
|
|
8
7
|
* Produce the final slot props for the styled hook
|
|
9
8
|
*
|
|
@@ -13,9 +12,9 @@ var buildProps_1 = require("./buildProps");
|
|
|
13
12
|
* @param cache - cache to use for the base of slot caching
|
|
14
13
|
*/
|
|
15
14
|
function resolveToSlotProps(styles, tokens, theme, cache) {
|
|
16
|
-
|
|
17
|
-
Object.keys(styles).forEach(
|
|
18
|
-
|
|
15
|
+
const slotProps = {};
|
|
16
|
+
Object.keys(styles).forEach((key) => {
|
|
17
|
+
const style = styles[key];
|
|
19
18
|
slotProps[key] = typeof style === 'function' ? style(tokens, theme, cache(null, [key])[1]) : style;
|
|
20
19
|
});
|
|
21
20
|
return slotProps;
|
|
@@ -28,26 +27,25 @@ function resolveToSlotProps(styles, tokens, theme, cache) {
|
|
|
28
27
|
*/
|
|
29
28
|
function buildUseStyling(options, themeHelper) {
|
|
30
29
|
// create a cache instance for this use styling implementation
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
var _a, _b;
|
|
30
|
+
const { useTheme, getComponentInfo } = themeHelper;
|
|
31
|
+
const { tokens, tokensThatAreAlsoProps: tokenProps } = options;
|
|
32
|
+
const styles = (0, buildProps_1.refinePropsFunctions)(options.slotProps || {}, tokenProps);
|
|
33
|
+
const useTokens = (0, use_tokens_1.buildUseTokens)(getComponentInfo, ...tokens);
|
|
34
|
+
return (props, lookup) => {
|
|
37
35
|
// query the theme
|
|
38
|
-
|
|
36
|
+
const theme = useTheme();
|
|
39
37
|
// get the merged tokens from the theme
|
|
40
|
-
|
|
38
|
+
let [mergedTokens, cache] = useTokens(theme);
|
|
41
39
|
// resolve overrides as appropriate
|
|
42
40
|
if (options.states) {
|
|
43
|
-
|
|
41
|
+
[mergedTokens, cache] = (0, use_tokens_1.applyTokenLayers)(mergedTokens, options.states, cache, lookup || ((val) => props[val]));
|
|
44
42
|
}
|
|
45
43
|
// now resolve tokens
|
|
46
44
|
if (typeof tokenProps === 'object' && Array.isArray(tokenProps)) {
|
|
47
|
-
|
|
45
|
+
[mergedTokens, cache] = (0, use_tokens_1.applyPropsToTokens)(props, mergedTokens, cache, tokenProps);
|
|
48
46
|
}
|
|
49
47
|
else if (tokenProps === 'all') {
|
|
50
|
-
mergedTokens =
|
|
48
|
+
mergedTokens = { ...mergedTokens, ...props };
|
|
51
49
|
}
|
|
52
50
|
// finally produce slotProps from calling the style functions on each entry
|
|
53
51
|
return resolveToSlotProps(styles, mergedTokens, theme, cache);
|
|
@@ -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":";;;AAEA,kEAAyG;AAGzG,6CAAoD;AAiDpD;;;;;;;GAOG;AACH,SAAS,kBAAkB,CACzB,MAAmD,EACnD,MAAe,EACf,KAAa,EACb,KAA4B;IAE5B,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACrG,CAAC,CAAC,CAAC;IACH,OAAO,SAAuB,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,OAA+D,EAC/D,WAAgC;IAEhC,8DAA8D;IAC9D,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,UAAU,EAAE,GAAG,OAAO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|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var baseTokens = {
|
|
3
|
+
const memo_cache_1 = require("@fluentui-react-native/memo-cache");
|
|
4
|
+
const buildProps_1 = require("./buildProps");
|
|
5
|
+
const buildUseStyling_1 = require("./buildUseStyling");
|
|
6
|
+
let lastInstance = 0;
|
|
7
|
+
const baseTokens = {
|
|
9
8
|
a: 'a-base',
|
|
10
9
|
b: 'b-base',
|
|
11
10
|
c: 'c-base',
|
|
@@ -16,7 +15,7 @@ var baseTokens = {
|
|
|
16
15
|
c: 'c-base-press',
|
|
17
16
|
},
|
|
18
17
|
};
|
|
19
|
-
|
|
18
|
+
const defaultTheme = {
|
|
20
19
|
vals: {
|
|
21
20
|
foo: 'foo',
|
|
22
21
|
bar: 'bar',
|
|
@@ -32,32 +31,38 @@ var defaultTheme = {
|
|
|
32
31
|
},
|
|
33
32
|
},
|
|
34
33
|
};
|
|
35
|
-
|
|
36
|
-
useTheme:
|
|
37
|
-
getComponentInfo:
|
|
34
|
+
const themeHelper = {
|
|
35
|
+
useTheme: () => defaultTheme,
|
|
36
|
+
getComponentInfo: (theme, name) => theme.components[name],
|
|
38
37
|
};
|
|
39
|
-
|
|
38
|
+
const slotFn1 = (tokens, theme) => {
|
|
40
39
|
return {
|
|
41
|
-
style:
|
|
40
|
+
style: {
|
|
41
|
+
a: tokens.a,
|
|
42
|
+
b: tokens.b,
|
|
43
|
+
c: tokens.c,
|
|
44
|
+
...theme.vals,
|
|
45
|
+
instance: lastInstance++,
|
|
46
|
+
},
|
|
42
47
|
};
|
|
43
48
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return extraCache(
|
|
49
|
+
const extraCache = (0, memo_cache_1.getMemoCache)();
|
|
50
|
+
const slotFn2 = (tokens) => {
|
|
51
|
+
return extraCache(() => ({
|
|
47
52
|
style: {
|
|
48
53
|
a: tokens.a,
|
|
49
54
|
b: tokens.b,
|
|
50
55
|
instance: lastInstance++,
|
|
51
56
|
},
|
|
52
|
-
})
|
|
57
|
+
}), [tokens.a, tokens.b])[0];
|
|
53
58
|
};
|
|
54
|
-
|
|
59
|
+
const baseOptions = {
|
|
55
60
|
tokens: [
|
|
56
61
|
baseTokens,
|
|
57
62
|
'uno',
|
|
58
|
-
|
|
63
|
+
(theme) => ({
|
|
59
64
|
b: theme.vals.foo,
|
|
60
|
-
})
|
|
65
|
+
}),
|
|
61
66
|
],
|
|
62
67
|
states: ['hover', 'press'],
|
|
63
68
|
slotProps: {
|
|
@@ -71,12 +76,12 @@ var baseOptions = {
|
|
|
71
76
|
},
|
|
72
77
|
tokensThatAreAlsoProps: ['b'],
|
|
73
78
|
};
|
|
74
|
-
describe('useStyling test suite',
|
|
75
|
-
test('basic built hook',
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Object.keys(slotProps).forEach(
|
|
79
|
+
describe('useStyling test suite', () => {
|
|
80
|
+
test('basic built hook', () => {
|
|
81
|
+
const useStyling = (0, buildUseStyling_1.buildUseStyling)(baseOptions, themeHelper);
|
|
82
|
+
const slotProps = useStyling({});
|
|
83
|
+
const slotProps2 = useStyling({ p1: 2, p2: 'bar' });
|
|
84
|
+
Object.keys(slotProps).forEach((key) => {
|
|
80
85
|
expect(slotProps[key]).toBe(slotProps2[key]);
|
|
81
86
|
});
|
|
82
87
|
});
|
|
@@ -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,kEAAiE;AAEjE,6CAA0C;AAE1C,uDAAoD;AAEpD,IAAI,YAAY,GAAG,CAAC,CAAC;AAUrB,MAAM,UAAU,GAAW;IACzB,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,KAAK,E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");
|
|
4
|
+
const React = tslib_1.__importStar(require("react"));
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const renderer = tslib_1.__importStar(require("react-test-renderer"));
|
|
7
|
+
const buildProps_1 = require("./buildProps");
|
|
8
|
+
const buildUseStyling_1 = require("./buildUseStyling");
|
|
9
9
|
/**
|
|
10
10
|
* The default/base theme just contains base values
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const baseTheme = {
|
|
13
13
|
globals: {
|
|
14
14
|
backgroundColor: 'white',
|
|
15
15
|
color: 'black',
|
|
@@ -19,20 +19,20 @@ var baseTheme = {
|
|
|
19
19
|
},
|
|
20
20
|
components: {},
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
const current = { theme: baseTheme };
|
|
23
23
|
/**
|
|
24
24
|
* Because the buildUseStyling utility is not opinionated about theming, the theming is injected via
|
|
25
25
|
* a theme helper implementation. This allows for a framework to build an opinionated version with
|
|
26
26
|
* whatever system they desire
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
|
-
useTheme:
|
|
30
|
-
getComponentInfo:
|
|
31
|
-
setActive:
|
|
32
|
-
current.theme = theme ?
|
|
28
|
+
const themeHelper = {
|
|
29
|
+
useTheme: () => current.theme,
|
|
30
|
+
getComponentInfo: (theme, name) => theme.components[name],
|
|
31
|
+
setActive: (theme) => {
|
|
32
|
+
current.theme = theme ? { ...baseTheme, ...theme } : baseTheme;
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
|
-
describe('useStyling samples',
|
|
35
|
+
describe('useStyling samples', () => {
|
|
36
36
|
/**
|
|
37
37
|
* Sample #1 - Themeable text element
|
|
38
38
|
*
|
|
@@ -40,17 +40,17 @@ describe('useStyling samples', function () {
|
|
|
40
40
|
* via theming
|
|
41
41
|
*/
|
|
42
42
|
// now create the styling hook, first the options so they can be reused later
|
|
43
|
-
|
|
43
|
+
const sample1StylingOptions = {
|
|
44
44
|
/**
|
|
45
45
|
* tell the styling hook how to build up the tokens
|
|
46
46
|
*/
|
|
47
47
|
tokens: [
|
|
48
48
|
/** first the default values should come from the global theme section */
|
|
49
|
-
|
|
49
|
+
(t) => ({
|
|
50
50
|
color: t.globals.color,
|
|
51
51
|
fontFamily: t.globals.fontFamily,
|
|
52
52
|
fontSize: t.globals.fontSize,
|
|
53
|
-
})
|
|
53
|
+
}),
|
|
54
54
|
/** next we should look for a component reference to overlay */
|
|
55
55
|
'Sample1',
|
|
56
56
|
],
|
|
@@ -63,9 +63,9 @@ describe('useStyling samples', function () {
|
|
|
63
63
|
/**
|
|
64
64
|
* first input for buildProps is a function which takes tokens and a theme and returns props
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
(tokens /*, theme: Theme */) => {
|
|
67
67
|
return {
|
|
68
|
-
style:
|
|
68
|
+
style: { ...tokens },
|
|
69
69
|
};
|
|
70
70
|
},
|
|
71
71
|
/**
|
|
@@ -76,20 +76,20 @@ describe('useStyling samples', function () {
|
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
78
|
// now build the actual hook from the options and theme helper
|
|
79
|
-
|
|
79
|
+
const useStylingSample1 = (0, buildUseStyling_1.buildUseStyling)(sample1StylingOptions, themeHelper);
|
|
80
80
|
// now the sample 1 component becomes simple to build, just merge the styled props with the input props
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return React.createElement(react_native_1.Text,
|
|
81
|
+
const Sample1Text = (props) => {
|
|
82
|
+
const styledProps = useStylingSample1(props).content;
|
|
83
|
+
const merged = { ...props, ...styledProps };
|
|
84
|
+
return React.createElement(react_native_1.Text, { ...merged }, props.children);
|
|
85
85
|
};
|
|
86
86
|
/** first render the component with no updates */
|
|
87
|
-
it('Sample1Text rendering with no overrides',
|
|
88
|
-
|
|
87
|
+
it('Sample1Text rendering with no overrides', () => {
|
|
88
|
+
const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1a")).toJSON();
|
|
89
89
|
expect(tree).toMatchSnapshot();
|
|
90
90
|
});
|
|
91
91
|
/** now re-theme the component via the components in the theme */
|
|
92
|
-
it('Sample1Text rendering with some custom settings in the theme',
|
|
92
|
+
it('Sample1Text rendering with some custom settings in the theme', () => {
|
|
93
93
|
themeHelper.setActive({
|
|
94
94
|
components: {
|
|
95
95
|
Sample1: {
|
|
@@ -98,14 +98,23 @@ describe('useStyling samples', function () {
|
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1b")).toJSON();
|
|
102
102
|
expect(tree).toMatchSnapshot();
|
|
103
103
|
});
|
|
104
104
|
/**
|
|
105
105
|
* Build the styling hook for sample2. Because this isn't being recombined this is being specified inline rather
|
|
106
106
|
* than using a separate options object. Both are fine.
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
const useStylingSample2 = (0, buildUseStyling_1.buildUseStyling)({
|
|
109
|
+
/**
|
|
110
|
+
* This just starts with the baseline styling from sample1, in particular we are using the recipes of how to turn
|
|
111
|
+
* token values into the props for the internal sub-components. While this example is not super complex, for real-world
|
|
112
|
+
* components, re-using these can be extremely valuable.
|
|
113
|
+
*
|
|
114
|
+
* With that in mind, this copies over the recipes for how to turn tokens into props, the customizations that
|
|
115
|
+
* will be made are about how to ensure the tokens are set up correctly.
|
|
116
|
+
*/
|
|
117
|
+
...sample1StylingOptions,
|
|
109
118
|
/**
|
|
110
119
|
* In sample1 tokens are set to defaults from the global theme section, then patched with any values looked up with
|
|
111
120
|
* the string 'Sample1'
|
|
@@ -117,7 +126,7 @@ describe('useStyling samples', function () {
|
|
|
117
126
|
* 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
|
|
118
127
|
* that could be filtered out of the array that is being copied
|
|
119
128
|
*/
|
|
120
|
-
tokens:
|
|
129
|
+
tokens: [...sample1StylingOptions.tokens, 'Sample2'],
|
|
121
130
|
/**
|
|
122
131
|
* This is the final bit of magic. The tokens will already have values set from the global theme, they will then be patched with
|
|
123
132
|
* any customizations set into Sample1 and/or Sample2.
|
|
@@ -126,20 +135,21 @@ describe('useStyling samples', function () {
|
|
|
126
135
|
* the component props we add a list of the props which need to be passed into tokens. If all props should be spread into the
|
|
127
136
|
* tokens then this value can be set to 'all'. If none should be passed it can be omitted or set to 'none'
|
|
128
137
|
*/
|
|
129
|
-
tokensThatAreAlsoProps: ['color']
|
|
138
|
+
tokensThatAreAlsoProps: ['color'],
|
|
139
|
+
}, themeHelper);
|
|
130
140
|
// the Sample2Text component is built the same way as sample1, just using the new hook that has been created
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
const Sample2Text = (props) => {
|
|
142
|
+
const styledProps = useStylingSample2(props).content;
|
|
143
|
+
const merged = { ...props, ...styledProps };
|
|
134
144
|
// delete the color key to not pass it through to the text props, could be done via destructuring, filtering, or any number of ways
|
|
135
145
|
delete merged.color;
|
|
136
146
|
// render the text
|
|
137
|
-
return React.createElement(react_native_1.Text,
|
|
147
|
+
return React.createElement(react_native_1.Text, { ...merged }, props.children);
|
|
138
148
|
};
|
|
139
149
|
/** rendering the Sample2 component with the base theme */
|
|
140
|
-
it('Sample2Text rendering with defaults and a color override',
|
|
150
|
+
it('Sample2Text rendering with defaults and a color override', () => {
|
|
141
151
|
themeHelper.setActive();
|
|
142
|
-
|
|
152
|
+
const tree = renderer
|
|
143
153
|
.create(React.createElement(react_native_1.View, null,
|
|
144
154
|
React.createElement(Sample2Text, null, "Sample2 with defaults"),
|
|
145
155
|
React.createElement(Sample2Text, { color: "green" }, "Sample2 with color override via prop")))
|
|
@@ -147,7 +157,7 @@ describe('useStyling samples', function () {
|
|
|
147
157
|
expect(tree).toMatchSnapshot();
|
|
148
158
|
});
|
|
149
159
|
/** now re-theme the component via the components in the theme */
|
|
150
|
-
it('Sample2Text rendering with some custom settings in the theme',
|
|
160
|
+
it('Sample2Text rendering with some custom settings in the theme', () => {
|
|
151
161
|
themeHelper.setActive({
|
|
152
162
|
components: {
|
|
153
163
|
Sample1: {
|
|
@@ -160,7 +170,7 @@ describe('useStyling samples', function () {
|
|
|
160
170
|
},
|
|
161
171
|
},
|
|
162
172
|
});
|
|
163
|
-
|
|
173
|
+
const tree = renderer
|
|
164
174
|
.create(React.createElement(react_native_1.View, null,
|
|
165
175
|
React.createElement(Sample2Text, null, "Sample2 with theme overrides set"),
|
|
166
176
|
React.createElement(Sample2Text, { color: "purple" }, "Sample2 with theme and color prop override")))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyling.samples.test.js","sourceRoot":"","sources":["../src/useStyling.samples.test.tsx"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useStyling.samples.test.js","sourceRoot":"","sources":["../src/useStyling.samples.test.tsx"],"names":[],"mappings":";;;AAAA,qDAA+B;AAE/B,+CAA0C;AAE1C,sEAAgD;AAEhD,6CAA0C;AAE1C,uDAAoD;AAuBpD;;GAEG;AACH,MAAM,SAAS,GAAU;IACvB,OAAO,EAAE;QACP,eAAe,EAAE,OAAO;QACxB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,EAAE;KACb;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAErC;;;;GAIG;AACH,MAAM,WAAW,GAAyE;IACxF,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK;IAC7B,gBAAgB,EAAE,CAAC,KAAY,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;IACxE,SAAS,EAAE,CAAC,KAAsB,EAAE,EAAE;QACpC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;CACF,CAAC;AAEF,QA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AAM,CACL,oBAAC,mBAAI;YACH,oBAAC,WAAW,gCAAoC;YAChD,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO,2CAAmD,CACxE,CACR;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,iEAAiE;IACjE,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,WAAW,CAAC,SAAS,CAAC;YACpB,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,KAAK,EAAE,MAAM;oBACb,QAAQ,EAAE,EAAE;iBACb;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE,EAAE;oBACZ,UAAU,EAAE,WAAW;iBACxB;aACF;SACF,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,mBAAI;YACH,oBAAC,WAAW,2CAA+C;YAC3D,oBAAC,WAAW,IAAC,KAAK,EAAC,QAAQ,iDAAyD,CAC/E,CACR;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/use-styling",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"description": "Opinionated use styling hook implementation",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
},
|
|
10
10
|
"main": "lib-commonjs/index.js",
|
|
11
11
|
"module": "lib/index.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./lib/index.js",
|
|
15
|
+
"require": "./lib-commonjs/index.js",
|
|
16
|
+
"types": "./lib/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
12
19
|
"typings": "lib/index.d.ts",
|
|
13
20
|
"scripts": {
|
|
14
21
|
"build": "fluentui-scripts build",
|
|
@@ -27,8 +34,8 @@
|
|
|
27
34
|
"author": "",
|
|
28
35
|
"license": "MIT",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"@fluentui-react-native/memo-cache": "1.3.
|
|
31
|
-
"@fluentui-react-native/use-tokens": "0.6.
|
|
37
|
+
"@fluentui-react-native/memo-cache": "1.3.4",
|
|
38
|
+
"@fluentui-react-native/use-tokens": "0.6.4",
|
|
32
39
|
"tslib": "^2.3.1"
|
|
33
40
|
},
|
|
34
41
|
"devDependencies": {
|
|
@@ -55,6 +62,7 @@
|
|
|
55
62
|
]
|
|
56
63
|
},
|
|
57
64
|
"capabilities": [
|
|
65
|
+
"babel-preset-react-native",
|
|
58
66
|
"core",
|
|
59
67
|
"core-android",
|
|
60
68
|
"core-ios",
|
package/.eslintrc.js
DELETED