@fluentui-react-native/drawer 0.5.0 → 0.5.3

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/lib/Drawer.d.ts +2 -7
  3. package/lib/Drawer.js +22 -37
  4. package/lib/Drawer.styling.d.ts +1 -1
  5. package/lib/Drawer.styling.js +42 -51
  6. package/lib/Drawer.types.d.ts +168 -179
  7. package/lib/Drawer.types.js +1 -1
  8. package/lib/DrawerTokens.d.ts +1 -1
  9. package/lib/DrawerTokens.js +32 -32
  10. package/lib/DrawerTokens.js.map +1 -1
  11. package/lib/__tests__/Drawer.test.d.ts +1 -1
  12. package/lib/__tests__/Drawer.test.js +12 -12
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.js +1 -1
  15. package/lib/useDrawer.d.ts +1 -1
  16. package/lib/useDrawer.d.ts.map +1 -1
  17. package/lib/useDrawer.js +67 -72
  18. package/lib/useDrawer.js.map +1 -1
  19. package/lib-commonjs/Drawer.d.ts +2 -7
  20. package/lib-commonjs/Drawer.js +29 -47
  21. package/lib-commonjs/Drawer.styling.d.ts +1 -1
  22. package/lib-commonjs/Drawer.styling.js +47 -56
  23. package/lib-commonjs/Drawer.types.d.ts +168 -179
  24. package/lib-commonjs/Drawer.types.js +3 -3
  25. package/lib-commonjs/DrawerTokens.d.ts +1 -1
  26. package/lib-commonjs/DrawerTokens.js +35 -35
  27. package/lib-commonjs/DrawerTokens.js.map +1 -1
  28. package/lib-commonjs/__tests__/Drawer.test.d.ts +1 -1
  29. package/lib-commonjs/__tests__/Drawer.test.js +46 -63
  30. package/lib-commonjs/index.d.ts +1 -1
  31. package/lib-commonjs/index.js +7 -17
  32. package/lib-commonjs/useDrawer.d.ts +1 -1
  33. package/lib-commonjs/useDrawer.d.ts.map +1 -1
  34. package/lib-commonjs/useDrawer.js +71 -76
  35. package/lib-commonjs/useDrawer.js.map +1 -1
  36. package/package.json +26 -25
  37. package/src/DrawerTokens.ts +1 -1
  38. package/src/useDrawer.ts +17 -6
  39. package/eslint.config.js +0 -3
@@ -1,35 +1,35 @@
1
1
  import { globalTokens } from '@fluentui-react-native/theme-tokens';
2
2
  export const defaultDrawerTokens = (t) => ({
3
- scrimColor: '#00000080', // to be replace with token in future based on design guidance
4
- drawerBackgroundColor: t.colors.neutralBackground2,
5
- handleBackgroundColor: t.colors.neutralStroke1,
6
- handleWidth: globalTokens.size360,
7
- handleHeight: globalTokens.size40,
8
- handleCornerRadius: globalTokens.size20,
9
- handleAlignment: 'center',
10
- handleMarginTop: globalTokens.size80,
11
- handleMarginBottom: globalTokens.sizeNone,
12
- handleMarginEnd: globalTokens.sizeNone,
13
- handleMarginStart: globalTokens.sizeNone,
14
- drawerElevation: globalTokens.size100,
15
- topPosition: 0,
16
- left: {
17
- height: '100%',
18
- width: '80%',
19
- leftPosition: 0,
20
- drawerCornerRadius: 0,
21
- },
22
- right: {
23
- height: '100%',
24
- width: '80%',
25
- rightPosition: 0,
26
- drawerCornerRadius: 0,
27
- },
28
- bottom: {
29
- bottomPosition: 0,
30
- width: '100%',
31
- drawerCornerRadius: globalTokens.corner.radius120,
32
- height: '50%',
33
- },
3
+ scrimColor: '#00000080', // to be replace with token in future based on design guidance
4
+ drawerBackgroundColor: t.colors.neutralBackground2,
5
+ handleBackgroundColor: t.colors.neutralStroke1,
6
+ handleWidth: globalTokens.size360,
7
+ handleHeight: globalTokens.size40,
8
+ handleCornerRadius: globalTokens.size20,
9
+ handleAlignment: 'center',
10
+ handleMarginTop: globalTokens.size80,
11
+ handleMarginBottom: globalTokens.sizeNone,
12
+ handleMarginEnd: globalTokens.sizeNone,
13
+ handleMarginStart: globalTokens.sizeNone,
14
+ drawerElevation: globalTokens.size100,
15
+ topPosition: 0,
16
+ left: {
17
+ height: '100%',
18
+ width: '80%',
19
+ leftPosition: 0,
20
+ drawerCornerRadius: 0,
21
+ },
22
+ right: {
23
+ height: '100%',
24
+ width: '80%',
25
+ rightPosition: 0,
26
+ drawerCornerRadius: 0,
27
+ },
28
+ bottom: {
29
+ bottomPosition: 0,
30
+ width: '100%',
31
+ drawerCornerRadius: globalTokens.corner.radius120,
32
+ height: '50%',
33
+ },
34
34
  });
