UNPKG

5.2 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var _colorManipulator = require("../styles/colorManipulator");
25
26var styles = function styles(theme) {
27 return {
28 /* Styles applied to the root element. */
29 root: {
30 height: 1,
31 margin: 0,
32 // Reset browser default style.
33 border: 'none',
34 flexShrink: 0,
35 backgroundColor: theme.palette.divider
36 },
37
38 /* Styles applied to the root element if `absolute={true}`. */
39 absolute: {
40 position: 'absolute',
41 bottom: 0,
42 left: 0,
43 width: '100%'
44 },
45
46 /* Styles applied to the root element if `variant="inset"`. */
47 inset: {
48 marginLeft: 72
49 },
50
51 /* Styles applied to the root element if `light={true}`. */
52 light: {
53 backgroundColor: (0, _colorManipulator.fade)(theme.palette.divider, 0.08)
54 },
55
56 /* Styles applied to the root element if `variant="middle"`. */
57 middle: {
58 marginLeft: theme.spacing(2),
59 marginRight: theme.spacing(2)
60 },
61
62 /* Styles applied to the root element if `orientation="vertical"`. */
63 vertical: {
64 height: '100%',
65 width: 1
66 },
67
68 /* Styles applied to the root element if `flexItem={true}`. */
69 flexItem: {
70 alignSelf: 'stretch',
71 height: 'auto'
72 }
73 };
74};
75
76exports.styles = styles;
77var Divider = /*#__PURE__*/React.forwardRef(function Divider(props, ref) {
78 var _props$absolute = props.absolute,
79 absolute = _props$absolute === void 0 ? false : _props$absolute,
80 classes = props.classes,
81 className = props.className,
82 _props$component = props.component,
83 Component = _props$component === void 0 ? 'hr' : _props$component,
84 _props$flexItem = props.flexItem,
85 flexItem = _props$flexItem === void 0 ? false : _props$flexItem,
86 _props$light = props.light,
87 light = _props$light === void 0 ? false : _props$light,
88 _props$orientation = props.orientation,
89 orientation = _props$orientation === void 0 ? 'horizontal' : _props$orientation,
90 _props$role = props.role,
91 role = _props$role === void 0 ? Component !== 'hr' ? 'separator' : undefined : _props$role,
92 _props$variant = props.variant,
93 variant = _props$variant === void 0 ? 'fullWidth' : _props$variant,
94 other = (0, _objectWithoutProperties2.default)(props, ["absolute", "classes", "className", "component", "flexItem", "light", "orientation", "role", "variant"]);
95 return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({
96 className: (0, _clsx.default)(classes.root, className, variant !== 'fullWidth' && classes[variant], absolute && classes.absolute, flexItem && classes.flexItem, light && classes.light, orientation === 'vertical' && classes.vertical),
97 role: role,
98 ref: ref
99 }, other));
100});
101process.env.NODE_ENV !== "production" ? Divider.propTypes = {
102 // ----------------------------- Warning --------------------------------
103 // | These PropTypes are generated from the TypeScript type definitions |
104 // | To update them edit the d.ts file and run "yarn proptypes" |
105 // ----------------------------------------------------------------------
106
107 /**
108 * Absolutely position the element.
109 */
110 absolute: _propTypes.default.bool,
111
112 /**
113 * @ignore
114 */
115 children: _propTypes.default.node,
116
117 /**
118 * Override or extend the styles applied to the component.
119 * See [CSS API](#css) below for more details.
120 */
121 classes: _propTypes.default.object,
122
123 /**
124 * @ignore
125 */
126 className: _propTypes.default.string,
127
128 /**
129 * The component used for the root node.
130 * Either a string to use a HTML element or a component.
131 */
132 component: _propTypes.default
133 /* @typescript-to-proptypes-ignore */
134 .elementType,
135
136 /**
137 * If `true`, a vertical divider will have the correct height when used in flex container.
138 * (By default, a vertical divider will have a calculated height of `0px` if it is the child of a flex container.)
139 */
140 flexItem: _propTypes.default.bool,
141
142 /**
143 * If `true`, the divider will have a lighter color.
144 */
145 light: _propTypes.default.bool,
146
147 /**
148 * The divider orientation.
149 */
150 orientation: _propTypes.default.oneOf(['horizontal', 'vertical']),
151
152 /**
153 * @ignore
154 */
155 role: _propTypes.default.string,
156
157 /**
158 * The variant to use.
159 */
160 variant: _propTypes.default.oneOf(['fullWidth', 'inset', 'middle'])
161} : void 0;
162
163var _default = (0, _withStyles.default)(styles, {
164 name: 'MuiDivider'
165})(Divider);
166
167exports.default = _default;
\No newline at end of file