@hh.ru/magritte-ui-button 7.2.8 → 7.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Button.js CHANGED
@@ -10,7 +10,7 @@ import { useButton } from './aria.js';
10
10
  import { isIconElement, IconDynamic } from '@hh.ru/magritte-ui-icon';
11
11
  import { Loader } from '@hh.ru/magritte-ui-loader';
12
12
 
13
- var styles = {"button":"magritte-button___Pubhr_7-2-8","button_loading":"magritte-button_loading___tSd9G_7-2-8","buttonLoading":"magritte-button__loading___lYs93_7-2-8","button-view":"magritte-button-view___53Slm_7-2-8","buttonView":"magritte-button-view___53Slm_7-2-8","button__content":"magritte-button__content___BXYU0_7-2-8","buttonContent":"magritte-button__content___BXYU0_7-2-8","button_size-medium":"magritte-button_size-medium___WvUsb_7-2-8","buttonSizeMedium":"magritte-button_size-medium___WvUsb_7-2-8","button_size-large":"magritte-button_size-large___Gjw7e_7-2-8","buttonSizeLarge":"magritte-button_size-large___Gjw7e_7-2-8","button__label":"magritte-button__label___zplmt_7-2-8","buttonLabel":"magritte-button__label___zplmt_7-2-8","button__subcaption":"magritte-button__subcaption___SSASN_7-2-8","buttonSubcaption":"magritte-button_subcaption___0-hG0_7-2-8","button_size-small":"magritte-button_size-small___ZAmsS_7-2-8","buttonSizeSmall":"magritte-button_size-small___ZAmsS_7-2-8","button_stretched":"magritte-button_stretched___-aXS6_7-2-8","buttonStretched":"magritte-button_stretched___-aXS6_7-2-8","button-postfix":"magritte-button-postfix___0rpTU_7-2-8","buttonPostfix":"magritte-button-postfix___0rpTU_7-2-8","button__icon":"magritte-button__icon___912gw_7-2-8","buttonIcon":"magritte-button__icon___912gw_7-2-8","button_with-icon":"magritte-button_with-icon___znqnP_7-2-8","buttonWithIcon":"magritte-button_with-icon___znqnP_7-2-8","button_with-postfix":"magritte-button_with-postfix___iB7I6_7-2-8","buttonWithPostfix":"magritte-button_with-postfix___iB7I6_7-2-8","button_centred":"magritte-button_centred___7nw81_7-2-8","buttonCentred":"magritte-button_centred___7nw81_7-2-8","button_subcaption":"magritte-button_subcaption___0-hG0_7-2-8","button_textless":"magritte-button_textless___XBvNJ_7-2-8","buttonTextless":"magritte-button_textless___XBvNJ_7-2-8","button__loading":"magritte-button__loading___lYs93_7-2-8","animation-timeout":"magritte-animation-timeout___IVFRG_7-2-8","animationTimeout":"magritte-animation-timeout___IVFRG_7-2-8","enter-animation":"magritte-enter-animation___tJoZW_7-2-8","enterAnimation":"magritte-enter-animation___tJoZW_7-2-8","enter-animation-active":"magritte-enter-animation-active___RRYSD_7-2-8","enterAnimationActive":"magritte-enter-animation-active___RRYSD_7-2-8","exit-animation":"magritte-exit-animation___BleRA_7-2-8","exitAnimation":"magritte-exit-animation___BleRA_7-2-8","exit-animation-active":"magritte-exit-animation-active___i0EAM_7-2-8","exitAnimationActive":"magritte-exit-animation-active___i0EAM_7-2-8","button_style-neutral":"magritte-button_style-neutral___I5qS5_7-2-8","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_7-2-8","button_mode-primary":"magritte-button_mode-primary___wU8PN_7-2-8","buttonModePrimary":"magritte-button_mode-primary___wU8PN_7-2-8","button-with-icon-color":"magritte-button-with-icon-color___IbNQO_7-2-8","buttonWithIconColor":"magritte-button-with-icon-color___IbNQO_7-2-8","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_7-2-8","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_7-2-8","on-surface":"magritte-on-surface___sOxCu_7-2-8","onSurface":"magritte-on-surface___sOxCu_7-2-8","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_7-2-8","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_7-2-8","button_style-accent":"magritte-button_style-accent___TE21J_7-2-8","buttonStyleAccent":"magritte-button_style-accent___TE21J_7-2-8","button_style-positive":"magritte-button_style-positive___i-dJx_7-2-8","buttonStylePositive":"magritte-button_style-positive___i-dJx_7-2-8","button_style-negative":"magritte-button_style-negative___B2CVQ_7-2-8","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_7-2-8","button_style-constant":"magritte-button_style-constant___vP0wU_7-2-8","buttonStyleConstant":"magritte-button_style-constant___vP0wU_7-2-8","button_style-special":"magritte-button_style-special___qi7Yf_7-2-8","buttonStyleSpecial":"magritte-button_style-special___qi7Yf_7-2-8","button-postfix_size-large":"magritte-button-postfix_size-large___6fupR_7-2-8","buttonPostfixSizeLarge":"magritte-button-postfix_size-large___6fupR_7-2-8","button-postfix_size-medium":"magritte-button-postfix_size-medium___CKs6F_7-2-8","buttonPostfixSizeMedium":"magritte-button-postfix_size-medium___CKs6F_7-2-8","button-postfix_size-small":"magritte-button-postfix_size-small___p9vHk_7-2-8","buttonPostfixSizeSmall":"magritte-button-postfix_size-small___p9vHk_7-2-8"};
13
+ var styles = {"button":"magritte-button___Pubhr_7-2-10","button_loading":"magritte-button_loading___tSd9G_7-2-10","buttonLoading":"magritte-button__loading___lYs93_7-2-10","button-view":"magritte-button-view___53Slm_7-2-10","buttonView":"magritte-button-view___53Slm_7-2-10","button__content":"magritte-button__content___BXYU0_7-2-10","buttonContent":"magritte-button__content___BXYU0_7-2-10","button_size-medium":"magritte-button_size-medium___WvUsb_7-2-10","buttonSizeMedium":"magritte-button_size-medium___WvUsb_7-2-10","button_size-large":"magritte-button_size-large___Gjw7e_7-2-10","buttonSizeLarge":"magritte-button_size-large___Gjw7e_7-2-10","button__label":"magritte-button__label___zplmt_7-2-10","buttonLabel":"magritte-button__label___zplmt_7-2-10","button__subcaption":"magritte-button__subcaption___SSASN_7-2-10","buttonSubcaption":"magritte-button_subcaption___0-hG0_7-2-10","button_size-small":"magritte-button_size-small___ZAmsS_7-2-10","buttonSizeSmall":"magritte-button_size-small___ZAmsS_7-2-10","button_stretched":"magritte-button_stretched___-aXS6_7-2-10","buttonStretched":"magritte-button_stretched___-aXS6_7-2-10","button-postfix":"magritte-button-postfix___0rpTU_7-2-10","buttonPostfix":"magritte-button-postfix___0rpTU_7-2-10","button__icon":"magritte-button__icon___912gw_7-2-10","buttonIcon":"magritte-button__icon___912gw_7-2-10","button_with-icon":"magritte-button_with-icon___znqnP_7-2-10","buttonWithIcon":"magritte-button_with-icon___znqnP_7-2-10","button_with-postfix":"magritte-button_with-postfix___iB7I6_7-2-10","buttonWithPostfix":"magritte-button_with-postfix___iB7I6_7-2-10","button_centred":"magritte-button_centred___7nw81_7-2-10","buttonCentred":"magritte-button_centred___7nw81_7-2-10","button_subcaption":"magritte-button_subcaption___0-hG0_7-2-10","button_textless":"magritte-button_textless___XBvNJ_7-2-10","buttonTextless":"magritte-button_textless___XBvNJ_7-2-10","button__loading":"magritte-button__loading___lYs93_7-2-10","animation-timeout":"magritte-animation-timeout___IVFRG_7-2-10","animationTimeout":"magritte-animation-timeout___IVFRG_7-2-10","enter-animation":"magritte-enter-animation___tJoZW_7-2-10","enterAnimation":"magritte-enter-animation___tJoZW_7-2-10","enter-animation-active":"magritte-enter-animation-active___RRYSD_7-2-10","enterAnimationActive":"magritte-enter-animation-active___RRYSD_7-2-10","exit-animation":"magritte-exit-animation___BleRA_7-2-10","exitAnimation":"magritte-exit-animation___BleRA_7-2-10","exit-animation-active":"magritte-exit-animation-active___i0EAM_7-2-10","exitAnimationActive":"magritte-exit-animation-active___i0EAM_7-2-10","button_style-neutral":"magritte-button_style-neutral___I5qS5_7-2-10","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_7-2-10","button_mode-primary":"magritte-button_mode-primary___wU8PN_7-2-10","buttonModePrimary":"magritte-button_mode-primary___wU8PN_7-2-10","button-with-icon-color":"magritte-button-with-icon-color___IbNQO_7-2-10","buttonWithIconColor":"magritte-button-with-icon-color___IbNQO_7-2-10","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_7-2-10","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_7-2-10","on-surface":"magritte-on-surface___sOxCu_7-2-10","onSurface":"magritte-on-surface___sOxCu_7-2-10","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_7-2-10","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_7-2-10","button_style-accent":"magritte-button_style-accent___TE21J_7-2-10","buttonStyleAccent":"magritte-button_style-accent___TE21J_7-2-10","button_style-positive":"magritte-button_style-positive___i-dJx_7-2-10","buttonStylePositive":"magritte-button_style-positive___i-dJx_7-2-10","button_style-negative":"magritte-button_style-negative___B2CVQ_7-2-10","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_7-2-10","button_style-constant":"magritte-button_style-constant___vP0wU_7-2-10","buttonStyleConstant":"magritte-button_style-constant___vP0wU_7-2-10","button_style-special":"magritte-button_style-special___qi7Yf_7-2-10","buttonStyleSpecial":"magritte-button_style-special___qi7Yf_7-2-10","button-postfix_size-large":"magritte-button-postfix_size-large___6fupR_7-2-10","buttonPostfixSizeLarge":"magritte-button-postfix_size-large___6fupR_7-2-10","button-postfix_size-medium":"magritte-button-postfix_size-medium___CKs6F_7-2-10","buttonPostfixSizeMedium":"magritte-button-postfix_size-medium___CKs6F_7-2-10","button-postfix_size-small":"magritte-button-postfix_size-small___p9vHk_7-2-10","buttonPostfixSizeSmall":"magritte-button-postfix_size-small___p9vHk_7-2-10"};
14
14
 
