@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
package/.eslintrc.js
ADDED
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluentui-react-native/drawer",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Fri, 19 May 2023 04:14:17 GMT",
|
|
6
|
+
"tag": "@fluentui-react-native/drawer_v0.1.0",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "rohanpd.work@gmail.com",
|
|
12
|
+
"package": "@fluentui-react-native/drawer",
|
|
13
|
+
"commit": "0d8e1dfb40fb9fd109fc76ceb583c2a4c08cd309",
|
|
14
|
+
"comment": "feat: initial structuring for v1 js drawer"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Change Log - @fluentui-react-native/drawer
|
|
2
|
+
|
|
3
|
+
This log was last generated on Fri, 19 May 2023 04:14:17 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 0.1.0
|
|
8
|
+
|
|
9
|
+
Fri, 19 May 2023 04:14:17 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat: initial structuring for v1 js drawer (rohanpd.work@gmail.com)
|
package/SPEC.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Drawer
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@fluentui-react-native/scripts/babel.config');
|
package/jest.config.js
ADDED
package/just.config.js
ADDED
package/lib/Drawer.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DrawerProps } from './Drawer.types';
|
|
2
|
+
export declare const drawerLookup: (layer: string, userProps: DrawerProps) => boolean;
|
|
3
|
+
export declare const Drawer: import("@fluentui-react-native/framework").ComposableComponent<DrawerProps, import("./Drawer.types").DrawerSlotProps, import("./Drawer.types").DrawerTokens, object>;
|
|
4
|
+
//# sourceMappingURL=Drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI9D,eAAO,MAAM,YAAY,UAAW,MAAM,aAAa,WAAW,KAAG,OAEpE,CAAC;AAEF,eAAO,MAAM,MAAM,sKAmCjB,CAAC"}
|
package/lib/Drawer.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
/** @jsx withSlots */
|
|
24
|
+
import { Animated, Modal, TouchableWithoutFeedback, View } from 'react-native';
|
|
25
|
+
import { compose, mergeProps, withSlots } from '@fluentui-react-native/framework';
|
|
26
|
+
import { stylingSettings } from './Drawer.styling';
|
|
27
|
+
import { DrawerName } from './Drawer.types';
|
|
28
|
+
import { useDrawer } from './useDrawer';
|
|
29
|
+
export var drawerLookup = function (layer, userProps) {
|
|
30
|
+
return userProps[layer] || layer === userProps['drawerPosition'];
|
|
31
|
+
};
|
|
32
|
+
export var Drawer = compose(__assign(__assign({ displayName: DrawerName }, stylingSettings), { slots: {
|
|
33
|
+
modal: Modal,
|
|
34
|
+
scrim: TouchableWithoutFeedback,
|
|
35
|
+
scrimContent: Animated.View,
|
|
36
|
+
content: Animated.View,
|
|
37
|
+
handle: View,
|
|
38
|
+
}, useRender: function (userProps, useSlots) {
|
|
39
|
+
var drawerProps = useDrawer(userProps).props;
|
|
40
|
+
var Slots = useSlots(userProps, function (layer) { return drawerLookup(layer, drawerProps); });
|
|
41
|
+
return function (final, children) {
|
|
42
|
+
var _a = 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"]);
|
|
43
|
+
return (withSlots(Slots.modal, __assign({}, rest, { visible: open, onRequestClose: onClose, supportedOrientations: ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'], animationType: "none", transparent: true }),
|
|
44
|
+
withSlots(Slots.scrim, { onPress: onScrimClick },
|
|
45
|
+
withSlots(Slots.scrimContent, { style: [{ opacity: animationConfig.animatedOpacity }] })),
|
|
46
|
+
withSlots(Slots.content, { style: animationConfig.animatedStyle },
|
|
47
|
+
drawerPosition === 'bottom' && showHandle && withSlots(Slots.handle, null),
|
|
48
|
+
children)));
|
|
49
|
+
};
|
|
50
|
+
} }));
|
|
51
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAqB;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,S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AE,sBAAsB,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAC7G,aAAa,EAAC,MAAM,EACpB,WAAW;gBAEX,UAAC,KAAK,CAAC,KAAK,IAAC,OAAO,EAAE,YAAY;oBAChC,UAAC,KAAK,CAAC,YAAY,IAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,eAAe,EAAE,CAAC,GAAI,CACjE;gBACd,UAAC,KAAK,CAAC,OAAO,IAAC,KAAK,EAAE,eAAe,CAAC,aAAa;oBAChD,cAAc,KAAK,QAAQ,IAAI,UAAU,IAAI,UAAC,KAAK,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,47 @@
|
|
|
1
|
+
import { buildProps } from '@fluentui-react-native/framework';
|
|
2
|
+
import { DrawerName } from './Drawer.types';
|
|
3
|
+
import { defaultDrawerTokens } from './DrawerTokens';
|
|
4
|
+
export var stylingSettings = {
|
|
5
|
+
tokens: [defaultDrawerTokens, DrawerName],
|
|
6
|
+
tokensThatAreAlsoProps: 'all',
|
|
7
|
+
states: ['left', 'right', 'bottom'],
|
|
8
|
+
slotProps: {
|
|
9
|
+
scrimContent: buildProps(function (tokens, _theme) { return ({
|
|
10
|
+
style: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
top: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
width: '100%',
|
|
15
|
+
height: '100%',
|
|
16
|
+
backgroundColor: tokens.scrimColor,
|
|
17
|
+
opacity: tokens.scrimOpacity,
|
|
18
|
+
},
|
|
19
|
+
}); }, ['scrimColor']),
|
|
20
|
+
content: buildProps(function (tokens, _theme) { return ({
|
|
21
|
+
style: {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
height: tokens.height,
|
|
24
|
+
width: tokens.width,
|
|
25
|
+
elevation: tokens.drawerElevation,
|
|
26
|
+
borderTopEndRadius: tokens.drawerCornerRadius,
|
|
27
|
+
borderTopStartRadius: tokens.drawerCornerRadius,
|
|
28
|
+
right: tokens.rightPosition,
|
|
29
|
+
left: tokens.leftPosition,
|
|
30
|
+
bottom: tokens.bottomPosition,
|
|
31
|
+
top: tokens.topPosition,
|
|
32
|
+
backgroundColor: tokens.drawerBackgroundColor,
|
|
33
|
+
},
|
|
34
|
+
}); }, ['drawerBackgroundColor', 'drawerElevation', 'height', 'width']),
|
|
35
|
+
handle: buildProps(function (tokens, _theme) { return ({
|
|
36
|
+
style: {
|
|
37
|
+
width: tokens.handleWidth,
|
|
38
|
+
height: tokens.handleHeight,
|
|
39
|
+
borderRadius: tokens.handleCornerRadius,
|
|
40
|
+
backgroundColor: tokens.handleBackgroundColor,
|
|
41
|
+
alignSelf: tokens.handleAlignment,
|
|
42
|
+
marginTop: tokens.handleMarginTop,
|
|
43
|
+
},
|
|
44
|
+
}); }, ['handleWidth', 'handleHeight', 'handleCornerRadius', 'handleBackgroundColor', 'handleAlignment', 'handleMarginTop']),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Drawer.styling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.styling.js","sourceRoot":"","sources":["../src/Drawer.styling.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,CAAC,IAAM,eAAe,GAAkE;IAC5F,MAAM,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC;IACzC,sBAAsB,EAAE,KAAK;IAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;IACnC,SAAS,EAAE;QACT,YAAY,EAAE,UAAU,CACtB,UAAC,MAAoB,EAAE,MAAa,IAAK,OAAA,CAAC;YACxC,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,eAAe,EAAE,MAAM,CAAC,UAAU;gBAClC,OAAO,EAAE,MAAM,CAAC,YAAY;aAC7B;SACF,CAAC,EAVuC,CAUvC,EACF,CAAC,YAAY,CAAC,CACf;QACD,OAAO,EAAE,UAAU,CACjB,UAAC,MAAoB,EAAE,MAAa,IAAK,OAAA,CAAC;YACxC,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,SAAS,EAAE,MAAM,CAAC,eAAe;gBACjC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;gBAC7C,oBAAoB,EAAE,MAAM,CAAC,kBAAkB;gBAC/C,KAAK,EAAE,MAAM,CAAC,aAAa;gBAC3B,IAAI,EAAE,MAAM,CAAC,YAAY;gBACzB,MAAM,EAAE,MAAM,CAAC,cAAc;gBAC7B,GAAG,EAAE,MAAM,CAAC,WAAW;gBACvB,eAAe,EAAE,MAAM,CAAC,qBAAqB;aAC9C;SACF,CAAC,EAduC,CAcvC,EACF,CAAC,uBAAuB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAChE;QACD,MAAM,EAAE,UAAU,CAChB,UAAC,MAAoB,EAAE,MAAa,IAAK,OAAA,CAAC;YACxC,KAAK,EAAE;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,6BAA6B,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9H,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEtG,eAAO,MAAM,UAAU,WAAW,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B;;SAEK;IACL,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;SAEK;IACL,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;SAEK;IACL,qBAAqB,CAAC,EAAE,UAAU,CAAC;IAEnC;;SAEK;IACL,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;UAEM;IACN,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;SAEK;IAEL,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;SAEK;IAEL,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;SAEK;IAEL,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;SAEK;IACL,eAAe,CAAC,EAAE,aAAa,CAAC;IAEhC;;SAEK;IAEL,qBAAqB,CAAC,EAAE,UAAU,CAAC;IAEnC;;;SAGK;IACL,kBAAkB,C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AC;IAEpC;;;SAGK;IACL,6BAA6B,CAAC,EAAE,OAAO,CAAC;IAExC;;;SAGK;IACL,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;SAGK;IACL,eAAe,CAAC,EAAE;QAChB,eAAe,EAAE,QAAQ,CAAC,qBAAqB,CAAC;QAChD,aAAa,EAAE;YAAE,SAAS,EAAE;gBAAE,UAAU,EAAE,QAAQ,CAAC,qBAAqB,CAAA;aAAE,EAAE,GAAG;gBAAE,UAAU,EAAE,QAAQ,CAAC,qBAAqB,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,MAAM,CAAC,IAAM,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,37 @@
|
|
|
1
|
+
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
2
|
+
export var defaultDrawerTokens = function (t) {
|
|
3
|
+
return ({
|
|
4
|
+
scrimColor: '#00000080',
|
|
5
|
+
drawerBackgroundColor: t.colors.neutralBackground2,
|
|
6
|
+
handleBackgroundColor: t.colors.neutralStroke1,
|
|
7
|
+
handleWidth: globalTokens.size360,
|
|
8
|
+
handleHeight: globalTokens.size40,
|
|
9
|
+
handleCornerRadius: globalTokens.size20,
|
|
10
|
+
handleAlignment: 'center',
|
|
11
|
+
handleMarginTop: globalTokens.size80,
|
|
12
|
+
handleMarginBottom: globalTokens.sizeNone,
|
|
13
|
+
handleMarginEnd: globalTokens.sizeNone,
|
|
14
|
+
handleMarginStart: globalTokens.sizeNone,
|
|
15
|
+
drawerElevation: globalTokens.size100,
|
|
16
|
+
topPosition: 0,
|
|
17
|
+
left: {
|
|
18
|
+
height: '100%',
|
|
19
|
+
width: '80%',
|
|
20
|
+
leftPosition: 0,
|
|
21
|
+
drawerCornerRadius: 0,
|
|
22
|
+
},
|
|
23
|
+
right: {
|
|
24
|
+
height: '100%',
|
|
25
|
+
width: '80%',
|
|
26
|
+
rightPosition: 0,
|
|
27
|
+
drawerCornerRadius: 0,
|
|
28
|
+
},
|
|
29
|
+
bottom: {
|
|
30
|
+
bottomPosition: 0,
|
|
31
|
+
width: '100%',
|
|
32
|
+
drawerCornerRadius: globalTokens.corner.radius120,
|
|
33
|
+
height: '50%',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=DrawerTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerTokens.js","sourceRoot":"","sources":["../src/DrawerTokens.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAKnE,MAAM,CAAC,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,YAAY,CAAC,OAAO;QACjC,YAAY,EAAE,YAAY,CAAC,MAAM;QACjC,kBAAkB,EAAE,YAAY,CAAC,MAAM;QACvC,eAAe,EAAE,QAAQ;QACzB,eAAe,EAAE,YAAY,CAAC,MAAM;QACpC,kBAAkB,EAAE,YAAY,CAAC,QAAQ;QACzC,eAAe,EAAE,YAAY,CAAC,QAAQ;QACtC,iBAAiB,EAAE,YAAY,CAAC,QAAQ;QACxC,eAAe,EAAE,YAAY,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,YAAY,CAAC,MAAM,CAAC,SAAS;YACjD,MAAM,EAAE,KAAK;SACd;KACe,CAAA;AAhClB,CAgCkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/Drawer.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import * as renderer from 'react-test-renderer';
|
|
4
|
+
import { Drawer } from '../Drawer';
|
|
5
|
+
// mocks out setTimeout and other timer functions with mock functions , test will fail without this as we're using Animated API
|
|
6
|
+
jest.useFakeTimers();
|
|
7
|
+
describe('Drawer component tests', function () {
|
|
8
|
+
it('Drawer default', function () {
|
|
9
|
+
var tree = renderer
|
|
10
|
+
.create(React.createElement(Drawer, { open: false, drawerPosition: "left" },
|
|
11
|
+
React.createElement(Text, null, "Hello")))
|
|
12
|
+
.toJSON();
|
|
13
|
+
expect(tree).toMatchSnapshot();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
//# 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,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;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,MAAM,IAAC,IAAI,EAAE,KAAK,EAAE,cAAc,EAAC,MAAM;YACxC,oBAAC,IAAI,gBAAa,CACX,CACV;aACA,MAAM,EAAE,CAAC;QACZ,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,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"}
|
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,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -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"}
|
package/lib/useDrawer.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import { useRef, useEffect, useState, useCallback } from 'react';
|
|
24
|
+
import { Animated, Dimensions } from 'react-native';
|
|
25
|
+
var _a = Dimensions.get('window'), height = _a.height, width = _a.width;
|
|
26
|
+
export var useDrawer = function (props) {
|
|
27
|
+
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"]);
|
|
28
|
+
var animatedValue = useRef(new Animated.Value(0)).current;
|
|
29
|
+
var _c = useState(open), internalOpen = _c[0], setInternalOpen = _c[1];
|
|
30
|
+
var _d = useState(true), isFirstOpen = _d[0], setIsFirstOpen = _d[1];
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
if (open) {
|
|
33
|
+
setInternalOpen(true);
|
|
34
|
+
Animated.timing(animatedValue, {
|
|
35
|
+
toValue: 1,
|
|
36
|
+
duration: 300,
|
|
37
|
+
useNativeDriver: true,
|
|
38
|
+
}).start();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (isFirstOpen) {
|
|
42
|
+
setIsFirstOpen(false);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
Animated.parallel([
|
|
46
|
+
Animated.timing(animatedValue, {
|
|
47
|
+
toValue: 0,
|
|
48
|
+
duration: 300,
|
|
49
|
+
useNativeDriver: true,
|
|
50
|
+
}),
|
|
51
|
+
]).start(function () {
|
|
52
|
+
setInternalOpen(false);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, [animatedValue, open]);
|
|
57
|
+
var onClose = useCallback(function (e) {
|
|
58
|
+
(props === null || props === void 0 ? void 0 : props.onClose) && props.onClose(e);
|
|
59
|
+
}, [props === null || props === void 0 ? void 0 : props.onClose]);
|
|
60
|
+
var onScrimClick = useCallback(function (e) {
|
|
61
|
+
(props === null || props === void 0 ? void 0 : props.onScrimClick) && props.onScrimClick(e);
|
|
62
|
+
}, [props === null || props === void 0 ? void 0 : props.onScrimClick]);
|
|
63
|
+
var animatedTranslateX = animatedValue.interpolate({
|
|
64
|
+
inputRange: [0, 1],
|
|
65
|
+
outputRange: drawerPosition === 'left' ? [-width * 0.8, 0] : drawerPosition === 'right' ? [width * 0.8, 0] : [0, 0],
|
|
66
|
+
});
|
|
67
|
+
var animatedTranslateY = animatedValue.interpolate({
|
|
68
|
+
inputRange: [0, 1],
|
|
69
|
+
outputRange: [height, height * 0.5],
|
|
70
|
+
});
|
|
71
|
+
var animatedOpacity = animatedValue.interpolate({
|
|
72
|
+
inputRange: [0, 1],
|
|
73
|
+
outputRange: [0, 0.5],
|
|
74
|
+
});
|
|
75
|
+
var animatedStyle = {
|
|
76
|
+
transform: drawerPosition === 'left' || drawerPosition === 'right' ? [{ translateX: animatedTranslateX }] : [{ translateY: animatedTranslateY }],
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
props: __assign(__assign({}, rest), { onClose: onClose, onScrimClick: onScrimClick, animationConfig: {
|
|
80
|
+
animatedOpacity: animatedOpacity,
|
|
81
|
+
animatedStyle: animatedStyle,
|
|
82
|
+
}, drawerPosition: drawerPosition !== null && drawerPosition !== void 0 ? drawerPosition : 'left', children: children, showHandle: showHandle, open: internalOpen }),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=useDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawer.js","sourceRoot":"","sources":["../src/useDrawer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM9C,IAAA,KAAoB,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAA1C,MAAM,YAAA,EAAE,KAAK,WAA6B,CAAC;AAEnD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAAkB;IAClC,IAAA,MAAM,GAAuG,KAAK,OAA5G,EAAE,OAAO,GAA8F,KAAK,QAAnG,EAAE,kBAAkB,GAA0E,KAAK,mBAA/E,EAAE,IAAI,GAAoE,KAAK,KAAzE,EAAE,KAAkE,KAAK,eAAhD,EAAvB,cAAc,mBAAG,MAAM,KAAA,EAAE,KAAyC,KAAK,WAA7B,EAAjB,UAAU,mBAAG,IAAI,KAAA,EAAE,QAAQ,GAAc,KAAK,SAAnB,EAAK,IAAI,UAAK,KAAK,EAApH,+FAA4G,CAAF,CAAW;IAC3H,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACtD,IAAA,KAAkC,QAAQ,CAAC,IAAI,CAAC,EAA/C,YAAY,QAAA,EAAE,eAAe,QAAkB,CAAC;IACjD,IAAA,KAAgC,QAAQ,CAAC,IAAI,CAAC,EAA7C,WAAW,QAAA,EAAE,cAAc,QAAkB,CAAC;IAErD,SAAS,CAAC;QACR,IAAI,IAAI,EAAE;YACR,eAAe,CAAC,IA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AAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DrawerProps } from './Drawer.types';
|
|
2
|
+
export declare const drawerLookup: (layer: string, userProps: DrawerProps) => boolean;
|
|
3
|
+
export declare const Drawer: import("@fluentui-react-native/framework").ComposableComponent<DrawerProps, import("./Drawer.types").DrawerSlotProps, import("./Drawer.types").DrawerTokens, object>;
|
|
4
|
+
//# sourceMappingURL=Drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI9D,eAAO,MAAM,YAAY,UAAW,MAAM,aAAa,WAAW,KAAG,OAEpE,CAAC;AAEF,eAAO,MAAM,MAAM,sKAmCjB,CAAC"}
|