UNPKG

2.19 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import { styled } from "../zero-styled/index.js";
7import memoTheme from "../utils/memoTheme.js";
8import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
9import capitalize from "../utils/capitalize.js";
10import { isHorizontal } from "../Drawer/Drawer.js";
11import { jsx as _jsx } from "react/jsx-runtime";
12const SwipeAreaRoot = styled('div', {
13 shouldForwardProp: rootShouldForwardProp
14})(memoTheme(({
15 theme
16}) => ({
17 position: 'fixed',
18 top: 0,
19 left: 0,
20 bottom: 0,
21 zIndex: theme.zIndex.drawer - 1,
22 variants: [{
23 props: {
24 anchor: 'left'
25 },
26 style: {
27 right: 'auto'
28 }
29 }, {
30 props: {
31 anchor: 'right'
32 },
33 style: {
34 left: 'auto',
35 right: 0
36 }
37 }, {
38 props: {
39 anchor: 'top'
40 },
41 style: {
42 bottom: 'auto',
43 right: 0
44 }
45 }, {
46 props: {
47 anchor: 'bottom'
48 },
49 style: {
50 top: 'auto',
51 bottom: 0,
52 right: 0
53 }
54 }]
55})));
56
57/**
58 * @ignore - internal component.
59 */
60const SwipeArea = /*#__PURE__*/React.forwardRef(function SwipeArea(props, ref) {
61 const {
62 anchor,
63 classes = {},
64 className,
65 width,
66 style,
67 ...other
68 } = props;
69 const ownerState = props;
70 return /*#__PURE__*/_jsx(SwipeAreaRoot, {
71 className: clsx('PrivateSwipeArea-root', classes.root, classes[`anchor${capitalize(anchor)}`], className),
72 ref: ref,
73 style: {
74 [isHorizontal(anchor) ? 'width' : 'height']: width,
75 ...style
76 },
77 ownerState: ownerState,
78 ...other
79 });
80});
81process.env.NODE_ENV !== "production" ? SwipeArea.propTypes = {
82 /**
83 * Side on which to attach the discovery area.
84 */
85 anchor: PropTypes.oneOf(['left', 'top', 'right', 'bottom']).isRequired,
86 /**
87 * @ignore
88 */
89 classes: PropTypes.object,
90 /**
91 * @ignore
92 */
93 className: PropTypes.string,
94 /**
95 * @ignore
96 */
97 style: PropTypes.object,
98 /**
99 * The width of the left most (or right most) area in `px` where the
100 * drawer can be swiped open from.
101 */
102 width: PropTypes.number.isRequired
103} : void 0;
104export default SwipeArea;
\No newline at end of file