35
- //# sourceMappingURL=DrawerTokens.js.map
35
+ //# sourceMappingURL=DrawerTokens.js.map
@@ -1 +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,MAAM,mBAAmB,GAAuC,CAAC,CAAQ,EAAE,EAAE,EACjF;IACC,UAAU,EAAE,WAAW,EAAE,8DAA8D;IACvF,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,kBAAkB;IAClD,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc;IAC9C,WAAW,EAAE,YAAY,CAAC,OAAO;IACjC,YAAY,EAAE,YAAY,CAAC,MAAM;IACjC,kBAAkB,EAAE,YAAY,CAAC,MAAM;IACvC,eAAe,EAAE,QAAQ;IACzB,eAAe,EAAE,YAAY,CAAC,MAAM;IACpC,kBAAkB,EAAE,YAAY,CAAC,QAAQ;IACzC,eAAe,EAAE,YAAY,CAAC,QAAQ;IACtC,iBAAiB,EAAE,YAAY,CAAC,QAAQ;IACxC,eAAe,EAAE,YAAY,CAAC,OAAO;IACrC,WAAW,EAAE,CAAC;IACd,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,KAAK;QACZ,YAAY,EAAE,CAAC;QACf,kBAAkB,EAAE,CAAC;KACtB;IACD,KAAK,EAAE;QACL,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,KAAK;QACZ,aAAa,EAAE,CAAC;QAChB,kBAAkB,EAAE,CAAC;KACtB;IACD,MAAM,EAAE;QACN,cAAc,EAAE,CAAC;QACjB,KAAK,EAAE,MAAM;QACb,kBAA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awer.test.d.ts.map
2
+ //# sourceMappingURL=Drawer.test.d.ts.map
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from 'react/jsx-runtime';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { act } from 'react';
3
3
  import { Text } from 'react-native';
4
4
  import * as renderer from 'react-test-renderer';
@@ -7,16 +7,16 @@ import * as renderer from 'react-test-renderer';
7
7
  jest.useFakeTimers();
8
8
  // Disable Drawer test, as it's still failing despite the line above
9
9
  describe('Drawer component tests', () => {
10
- it('Drawer default', () => {
11
- let component;
12
- act(() => {
13
- component = renderer.create(
14
- // <Drawer open={false} drawerPosition="left">
15
- _jsx(Text, { children: 'Hello' }),
16
- // </Drawer>,
17
- );
10
+ it('Drawer default', () => {
11
+ let component;
12
+ act(() => {
13
+ component = renderer.create(
14
+ // <Drawer open={false} drawerPosition="left">
15
+ _jsx(Text, { children: "Hello" })
16
+ // </Drawer>,
17
+ );
18
+ });
19
+ expect(component.toJSON()).toMatchSnapshot();
18
20
  });
19
- expect(component.toJSON()).toMatchSnapshot();
20
- });
21
21
  });
22
- //# sourceMappingURL=Drawer.test.js.map
22
+ //# sourceMappingURL=Drawer.test.js.map
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Drawer } from './Drawer';
2
2
  export type { DrawerProps, DrawerSlotProps, DrawerTokens, DrawerType, DrawerPositionType } from './Drawer.types';
3
3
  export { DrawerName } from './Drawer.types';
4
- //# sourceMappingURL=index.d.ts.map
4
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Drawer } from './Drawer';
2
2
  export { DrawerName } from './Drawer.types';
