@snack-uikit/list 0.8.0 → 0.8.2-preview-e6b01723.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.8.1 (2024-03-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-4559:** truncate long group label ([4862a19](https://github.com/cloud-ru-tech/snack-uikit/commit/4862a192452c6e3b735ec0da0218e0af028dc127))
12
+
13
+
14
+
15
+
16
+
6
17
  # 0.8.0 (2024-03-11)
7
18
 
8
19
 
@@ -71,7 +71,7 @@ export function BaseItem(_a) {
71
71
  e.stopPropagation();
72
72
  };
73
73
  const props = extractSupportProps(rest);
74
- const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, onMouseDown: onMouseDown, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "data-disabled": disabled || undefined, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: (_b = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.option) !== null && _b !== void 0 ? _b : 1, "data-test-id": 'list__base-item-option' }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: (_c = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.description) !== null && _c !== void 0 ? _c : 2, "data-test-id": 'list__base-item-description' }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
74
+ const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, onMouseDown: onMouseDown, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "data-disabled": disabled || undefined, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { variant: contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.variant, text: option, maxLines: (_b = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.option) !== null && _b !== void 0 ? _b : 1, "data-test-id": 'list__base-item-option' }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: (_c = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.description) !== null && _c !== void 0 ? _c : 2, "data-test-id": 'list__base-item-description' }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
75
75
  if (!itemWrapRender) {
76
76
  return item;
77
77
  }
@@ -1,2 +1,2 @@
1
1
  import { GroupItemProps } from '../types';
