@rnw-community/object-field-tree 0.52.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/readme.md +22 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnw-community/object-field-tree",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "Create a object fields combinations tree with data generator function",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"object field tree",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"clear": "rm -rf coverage && rm -rf dist && rm -f *.tsbuildinfo",
|
|
45
45
|
"clear:deps": "rm -rf ./node_modules && rm -rf ./dist"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4ea55d84a33098abf2830f86bb94ba44f7ee0c20",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@rnw-community/shared": "^0.
|
|
49
|
+
"@rnw-community/shared": "^0.53.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@rnw-community/shared": "^0.46.0"
|
package/readme.md
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Utility for generating complex nested objects with data generation callback and full TypeScript support
|
|
4
4
|
with IDE autocompletion.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
[](https://badge.fury.io/js/%40rnw-community%2Fobject-field-tree)
|
|
7
|
+
[](https://www.npmjs.com/package/%40rnw-community%2Fobject-field-tree)
|
|
8
|
+
|
|
9
|
+
`combine((...keys) => data, ...objects)`
|
|
7
10
|
|
|
8
11
|
Real world usage examples:
|
|
9
12
|
[@rnw-community/fast-style](https://github.com/rnw-community/rnw-community/tree/master/packages/fast-style)
|
|
@@ -23,19 +26,20 @@ import { WidgetStyles } from './widget.styles';
|
|
|
23
26
|
enum ScienceEnum {
|
|
24
27
|
'Mathematics' = 'Mathematics Science',
|
|
25
28
|
'Physics' = 'Physics Science',
|
|
26
|
-
'Chemistry' = 'Chemistry Science'
|
|
29
|
+
'Chemistry' = 'Chemistry Science',
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
const complexityObject = {
|
|
30
33
|
Easy: 'Easy',
|
|
31
34
|
Medium: 'Medium',
|
|
32
35
|
Hard: 'Hard',
|
|
33
|
-
}
|
|
36
|
+
};
|
|
34
37
|
|
|
35
|
-
const tree = combine(
|
|
38
|
+
const tree = combine(
|
|
39
|
+
(science, complexity) => ({
|
|
36
40
|
science: ScienceEnum[science],
|
|
37
41
|
complexity: complexityObject[complexity],
|
|
38
|
-
complexData: `${science}_${complexity}
|
|
42
|
+
complexData: `${science}_${complexity}`,
|
|
39
43
|
}),
|
|
40
44
|
ScienceEnum,
|
|
41
45
|
complexityObject
|
|
@@ -62,26 +66,28 @@ enum WidgetHeightEnum {
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
const widgetWidthMap = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
+
Third: WidgetStyles.thrirdWidth,
|
|
70
|
+
TwoThirds: WidgetStyles.twoThrirdsWidth,
|
|
71
|
+
Full: WidgetStyles.fullWidth,
|
|
72
|
+
};
|
|
69
73
|
|
|
70
74
|
const widgetHeightStyleMap = {
|
|
71
75
|
[WidgetHeightEnum.Small]: WidgetStyles.smallHeight,
|
|
72
76
|
[WidgetHeightEnum.Medium]: WidgetStyles.MediumHeight,
|
|
73
|
-
}
|
|
77
|
+
};
|
|
74
78
|
|
|
75
79
|
export const Widget = combine(
|
|
76
|
-
(height, width) =>
|
|
80
|
+
(height, width) => props => <View {...props} style={[widgetHeightStyleMap[height], widgetWidthMap[width]]} />,
|
|
77
81
|
WidgetHeightEnum,
|
|
78
82
|
widgetWidthMap
|
|
79
83
|
);
|
|
80
84
|
|
|
81
85
|
// Widget usage
|
|
82
|
-
const Component = () =>
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
</
|
|
86
|
+
const Component = () => (
|
|
87
|
+
<Widget.Small.Full>
|
|
88
|
+
<View>
|
|
89
|
+
<Text>Hello!</Text>
|
|
90
|
+
</View>
|
|
91
|
+
</Widget.Small.Full>
|
|
92
|
+
);
|
|
87
93
|
```
|