3
- //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
1
  import type { DrawerProps, DrawerInfo } from './Drawer.types';
2
2
  export declare const useDrawer: (props: DrawerProps) => DrawerInfo;
3
- //# sourceMappingURL=useDrawer.d.ts.map
3
+ //# sourceMappingURL=useDrawer.d.ts.map
@@ -1 +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,oCAgFrB,CAAC"}
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,oCA2FrB,CAAC"}
package/lib/useDrawer.js CHANGED
@@ -2,76 +2,71 @@ import { useRef, useEffect, useState, useCallback } from 'react';
2
2
  import { Animated, Dimensions } from 'react-native';
3
3
  const { height, width } = Dimensions.get('window');
4
4
  export const useDrawer = (props) => {
5
- const { onBlur, onFocus, accessibilityLabel, open, drawerPosition = 'left', showHandle = true, children, ...rest } = props;
6
- const animatedValue = useRef(new Animated.Value(0)).current;
7
- const [internalOpen, setInternalOpen] = useState(open);
8
- const [isFirstOpen, setIsFirstOpen] = useState(true);
9
- useEffect(() => {
10
- if (open) {
11
- setInternalOpen(true);
12
- Animated.timing(animatedValue, {
13
- toValue: 1,
14
- duration: 300,
15
- useNativeDriver: true,
16
- }).start();
17
- } else {
18
- if (isFirstOpen) {
19
- setIsFirstOpen(false);
20
- } else {
21
- Animated.parallel([
22
- Animated.timing(animatedValue, {
23
- toValue: 0,
24
- duration: 300,
25
- useNativeDriver: true,
26
- }),
27
- ]).start(() => {
28
- setInternalOpen(false);
29
- });
30
- }
31
- }
32
- }, [animatedValue, open]);
33
- const onClose = useCallback(
34
- (e) => {
35
- props?.onClose && props.onClose(e);
36
- },
37
- [props?.onClose],
38
- );
39
- const onScrimClick = useCallback(
40
- (e) => {
41
- props?.onScrimClick && props.onScrimClick(e);
42
- },
43
- [props?.onScrimClick],
44
- );
45
- const animatedTranslateX = animatedValue.interpolate({
46
- inputRange: [0, 1],
47
- outputRange: drawerPosition === 'left' ? [-width * 0.8, 0] : drawerPosition === 'right' ? [width * 0.8, 0] : [0, 0],
48
- });
49
- const animatedTranslateY = animatedValue.interpolate({
50
- inputRange: [0, 1],
51
- outputRange: [height, height * 0.5],
52
- });
53
- const animatedOpacity = animatedValue.interpolate({
54
- inputRange: [0, 1],
55
- outputRange: [0, 0.5],
56
- });
57
- const animatedStyle = {
58
- transform:
59
- drawerPosition === 'left' || drawerPosition === 'right' ? [{ translateX: animatedTranslateX }] : [{ translateY: animatedTranslateY }],
60
- };
61
- return {
62
- props: {
63
- ...rest,
64
- onClose,
65
- onScrimClick,
66
- animationConfig: {
67
- animatedOpacity,
68
- animatedStyle,
69
- },
70
- drawerPosition: drawerPosition ?? 'left',
71
- children,
72
- showHandle,
73
- open: internalOpen,
74
- },
75
- };
5
+ const { onBlur, onClose: onCloseProp, onFocus, onScrimClick: onScrimClickProp, accessibilityLabel, open, drawerPosition = 'left', showHandle = true, children, ...rest } = props;
6
+ const animatedValue = useRef(new Animated.Value(0)).current;
7
+ const [internalOpen, setInternalOpen] = useState(open);
8
+ const [isFirstOpen, setIsFirstOpen] = useState(true);
9
+ useEffect(() => {
10
+ if (open) {
11
+ setInternalOpen(true);
12
+ Animated.timing(animatedValue, {
13
+ toValue: 1,
14
+ duration: 300,
15
+ useNativeDriver: true,
16
+ }).start();
17
+ }
18
+ else {
19
+ if (isFirstOpen) {
20
+ setIsFirstOpen(false);
21
+ }
22
+ else {
23
+ Animated.parallel([
24
+ Animated.timing(animatedValue, {
25
+ toValue: 0,
26
+ duration: 300,
27
+ useNativeDriver: true,
28
+ }),
29
+ ]).start(() => {
30
+ setInternalOpen(false);
31
+ });
32
+ }
33
+ }
34
+ }, [animatedValue, isFirstOpen, open]);
35
+ const onClose = useCallback((e) => {
36
+ onCloseProp && onCloseProp(e);
37
+ }, [onCloseProp]);
38
+ const onScrimClick = useCallback((e) => {
39
+ onScrimClickProp && onScrimClickProp(e);
40
+ }, [onScrimClickProp]);
41
+ const animatedTranslateX = animatedValue.interpolate({
42
+ inputRange: [0, 1],
43
+ outputRange: drawerPosition === 'left' ? [-width * 0.8, 0] : drawerPosition === 'right' ? [width * 0.8, 0] : [0, 0],
44
+ });
45
+ const animatedTranslateY = animatedValue.interpolate({
46
+ inputRange: [0, 1],
47
+ outputRange: [height, height * 0.5],
48
+ });
49
+ const animatedOpacity = animatedValue.interpolate({
50
+ inputRange: [0, 1],
51
+ outputRange: [0, 0.5],
52
+ });
53
+ const animatedStyle = {
54
+ transform: drawerPosition === 'left' || drawerPosition === 'right' ? [{ translateX: animatedTranslateX }] : [{ translateY: animatedTranslateY }],
55
+ };
56
+ return {
57
+ props: {
58
+ ...rest,
59
+ onClose,
60
+ onScrimClick,
61
+ animationConfig: {
62
+ animatedOpacity,
63
+ animatedStyle,
64
+ },
65
+ drawerPosition: drawerPosition ?? 'left',
66
+ children,
67
+ showHandle,
68
+ open: internalOpen,
69
+ },
70
+ };
76
71
  };
