@snack-uikit/chips 0.25.7 → 0.26.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +8 -0
  3. package/dist/cjs/components/ChipAssist/ChipAssist.d.ts +1 -1
  4. package/dist/cjs/components/ChipAssist/ChipAssist.js +8 -3
  5. package/dist/cjs/components/ChipAssist/styles.module.css +4 -2
  6. package/dist/cjs/components/ChipChoice/components/ChipChoiceBase/ChipChoiceBase.d.ts +2 -2
  7. package/dist/cjs/components/ChipChoice/components/ChipChoiceBase/ChipChoiceBase.js +8 -3
  8. package/dist/cjs/components/ChipChoice/components/ChipChoiceBase/styles.module.css +14 -5
  9. package/dist/cjs/components/ChipChoice/styles.module.css +3 -2
  10. package/dist/cjs/components/ChipChoice/types.d.ts +3 -0
  11. package/dist/cjs/components/ChipChoiceRow/ChipChoiceRow.d.ts +1 -1
  12. package/dist/cjs/components/ChipChoiceRow/ChipChoiceRow.js +5 -3
  13. package/dist/cjs/components/ChipChoiceRow/styles.module.css +1 -0
  14. package/dist/cjs/components/ChipToggle/ChipToggle.d.ts +1 -1
  15. package/dist/cjs/components/ChipToggle/ChipToggle.js +8 -3
  16. package/dist/cjs/components/ChipToggle/styles.module.css +5 -2
  17. package/dist/cjs/types.d.ts +3 -0
  18. package/dist/esm/components/ChipAssist/ChipAssist.d.ts +1 -1
  19. package/dist/esm/components/ChipAssist/ChipAssist.js +3 -2
  20. package/dist/esm/components/ChipAssist/styles.module.css +4 -2
  21. package/dist/esm/components/ChipChoice/components/ChipChoiceBase/ChipChoiceBase.d.ts +2 -2
  22. package/dist/esm/components/ChipChoice/components/ChipChoiceBase/ChipChoiceBase.js +3 -2
  23. package/dist/esm/components/ChipChoice/components/ChipChoiceBase/styles.module.css +14 -5
  24. package/dist/esm/components/ChipChoice/styles.module.css +3 -2
  25. package/dist/esm/components/ChipChoice/types.d.ts +3 -0
  26. package/dist/esm/components/ChipChoiceRow/ChipChoiceRow.d.ts +1 -1
  27. package/dist/esm/components/ChipChoiceRow/ChipChoiceRow.js +4 -2
  28. package/dist/esm/components/ChipChoiceRow/styles.module.css +1 -0
  29. package/dist/esm/components/ChipToggle/ChipToggle.d.ts +1 -1
  30. package/dist/esm/components/ChipToggle/ChipToggle.js +3 -2
  31. package/dist/esm/components/ChipToggle/styles.module.css +5 -2
  32. package/dist/esm/types.d.ts +3 -0
  33. package/package.json +5 -4
  34. package/src/components/ChipAssist/ChipAssist.tsx +3 -1
  35. package/src/components/ChipAssist/styles.module.scss +1 -0
  36. package/src/components/ChipChoice/components/ChipChoiceBase/ChipChoiceBase.tsx +13 -2
  37. package/src/components/ChipChoice/components/ChipChoiceBase/styles.module.scss +8 -1
  38. package/src/components/ChipChoice/types.ts +3 -0
  39. package/src/components/ChipChoiceRow/ChipChoiceRow.tsx +6 -3
  40. package/src/components/ChipChoiceRow/styles.module.scss +1 -0
  41. package/src/components/ChipToggle/ChipToggle.tsx +3 -1
  42. package/src/components/ChipToggle/styles.module.scss +2 -0
  43. package/src/styles.module.scss +3 -1
  44. package/src/types.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.26.0 (2025-03-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-1672:** hide pinned filters divider if no elements is on the right ([8c19dda](https://github.com/cloud-ru-tech/snack-uikit/commit/8c19dda66eb679e2322f64434a6497bd6117ab3c))
12
+
13
+
14
+ ### Features
15
+
16
+ * **PDS-1685:** add truncate to chips ([178b951](https://github.com/cloud-ru-tech/snack-uikit/commit/178b95175c4f0d73b41c343faadaf7dbc28da7b1))
17
+
18
+
19
+
20
+
21
+
6
22
  ## 0.25.7 (2025-03-04)
7
23
 
8
24
  ### Only dependencies have been changed
package/README.md CHANGED
@@ -97,6 +97,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
97
97
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
98
98
  | className | `string` | - | CSS-класс |
99
99
  | tabIndex | `number` | - | HTML tab index |
100
+ | truncateVariant | "end" \| "middle" | middle | Вариант обрезания лейбла |
100
101
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | s | Размер |
101
102
  ## ChipToggle
102
103
  Чип с состоянием выбран/не выбран
@@ -111,6 +112,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
111
112
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
112
113
  | className | `string` | - | CSS-класс |
113
114
  | tabIndex | `number` | - | HTML tab index |
115
+ | truncateVariant | "end" \| "middle" | middle | Вариант обрезания лейбла |
114
116
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | s | Размер |
115
117
  ## ChipChoice.Custom
116
118
  ### Props
@@ -122,6 +124,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
122
124
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
123
125
  | className | `string` | - | CSS-класс |
124
126
  | tabIndex | `number` | - | HTML tab index |
127
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
125
128
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
126
129
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
127
130
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -146,6 +149,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
146
149
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
147
150
  | className | `string` | - | CSS-класс |
148
151
  | tabIndex | `number` | - | HTML tab index |
152
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
149
153
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
150
154
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
151
155
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -188,6 +192,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
188
192
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
189
193
  | className | `string` | - | CSS-класс |
190
194
  | tabIndex | `number` | - | HTML tab index |
195
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
191
196
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
192
197
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
193
198
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -229,6 +234,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
229
234
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
230
235
  | className | `string` | - | CSS-класс |
231
236
  | tabIndex | `number` | - | HTML tab index |
237
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
232
238
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
233
239
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
234
240
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -255,6 +261,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
255
261
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
256
262
  | className | `string` | - | CSS-класс |
257
263
  | tabIndex | `number` | - | HTML tab index |
264
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
258
265
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
259
266
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
260
267
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -279,6 +286,7 @@ import { PlaceholderSVG } from '@snack-uikit/icons';
279
286
  | icon | `ReactElement<any, string \| JSXElementConstructor<any>>` | - | Иконка |
280
287
  | className | `string` | - | CSS-класс |
281
288
  | tabIndex | `number` | - | HTML tab index |
289
+ | truncateVariant | "end" \| "middle" | - | Вариант обрезания лейбла Вариант обрезания значения |
282
290
  | size | enum Size: `"xs"`, `"s"`, `"m"`, `"l"` | - | Размер |
283
291
  | onClick | `MouseEventHandler<HTMLButtonElement \| HTMLDivElement>` | - | Колбек обработки клика |
284
292
  | disableFuzzySearch | `boolean` | false | Отключает Fuzzy Search. Иногда в дроплисте могут быть различные айдишники - нам важно искать их без Fuzzy Search |
@@ -8,4 +8,4 @@ export type ChipAssistProps = WithSupportProps<BaseChipProps & {
8
8
  onClick: MouseEventHandler<HTMLButtonElement>;
9
9
  }>;
10
10
  /** Чип с лейблом */
11
- export declare function ChipAssist({ icon, size, label, disabled, loading, onClick, className, tabIndex, ...rest }: ChipAssistProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ChipAssist({ icon, size, label, disabled, loading, onClick, className, tabIndex, truncateVariant, ...rest }: ChipAssistProps): import("react/jsx-runtime").JSX.Element;
@@ -20,6 +20,7 @@ exports.ChipAssist = ChipAssist;
20
20
  const jsx_runtime_1 = require("react/jsx-runtime");
21
21
  const classnames_1 = __importDefault(require("classnames"));
22
22
  const loaders_1 = require("@snack-uikit/loaders");
23
+ const truncate_string_1 = require("@snack-uikit/truncate-string");
23
24
  const utils_1 = require("@snack-uikit/utils");
24
25
  const constants_1 = require("../../constants");
25
26
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
@@ -33,9 +34,10 @@ function ChipAssist(_a) {
33
34
  loading,
34
35
  onClick,
35
36
  className,
36
- tabIndex
37
+ tabIndex,
38
+ truncateVariant = 'middle'
37
39
  } = _a,
38
- rest = __rest(_a, ["icon", "size", "label", "disabled", "loading", "onClick", "className", "tabIndex"]);
40
+ rest = __rest(_a, ["icon", "size", "label", "disabled", "loading", "onClick", "className", "tabIndex", "truncateVariant"]);
39
41
  const variant = icon && size !== constants_1.SIZE.Xs ? constants_1.VARIANT.IconBefore : constants_1.VARIANT.LabelOnly;
40
42
  const spinnerSize = size === constants_1.SIZE.Xs ? 'xs' : 's';
41
43
  const handleClick = e => {
@@ -67,7 +69,10 @@ function ChipAssist(_a) {
67
69
  }), (0, jsx_runtime_1.jsx)("span", {
68
70
  className: (0, classnames_1.default)(styles_module_scss_1.default.labelLayout, styles_module_scss_1.default.label),
69
71
  "data-test-id": constants_1.CHIP_ASSIST_TEST_IDS.label,
70
- children: label
72
+ children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
73
+ text: label,
74
+ variant: truncateVariant
75
+ })
71
76
  })]
72
77
  }));
