66 * Side Public License, v 1.
77 */
88
9- import React , {
10- forwardRef ,
11- FunctionComponent ,
12- Ref ,
13- CSSProperties ,
14- HTMLAttributes ,
15- ReactNode ,
16- } from 'react' ;
17- import classNames from 'classnames' ;
9+ import React , { FunctionComponent , Ref , ReactNode } from 'react' ;
1810
1911import {
2012 CommonProps ,
@@ -23,7 +15,6 @@ import {
2315 PropsForButton ,
2416} from '../common' ;
2517
26- import { EuiButtonContentDeprecated as EuiButtonContent } from './_button_content_deprecated' ;
2718import {
2819 BUTTON_COLORS ,
2920 useEuiButtonColorCSS ,
@@ -137,135 +128,3 @@ EuiButton.defaultProps = {
137128 size : 'm' ,
138129 color : 'primary' ,
139130} ;
140-
141- export type EuiButtonDisplayProps = EuiButtonProps &
142- HTMLAttributes < HTMLElement > & {
143- /**
144- * Provide a valid element to render the element as
145- */
146- element : 'a' | 'button' | 'span' | 'label' ;
147- /**
148- * Provide the component's base class name to build the class list on
149- */
150- baseClassName : string ;
151- } ;
152-
153- export const sizeToClassNameMap : { [ size in EuiButtonSize ] : string | null } = {
154- s : '--small' ,
155- m : null ,
156- } ;
157-
158- export const colorToClassNameMap : {
159- [ color in EuiButtonColor ] : string | null ;
160- } = {
161- primary : '--primary' ,
162- accent : '--accent' ,
163- success : '--success' ,
164- warning : '--warning' ,
165- danger : '--danger' ,
166- ghost : '--ghost' ,
167- text : '--text' ,
168- } ;
169-
170- /**
171- * *DEPRECATED*
172- * EuiButtonDisplay is an internal-only component used for displaying
173- * any element as a button.
174- * NOTE: This component *must* be below EuiButton in the file and
175- * EuiButton must also set a displayName for react-docgen-typescript
176- * to correctly set EuiButton's docgenInfo and display a props table.
177- * This component has been deprecated in favor of the new EuiButtonDisplay
178- * that can be found in `src/components/button/button_display/_button_display.tsx`
179- */
180- export const EuiButtonDisplayDeprecated = forwardRef <
181- HTMLElement ,
182- EuiButtonDisplayProps
183- > (
184- (
185- {
186- element = 'button' ,
187- baseClassName,
188- children,
189- className,
190- iconType,
191- iconSide = 'left' ,
192- color,
193- size = 'm' ,
194- isDisabled,
195- isLoading,
196- isSelected,
197- contentProps,
198- textProps,
199- fullWidth,
200- minWidth,
201- style,
202- ...rest
203- } ,
204- ref
205- ) => {
206- const buttonIsDisabled = isButtonDisabled ( { isLoading, isDisabled } ) ;
207-
208- const classes = classNames (
209- baseClassName ,
210- color && colorToClassNameMap [ color ]
211- ? `${ baseClassName } ${ colorToClassNameMap [ color ] } `
212- : undefined ,
213- size && sizeToClassNameMap [ size ]
214- ? `${ baseClassName } ${ sizeToClassNameMap [ size ] } `
215- : null ,
216- fullWidth && `${ baseClassName } --fullWidth` ,
217- className
218- ) ;
219-
220- /**
221- * Not changing the content or text class names to match baseClassName yet,
222- * as it is a major breaking change.
223- */
224- const contentClassNames = classNames (
225- 'euiButton__content' ,
226- contentProps && contentProps . className
227- ) ;
228-
229- const textClassNames = classNames (
230- 'euiButton__text' ,
231- textProps && textProps . className
232- ) ;
233-
234- const innerNode = (
235- < EuiButtonContent
236- isLoading = { isLoading }
237- iconType = { iconType }
238- iconSide = { iconSide }
239- textProps = { { ...textProps , className : textClassNames } }
240- { ...contentProps }
241- // className has to come last to override contentProps.className
242- className = { contentClassNames }
243- >
244- { children }
245- </ EuiButtonContent >
246- ) ;
247-
248- let calculatedStyle : CSSProperties | undefined = style ;
249- if ( minWidth !== undefined || minWidth !== null ) {
250- calculatedStyle = {
251- ...calculatedStyle ,
252- // @ts -ignore - deprecated component
253- minWidth,
254- } ;
255- }
256-
257- return React . createElement (
258- element ,
259- {
260- className : classes ,
261- style : calculatedStyle ,
262- disabled : element === 'button' && buttonIsDisabled ,
263- 'aria-pressed' : element === 'button' ? isSelected : undefined ,
264- ref,
265- ...rest ,
266- } ,
267- innerNode
268- ) ;
269- }
270- ) ;
271- EuiButtonDisplayDeprecated . displayName = 'EuiButtonDisplay' ;
0 commit comments