@hh.ru/magritte-ui-button 7.1.4 → 7.1.5

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
@@ -9,7 +9,7 @@ import { ComponentWithBadge } from '@hh.ru/magritte-ui-badge';
9
9
  import { useButton } from './aria.js';
10
10
  import { Loader } from '@hh.ru/magritte-ui-loader';
11
11
 
12
- var styles = {"button":"magritte-button___Pubhr_7-1-4","button_loading":"magritte-button_loading___tSd9G_7-1-4","buttonLoading":"magritte-button__loading___lYs93_7-1-4","button-view":"magritte-button-view___53Slm_7-1-4","buttonView":"magritte-button-view___53Slm_7-1-4","button__content":"magritte-button__content___BXYU0_7-1-4","buttonContent":"magritte-button__content___BXYU0_7-1-4","button_size-medium":"magritte-button_size-medium___WvUsb_7-1-4","buttonSizeMedium":"magritte-button_size-medium___WvUsb_7-1-4","button_size-large":"magritte-button_size-large___Gjw7e_7-1-4","buttonSizeLarge":"magritte-button_size-large___Gjw7e_7-1-4","button__label":"magritte-button__label___zplmt_7-1-4","buttonLabel":"magritte-button__label___zplmt_7-1-4","button__subcaption":"magritte-button__subcaption___SSASN_7-1-4","buttonSubcaption":"magritte-button_subcaption___0-hG0_7-1-4","button_size-small":"magritte-button_size-small___ZAmsS_7-1-4","buttonSizeSmall":"magritte-button_size-small___ZAmsS_7-1-4","button_stretched":"magritte-button_stretched___-aXS6_7-1-4","buttonStretched":"magritte-button_stretched___-aXS6_7-1-4","button-postfix":"magritte-button-postfix___0rpTU_7-1-4","buttonPostfix":"magritte-button-postfix___0rpTU_7-1-4","button__icon":"magritte-button__icon___912gw_7-1-4","buttonIcon":"magritte-button__icon___912gw_7-1-4","button_with-icon":"magritte-button_with-icon___znqnP_7-1-4","buttonWithIcon":"magritte-button_with-icon___znqnP_7-1-4","button_with-postfix":"magritte-button_with-postfix___iB7I6_7-1-4","buttonWithPostfix":"magritte-button_with-postfix___iB7I6_7-1-4","button_centred":"magritte-button_centred___7nw81_7-1-4","buttonCentred":"magritte-button_centred___7nw81_7-1-4","button_subcaption":"magritte-button_subcaption___0-hG0_7-1-4","button_textless":"magritte-button_textless___XBvNJ_7-1-4","buttonTextless":"magritte-button_textless___XBvNJ_7-1-4","button__loading":"magritte-button__loading___lYs93_7-1-4","animation-timeout":"magritte-animation-timeout___IVFRG_7-1-4","animationTimeout":"magritte-animation-timeout___IVFRG_7-1-4","enter-animation":"magritte-enter-animation___tJoZW_7-1-4","enterAnimation":"magritte-enter-animation___tJoZW_7-1-4","enter-animation-active":"magritte-enter-animation-active___RRYSD_7-1-4","enterAnimationActive":"magritte-enter-animation-active___RRYSD_7-1-4","exit-animation":"magritte-exit-animation___BleRA_7-1-4","exitAnimation":"magritte-exit-animation___BleRA_7-1-4","exit-animation-active":"magritte-exit-animation-active___i0EAM_7-1-4","exitAnimationActive":"magritte-exit-animation-active___i0EAM_7-1-4","button_style-neutral":"magritte-button_style-neutral___I5qS5_7-1-4","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_7-1-4","button_mode-primary":"magritte-button_mode-primary___wU8PN_7-1-4","buttonModePrimary":"magritte-button_mode-primary___wU8PN_7-1-4","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_7-1-4","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_7-1-4","on-surface":"magritte-on-surface___sOxCu_7-1-4","onSurface":"magritte-on-surface___sOxCu_7-1-4","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_7-1-4","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_7-1-4","button_style-accent":"magritte-button_style-accent___TE21J_7-1-4","buttonStyleAccent":"magritte-button_style-accent___TE21J_7-1-4","button_style-positive":"magritte-button_style-positive___i-dJx_7-1-4","buttonStylePositive":"magritte-button_style-positive___i-dJx_7-1-4","button_style-negative":"magritte-button_style-negative___B2CVQ_7-1-4","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_7-1-4","button_style-constant":"magritte-button_style-constant___vP0wU_7-1-4","buttonStyleConstant":"magritte-button_style-constant___vP0wU_7-1-4","button_style-special":"magritte-button_style-special___qi7Yf_7-1-4","buttonStyleSpecial":"magritte-button_style-special___qi7Yf_7-1-4","button-postfix_size-large":"magritte-button-postfix_size-large___6fupR_7-1-4","buttonPostfixSizeLarge":"magritte-button-postfix_size-large___6fupR_7-1-4","button-postfix_size-medium":"magritte-button-postfix_size-medium___CKs6F_7-1-4","buttonPostfixSizeMedium":"magritte-button-postfix_size-medium___CKs6F_7-1-4","button-postfix_size-small":"magritte-button-postfix_size-small___p9vHk_7-1-4","buttonPostfixSizeSmall":"magritte-button-postfix_size-small___p9vHk_7-1-4"};
12
+ var styles = {"button":"magritte-button___Pubhr_7-1-5","button_loading":"magritte-button_loading___tSd9G_7-1-5","buttonLoading":"magritte-button__loading___lYs93_7-1-5","button-view":"magritte-button-view___53Slm_7-1-5","buttonView":"magritte-button-view___53Slm_7-1-5","button__content":"magritte-button__content___BXYU0_7-1-5","buttonContent":"magritte-button__content___BXYU0_7-1-5","button_size-medium":"magritte-button_size-medium___WvUsb_7-1-5","buttonSizeMedium":"magritte-button_size-medium___WvUsb_7-1-5","button_size-large":"magritte-button_size-large___Gjw7e_7-1-5","buttonSizeLarge":"magritte-button_size-large___Gjw7e_7-1-5","button__label":"magritte-button__label___zplmt_7-1-5","buttonLabel":"magritte-button__label___zplmt_7-1-5","button__subcaption":"magritte-button__subcaption___SSASN_7-1-5","buttonSubcaption":"magritte-button_subcaption___0-hG0_7-1-5","button_size-small":"magritte-button_size-small___ZAmsS_7-1-5","buttonSizeSmall":"magritte-button_size-small___ZAmsS_7-1-5","button_stretched":"magritte-button_stretched___-aXS6_7-1-5","buttonStretched":"magritte-button_stretched___-aXS6_7-1-5","button-postfix":"magritte-button-postfix___0rpTU_7-1-5","buttonPostfix":"magritte-button-postfix___0rpTU_7-1-5","button__icon":"magritte-button__icon___912gw_7-1-5","buttonIcon":"magritte-button__icon___912gw_7-1-5","button_with-icon":"magritte-button_with-icon___znqnP_7-1-5","buttonWithIcon":"magritte-button_with-icon___znqnP_7-1-5","button_with-postfix":"magritte-button_with-postfix___iB7I6_7-1-5","buttonWithPostfix":"magritte-button_with-postfix___iB7I6_7-1-5","button_centred":"magritte-button_centred___7nw81_7-1-5","buttonCentred":"magritte-button_centred___7nw81_7-1-5","button_subcaption":"magritte-button_subcaption___0-hG0_7-1-5","button_textless":"magritte-button_textless___XBvNJ_7-1-5","buttonTextless":"magritte-button_textless___XBvNJ_7-1-5","button__loading":"magritte-button__loading___lYs93_7-1-5","animation-timeout":"magritte-animation-timeout___IVFRG_7-1-5","animationTimeout":"magritte-animation-timeout___IVFRG_7-1-5","enter-animation":"magritte-enter-animation___tJoZW_7-1-5","enterAnimation":"magritte-enter-animation___tJoZW_7-1-5","enter-animation-active":"magritte-enter-animation-active___RRYSD_7-1-5","enterAnimationActive":"magritte-enter-animation-active___RRYSD_7-1-5","exit-animation":"magritte-exit-animation___BleRA_7-1-5","exitAnimation":"magritte-exit-animation___BleRA_7-1-5","exit-animation-active":"magritte-exit-animation-active___i0EAM_7-1-5","exitAnimationActive":"magritte-exit-animation-active___i0EAM_7-1-5","button_style-neutral":"magritte-button_style-neutral___I5qS5_7-1-5","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_7-1-5","button_mode-primary":"magritte-button_mode-primary___wU8PN_7-1-5","buttonModePrimary":"magritte-button_mode-primary___wU8PN_7-1-5","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_7-1-5","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_7-1-5","on-surface":"magritte-on-surface___sOxCu_7-1-5","onSurface":"magritte-on-surface___sOxCu_7-1-5","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_7-1-5","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_7-1-5","button_style-accent":"magritte-button_style-accent___TE21J_7-1-5","buttonStyleAccent":"magritte-button_style-accent___TE21J_7-1-5","button_style-positive":"magritte-button_style-positive___i-dJx_7-1-5","buttonStylePositive":"magritte-button_style-positive___i-dJx_7-1-5","button_style-negative":"magritte-button_style-negative___B2CVQ_7-1-5","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_7-1-5","button_style-constant":"magritte-button_style-constant___vP0wU_7-1-5","buttonStyleConstant":"magritte-button_style-constant___vP0wU_7-1-5","button_style-special":"magritte-button_style-special___qi7Yf_7-1-5","buttonStyleSpecial":"magritte-button_style-special___qi7Yf_7-1-5","button-postfix_size-large":"magritte-button-postfix_size-large___6fupR_7-1-5","buttonPostfixSizeLarge":"magritte-button-postfix_size-large___6fupR_7-1-5","button-postfix_size-medium":"magritte-button-postfix_size-medium___CKs6F_7-1-5","buttonPostfixSizeMedium":"magritte-button-postfix_size-medium___CKs6F_7-1-5","button-postfix_size-small":"magritte-button-postfix_size-small___p9vHk_7-1-5","buttonPostfixSizeSmall":"magritte-button-postfix_size-small___p9vHk_7-1-5"};
13
13
 