73
78
  }
@@ -6,8 +6,8 @@
6
6
  box-sizing:border-box;
7
7
  width:-moz-max-content;
8
8
  width:max-content;
9
- min-width:-moz-max-content;
10
- min-width:max-content;
9
+ min-width:var(--dimension-6m, 48px);
10
+ max-width:100%;
11
11
  margin:0;
12
12
  padding:0;
13
13
  text-decoration:none;
@@ -15,6 +15,7 @@
15
15
  border-style:solid;
16
16
  outline:0;
17
17
  outline-offset:0;
18
+ justify-content:center;
18
19
  color:var(--sys-neutral-text-support, #6d707f);
19
20
  background-color:var(--sys-neutral-background1-level, #fdfdfd);
20
21
  border-color:var(--sys-neutral-decor-default, #dde0ea);
@@ -32,6 +33,7 @@
32
33
  .assistChip .labelLayout{
33
34
  display:inline-flex;
34
35
  align-items:center;
36
+ min-width:0;
35
37
  }
36
38
  .assistChip[data-size=xs]{
37
39
  height:var(--size-chips-xs, 24px);
@@ -1,13 +1,13 @@
1
1
  import { KeyboardEvent, ReactNode } from 'react';
2
2
  import { ChipChoiceCommonProps } from '../../types';
3
- export type ChipChoiceBaseProps = Pick<ChipChoiceCommonProps, 'loading' | 'tabIndex' | 'onClearButtonClick' | 'disabled' | 'icon' | 'label' | 'size' | 'onClick' | 'className'> & {
3
+ export type ChipChoiceBaseProps = Pick<ChipChoiceCommonProps, 'loading' | 'tabIndex' | 'onClearButtonClick' | 'disabled' | 'icon' | 'label' | 'size' | 'onClick' | 'className' | 'truncateVariant'> & {
4
4
  /** Отображаемое значение */
5
5
  valueToRender?: ReactNode;
6
6
  /** Фактическое значение. Используется для отображения кнопки очистки, если свойство <strong>showClearButton=true</strong> */
7
7
  value?: any;
8
8
  onKeyDown?(e: KeyboardEvent<HTMLDivElement>): void;
9
9
  };
10
- export declare const ChipChoiceBase: import("react").ForwardRefExoticComponent<Pick<ChipChoiceCommonProps, "icon" | "size" | "label" | "disabled" | "loading" | "onClick" | "className" | "tabIndex" | "onClearButtonClick"> & {
10
+ export declare const ChipChoiceBase: import("react").ForwardRefExoticComponent<Pick<ChipChoiceCommonProps, "icon" | "size" | "label" | "disabled" | "loading" | "onClick" | "className" | "tabIndex" | "truncateVariant" | "onClearButtonClick"> & {
11
11
  /** Отображаемое значение */
12
12
  valueToRender?: ReactNode;
13
13
  /** Фактическое значение. Используется для отображения кнопки очистки, если свойство <strong>showClearButton=true</strong> */
@@ -22,6 +22,7 @@ const classnames_1 = __importDefault(require("classnames"));
22
22
  const merge_refs_1 = __importDefault(require("merge-refs"));
23
23
  const react_1 = require("react");
24
24
  const loaders_1 = require("@snack-uikit/loaders");
25
+ const truncate_string_1 = require("@snack-uikit/truncate-string");
25
26
  const utils_1 = require("@snack-uikit/utils");
26
27
  const constants_1 = require("../../../../constants");
27
28
  const helperComponents_1 = require("../../../../helperComponents");
@@ -40,9 +41,10 @@ exports.ChipChoiceBase = (0, react_1.forwardRef)((_a, ref) => {
40
41
  className,
41
42
  tabIndex = 0,
42
43
  onClearButtonClick,
43
- onKeyDown
44
+ onKeyDown,
45
+ truncateVariant = 'middle'
44
46
  } = _a,
45
- rest = __rest(_a, ["size", "disabled", "loading", "icon", "label", "valueToRender", "value", "onClick", "className", "tabIndex", "onClearButtonClick", "onKeyDown"]);
47
+ rest = __rest(_a, ["size", "disabled", "loading", "icon", "label", "valueToRender", "value", "onClick", "className", "tabIndex", "onClearButtonClick", "onKeyDown", "truncateVariant"]);
46
48
  const variant = icon && size !== constants_1.SIZE.Xs ? constants_1.VARIANT.IconBefore : constants_1.VARIANT.LabelOnly;
47
49
  const spinnerSize = size === constants_1.SIZE.Xs ? 'xs' : 's';
48
50
  const localRef = (0, react_1.useRef)(null);
@@ -114,7 +116,10 @@ exports.ChipChoiceBase = (0, react_1.forwardRef)((_a, ref) => {
114
116
  }) : (0, jsx_runtime_1.jsx)("span", {
115
117
  className: styles_module_scss_1.default.value,
116
118
  "data-test-id": constants_1.CHIP_CHOICE_TEST_IDS.value,
117
- children: valueToRender !== null && valueToRender !== void 0 ? valueToRender : value
119
+ children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
120
+ text: valueToRender !== null && valueToRender !== void 0 ? valueToRender : value,
121
+ variant: truncateVariant
122
+ })
118
123
  })]
119
124
  }), !disabled && !loading && showClearButton && (0, jsx_runtime_1.jsx)(helperComponents_1.ButtonClearValue, {
120
125
  size: constants_2.BUTTON_CLEAR_VALUE_SIZE_MAP[size],
@@ -12,8 +12,8 @@
12
12
  box-sizing:border-box;
13
13
  width:-moz-max-content;
14
14
  width:max-content;
15
- min-width:-moz-max-content;
16
- min-width:max-content;
15
+ min-width:var(--dimension-6m, 48px);
16
+ max-width:100%;
17
17
  margin:0;
18
18
  padding:0;
19
19
  text-decoration:none;
@@ -37,6 +37,7 @@
37
37
  .choiceChip .labelLayout{
38
38
  display:inline-flex;
39
39
  align-items:center;
40
+ min-width:0;
40
41
  }
41
42
  .choiceChip[data-size=xs]{
42
43
  height:var(--size-chips-xs, 24px);
@@ -220,10 +221,17 @@
220
221
  --offset:var(--space-drop-list-drop-offset, 4px);
221
222
  }
222
223
 
223
- .label,
224
+ .label{
225
+ display:inline-flex;
226
+ flex-grow:1;
227
+ align-items:center;
228
+ white-space:nowrap;
229
+ }
230
+
224
231
  .value{
225
232
  display:inline-flex;
226
233
  align-items:center;
234
+ min-width:0;
227
235
  }
228
236
 
229
237
  .choiceChip{
@@ -234,8 +242,8 @@
234
242
  box-sizing:border-box;
235
243
  width:-moz-max-content;
236
244
  width:max-content;
237
- min-width:-moz-max-content;
238
- min-width:max-content;
245
+ min-width:var(--dimension-6m, 48px);
246
+ max-width:100%;
239
247
  margin:0;
240
248
  padding:0;
241
249
  text-decoration:none;
@@ -259,6 +267,7 @@
259
267
  .choiceChip .labelLayout{
260
268
  display:inline-flex;
261
269
  align-items:center;
270
+ min-width:0;
262
271
  }
263
272
  .choiceChip[data-size=xs]{
264
273
  height:var(--size-chips-xs, 24px);
@@ -12,8 +12,8 @@
12
12
  box-sizing:border-box;
13
13
  width:-moz-max-content;
14
14
  width:max-content;
15
- min-width:-moz-max-content;
16
- min-width:max-content;
15
+ min-width:var(--dimension-6m, 48px);
16
+ max-width:100%;
17
17
  margin:0;
18
18
  padding:0;
19
19
  text-decoration:none;
@@ -37,6 +37,7 @@
37
37
  .choiceChip .labelLayout{
38
38
  display:inline-flex;
39
39
  align-items:center;
40
+ min-width:0;
40
41
  }
41
42
  .choiceChip[data-size=xs]{
42
43
  height:var(--size-chips-xs, 24px);
@@ -1,6 +1,7 @@
1
1
  import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { DropdownProps } from '@snack-uikit/dropdown';
3
3
  import { BaseItemProps, DroplistProps, GroupItemProps, GroupSelectItemProps, ItemContentProps, ItemId, NextListItemProps, SelectionMultipleState, SelectionSingleState } from '@snack-uikit/list';
4
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
4
5
  import { WithSupportProps } from '@snack-uikit/utils';
5
6
  import { BaseChipProps, Size } from '../../types';
6
7
  export type AnyType = any;
@@ -54,6 +55,8 @@ export type ChipChoiceCommonProps = WithSupportProps<Partial<BaseChipProps> & {
54
55
  open?: boolean;
55
56
  /** Колбек отображения компонента. Срабатывает при изменении состояния open. */
56
57
  onOpenChange?: (isOpen: boolean) => void;
58
+ /** Вариант обрезания значения */
59
+ truncateVariant?: TruncateStringProps['variant'];
57
60
  }>;
58
61
  export type ChipChoiceSelectCommonProps<T extends ContentRenderProps = ContentRenderProps> = ChipChoiceCommonProps & {
59
62
  options: FilterOption<T>[];
@@ -26,4 +26,4 @@ export type ChipChoiceRowProps<TState extends FiltersState> = WithSupportProps<{
26
26
  /** Коллбек на изменение видимых фильтров */
27
27
  onVisibleFiltersChange?(value: string[]): void;
28
28
  }>;
29
- export declare function ChipChoiceRow<TState extends FiltersState>({ filters, onChange, showClearButton, showAddButton, className, value, defaultValue: defaultValueProp, size, visibleFilters: visibleFiltersProp, onVisibleFiltersChange, ...rest }: ChipChoiceRowProps<TState>): import("react/jsx-runtime").JSX.Element;
29
+ export declare function ChipChoiceRow<TState extends FiltersState>({ filters, onChange, showClearButton: showClearButtonProp, showAddButton, className, value, defaultValue: defaultValueProp, size, visibleFilters: visibleFiltersProp, onVisibleFiltersChange, ...rest }: ChipChoiceRowProps<TState>): import("react/jsx-runtime").JSX.Element;
@@ -36,7 +36,7 @@ function ChipChoiceRow(_a) {
36
36
  var {
37
37
  filters,
38
38
  onChange,
39
- showClearButton = true,
39
+ showClearButton: showClearButtonProp = true,
40
40
  showAddButton = true,
41
41
  className,
42
42
  value,
@@ -149,6 +149,8 @@ function ChipChoiceRow(_a) {
149
149
  }
150
150
  addListPrevValue.current = addListValue;
151
151
  }, [addListValue, handleChipOpen]);
152
+ const showClearButton = showClearButtonProp && hasAnyFilter;
153
+ const showPinnedFiltersDivider = showAddButton || showClearButton || visibleFilters.length > 0;
152
154
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({
153
155
  className: (0, classnames_1.default)(styles_module_scss_1.default.chipChoiceRow, className)
154
156
  }, (0, utils_1.extractSupportProps)(rest), {
@@ -159,7 +161,7 @@ function ChipChoiceRow(_a) {
159
161
  size: constants_2.MAP_ROW_SIZE_TO_CHOICE_SIZE[size],
160
162
  onChange: value => handleChange(filter.id, value),
161
163
  onClearButtonClick: handleClearPinnedFilter(filter.id)
162
- }), filter.id)), (0, jsx_runtime_1.jsx)(divider_1.Divider, {
164
+ }), filter.id)), showPinnedFiltersDivider && (0, jsx_runtime_1.jsx)(divider_1.Divider, {
163
165
  orientation: 'vertical',
164
166
  className: styles_module_scss_1.default.divider
165
167
  })]
@@ -192,7 +194,7 @@ function ChipChoiceRow(_a) {
192
194
  "data-test-id": constants_1.CHIP_CHOICE_ROW_IDS.addButton
193
195
  })
194
196
  })
195
- }), showClearButton && hasAnyFilter && (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
197
+ }), showClearButton && (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
196
198
  onClick: handleFiltersClear,
197
199
  label: t('clear'),
198
200
  icon: (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {}),
@@ -9,6 +9,7 @@
9
9
  gap:var(--space-chips-filter-row-gap, 4px);
10
10
  display:flex;
11
11
  flex-wrap:wrap;
12
+ min-width:0;
12
13
  }
