@hh.ru/magritte-ui-chips 5.0.3 → 5.1.1

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/CheckableChip.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import './index.css';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { forwardRef } from 'react';
4
+ import classnames from 'classnames';
4
5
  import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
5
- import { s as styles, C as ChipContent } from './ChipContent-Bxa1JKDG.js';
6
- import 'classnames';
6
+ import { s as styles, C as ChipContent } from './ChipContent-H8lnG-Ce.js';
7
7
  import '@hh.ru/magritte-ui-typography';
8
8
 
9
9
  const STYLE_TO_CSS = {
10
10
  neutral: styles.chipStyleNeutral,
11
11
  accent: styles.chipStyleAccent,
12
12
  };
13
- const CheckableChipComponent = ({ style = 'neutral', type = 'checkbox', addon, postfix, hideLabel, children, disabled, 'aria-label': ariaLabel, dataQaWrapper = 'chip', ...inputProps }, ref) => {
13
+ const CheckableChipComponent = ({ style = 'neutral', type = 'checkbox', addon, postfix, hideLabel, children, disabled, 'aria-label': ariaLabel, dataQaWrapper = 'chip', size = 'medium', ...inputProps }, ref) => {
14
14
  const forceDisabled = useDisabled();
15
15
  const isComponentDisabled = disabled || forceDisabled;
16
- return (jsxs("label", { className: `${styles.chip} ${STYLE_TO_CSS[style]}`, ref: ref, "data-qa": dataQaWrapper, "data-interactive": true, children: [jsx("input", { ...inputProps, type: type, className: styles.input, disabled: isComponentDisabled }), jsx(ChipContent, { postfix: postfix, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, children: children })] }));
16
+ return (jsxs("label", { className: classnames(styles.chip, STYLE_TO_CSS[style], { [styles.sizeSmall]: size === 'small' }), ref: ref, "data-qa": dataQaWrapper, "data-interactive": true, children: [jsx("input", { ...inputProps, type: type, className: styles.input, disabled: isComponentDisabled }), jsx(ChipContent, { size: size, postfix: postfix, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, children: children })] }));
17
17
  };
18
18
  const CheckableChip = forwardRef(CheckableChipComponent);
19
19
 
@@ -1 +1 @@
1
- {"version":3,"file":"CheckableChip.js","sources":["../src/CheckableChip.tsx"],"sourcesContent":["import { forwardRef, ForwardedRef } from 'react';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { CheckableChipProps } from '@hh.ru/magritte-ui-chips/types';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CheckableChipComponent = (\n {\n style = 'neutral',\n type = 'checkbox',\n addon,\n postfix,\n hideLabel,\n children,\n disabled,\n 'aria-label': ariaLabel,\n dataQaWrapper = 'chip',\n ...inputProps\n }: CheckableChipProps,\n ref: ForwardedRef<HTMLLabelElement>\n) => {\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n return (\n <label\n className={`${styles.chip} ${STYLE_TO_CSS[style]}`}\n ref={ref}\n data-qa={dataQaWrapper}\n data-interactive={true}\n >\n <input {...inputProps} type={type} className={styles.input} disabled={isComponentDisabled} />\n <ChipContent postfix={postfix} addon={addon} aria-label={ariaLabel} hideLabel={hideLabel}>\n {children}\n </ChipContent>\n </label>\n );\n};\n\nconst CheckableChip = forwardRef(CheckableChipComponent);\nexport { CheckableChip };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAQA,MAAM,YAAY,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC,eAAe;CACjC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,EACI,KAAK,GAAG,SAAS,EACjB,IAAI,GAAG,UAAU,EACjB,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,GAAG,MAAM,EACtB,GAAG,UAAU,EACI,EACrB,GAAmC,KACnC;AACA,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,QAAQ,IAAI,aAAa,CAAC;AAEtD,IAAA,QACIA,IAAA,CAAA,OAAA,EAAA,EACI,SAAS,EAAE,CAAG,EAAA,MAAM,CAAC,IAAI,CAAI,CAAA,EAAA,YAAY,CAAC,KAAK,CAAC,CAAA,CAAE,EAClD,GAAG,EAAE,GAAG,EACC,SAAA,EAAA,aAAa,EACJ,kBAAA,EAAA,IAAI,EAEtB,QAAA,EAAA,CAAAC,GAAA,CAAA,OAAA,EAAA,EAAA,GAAW,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAI,CAAA,EAC7FA,GAAC,CAAA,WAAW,EAAC,EAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAc,YAAA,EAAA,SAAS,EAAE,SAAS,EAAE,SAAS,EACnF,QAAA,EAAA,QAAQ,EACC,CAAA,CAAA,EAAA,CACV,EACV;AACN,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,UAAU,CAAC,sBAAsB;;;;"}
1
+ {"version":3,"file":"CheckableChip.js","sources":["../src/CheckableChip.tsx"],"sourcesContent":["import { forwardRef, ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { CheckableChipProps } from '@hh.ru/magritte-ui-chips/types';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CheckableChipComponent = (\n {\n style = 'neutral',\n type = 'checkbox',\n addon,\n postfix,\n hideLabel,\n children,\n disabled,\n 'aria-label': ariaLabel,\n dataQaWrapper = 'chip',\n size = 'medium',\n ...inputProps\n }: CheckableChipProps,\n ref: ForwardedRef<HTMLLabelElement>\n) => {\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n return (\n <label\n className={classnames(styles.chip, STYLE_TO_CSS[style], { [styles.sizeSmall]: size === 'small' })}\n ref={ref}\n data-qa={dataQaWrapper}\n data-interactive={true}\n >\n <input {...inputProps} type={type} className={styles.input} disabled={isComponentDisabled} />\n <ChipContent size={size} postfix={postfix} addon={addon} aria-label={ariaLabel} hideLabel={hideLabel}>\n {children}\n </ChipContent>\n </label>\n );\n};\n\nconst CheckableChip = forwardRef(CheckableChipComponent);\nexport { CheckableChip };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AASA,MAAM,YAAY,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC,eAAe;CACjC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,EACI,KAAK,GAAG,SAAS,EACjB,IAAI,GAAG,UAAU,EACjB,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,GAAG,MAAM,EACtB,IAAI,GAAG,QAAQ,EACf,GAAG,UAAU,EACI,EACrB,GAAmC,KACnC;AACA,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,QAAQ,IAAI,aAAa,CAAC;AAEtD,IAAA,QACIA,IACI,CAAA,OAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,EACjG,GAAG,EAAE,GAAG,EACC,SAAA,EAAA,aAAa,sBACJ,IAAI,EAAA,QAAA,EAAA,CAEtBC,kBAAW,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAI,CAAA,EAC7FA,IAAC,WAAW,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAc,YAAA,EAAA,SAAS,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EAC/F,QAAQ,EACC,CAAA,CAAA,EAAA,CACV,EACV;AACN,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,UAAU,CAAC,sBAAsB;;;;"}
@@ -0,0 +1,22 @@
1
+ import './index.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { cloneElement } from 'react';
4
+ import classnames from 'classnames';
5
+ import { Text } from '@hh.ru/magritte-ui-typography';
6
+
7
+ var styles = {"input":"magritte-input___ctH9G_5-1-1","chip":"magritte-chip___uulZ9_5-1-1","chip-wrapper":"magritte-chip-wrapper___os8tP_5-1-1","chipWrapper":"magritte-chip-wrapper___os8tP_5-1-1","chip-wrapper__disabled":"magritte-chip-wrapper__disabled___mHM6-_5-1-1","chipWrapperDisabled":"magritte-chip-wrapper__disabled___mHM6-_5-1-1","content":"magritte-content___17f1s_5-1-1","size-small":"magritte-size-small___2di4r_5-1-1","sizeSmall":"magritte-size-small___2di4r_5-1-1","content__deletable":"magritte-content__deletable___iqF4W_5-1-1","contentDeletable":"magritte-content__deletable___iqF4W_5-1-1","addon":"magritte-addon___mlwVD_5-1-1","label-container":"magritte-label-container___VVRg1_5-1-1","labelContainer":"magritte-label-container___VVRg1_5-1-1","label":"magritte-label___NSEUN_5-1-1","postfix-wrapper":"magritte-postfix-wrapper___Qmxwy_5-1-1","postfixWrapper":"magritte-postfix-wrapper___Qmxwy_5-1-1","close":"magritte-close___5I1Fe_5-1-1","chip_style-neutral":"magritte-chip_style-neutral___gELi3_5-1-1","chipStyleNeutral":"magritte-chip_style-neutral___gELi3_5-1-1","postfix":"magritte-postfix___hgYUe_5-1-1","chip__checked":"magritte-chip__checked___3GRxf_5-1-1","chipChecked":"magritte-chip__checked___3GRxf_5-1-1","chip__custom":"magritte-chip__custom___mE-pN_5-1-1","chipCustom":"magritte-chip__custom___mE-pN_5-1-1","disabled":"magritte-disabled___CLRlf_5-1-1","chip_style-accent":"magritte-chip_style-accent___rD0pt_5-1-1","chipStyleAccent":"magritte-chip_style-accent___rD0pt_5-1-1","delete-only":"magritte-delete-only___dn3c7_5-1-1","deleteOnly":"magritte-delete-only___dn3c7_5-1-1"};
8
+
9
+ const ChipContent = ({ addon, 'aria-label': ariaLabel, hideLabel, onDelete, postfix, children, size = 'medium', }) => {
10
+ const showLabel = !hideLabel && !!children;
11
+ const typography = size === 'small' ? 'subtitle-2-semibold' : 'subtitle-1-semibold';
12
+ return (jsxs("span", { className: classnames(styles.content, {
13
+ [styles.contentDeletable]: !!onDelete,
14
+ }), children: [addon && (jsx("span", { className: styles.addon, children: cloneElement(addon, {
15
+ 'data-qa': 'chip-addon',
16
+ 'aria-label': ariaLabel,
17
+ 'aria-hidden': showLabel,
18
+ }) })), showLabel && (jsxs("span", { className: styles.labelContainer, children: [jsx("span", { className: styles.label, children: jsx(Text, { Element: "span", typography: typography, children: children }) }), postfix && (jsx("span", { className: styles.postfixWrapper, children: jsx(Text, { Element: "span", typography: typography, children: jsx("span", { className: styles.postfix, children: postfix }) }) }))] }))] }));
19
+ };
20
+
21
+ export { ChipContent as C, styles as s };
22
+ //# sourceMappingURL=ChipContent-H8lnG-Ce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipContent-H8lnG-Ce.js","sources":["../src/ChipContent.tsx"],"sourcesContent":["import { cloneElement, FC } from 'react';\nimport classnames from 'classnames';\n\nimport { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './chips.less';\n\ntype ChipContentProps = Pick<\n CustomChipProps,\n 'addon' | 'hideLabel' | 'aria-label' | 'postfix' | 'onDelete' | 'children' | 'size'\n>;\n\nconst ChipContent: FC<ChipContentProps> = ({\n addon,\n 'aria-label': ariaLabel,\n hideLabel,\n onDelete,\n postfix,\n children,\n size = 'medium',\n}) => {\n const showLabel = !hideLabel && !!children;\n const typography = size === 'small' ? 'subtitle-2-semibold' : 'subtitle-1-semibold';\n return (\n <span\n className={classnames(styles.content, {\n [styles.contentDeletable]: !!onDelete,\n })}\n >\n {addon && (\n <span className={styles.addon}>\n {cloneElement(addon, {\n 'data-qa': 'chip-addon',\n 'aria-label': ariaLabel,\n 'aria-hidden': showLabel,\n })}\n </span>\n )}\n {showLabel && (\n <span className={styles.labelContainer}>\n <span className={styles.label}>\n <Text Element=\"span\" typography={typography}>\n {children}\n </Text>\n </span>\n {postfix && (\n <span className={styles.postfixWrapper}>\n <Text Element=\"span\" typography={typography}>\n <span className={styles.postfix}>{postfix}</span>\n </Text>\n </span>\n )}\n </span>\n )}\n </span>\n );\n};\n\nexport default ChipContent;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AAaM,MAAA,WAAW,GAAyB,CAAC,EACvC,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,GAAG,QAAQ,GAClB,KAAI;IACD,MAAM,SAAS,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC;AAC3C,IAAA,MAAM,UAAU,GAAG,IAAI,KAAK,OAAO,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;IACpF,QACIA,eACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE;AAClC,YAAA,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC,QAAQ;AACxC,SAAA,CAAC,EAED,QAAA,EAAA,CAAA,KAAK,KACFC,cAAM,SAAS,EAAE,MAAM,CAAC,KAAK,EAAA,QAAA,EACxB,YAAY,CAAC,KAAK,EAAE;AACjB,oBAAA,SAAS,EAAE,YAAY;AACvB,oBAAA,YAAY,EAAE,SAAS;AACvB,oBAAA,aAAa,EAAE,SAAS;AAC3B,iBAAA,CAAC,EACC,CAAA,CACV,EACA,SAAS,KACND,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,cAAc,EAClC,QAAA,EAAA,CAAAC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,KAAK,EACzB,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAE,UAAU,EAAA,QAAA,EACtC,QAAQ,EAAA,CACN,GACJ,EACN,OAAO,KACJA,GAAM,CAAA,MAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,cAAc,EAAA,QAAA,EAClCA,GAAC,CAAA,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,UAAU,EAAE,UAAU,EACvC,QAAA,EAAAA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,OAAO,EAAG,QAAA,EAAA,OAAO,EAAQ,CAAA,EAAA,CAC9C,GACJ,CACV,CAAA,EAAA,CACE,CACV,CAAA,EAAA,CACE,EACT;AACN;;;;"}
package/ChipContent.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
2
  import { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';
3
- type ChipContentProps = Pick<CustomChipProps, 'addon' | 'hideLabel' | 'aria-label' | 'postfix' | 'onDelete' | 'children'>;
3
+ type ChipContentProps = Pick<CustomChipProps, 'addon' | 'hideLabel' | 'aria-label' | 'postfix' | 'onDelete' | 'children' | 'size'>;
4
4
  declare const ChipContent: FC<ChipContentProps>;
5
5
  export default ChipContent;
package/ChipContent.js CHANGED
@@ -3,5 +3,5 @@ import 'react/jsx-runtime';
3
3
  import 'react';
4
4
  import 'classnames';
5
5
  import '@hh.ru/magritte-ui-typography';
6
- export { C as default } from './ChipContent-Bxa1JKDG.js';
6
+ export { C as default } from './ChipContent-H8lnG-Ce.js';
7
7
  //# sourceMappingURL=ChipContent.js.map
package/ChipsContainer.js CHANGED
@@ -6,12 +6,12 @@ import { CheckableChip } from './CheckableChip.js';
6
6
  import { CustomChip } from './CustomChip.js';
7
7
  import { ScrollableContainer, useScrollContext } from '@hh.ru/magritte-ui-scrollable-container';
8
8
  import '@hh.ru/magritte-common-use-disabled';
9
- import './ChipContent-Bxa1JKDG.js';
9
+ import './ChipContent-H8lnG-Ce.js';
10
10
  import '@hh.ru/magritte-ui-typography';
11
11
  import '@hh.ru/magritte-ui-action';
12
12
  import '@hh.ru/magritte-ui-icon/variants/icon';
13
13
 
14
- var styles = {"container":"magritte-container___o9zaa_5-0-3","scrollable":"magritte-scrollable___GhecO_5-0-3","item":"magritte-item___LBqGp_5-0-3","nowrap":"magritte-nowrap___ioKUP_5-0-3"};
14
+ var styles = {"container":"magritte-container___o9zaa_5-1-1","scrollable":"magritte-scrollable___GhecO_5-1-1","item":"magritte-item___LBqGp_5-1-1","nowrap":"magritte-nowrap___ioKUP_5-1-1"};
15
15
 
16
16
  const isValidCheckableChipElement = (child) => isValidElement(child) && child.type === CheckableChip;
17
17
  const isValidCustomChipElement = (child) => isValidElement(child) && child.type === CustomChip;
package/CustomChip.js CHANGED
@@ -4,26 +4,27 @@ import { forwardRef } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
6
6
  import { Action } from '@hh.ru/magritte-ui-action';
7
- import { s as styles, C as ChipContent } from './ChipContent-Bxa1JKDG.js';
8
- import { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/variants/icon';
7
+ import { s as styles, C as ChipContent } from './ChipContent-H8lnG-Ce.js';
8
+ import { CrossOutlinedSize16, CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/variants/icon';
9
9
  import '@hh.ru/magritte-ui-typography';
10
10
 
11
11
  const STYLE_TO_CSS = {
12
12
  neutral: styles.chipStyleNeutral,
13
13
  accent: styles.chipStyleAccent,
14
14
  };
15
- const CustomChipComponent = ({ Element = 'button', addon, style = 'neutral', postfix, onDelete, checked = false, disabled = false, 'aria-label': ariaLabel, hideLabel, dataQaWrapper = 'chip', children, ...buttonProps }, ref) => {
15
+ const CustomChipComponent = ({ Element = 'button', addon, style = 'neutral', postfix, onDelete, deleteOnly = false, checked = false, disabled = false, 'aria-label': ariaLabel, hideLabel, dataQaWrapper = 'chip', children, size = 'medium', ...buttonProps }, ref) => {
16
16
  const forceDisabled = useDisabled();
17
17
  const isComponentDisabled = disabled || forceDisabled;
18
18
  let additionalAttributes;
19
19
  if (Element === 'button') {
20
20
  additionalAttributes = {
21
21
  type: 'button',
22
+ tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,
22
23
  };
23
24
  }
24
25
  else {
25
26
  additionalAttributes = {
26
- tabIndex: isComponentDisabled ? -1 : 0,
27
+ tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,
27
28
  'aria-disabled': disabled,
28
29
  };
29
30
  }
@@ -32,7 +33,10 @@ const CustomChipComponent = ({ Element = 'button', addon, style = 'neutral', pos
32
33
  }
33
34
  return (jsxs("div", { className: classnames(styles.chipWrapper, isComponentDisabled && styles.chipWrapperDisabled), "data-qa": dataQaWrapper, children: [jsx(Element, { ...additionalAttributes, ...buttonProps, className: classnames(styles.chip, styles.chipCustom, STYLE_TO_CSS[style], {
34
35
  [styles.chipChecked]: checked,
35
- }), disabled: isComponentDisabled, children: jsx(ChipContent, { postfix: postfix, onDelete: onDelete, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, children: children }) }), onDelete && (jsx("span", { className: styles.close, children: jsx(Action, { "data-qa": "chip-delete-action", onClick: onDelete, disabled: isComponentDisabled, mode: "secondary", icon: CrossOutlinedSize24 }) }))] }));
36
+ [styles.deleteOnly]: deleteOnly,
37
+ [styles.sizeSmall]: size === 'small',
38
+ [styles.disabled]: isComponentDisabled,
39
+ }), disabled: isComponentDisabled || deleteOnly, children: jsx(ChipContent, { postfix: postfix, onDelete: onDelete, addon: addon, "aria-label": ariaLabel, hideLabel: hideLabel, size: size, children: children }) }), onDelete && (jsx("span", { className: styles.close, children: jsx(Action, { "data-qa": "chip-delete-action", onClick: onDelete, disabled: isComponentDisabled, mode: "secondary", icon: size === 'small' ? CrossOutlinedSize16 : CrossOutlinedSize24 }) }))] }));
36
40
  };