14
14
  const ALLOWED_BADGE_SIZES = ['small', 'extra-small'];
15
15
  const ButtonForwardRefRenderFunc = (props, ref) => {
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 } 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 { 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,\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 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 <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 })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\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 ? { 'aria-label': ariaLabel } : { '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 </Element>\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":";;;;;;;;;;;;AAcA,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,EACR,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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A,EAAA,SAAS,EAAE,MAAM,CAAC,eAAe,EAAE,GAAG,EAAE,SAAS,EACnD,QAAA,EAAAA,GAAA,CAAC,MAAM,EAAG,EAAA,CAAA,EAAA,CACP,GACK,CACb,EAAA,CAAA,EAAA,CACJ,EACD,CAAA,CACb,CAAC;IAEF,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,EAAE;AACtC,QAAA,QACIA,GAAC,CAAA,kBAAkB,IAAC,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,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 } 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 { 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,\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 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 <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 })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\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 ? { 'aria-label': ariaLabel } : { '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 </Element>\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":";;;;;;;;;;;;AAcA,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,EACR,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;AAEhD,IAAA,IAAI,OAAO,KAAK,QAAQ,EAAE;AACtB,QAAA,oBAAoB,CAAC,IAAI,GAAG,IAAI,CAAC;KACpC;IAED,IAAI,GAAG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,CACJ,EACD,CAAA,CACb,CAAC;IAEF,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,aAAa,EAAE;AACtC,QAAA,QACIA,GAAC,CAAA,kBAAkB,IAAC,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,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;;;;"}
package/aria.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aria.js","sources":["../src/aria.ts"],"sourcesContent":["export const useButton = ({\n disabled,\n Element = 'button',\n}: Record<string, unknown>): {\n ariaProps: { [x: string]: unknown };\n} => {\n let additionalAttributes: { [x: string]: unknown } = {};\n\n if (Element === 'button') {\n additionalAttributes = {};\n } else {\n additionalAttributes = {\n role: 'button',\n tabIndex: disabled ? undefined : 0,\n 'aria-disabled': disabled,\n };\n }\n\n return {\n ariaProps: additionalAttributes,\n };\n};\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,GAAG,CAAC,EACtB,QAAQ,EACR,OAAO,GAAG,QAAQ,GACI,KAEtB;IACA,IAAI,oBAAoB,GAA6B,EAAE,CAAC;AAExD,IAAA,IAAI,OAAO,KAAK,QAAQ,EAAE;QACtB,oBAAoB,GAAG,EAAE,CAAC;KAC7B;SAAM;AACH,QAAA,oBAAoB,GAAG;AACnB,YAAA,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,CAAC;AAClC,YAAA,eAAe,EAAE,QAAQ;SAC5B,CAAC;KACL;IAED,OAAO;AACH,QAAA,SAAS,EAAE,oBAAoB;KAClC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"aria.js","sources":["src/aria.ts"],"sourcesContent":["export const useButton = ({\n disabled,\n Element = 'button',\n}: Record<string, unknown>): {\n ariaProps: { [x: string]: unknown };\n} => {\n let additionalAttributes: { [x: string]: unknown } = {};\n\n if (Element === 'button') {\n additionalAttributes = {};\n } else {\n additionalAttributes = {\n role: 'button',\n tabIndex: disabled ? undefined : 0,\n 'aria-disabled': disabled,\n };\n }\n\n return {\n ariaProps: additionalAttributes,\n };\n};\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,GAAG,CAAC,EACtB,QAAQ,EACR,OAAO,GAAG,QAAQ,GACI,KAEtB;IACA,IAAI,oBAAoB,GAA6B,EAAE,CAAC;AAExD,IAAA,IAAI,OAAO,KAAK,QAAQ,EAAE;QACtB,oBAAoB,GAAG,EAAE,CAAC;KAC7B;SAAM;AACH,QAAA,oBAAoB,GAAG;AACnB,YAAA,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,CAAC;AAClC,YAAA,eAAe,EAAE,QAAQ;SAC5B,CAAC;KACL;IAED,OAAO;AACH,QAAA,SAAS,EAAE,oBAAoB;KAClC,CAAC;AACN;;;;"}