@hh.ru/magritte-ui-button 5.2.4 → 5.2.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.d.ts +3 -2
- package/Button.js +3 -3
- package/Button.js.map +1 -1
- package/index.css +697 -697
- package/package.json +4 -4
- package/types.d.ts +1 -7
package/Button.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { PolymorphicComponentWithRef } from '@hh.ru/magritte-types';
|
|
2
|
+
import type { ButtonProps } from '@hh.ru/magritte-ui-button/types';
|
|
3
|
+
export declare const Button: PolymorphicComponentWithRef<ButtonProps, 'button'>;
|
|
3
4
|
export declare const STRETCHED_WRAPPER_CLASS = "magritte-button-stretched-wrapper";
|
package/Button.js
CHANGED
|
@@ -7,10 +7,10 @@ import { ComponentWithBadge } from '@hh.ru/magritte-ui-badge';
|
|
|
7
7
|
import { useButton } from './aria.js';
|
|
8
8
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
|
9
9
|
|
|
10
|
-
var styles = {"button":"magritte-button___Pubhr_5-2-
|
|
10
|
+
var styles = {"button":"magritte-button___Pubhr_5-2-5","button_loading":"magritte-button_loading___tSd9G_5-2-5","buttonLoading":"magritte-button__loading___lYs93_5-2-5","button-view":"magritte-button-view___53Slm_5-2-5","buttonView":"magritte-button-view___53Slm_5-2-5","button__content":"magritte-button__content___BXYU0_5-2-5","buttonContent":"magritte-button__content___BXYU0_5-2-5","button_size-medium":"magritte-button_size-medium___WvUsb_5-2-5","buttonSizeMedium":"magritte-button_size-medium___WvUsb_5-2-5","button_size-large":"magritte-button_size-large___Gjw7e_5-2-5","buttonSizeLarge":"magritte-button_size-large___Gjw7e_5-2-5","button__label":"magritte-button__label___zplmt_5-2-5","buttonLabel":"magritte-button__label___zplmt_5-2-5","button__subcaption":"magritte-button__subcaption___SSASN_5-2-5","buttonSubcaption":"magritte-button_subcaption___0-hG0_5-2-5","button_size-small":"magritte-button_size-small___ZAmsS_5-2-5","buttonSizeSmall":"magritte-button_size-small___ZAmsS_5-2-5","button_stretched":"magritte-button_stretched___-aXS6_5-2-5","buttonStretched":"magritte-button_stretched___-aXS6_5-2-5","button-postfix":"magritte-button-postfix___0rpTU_5-2-5","buttonPostfix":"magritte-button-postfix___0rpTU_5-2-5","button__icon":"magritte-button__icon___912gw_5-2-5","buttonIcon":"magritte-button__icon___912gw_5-2-5","button_with-icon":"magritte-button_with-icon___znqnP_5-2-5","buttonWithIcon":"magritte-button_with-icon___znqnP_5-2-5","button_subcaption":"magritte-button_subcaption___0-hG0_5-2-5","button_textless":"magritte-button_textless___XBvNJ_5-2-5","buttonTextless":"magritte-button_textless___XBvNJ_5-2-5","button__loading":"magritte-button__loading___lYs93_5-2-5","button_style-neutral":"magritte-button_style-neutral___I5qS5_5-2-5","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_5-2-5","button_mode-primary":"magritte-button_mode-primary___wU8PN_5-2-5","buttonModePrimary":"magritte-button_mode-primary___wU8PN_5-2-5","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_5-2-5","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_5-2-5","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_5-2-5","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_5-2-5","button_style-accent":"magritte-button_style-accent___TE21J_5-2-5","buttonStyleAccent":"magritte-button_style-accent___TE21J_5-2-5","button_style-positive":"magritte-button_style-positive___i-dJx_5-2-5","buttonStylePositive":"magritte-button_style-positive___i-dJx_5-2-5","button_style-negative":"magritte-button_style-negative___B2CVQ_5-2-5","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_5-2-5","button_style-contrast":"magritte-button_style-contrast___mxXt-_5-2-5","buttonStyleContrast":"magritte-button_style-contrast___mxXt-_5-2-5","button-postfix_size-large":"magritte-button-postfix_size-large___6fupR_5-2-5","buttonPostfixSizeLarge":"magritte-button-postfix_size-large___6fupR_5-2-5","button-postfix_size-medium":"magritte-button-postfix_size-medium___CKs6F_5-2-5","buttonPostfixSizeMedium":"magritte-button-postfix_size-medium___CKs6F_5-2-5","button-postfix_size-small":"magritte-button-postfix_size-small___p9vHk_5-2-5","buttonPostfixSizeSmall":"magritte-button-postfix_size-small___p9vHk_5-2-5"};
|
|
11
11
|
|
|
12
12
|
const ALLOWED_BADGE_SIZES = ['small', 'extra-small'];
|
|
13
|
-
const
|
|
13
|
+
const ButtonForwardRefRenderFunc = (props, ref) => {
|
|
14
14
|
const { 'aria-label': ariaLabel, children, postfix, Element = 'button', hideLabel = false, icon, loading, mode, size = 'medium', stretched, style = 'neutral', subcaption, type = 'button', disabled, badge, ...buttonProps } = props;
|
|
15
15
|
const forceDisabled = useDisabled();
|
|
16
16
|
const { ariaProps: additionalAttributes } = useButton({ disabled: !!disabled || forceDisabled, Element });
|
|
@@ -44,7 +44,7 @@ const ButtonRenderer = (props, ref) => {
|
|
|
44
44
|
}
|
|
45
45
|
return button;
|
|
46
46
|
};
|
|
47
|
-
const Button = forwardRef(
|
|
47
|
+
const Button = forwardRef(ButtonForwardRefRenderFunc);
|
|
48
48
|
const STRETCHED_WRAPPER_CLASS = 'magritte-button-stretched-wrapper';
|
|
49
49
|
|
|
50
50
|
export { Button, STRETCHED_WRAPPER_CLASS };
|
package/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../src/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport {
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../src/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\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 ...buttonProps\n } = props;\n\n const forceDisabled = useDisabled();\n const { ariaProps: additionalAttributes } = useButton({ disabled: !!disabled || forceDisabled, Element });\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.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 })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\n <div 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 {loading && (\n <span className={styles.button__loading}>\n <Loader />\n </span>\n )}\n </span>\n </div>\n </Element>\n );\n\n if (badge && !disabled && !forceDisabled) {\n return (\n <ComponentWithBadge allowedSizes={ALLOWED_BADGE_SIZES} badge={badge}>\n {button}\n </ComponentWithBadge>\n );\n }\n\n return button;\n};\n\nexport const Button: PolymorphicComponentWithRef<ButtonProps, 'button'> = forwardRef(ButtonForwardRefRenderFunc);\n\nexport const STRETCHED_WRAPPER_CLASS = 'magritte-button-stretched-wrapper';\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AAYA,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,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;AAE1G,IAAA,IAAI,OAAO,KAAK,QAAQ,EAAE;AACtB,QAAA,oBAAoB,CAAC,IAAI,GAAG,IAAI,CAAC;KACpC;IAED,IAAI,GAAG,EAAE;AACL;;;;;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