77
- //# sourceMappingURL=useDrawer.js.map
72
+ //# sourceMappingURL=useDrawer.js.map
@@ -1 +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;AAMpD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAkB,EAAc,EAAE,CAAC;IAC3D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,EAAE,UAAU,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG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U,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAClB,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC;KACpC,CAAC,CAAC;IAEH,MAAM,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,MAAM,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,EAAE;YACL,GAAG,IAAI;YACP,OAAO;YACP,YAAY;YACZ,eAAe,EAAE;gBACf,eAAe;gBACf,aAAa;aACd;YACD,cAAc,EAAE,cAAc,IAAI,MAAM;YACxC,QAAQ;YACR,UAAU;YACV,IAAI,EAAE,YAAY;SACnB;KACF,CAAC;AAAA,CACH,CAAC"}
@@ -1,9 +1,4 @@
1
1
  import type { DrawerProps } from './Drawer.types';
2
2
  export declare const drawerLookup: (layer: string, userProps: DrawerProps) => boolean;
3
- export declare const Drawer: import('@fluentui-react-native/framework').ComposableComponent<
4
- DrawerProps,
5
- import('./Drawer.types').DrawerSlotProps,
6
- import('./Drawer.types').DrawerTokens,
7
- import('@fluentui-react-native/framework').ObjectBase
8
- >;
9
- //# sourceMappingURL=Drawer.d.ts.map
3
+ export declare const Drawer: import("@fluentui-react-native/framework").ComposableComponent<DrawerProps, import("./Drawer.types").DrawerSlotProps, import("./Drawer.types").DrawerTokens, import("@fluentui-react-native/framework").ObjectBase>;
4
+ //# sourceMappingURL=Drawer.d.ts.map
@@ -1,54 +1,36 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Drawer = exports.drawerLookup = void 0;
4
- const jsx_runtime_1 = require('@fluentui-react-native/framework-base/jsx-runtime');
4
+ const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
5
5
  /** @jsxImportSource @fluentui-react-native/framework-base */
