@hh.ru/magritte-ui-button 3.1.16 → 4.0.0
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 +2 -2
- package/Button.js.map +1 -1
- package/index.css +688 -688
- package/package.json +3 -3
- package/types.d.ts +5 -5
package/Button.js
CHANGED
|
@@ -8,7 +8,7 @@ import { useButton } from './aria.js';
|
|
|
8
8
|
import { Counter } from '@hh.ru/magritte-ui-counter';
|
|
9
9
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
|
10
10
|
|
|
11
|
-
var styles = {"button":"magritte-
|
|
11
|
+
var styles = {"button":"magritte-button___Pubhr_4-0-0","button_loading":"magritte-button_loading___tSd9G_4-0-0","buttonLoading":"magritte-button__loading___lYs93_4-0-0","button__content":"magritte-button__content___BXYU0_4-0-0","buttonContent":"magritte-button__content___BXYU0_4-0-0","button_size-medium":"magritte-button_size-medium___WvUsb_4-0-0","buttonSizeMedium":"magritte-button_size-medium___WvUsb_4-0-0","button_size-large":"magritte-button_size-large___Gjw7e_4-0-0","buttonSizeLarge":"magritte-button_size-large___Gjw7e_4-0-0","button__label":"magritte-button__label___zplmt_4-0-0","buttonLabel":"magritte-button__label___zplmt_4-0-0","button__subcaption":"magritte-button__subcaption___SSASN_4-0-0","buttonSubcaption":"magritte-button_subcaption___0-hG0_4-0-0","button__counter":"magritte-button__counter___X6-Fm_4-0-0","buttonCounter":"magritte-button__counter___X6-Fm_4-0-0","button_size-small":"magritte-button_size-small___ZAmsS_4-0-0","buttonSizeSmall":"magritte-button_size-small___ZAmsS_4-0-0","button_stretched":"magritte-button_stretched___-aXS6_4-0-0","buttonStretched":"magritte-button_stretched___-aXS6_4-0-0","button__icon":"magritte-button__icon___912gw_4-0-0","buttonIcon":"magritte-button__icon___912gw_4-0-0","button_subcaption":"magritte-button_subcaption___0-hG0_4-0-0","button_textless":"magritte-button_textless___XBvNJ_4-0-0","buttonTextless":"magritte-button_textless___XBvNJ_4-0-0","button__loading":"magritte-button__loading___lYs93_4-0-0","button_style-neutral":"magritte-button_style-neutral___I5qS5_4-0-0","buttonStyleNeutral":"magritte-button_style-neutral___I5qS5_4-0-0","button_mode-primary":"magritte-button_mode-primary___wU8PN_4-0-0","buttonModePrimary":"magritte-button_mode-primary___wU8PN_4-0-0","button_mode-secondary":"magritte-button_mode-secondary___xYz4-_4-0-0","buttonModeSecondary":"magritte-button_mode-secondary___xYz4-_4-0-0","button_mode-tertiary":"magritte-button_mode-tertiary___ZMpad_4-0-0","buttonModeTertiary":"magritte-button_mode-tertiary___ZMpad_4-0-0","button_style-accent":"magritte-button_style-accent___TE21J_4-0-0","buttonStyleAccent":"magritte-button_style-accent___TE21J_4-0-0","button_style-positive":"magritte-button_style-positive___i-dJx_4-0-0","buttonStylePositive":"magritte-button_style-positive___i-dJx_4-0-0","button_style-negative":"magritte-button_style-negative___B2CVQ_4-0-0","buttonStyleNegative":"magritte-button_style-negative___B2CVQ_4-0-0","button_style-contrast":"magritte-button_style-contrast___mxXt-_4-0-0","buttonStyleContrast":"magritte-button_style-contrast___mxXt-_4-0-0"};
|
|
12
12
|
|
|
13
13
|
const buttonSizeToCounterSize = {
|
|
14
14
|
large: 'medium',
|
|
@@ -16,7 +16,7 @@ const buttonSizeToCounterSize = {
|
|
|
16
16
|
small: 'small',
|
|
17
17
|
};
|
|
18
18
|
const ButtonRenderer = (props, ref) => {
|
|
19
|
-
const { ariaLabel, children, counter, Element = 'button', hideLabel = false, icon, loading, mode, size = 'medium', stretched, style = 'neutral', subcaption, type = 'button', disabled, badge, ...buttonProps } = props;
|
|
19
|
+
const { 'aria-label': ariaLabel, children, counter, Element = 'button', hideLabel = false, icon, loading, mode, size = 'medium', stretched, style = 'neutral', subcaption, type = 'button', disabled, badge, ...buttonProps } = props;
|
|
20
20
|
const forceDisabled = useDisabled();
|
|
21
21
|
const { ariaProps: additionalAttributes } = useButton({ disabled: !!disabled || forceDisabled, Element });
|
|
22
22
|
if (Element === 'button') {
|
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 { ForwardRefRenderFuncWithCustomElement } from '@hh.ru/magritte-types';\nimport { ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport { useButton } from '@hh.ru/magritte-ui-button/aria';\nimport { ButtonProps, ButtonWithCustomElement } from '@hh.ru/magritte-ui-button/types';\nimport { Counter } from '@hh.ru/magritte-ui-counter';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './button.less';\n\nconst buttonSizeToCounterSize = {\n large: 'medium',\n medium: 'medium',\n small: 'small',\n} as const;\n\nconst ButtonRenderer: ForwardRefRenderFuncWithCustomElement<ButtonProps, 'button'> = (props, ref) => {\n const {\n ariaLabel,\n children,\n counter,\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) && !counter,\n [styles.button_loading]: loading,\n [styles[`button_style-${style}`]]: style,\n })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\n <span className={styles.button__content}>\n {counter && (\n <span className={styles.button__counter}>\n <Counter\n label={counter}\n style=\"attention\"\n mode=\"secondary\"\n size={buttonSizeToCounterSize[size]}\n />\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 </Element>\n );\n\n if (!badge) {\n return button;\n }\n\n return <ComponentWithBadge badge={badge}>{button}</ComponentWithBadge>;\n};\n\nexport const Button = forwardRef(ButtonRenderer) as ButtonWithCustomElement<ButtonProps, 'button'>;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAaA,MAAM,uBAAuB,GAAG;AAC5B,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;CACR,CAAC;AAEX,MAAM,cAAc,GAAiE,CAAC,KAAK,EAAE,GAAG,KAAI;IAChG,MAAM,EACF,SAAS,
|
|
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 { ForwardRefRenderFuncWithCustomElement } from '@hh.ru/magritte-types';\nimport { ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport { useButton } from '@hh.ru/magritte-ui-button/aria';\nimport { ButtonProps, ButtonWithCustomElement } from '@hh.ru/magritte-ui-button/types';\nimport { Counter } from '@hh.ru/magritte-ui-counter';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\n\nimport styles from './button.less';\n\nconst buttonSizeToCounterSize = {\n large: 'medium',\n medium: 'medium',\n small: 'small',\n} as const;\n\nconst ButtonRenderer: ForwardRefRenderFuncWithCustomElement<ButtonProps, 'button'> = (props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n counter,\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) && !counter,\n [styles.button_loading]: loading,\n [styles[`button_style-${style}`]]: style,\n })}\n disabled={forceDisabled || !!disabled}\n tabIndex={loading ? -1 : undefined}\n {...additionalAttributes}\n {...buttonProps}\n >\n <span className={styles.button__content}>\n {counter && (\n <span className={styles.button__counter}>\n <Counter\n label={counter}\n style=\"attention\"\n mode=\"secondary\"\n size={buttonSizeToCounterSize[size]}\n />\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 </Element>\n );\n\n if (!badge) {\n return button;\n }\n\n return <ComponentWithBadge badge={badge}>{button}</ComponentWithBadge>;\n};\n\nexport const Button = forwardRef(ButtonRenderer) as ButtonWithCustomElement<ButtonProps, 'button'>;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAaA,MAAM,uBAAuB,GAAG;AAC5B,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,OAAO;CACR,CAAC;AAEX,MAAM,cAAc,GAAiE,CAAC,KAAK,EAAE,GAAG,KAAI;IAChG,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;IAE1G,IAAI,OAAO,KAAK,QAAQ,EAAE;AACtB,QAAA,oBAAoB,CAAC,IAAI,GAAG,IAAI,CAAC;AACpC,KAAA;AAED,IAAA,IAAI,GAAG,EAAE;AACL;;;;;AAKG;AACH,QAAA,oBAAoB,CAAC,GAAG,GAAG,GAAG,CAAC;AAClC,KAAA;AAED,IAAA,MAAM,cAAc,GAAG,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC;AAEtD,IAAA,MAAM,MAAM,IACRA,GAAA,CAAC,OAAO,EAAA,EACJ,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE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