37
41
  const CustomChip = forwardRef(CustomChipComponent);
38
42
 
package/CustomChip.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"CustomChip.js","sources":["../src/CustomChip.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { ForwardRefRenderFuncWithCustomElement, ComponentWithCustomElement } from '@hh.ru/magritte-types';\nimport { Action } from '@hh.ru/magritte-ui-action';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/variants/icon';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CustomChipComponent: ForwardRefRenderFuncWithCustomElement<CustomChipProps, 'button'> = (\n {\n Element = 'button',\n addon,\n style = 'neutral',\n postfix,\n onDelete,\n checked = false,\n disabled = false,\n 'aria-label': ariaLabel,\n hideLabel,\n dataQaWrapper = 'chip',\n children,\n ...buttonProps\n },\n ref\n) => {\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n let additionalAttributes: Record<string, unknown>;\n\n if (Element === 'button') {\n additionalAttributes = {\n type: 'button',\n };\n } else {\n additionalAttributes = {\n tabIndex: isComponentDisabled ? -1 : 0,\n 'aria-disabled': disabled,\n };\n }\n\n if (ref) {\n additionalAttributes.ref = ref;\n }\n\n return (\n <div\n className={classnames(styles.chipWrapper, isComponentDisabled && styles.chipWrapperDisabled)}\n data-qa={dataQaWrapper}\n >\n <Element\n {...additionalAttributes}\n {...buttonProps}\n className={classnames(styles.chip, styles.chipCustom, STYLE_TO_CSS[style], {\n [styles.chipChecked]: checked,\n })}\n disabled={isComponentDisabled}\n >\n <ChipContent\n postfix={postfix}\n onDelete={onDelete}\n addon={addon}\n aria-label={ariaLabel}\n hideLabel={hideLabel}\n >\n {children}\n </ChipContent>\n </Element>\n {onDelete && (\n <span className={styles.close}>\n <Action\n data-qa=\"chip-delete-action\"\n onClick={onDelete}\n disabled={isComponentDisabled}\n mode=\"secondary\"\n icon={CrossOutlinedSize24}\n />\n </span>\n )}\n </div>\n );\n};\n\nexport const CustomChip = forwardRef(CustomChipComponent) as ComponentWithCustomElement<CustomChipProps, 'button'>;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AAYA,MAAM,YAAY,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC,eAAe;CACjC,CAAC;AAEF,MAAM,mBAAmB,GAAqE,CAC1F,EACI,OAAO,GAAG,QAAQ,EAClB,KAAK,EACL,KAAK,GAAG,SAAS,EACjB,OAAO,EACP,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,aAAa,GAAG,MAAM,EACtB,QAAQ,EACR,GAAG,WAAW,EACjB,EACD,GAAG,KACH;AACA,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,QAAQ,IAAI,aAAa,CAAC;AAEtD,IAAA,IAAI,oBAA6C,CAAC;IAElD,IAAI,OAAO,KAAK,QAAQ,EAAE;AACtB,QAAA,oBAAoB,GAAG;AACnB,YAAA,IAAI,EAAE,QAAQ;SACjB,CAAC;AACL,KAAA;AAAM,SAAA;AACH,QAAA,oBAAoB,GAAG;YACnB,QAAQ,EAAE,mBAAmB,GAAG,CAAC,CA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} from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { ForwardRefRenderFuncWithCustomElement, ComponentWithCustomElement } from '@hh.ru/magritte-types';\nimport { Action } from '@hh.ru/magritte-ui-action';\nimport ChipContent from '@hh.ru/magritte-ui-chips/ChipContent';\nimport { CustomChipProps } from '@hh.ru/magritte-ui-chips/types';\nimport { CrossOutlinedSize24, CrossOutlinedSize16 } from '@hh.ru/magritte-ui-icon/variants/icon';\n\nimport styles from './chips.less';\n\nconst STYLE_TO_CSS = {\n neutral: styles.chipStyleNeutral,\n accent: styles.chipStyleAccent,\n};\n\nconst CustomChipComponent: ForwardRefRenderFuncWithCustomElement<CustomChipProps, 'button'> = (\n {\n Element = 'button',\n addon,\n style = 'neutral',\n postfix,\n onDelete,\n deleteOnly = false,\n checked = false,\n disabled = false,\n 'aria-label': ariaLabel,\n hideLabel,\n dataQaWrapper = 'chip',\n children,\n size = 'medium',\n ...buttonProps\n },\n ref\n) => {\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n let additionalAttributes: Record<string, unknown>;\n\n if (Element === 'button') {\n additionalAttributes = {\n type: 'button',\n tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,\n };\n } else {\n additionalAttributes = {\n tabIndex: isComponentDisabled || deleteOnly ? -1 : 0,\n 'aria-disabled': disabled,\n };\n }\n\n if (ref) {\n additionalAttributes.ref = ref;\n }\n\n return (\n <div\n className={classnames(styles.chipWrapper, isComponentDisabled && styles.chipWrapperDisabled)}\n data-qa={dataQaWrapper}\n >\n <Element\n {...additionalAttributes}\n {...buttonProps}\n className={classnames(styles.chip, styles.chipCustom, STYLE_TO_CSS[style], {\n [styles.chipChecked]: checked,\n [styles.deleteOnly]: deleteOnly,\n [styles.sizeSmall]: size === 'small',\n [styles.disabled]: isComponentDisabled,\n })}\n disabled={isComponentDisabled || deleteOnly}\n >\n <ChipContent\n postfix={postfix}\n onDelete={onDelete}\n addon={addon}\n aria-label={ariaLabel}\n hideLabel={hideLabel}\n size={size}\n >\n {children}\n </ChipContent>\n </Element>\n {onDelete && (\n <span className={styles.close}>\n <Action\n data-qa=\"chip-delete-action\"\n onClick={onDelete}\n disabled={isComponentDisabled}\n mode=\"secondary\"\n icon={size === 'small' ? CrossOutlinedSize16 : CrossOutlinedSize24}\n />\n </span>\n )}\n </div>\n );\n};\n\nexport const CustomChip = forwardRef(CustomChipComponent) as ComponentWithCustomElement<CustomChipProps, 'button'>;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AAYA,MAAM,YAAY,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC,eAAe;CACjC,CAAC;AAEF,MAAM,mBAAmB,GAAqE,CAC1F,EACI,OAAO,GAAG,QAAQ,EAClB,KAAK,EACL,KAAK,GAAG,SAAS,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,aAAa,GAAG,MAAM,EACtB,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,GAAG,WAAW,EACjB,EACD,GAAG,KACH;AACA,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AACpC,IAAA,MAAM,mBAAmB,GAAG,QAAQ,IAAI,aAAa,CAAC;AAEtD,IAAA,IAAI,oBAA6C,CAAC;IAElD,IAAI,OAAO,KAAK,QAAQ,EAAE;AACtB,QAAA,oBAAoB,GAAG;AACnB,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,QAAQ,EAAE,mBAAmB,IAAI,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC;SACvD,CAAC;AACL,KAAA;AAAM,SAAA;AACH,QAAA,oBAAoB,GAAG;AACnB,YAAA,QAAQ,EAAE,mBAAmB,IAAI,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC;AACp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