6
- const react_native_1 = require('react-native');
7
- const framework_1 = require('@fluentui-react-native/framework');
8
- const Drawer_styling_1 = require('./Drawer.styling');
9
- const Drawer_types_1 = require('./Drawer.types');
10
- const useDrawer_1 = require('./useDrawer');
6
+ const react_native_1 = require("react-native");
7
+ const framework_1 = require("@fluentui-react-native/framework");
8
+ const Drawer_styling_1 = require("./Drawer.styling");
9
+ const Drawer_types_1 = require("./Drawer.types");
10
+ const useDrawer_1 = require("./useDrawer");
11
11
  const drawerLookup = (layer, userProps) => {
12
- return userProps[layer] || layer === userProps['drawerPosition'];
12
+ return userProps[layer] || layer === userProps['drawerPosition'];
13
13
  };
14
14
  exports.drawerLookup = drawerLookup;
15
15
  exports.Drawer = (0, framework_1.compose)({
16
- displayName: Drawer_types_1.DrawerName,
17
- ...Drawer_styling_1.stylingSettings,
18
- slots: {
19
- modal: react_native_1.Modal,
20
- scrim: react_native_1.TouchableWithoutFeedback,
21
- scrimContent: react_native_1.Animated.View,
22
- content: react_native_1.Animated.View,
23
- handle: react_native_1.View,
24
- },
25
- useRender: (userProps, useSlots) => {
26
- const drawerProps = (0, useDrawer_1.useDrawer)(userProps).props;
27
- const Slots = useSlots(userProps, (layer) => (0, exports.drawerLookup)(layer, drawerProps));
28
- return (final, children) => {
29
- const { open, onClose, onScrimClick, animationConfig, drawerPosition, showHandle, ...rest } = (0, framework_1.mergeProps)(
30
- drawerProps,
31
- final,
32
- );
33
- return jsx_runtime_1.jsxs(Slots.modal, {
34
- ...rest,
35
- visible: open,
36
- onRequestClose: onClose,
37
- supportedOrientations: ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'],
38
- animationType: 'none',
39
- transparent: true,
40
- children: [
41
- jsx_runtime_1.jsx(Slots.scrim, {
42
- onPress: onScrimClick,
43
- children: jsx_runtime_1.jsx(Slots.scrimContent, { style: [{ opacity: animationConfig.animatedOpacity }] }),
44
- }),
45
- jsx_runtime_1.jsxs(Slots.content, {
46
- style: animationConfig.animatedStyle,
47
- children: [drawerPosition === 'bottom' && showHandle && jsx_runtime_1.jsx(Slots.handle, {}), children],
48
- }),
49
- ],
50
- });
51
- };
52
- },
16
+ displayName: Drawer_types_1.DrawerName,
17
+ ...Drawer_styling_1.stylingSettings,
18
+ slots: {
19
+ modal: react_native_1.Modal,
20
+ scrim: react_native_1.TouchableWithoutFeedback,
21
+ scrimContent: react_native_1.Animated.View,
22
+ content: react_native_1.Animated.View,
23
+ handle: react_native_1.View,
24
+ },
25
+ useRender: (userProps, useSlots) => {
26
+ const drawerProps = (0, useDrawer_1.useDrawer)(userProps).props;
27
+ const Slots = useSlots(userProps, (layer) => (0, exports.drawerLookup)(layer, drawerProps));
28
+ return (final, children) => {
29
+ const { open, onClose, onScrimClick, animationConfig, drawerPosition, showHandle, ...rest } = (0, framework_1.mergeProps)(drawerProps, final);
30
+ return (jsx_runtime_1.jsxs(Slots.modal, { ...rest, visible: open, onRequestClose: onClose, supportedOrientations: ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'], animationType: "none", transparent: true, children: [
31
+ jsx_runtime_1.jsx(Slots.scrim, { onPress: onScrimClick, children: jsx_runtime_1.jsx(Slots.scrimContent, { style: [{ opacity: animationConfig.animatedOpacity }] }) }), jsx_runtime_1.jsxs(Slots.content, { style: animationConfig.animatedStyle, children: [drawerPosition === 'bottom' && showHandle && jsx_runtime_1.jsx(Slots.handle, {}), children] })
32
+ ] }));
33
+ };
34
+ },
53
35
  });
