@fluentui-react-native/drawer 0.1.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/.eslintrc.js +3 -0
- package/CHANGELOG.json +20 -0
- package/CHANGELOG.md +13 -0
- package/SPEC.md +1 -0
- package/babel.config.js +1 -0
- package/jest.config.js +2 -0
- package/just.config.js +3 -0
- package/lib/Drawer.d.ts +4 -0
- package/lib/Drawer.d.ts.map +1 -0
- package/lib/Drawer.js +51 -0
- package/lib/Drawer.js.map +1 -0
- package/lib/Drawer.styling.d.ts +4 -0
- package/lib/Drawer.styling.d.ts.map +1 -0
- package/lib/Drawer.styling.js +47 -0
- package/lib/Drawer.styling.js.map +1 -0
- package/lib/Drawer.types.d.ts +184 -0
- package/lib/Drawer.types.d.ts.map +1 -0
- package/lib/Drawer.types.js +2 -0
- package/lib/Drawer.types.js.map +1 -0
- package/lib/DrawerTokens.d.ts +5 -0
- package/lib/DrawerTokens.d.ts.map +1 -0
- package/lib/DrawerTokens.js +37 -0
- package/lib/DrawerTokens.js.map +1 -0
- package/lib/__tests__/Drawer.test.d.ts +2 -0
- package/lib/__tests__/Drawer.test.d.ts.map +1 -0
- package/lib/__tests__/Drawer.test.js +16 -0
- package/lib/__tests__/Drawer.test.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/useDrawer.d.ts +3 -0
- package/lib/useDrawer.d.ts.map +1 -0
- package/lib/useDrawer.js +85 -0
- package/lib/useDrawer.js.map +1 -0
- package/lib-commonjs/Drawer.d.ts +4 -0
- package/lib-commonjs/Drawer.d.ts.map +1 -0
- package/lib-commonjs/Drawer.js +55 -0
- package/lib-commonjs/Drawer.js.map +1 -0
- package/lib-commonjs/Drawer.styling.d.ts +4 -0
- package/lib-commonjs/Drawer.styling.d.ts.map +1 -0
- package/lib-commonjs/Drawer.styling.js +50 -0
- package/lib-commonjs/Drawer.styling.js.map +1 -0
- package/lib-commonjs/Drawer.types.d.ts +184 -0
- package/lib-commonjs/Drawer.types.d.ts.map +1 -0
- package/lib-commonjs/Drawer.types.js +5 -0
- package/lib-commonjs/Drawer.types.js.map +1 -0
- package/lib-commonjs/DrawerTokens.d.ts +5 -0
- package/lib-commonjs/DrawerTokens.d.ts.map +1 -0
- package/lib-commonjs/DrawerTokens.js +41 -0
- package/lib-commonjs/DrawerTokens.js.map +1 -0
- package/lib-commonjs/__tests__/Drawer.test.d.ts +2 -0
- package/lib-commonjs/__tests__/Drawer.test.d.ts.map +1 -0
- package/lib-commonjs/__tests__/Drawer.test.js +41 -0
- package/lib-commonjs/__tests__/Drawer.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +4 -0
- package/lib-commonjs/index.d.ts.map +1 -0
- package/lib-commonjs/index.js +8 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/useDrawer.d.ts +3 -0
- package/lib-commonjs/useDrawer.d.ts.map +1 -0
- package/lib-commonjs/useDrawer.js +89 -0
- package/lib-commonjs/useDrawer.js.map +1 -0
- package/package.json +59 -0
- package/src/Drawer.styling.ts +59 -0
- package/src/Drawer.tsx +51 -0
- package/src/Drawer.types.ts +221 -0
- package/src/DrawerTokens.ts +40 -0
- package/src/__tests__/Drawer.test.tsx +22 -0
- package/src/__tests__/__snapshots__/Drawer.test.tsx.snap +20 -0
- package/src/index.ts +3 -0
- package/src/useDrawer.ts +90 -0
- package/svgs.d.ts +4 -0
- package/tsconfig.json +8 -0
|
@@ -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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.Drawer = exports.drawerLookup = void 0;
|
|
26
|
+
/** @jsx withSlots */
|
|
27
|
+
var react_native_1 = require("react-native");
|
|
28
|
+
var framework_1 = require("@fluentui-react-native/framework");
|
|
29
|
+
var Drawer_styling_1 = require("./Drawer.styling");
|
|
30
|
+
var Drawer_types_1 = require("./Drawer.types");
|
|
31
|
+
var useDrawer_1 = require("./useDrawer");
|
|
32
|
+
var drawerLookup = function (layer, userProps) {
|
|
33
|
+
return userProps[layer] || layer === userProps['drawerPosition'];
|
|
34
|
+
};
|
|
35
|
+
exports.drawerLookup = drawerLookup;
|
|
36
|
+
exports.Drawer = (0, framework_1.compose)(__assign(__assign({ displayName: Drawer_types_1.DrawerName }, Drawer_styling_1.stylingSettings), { slots: {
|
|
37
|
+
modal: react_native_1.Modal,
|
|
38
|
+
scrim: react_native_1.TouchableWithoutFeedback,
|
|
39
|
+
scrimContent: react_native_1.Animated.View,
|
|
40
|
+
content: react_native_1.Animated.View,
|
|
41
|
+
handle: react_native_1.View,
|
|
42
|
+
}, useRender: function (userProps, useSlots) {
|
|
43
|
+
var drawerProps = (0, useDrawer_1.useDrawer)(userProps).props;
|
|
44
|
+
var Slots = useSlots(userProps, function (layer) { return (0, exports.drawerLookup)(layer, drawerProps); });
|
|
45
|
+
return function (final, children) {
|
|
46
|
+
var _a = (0, framework_1.mergeProps)(drawerProps, final), open = _a.open, onClose = _a.onClose, onScrimClick = _a.onScrimClick, animationConfig = _a.animationConfig, drawerPosition = _a.drawerPosition, showHandle = _a.showHandle, rest = __rest(_a, ["open", "onClose", "onScrimClick", "animationConfig", "drawerPosition", "showHandle"]);
|
|
47
|
+
return ((0, framework_1.withSlots)(Slots.modal, __assign({}, rest, { visible: open, onRequestClose: onClose, supportedOrientations: ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'], animationType: "none", transparent: true }),
|
|
48
|
+
(0, framework_1.withSlots)(Slots.scrim, { onPress: onScrimClick },
|
|
49
|
+
(0, framework_1.withSlots)(Slots.scrimContent, { style: [{ opacity: animationConfig.animatedOpacity }] })),
|
|
50
|
+
(0, framework_1.withSlots)(Slots.content, { style: animationConfig.animatedStyle },
|
|
51
|
+
drawerPosition === 'bottom' && showHandle && (0, framework_1.withSlots)(Slots.handle, null),
|
|
52
|
+
children)));
|
|
53
|
+
};
|
|
54
|
+
} }));
|
|
55
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAqB;AACrB,6CAA+E;AAG/E,8DAAkF;AAElF,mDAAmD;AAEnD,+CAA4C;AAC5C,yCAAwC;AAEjC,IAAM,YAAY,GAAG,UAAC,KAAa,EAAE,SAAsB;IAChE,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,SAAS,CAAC,gBAAgB,CAAC,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEW,QAAA,MAAM,GAAG,IAAA,mBAAO,sBAC3B,WAAW,EAAE,yBAAU,I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AAK,CAAC,MAAM,OAAG;oBAC7D,QAAQ,CACK,CACJ,CACf,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,IACD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UseStylingOptions } from '@fluentui-react-native/framework';
|
|
2
|
+
import type { DrawerTokens, DrawerSlotProps, DrawerProps } from './Drawer.types';
|
|
3
|
+
export declare const stylingSettings: UseStylingOptions<DrawerProps, DrawerSlotProps, DrawerTokens>;
|
|
4
|
+
//# sourceMappingURL=Drawer.styling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.styling.d.ts","sourceRoot":"","sources":["../src/Drawer.styling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAIjF,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGjF,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,WAAW,EAAE,eAAe,EAAE,YAAY,CAmDzF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stylingSettings = void 0;
|
|
4
|
+
var framework_1 = require("@fluentui-react-native/framework");
|
|
5
|
+
var Drawer_types_1 = require("./Drawer.types");
|
|
6
|
+
var DrawerTokens_1 = require("./DrawerTokens");
|
|
7
|
+
exports.stylingSettings = {
|
|
8
|
+
tokens: [DrawerTokens_1.defaultDrawerTokens, Drawer_types_1.DrawerName],
|
|
9
|
+
tokensThatAreAlsoProps: 'all',
|
|
10
|
+
states: ['left', 'right', 'bottom'],
|
|
11
|
+
slotProps: {
|
|
12
|
+
scrimContent: (0, framework_1.buildProps)(function (tokens, _theme) { return ({
|
|
13
|
+
style: {
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
width: '100%',
|
|
18
|
+
height: '100%',
|
|
19
|
+
backgroundColor: tokens.scrimColor,
|
|
20
|
+
opacity: tokens.scrimOpacity,
|
|
21
|
+
},
|
|
22
|
+
}); }, ['scrimColor']),
|
|
23
|
+
content: (0, framework_1.buildProps)(function (tokens, _theme) { return ({
|
|
24
|
+
style: {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
height: tokens.height,
|
|
27
|
+
width: tokens.width,
|
|
28
|
+
elevation: tokens.drawerElevation,
|
|
29
|
+
borderTopEndRadius: tokens.drawerCornerRadius,
|
|
30
|
+
borderTopStartRadius: tokens.drawerCornerRadius,
|
|
31
|
+
right: tokens.rightPosition,
|
|
32
|
+
left: tokens.leftPosition,
|
|
33
|
+
bottom: tokens.bottomPosition,
|
|
34
|
+
top: tokens.topPosition,
|
|
35
|
+
backgroundColor: tokens.drawerBackgroundColor,
|
|
36
|
+
},
|
|
37
|
+
}); }, ['drawerBackgroundColor', 'drawerElevation', 'height', 'width']),
|
|
38
|
+
handle: (0, framework_1.buildProps)(function (tokens, _theme) { return ({
|
|
39
|
+
style: {
|
|
40
|
+
width: tokens.handleWidth,
|
|
41
|
+
height: tokens.handleHeight,
|
|
42
|
+
borderRadius: tokens.handleCornerRadius,
|
|
43
|
+
backgroundColor: tokens.handleBackgroundColor,
|
|
44
|
+
alignSelf: tokens.handleAlignment,
|
|
45
|
+
marginTop: tokens.handleMarginTop,
|
|
46
|
+
},
|
|
47
|
+
}); }, ['handleWidth', 'handleHeight', 'handleCornerRadius', 'handleBackgroundColor', 'handleAlignment', 'handleMarginTop']),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=Drawer.styling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.styling.js","sourceRoot":"","sources":["../src/Drawer.styling.ts"],"names":[],"mappings":";;;AACA,8DAA8D;AAE9D,+CAA4C;AAE5C,+CAAqD;AAExC,QAAA,eA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AAE;gBACL,KAAK,EAAE,MAAM,CAAC,WAAW;gBACzB,MAAM,EAAE,MAAM,CAAC,YAAY;gBAC3B,YAAY,EAAE,MAAM,CAAC,kBAAkB;gBACvC,eAAe,EAAE,MAAM,CAAC,qBAAqB;gBAC7C,SAAS,EAAE,MAAM,CAAC,eAAe;gBACjC,SAAS,EAAE,MAAM,CAAC,eAAe;aAClC;SACF,CAAC,EATuC,CASvC,EACF,CAAC,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CACrH;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Animated, ColorValue, FlexAlignType, ModalProps, TouchableWithoutFeedbackProps, ViewProps } from 'react-native';
|
|
2
|
+
import type { InteractionEvent, PressableFocusProps } from '@fluentui-react-native/interactive-hooks';
|
|
3
|
+
export declare const DrawerName = "Drawer";
|
|
4
|
+
/**
|
|
5
|
+
* Specifies the possible position of the Drawer.
|
|
6
|
+
*/
|
|
7
|
+
export type DrawerPositionType = 'bottom' | 'left' | 'right';
|
|
8
|
+
export interface DrawerTokens {
|
|
9
|
+
/**
|
|
10
|
+
* The color of the scrim.
|
|
11
|
+
* */
|
|
12
|
+
scrimColor?: ColorValue;
|
|
13
|
+
/**
|
|
14
|
+
* The opacity of the scrim.
|
|
15
|
+
* */
|
|
16
|
+
scrimOpacity?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Width of the handle.
|
|
19
|
+
*/
|
|
20
|
+
handleWidth?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Height of the handle.
|
|
23
|
+
*/
|
|
24
|
+
handleHeight?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The background color of the handle.
|
|
27
|
+
* */
|
|
28
|
+
handleBackgroundColor?: ColorValue;
|
|
29
|
+
/**
|
|
30
|
+
* The corner radius of the handle.
|
|
31
|
+
* */
|
|
32
|
+
handleCornerRadius?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The top margin of the handle.
|
|
35
|
+
* */
|
|
36
|
+
handleMarginTop?: number;
|
|
37
|
+
/**
|
|
38
|
+
* The bottom margin of the handle.
|
|
39
|
+
* */
|
|
40
|
+
handleMarginBottom?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The start margin of the handle.
|
|
43
|
+
* */
|
|
44
|
+
handleMarginStart?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The end margin of the handle.
|
|
47
|
+
* */
|
|
48
|
+
handleMarginEnd?: number;
|
|
49
|
+
/**
|
|
50
|
+
* The flex alignment of the handle.
|
|
51
|
+
* */
|
|
52
|
+
handleAlignment?: FlexAlignType;
|
|
53
|
+
/**
|
|
54
|
+
* The background for drawer
|
|
55
|
+
* */
|
|
56
|
+
drawerBackgroundColor?: ColorValue;
|
|
57
|
+
/**
|
|
58
|
+
* The corner radius of the Drawer
|
|
59
|
+
* @default 0
|
|
60
|
+
* */
|
|
61
|
+
drawerCornerRadius?: number;
|
|
62
|
+
/**
|
|
63
|
+
* The elevation of the Drawer
|
|
64
|
+
* @default 5
|
|
65
|
+
* @platform android
|
|
66
|
+
* */
|
|
67
|
+
drawerElevation?: number;
|
|
68
|
+
/**
|
|
69
|
+
* The width of the Drawer
|
|
70
|
+
* Note: Only applicable when position is 'left' or 'right'
|
|
71
|
+
* @default '100%'
|
|
72
|
+
* */
|
|
73
|
+
width?: number | string;
|
|
74
|
+
/**
|
|
75
|
+
* The height of the Drawer
|
|
76
|
+
* Note: Only applicable when position is 'bottom'
|
|
77
|
+
* @default '40%'
|
|
78
|
+
* */
|
|
79
|
+
height?: number | string;
|
|
80
|
+
/**
|
|
81
|
+
* The shadow color of the Drawer
|
|
82
|
+
* @platform iOS
|
|
83
|
+
* */
|
|
84
|
+
shadowColor?: ColorValue;
|
|
85
|
+
/**
|
|
86
|
+
* The shadow offset of the Drawer
|
|
87
|
+
* @platform iOS
|
|
88
|
+
* */
|
|
89
|
+
shadowOffset?: {
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The shadow opacity of the Drawer
|
|
95
|
+
* @platform iOS
|
|
96
|
+
* */
|
|
97
|
+
shadowOpacity?: number;
|
|
98
|
+
/**
|
|
99
|
+
* The shadow radius of the Drawer
|
|
100
|
+
* @platform iOS
|
|
101
|
+
* */
|
|
102
|
+
shadowRadius?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Positions/Behaviours of the Drawer, This is used to apply different tokens for different positions.
|
|
105
|
+
*/
|
|
106
|
+
left?: DrawerTokens;
|
|
107
|
+
right?: DrawerTokens;
|
|
108
|
+
bottom?: DrawerTokens;
|
|
109
|
+
/**
|
|
110
|
+
* Coordinate position of the Drawer, This is used to position the Drawer at a particular coordinate.
|
|
111
|
+
*/
|
|
112
|
+
leftPosition?: number;
|
|
113
|
+
rightPosition?: number;
|
|
114
|
+
bottomPosition?: number;
|
|
115
|
+
topPosition?: number;
|
|
116
|
+
}
|
|
117
|
+
export interface DrawerProps extends PressableFocusProps {
|
|
118
|
+
accessibilityLabel?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Visibility of the Drawer
|
|
121
|
+
*/
|
|
122
|
+
open?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Callback when the Drawer is closed
|
|
125
|
+
* */
|
|
126
|
+
onClose?: (e: InteractionEvent) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Callback when the Drawer is opened
|
|
129
|
+
* */
|
|
130
|
+
onOpen?: (e: InteractionEvent) => void;
|
|
131
|
+
/**
|
|
132
|
+
* Callback when the scrim is clicked
|
|
133
|
+
* */
|
|
134
|
+
onScrimClick?: (e: InteractionEvent) => void;
|
|
135
|
+
/**
|
|
136
|
+
* The content of the Drawer
|
|
137
|
+
* */
|
|
138
|
+
children?: React.ReactNode;
|
|
139
|
+
/**
|
|
140
|
+
* The behavior of the Drawer
|
|
141
|
+
* @default 'left'
|
|
142
|
+
* */
|
|
143
|
+
drawerPosition?: DrawerPositionType;
|
|
144
|
+
/**
|
|
145
|
+
* The behavior is for only bottom drawer in which content is scrollable without expanding the bottom drawer
|
|
146
|
+
* @default false
|
|
147
|
+
* */
|
|
148
|
+
isContentScrollableUnexpanded?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* The behavior is for only bottom drawer in which handle can be hidden for some usecases
|
|
151
|
+
* @default true
|
|
152
|
+
* */
|
|
153
|
+
showHandle?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* The width of the Drawer
|
|
156
|
+
* Animation configuration for the Drawer
|
|
157
|
+
* */
|
|
158
|
+
animationConfig?: {
|
|
159
|
+
animatedOpacity: Animated.AnimatedInterpolation;
|
|
160
|
+
animatedStyle: {
|
|
161
|
+
transform: {
|
|
162
|
+
translateX: Animated.AnimatedInterpolation;
|
|
163
|
+
}[] | {
|
|
164
|
+
translateY: Animated.AnimatedInterpolation;
|
|
165
|
+
}[];
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export interface DrawerInfo {
|
|
170
|
+
props: DrawerProps;
|
|
171
|
+
}
|
|
172
|
+
export interface DrawerSlotProps {
|
|
173
|
+
modal: ModalProps;
|
|
174
|
+
scrim: TouchableWithoutFeedbackProps;
|
|
175
|
+
scrimContent: Animated.AnimatedProps<ViewProps>;
|
|
176
|
+
content: Animated.AnimatedProps<ViewProps>;
|
|
177
|
+
handle: ViewProps;
|
|
178
|
+
}
|
|
179
|
+
export interface DrawerType {
|
|
180
|
+
props: DrawerProps;
|
|
181
|
+
tokens: DrawerTokens;
|
|
182
|
+
slotProps: DrawerSlotProps;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=Drawer.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.types.d.ts","sourceRoot":"","sources":["../src/Drawer.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,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CAAA;aAAE,EAAE,CAAA;SAAE,CAAC;KACnI,CAAC;CACH;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,6BAA6B,CAAC;IACrC,YAAY,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC3C,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.types.js","sourceRoot":"","sources":["../src/Drawer.types.ts"],"names":[],"mappings":";;;AAIa,QAAA,UAAU,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Theme } from '@fluentui-react-native/framework';
|
|
2
|
+
import type { TokenSettings } from '@fluentui-react-native/use-styling';
|
|
3
|
+
import type { DrawerTokens } from './Drawer.types';
|
|
4
|
+
export declare const defaultDrawerTokens: TokenSettings<DrawerTokens, Theme>;
|
|
5
|
+
//# sourceMappingURL=DrawerTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerTokens.d.ts","sourceRoot":"","sources":["../src/DrawerTokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,YAAY,EAAE,KAAK,CAiC/C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultDrawerTokens = void 0;
|
|
4
|
+
var theme_tokens_1 = require("@fluentui-react-native/theme-tokens");
|
|
5
|
+
var defaultDrawerTokens = function (t) {
|
|
6
|
+
return ({
|
|
7
|
+
scrimColor: '#00000080',
|
|
8
|
+
drawerBackgroundColor: t.colors.neutralBackground2,
|
|
9
|
+
handleBackgroundColor: t.colors.neutralStroke1,
|
|
10
|
+
handleWidth: theme_tokens_1.globalTokens.size360,
|
|
11
|
+
handleHeight: theme_tokens_1.globalTokens.size40,
|
|
12
|
+
handleCornerRadius: theme_tokens_1.globalTokens.size20,
|
|
13
|
+
handleAlignment: 'center',
|
|
14
|
+
handleMarginTop: theme_tokens_1.globalTokens.size80,
|
|
15
|
+
handleMarginBottom: theme_tokens_1.globalTokens.sizeNone,
|
|
16
|
+
handleMarginEnd: theme_tokens_1.globalTokens.sizeNone,
|
|
17
|
+
handleMarginStart: theme_tokens_1.globalTokens.sizeNone,
|
|
18
|
+
drawerElevation: theme_tokens_1.globalTokens.size100,
|
|
19
|
+
topPosition: 0,
|
|
20
|
+
left: {
|
|
21
|
+
height: '100%',
|
|
22
|
+
width: '80%',
|
|
23
|
+
leftPosition: 0,
|
|
24
|
+
drawerCornerRadius: 0,
|
|
25
|
+
},
|
|
26
|
+
right: {
|
|
27
|
+
height: '100%',
|
|
28
|
+
width: '80%',
|
|
29
|
+
rightPosition: 0,
|
|
30
|
+
drawerCornerRadius: 0,
|
|
31
|
+
},
|
|
32
|
+
bottom: {
|
|
33
|
+
bottomPosition: 0,
|
|
34
|
+
width: '100%',
|
|
35
|
+
drawerCornerRadius: theme_tokens_1.globalTokens.corner.radius120,
|
|
36
|
+
height: '50%',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.defaultDrawerTokens = defaultDrawerTokens;
|
|
41
|
+
//# sourceMappingURL=DrawerTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerTokens.js","sourceRoot":"","sources":["../src/DrawerTokens.ts"],"names":[],"mappings":";;;AACA,oEAAmE;AAK5D,IAAM,mBAAmB,GAAuC,UAAC,CAAQ;IAC9E,OAAA,CAAC;QACC,UAAU,EAAE,WAAW;QACvB,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,kBAAkB;QAClD,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc;QAC9C,WAAW,EAAE,2BAAY,CAAC,OAAO;QACjC,YAAY,EAAE,2BAAY,CAAC,MAAM;QACjC,kBAAkB,EAAE,2BAAY,CAAC,MAAM;QACvC,eAAe,EAAE,QAAQ;QACzB,eAAe,EAAE,2BAAY,CAAC,MAAM;QACpC,kBAAkB,EAAE,2BAAY,CAAC,QAAQ;QACzC,eAAe,EAAE,2BAAY,CAAC,QAAQ;QACtC,iBAAiB,EAAE,2BAAY,CAAC,QAAQ;QACxC,eAAe,EAAE,2BAAY,CAAC,OAAO;QACrC,WAAW,EAAE,CAAC;QACd,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,CAAC;YACf,kBAAkB,EAAE,CAAC;SACtB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK;YACZ,aAAa,EAAE,CAAC;YAChB,kBAAkB,EAAE,CAAC;SACtB;QACD,MAAM,EAAE;YACN,cAAc,EAAE,CAAC;YACjB,KAAK,EAAE,MAAM;YACb,kBAAkB,EAAE,2BAAY,CAAC,MAAM,CAAC,SAAS;YACjD,MAAM,EAAE,KAAK;SACd;KACe,CAAA;AAhClB,CAgCkB,CAAC;AAjCR,QAAA,mBAAmB,uBAiCX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/Drawer.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var React = __importStar(require("react"));
|
|
27
|
+
var react_native_1 = require("react-native");
|
|
28
|
+
var renderer = __importStar(require("react-test-renderer"));
|
|
29
|
+
var Drawer_1 = require("../Drawer");
|
|
30
|
+
// mocks out setTimeout and other timer functions with mock functions , test will fail without this as we're using Animated API
|
|
31
|
+
jest.useFakeTimers();
|
|
32
|
+
describe('Drawer component tests', function () {
|
|
33
|
+
it('Drawer default', function () {
|
|
34
|
+
var tree = renderer
|
|
35
|
+
.create(React.createElement(Drawer_1.Drawer, { open: false, drawerPosition: "left" },
|
|
36
|
+
React.createElement(react_native_1.Text, null, "Hello")))
|
|
37
|
+
.toJSON();
|
|
38
|
+
expect(tree).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=Drawer.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.test.js","sourceRoot":"","sources":["../../src/__tests__/Drawer.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+B;AAC/B,6CAAoC;AAEpC,4DAAgD;AAEhD,oCAAmC;AAEnC,+HAA+H;AAC/H,IAAI,CAAC,aAAa,EAAE,CAAC;AAErB,QAAQ,CAAC,wBAAwB,EAAE;IACjC,EAAE,CAAC,gBAAgB,EAAE;QACnB,IAAM,IAAI,GAAG,QAAQ;aAClB,MAAM,CACL,oBAAC,eAAM,IAAC,IAAI,EAAE,KAAK,EAAE,cAAc,EAAC,MAAM;YACxC,oBAAC,mBAAI,gBAAa,CACX,CACV;aACA,MAAM,EAAE,CAAC;QACZ,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,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DrawerName = exports.Drawer = void 0;
|
|
4
|
+
var Drawer_1 = require("./Drawer");
|
|
5
|
+
Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Drawer_1.Drawer; } });
|
|
6
|
+
var Drawer_types_1 = require("./Drawer.types");
|
|
7
|
+
Object.defineProperty(exports, "DrawerName", { enumerable: true, get: function () { return Drawer_types_1.DrawerName; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,+CAA4C;AAAnC,0GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawer.d.ts","sourceRoot":"","sources":["../src/useDrawer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI9D,eAAO,MAAM,SAAS,UAAW,WAAW,KAAG,UAgF9C,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.useDrawer = void 0;
|
|
26
|
+
var react_1 = require("react");
|
|
27
|
+
var react_native_1 = require("react-native");
|
|
28
|
+
var _a = react_native_1.Dimensions.get('window'), height = _a.height, width = _a.width;
|
|
29
|
+
var useDrawer = function (props) {
|
|
30
|
+
var onBlur = props.onBlur, onFocus = props.onFocus, accessibilityLabel = props.accessibilityLabel, open = props.open, _a = props.drawerPosition, drawerPosition = _a === void 0 ? 'left' : _a, _b = props.showHandle, showHandle = _b === void 0 ? true : _b, children = props.children, rest = __rest(props, ["onBlur", "onFocus", "accessibilityLabel", "open", "drawerPosition", "showHandle", "children"]);
|
|
31
|
+
var animatedValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
32
|
+
var _c = (0, react_1.useState)(open), internalOpen = _c[0], setInternalOpen = _c[1];
|
|
33
|
+
var _d = (0, react_1.useState)(true), isFirstOpen = _d[0], setIsFirstOpen = _d[1];
|
|
34
|
+
(0, react_1.useEffect)(function () {
|
|
35
|
+
if (open) {
|
|
36
|
+
setInternalOpen(true);
|
|
37
|
+
react_native_1.Animated.timing(animatedValue, {
|
|
38
|
+
toValue: 1,
|
|
39
|
+
duration: 300,
|
|
40
|
+
useNativeDriver: true,
|
|
41
|
+
}).start();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (isFirstOpen) {
|
|
45
|
+
setIsFirstOpen(false);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
react_native_1.Animated.parallel([
|
|
49
|
+
react_native_1.Animated.timing(animatedValue, {
|
|
50
|
+
toValue: 0,
|
|
51
|
+
duration: 300,
|
|
52
|
+
useNativeDriver: true,
|
|
53
|
+
}),
|
|
54
|
+
]).start(function () {
|
|
55
|
+
setInternalOpen(false);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [animatedValue, open]);
|
|
60
|
+
var onClose = (0, react_1.useCallback)(function (e) {
|
|
61
|
+
(props === null || props === void 0 ? void 0 : props.onClose) && props.onClose(e);
|
|
62
|
+
}, [props === null || props === void 0 ? void 0 : props.onClose]);
|
|
63
|
+
var onScrimClick = (0, react_1.useCallback)(function (e) {
|
|
64
|
+
(props === null || props === void 0 ? void 0 : props.onScrimClick) && props.onScrimClick(e);
|
|
65
|
+
}, [props === null || props === void 0 ? void 0 : props.onScrimClick]);
|
|
66
|
+
var animatedTranslateX = animatedValue.interpolate({
|
|
67
|
+
inputRange: [0, 1],
|
|
68
|
+
outputRange: drawerPosition === 'left' ? [-width * 0.8, 0] : drawerPosition === 'right' ? [width * 0.8, 0] : [0, 0],
|
|
69
|
+
});
|
|
70
|
+
var animatedTranslateY = animatedValue.interpolate({
|
|
71
|
+
inputRange: [0, 1],
|
|
72
|
+
outputRange: [height, height * 0.5],
|
|
73
|
+
});
|
|
74
|
+
var animatedOpacity = animatedValue.interpolate({
|
|
75
|
+
inputRange: [0, 1],
|
|
76
|
+
outputRange: [0, 0.5],
|
|
77
|
+
});
|
|
78
|
+
var animatedStyle = {
|
|
79
|
+
transform: drawerPosition === 'left' || drawerPosition === 'right' ? [{ translateX: animatedTranslateX }] : [{ translateY: animatedTranslateY }],
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
props: __assign(__assign({}, rest), { onClose: onClose, onScrimClick: onScrimClick, animationConfig: {
|
|
83
|
+
animatedOpacity: animatedOpacity,
|
|
84
|
+
animatedStyle: animatedStyle,
|
|
85
|
+
}, drawerPosition: drawerPosition !== null && drawerPosition !== void 0 ? drawerPosition : 'left', children: children, showHandle: showHandle, open: internalOpen }),
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
exports.useDrawer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C,EAAE,CAAC,CAAC;KACpH,CAAC,CAAC;IAEH,IAAM,kBAAkB,GAAG,aAAa,CAAC,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAClB,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC;KACpC,CAAC,CAAC;IAEH,IAAM,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;QAChD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAClB,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC;KACtB,CAAC,CAAC;IAEH,IAAM,aAAa,GAAG;QACpB,SAAS,EACP,cAAc,KAAK,MAAM,IAAI,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;KACxI,CAAC;IAEF,OAAO;QACL,KAAK,wBACA,IAAI,KACP,OAAO,SAAA,EACP,YAAY,cAAA,EACZ,eAAe,EAAE;gBACf,eAAe,iBAAA;gBACf,aAAa,eAAA;aACd,EACD,cAAc,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,MAAM,EACxC,QAAQ,UAAA,EACR,UAAU,YAAA,EACV,IAAI,EAAE,YAAY,GACnB;KACF,CAAC;AACJ,CAAC,CAAC;AAhFW,QAAA,SAAS,aAgFpB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluentui-react-native/drawer",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A cross-platform Drawer component using the Fluent Design System",
|
|
5
|
+
"main": "lib-commonjs/index.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "fluentui-scripts build",
|
|
10
|
+
"clean": "fluentui-scripts clean",
|
|
11
|
+
"depcheck": "fluentui-scripts depcheck",
|
|
12
|
+
"just": "fluentui-scripts",
|
|
13
|
+
"lint": "fluentui-scripts eslint",
|
|
14
|
+
"test": "fluentui-scripts jest",
|
|
15
|
+
"update-snapshots": "fluentui-scripts jest -u",
|
|
16
|
+
"prettier": "fluentui-scripts prettier",
|
|
17
|
+
"prettier-fix": "fluentui-scripts prettier --fix true"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/microsoft/fluentui-react-native.git",
|
|
22
|
+
"directory": "packages/components/Drawer"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@fluentui-react-native/framework": "0.9.9",
|
|
26
|
+
"@fluentui-react-native/interactive-hooks": ">=0.22.30 <1.0.0",
|
|
27
|
+
"@fluentui-react-native/theme-tokens": "^0.24.6",
|
|
28
|
+
"@fluentui-react-native/use-styling": ">=0.9.4 <1.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@fluentui-react-native/eslint-config-rules": "^0.1.1",
|
|
32
|
+
"@fluentui-react-native/scripts": "^0.1.1",
|
|
33
|
+
"react": "17.0.2",
|
|
34
|
+
"react-native": "^0.68.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "17.0.2",
|
|
38
|
+
"react-native": "^0.68.0"
|
|
39
|
+
},
|
|
40
|
+
"author": "",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"rnx-kit": {
|
|
43
|
+
"kitType": "library",
|
|
44
|
+
"alignDeps": {
|
|
45
|
+
"presets": [
|
|
46
|
+
"microsoft/react-native"
|
|
47
|
+
],
|
|
48
|
+
"requirements": [
|
|
49
|
+
"react-native@0.68"
|
|
50
|
+
],
|
|
51
|
+
"capabilities": [
|
|
52
|
+
"core",
|
|
53
|
+
"core-android",
|
|
54
|
+
"core-ios",
|
|
55
|
+
"react"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|