@fluentui-react-native/composition 0.6.9
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 +601 -0
- package/CHANGELOG.md +173 -0
- package/README.md +1 -0
- package/babel.config.js +1 -0
- package/just.config.js +3 -0
- package/lib/composeFactory.d.ts +26 -0
- package/lib/composeFactory.d.ts.map +1 -0
- package/lib/composeFactory.js +52 -0
- package/lib/composeFactory.js.map +1 -0
- package/lib/composeFactory.test.d.ts +2 -0
- package/lib/composeFactory.test.d.ts.map +1 -0
- package/lib/composeFactory.test.js +72 -0
- package/lib/composeFactory.test.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib-commonjs/composeFactory.d.ts +26 -0
- package/lib-commonjs/composeFactory.d.ts.map +1 -0
- package/lib-commonjs/composeFactory.js +55 -0
- package/lib-commonjs/composeFactory.js.map +1 -0
- package/lib-commonjs/composeFactory.test.d.ts +2 -0
- package/lib-commonjs/composeFactory.test.d.ts.map +1 -0
- package/lib-commonjs/composeFactory.test.js +81 -0
- package/lib-commonjs/composeFactory.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +2 -0
- package/lib-commonjs/index.d.ts.map +1 -0
- package/lib-commonjs/index.js +7 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +44 -0
- package/src/__snapshots__/composeFactory.test.tsx.snap +49 -0
- package/src/composeFactory.test.tsx +94 -0
- package/src/composeFactory.ts +90 -0
- package/src/index.ts +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Change Log - @fluentui-react-native/composition
|
|
2
|
+
|
|
3
|
+
This log was last generated on Tue, 28 Sep 2021 21:06:18 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 0.6.9
|
|
8
|
+
|
|
9
|
+
Tue, 28 Sep 2021 21:06:18 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Bump @fluentui-react-native/use-styling to v0.6.8 (67026167+chiuam@users.noreply.github.com)
|
|
14
|
+
|
|
15
|
+
## 0.6.8
|
|
16
|
+
|
|
17
|
+
Sat, 07 Aug 2021 00:40:04 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- enable usePressableState with stock Pressable component (jasonmo@microsoft.com)
|
|
22
|
+
|
|
23
|
+
## 0.6.7
|
|
24
|
+
|
|
25
|
+
Wed, 04 Aug 2021 16:54:20 GMT
|
|
26
|
+
|
|
27
|
+
### Patches
|
|
28
|
+
|
|
29
|
+
- Bump @fluentui-react-native/use-styling to v0.6.6 (jasonmo@microsoft.com)
|
|
30
|
+
|
|
31
|
+
## 0.6.6
|
|
32
|
+
|
|
33
|
+
Wed, 04 Aug 2021 06:26:25 GMT
|
|
34
|
+
|
|
35
|
+
### Patches
|
|
36
|
+
|
|
37
|
+
- radio group on macOS (67026167+chiuam@users.noreply.github.com)
|
|
38
|
+
|
|
39
|
+
## 0.6.5
|
|
40
|
+
|
|
41
|
+
Tue, 03 Aug 2021 22:33:17 GMT
|
|
42
|
+
|
|
43
|
+
### Patches
|
|
44
|
+
|
|
45
|
+
- Bump @fluentui-react-native/use-styling to v0.6.4 (jasonmo@microsoft.com)
|
|
46
|
+
|
|
47
|
+
## 0.6.4
|
|
48
|
+
|
|
49
|
+
Tue, 27 Jul 2021 22:17:20 GMT
|
|
50
|
+
|
|
51
|
+
### Patches
|
|
52
|
+
|
|
53
|
+
- add compressible utility and a snapshot test / demo to framework (jasonmo@microsoft.com)
|
|
54
|
+
|
|
55
|
+
## 0.6.3
|
|
56
|
+
|
|
57
|
+
Mon, 26 Jul 2021 20:41:04 GMT
|
|
58
|
+
|
|
59
|
+
### Patches
|
|
60
|
+
|
|
61
|
+
- add new use-slot package, move framework to consume that package (jasonmo@microsoft.com)
|
|
62
|
+
|
|
63
|
+
## 0.6.2
|
|
64
|
+
|
|
65
|
+
Wed, 21 Jul 2021 22:55:40 GMT
|
|
66
|
+
|
|
67
|
+
### Patches
|
|
68
|
+
|
|
69
|
+
- expose use-tokens in framework package (jasonmo@microsoft.com)
|
|
70
|
+
|
|
71
|
+
## 0.6.1
|
|
72
|
+
|
|
73
|
+
Fri, 18 Jun 2021 00:38:19 GMT
|
|
74
|
+
|
|
75
|
+
### Patches
|
|
76
|
+
|
|
77
|
+
- Apply prettier to framework, run (ruaraki@microsoft.com)
|
|
78
|
+
|
|
79
|
+
## 0.6.0
|
|
80
|
+
|
|
81
|
+
Tue, 15 Jun 2021 00:55:36 GMT
|
|
82
|
+
|
|
83
|
+
### Minor changes
|
|
84
|
+
|
|
85
|
+
- Add support for ColorValue (ruaraki@microsoft.com)
|
|
86
|
+
|
|
87
|
+
## 0.5.0
|
|
88
|
+
|
|
89
|
+
Sat, 06 Mar 2021 00:20:05 GMT
|
|
90
|
+
|
|
91
|
+
### Minor changes
|
|
92
|
+
|
|
93
|
+
- Update to react-native 0.63 (30809111+acoates-ms@users.noreply.github.com)
|
|
94
|
+
|
|
95
|
+
## 0.4.1
|
|
96
|
+
|
|
97
|
+
Mon, 02 Nov 2020 19:16:23 GMT
|
|
98
|
+
|
|
99
|
+
### Patches
|
|
100
|
+
|
|
101
|
+
- Update type of the tokens parameter to make TSC happy. (kinhln@microsoft.com)
|
|
102
|
+
|
|
103
|
+
## 0.4.0
|
|
104
|
+
|
|
105
|
+
Fri, 23 Oct 2020 22:27:37 GMT
|
|
106
|
+
|
|
107
|
+
### Minor changes
|
|
108
|
+
|
|
109
|
+
- RNIcon feature (warleu@microsoft.com)
|
|
110
|
+
|
|
111
|
+
## 0.3.8
|
|
112
|
+
|
|
113
|
+
Fri, 25 Sep 2020 19:21:43 GMT
|
|
114
|
+
|
|
115
|
+
### Patches
|
|
116
|
+
|
|
117
|
+
- Update react-native-win32 versions - enable logbox (acoates-ms@noreply.github.com)
|
|
118
|
+
|
|
119
|
+
## 0.3.7
|
|
120
|
+
|
|
121
|
+
Wed, 23 Sep 2020 18:31:48 GMT
|
|
122
|
+
|
|
123
|
+
### Patches
|
|
124
|
+
|
|
125
|
+
- start publishing src to fix customer source maps (jasonmo@microsoft.com)
|
|
126
|
+
|
|
127
|
+
## 0.3.4
|
|
128
|
+
|
|
129
|
+
Mon, 17 Aug 2020 22:08:34 GMT
|
|
130
|
+
|
|
131
|
+
### Patches
|
|
132
|
+
|
|
133
|
+
- fix dependency errors (jasonmo@microsoft.com)
|
|
134
|
+
|
|
135
|
+
## 0.3.3
|
|
136
|
+
|
|
137
|
+
Thu, 13 Aug 2020 04:48:19 GMT
|
|
138
|
+
|
|
139
|
+
### Patches
|
|
140
|
+
|
|
141
|
+
- release @fluentui-react-native/memo-cache (jasonmo@microsoft.com)
|
|
142
|
+
|
|
143
|
+
## 0.3.2
|
|
144
|
+
|
|
145
|
+
Wed, 12 Aug 2020 23:52:15 GMT
|
|
146
|
+
|
|
147
|
+
### Patches
|
|
148
|
+
|
|
149
|
+
- release @fluentui-react-native/immutable-merge (jasonmo@microsoft.com)
|
|
150
|
+
|
|
151
|
+
## 0.3.0
|
|
152
|
+
|
|
153
|
+
Sat, 01 Aug 2020 00:34:34 GMT
|
|
154
|
+
|
|
155
|
+
### Minor changes
|
|
156
|
+
|
|
157
|
+
- specify types for tests (krsiler@microsoft.com)
|
|
158
|
+
|
|
159
|
+
## 0.2.1
|
|
160
|
+
|
|
161
|
+
Wed, 29 Jul 2020 22:38:20 GMT
|
|
162
|
+
|
|
163
|
+
### Patches
|
|
164
|
+
|
|
165
|
+
- switch to using Lage for build sequencing (jasonmo@microsoft.com)
|
|
166
|
+
|
|
167
|
+
## 0.2.0
|
|
168
|
+
|
|
169
|
+
Tue, 28 Jul 2020 18:21:12 GMT
|
|
170
|
+
|
|
171
|
+
### Minor changes
|
|
172
|
+
|
|
173
|
+
- add experimental framework packages (jasonmo@microsoft.com)
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @fluentui-react-native/use-styling
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@uifabricshared/build-native/babel.config');
|
package/just.config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UseStylingOptions, TokenSettings, ThemeHelper, HasLayer } from '@fluentui-react-native/use-styling';
|
|
2
|
+
import { ComposableFunction } from '@fluentui-react-native/use-slot';
|
|
3
|
+
import { UseSlotOptions, Slots } from '@fluentui-react-native/use-slots';
|
|
4
|
+
export declare type UseStyledSlots<TProps, TSlotProps> = (props: TProps, lookup?: HasLayer) => Slots<TSlotProps>;
|
|
5
|
+
export declare type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<TProps, TSlotProps, TTokens, TTheme> & UseSlotOptions<TSlotProps> & {
|
|
6
|
+
/**
|
|
7
|
+
* Includes from UseStylingOptions:
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
displayName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* staged render function that takes props and a useSlots hook as an input
|
|
13
|
+
*/
|
|
14
|
+
render: (props: TProps, useSlots: UseStyledSlots<TProps, TSlotProps>) => React.FunctionComponent<TProps>;
|
|
15
|
+
/**
|
|
16
|
+
* optional statics to attach to the component
|
|
17
|
+
*/
|
|
18
|
+
statics?: TStatics;
|
|
19
|
+
};
|
|
20
|
+
export declare type ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = ComposableFunction<TProps> & {
|
|
21
|
+
__options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
22
|
+
customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
23
|
+
compose: (options: Partial<ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>>) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
24
|
+
} & TStatics;
|
|
25
|
+
export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>, themeHelper: ThemeHelper<TTheme>, base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
26
|
+
//# sourceMappingURL=composeFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.d.ts","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAmB,MAAM,oCAAoC,CAAC;AAC9H,OAAO,EAAE,kBAAkB,EAAmB,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAiB,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAGxF,oBAAY,cAAc,CAAC,MAAM,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,KAAK,KAAK,CAAC,UAAU,CAAC,CAAC;AAEzG,oBAAY,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,MAAM,IAAI,iBAAiB,CAC1H,MAAM,EACN,UAAU,EACV,OAAO,EACP,MAAM,CACP,GACC,cAAc,CAAC,UAAU,CAAC,GAAG;IAC3B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEzG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= 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
|
+
import { buildUseStyling } from '@fluentui-react-native/use-styling';
|
|
13
|
+
import { stagedComponent } from '@fluentui-react-native/use-slot';
|
|
14
|
+
import { buildUseSlots } from '@fluentui-react-native/use-slots';
|
|
15
|
+
import { immutableMergeCore } from '@fluentui-react-native/immutable-merge';
|
|
16
|
+
/**
|
|
17
|
+
* options get deep merged except the tokens array gets appended
|
|
18
|
+
*/
|
|
19
|
+
var mergeOptions = {
|
|
20
|
+
tokens: 'appendArray',
|
|
21
|
+
object: true,
|
|
22
|
+
};
|
|
23
|
+
export function composeFactory(options, themeHelper, base) {
|
|
24
|
+
// merge options together if a base is specified
|
|
25
|
+
var baseOptions = base === null || base === void 0 ? void 0 : base.__options;
|
|
26
|
+
options = baseOptions ? immutableMergeCore(mergeOptions, baseOptions, options) : __assign({}, options);
|
|
27
|
+
// build styling if styling options are specified
|
|
28
|
+
options.useStyling = options.slotProps || options.tokens ? buildUseStyling(options, themeHelper) : function () { return ({}); };
|
|
29
|
+
// build the slots hook, which will use the styling hook if it has been built
|
|
30
|
+
var useSlots = buildUseSlots(options);
|
|
31
|
+
// build the staged component
|
|
32
|
+
var component = stagedComponent(function (props) { return options.render(props, useSlots); });
|
|
33
|
+
// attach additional props to the returned component
|
|
34
|
+
component.displayName = options.displayName;
|
|
35
|
+
component.__options = options;
|
|
36
|
+
component.customize = function () {
|
|
37
|
+
var tokens = [];
|
|
38
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
39
|
+
tokens[_i] = arguments[_i];
|
|
40
|
+
}
|
|
41
|
+
return composeFactory(immutableMergeCore(mergeOptions, options, { tokens: tokens }), themeHelper);
|
|
42
|
+
};
|
|
43
|
+
component.compose = function (customOptions) {
|
|
44
|
+
return composeFactory(immutableMergeCore(mergeOptions, options, customOptions), themeHelper);
|
|
45
|
+
};
|
|
46
|
+
// attach statics if specified
|
|
47
|
+
if (options.statics) {
|
|
48
|
+
Object.assign(component, options.statics);
|
|
49
|
+
}
|
|
50
|
+
return component;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=composeFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.js","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAA2D,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC9H,OAAO,EAAsB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAkB,aAAa,EAAS,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAgB,MAAM,wCAAwC,CAAC;AAoC1F;;GAEG;AACH,IAAM,YAAY,GAAiB;IACjC,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,MAAM,UAAU,cAAc,CAC5B,OAA6E,EAC7E,WAAgC,EAChC,IAA6E;IAK7E,gDAAgD;IAChD,IAAM,WAAW,GAAiB,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAyB,CAAC;IAClE,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAe,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,cAAM,OAAO,CAAE,CAAC;IAE9G,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,cAAM,OAAA,CAAC,EAAiB,CAAA,EAAlB,CAAkB,CAAC;IAE5H,6EAA6E;IAC7E,IAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAuC,CAAC;IAE9E,6BAA6B;IAC7B,IAAM,SAAS,GAAG,eAAe,CAAS,UAAC,KAAK,IAAK,OAAA,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,EAA/B,CAA+B,CAAmB,CAAC;IAExG,oDAAoD;IACpD,SAAS,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC5C,SAAS,CAAC,SAAS,GAAG,OAAO,CAAC;IAC9B,SAAS,CAAC,SAAS,GAAG;QAAC,gBAAiC;aAAjC,UAAiC,EAAjC,qBAAiC,EAAjC,IAAiC;YAAjC,2BAAiC;;QACtD,OAAA,cAAc,CACZ,kBAAkB,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAkB,CAAC,EAC7E,WAAW,CACZ;IAHD,CAGC,CAAC;IAEJ,SAAS,CAAC,OAAO,GAAG,UAAC,aAAoC;QACvD,OAAA,cAAc,CACZ,kBAAkB,CAAC,YAAY,EAAE,OAAO,EAAE,aAAa,CAAiB,EACxE,WAAW,CACZ;IAHD,CAGC,CAAC;IAEJ,8BAA8B;IAC9B,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;KAC3C;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.test.d.ts","sourceRoot":"","sources":["../src/composeFactory.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
/** @jsx withSlots */
|
|
13
|
+
import { withSlots } from '@fluentui-react-native/use-slot';
|
|
14
|
+
import * as renderer from 'react-test-renderer';
|
|
15
|
+
import { composeFactory } from './composeFactory';
|
|
16
|
+
import { View, Text } from 'react-native';
|
|
17
|
+
var theme = {
|
|
18
|
+
values: {
|
|
19
|
+
backgroundColor: 'black',
|
|
20
|
+
color: 'white',
|
|
21
|
+
},
|
|
22
|
+
components: {},
|
|
23
|
+
};
|
|
24
|
+
var themeHelper = {
|
|
25
|
+
useTheme: function () { return theme; },
|
|
26
|
+
getComponentInfo: function (theme, name) {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = theme === null || theme === void 0 ? void 0 : theme.components) !== null && _a !== void 0 ? _a : theme.components[name];
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
function mergeProps(p1, p2) {
|
|
32
|
+
return __assign(__assign({}, p1), p2);
|
|
33
|
+
}
|
|
34
|
+
var Base = composeFactory({
|
|
35
|
+
tokens: [
|
|
36
|
+
function (t) { return ({
|
|
37
|
+
backgroundColor: t.values.backgroundColor,
|
|
38
|
+
color: t.values.color,
|
|
39
|
+
}); },
|
|
40
|
+
],
|
|
41
|
+
slotProps: {
|
|
42
|
+
outer: function (tokens) { return ({ style: { backgroundColor: tokens.backgroundColor } }); },
|
|
43
|
+
content: function (tokens) { return ({ style: { color: tokens.color } }); },
|
|
44
|
+
},
|
|
45
|
+
slots: {
|
|
46
|
+
outer: View,
|
|
47
|
+
content: Text,
|
|
48
|
+
},
|
|
49
|
+
render: function (props, useSlots) {
|
|
50
|
+
var Slots = useSlots(props);
|
|
51
|
+
return function (extra) { return (withSlots(Slots.outer, __assign({}, mergeProps(props, extra)),
|
|
52
|
+
withSlots(Slots.content, null, "Hello"))); };
|
|
53
|
+
},
|
|
54
|
+
}, themeHelper);
|
|
55
|
+
var Customized = Base.customize({ backgroundColor: 'pink' });
|
|
56
|
+
var mixinStyle = {
|
|
57
|
+
width: 30,
|
|
58
|
+
height: 20,
|
|
59
|
+
borderColor: 'green',
|
|
60
|
+
borderWidth: 1,
|
|
61
|
+
};
|
|
62
|
+
describe('composeFactory test suite', function () {
|
|
63
|
+
it('Base component render', function () {
|
|
64
|
+
var tree = renderer.create(withSlots(Base, { style: mixinStyle })).toJSON();
|
|
65
|
+
expect(tree).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
it('Base component render', function () {
|
|
68
|
+
var tree = renderer.create(withSlots(Customized, { style: mixinStyle })).toJSON();
|
|
69
|
+
expect(tree).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=composeFactory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.test.js","sourceRoot":"","sources":["../src/composeFactory.test.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,qBAAqB;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAa,IAAI,EAAE,IAAI,EAAyB,MAAM,cAAc,CAAC;AAa5E,IAAM,KAAK,GAAU;IACnB,MAAM,EAAE;QACN,eAAe,EAAE,OAAO;QACxB,KAAK,EAAE,OAAO;KACf;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAYF,IAAM,WAAW,GAAuB;IACtC,QAAQ,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACrB,gBAAgB,EAAE,UAAC,KAAY,EAAE,IAAY;;QAC3C,aAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,mCAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrD,CA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CAAC,2BAA2B,EAAE;IACpC,EAAE,CAAC,uBAAuB,EAAE;QAC1B,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAC,IAAI,IAAC,KAAK,EAAE,UAAU,GAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACnE,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE;QAC1B,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAC,UAAU,IAAC,KAAK,EAAE,UAAU,GAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UseStylingOptions, TokenSettings, ThemeHelper, HasLayer } from '@fluentui-react-native/use-styling';
|
|
2
|
+
import { ComposableFunction } from '@fluentui-react-native/use-slot';
|
|
3
|
+
import { UseSlotOptions, Slots } from '@fluentui-react-native/use-slots';
|
|
4
|
+
export declare type UseStyledSlots<TProps, TSlotProps> = (props: TProps, lookup?: HasLayer) => Slots<TSlotProps>;
|
|
5
|
+
export declare type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<TProps, TSlotProps, TTokens, TTheme> & UseSlotOptions<TSlotProps> & {
|
|
6
|
+
/**
|
|
7
|
+
* Includes from UseStylingOptions:
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
displayName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* staged render function that takes props and a useSlots hook as an input
|
|
13
|
+
*/
|
|
14
|
+
render: (props: TProps, useSlots: UseStyledSlots<TProps, TSlotProps>) => React.FunctionComponent<TProps>;
|
|
15
|
+
/**
|
|
16
|
+
* optional statics to attach to the component
|
|
17
|
+
*/
|
|
18
|
+
statics?: TStatics;
|
|
19
|
+
};
|
|
20
|
+
export declare type ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = ComposableFunction<TProps> & {
|
|
21
|
+
__options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
22
|
+
customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
23
|
+
compose: (options: Partial<ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>>) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
24
|
+
} & TStatics;
|
|
25
|
+
export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>, themeHelper: ThemeHelper<TTheme>, base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
|
|
26
|
+
//# sourceMappingURL=composeFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.d.ts","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAmB,MAAM,oCAAoC,CAAC;AAC9H,OAAO,EAAE,kBAAkB,EAAmB,MAAM,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AQ,CAAC,CAAC,KACnF,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC7E,GAAG,QAAQ,CAAC;AAUb,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,MAAM,EAClG,OAAO,EAAE,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAC7E,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,IAAI,CAAC,EAAE,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC5E,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAsCxE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var use_styling_1 = require("@fluentui-react-native/use-styling");
|
|
15
|
+
var use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
16
|
+
var use_slots_1 = require("@fluentui-react-native/use-slots");
|
|
17
|
+
var immutable_merge_1 = require("@fluentui-react-native/immutable-merge");
|
|
18
|
+
/**
|
|
19
|
+
* options get deep merged except the tokens array gets appended
|
|
20
|
+
*/
|
|
21
|
+
var mergeOptions = {
|
|
22
|
+
tokens: 'appendArray',
|
|
23
|
+
object: true,
|
|
24
|
+
};
|
|
25
|
+
function composeFactory(options, themeHelper, base) {
|
|
26
|
+
// merge options together if a base is specified
|
|
27
|
+
var baseOptions = base === null || base === void 0 ? void 0 : base.__options;
|
|
28
|
+
options = baseOptions ? immutable_merge_1.immutableMergeCore(mergeOptions, baseOptions, options) : __assign({}, options);
|
|
29
|
+
// build styling if styling options are specified
|
|
30
|
+
options.useStyling = options.slotProps || options.tokens ? use_styling_1.buildUseStyling(options, themeHelper) : function () { return ({}); };
|
|
31
|
+
// build the slots hook, which will use the styling hook if it has been built
|
|
32
|
+
var useSlots = use_slots_1.buildUseSlots(options);
|
|
33
|
+
// build the staged component
|
|
34
|
+
var component = use_slot_1.stagedComponent(function (props) { return options.render(props, useSlots); });
|
|
35
|
+
// attach additional props to the returned component
|
|
36
|
+
component.displayName = options.displayName;
|
|
37
|
+
component.__options = options;
|
|
38
|
+
component.customize = function () {
|
|
39
|
+
var tokens = [];
|
|
40
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
41
|
+
tokens[_i] = arguments[_i];
|
|
42
|
+
}
|
|
43
|
+
return composeFactory(immutable_merge_1.immutableMergeCore(mergeOptions, options, { tokens: tokens }), themeHelper);
|
|
44
|
+
};
|
|
45
|
+
component.compose = function (customOptions) {
|
|
46
|
+
return composeFactory(immutable_merge_1.immutableMergeCore(mergeOptions, options, customOptions), themeHelper);
|
|
47
|
+
};
|
|
48
|
+
// attach statics if specified
|
|
49
|
+
if (options.statics) {
|
|
50
|
+
Object.assign(component, options.statics);
|
|
51
|
+
}
|
|
52
|
+
return component;
|
|
53
|
+
}
|
|
54
|
+
exports.composeFactory = composeFactory;
|
|
55
|
+
//# sourceMappingURL=composeFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.js","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kEAA8H;AAC9H,4DA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C,OAAO,GAAG,UAAC,aAAoC;QACvD,OAAA,cAAc,CACZ,oCAAkB,CAAC,YAAY,EAAE,OAAO,EAAE,aAAa,CAAiB,EACxE,WAAW,CACZ;IAHD,CAGC,CAAC;IAEJ,8BAA8B;IAC9B,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;KAC3C;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AA1CD,wCA0CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.test.d.ts","sourceRoot":"","sources":["../src/composeFactory.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14
|
+
if (mod && mod.__esModule) return mod;
|
|
15
|
+
var result = {};
|
|
16
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
17
|
+
result["default"] = mod;
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
/** @jsx withSlots */
|
|
22
|
+
var use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
23
|
+
var renderer = __importStar(require("react-test-renderer"));
|
|
24
|
+
var composeFactory_1 = require("./composeFactory");
|
|
25
|
+
var react_native_1 = require("react-native");
|
|
26
|
+
var theme = {
|
|
27
|
+
values: {
|
|
28
|
+
backgroundColor: 'black',
|
|
29
|
+
color: 'white',
|
|
30
|
+
},
|
|
31
|
+
components: {},
|
|
32
|
+
};
|
|
33
|
+
var themeHelper = {
|
|
34
|
+
useTheme: function () { return theme; },
|
|
35
|
+
getComponentInfo: function (theme, name) {
|
|
36
|
+
var _a;
|
|
37
|
+
return (_a = theme === null || theme === void 0 ? void 0 : theme.components) !== null && _a !== void 0 ? _a : theme.components[name];
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
function mergeProps(p1, p2) {
|
|
41
|
+
return __assign(__assign({}, p1), p2);
|
|
42
|
+
}
|
|
43
|
+
var Base = composeFactory_1.composeFactory({
|
|
44
|
+
tokens: [
|
|
45
|
+
function (t) { return ({
|
|
46
|
+
backgroundColor: t.values.backgroundColor,
|
|
47
|
+
color: t.values.color,
|
|
48
|
+
}); },
|
|
49
|
+
],
|
|
50
|
+
slotProps: {
|
|
51
|
+
outer: function (tokens) { return ({ style: { backgroundColor: tokens.backgroundColor } }); },
|
|
52
|
+
content: function (tokens) { return ({ style: { color: tokens.color } }); },
|
|
53
|
+
},
|
|
54
|
+
slots: {
|
|
55
|
+
outer: react_native_1.View,
|
|
56
|
+
content: react_native_1.Text,
|
|
57
|
+
},
|
|
58
|
+
render: function (props, useSlots) {
|
|
59
|
+
var Slots = useSlots(props);
|
|
60
|
+
return function (extra) { return (use_slot_1.withSlots(Slots.outer, __assign({}, mergeProps(props, extra)),
|
|
61
|
+
use_slot_1.withSlots(Slots.content, null, "Hello"))); };
|
|
62
|
+
},
|
|
63
|
+
}, themeHelper);
|
|
64
|
+
var Customized = Base.customize({ backgroundColor: 'pink' });
|
|
65
|
+
var mixinStyle = {
|
|
66
|
+
width: 30,
|
|
67
|
+
height: 20,
|
|
68
|
+
borderColor: 'green',
|
|
69
|
+
borderWidth: 1,
|
|
70
|
+
};
|
|
71
|
+
describe('composeFactory test suite', function () {
|
|
72
|
+
it('Base component render', function () {
|
|
73
|
+
var tree = renderer.create(use_slot_1.withSlots(Base, { style: mixinStyle })).toJSON();
|
|
74
|
+
expect(tree).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
it('Base component render', function () {
|
|
77
|
+
var tree = renderer.create(use_slot_1.withSlots(Customized, { style: mixinStyle })).toJSON();
|
|
78
|
+
expect(tree).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=composeFactory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeFactory.test.js","sourceRoot":"","sources":["../src/composeFactory.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,qBAAqB;AACrB,4DAA4D;AAC5D,4DAAgD;AAChD,mDAAkE;AAClE,6CAA4E;AAa5E,IAAM,KAAK,GAAU;IACnB,MAAM,EAAE;QACN,eAAe,EAAE,OAAO;QACxB,KAAK,EAAE,OAAO;KACf;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAYF,IAAM,WAAW,GAAuB;IACtC,QAAQ,EAAE,cAAM,OAAA,KAAK,EAAL,CAAK;IACrB,gBAAgB,EAAE,UAAC,KAAY,EAAE,IAAY;;QAC3C,aAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,mCAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,CAAC;AAEF,SAAS,UAAU,CAAI,EAAK,EAAE,EAAK;IACjC,6BAAY,EAAE,GAAK,EAAE,EAAG;AAC1B,CAAC;AAED,IAAM,IAAI,GAAG,+BAAc,CACzB;IACE,MAAM,EAAE;QACN,UAAC,CAAC,IAAK,OAAA,CAAC;YACN,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,eAAe;YACzC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK;SACtB,CAAC,EAHK,CAGL;KACH;IACD,SAAS,EAAE;QACT,KAAK,EAAE,UAAC,MAAM,IAAK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EAAE,UAAU,GAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,sCAAiC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluentui-react-native/composition",
|
|
3
|
+
"version": "0.6.9",
|
|
4
|
+
"description": "Composition factories for building HOCs",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/microsoft/ui-fabric-react-native"
|
|
8
|
+
},
|
|
9
|
+
"main": "lib-commonjs/index.js",
|
|
10
|
+
"module": "lib/index.js",
|
|
11
|
+
"typings": "lib/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "fluentui-scripts build",
|
|
14
|
+
"bundle": "fluentui-scripts bundle",
|
|
15
|
+
"clean": "fluentui-scripts clean",
|
|
16
|
+
"depcheck": "fluentui-scripts depcheck",
|
|
17
|
+
"code-style": "fluentui-scripts code-style",
|
|
18
|
+
"just": "fluentui-scripts",
|
|
19
|
+
"lint": "fluentui-scripts eslint",
|
|
20
|
+
"start": "fluentui-scripts dev",
|
|
21
|
+
"start-test": "fluentui-scripts jest-watch",
|
|
22
|
+
"test": "fluentui-scripts jest",
|
|
23
|
+
"update-snapshots": "fluentui-scripts jest -u",
|
|
24
|
+
"prettier": "fluentui-scripts prettier",
|
|
25
|
+
"prettier-fix": "fluentui-scripts prettier --fix true"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@fluentui-react-native/immutable-merge": "^1.1.3",
|
|
32
|
+
"@fluentui-react-native/use-slot": ">=0.1.6 <1.0.0",
|
|
33
|
+
"@fluentui-react-native/use-slots": ">=0.5.8 <1.0.0",
|
|
34
|
+
"@fluentui-react-native/use-styling": ">=0.6.8 <1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/react-native": "^0.63.0",
|
|
38
|
+
"@uifabricshared/build-native": "^0.1.1",
|
|
39
|
+
"react-native": "^0.63.4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react-native": ">=0.63.4"
|
|
43
|
+
}
|
|
44
|
+
}
|