13
14
 
14
15
  .controlWrapper{
@@ -10,4 +10,4 @@ export type ChipToggleProps = WithSupportProps<BaseChipProps & {
10
10
  onChange(checked: boolean, e: ChangeEvent<HTMLInputElement>): void;
11
11
  }>;
12
12
  /** Чип с состоянием выбран/не выбран */
13
- export declare function ChipToggle({ icon, size, label, checked, disabled, loading, onChange, className, tabIndex, ...rest }: ChipToggleProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function ChipToggle({ icon, size, label, checked, disabled, loading, onChange, className, tabIndex, truncateVariant, ...rest }: ChipToggleProps): import("react/jsx-runtime").JSX.Element;
@@ -20,6 +20,7 @@ exports.ChipToggle = ChipToggle;
20
20
  const jsx_runtime_1 = require("react/jsx-runtime");
21
21
  const classnames_1 = __importDefault(require("classnames"));
22
22
  const loaders_1 = require("@snack-uikit/loaders");
23
+ const truncate_string_1 = require("@snack-uikit/truncate-string");
23
24
  const utils_1 = require("@snack-uikit/utils");
24
25
  const constants_1 = require("../../constants");
25
26
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
@@ -34,9 +35,10 @@ function ChipToggle(_a) {
34
35
  loading,
35
36
  onChange,
36
37
  className,
37
- tabIndex = 0
38
+ tabIndex = 0,
39
+ truncateVariant = 'middle'
38
40
  } = _a,
39
- rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex"]);
41
+ rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex", "truncateVariant"]);
40
42
  const variant = icon && size !== constants_1.SIZE.Xs ? constants_1.VARIANT.IconBefore : constants_1.VARIANT.LabelOnly;
41
43
  const spinnerSize = size === constants_1.SIZE.Xs ? 'xs' : 's';
42
44
  const handleChange = e => {
@@ -75,7 +77,10 @@ function ChipToggle(_a) {
75
77
  }), (0, jsx_runtime_1.jsx)("span", {
76
78
  className: (0, classnames_1.default)(styles_module_scss_1.default.labelLayout, styles_module_scss_1.default.label),
77
79
  "data-test-id": constants_1.CHIP_TOGGLE_TEST_IDS.label,
78
- children: label
80
+ children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
81
+ text: label,
82
+ variant: truncateVariant
83
+ })
79
84
  })]
80
85
  })]
81
86
  }));
@@ -6,8 +6,8 @@
6
6
  box-sizing:border-box;
