UNPKG

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