UNPKG

4.22 kBJavaScriptView Raw
1"use strict";
2'use client';
3
4var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6Object.defineProperty(exports, "__esModule", {
7 value: true
8});
9exports.default = NotchedOutline;
10var React = _interopRequireWildcard(require("react"));
11var _propTypes = _interopRequireDefault(require("prop-types"));
12var _rootShouldForwardProp = _interopRequireDefault(require("../styles/rootShouldForwardProp"));
13var _zeroStyled = require("../zero-styled");
14var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
15var _jsxRuntime = require("react/jsx-runtime");
16var _span;
17const NotchedOutlineRoot = (0, _zeroStyled.styled)('fieldset', {
18 shouldForwardProp: _rootShouldForwardProp.default
19})({
20 textAlign: 'left',
21 position: 'absolute',
22 bottom: 0,
23 right: 0,
24 top: -5,
25 left: 0,
26 margin: 0,
27 padding: '0 8px',
28 pointerEvents: 'none',
29 borderRadius: 'inherit',
30 borderStyle: 'solid',
31 borderWidth: 1,
32 overflow: 'hidden',
33 minWidth: '0%'
34});
35const NotchedOutlineLegend = (0, _zeroStyled.styled)('legend', {
36 shouldForwardProp: _rootShouldForwardProp.default
37})((0, _memoTheme.default)(({
38 theme
39}) => ({
40 float: 'unset',
41 // Fix conflict with bootstrap
42 width: 'auto',
43 // Fix conflict with bootstrap
44 overflow: 'hidden',
45 // Fix Horizontal scroll when label too long
46 variants: [{
47 props: ({
48 ownerState
49 }) => !ownerState.withLabel,
50 style: {
51 padding: 0,
52 lineHeight: '11px',
53 // sync with `height` in `legend` styles
54 transition: theme.transitions.create('width', {
55 duration: 150,
56 easing: theme.transitions.easing.easeOut
57 })
58 }
59 }, {
60 props: ({
61 ownerState
62 }) => ownerState.withLabel,
63 style: {
64 display: 'block',
65 // Fix conflict with normalize.css and sanitize.css
66 padding: 0,
67 height: 11,
68 // sync with `lineHeight` in `legend` styles
69 fontSize: '0.75em',
70 visibility: 'hidden',
71 maxWidth: 0.01,
72 transition: theme.transitions.create('max-width', {
73 duration: 50,
74 easing: theme.transitions.easing.easeOut
75 }),
76 whiteSpace: 'nowrap',
77 '& > span': {
78 paddingLeft: 5,
79 paddingRight: 5,
80 display: 'inline-block',
81 opacity: 0,
82 visibility: 'visible'
83 }
84 }
85 }, {
86 props: ({
87 ownerState
88 }) => ownerState.withLabel && ownerState.notched,
89 style: {
90 maxWidth: '100%',
91 transition: theme.transitions.create('max-width', {
92 duration: 100,
93 easing: theme.transitions.easing.easeOut,
94 delay: 50
95 })
96 }
97 }]
98})));
99
100/**
101 * @ignore - internal component.
102 */
103function NotchedOutline(props) {
104 const {
105 children,
106 classes,
107 className,
108 label,
109 notched,
110 ...other
111 } = props;
112 const withLabel = label != null && label !== '';
113 const ownerState = {
114 ...props,
115 notched,
116 withLabel
117 };
118 return /*#__PURE__*/(0, _jsxRuntime.jsx)(NotchedOutlineRoot, {
119 "aria-hidden": true,
120 className: className,
121 ownerState: ownerState,
122 ...other,
123 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(NotchedOutlineLegend, {
124 ownerState: ownerState,
125 children: withLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
126 children: label
127 }) : // notranslate needed while Google Translate will not fix zero-width space issue
128 _span || (_span = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
129 className: "notranslate",
130 children: "\u200B"
131 }))
132 })
133 });
134}
135process.env.NODE_ENV !== "production" ? NotchedOutline.propTypes /* remove-proptypes */ = {
136 /**
137 * The content of the component.
138 */
139 children: _propTypes.default.node,
140 /**
141 * Override or extend the styles applied to the component.
142 */
143 classes: _propTypes.default.object,
144 /**
145 * @ignore
146 */
147 className: _propTypes.default.string,
148 /**
149 * The label.
150 */
151 label: _propTypes.default.node,
152 /**
153 * If `true`, the outline is notched to accommodate the label.
154 */
155 notched: _propTypes.default.bool.isRequired,
156 /**
157 * @ignore
158 */
159 style: _propTypes.default.object
160} : void 0;
\No newline at end of file