7
7
  width:-moz-max-content;
8
8
  width:max-content;
9
- min-width:-moz-max-content;
10
- min-width:max-content;
9
+ min-width:var(--dimension-6m, 48px);
10
+ max-width:100%;
11
11
  margin:0;
12
12
  padding:0;
13
13
  text-decoration:none;
@@ -15,6 +15,7 @@
15
15
  border-style:solid;
16
16
  outline:0;
17
17
  outline-offset:0;
18
+ justify-content:center;
18
19
  color:var(--sys-neutral-text-support, #6d707f);
19
20
  background-color:var(--sys-neutral-background1-level, #fdfdfd);
20
21
  border-color:var(--sys-neutral-decor-default, #dde0ea);
@@ -45,6 +46,7 @@
45
46
 
46
47
  .toggleChip{
47
48
  position:relative;
49
+ min-width:0;
48
50
  margin:0;
49
51
  padding:0;
50
52
  border:none;
@@ -61,6 +63,7 @@
61
63
  .toggleChip .labelLayout{
62
64
  display:inline-flex;
63
65
  align-items:center;
66
+ min-width:0;
64
67
  }
65
68
  .toggleChip[data-size=xs] .label{
66
69
  font-family:var(--sans-label-s-font-family, SB Sans Interface);
@@ -1,4 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
2
3
  import { ValueOf } from '@snack-uikit/utils';
3
4
  import { BUTTON_SIZE, SIZE, VARIANT } from './constants';
4
5
  export type Size = ValueOf<typeof SIZE>;
@@ -17,4 +18,6 @@ export type BaseChipProps = {
17
18
  className?: string;
18
19
  /** HTML tab index */
19
20
  tabIndex?: number;
21
+ /** Вариант обрезания лейбла */
22
+ truncateVariant?: TruncateStringProps['variant'];
20
23
  };
@@ -8,4 +8,4 @@ export type ChipAssistProps = WithSupportProps<BaseChipProps & {
8
8
  onClick: MouseEventHandler<HTMLButtonElement>;
9
9
  }>;
10
10
  /** Чип с лейблом */
11
- export declare function ChipAssist({ icon, size, label, disabled, loading, onClick, className, tabIndex, ...rest }: ChipAssistProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function ChipAssist({ icon, size, label, disabled, loading, onClick, className, tabIndex, truncateVariant, ...rest }: ChipAssistProps): import("react/jsx-runtime").JSX.Element;
@@ -12,12 +12,13 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { Sun } from '@snack-uikit/loaders';
15
+ import { TruncateString } from '@snack-uikit/truncate-string';
15
16
  import { extractSupportProps } from '@snack-uikit/utils';
16
17
  import { CHIP_ASSIST_TEST_IDS, SIZE, VARIANT } from '../../constants';
17
18
  import styles from './styles.module.css';
18
19
  /** Чип с лейблом */
19
20
  export function ChipAssist(_a) {
20
- var { icon, size = SIZE.S, label, disabled, loading, onClick, className, tabIndex } = _a, rest = __rest(_a, ["icon", "size", "label", "disabled", "loading", "onClick", "className", "tabIndex"]);
21
+ var { icon, size = SIZE.S, label, disabled, loading, onClick, className, tabIndex, truncateVariant = 'middle' } = _a, rest = __rest(_a, ["icon", "size", "label", "disabled", "loading", "onClick", "className", "tabIndex", "truncateVariant"]);
21
22
  const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
22
23
  const spinnerSize = size === SIZE.Xs ? 'xs' : 's';
23
24
  const handleClick = e => {
@@ -26,5 +27,5 @@ export function ChipAssist(_a) {
26
27
  }
27
28
  onClick === null || onClick === void 0 ? void 0 : onClick(e);
28
29
  };
29
- return (_jsxs("button", Object.assign({ type: 'button' }, extractSupportProps(rest), { tabIndex: tabIndex, "data-size": size, "data-loading": loading || undefined, "data-variant": variant, disabled: !loading && disabled, onClick: handleClick, className: cn(styles.assistChip, className), children: [variant === VARIANT.IconBefore && !loading && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_ASSIST_TEST_IDS.icon, children: icon })), loading && (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_ASSIST_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })), _jsx("span", { className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_ASSIST_TEST_IDS.label, children: label })] })));
30
+ return (_jsxs("button", Object.assign({ type: 'button' }, extractSupportProps(rest), { tabIndex: tabIndex, "data-size": size, "data-loading": loading || undefined, "data-variant": variant, disabled: !loading && disabled, onClick: handleClick, className: cn(styles.assistChip, className), children: [variant === VARIANT.IconBefore && !loading && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_ASSIST_TEST_IDS.icon, children: icon })), loading && (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_ASSIST_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })), _jsx("span", { className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_ASSIST_TEST_IDS.label, children: _jsx(TruncateString, { text: label, variant: truncateVariant }) })] })));
30
31
  }
@@ -6,8 +6,8 @@
6
6
  box-sizing:border-box;
7
7
  width:-moz-max-content;
8
8
  width:max-content;
9
- min-width:-moz-max-content;
10
- min-width:max-content;
9
+ min-width:var(--dimension-6m, 48px);
10
+ max-width:100%;
11
11
  margin:0;
12
12
  padding:0;
13
13
  text-decoration:none;
@@ -15,6 +15,7 @@
15
15
  border-style:solid;
16
16
  outline:0;
17
17
  outline-offset:0;
