@fluentui-react-native/use-slots 0.10.2 → 0.10.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 +66 -1
- package/CHANGELOG.md +18 -2
- package/eslint.config.js +3 -0
- package/lib/buildUseSlots.js +5 -9
- package/lib/buildUseSlots.js.map +1 -1
- package/lib/buildUseSlots.test.js +9 -20
- package/lib/buildUseSlots.test.js.map +1 -1
- package/lib/useSlots.samples.test.js +46 -68
- package/lib/useSlots.samples.test.js.map +1 -1
- package/lib-commonjs/buildUseSlots.js +6 -10
- package/lib-commonjs/buildUseSlots.js.map +1 -1
- package/lib-commonjs/buildUseSlots.test.js +13 -24
- package/lib-commonjs/buildUseSlots.test.js.map +1 -1
- package/lib-commonjs/useSlots.samples.test.js +50 -72
- package/lib-commonjs/useSlots.samples.test.js.map +1 -1
- package/package.json +24 -10
- package/.eslintrc.js +0 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,72 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/use-slots",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 10 Jul 2025 20:30:28 GMT",
|
|
6
|
+
"version": "0.10.4",
|
|
7
|
+
"tag": "@fluentui-react-native/use-slots_v0.10.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "ruaraki@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/use-slots",
|
|
13
|
+
"commit": "a245202877ef7f2be9ab5f0e1356b2270957e693",
|
|
14
|
+
"comment": "Run bump-versions"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "4123478+tido64@users.noreply.github.com",
|
|
18
|
+
"package": "@fluentui-react-native/use-slots",
|
|
19
|
+
"commit": "79bb06f6bbfd0a36f9d2ef371f4857be9660f027",
|
|
20
|
+
"comment": "Fixed `align-deps` warnings"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "jasonmo@microsoft.com",
|
|
24
|
+
"package": "@fluentui-react-native/use-slots",
|
|
25
|
+
"commit": "54087dca787180bbf34630470cd0d06e88366b30",
|
|
26
|
+
"comment": "update eslint to 9.x and use new flat config format with security rules"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"patch": [
|
|
30
|
+
{
|
|
31
|
+
"author": "jasonmo@microsoft.com",
|
|
32
|
+
"package": "@fluentui-react-native/use-slots",
|
|
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:14 GMT",
|
|
41
|
+
"version": "0.10.3",
|
|
42
|
+
"tag": "@fluentui-react-native/use-slots_v0.10.3",
|
|
43
|
+
"comments": {
|
|
44
|
+
"patch": [
|
|
45
|
+
{
|
|
46
|
+
"author": "4123478+tido64@users.noreply.github.com",
|
|
47
|
+
"package": "@fluentui-react-native/use-slots",
|
|
48
|
+
"commit": "24b9abab3370f008afd2dbb304751fc9af6bec4a",
|
|
49
|
+
"comment": "Add support for React Native 0.74"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"date": "Wed, 11 Jun 2025 19:34:46 GMT",
|
|
56
|
+
"version": "0.10.2",
|
|
57
|
+
"tag": "@fluentui-react-native/use-slots_v0.10.2",
|
|
58
|
+
"comments": {
|
|
59
|
+
"none": [
|
|
60
|
+
{
|
|
61
|
+
"author": "4123478+tido64@users.noreply.github.com",
|
|
62
|
+
"package": "@fluentui-react-native/use-slots",
|
|
63
|
+
"commit": "2342b87a20e5a584bd2073c8c5a266f0aa48c8bb",
|
|
64
|
+
"comment": "Added missing dev dependencies"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"date": "Wed, 29 Jan 2025 23:43:52 GMT",
|
|
6
71
|
"version": "0.10.2",
|
|
7
72
|
"tag": "@fluentui-react-native/use-slots_v0.10.2",
|
|
8
73
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/use-slots
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
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.10.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
|
+
|
|
15
|
+
## 0.10.3
|
|
16
|
+
|
|
17
|
+
Thu, 10 Jul 2025 19:20:14 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Add support for React Native 0.74 (4123478+tido64@users.noreply.github.com)
|
|
22
|
+
|
|
7
23
|
## 0.10.2
|
|
8
24
|
|
|
9
|
-
Wed, 29 Jan 2025 23:
|
|
25
|
+
Wed, 29 Jan 2025 23:43:52 GMT
|
|
10
26
|
|
|
11
27
|
### Patches
|
|
12
28
|
|
package/eslint.config.js
ADDED
package/lib/buildUseSlots.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { useSlot } from '@fluentui-react-native/use-slot';
|
|
2
2
|
export function buildUseSlots(options) {
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
var args = [];
|
|
6
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
-
args[_i] = arguments[_i];
|
|
8
|
-
}
|
|
3
|
+
const { slots, filters = {}, useStyling } = options;
|
|
4
|
+
return (...args) => {
|
|
9
5
|
// get the baseline slot props to render with the slots
|
|
10
6
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11
|
-
|
|
7
|
+
const slotProps = typeof useStyling === 'function' ? useStyling(...args) : (useStyling || {});
|
|
12
8
|
// build up a set of slots closures and store them in props
|
|
13
|
-
|
|
9
|
+
const builtSlots = {};
|
|
14
10
|
// for each slot go through and either cache the slot props or call part one render if it is staged
|
|
15
|
-
Object.keys(slots).forEach(
|
|
11
|
+
Object.keys(slots).forEach((slotName) => {
|
|
16
12
|
builtSlots[slotName] = useSlot(slots[slotName], slotProps[slotName], filters[slotName]);
|
|
17
13
|
});
|
|
18
14
|
// return the prebuilt closures, these will have internal references to state.results
|
package/lib/buildUseSlots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseSlots.js","sourceRoot":"","sources":["../src/buildUseSlots.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAgB1D,MAAM,UAAU,aAAa,CAAa,OAAmC;
|
|
1
|
+
{"version":3,"file":"buildUseSlots.js","sourceRoot":"","sources":["../src/buildUseSlots.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAgB1D,MAAM,UAAU,aAAa,CAAa,OAAmC;IAC3E,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACpD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,uDAAuD;QACvD,wDAAwD;QACxD,MAAM,SAAS,GAAe,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAE,UAAuB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,UAAU,IAAI,EAAE,CAAgB,CAAC;QAExI,2DAA2D;QAC3D,MAAM,UAAU,GAAsB,EAAuB,CAAC;QAE9D,mGAAmG;QACnG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACtC,UAAU,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QAEH,qFAAqF;QACrF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { View, Text } from 'react-native';
|
|
13
2
|
import { withSlots, stagedComponent } from '@fluentui-react-native/use-slot';
|
|
14
3
|
import * as renderer from 'react-test-renderer';
|
|
15
4
|
import { buildUseSlots } from './buildUseSlots';
|
|
16
|
-
|
|
5
|
+
const useSlotsBase = buildUseSlots({
|
|
17
6
|
slots: {
|
|
18
7
|
outer: View,
|
|
19
8
|
inner: View,
|
|
20
9
|
content: Text,
|
|
21
10
|
},
|
|
22
11
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
return (withSlots(Slots.outer,
|
|
12
|
+
const CompBase = stagedComponent((props) => {
|
|
13
|
+
const Slots = useSlotsBase(props);
|
|
14
|
+
return (extra) => {
|
|
15
|
+
const merged = { ...props, ...extra };
|
|
16
|
+
return (withSlots(Slots.outer, { ...merged },
|
|
28
17
|
withSlots(Slots.inner, { style: { backgroundColor: 'blue', width: 20, height: 10 } },
|
|
29
18
|
withSlots(Slots.content, null, "Hello"))));
|
|
30
19
|
};
|
|
31
20
|
});
|
|
32
|
-
describe('buildUseSlots test suite',
|
|
33
|
-
it('Simple component render',
|
|
34
|
-
|
|
21
|
+
describe('buildUseSlots test suite', () => {
|
|
22
|
+
it('Simple component render', () => {
|
|
23
|
+
const tree = renderer.create(withSlots(CompBase, { style: { width: 30, height: 20, borderColor: 'green', borderWidth: 1 } })).toJSON();
|
|
35
24
|
expect(tree).toMatchSnapshot();
|
|
36
25
|
});
|
|
37
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseSlots.test.js","sourceRoot":"","sources":["../src/buildUseSlots.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildUseSlots.test.js","sourceRoot":"","sources":["../src/buildUseSlots.test.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,MAAM,YAAY,GAAG,aAAa,CAAa;IAC7C,KAAK,EAAE;QACL,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,KAAgB,EAAE,EAAE;IACpD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,CAAC,KAAgB,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;QACtC,OAAO,CACL,UAAC,KAAK,CAAC,KAAK,OAAK,MAAM;YACrB,UAAC,KAAK,CAAC,KAAK,IAAC,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBACpE,UAAC,KAAK,CAAC,OAAO,gBAAsB,CACxB,CACF,CACf,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,GAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5H,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import { mergeProps } from '@fluentui-react-native/merge-props';
|
|
24
2
|
import { withSlots, stagedComponent } from '@fluentui-react-native/use-slot';
|
|
25
3
|
import * as renderer from 'react-test-renderer';
|
|
@@ -28,7 +6,7 @@ import { buildUseSlots } from './buildUseSlots';
|
|
|
28
6
|
* This file contains samples and description to help explain what the useSlots hook does and why it is useful
|
|
29
7
|
* for building components.
|
|
30
8
|
*/
|
|
31
|
-
describe('useSlots sample code test suite',
|
|
9
|
+
describe('useSlots sample code test suite', () => {
|
|
32
10
|
/**
|
|
33
11
|
* The first mechanism to understand is the stagedComponent mechanic. This allows a component to be written, separating
|
|
34
12
|
* hook calls and component rendering. This allows it to be safely called as a function by a higher order component, even conditionally.
|
|
@@ -39,20 +17,20 @@ describe('useSlots sample code test suite', function () {
|
|
|
39
17
|
* First we are going to create a wrapped text component that bolds all text. One component will be authored as a staged
|
|
40
18
|
* component and one as a regular component.
|
|
41
19
|
*/
|
|
42
|
-
|
|
20
|
+
const boldBaseProps = { style: { fontWeight: 900 } };
|
|
43
21
|
/**
|
|
44
22
|
* First create the bold text in the standard way. This is just a function component.
|
|
45
23
|
*/
|
|
46
|
-
|
|
24
|
+
const BoldTextStandard = (props) => {
|
|
47
25
|
/**
|
|
48
26
|
* Pick out the children to pass them on to the child Text element
|
|
49
27
|
*/
|
|
50
|
-
|
|
28
|
+
const { children, ...rest } = props;
|
|
51
29
|
/**
|
|
52
30
|
* Now render the text, merging the baseProps with the style updates with the rest param. Note that this leverages the fact
|
|
53
31
|
* that mergeProps will reliably produce style objects with the same reference, given the same inputs.
|
|
54
32
|
*/
|
|
55
|
-
return withSlots("span",
|
|
33
|
+
return withSlots("span", { ...mergeProps(boldBaseProps, rest) }, children);
|
|
56
34
|
};
|
|
57
35
|
BoldTextStandard.displayName = 'BoldTextStandard';
|
|
58
36
|
/**
|
|
@@ -61,26 +39,26 @@ describe('useSlots sample code test suite', function () {
|
|
|
61
39
|
*
|
|
62
40
|
* The stagedComponent function takes an input function of this form and wraps it in a function component that react knows how to render
|
|
63
41
|
*/
|
|
64
|
-
|
|
42
|
+
const BoldTextStaged = stagedComponent((props) => {
|
|
65
43
|
/**
|
|
66
44
|
* This section would be where hook/styling code would go, props here would include everything coming in from the base react tree with the
|
|
67
45
|
* exception of children, which will be passed in stage 2.
|
|
68
46
|
*/
|
|
69
|
-
return
|
|
47
|
+
return (extra, children) => {
|
|
70
48
|
/**
|
|
71
49
|
* extra are additional props that may be filled in by a higher order component. They should not include styling and are only props the
|
|
72
50
|
* enclosing component are passing to the JSX elements
|
|
73
51
|
*/
|
|
74
|
-
return withSlots("span",
|
|
52
|
+
return withSlots("span", { ...mergeProps(boldBaseProps, props, extra) }, children);
|
|
75
53
|
};
|
|
76
54
|
});
|
|
77
55
|
BoldTextStaged.displayName = 'BoldTextStaged';
|
|
78
|
-
it('renders sample 1 - the two types of basic bold text components',
|
|
79
|
-
|
|
56
|
+
it('renders sample 1 - the two types of basic bold text components', () => {
|
|
57
|
+
const styleToMerge = { color: 'black' };
|
|
80
58
|
/**
|
|
81
59
|
* First render the staged component. This invokes the wrapper that was built by the stagedComponent function
|
|
82
60
|
*/
|
|
83
|
-
|
|
61
|
+
const wrapper = renderer
|
|
84
62
|
.create(withSlots("div", null,
|
|
85
63
|
withSlots(BoldTextStaged, { style: styleToMerge }, "Staged component at one level"),
|
|
86
64
|
withSlots(BoldTextStandard, { style: styleToMerge }, "Standard component of a single level")))
|
|
@@ -93,16 +71,16 @@ describe('useSlots sample code test suite', function () {
|
|
|
93
71
|
* Next we will build a layer on top of the previously authored components to turn the bold text components into header components. This is
|
|
94
72
|
* to illustrate the way in which components can be commonly built on top of other simpler components.
|
|
95
73
|
*/
|
|
96
|
-
|
|
74
|
+
const headerBaseProps = { style: { fontSize: 20 } };
|
|
97
75
|
/**
|
|
98
76
|
* The standard way of doing things is a repeat of what happens above. Grab the children, pass them on, merge the rest of the props with
|
|
99
77
|
* base props.
|
|
100
78
|
*
|
|
101
79
|
* This again leverages style merging via mergeProps to avoid changing the references of the style objects on every render
|
|
102
80
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return withSlots(BoldTextStandard,
|
|
81
|
+
const HeaderStandard = (props) => {
|
|
82
|
+
const { children, ...rest } = props;
|
|
83
|
+
return withSlots(BoldTextStandard, { ...mergeProps(headerBaseProps, rest) }, children);
|
|
106
84
|
};
|
|
107
85
|
HeaderStandard.displayName = 'HeaderStandard';
|
|
108
86
|
/**
|
|
@@ -112,11 +90,11 @@ describe('useSlots sample code test suite', function () {
|
|
|
112
90
|
*
|
|
113
91
|
* This should be built once, and consumed by the component, not built on the fly inside
|
|
114
92
|
*/
|
|
115
|
-
|
|
93
|
+
const useHeaderSlots = buildUseSlots({ slots: { text: BoldTextStaged } });
|
|
116
94
|
/**
|
|
117
95
|
* Now author the staged component using the slot hook
|
|
118
96
|
*/
|
|
119
|
-
|
|
97
|
+
const HeaderStaged = stagedComponent((props) => {
|
|
120
98
|
/**
|
|
121
99
|
* Call the slots hook (or any hook) outside of the inner closure. The useSlots hook will return an object with each slot as a renderable
|
|
122
100
|
* function. The hooks for sub-components will be called as part of this call. Props passed in at this point will be the props that appear
|
|
@@ -124,9 +102,9 @@ describe('useSlots sample code test suite', function () {
|
|
|
124
102
|
*
|
|
125
103
|
* Note that while we are passing in props, in the simple usage case it isn't used and could be omitted if desired
|
|
126
104
|
* */
|
|
127
|
-
|
|
105
|
+
const BoldText = useHeaderSlots(props).text;
|
|
128
106
|
/** Now the inner closure, pretty much the same as before */
|
|
129
|
-
return
|
|
107
|
+
return (extra, children) => {
|
|
130
108
|
/**
|
|
131
109
|
* Instead of rendering the <BoldTextStageed> component directly we render using the slot. If this is a staged component it will call the
|
|
132
110
|
* inner closure directly, without going through createElement. Entries passed into the JSX, including children, are what appear in the
|
|
@@ -135,7 +113,7 @@ describe('useSlots sample code test suite', function () {
|
|
|
135
113
|
* NOTE: this requires using the withSlots helper via the jsx directive. This knows how to pick apart the entries and just call the second
|
|
136
114
|
* part of the function
|
|
137
115
|
*/
|
|
138
|
-
return withSlots(BoldText,
|
|
116
|
+
return withSlots(BoldText, { ...mergeProps(headerBaseProps, props, extra) }, children);
|
|
139
117
|
};
|
|
140
118
|
});
|
|
141
119
|
HeaderStaged.displayName = 'HeaderStaged';
|
|
@@ -143,12 +121,12 @@ describe('useSlots sample code test suite', function () {
|
|
|
143
121
|
* Look at the snapshots to compare the rendered output. The staged component will skip the intermediate levels of the react hieararchy while
|
|
144
122
|
* still rendering to the correct primitives.
|
|
145
123
|
*/
|
|
146
|
-
it('renders sample 2 = the two types of two level header components',
|
|
147
|
-
|
|
124
|
+
it('renders sample 2 = the two types of two level header components', () => {
|
|
125
|
+
const styleToMerge = { color: 'black' };
|
|
148
126
|
/**
|
|
149
127
|
* First render the staged component. This invokes the wrapper that was built by the stagedComponent function
|
|
150
128
|
*/
|
|
151
|
-
|
|
129
|
+
const wrapper = renderer
|
|
152
130
|
.create(withSlots("div", null,
|
|
153
131
|
withSlots(HeaderStaged, { style: styleToMerge }, "Staged component with two levels"),
|
|
154
132
|
withSlots(HeaderStandard, { style: styleToMerge }, "Standard component with two levels")))
|
|
@@ -156,13 +134,13 @@ describe('useSlots sample code test suite', function () {
|
|
|
156
134
|
expect(wrapper).toMatchSnapshot();
|
|
157
135
|
});
|
|
158
136
|
/** standard props for the container */
|
|
159
|
-
|
|
137
|
+
const containerProps = { style: { display: 'flex', flexDirection: 'column' } };
|
|
160
138
|
/**
|
|
161
139
|
* add a quick cache to ensure that we don't thrash the styles. This is a danger any time a value from a style is added as
|
|
162
140
|
* a prop on a component
|
|
163
141
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
const colorProps = {};
|
|
143
|
+
const getColorProps = (value) => {
|
|
166
144
|
if (value !== undefined) {
|
|
167
145
|
colorProps[value] = colorProps[value] || { style: { color: value } };
|
|
168
146
|
return colorProps[value];
|
|
@@ -172,19 +150,19 @@ describe('useSlots sample code test suite', function () {
|
|
|
172
150
|
/**
|
|
173
151
|
* now just create the component like a standard react functional component
|
|
174
152
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return (withSlots("div",
|
|
180
|
-
withSlots(HeaderStandard,
|
|
181
|
-
captionText && withSlots(BoldTextStandard,
|
|
153
|
+
const CaptionedHeaderStandard = (props) => {
|
|
154
|
+
const { headerColor, captionColor, captionText, children, ...rest } = props;
|
|
155
|
+
const headerColorProps = getColorProps(headerColor);
|
|
156
|
+
const captionColorProps = getColorProps(captionColor);
|
|
157
|
+
return (withSlots("div", { ...mergeProps(containerProps, rest) },
|
|
158
|
+
withSlots(HeaderStandard, { ...headerColorProps }, children),
|
|
159
|
+
captionText && withSlots(BoldTextStandard, { ...captionColorProps }, captionText)));
|
|
182
160
|
};
|
|
183
|
-
CaptionedHeaderStandard.displayName =
|
|
161
|
+
CaptionedHeaderStandard.displayName = `CaptionedHeaderStandard';`;
|
|
184
162
|
/**
|
|
185
163
|
* now build the same component using slots hook. This will also add use of the style injection pattern
|
|
186
164
|
*/
|
|
187
|
-
|
|
165
|
+
const useCaptionedHeaderSlots = buildUseSlots({
|
|
188
166
|
/** Slots are just like above, this component will have three sub-components */
|
|
189
167
|
slots: {
|
|
190
168
|
container: 'div',
|
|
@@ -192,37 +170,37 @@ describe('useSlots sample code test suite', function () {
|
|
|
192
170
|
caption: BoldTextStaged,
|
|
193
171
|
},
|
|
194
172
|
/** useStyling is an optional function that turns props into props for the sub-components */
|
|
195
|
-
useStyling:
|
|
173
|
+
useStyling: (props) => ({
|
|
196
174
|
container: containerProps,
|
|
197
175
|
header: getColorProps(props.headerColor),
|
|
198
176
|
caption: getColorProps(props.captionColor),
|
|
199
|
-
})
|
|
177
|
+
}),
|
|
200
178
|
});
|
|
201
179
|
/** a mask to clear props that we don't want to pass to the inner view */
|
|
202
|
-
|
|
180
|
+
const clearCustomProps = { headerColor: undefined, captionColor: undefined };
|
|
203
181
|
/**
|
|
204
182
|
* now use the hook to implement it as a staged component
|
|
205
183
|
*/
|
|
206
|
-
|
|
184
|
+
const CaptionedHeaderStaged = stagedComponent((props) => {
|
|
207
185
|
// At the point where this is called the slots are initialized with the initial prop values from useStyling above
|
|
208
|
-
|
|
209
|
-
return
|
|
186
|
+
const Slots = useCaptionedHeaderSlots(props);
|
|
187
|
+
return (extra, children) => {
|
|
210
188
|
// merge the props together, picking out the caption text and clearing any custom values we don't want forwarded to the view
|
|
211
|
-
|
|
189
|
+
const { captionText, ...rest } = mergeProps(props, extra, clearCustomProps);
|
|
212
190
|
// now render using the slots. Any values passed in via JSX will be merged with values from the slot hook above
|
|
213
|
-
return (withSlots(Slots.container,
|
|
191
|
+
return (withSlots(Slots.container, { ...rest },
|
|
214
192
|
withSlots(Slots.header, null, children),
|
|
215
193
|
captionText && withSlots(Slots.caption, null, captionText)));
|
|
216
194
|
};
|
|
217
195
|
});
|
|
218
196
|
CaptionedHeaderStaged.displayName = 'CaptionedHeaderStaged';
|
|
219
|
-
it('renders sample 3 - the two types of higher order header components',
|
|
220
|
-
|
|
197
|
+
it('renders sample 3 - the two types of higher order header components', () => {
|
|
198
|
+
const styleToMerge = { backgroundColor: 'gray', borderColor: 'purple', borderWidth: 1 };
|
|
221
199
|
/**
|
|
222
200
|
* Render the two sets of components. Note in the snapshots how the render tree layers for the standard approach are starting
|
|
223
201
|
* to add up.
|
|
224
202
|
*/
|
|
225
|
-
|
|
203
|
+
const wrapper = renderer
|
|
226
204
|
.create(withSlots("div", null,
|
|
227
205
|
withSlots("span", null, "--- SIMPLE USAGE COMPARISON ---"),
|
|
228
206
|
withSlots(CaptionedHeaderStandard, { style: styleToMerge }, "Standard HOC"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSlots.samples.test.js","sourceRoot":"","sources":["../src/useSlots.samples.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSlots.samples.test.js","sourceRoot":"","sources":["../src/useSlots.samples.test.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD;;;GAGG;AAEH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C;;;OAGG;IAEH;;;;;OAKG;IAEH,MAAM,aAAa,GAAc,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,CAAC;IAEhE;;OAEG;IACH,MAAM,gBAAgB,GAAgE,CAAC,KAAyC,EAAE,EAAE;QAClI;;WAEG;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAEpC;;;WAGG;QACH,OAAO,uBAAU,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,IAAG,QAAQ,CAAQ,CAAC;IACtE,CAAC,CAAC;IACF,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAElD;;;;;OAKG;IACH,MAAM,cAAc,GAAG,eAAe,CAAC,CAAC,KAAyC,EAAE,EAAE;QACnF;;;WAGG;QACH,OAAO,CAAC,KAAgB,EAAE,QAAyB,EAAE,EAAE;YACrD;;;eAGG;YACH,OAAO,uBAAU,UAAU,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,IAAG,QAAQ,CAAQ,CAAC;QAC9E,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAE9C,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,YAAY,GAAc,EA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CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,qBAAqB,CAAC,WAAW,GAAG,uBAAuB,CAAC;IAE5D,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,YAAY,GAAc,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAEnG;;;WAGG;QACH,MAAM,OAAO,GAAG,QAAQ;aACrB,MAAM,CACL;YACE,0DAA4C;YAC5C,UAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,mBAAwC;YACpF,UAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,iBAAoC;YAC9E,2DAA6C;YAC7C,UAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,gCAE9C;YAC1B,UAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,8BAE9C;YACxB,8EAAgE;YAChE,UAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,EAAC,YAAY,EAAC,QAAQ,EAAC,WAAW,EAAC,KAAK,mDAEtF;YAC1B,UAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,EAAC,YAAY,EAAC,QAAQ,EAAC,WAAW,EAAC,KAAK,iDAEtF,CACpB,CACP;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildUseSlots = void 0;
|
|
4
|
-
|
|
4
|
+
const use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
5
5
|
function buildUseSlots(options) {
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
var args = [];
|
|
9
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
-
args[_i] = arguments[_i];
|
|
11
|
-
}
|
|
6
|
+
const { slots, filters = {}, useStyling } = options;
|
|
7
|
+
return (...args) => {
|
|
12
8
|
// get the baseline slot props to render with the slots
|
|
13
9
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
14
|
-
|
|
10
|
+
const slotProps = typeof useStyling === 'function' ? useStyling(...args) : (useStyling || {});
|
|
15
11
|
// build up a set of slots closures and store them in props
|
|
16
|
-
|
|
12
|
+
const builtSlots = {};
|
|
17
13
|
// for each slot go through and either cache the slot props or call part one render if it is staged
|
|
18
|
-
Object.keys(slots).forEach(
|
|
14
|
+
Object.keys(slots).forEach((slotName) => {
|
|
19
15
|
builtSlots[slotName] = (0, use_slot_1.useSlot)(slots[slotName], slotProps[slotName], filters[slotName]);
|
|
20
16
|
});
|
|
21
17
|
// return the prebuilt closures, these will have internal references to state.results
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseSlots.js","sourceRoot":"","sources":["../src/buildUseSlots.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"buildUseSlots.js","sourceRoot":"","sources":["../src/buildUseSlots.ts"],"names":[],"mappings":";;;AACA,8DAA0D;AAgB1D,SAAgB,aAAa,CAAa,OAAmC;IAC3E,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACpD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,uDAAuD;QACvD,wDAAwD;QACxD,MAAM,SAAS,GAAe,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAE,UAAuB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,UAAU,IAAI,EAAE,CAAgB,CAAC;QAExI,2DAA2D;QAC3D,MAAM,UAAU,GAAsB,EAAuB,CAAC;QAE9D,mGAAmG;QACnG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACtC,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAA,kBAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;QAEH,qFAAqF;QACrF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAlBD,sCAkBC"}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -34,29 +23,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
34
23
|
return result;
|
|
35
24
|
};
|
|
36
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const react_native_1 = require("react-native");
|
|
27
|
+
const use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
28
|
+
const renderer = __importStar(require("react-test-renderer"));
|
|
29
|
+
const buildUseSlots_1 = require("./buildUseSlots");
|
|
30
|
+
const useSlotsBase = (0, buildUseSlots_1.buildUseSlots)({
|
|
42
31
|
slots: {
|
|
43
32
|
outer: react_native_1.View,
|
|
44
33
|
inner: react_native_1.View,
|
|
45
34
|
content: react_native_1.Text,
|
|
46
35
|
},
|
|
47
36
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
return ((0, use_slot_1.withSlots)(Slots.outer,
|
|
37
|
+
const CompBase = (0, use_slot_1.stagedComponent)((props) => {
|
|
38
|
+
const Slots = useSlotsBase(props);
|
|
39
|
+
return (extra) => {
|
|
40
|
+
const merged = { ...props, ...extra };
|
|
41
|
+
return ((0, use_slot_1.withSlots)(Slots.outer, { ...merged },
|
|
53
42
|
(0, use_slot_1.withSlots)(Slots.inner, { style: { backgroundColor: 'blue', width: 20, height: 10 } },
|
|
54
43
|
(0, use_slot_1.withSlots)(Slots.content, null, "Hello"))));
|
|
55
44
|
};
|
|
56
45
|
});
|
|
57
|
-
describe('buildUseSlots test suite',
|
|
58
|
-
it('Simple component render',
|
|
59
|
-
|
|
46
|
+
describe('buildUseSlots test suite', () => {
|
|
47
|
+
it('Simple component render', () => {
|
|
48
|
+
const tree = renderer.create((0, use_slot_1.withSlots)(CompBase, { style: { width: 30, height: 20, borderColor: 'green', borderWidth: 1 } })).toJSON();
|
|
60
49
|
expect(tree).toMatchSnapshot();
|
|
61
50
|
});
|
|
62
51
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUseSlots.test.js","sourceRoot":"","sources":["../src/buildUseSlots.test.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildUseSlots.test.js","sourceRoot":"","sources":["../src/buildUseSlots.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,+CAA0C;AAE1C,8DAA6E;AAC7E,8DAAgD;AAEhD,mDAAgD;AAQhD,MAAM,YAAY,GAAG,IAAA,6BAAa,EAAa;IAC7C,KAAK,EAAE;QACL,KAAK,EAAE,mBAAI;QACX,KAAK,EAAE,mBAAI;QACX,OAAO,EAAE,mBAAI;KACd;CACF,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,IAAA,0BAAe,EAAC,CAAC,KAAgB,EAAE,EAAE;IACpD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAClC,OAAO,CAAC,KAAgB,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;QACtC,OAAO,CACL,0BAAC,KAAK,CAAC,KAAK,OAAK,MAAM;YACrB,0BAAC,KAAK,CAAC,KAAK,IAAC,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBACpE,0BAAC,KAAK,CAAC,OAAO,gBAAsB,CACxB,CACF,CACf,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,0BAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,GAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5H,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -33,27 +22,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
22
|
__setModuleDefault(result, mod);
|
|
34
23
|
return result;
|
|
35
24
|
};
|
|
36
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
-
var t = {};
|
|
38
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
-
t[p] = s[p];
|
|
40
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
-
t[p[i]] = s[p[i]];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
const merge_props_1 = require("@fluentui-react-native/merge-props");
|
|
27
|
+
const use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
28
|
+
const renderer = __importStar(require("react-test-renderer"));
|
|
29
|
+
const buildUseSlots_1 = require("./buildUseSlots");
|
|
52
30
|
/**
|
|
53
31
|
* This file contains samples and description to help explain what the useSlots hook does and why it is useful
|
|
54
32
|
* for building components.
|
|
55
33
|
*/
|
|
56
|
-
describe('useSlots sample code test suite',
|
|
34
|
+
describe('useSlots sample code test suite', () => {
|
|
57
35
|
/**
|
|
58
36
|
* The first mechanism to understand is the stagedComponent mechanic. This allows a component to be written, separating
|
|
59
37
|
* hook calls and component rendering. This allows it to be safely called as a function by a higher order component, even conditionally.
|
|
@@ -64,20 +42,20 @@ describe('useSlots sample code test suite', function () {
|
|
|
64
42
|
* First we are going to create a wrapped text component that bolds all text. One component will be authored as a staged
|
|
65
43
|
* component and one as a regular component.
|
|
66
44
|
*/
|
|
67
|
-
|
|
45
|
+
const boldBaseProps = { style: { fontWeight: 900 } };
|
|
68
46
|
/**
|
|
69
47
|
* First create the bold text in the standard way. This is just a function component.
|
|
70
48
|
*/
|
|
71
|
-
|
|
49
|
+
const BoldTextStandard = (props) => {
|
|
72
50
|
/**
|
|
73
51
|
* Pick out the children to pass them on to the child Text element
|
|
74
52
|
*/
|
|
75
|
-
|
|
53
|
+
const { children, ...rest } = props;
|
|
76
54
|
/**
|
|
77
55
|
* Now render the text, merging the baseProps with the style updates with the rest param. Note that this leverages the fact
|
|
78
56
|
* that mergeProps will reliably produce style objects with the same reference, given the same inputs.
|
|
79
57
|
*/
|
|
80
|
-
return (0, use_slot_1.withSlots)("span",
|
|
58
|
+
return (0, use_slot_1.withSlots)("span", { ...(0, merge_props_1.mergeProps)(boldBaseProps, rest) }, children);
|
|
81
59
|
};
|
|
82
60
|
BoldTextStandard.displayName = 'BoldTextStandard';
|
|
83
61
|
/**
|
|
@@ -86,26 +64,26 @@ describe('useSlots sample code test suite', function () {
|
|
|
86
64
|
*
|
|
87
65
|
* The stagedComponent function takes an input function of this form and wraps it in a function component that react knows how to render
|
|
88
66
|
*/
|
|
89
|
-
|
|
67
|
+
const BoldTextStaged = (0, use_slot_1.stagedComponent)((props) => {
|
|
90
68
|
/**
|
|
91
69
|
* This section would be where hook/styling code would go, props here would include everything coming in from the base react tree with the
|
|
92
70
|
* exception of children, which will be passed in stage 2.
|
|
93
71
|
*/
|
|
94
|
-
return
|
|
72
|
+
return (extra, children) => {
|
|
95
73
|
/**
|
|
96
74
|
* extra are additional props that may be filled in by a higher order component. They should not include styling and are only props the
|
|
97
75
|
* enclosing component are passing to the JSX elements
|
|
98
76
|
*/
|
|
99
|
-
return (0, use_slot_1.withSlots)("span",
|
|
77
|
+
return (0, use_slot_1.withSlots)("span", { ...(0, merge_props_1.mergeProps)(boldBaseProps, props, extra) }, children);
|
|
100
78
|
};
|
|
101
79
|
});
|
|
102
80
|
BoldTextStaged.displayName = 'BoldTextStaged';
|
|
103
|
-
it('renders sample 1 - the two types of basic bold text components',
|
|
104
|
-
|
|
81
|
+
it('renders sample 1 - the two types of basic bold text components', () => {
|
|
82
|
+
const styleToMerge = { color: 'black' };
|
|
105
83
|
/**
|
|
106
84
|
* First render the staged component. This invokes the wrapper that was built by the stagedComponent function
|
|
107
85
|
*/
|
|
108
|
-
|
|
86
|
+
const wrapper = renderer
|
|
109
87
|
.create((0, use_slot_1.withSlots)("div", null,
|
|
110
88
|
(0, use_slot_1.withSlots)(BoldTextStaged, { style: styleToMerge }, "Staged component at one level"),
|
|
111
89
|
(0, use_slot_1.withSlots)(BoldTextStandard, { style: styleToMerge }, "Standard component of a single level")))
|
|
@@ -118,16 +96,16 @@ describe('useSlots sample code test suite', function () {
|
|
|
118
96
|
* Next we will build a layer on top of the previously authored components to turn the bold text components into header components. This is
|
|
119
97
|
* to illustrate the way in which components can be commonly built on top of other simpler components.
|
|
120
98
|
*/
|
|
121
|
-
|
|
99
|
+
const headerBaseProps = { style: { fontSize: 20 } };
|
|
122
100
|
/**
|
|
123
101
|
* The standard way of doing things is a repeat of what happens above. Grab the children, pass them on, merge the rest of the props with
|
|
124
102
|
* base props.
|
|
125
103
|
*
|
|
126
104
|
* This again leverages style merging via mergeProps to avoid changing the references of the style objects on every render
|
|
127
105
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return (0, use_slot_1.withSlots)(BoldTextStandard,
|
|
106
|
+
const HeaderStandard = (props) => {
|
|
107
|
+
const { children, ...rest } = props;
|
|
108
|
+
return (0, use_slot_1.withSlots)(BoldTextStandard, { ...(0, merge_props_1.mergeProps)(headerBaseProps, rest) }, children);
|
|
131
109
|
};
|
|
132
110
|
HeaderStandard.displayName = 'HeaderStandard';
|
|
133
111
|
/**
|
|
@@ -137,11 +115,11 @@ describe('useSlots sample code test suite', function () {
|
|
|
137
115
|
*
|
|
138
116
|
* This should be built once, and consumed by the component, not built on the fly inside
|
|
139
117
|
*/
|
|
140
|
-
|
|
118
|
+
const useHeaderSlots = (0, buildUseSlots_1.buildUseSlots)({ slots: { text: BoldTextStaged } });
|
|
141
119
|
/**
|
|
142
120
|
* Now author the staged component using the slot hook
|
|
143
121
|
*/
|
|
144
|
-
|
|
122
|
+
const HeaderStaged = (0, use_slot_1.stagedComponent)((props) => {
|
|
145
123
|
/**
|
|
146
124
|
* Call the slots hook (or any hook) outside of the inner closure. The useSlots hook will return an object with each slot as a renderable
|
|
147
125
|
* function. The hooks for sub-components will be called as part of this call. Props passed in at this point will be the props that appear
|
|
@@ -149,9 +127,9 @@ describe('useSlots sample code test suite', function () {
|
|
|
149
127
|
*
|
|
150
128
|
* Note that while we are passing in props, in the simple usage case it isn't used and could be omitted if desired
|
|
151
129
|
* */
|
|
152
|
-
|
|
130
|
+
const BoldText = useHeaderSlots(props).text;
|
|
153
131
|
/** Now the inner closure, pretty much the same as before */
|
|
154
|
-
return
|
|
132
|
+
return (extra, children) => {
|
|
155
133
|
/**
|
|
156
134
|
* Instead of rendering the <BoldTextStageed> component directly we render using the slot. If this is a staged component it will call the
|
|
157
135
|
* inner closure directly, without going through createElement. Entries passed into the JSX, including children, are what appear in the
|
|
@@ -160,7 +138,7 @@ describe('useSlots sample code test suite', function () {
|
|
|
160
138
|
* NOTE: this requires using the withSlots helper via the jsx directive. This knows how to pick apart the entries and just call the second
|
|
161
139
|
* part of the function
|
|
162
140
|
*/
|
|
163
|
-
return (0, use_slot_1.withSlots)(BoldText,
|
|
141
|
+
return (0, use_slot_1.withSlots)(BoldText, { ...(0, merge_props_1.mergeProps)(headerBaseProps, props, extra) }, children);
|
|
164
142
|
};
|
|
165
143
|
});
|
|
166
144
|
HeaderStaged.displayName = 'HeaderStaged';
|
|
@@ -168,12 +146,12 @@ describe('useSlots sample code test suite', function () {
|
|
|
168
146
|
* Look at the snapshots to compare the rendered output. The staged component will skip the intermediate levels of the react hieararchy while
|
|
169
147
|
* still rendering to the correct primitives.
|
|
170
148
|
*/
|
|
171
|
-
it('renders sample 2 = the two types of two level header components',
|
|
172
|
-
|
|
149
|
+
it('renders sample 2 = the two types of two level header components', () => {
|
|
150
|
+
const styleToMerge = { color: 'black' };
|
|
173
151
|
/**
|
|
174
152
|
* First render the staged component. This invokes the wrapper that was built by the stagedComponent function
|
|
175
153
|
*/
|
|
176
|
-
|
|
154
|
+
const wrapper = renderer
|
|
177
155
|
.create((0, use_slot_1.withSlots)("div", null,
|
|
178
156
|
(0, use_slot_1.withSlots)(HeaderStaged, { style: styleToMerge }, "Staged component with two levels"),
|
|
179
157
|
(0, use_slot_1.withSlots)(HeaderStandard, { style: styleToMerge }, "Standard component with two levels")))
|
|
@@ -181,13 +159,13 @@ describe('useSlots sample code test suite', function () {
|
|
|
181
159
|
expect(wrapper).toMatchSnapshot();
|
|
182
160
|
});
|
|
183
161
|
/** standard props for the container */
|
|
184
|
-
|
|
162
|
+
const containerProps = { style: { display: 'flex', flexDirection: 'column' } };
|
|
185
163
|
/**
|
|
186
164
|
* add a quick cache to ensure that we don't thrash the styles. This is a danger any time a value from a style is added as
|
|
187
165
|
* a prop on a component
|
|
188
166
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
167
|
+
const colorProps = {};
|
|
168
|
+
const getColorProps = (value) => {
|
|
191
169
|
if (value !== undefined) {
|
|
192
170
|
colorProps[value] = colorProps[value] || { style: { color: value } };
|
|
193
171
|
return colorProps[value];
|
|
@@ -197,19 +175,19 @@ describe('useSlots sample code test suite', function () {
|
|
|
197
175
|
/**
|
|
198
176
|
* now just create the component like a standard react functional component
|
|
199
177
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return ((0, use_slot_1.withSlots)("div",
|
|
205
|
-
(0, use_slot_1.withSlots)(HeaderStandard,
|
|
206
|
-
captionText && (0, use_slot_1.withSlots)(BoldTextStandard,
|
|
178
|
+
const CaptionedHeaderStandard = (props) => {
|
|
179
|
+
const { headerColor, captionColor, captionText, children, ...rest } = props;
|
|
180
|
+
const headerColorProps = getColorProps(headerColor);
|
|
181
|
+
const captionColorProps = getColorProps(captionColor);
|
|
182
|
+
return ((0, use_slot_1.withSlots)("div", { ...(0, merge_props_1.mergeProps)(containerProps, rest) },
|
|
183
|
+
(0, use_slot_1.withSlots)(HeaderStandard, { ...headerColorProps }, children),
|
|
184
|
+
captionText && (0, use_slot_1.withSlots)(BoldTextStandard, { ...captionColorProps }, captionText)));
|
|
207
185
|
};
|
|
208
|
-
CaptionedHeaderStandard.displayName =
|
|
186
|
+
CaptionedHeaderStandard.displayName = `CaptionedHeaderStandard';`;
|
|
209
187
|
/**
|
|
210
188
|
* now build the same component using slots hook. This will also add use of the style injection pattern
|
|
211
189
|
*/
|
|
212
|
-
|
|
190
|
+
const useCaptionedHeaderSlots = (0, buildUseSlots_1.buildUseSlots)({
|
|
213
191
|
/** Slots are just like above, this component will have three sub-components */
|
|
214
192
|
slots: {
|
|
215
193
|
container: 'div',
|
|
@@ -217,37 +195,37 @@ describe('useSlots sample code test suite', function () {
|
|
|
217
195
|
caption: BoldTextStaged,
|
|
218
196
|
},
|
|
219
197
|
/** useStyling is an optional function that turns props into props for the sub-components */
|
|
220
|
-
useStyling:
|
|
198
|
+
useStyling: (props) => ({
|
|
221
199
|
container: containerProps,
|
|
222
200
|
header: getColorProps(props.headerColor),
|
|
223
201
|
caption: getColorProps(props.captionColor),
|
|
224
|
-
})
|
|
202
|
+
}),
|
|
225
203
|
});
|
|
226
204
|
/** a mask to clear props that we don't want to pass to the inner view */
|
|
227
|
-
|
|
205
|
+
const clearCustomProps = { headerColor: undefined, captionColor: undefined };
|
|
228
206
|
/**
|
|
229
207
|
* now use the hook to implement it as a staged component
|
|
230
208
|
*/
|
|
231
|
-
|
|
209
|
+
const CaptionedHeaderStaged = (0, use_slot_1.stagedComponent)((props) => {
|
|
232
210
|
// At the point where this is called the slots are initialized with the initial prop values from useStyling above
|
|
233
|
-
|
|
234
|
-
return
|
|
211
|
+
const Slots = useCaptionedHeaderSlots(props);
|
|
212
|
+
return (extra, children) => {
|
|
235
213
|
// merge the props together, picking out the caption text and clearing any custom values we don't want forwarded to the view
|
|
236
|
-
|
|
214
|
+
const { captionText, ...rest } = (0, merge_props_1.mergeProps)(props, extra, clearCustomProps);
|
|
237
215
|
// now render using the slots. Any values passed in via JSX will be merged with values from the slot hook above
|
|
238
|
-
return ((0, use_slot_1.withSlots)(Slots.container,
|
|
216
|
+
return ((0, use_slot_1.withSlots)(Slots.container, { ...rest },
|
|
239
217
|
(0, use_slot_1.withSlots)(Slots.header, null, children),
|
|
240
218
|
captionText && (0, use_slot_1.withSlots)(Slots.caption, null, captionText)));
|
|
241
219
|
};
|
|
242
220
|
});
|
|
243
221
|
CaptionedHeaderStaged.displayName = 'CaptionedHeaderStaged';
|
|
244
|
-
it('renders sample 3 - the two types of higher order header components',
|
|
245
|
-
|
|
222
|
+
it('renders sample 3 - the two types of higher order header components', () => {
|
|
223
|
+
const styleToMerge = { backgroundColor: 'gray', borderColor: 'purple', borderWidth: 1 };
|
|
246
224
|
/**
|
|
247
225
|
* Render the two sets of components. Note in the snapshots how the render tree layers for the standard approach are starting
|
|
248
226
|
* to add up.
|
|
249
227
|
*/
|
|
250
|
-
|
|
228
|
+
const wrapper = renderer
|
|
251
229
|
.create((0, use_slot_1.withSlots)("div", null,
|
|
252
230
|
(0, use_slot_1.withSlots)("span", null, "--- SIMPLE USAGE COMPARISON ---"),
|
|
253
231
|
(0, use_slot_1.withSlots)(CaptionedHeaderStandard, { style: styleToMerge }, "Standard HOC"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSlots.samples.test.js","sourceRoot":"","sources":["../src/useSlots.samples.test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CAAC,WAAW,GAAG,uBAAuB,CAAC;IAE5D,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,YAAY,GAAc,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAEnG;;;WAGG;QACH,MAAM,OAAO,GAAG,QAAQ;aACrB,MAAM,CACL;YACE,0EAA4C;YAC5C,0BAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,mBAAwC;YACpF,0BAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,iBAAoC;YAC9E,2EAA6C;YAC7C,0BAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,gCAE9C;YAC1B,0BAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,8BAE9C;YACxB,8FAAgE;YAChE,0BAAC,uBAAuB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,EAAC,YAAY,EAAC,QAAQ,EAAC,WAAW,EAAC,KAAK,mDAEtF;YAC1B,0BAAC,qBAAqB,IAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAC,cAAc,EAAC,YAAY,EAAC,QAAQ,EAAC,WAAW,EAAC,KAAK,iDAEtF,CACpB,CACP;aACA,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/use-slots",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "Hook function to return styled slots",
|
|
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,19 +34,20 @@
|
|
|
27
34
|
"author": "",
|
|
28
35
|
"license": "MIT",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"@fluentui-react-native/use-slot": "0.6.
|
|
37
|
+
"@fluentui-react-native/use-slot": "0.6.4"
|
|
31
38
|
},
|
|
32
39
|
"devDependencies": {
|
|
33
|
-
"@
|
|
40
|
+
"@babel/core": "^7.20.0",
|
|
41
|
+
"@fluentui-react-native/merge-props": "0.9.3",
|
|
34
42
|
"@fluentui-react-native/scripts": "0.1.1",
|
|
35
|
-
"@react-native/babel-preset": "^0.
|
|
36
|
-
"@react-native/metro-config": "^0.
|
|
43
|
+
"@react-native/babel-preset": "^0.74.0",
|
|
44
|
+
"@react-native/metro-config": "^0.74.0",
|
|
37
45
|
"react": "18.2.0",
|
|
38
|
-
"react-native": "^0.
|
|
46
|
+
"react-native": "^0.74.0"
|
|
39
47
|
},
|
|
40
48
|
"peerDependencies": {
|
|
41
49
|
"react": "18.2.0",
|
|
42
|
-
"react-native": "^0.73.0"
|
|
50
|
+
"react-native": "^0.73.0 || ^0.74.0"
|
|
43
51
|
},
|
|
44
52
|
"rnx-kit": {
|
|
45
53
|
"kitType": "library",
|
|
@@ -47,10 +55,16 @@
|
|
|
47
55
|
"presets": [
|
|
48
56
|
"microsoft/react-native"
|
|
49
57
|
],
|
|
50
|
-
"requirements":
|
|
51
|
-
"
|
|
52
|
-
|
|
58
|
+
"requirements": {
|
|
59
|
+
"development": [
|
|
60
|
+
"react-native@0.74"
|
|
61
|
+
],
|
|
62
|
+
"production": [
|
|
63
|
+
"react-native@0.73 || 0.74"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
53
66
|
"capabilities": [
|
|
67
|
+
"babel-preset-react-native",
|
|
54
68
|
"core",
|
|
55
69
|
"core-android",
|
|
56
70
|
"core-ios",
|
package/.eslintrc.js
DELETED