UNPKG

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