18
+ justify-content:center;
18
19
  color:var(--sys-neutral-text-support, #6d707f);
19
20
  background-color:var(--sys-neutral-background1-level, #fdfdfd);
20
21
  border-color:var(--sys-neutral-decor-default, #dde0ea);
@@ -32,6 +33,7 @@
32
33
  .assistChip .labelLayout{
33
34
  display:inline-flex;
34
35
  align-items:center;
36
+ min-width:0;
35
37
  }
36
38
  .assistChip[data-size=xs]{
37
39
  height:var(--size-chips-xs, 24px);
@@ -1,13 +1,13 @@
1
1
  import { KeyboardEvent, ReactNode } from 'react';
2
2
  import { ChipChoiceCommonProps } from '../../types';
3
- export type ChipChoiceBaseProps = Pick<ChipChoiceCommonProps, 'loading' | 'tabIndex' | 'onClearButtonClick' | 'disabled' | 'icon' | 'label' | 'size' | 'onClick' | 'className'> & {
3
+ export type ChipChoiceBaseProps = Pick<ChipChoiceCommonProps, 'loading' | 'tabIndex' | 'onClearButtonClick' | 'disabled' | 'icon' | 'label' | 'size' | 'onClick' | 'className' | 'truncateVariant'> & {
4
4
  /** Отображаемое значение */
5
5
  valueToRender?: ReactNode;
6
6
  /** Фактическое значение. Используется для отображения кнопки очистки, если свойство <strong>showClearButton=true</strong> */
7
7
  value?: any;
8
8
  onKeyDown?(e: KeyboardEvent<HTMLDivElement>): void;
9
9
  };
10
- export declare const ChipChoiceBase: import("react").ForwardRefExoticComponent<Pick<ChipChoiceCommonProps, "icon" | "size" | "label" | "disabled" | "loading" | "onClick" | "className" | "tabIndex" | "onClearButtonClick"> & {
10
+ export declare const ChipChoiceBase: import("react").ForwardRefExoticComponent<Pick<ChipChoiceCommonProps, "icon" | "size" | "label" | "disabled" | "loading" | "onClick" | "className" | "tabIndex" | "truncateVariant" | "onClearButtonClick"> & {
11
11
  /** Отображаемое значение */
12
12
  valueToRender?: ReactNode;
13
13
  /** Фактическое значение. Используется для отображения кнопки очистки, если свойство <strong>showClearButton=true</strong> */
@@ -14,13 +14,14 @@ import cn from 'classnames';
14
14
  import mergeRefs from 'merge-refs';
15
15
  import { forwardRef, useRef, useState } from 'react';
16
16
  import { Sun } from '@snack-uikit/loaders';
17
+ import { TruncateString } from '@snack-uikit/truncate-string';
17
18
  import { extractSupportProps } from '@snack-uikit/utils';
18
19
  import { CHIP_CHOICE_TEST_IDS, SIZE, VARIANT } from '../../../../constants';
19
20
  import { ButtonClearValue } from '../../../../helperComponents';
20
21
  import { BUTTON_CLEAR_VALUE_SIZE_MAP } from '../../constants';
21
22
  import styles from './styles.module.css';
22
23
  export const ChipChoiceBase = forwardRef((_a, ref) => {
23
- var { size = SIZE.S, disabled, loading, icon, label, valueToRender, value, onClick, className, tabIndex = 0, onClearButtonClick, onKeyDown } = _a, rest = __rest(_a, ["size", "disabled", "loading", "icon", "label", "valueToRender", "value", "onClick", "className", "tabIndex", "onClearButtonClick", "onKeyDown"]);
24
+ var { size = SIZE.S, disabled, loading, icon, label, valueToRender, value, onClick, className, tabIndex = 0, onClearButtonClick, onKeyDown, truncateVariant = 'middle' } = _a, rest = __rest(_a, ["size", "disabled", "loading", "icon", "label", "valueToRender", "value", "onClick", "className", "tabIndex", "onClearButtonClick", "onKeyDown", "truncateVariant"]);
24
25
  const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
25
26
  const spinnerSize = size === SIZE.Xs ? 'xs' : 's';
26
27
  const localRef = useRef(null);
@@ -61,5 +62,5 @@ export const ChipChoiceBase = forwardRef((_a, ref) => {
61
62
  break;
62
63
  }
63
64
  };
64
- return (_jsxs("div", Object.assign({}, extractSupportProps(rest), { role: 'button', ref: mergeRefs(localRef, ref), className: cn(styles.choiceChip, className), "data-size": size, "data-variant": variant, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, onClick: handleChipClick, onKeyDown: handleChipKeyDown, tabIndex: tabIndex, children: [variant === VARIANT.IconBefore && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_CHOICE_TEST_IDS.icon, children: icon })), _jsxs("span", { className: styles.labelLayout, children: [label && (_jsx("span", { className: styles.label, "data-test-id": CHIP_CHOICE_TEST_IDS.label, children: label + ': ' })), loading ? (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_CHOICE_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })) : (_jsx("span", { className: styles.value, "data-test-id": CHIP_CHOICE_TEST_IDS.value, children: valueToRender !== null && valueToRender !== void 0 ? valueToRender : value }))] }), !disabled && !loading && showClearButton && (_jsx(ButtonClearValue, { size: BUTTON_CLEAR_VALUE_SIZE_MAP[size], onClick: handleClearButtonClick, "data-test-id": CHIP_CHOICE_TEST_IDS.clearButton, onKeyDown: handleClearButtonKeyDown, ref: clearButtonRef }))] })));
65
+ return (_jsxs("div", Object.assign({}, extractSupportProps(rest), { role: 'button', ref: mergeRefs(localRef, ref), className: cn(styles.choiceChip, className), "data-size": size, "data-variant": variant, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, onClick: handleChipClick, onKeyDown: handleChipKeyDown, tabIndex: tabIndex, children: [variant === VARIANT.IconBefore && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_CHOICE_TEST_IDS.icon, children: icon })), _jsxs("span", { className: styles.labelLayout, children: [label && (_jsx("span", { className: styles.label, "data-test-id": CHIP_CHOICE_TEST_IDS.label, children: label + ': ' })), loading ? (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_CHOICE_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })) : (_jsx("span", { className: styles.value, "data-test-id": CHIP_CHOICE_TEST_IDS.value, children: _jsx(TruncateString, { text: valueToRender !== null && valueToRender !== void 0 ? valueToRender : value, variant: truncateVariant }) }))] }), !disabled && !loading && showClearButton && (_jsx(ButtonClearValue, { size: BUTTON_CLEAR_VALUE_SIZE_MAP[size], onClick: handleClearButtonClick, "data-test-id": CHIP_CHOICE_TEST_IDS.clearButton, onKeyDown: handleClearButtonKeyDown, ref: clearButtonRef }))] })));
65
66
  });
@@ -12,8 +12,8 @@
12
12
  box-sizing:border-box;
13
13
  width:-moz-max-content;
14
14
  width:max-content;
15
- min-width:-moz-max-content;
16
- min-width:max-content;
15
+ min-width:var(--dimension-6m, 48px);
16
+ max-width:100%;
17
17
  margin:0;
18
18
  padding:0;
19
19
  text-decoration:none;
@@ -37,6 +37,7 @@
37
37
  .choiceChip .labelLayout{
38
38
  display:inline-flex;
39
39
  align-items:center;
40
+ min-width:0;
40
41
  }
41
42
  .choiceChip[data-size=xs]{
42
43
  height:var(--size-chips-xs, 24px);
@@ -220,10 +221,17 @@
220
221
  --offset:var(--space-drop-list-drop-offset, 4px);
221
222
  }
222
223
 
223
- .label,
224
+ .label{
225
+ display:inline-flex;
226
+ flex-grow:1;
227
+ align-items:center;
228
+ white-space:nowrap;
229
+ }
230
+
224
231
  .value{
225
232
  display:inline-flex;
226
233
  align-items:center;
234
+ min-width:0;
227
235
  }
228
236
 