15
15
  const ALLOWED_BADGE_SIZES = ['small', 'extra-small'];
16
16
  const ButtonForwardRefRenderFunc = (props, ref) => {
@@ -47,11 +47,9 @@ const ButtonForwardRefRenderFunc = (props, ref) => {
47
47
  [styles.buttonWithPostfix]: !!postfix,
48
48
  [styles.buttonCentred]: !spaceBetween,
49
49
  [styles.buttonWithIconColor]: iconWithColor,
50
- }), disabled: forceDisabled || !!disabled, tabIndex: loading ? -1 : undefined, ...additionalAttributes, ...buttonProps, children: jsx(IconDynamic, { stretched: true, children: jsx("span", { className: styles.buttonView, children: jsxs("span", { className: styles.button__content, children: [postfix && (jsx("span", { className: classnames(styles.buttonPostfix, {
50
+ }), disabled: forceDisabled || !!disabled, tabIndex: loading ? -1 : undefined, "aria-label": ariaLabel, ...additionalAttributes, ...buttonProps, children: jsx(IconDynamic, { stretched: true, children: jsx("span", { className: styles.buttonView, children: jsxs("span", { className: styles.button__content, children: [postfix && (jsx("span", { className: classnames(styles.buttonPostfix, {
51
51
  [styles[`button-postfix_size-${size}`]]: size,
52
- }), children: postfix })), icon && (jsx("span", { className: styles.button__icon, children: React.cloneElement(icon, hideLabel
53
- ? { 'aria-label': ariaLabel }
54
- : { 'aria-hidden': true, focusable: false }) })), children && !hideLabel && jsx("span", { className: styles.button__label, children: children }), withSubcaption && jsx("span", { className: styles.button__subcaption, children: subcaption }), jsx(CSSTransition, { in: loading, nodeRef: loaderRef, timeout: tokenSemanticAnimationTimeMDuration, classNames: {
52
+ }), children: postfix })), icon && (jsx("span", { className: styles.button__icon, children: React.cloneElement(icon, { 'aria-hidden': true }) })), children && !hideLabel && jsx("span", { className: styles.button__label, children: children }), withSubcaption && jsx("span", { className: styles.button__subcaption, children: subcaption }), jsx(CSSTransition, { in: loading, nodeRef: loaderRef, timeout: tokenSemanticAnimationTimeMDuration, classNames: {
55
53
  enter: styles.enterAnimation,
56
54
  enterActive: styles.enterAnimationActive,
57
55
  exit: styles.exitAnimation,
package/Button.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useDisabled, DisabledContext } from '@hh.ru/magritte-common-use-disabled';\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport { BadgeSize, ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport { useButton } from '@hh.ru/magritte-ui-button/aria';\nimport type { ButtonProps } from '@hh.ru/magritte-ui-button/types';\nimport { IconDynamic, isIconElement } from '@hh.ru/magritte-ui-icon';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './button.less';\n\nconst ALLOWED_BADGE_SIZES: BadgeSize[] = ['small', 'extra-small'];\n\nconst ButtonForwardRefRenderFunc: PolymorphicForwardRefRenderFunc<ButtonProps, 'button'> = (props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n postfix,\n Element = 'button',\n hideLabel = false,\n icon,\n loading,\n mode,\n size = 'medium',\n stretched,\n style = 'neutral',\n subcaption,\n type = 'button',\n disabled = false,\n badge,\n spaceBetween = true,\n onSurface,\n ...buttonProps\n } = props;\n\n const forceDisabled = useDisabled();\n const { ariaProps: additionalAttributes } = useButton({ disabled: !!disabled || forceDisabled, Element });\n const loaderRef = useRef<HTMLSpanElement>(null);\n\n const iconWithColor =\n icon &&\n isIconElement(icon) &&\n (!!icon.props.initialColor || !!icon.props.highlightedColor || !!icon.props.disabledColor);\n\n if (Element === 'button') {\n additionalAttributes.type = type;\n }\n\n if (ref) {\n /**\n * Element может быть простой функцией поэтому напрямую\n * нельзя назначать ref\n * А может быть forwardRef, ClassComponent и простой тег,\n * поэтому в обход типизации назначаем ref как unknown\n */\n additionalAttributes.ref = ref;\n }\n\n const withSubcaption = size !== 'small' && subcaption;\n\n const button = (\n <DisabledContext.Provider value={forceDisabled || !!disabled}>\n <Element\n className={classnames(styles.button, {\n [styles[`button_mode-${mode}`]]: mode,\n [styles[`button_size-${size}`]]: size,\n [styles.onSurface]: !!onSurface,\n [styles.button_stretched]: stretched,\n [styles.button_subcaption]: withSubcaption,\n [styles.button_textless]: !withSubcaption && (hideLabel || !children) && !postfix,\n [styles.button_loading]: loading,\n [styles[`button_style-${style}`]]: style,\n [styles.buttonWithIcon]: !!icon,\n [styles.buttonWithPostfix]: !!postfix,\n [styles.buttonCentred]: !spaceBetween,\n [styles.buttonWithIconColor]: iconWithColor,\n })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\n <IconDynamic stretched>\n <span className={styles.buttonView}>\n <span className={styles.button__content}>\n {postfix && (\n <span\n className={classnames(styles.buttonPostfix, {\n [styles[`button-postfix_size-${size}`]]: size,\n })}\n >\n {postfix}\n </span>\n )}\n {icon && (\n <span className={styles.button__icon}>\n {React.cloneElement(\n icon,\n hideLabel\n ? { 'aria-label': ariaLabel }\n : { 'aria-hidden': true, focusable: false }\n )}\n </span>\n )}\n {children && !hideLabel && <span className={styles.button__label}>{children}</span>}\n {withSubcaption && <span className={styles.button__subcaption}>{subcaption}</span>}\n <CSSTransition\n in={loading}\n nodeRef={loaderRef}\n timeout={tokenSemanticAnimationTimeMDuration}\n classNames={{\n enter: styles.enterAnimation,\n enterActive: styles.enterAnimationActive,\n exit: styles.exitAnimation,\n exitActive: styles.exitAnimationActive,\n }}\n unmountOnExit\n >\n <span className={styles.button__loading} ref={loaderRef}>\n <Loader />\n </span>\n </CSSTransition>\n </span>\n </span>\n </IconDynamic>\n </Element>\n </DisabledContext.Provider>\n );\n\n if (badge && !disabled && !forceDisabled) {\n return (\n <ComponentWithBadge allowedSizes={ALLOWED_BADGE_SIZES} badge={badge} stretched={stretched}>\n {button}\n </ComponentWithBadge>\n );\n }\n\n return button;\n};\n\nexport const Button = forwardRef(ButtonForwardRefRenderFunc) as PolymorphicComponentWithRef<ButtonProps, 'button'>;\n\nexport const STRETCHED_WRAPPER_CLASS = 'magritte-button-stretched-wrapper';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,mBAAmB,GAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAElE,MAAM,0BAA0B,GAA2D,CAAC,KAAK,EAAE,GAAG,KAAI;IACtG,MAAM,EACF,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,SAAS,GAAG,KAAK,EACjB,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,GAAG,QAAQ,EACf,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,UAAU,EACV,IAAI,GAAG,QAA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,YACpF,MAAM,EAAA,CACU,EACvB;KACL;AAED,IAAA,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;MAEW,MAAM,GAAG,UAAU,CAAC,0BAA0B,EAAwD;AAE5G,MAAM,uBAAuB,GAAG;;;;"}
1
+ {"version":3,"file":"Button.js","sources":["src/Button.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useDisabled, DisabledContext } from '@hh.ru/magritte-common-use-disabled';\nimport { tokenSemanticAnimationTimeMDuration } from '@hh.ru/magritte-design-tokens/types';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport { BadgeSize, ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport { useButton } from '@hh.ru/magritte-ui-button/aria';\nimport type { ButtonProps } from '@hh.ru/magritte-ui-button/types';\nimport { IconDynamic, isIconElement } from '@hh.ru/magritte-ui-icon';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './button.less';\n\nconst ALLOWED_BADGE_SIZES: BadgeSize[] = ['small', 'extra-small'];\n\nconst ButtonForwardRefRenderFunc: PolymorphicForwardRefRenderFunc<ButtonProps, 'button'> = (props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n postfix,\n Element = 'button',\n hideLabel = false,\n icon,\n loading,\n mode,\n size = 'medium',\n stretched,\n style = 'neutral',\n subcaption,\n type = 'button',\n disabled = false,\n badge,\n spaceBetween = true,\n onSurface,\n ...buttonProps\n } = props;\n\n const forceDisabled = useDisabled();\n const { ariaProps: additionalAttributes } = useButton({ disabled: !!disabled || forceDisabled, Element });\n const loaderRef = useRef<HTMLSpanElement>(null);\n\n const iconWithColor =\n icon &&\n isIconElement(icon) &&\n (!!icon.props.initialColor || !!icon.props.highlightedColor || !!icon.props.disabledColor);\n\n if (Element === 'button') {\n additionalAttributes.type = type;\n }\n\n if (ref) {\n /**\n * Element может быть простой функцией поэтому напрямую\n * нельзя назначать ref\n * А может быть forwardRef, ClassComponent и простой тег,\n * поэтому в обход типизации назначаем ref как unknown\n */\n additionalAttributes.ref = ref;\n }\n\n const withSubcaption = size !== 'small' && subcaption;\n\n const button = (\n <DisabledContext.Provider value={forceDisabled || !!disabled}>\n <Element\n className={classnames(styles.button, {\n [styles[`button_mode-${mode}`]]: mode,\n [styles[`button_size-${size}`]]: size,\n [styles.onSurface]: !!onSurface,\n [styles.button_stretched]: stretched,\n [styles.button_subcaption]: withSubcaption,\n [styles.button_textless]: !withSubcaption && (hideLabel || !children) && !postfix,\n [styles.button_loading]: loading,\n [styles[`button_style-${style}`]]: style,\n [styles.buttonWithIcon]: !!icon,\n [styles.buttonWithPostfix]: !!postfix,\n [styles.buttonCentred]: !spaceBetween,\n [styles.buttonWithIconColor]: iconWithColor,\n })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n aria-label={ariaLabel}\n {...additionalAttributes}\n {...buttonProps}\n >\n <IconDynamic stretched>\n <span className={styles.buttonView}>\n <span className={styles.button__content}>\n {postfix && (\n <span\n className={classnames(styles.buttonPostfix, {\n [styles[`button-postfix_size-${size}`]]: size,\n })}\n >\n {postfix}\n </span>\n )}\n {icon && (\n <span className={styles.button__icon}>\n {React.cloneElement(icon, { 'aria-hidden': true })}\n </span>\n )}\n {children && !hideLabel && <span className={styles.button__label}>{children}</span>}\n {withSubcaption && <span className={styles.button__subcaption}>{subcaption}</span>}\n <CSSTransition\n in={loading}\n nodeRef={loaderRef}\n timeout={tokenSemanticAnimationTimeMDuration}\n classNames={{\n enter: styles.enterAnimation,\n enterActive: styles.enterAnimationActive,\n exit: styles.exitAnimation,\n exitActive: styles.exitAnimationActive,\n }}\n unmountOnExit\n >\n <span className={styles.button__loading} ref={loaderRef}>\n <Loader />\n </span>\n </CSSTransition>\n </span>\n </span>\n </IconDynamic>\n </Element>\n </DisabledContext.Provider>\n );\n\n if (badge && !disabled && !forceDisabled) {\n return (\n <ComponentWithBadge allowedSizes={ALLOWED_BADGE_SIZES} badge={badge} stretched={stretched}>\n {button}\n </ComponentWithBadge>\n );\n }\n\n return button;\n};\n\nexport const Button = forwardRef(ButtonForwardRefRenderFunc) as PolymorphicComponentWithRef<ButtonProps, 'button'>;\n\nexport const STRETCHED_WRAPPER_CLASS = 'magritte-button-stretched-wrapper';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,mBAAmB,GAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAElE,MAAM,0BAA0B,GAA2D,CAAC,KAAK,EAAE,GAAG,KAAI;IACtG,MAAM,EACF,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,OAAO,EACP,OAAO,GAAG,QAAQ,EAClB,SAAS,GAAG,KAAK,EACjB,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,GAAG,QAAQ,EACf,SAAS,EACT,KAAK,GAAG,SAAS,EACjB,UAAU,EACV,IAAI,GAAG,QAAQ,EACf,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,YAAY,GAAG,IAAI,EACnB,SAAS,EACT,GAAG,WAAW,EACjB,GAAG,KAAK,CAAC;AAEV,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;IACpC,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1G,IAAA,MAAM,SAAS,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAEhD,MAAM,aAAa,GACf,IAAI;QACJ,aAAa,CAAC,IAAI,CAAC;SAClB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAE/F,IAAA,IA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