@snack-uikit/list 0.8.1 → 0.8.2-preview-1fcf96b1.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/dist/components/Items/BaseItem/BaseItem.js +1 -1
- package/dist/components/Items/GroupItem/GroupItem.d.ts +1 -1
- package/dist/components/Items/GroupItem/GroupItem.js +2 -2
- package/dist/components/Items/types.d.ts +2 -0
- package/dist/helperComponents/Separator/Separator.d.ts +5 -1
- package/dist/helperComponents/Separator/Separator.js +2 -2
- package/package.json +3 -3
- package/src/components/Items/BaseItem/BaseItem.tsx +1 -0
- package/src/components/Items/GroupItem/GroupItem.tsx +2 -2
- package/src/components/Items/types.ts +2 -0
- package/src/helperComponents/Separator/Separator.tsx +6 -3
|
@@ -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;
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Divider } from '@snack-uikit/divider';
|
|
3
3
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
4
4
|
import styles from './styles.module.css';
|
|
5
|
-
export function Separator({ label, divider, mode = 'secondary', size = 's' }) {
|
|
5
|
+
export function Separator({ label, truncate, divider, mode = 'secondary', size = 's' }) {
|
|
6
6
|
if (label) {
|
|
7
|
-
return (_jsxs("div", { className: styles.separatorWithLabel, "data-size": size, children: [_jsx("span", { className: styles.label, "data-mode": mode, children: _jsx(TruncateString, { text: label, maxLines: 1 }) }), divider && _jsx(Divider, { weight: mode === 'primary' ? 'regular' : 'light', className: styles.divider })] }));
|
|
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 })] }));
|
|
8
8
|
}
|
|
9
9
|
if (divider) {
|
|
10
10
|
return (_jsx("div", { className: styles.separatorWithoutLabel, "data-size": size, children: _jsx(Divider, { weight: 'regular' }) }));
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "List",
|
|
7
|
-
"version": "0.8.
|
|
7
|
+
"version": "0.8.2-preview-1fcf96b1.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@snack-uikit/scroll": "0.5.2",
|
|
42
42
|
"@snack-uikit/search-private": "0.1.5",
|
|
43
43
|
"@snack-uikit/toggles": "0.9.7",
|
|
44
|
-
"@snack-uikit/truncate-string": "0.4.
|
|
44
|
+
"@snack-uikit/truncate-string": "0.4.11-preview-1fcf96b1.0",
|
|
45
45
|
"@snack-uikit/utils": "3.2.0",
|
|
46
46
|
"classnames": "2.5.1",
|
|
47
47
|
"fuzzy-search": "3.2.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@snack-uikit/locale": "*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "6258f32293b256d090f415fbbecd88ac9b037fc8"
|
|
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,21 +1,24 @@
|
|
|
1
1
|
import { Divider } from '@snack-uikit/divider';
|
|
2
|
-
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
2
|
+
import { TruncateString, TruncateStringProps } from '@snack-uikit/truncate-string';
|
|
3
3
|
|
|
4
4
|
import styles from './styles.module.scss';
|
|
5
5
|
|
|
6
6
|
export type SeparatorProps = {
|
|
7
7
|
label?: string;
|
|
8
|
+
truncate?: {
|
|
9
|
+
variant?: TruncateStringProps['variant'];
|
|
10
|
+
};
|
|
8
11
|
mode?: 'primary' | 'secondary';
|
|
9
12
|
divider?: boolean;
|
|
10
13
|
size?: 's' | 'm' | 'l';
|
|
11
14
|
};
|
|
12
15
|
|
|
13
|
-
export function Separator({ label, divider, mode = 'secondary', size = 's' }: SeparatorProps) {
|
|
16
|
+
export function Separator({ label, truncate, divider, mode = 'secondary', size = 's' }: SeparatorProps) {
|
|
14
17
|
if (label) {
|
|
15
18
|
return (
|
|
16
19
|
<div className={styles.separatorWithLabel} data-size={size}>
|
|
17
20
|
<span className={styles.label} data-mode={mode}>
|
|
18
|
-
<TruncateString text={label} maxLines={1} />
|
|
21
|
+
<TruncateString variant={truncate?.variant} text={label} maxLines={1} />
|
|
19
22
|
</span>
|
|
20
23
|
|
|
21
24
|
{divider && <Divider weight={mode === 'primary' ? 'regular' : 'light'} className={styles.divider} />}
|