229
237
  .choiceChip{
@@ -234,8 +242,8 @@
234
242
  box-sizing:border-box;
235
243
  width:-moz-max-content;
236
244
  width:max-content;
237
- min-width:-moz-max-content;
238
- min-width:max-content;
245
+ min-width:var(--dimension-6m, 48px);
246
+ max-width:100%;
239
247
  margin:0;
240
248
  padding:0;
241
249
  text-decoration:none;
@@ -259,6 +267,7 @@
259
267
  .choiceChip .labelLayout{
260
268
  display:inline-flex;
261
269
  align-items:center;
270
+ min-width:0;
262
271
  }
263
272
  .choiceChip[data-size=xs]{
264
273
  height:var(--size-chips-xs, 24px);
@@ -12,8 +12,8 @@
12
12
  box-sizing:border-box;
13
13
  width:-moz-max-content;
14
14
  width:max-content;
15
- min-width:-moz-max-content;
16
- min-width:max-content;
15
+ min-width:var(--dimension-6m, 48px);
16
+ max-width:100%;
17
17
  margin:0;
18
18
  padding:0;
19
19
  text-decoration:none;
@@ -37,6 +37,7 @@
37
37
  .choiceChip .labelLayout{
38
38
  display:inline-flex;
39
39
  align-items:center;
40
+ min-width:0;
40
41
  }
41
42
  .choiceChip[data-size=xs]{
42
43
  height:var(--size-chips-xs, 24px);
@@ -1,6 +1,7 @@
1
1
  import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { DropdownProps } from '@snack-uikit/dropdown';
3
3
  import { BaseItemProps, DroplistProps, GroupItemProps, GroupSelectItemProps, ItemContentProps, ItemId, NextListItemProps, SelectionMultipleState, SelectionSingleState } from '@snack-uikit/list';
4
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
4
5
  import { WithSupportProps } from '@snack-uikit/utils';
5
6
  import { BaseChipProps, Size } from '../../types';
6
7
  export type AnyType = any;
@@ -54,6 +55,8 @@ export type ChipChoiceCommonProps = WithSupportProps<Partial<BaseChipProps> & {
54
55
  open?: boolean;
55
56
  /** Колбек отображения компонента. Срабатывает при изменении состояния open. */
56
57
  onOpenChange?: (isOpen: boolean) => void;
58
+ /** Вариант обрезания значения */
59
+ truncateVariant?: TruncateStringProps['variant'];
57
60
  }>;
58
61
  export type ChipChoiceSelectCommonProps<T extends ContentRenderProps = ContentRenderProps> = ChipChoiceCommonProps & {
59
62
  options: FilterOption<T>[];
@@ -26,4 +26,4 @@ export type ChipChoiceRowProps<TState extends FiltersState> = WithSupportProps<{
26
26
  /** Коллбек на изменение видимых фильтров */
27
27
  onVisibleFiltersChange?(value: string[]): void;
28
28
  }>;
29
- export declare function ChipChoiceRow<TState extends FiltersState>({ filters, onChange, showClearButton, showAddButton, className, value, defaultValue: defaultValueProp, size, visibleFilters: visibleFiltersProp, onVisibleFiltersChange, ...rest }: ChipChoiceRowProps<TState>): import("react/jsx-runtime").JSX.Element;
29
+ export declare function ChipChoiceRow<TState extends FiltersState>({ filters, onChange, showClearButton: showClearButtonProp, showAddButton, className, value, defaultValue: defaultValueProp, size, visibleFilters: visibleFiltersProp, onVisibleFiltersChange, ...rest }: ChipChoiceRowProps<TState>): import("react/jsx-runtime").JSX.Element;
@@ -25,7 +25,7 @@ import { ForwardedChipChoice } from './components';
25
25
  import { CHIP_CHOICE_ROW_SIZE, MAP_ROW_SIZE_TO_BUTTON_SIZE, MAP_ROW_SIZE_TO_CHOICE_SIZE } from './constants';
26
26
  import styles from './styles.module.css';
27
27
  export function ChipChoiceRow(_a) {
28
- var { filters, onChange, showClearButton = true, showAddButton = true, className, value, defaultValue: defaultValueProp, size = CHIP_CHOICE_ROW_SIZE.S, visibleFilters: visibleFiltersProp, onVisibleFiltersChange } = _a, rest = __rest(_a, ["filters", "onChange", "showClearButton", "showAddButton", "className", "value", "defaultValue", "size", "visibleFilters", "onVisibleFiltersChange"]);
28
+ var { filters, onChange, showClearButton: showClearButtonProp = true, showAddButton = true, className, value, defaultValue: defaultValueProp, size = CHIP_CHOICE_ROW_SIZE.S, visibleFilters: visibleFiltersProp, onVisibleFiltersChange } = _a, rest = __rest(_a, ["filters", "onChange", "showClearButton", "showAddButton", "className", "value", "defaultValue", "size", "visibleFilters", "onVisibleFiltersChange"]);
29
29
  const { t } = useLocale('Chips');
30
30
  const defaultValue = useMemo(() => (defaultValueProp !== null && defaultValueProp !== void 0 ? defaultValueProp : {}), [defaultValueProp]);
31
31
  const [state, setState] = useUncontrolledProp(value, defaultValue, newState => {
@@ -112,5 +112,7 @@ export function ChipChoiceRow(_a) {
112
112
  }
113
113
  addListPrevValue.current = addListValue;
114
114
  }, [addListValue, handleChipOpen]);
115
- return (_jsxs("div", Object.assign({ className: cn(styles.chipChoiceRow, className) }, extractSupportProps(rest), { children: [pinnedFilters.length > 0 && (_jsxs("div", { className: styles.pinnedItems, children: [pinnedFilters.map(filter => (_jsx(ForwardedChipChoice, Object.assign({}, filter, { value: state[filter.id], size: MAP_ROW_SIZE_TO_CHOICE_SIZE[size], onChange: (value) => handleChange(filter.id, value), onClearButtonClick: handleClearPinnedFilter(filter.id) }), filter.id))), _jsx(Divider, { orientation: 'vertical', className: styles.divider })] })), visibleFilters.map(filter => (_jsx(ForwardedChipChoice, Object.assign({}, filter, { value: state[filter.id], size: MAP_ROW_SIZE_TO_CHOICE_SIZE[size], onChange: (value) => handleChange(filter.id, value), onClearButtonClick: handleRemoveVisibleFilter(filter.id), open: openedChip === filter.id, onOpenChange: handleChipOpen(filter.id) }), filter.id))), _jsxs("div", { className: styles.controlWrapper, children: [showAddButton && (_jsx(Tooltip, { tip: t('addButtonDisabledTip'), open: canAddChips ? false : undefined, placement: 'bottom', "data-test-id": CHIP_CHOICE_ROW_IDS.addButtonTooltip, children: _jsx(Droplist, { open: canAddChips && addListOpen, onOpenChange: setAddListOpen, items: addSelectorOptions, triggerClassName: styles.addButtonWrapper, trigger: 'clickAndFocusVisible', children: _jsx(ButtonFunction, { disabled: !canAddChips, label: t('add'), icon: _jsx(PlusSVG, {}), iconPosition: 'before', size: MAP_ROW_SIZE_TO_BUTTON_SIZE[size], "data-test-id": CHIP_CHOICE_ROW_IDS.addButton }) }) })), showClearButton && hasAnyFilter && (_jsx(ButtonFunction, { onClick: handleFiltersClear, label: t('clear'), icon: _jsx(CrossSVG, {}), iconPosition: 'before', size: MAP_ROW_SIZE_TO_BUTTON_SIZE[size], "data-test-id": CHIP_CHOICE_ROW_IDS.clearButton }))] })] })));
115
+ const showClearButton = showClearButtonProp && hasAnyFilter;
116
+ const showPinnedFiltersDivider = showAddButton || showClearButton || visibleFilters.length > 0;
117
+ return (_jsxs("div", Object.assign({ className: cn(styles.chipChoiceRow, className) }, extractSupportProps(rest), { children: [pinnedFilters.length > 0 && (_jsxs("div", { className: styles.pinnedItems, children: [pinnedFilters.map(filter => (_jsx(ForwardedChipChoice, Object.assign({}, filter, { value: state[filter.id], size: MAP_ROW_SIZE_TO_CHOICE_SIZE[size], onChange: (value) => handleChange(filter.id, value), onClearButtonClick: handleClearPinnedFilter(filter.id) }), filter.id))), showPinnedFiltersDivider && _jsx(Divider, { orientation: 'vertical', className: styles.divider })] })), visibleFilters.map(filter => (_jsx(ForwardedChipChoice, Object.assign({}, filter, { value: state[filter.id], size: MAP_ROW_SIZE_TO_CHOICE_SIZE[size], onChange: (value) => handleChange(filter.id, value), onClearButtonClick: handleRemoveVisibleFilter(filter.id), open: openedChip === filter.id, onOpenChange: handleChipOpen(filter.id) }), filter.id))), _jsxs("div", { className: styles.controlWrapper, children: [showAddButton && (_jsx(Tooltip, { tip: t('addButtonDisabledTip'), open: canAddChips ? false : undefined, placement: 'bottom', "data-test-id": CHIP_CHOICE_ROW_IDS.addButtonTooltip, children: _jsx(Droplist, { open: canAddChips && addListOpen, onOpenChange: setAddListOpen, items: addSelectorOptions, triggerClassName: styles.addButtonWrapper, trigger: 'clickAndFocusVisible', children: _jsx(ButtonFunction, { disabled: !canAddChips, label: t('add'), icon: _jsx(PlusSVG, {}), iconPosition: 'before', size: MAP_ROW_SIZE_TO_BUTTON_SIZE[size], "data-test-id": CHIP_CHOICE_ROW_IDS.addButton }) }) })), showClearButton && (_jsx(ButtonFunction, { onClick: handleFiltersClear, label: t('clear'), icon: _jsx(CrossSVG, {}), iconPosition: 'before', size: MAP_ROW_SIZE_TO_BUTTON_SIZE[size], "data-test-id": CHIP_CHOICE_ROW_IDS.clearButton }))] })] })));
116
118
  }
@@ -9,6 +9,7 @@
9
9
  gap:var(--space-chips-filter-row-gap, 4px);
10
10
  display:flex;
11
11
  flex-wrap:wrap;
12
+ min-width:0;
12
13
  }
13
14
 
14
15
  .controlWrapper{
@@ -10,4 +10,4 @@ export type ChipToggleProps = WithSupportProps<BaseChipProps & {
10
10
  onChange(checked: boolean, e: ChangeEvent<HTMLInputElement>): void;
11
11
  }>;
12
12
  /** Чип с состоянием выбран/не выбран */
13
- export declare function ChipToggle({ icon, size, label, checked, disabled, loading, onChange, className, tabIndex, ...rest }: ChipToggleProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function ChipToggle({ icon, size, label, checked, disabled, loading, onChange, className, tabIndex, truncateVariant, ...rest }: ChipToggleProps): import("react/jsx-runtime").JSX.Element;
@@ -12,12 +12,13 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { Sun } from '@snack-uikit/loaders';
15
+ import { TruncateString } from '@snack-uikit/truncate-string';
15
16
  import { extractSupportProps } from '@snack-uikit/utils';
16
17
  import { CHIP_TOGGLE_TEST_IDS, SIZE, VARIANT } from '../../constants';
17
18
  import styles from './styles.module.css';
18
19
  /** Чип с состоянием выбран/не выбран */
19
20
  export function ChipToggle(_a) {
20
- var { icon, size = SIZE.S, label, checked, disabled, loading, onChange, className, tabIndex = 0 } = _a, rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex"]);
21
+ var { icon, size = SIZE.S, label, checked, disabled, loading, onChange, className, tabIndex = 0, truncateVariant = 'middle' } = _a, rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex", "truncateVariant"]);
21
22
  const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
22
23
  const spinnerSize = size === SIZE.Xs ? 'xs' : 's';
23
24
  const handleChange = e => {
@@ -26,5 +27,5 @@ export function ChipToggle(_a) {
26
27
  }
27
28
  onChange === null || onChange === void 0 ? void 0 : onChange(!checked, e);
28
29
  };
29
- return (_jsxs("label", Object.assign({}, extractSupportProps(rest), { "data-size": size, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, "data-variant": variant, "data-checked": checked || undefined, className: cn(styles.toggleChip, className), children: [_jsx("input", { "data-test-id": CHIP_TOGGLE_TEST_IDS.input, type: 'checkbox', checked: checked, onChange: handleChange, disabled: !loading && disabled, tabIndex: disabled ? -1 : tabIndex, className: styles.toggleChipInput }), _jsxs("span", { className: styles.toggleChipContent, children: [variant === VARIANT.IconBefore && !loading && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_TOGGLE_TEST_IDS.icon, children: icon })), loading && (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_TOGGLE_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })), _jsx("span", { className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_TOGGLE_TEST_IDS.label, children: label })] })] })));
30
+ return (_jsxs("label", Object.assign({}, extractSupportProps(rest), { "data-size": size, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, "data-variant": variant, "data-checked": checked || undefined, className: cn(styles.toggleChip, className), children: [_jsx("input", { "data-test-id": CHIP_TOGGLE_TEST_IDS.input, type: 'checkbox', checked: checked, onChange: handleChange, disabled: !loading && disabled, tabIndex: disabled ? -1 : tabIndex, className: styles.toggleChipInput }), _jsxs("span", { className: styles.toggleChipContent, children: [variant === VARIANT.IconBefore && !loading && (_jsx("span", { className: styles.icon, "data-test-id": CHIP_TOGGLE_TEST_IDS.icon, children: icon })), loading && (_jsx("span", { className: styles.spinner, "data-test-id": CHIP_TOGGLE_TEST_IDS.spinner, children: _jsx(Sun, { size: spinnerSize }) })), _jsx("span", { className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_TOGGLE_TEST_IDS.label, children: _jsx(TruncateString, { text: label, variant: truncateVariant }) })] })] })));
30
31
  }
