@hh.ru/magritte-ui-chips 5.0.3 → 5.1.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/index.js CHANGED
@@ -5,9 +5,9 @@ export { CustomChip } from './CustomChip.js';
5
5
  export { ChipsContainer } from './ChipsContainer.js';
6
6
  import 'react/jsx-runtime';
7
7
  import 'react';
8
- import '@hh.ru/magritte-common-use-disabled';
9
- import './ChipContent-Bxa1JKDG.js';
10
8
  import 'classnames';
9
+ import '@hh.ru/magritte-common-use-disabled';
10
+ import './ChipContent-CLHuHhW2.js';
11
11
  import '@hh.ru/magritte-ui-typography';
12
12
  import '@hh.ru/magritte-ui-action';
13
13
  import '@hh.ru/magritte-ui-icon/variants/icon';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hh.ru/magritte-ui-chips",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "07811bb36acfa5d6b622e7376d04736612344b19"
42
+ "gitHead": "4fda8bc47483c24498bfef71a65020bbb2375df3"
43
43
  }
package/types.d.ts CHANGED
@@ -35,6 +35,8 @@ type ChipCommonProps = {
35
35
  style?: ChipStyle;
36
36
  /** data-qa атрибут для самой верхней обертки */
37
37
  dataQaWrapper?: string;
38
+ /** Размер чипса */
39
+ size?: 'small' | 'medium';
38
40
  } & (ChipChildrenProps | ChildIconProps);
39
41
  type CheckableChipBaseProps = {
40
42
  /** Тип чипса */
@@ -43,18 +45,29 @@ type CheckableChipBaseProps = {
43
45
  'data-qa'?: string;
44
46
  } & ChipCommonProps;
45
47
  export type CheckableChipProps = Omit<InputHTMLAttributes<HTMLInputElement>, keyof CheckableChipBaseProps> & CheckableChipBaseProps;
48
+ type DeletableCustomChipProps = {
49
+ /** Обработчик клика по крестику. Крестик рисуется, если этот проп задан */
50
+ onDelete: VoidFunction;
51
+ /**
52
+ * Флаг включающий режим в котором сам чипс не реагирует на взаимодействия, но кнопка
53
+ * удаления доступна для нажатия
54
+ */
55
+ deleteOnly?: boolean;
56
+ };
57
+ type NonDeletableCustomChipProps = {
58
+ onDelete?: never;
59
+ deleteOnly?: never;
60
+ };
46
61
  export type CustomChipProps = {
47
62
  /** Флаг выбран ли чипс */
48
63
  checked?: boolean;
49
64
  /** Флаг включен ли чипс */
50
65
  disabled?: boolean;
51
- /** Обработчик клика по крестику. Крестик рисуется, если этот проп задан */
52
- onDelete?: () => void;
53
66
  /** Кастомный компонент */
54
67
  Element?: 'button' | 'a';
55
68
  /** data-qa атрибут для Element */
56
69
  'data-qa'?: string;
57
- } & ChipCommonProps;
70
+ } & ChipCommonProps & (DeletableCustomChipProps | NonDeletableCustomChipProps);
58
71
  export type CustomChipWithElementProps = PropsWithCustomElement<CustomChipProps, 'button'>;
59
72
  export type ChipsContainerProps = {
60
73
  'data-qa'?: string;
@@ -1,21 +0,0 @@
1
- import './index.css';
2
- import { jsxs, jsx, Fragment } 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-0-3","chip":"magritte-chip___uulZ9_5-0-3","chip-wrapper":"magritte-chip-wrapper___os8tP_5-0-3","chipWrapper":"magritte-chip-wrapper___os8tP_5-0-3","chip-wrapper__disabled":"magritte-chip-wrapper__disabled___mHM6-_5-0-3","chipWrapperDisabled":"magritte-chip-wrapper__disabled___mHM6-_5-0-3","content":"magritte-content___17f1s_5-0-3","content__deletable":"magritte-content__deletable___iqF4W_5-0-3","contentDeletable":"magritte-content__deletable___iqF4W_5-0-3","addon":"magritte-addon___mlwVD_5-0-3","label":"magritte-label___NSEUN_5-0-3","postfix-wrapper":"magritte-postfix-wrapper___Qmxwy_5-0-3","postfixWrapper":"magritte-postfix-wrapper___Qmxwy_5-0-3","close":"magritte-close___5I1Fe_5-0-3","chip_style-neutral":"magritte-chip_style-neutral___gELi3_5-0-3","chipStyleNeutral":"magritte-chip_style-neutral___gELi3_5-0-3","postfix":"magritte-postfix___hgYUe_5-0-3","chip__checked":"magritte-chip__checked___3GRxf_5-0-3","chipChecked":"magritte-chip__checked___3GRxf_5-0-3","chip__custom":"magritte-chip__custom___mE-pN_5-0-3","chipCustom":"magritte-chip__custom___mE-pN_5-0-3","chip_style-accent":"magritte-chip_style-accent___rD0pt_5-0-3","chipStyleAccent":"magritte-chip_style-accent___rD0pt_5-0-3"};
8
-
9
- const ChipContent = ({ addon, 'aria-label': ariaLabel, hideLabel, onDelete, postfix, children, }) => {
10
- const showLabel = !hideLabel && !!children;
11
- return (jsxs("span", { className: classnames(styles.content, {
12
- [styles.contentDeletable]: !!onDelete,
13
- }), children: [addon && (jsx("span", { className: styles.addon, children: cloneElement(addon, {
14
- 'data-qa': 'chip-addon',
15
- 'aria-label': ariaLabel,
16
- 'aria-hidden': showLabel,
17
- }) })), showLabel && (jsxs(Fragment, { children: [jsx("span", { className: styles.label, children: jsx(Text, { Element: "span", typography: "subtitle-1-semibold", children: children }) }), postfix && (jsx("span", { className: styles.postfixWrapper, children: jsx(Text, { Element: "span", typography: "subtitle-1-semibold", children: jsx("span", { className: styles.postfix, children: postfix }) }) }))] }))] }));
18
- };
19
-
20
- export { ChipContent as C, styles as s };
21
- //# sourceMappingURL=ChipContent-Bxa1JKDG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChipContent-Bxa1JKDG.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'\n>;\n\nconst ChipContent: FC<ChipContentProps> = ({\n addon,\n 'aria-label': ariaLabel,\n hideLabel,\n onDelete,\n postfix,\n children,\n}) => {\n const showLabel = !hideLabel && !!children;\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 <>\n <span className={styles.label}>\n <Text Element=\"span\" typography=\"subtitle-1-semibold\">\n {children}\n </Text>\n </span>\n {postfix && (\n <span className={styles.postfixWrapper}>\n <Text Element=\"span\" typography=\"subtitle-1-semibold\">\n <span className={styles.postfix}>{postfix}</span>\n </Text>\n </span>\n )}\n </>\n )}\n </span>\n );\n};\n\nexport default ChipContent;\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;AAaA,MAAM,WAAW,GAAyB,CAAC,EACvC,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,GACX,KAAI;IACD,MAAM,SAAS,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC3C,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,IACI,CAAAE,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAD,G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