54
- //# sourceMappingURL=Drawer.js.map
36
+ //# sourceMappingURL=Drawer.js.map
@@ -1,4 +1,4 @@
1
1
  import type { UseStylingOptions } from '@fluentui-react-native/framework';
2
2
  import type { DrawerTokens, DrawerSlotProps, DrawerProps } from './Drawer.types';
3
3
  export declare const stylingSettings: UseStylingOptions<DrawerProps, DrawerSlotProps, DrawerTokens>;
4
- //# sourceMappingURL=Drawer.styling.d.ts.map
4
+ //# sourceMappingURL=Drawer.styling.d.ts.map
@@ -1,59 +1,50 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stylingSettings = void 0;
4
- const framework_1 = require('@fluentui-react-native/framework');
5
- const Drawer_types_1 = require('./Drawer.types');
6
- const DrawerTokens_1 = require('./DrawerTokens');
4
+ const framework_1 = require("@fluentui-react-native/framework");
5
+ const Drawer_types_1 = require("./Drawer.types");
6
+ const DrawerTokens_1 = require("./DrawerTokens");
7
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)(
13
- (tokens, _theme) => ({
14
- style: {
15
- position: 'absolute',
16
- top: 0,
17
- left: 0,
18
- width: '100%',
19
- height: '100%',
20
- backgroundColor: tokens.scrimColor,
21
- opacity: tokens.scrimOpacity,
22
- },
23
- }),
24
- ['scrimColor'],
25
- ),
26
- content: (0, framework_1.buildProps)(
27
- (tokens, _theme) => ({
28
- style: {
29
- position: 'absolute',
30
- height: tokens.height,
31
- width: tokens.width,
32
- elevation: tokens.drawerElevation,
33
- borderTopEndRadius: tokens.drawerCornerRadius,
34
- borderTopStartRadius: tokens.drawerCornerRadius,
35
- right: tokens.rightPosition,
36
- left: tokens.leftPosition,
37
- bottom: tokens.bottomPosition,
38
- top: tokens.topPosition,
39
- backgroundColor: tokens.drawerBackgroundColor,
40
- },
41
- }),
42
- ['drawerBackgroundColor', 'drawerElevation', 'height', 'width'],
43
- ),
44
- handle: (0, framework_1.buildProps)(
45
- (tokens, _theme) => ({
46
- style: {
47
- width: tokens.handleWidth,
48
- height: tokens.handleHeight,
49
- borderRadius: tokens.handleCornerRadius,
50
- backgroundColor: tokens.handleBackgroundColor,
51
- alignSelf: tokens.handleAlignment,
52
- marginTop: tokens.handleMarginTop,
53
- },
54
- }),
55
- ['handleWidth', 'handleHeight', 'handleCornerRadius', 'handleBackgroundColor', 'handleAlignment', 'handleMarginTop'],
56
- ),
57
- },
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)((tokens, _theme) => ({
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)((tokens, _theme) => ({
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)((tokens, _theme) => ({
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
+ },
58
49
  };
59
- //# sourceMappingURL=Drawer.styling.js.map
50
+ //# sourceMappingURL=Drawer.styling.js.map