2
- export declare function GroupItem({ label, divider, items, mode }: GroupItemProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function GroupItem({ label, truncate, divider, items, mode }: GroupItemProps): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { Separator } from '../../../helperComponents';
3
3
  import { useListContext } from '../../Lists/contexts';
4
4
  import { useRenderItems } from '../hooks';
5
- export function GroupItem({ label, divider, items, mode }) {
5
+ export function GroupItem({ label, truncate, divider, items, mode }) {
6
6
  const { size } = useListContext();
7
7
  const itemsJSX = useRenderItems(items);
8
- return (_jsxs(_Fragment, { children: [_jsx(Separator, { label: label, divider: divider, mode: mode, size: size }), itemsJSX] }));
8
+ return (_jsxs(_Fragment, { children: [_jsx(Separator, { label: label, truncate: truncate, divider: divider, mode: mode, size: size }), itemsJSX] }));
9
9
  }
@@ -1,4 +1,5 @@
1
1
  import { FocusEvent, KeyboardEvent, MouseEvent, ReactNode, RefObject } from 'react';
2
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
2
3
  import { WithSupportProps } from '@snack-uikit/utils';
3
4
  import { SeparatorProps } from '../../helperComponents';
4
5
  import { ScrollProps, SearchState } from '../../types';
@@ -9,6 +10,7 @@ export type ItemContentProps = {
9
10
  truncate?: {
10
11
  option?: number;
11
12
  description?: number;
13
+ variant?: TruncateStringProps['variant'];
12
14
  };
13
15
  };
14
16
  export type BaseItemPrivateProps = {
@@ -1,7 +1,11 @@
1
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
1
2
  export type SeparatorProps = {
2
3
  label?: string;
4
+ truncate?: {
5
+ variant?: TruncateStringProps['variant'];
6
+ };
3
7
  mode?: 'primary' | 'secondary';
4
8
  divider?: boolean;
5
9
  size?: 's' | 'm' | 'l';
6
10
  };
7
- export declare function Separator({ label, divider, mode, size }: SeparatorProps): import("react/jsx-runtime").JSX.Element | null;
11
+ export declare function Separator({ label, truncate, divider, mode, size }: SeparatorProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Divider } from '@snack-uikit/divider';
3
+ import { TruncateString } from '@snack-uikit/truncate-string';
3
4
  import styles from './styles.module.css';
4
- export function Separator({ label, divider, mode = 'secondary', size = 's' }) {
5
+ export function Separator({ label, truncate, divider, mode = 'secondary', size = 's' }) {
5
6
  if (label) {
6
- return (_jsxs("div", { className: styles.separatorWithLabel, "data-size": size, children: [_jsx("span", { className: styles.label, "data-mode": mode, children: label }), divider && _jsx(Divider, { weight: mode === 'primary' ? 'regular' : 'light' })] }));
7
+ return (_jsxs("div", { className: styles.separatorWithLabel, "data-size": size, children: [_jsx("span", { className: styles.label, "data-mode": mode, children: _jsx(TruncateString, { variant: truncate === null || truncate === void 0 ? void 0 : truncate.variant, text: label, maxLines: 1 }) }), divider && _jsx(Divider, { weight: mode === 'primary' ? 'regular' : 'light', className: styles.divider })] }));
7
8
  }
8
9
  if (divider) {
9
10
  return (_jsx("div", { className: styles.separatorWithoutLabel, "data-size": size, children: _jsx(Divider, { weight: 'regular' }) }));
@@ -1,8 +1,11 @@
1
1
  .separatorWithLabel{
2
+ overflow:hidden;
2
3
  display:flex;
3
4
  gap:var(--dimension-1m, 8px);
4
5
  align-items:flex-end;
5
6
  box-sizing:border-box;
7
+ width:100%;
8
+ min-width:100%;
6
9
  }
7
10
  .separatorWithLabel[data-size=s]{
8
11
  padding-top:var(--space-drop-list-item-s-container-separator-subheader-vertical-padding, 4px);
@@ -102,11 +105,18 @@
102
105
  }
103
106
 
104
107
  .label{
105
- flex-shrink:0;
108
+ overflow:hidden;
109
+ flex-shrink:1;
106
110
  }
107
111
  .label[data-mode=primary]{
108
112
  color:var(--sys-neutral-text-main, #33333b);
109
113
  }
110
114
  .label[data-mode=secondary]{
111
115
  color:var(--sys-neutral-text-light, #868892);
116
+ }
117
+
118
+ hr.divider{
119
+ flex:1;
120
+ width:auto;
121
+ min-width:0;
112
122
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "List",
7
- "version": "0.8.0",
7
+ "version": "0.8.2-preview-e6b01723.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -54,5 +54,5 @@
54
54
  "peerDependencies": {
55
55
  "@snack-uikit/locale": "*"
56
56
  },
57
- "gitHead": "113e80e60c1a5ce1ce6957d48d37a6181991c5fd"
57
+ "gitHead": "360fe71de7d4d4736015b31a02622d80c961d363"
58
58
  }
@@ -146,6 +146,7 @@ export function BaseItem({
146
146
  <div className={styles.headline}>
147
147
  <span className={styles.option}>
148
148
  <TruncateString
149
+ variant={contentTruncate?.variant}
149
150
  text={option}
150
151
  maxLines={contentTruncate?.option ?? 1}
151
152
  data-test-id='list__base-item-option'
@@ -3,14 +3,14 @@ import { useListContext } from '../../Lists/contexts';
3
3
  import { useRenderItems } from '../hooks';
4
4
  import { GroupItemProps } from '../types';
5
5
 
6
- export function GroupItem({ label, divider, items, mode }: GroupItemProps) {
6
+ export function GroupItem({ label, truncate, divider, items, mode }: GroupItemProps) {
7
7
  const { size } = useListContext();
8
8
 
9
9
  const itemsJSX = useRenderItems(items);
10
10
 
11
11
  return (
12
12
  <>
13
- <Separator label={label} divider={divider} mode={mode} size={size} />
13
+ <Separator label={label} truncate={truncate} divider={divider} mode={mode} size={size} />
14
14
  {itemsJSX}
15
15
  </>
16
16
  );
@@ -1,5 +1,6 @@
1
1
  import { FocusEvent, KeyboardEvent, MouseEvent, ReactNode, RefObject } from 'react';
2
2
 
3
+ import { TruncateStringProps } from '@snack-uikit/truncate-string';
3
4
  import { WithSupportProps } from '@snack-uikit/utils';
4
5
 
5
6
  import { SeparatorProps } from '../../helperComponents';
@@ -12,6 +13,7 @@ export type ItemContentProps = {
12
13
  truncate?: {
13
14
  option?: number;
14
15
  description?: number;
16
+ variant?: TruncateStringProps['variant'];
15
17
  };
16
18
  };
17
19
 
@@ -1,22 +1,27 @@
1
1
  import { Divider } from '@snack-uikit/divider';
2
+ import { TruncateString, TruncateStringProps } from '@snack-uikit/truncate-string';
2
3
 
3
4
  import styles from './styles.module.scss';
4
5
 
5
6
  export type SeparatorProps = {
6
7
  label?: string;
8
+ truncate?: {
9
+ variant?: TruncateStringProps['variant'];
10
+ };
7
11
  mode?: 'primary' | 'secondary';
8
12
  divider?: boolean;
9
13
  size?: 's' | 'm' | 'l';
10
14
  };
11
15
 
12
- export function Separator({ label, divider, mode = 'secondary', size = 's' }: SeparatorProps) {
16
+ export function Separator({ label, truncate, divider, mode = 'secondary', size = 's' }: SeparatorProps) {
13
17
  if (label) {
14
18
  return (
15
19
  <div className={styles.separatorWithLabel} data-size={size}>
16
20
  <span className={styles.label} data-mode={mode}>
17
- {label}
21
+ <TruncateString variant={truncate?.variant} text={label} maxLines={1} />
18
22
  </span>
19
- {divider && <Divider weight={mode === 'primary' ? 'regular' : 'light'} />}
23
+
24
+ {divider && <Divider weight={mode === 'primary' ? 'regular' : 'light'} className={styles.divider} />}
20
25
  </div>
21
26
  );
22
27
  }
@@ -16,10 +16,14 @@ $typography-secondary: (
16
16
  );
17
17
 
18
18
  .separatorWithLabel {
19
+ overflow: hidden;
19
20
  display: flex;
20
21
  gap: $dimension-1m;
21
22
  align-items: flex-end;
23
+
22
24
  box-sizing: border-box;
25
+ width: 100%;
26
+ min-width: 100%;
23
27
 
24
28
  @each $size in $sizes {
25
29
  &[data-size='#{$size}'] {
@@ -51,7 +55,8 @@ $typography-secondary: (
51
55
  }
52
56
 
53
57
  .label {
54
- flex-shrink: 0;
58
+ overflow: hidden;
59
+ flex-shrink: 1;
55
60
 
56
61
  &[data-mode='primary'] {
57
62
  color: $sys-neutral-text-main;
@@ -61,3 +66,9 @@ $typography-secondary: (
61
66
  color: $sys-neutral-text-light;
62
67
  }
63
68
  }
69
+
70
+ hr.divider {
71
+ flex: 1;
72
+ width: auto;
73
+ min-width: 0;
74
+ }