@@ -6,8 +6,8 @@
6
6
  box-sizing:border-box;
7
7
  width:-moz-max-content;
8
8
  width:max-content;
9
- min-width:-moz-max-content;
10
- min-width:max-content;
9
+ min-width:var(--dimension-6m, 48px);
10
+ max-width:100%;
11
11
  margin:0;
12
12
  padding:0;
13
13
  text-decoration:none;
@@ -15,6 +15,7 @@
15
15
  border-style:solid;
16
16
  outline:0;
17
17
  outline-offset:0;
18
+ justify-content:center;
18
19
  color:var(--sys-neutral-text-support, #6d707f);
19
20
  background-color:var(--sys-neutral-background1-level, #fdfdfd);
20
21
  border-color:var(--sys-neutral-decor-default, #dde0ea);
@@ -45,6 +46,7 @@
45
46
 
46
47
  .toggleChip{
47
48
  position:relative;
49
+ min-width:0;
48
50
  margin:0;
49
51
  padding:0;
50
52
  border:none;
@@ -61,6 +63,7 @@
61
63
  .toggleChip .labelLayout{
62
64
  display:inline-flex;
63
65
  align-items:center;
66
+ min-width:0;
64
67
  }
65
68
  .toggleChip[data-size=xs] .label{
66
69
  font-family:var(--sans-label-s-font-family, SB Sans Interface);
@@ -1,4 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
2
3
  import { ValueOf } from '@snack-uikit/utils';
3
4
  import { BUTTON_SIZE, SIZE, VARIANT } from './constants';
4
5
  export type Size = ValueOf<typeof SIZE>;
@@ -17,4 +18,6 @@ export type BaseChipProps = {
17
18
  className?: string;
18
19
  /** HTML tab index */
19
20
  tabIndex?: number;
21
+ /** Вариант обрезания лейбла */
22
+ truncateVariant?: TruncateStringProps['variant'];
20
23
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Chips",
7
- "version": "0.25.7",
7
+ "version": "0.26.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -37,13 +37,14 @@
37
37
  "scripts": {},
38
38
  "dependencies": {
39
39
  "@snack-uikit/button": "0.19.8",
40
- "@snack-uikit/calendar": "0.11.26",
40
+ "@snack-uikit/calendar": "0.11.27",
41
41
  "@snack-uikit/divider": "3.2.4",
42
42
  "@snack-uikit/dropdown": "0.4.6",
43
43
  "@snack-uikit/icons": "0.25.1",
44
- "@snack-uikit/list": "0.26.3",
44
+ "@snack-uikit/list": "0.26.4",
45
45
  "@snack-uikit/loaders": "0.9.2",
46
46
  "@snack-uikit/tooltip": "0.16.5",
47
+ "@snack-uikit/truncate-string": "0.6.13",
47
48
  "@snack-uikit/utils": "3.8.0",
48
49
  "classnames": "2.5.1",
49
50
  "fuzzy-search": "3.2.1",
@@ -56,5 +57,5 @@
56
57
  "peerDependencies": {
57
58
  "@snack-uikit/locale": "*"
58
59
  },
59
- "gitHead": "83190fc4f4d6dac84d3801ac3fe18c73354e1029"
60
+ "gitHead": "245f761e18557fddf0d10e8277e6b2e2740a81a4"
60
61
  }
@@ -2,6 +2,7 @@ import cn from 'classnames';
2
2
  import { MouseEventHandler } from 'react';
3
3
 
4
4
  import { Sun, SunProps } from '@snack-uikit/loaders';
5
+ import { TruncateString } from '@snack-uikit/truncate-string';
5
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
7
 
7
8
  import { CHIP_ASSIST_TEST_IDS, SIZE, VARIANT } from '../../constants';
@@ -27,6 +28,7 @@ export function ChipAssist({
27
28
  onClick,
28
29
  className,
29
30
  tabIndex,
31
+ truncateVariant = 'middle',
30
32
  ...rest
31
33
  }: ChipAssistProps) {
32
34
  const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
@@ -65,7 +67,7 @@ export function ChipAssist({
65
67
  )}
66
68
 
67
69
  <span className={cn(styles.labelLayout, styles.label)} data-test-id={CHIP_ASSIST_TEST_IDS.label}>
68
- {label}
70
+ <TruncateString text={label} variant={truncateVariant} />
69
71
  </span>
70
72
  </button>
71
73
  );
@@ -14,6 +14,7 @@ $typography: (
14
14
  @include styles.chip-defaults;
15
15
  @include styles.chip-anatomy-styles(styles-tokens-chips-chipAssist.$chip-assist, $sizes, $typography);
16
16
 
17
+ justify-content: center;
17
18
  color: styles-tokens-chips-chipAssist.$sys-neutral-text-support;
18
19
  background-color: styles-tokens-chips-chipAssist.$sys-neutral-background1-level;
19
20
  border-color: styles-tokens-chips-chipAssist.$sys-neutral-decor-default;
@@ -3,6 +3,7 @@ import mergeRefs from 'merge-refs';
3
3
  import { forwardRef, KeyboardEvent, KeyboardEventHandler, MouseEventHandler, ReactNode, useRef, useState } from 'react';
4
4
 
5
5
  import { Sun, SunProps } from '@snack-uikit/loaders';
6
+ import { TruncateString } from '@snack-uikit/truncate-string';
6
7
  import { extractSupportProps } from '@snack-uikit/utils';
7
8
 
8
9
  import { CHIP_CHOICE_TEST_IDS, SIZE, VARIANT } from '../../../../constants';
@@ -13,7 +14,16 @@ import styles from './styles.module.scss';
13
14
 
14
15
  export type ChipChoiceBaseProps = Pick<
15
16
  ChipChoiceCommonProps,
16
- 'loading' | 'tabIndex' | 'onClearButtonClick' | 'disabled' | 'icon' | 'label' | 'size' | 'onClick' | 'className'
17
+ | 'loading'
18
+ | 'tabIndex'
19
+ | 'onClearButtonClick'
20
+ | 'disabled'
21
+ | 'icon'
22
+ | 'label'
23
+ | 'size'
24
+ | 'onClick'
25
+ | 'className'
26
+ | 'truncateVariant'
17
27
  > & {
18
28
  /** Отображаемое значение */
19
29
  valueToRender?: ReactNode;
@@ -38,6 +48,7 @@ export const ChipChoiceBase = forwardRef<HTMLDivElement, ChipChoiceBaseProps>(
38
48
  tabIndex = 0,
39
49
  onClearButtonClick,
40
50
  onKeyDown,
51
+ truncateVariant = 'middle',
41
52
  ...rest
42
53
  },
43
54
  ref,
@@ -124,7 +135,7 @@ export const ChipChoiceBase = forwardRef<HTMLDivElement, ChipChoiceBaseProps>(
124
135
  </span>
125
136
  ) : (
126
137
  <span className={styles.value} data-test-id={CHIP_CHOICE_TEST_IDS.value}>
127
- {valueToRender ?? value}
138
+ <TruncateString text={valueToRender ?? value} variant={truncateVariant} />
128
139
  </span>
129
140
  )}
130
141
  </span>
@@ -1,10 +1,17 @@
1
1
  @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-chips-chipChoice';
2
2
  @use '../../styles.module';
3
3
 
4
- .label,
4
+ .label {
5
+ display: inline-flex;
6
+ flex-grow: 1;
7
+ align-items: center;
8
+ white-space: nowrap;
9
+ }
10
+
5
11
  .value {
6
12
  display: inline-flex;
7
13
  align-items: center;
14
+ min-width: 0;
8
15
  }
9
16
 
10
17
  .choiceChip {
@@ -12,6 +12,7 @@ import {
12
12
  SelectionMultipleState,
13
13
  SelectionSingleState,
14
14
  } from '@snack-uikit/list';
15
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
15
16
  import { WithSupportProps } from '@snack-uikit/utils';
16
17
 
17
18
  import { BaseChipProps, Size } from '../../types';
@@ -96,6 +97,8 @@ export type ChipChoiceCommonProps = WithSupportProps<
96
97
  open?: boolean;
97
98
  /** Колбек отображения компонента. Срабатывает при изменении состояния open. */
98
99
  onOpenChange?: (isOpen: boolean) => void;
100
+ /** Вариант обрезания значения */
101
+ truncateVariant?: TruncateStringProps['variant'];
99
102
  }
100
103
  >;
101
104
 
@@ -48,7 +48,7 @@ export type ChipChoiceRowProps<TState extends FiltersState> = WithSupportProps<{
48
48
  export function ChipChoiceRow<TState extends FiltersState>({
49
49
  filters,
50
50
  onChange,
51
- showClearButton = true,
51
+ showClearButton: showClearButtonProp = true,
52
52
  showAddButton = true,
53
53
  className,
54
54
  value,
@@ -203,6 +203,9 @@ export function ChipChoiceRow<TState extends FiltersState>({
203
203
  addListPrevValue.current = addListValue;
204
204
  }, [addListValue, handleChipOpen]);
205
205
 
206
+ const showClearButton = showClearButtonProp && hasAnyFilter;
207
+ const showPinnedFiltersDivider = showAddButton || showClearButton || visibleFilters.length > 0;
208
+
206
209
  return (
207
210
  <div className={cn(styles.chipChoiceRow, className)} {...extractSupportProps(rest)}>
208
211
  {pinnedFilters.length > 0 && (
@@ -218,7 +221,7 @@ export function ChipChoiceRow<TState extends FiltersState>({
218
221
  />
219
222
  ))}
220
223
 
221
- <Divider orientation='vertical' className={styles.divider} />
224
+ {showPinnedFiltersDivider && <Divider orientation='vertical' className={styles.divider} />}
222
225
  </div>
223
226
  )}
224
227
 
@@ -262,7 +265,7 @@ export function ChipChoiceRow<TState extends FiltersState>({
262
265
  </Tooltip>
263
266
  )}
264
267
 
265
- {showClearButton && hasAnyFilter && (
268
+ {showClearButton && (
266
269
  <ButtonFunction
267
270
  onClick={handleFiltersClear}
268
271
  label={t('clear')}
@@ -12,6 +12,7 @@
12
12
 
13
13
  display: flex;
14
14
  flex-wrap: wrap;
15
+ min-width: 0;
15
16
  }
16
17
 
17
18
  .controlWrapper {
@@ -2,6 +2,7 @@ import cn from 'classnames';
2
2
  import { ChangeEvent, ChangeEventHandler } from 'react';
3
3
 
4
4
  import { Sun, SunProps } from '@snack-uikit/loaders';
5
+ import { TruncateString } from '@snack-uikit/truncate-string';
5
6
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
7
 
7
8
  import { CHIP_TOGGLE_TEST_IDS, SIZE, VARIANT } from '../../constants';
@@ -30,6 +31,7 @@ export function ChipToggle({
30
31
  onChange,
31
32
  className,
32
33
  tabIndex = 0,
34
+ truncateVariant = 'middle',
33
35
  ...rest
34
36
  }: ChipToggleProps) {
35
37
  const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
@@ -77,7 +79,7 @@ export function ChipToggle({
77
79
  )}
78
80
 
79
81
  <span className={cn(styles.labelLayout, styles.label)} data-test-id={CHIP_TOGGLE_TEST_IDS.label}>
80
- {label}
82
+ <TruncateString text={label} variant={truncateVariant} />
81
83
  </span>
82
84
  </span>
83
85
  </label>
@@ -13,6 +13,7 @@ $typography: (
13
13
  .toggleChipContent {
14
14
  @include styles.chip-defaults;
15
15
 
16
+ justify-content: center;
16
17
  color: styles-tokens-chips-chipToggle.$sys-neutral-text-support;
17
18
  background-color: styles-tokens-chips-chipToggle.$sys-neutral-background1-level;
18
19
  border-color: styles-tokens-chips-chipToggle.$sys-neutral-decor-default;
@@ -44,6 +45,7 @@ $typography: (
44
45
 
45
46
  position: relative;
46
47
 
48
+ min-width: 0;
47
49
  margin: 0;
48
50
  padding: 0;
49
51
 
@@ -10,7 +10,8 @@
10
10
 
11
11
  box-sizing: border-box;
12
12
  width: max-content;
13
- min-width: max-content;
13
+ min-width: styles-tokens-element.$dimension-6m;
14
+ max-width: 100%;
14
15
  margin: 0;
15
16
  padding: 0;
16
17
 
@@ -32,6 +33,7 @@
32
33
  .labelLayout {
33
34
  display: inline-flex;
34
35
  align-items: center;
36
+ min-width: 0;
35
37
  }
36
38
 
37
39
  @each $size in $sizes {
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
2
 
3
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
3
4
  import { ValueOf } from '@snack-uikit/utils';
4
5
 
5
6
  import { BUTTON_SIZE, SIZE, VARIANT } from './constants';
@@ -23,4 +24,6 @@ export type BaseChipProps = {
23
24
  className?: string;
24
25
  /** HTML tab index */
25
26
  tabIndex?: number;
27
+ /** Вариант обрезания лейбла */
28
+ truncateVariant?: TruncateStringProps['variant'];
26
29
  };