@snack-uikit/tree 0.8.27 → 0.8.28-preview-dc056d73.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/cjs/contexts/TreeContext.js +3 -0
- package/dist/cjs/helperComponents/TreeNode/TreeNode.d.ts +2 -0
- package/dist/cjs/helperComponents/TreeNode/TreeNode.js +5 -3
- package/dist/cjs/types.d.ts +4 -1
- package/dist/esm/contexts/TreeContext.js +3 -0
- package/dist/esm/helperComponents/TreeNode/TreeNode.d.ts +2 -0
- package/dist/esm/helperComponents/TreeNode/TreeNode.js +3 -2
- package/dist/esm/types.d.ts +4 -1
- package/package.json +2 -2
- package/src/contexts/TreeContext.tsx +3 -0
- package/src/helperComponents/TreeNode/TreeNode.tsx +5 -1
- package/src/types.ts +5 -1
|
@@ -7,5 +7,7 @@ type TreeNodeComponentProps = TreeNodeProps & {
|
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
parentNode?: ParentNode;
|
|
9
9
|
tabIndexAvailable?: boolean;
|
|
10
|
+
/** Скрываем элемент выбора */
|
|
11
|
+
hideSelection?: boolean;
|
|
10
12
|
};
|
|
11
13
|
export declare const TreeNode: import("react").ForwardRefExoticComponent<TreeNodeComponentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -54,9 +54,10 @@ exports.TreeNode = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
54
54
|
onKeyDown,
|
|
55
55
|
isLoading,
|
|
56
56
|
parentNode,
|
|
57
|
-
tabIndexAvailable
|
|
57
|
+
tabIndexAvailable,
|
|
58
|
+
hideSelection
|
|
58
59
|
} = _a,
|
|
59
|
-
rest = __rest(_a, ["id", "title", "icon", "expandedIcon", "collapsedIcon", "disabled", "onClick", "nested", "className", "onChevronClick", "onKeyDown", "isLoading", "parentNode", "tabIndexAvailable"]);
|
|
60
|
+
rest = __rest(_a, ["id", "title", "icon", "expandedIcon", "collapsedIcon", "disabled", "onClick", "nested", "className", "onChevronClick", "onKeyDown", "isLoading", "parentNode", "tabIndexAvailable", "hideSelection"]);
|
|
60
61
|
const {
|
|
61
62
|
isMultiSelect,
|
|
62
63
|
isSelectable,
|
|
@@ -105,6 +106,7 @@ exports.TreeNode = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
105
106
|
disabled,
|
|
106
107
|
nested,
|
|
107
108
|
onClick
|
|
109
|
+
// hideSelection // Упадет если раскомментить
|
|
108
110
|
}, e);
|
|
109
111
|
};
|
|
110
112
|
const handleSelect = () => {
|
|
@@ -235,7 +237,7 @@ exports.TreeNode = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
235
237
|
className: styles_module_scss_1.default.treeNodeContent,
|
|
236
238
|
"data-test-id": constants_1.TEST_IDS.item,
|
|
237
239
|
ref: contentRef,
|
|
238
|
-
children: [(isMultiSelect || showToggle) && (0, jsx_runtime_1.jsxs)("div", {
|
|
240
|
+
children: [(isMultiSelect || showToggle) && !hideSelection && (0, jsx_runtime_1.jsxs)("div", {
|
|
239
241
|
className: styles_module_scss_1.default.treeNodeCheckboxWrap,
|
|
240
242
|
children: [isMultiSelect && (0, jsx_runtime_1.jsx)(toggles_1.Checkbox, {
|
|
241
243
|
size: 's',
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type ChildTreeNode = BaseTreeNode & {
|
|
|
21
21
|
nested?: never;
|
|
22
22
|
expandedIcon?: never;
|
|
23
23
|
collapsedIcon?: never;
|
|
24
|
+
hideSelection?: never;
|
|
24
25
|
};
|
|
25
26
|
export type ParentTreeNode = BaseTreeNode & {
|
|
26
27
|
icon?: never;
|
|
@@ -30,10 +31,12 @@ export type ParentTreeNode = BaseTreeNode & {
|
|
|
30
31
|
collapsedIcon?: ReactNode;
|
|
31
32
|
/** Вложенные элементы дерева */
|
|
32
33
|
nested: (ChildTreeNode | ParentTreeNode)[];
|
|
34
|
+
/** Скрываем элемент выбора */
|
|
35
|
+
hideSelection?: boolean;
|
|
33
36
|
title: string | ((value: Pick<ParentTreeNode, 'id' | 'disabled' | 'nested'>) => ReactNode);
|
|
34
37
|
};
|
|
35
38
|
export type TreeNodeProps = ChildTreeNode | ParentTreeNode;
|
|
36
|
-
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested'> & {
|
|
39
|
+
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested' | 'hideSelection'> & {
|
|
37
40
|
parentNode?: ParentNode;
|
|
38
41
|
};
|
|
39
42
|
export type OnNodeClick = (node: TreeNodeProps, e: MouseEvent) => void;
|
|
@@ -7,5 +7,7 @@ type TreeNodeComponentProps = TreeNodeProps & {
|
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
parentNode?: ParentNode;
|
|
9
9
|
tabIndexAvailable?: boolean;
|
|
10
|
+
/** Скрываем элемент выбора */
|
|
11
|
+
hideSelection?: boolean;
|
|
10
12
|
};
|
|
11
13
|
export declare const TreeNode: import("react").ForwardRefExoticComponent<TreeNodeComponentProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -26,7 +26,7 @@ import { TreeNodeActions } from './components';
|
|
|
26
26
|
import styles from './styles.module.css';
|
|
27
27
|
import { stopPropagationClick } from './utils';
|
|
28
28
|
export const TreeNode = forwardRef((_a, ref) => {
|
|
29
|
-
var { id, title, icon = _jsx(FileSVG, { size: 24 }), expandedIcon = _jsx(FolderOpenSVG, { size: 24 }), collapsedIcon = _jsx(FolderSVG, { size: 24 }), disabled, onClick, nested, className, onChevronClick, onKeyDown, isLoading, parentNode, tabIndexAvailable } = _a, rest = __rest(_a, ["id", "title", "icon", "expandedIcon", "collapsedIcon", "disabled", "onClick", "nested", "className", "onChevronClick", "onKeyDown", "isLoading", "parentNode", "tabIndexAvailable"]);
|
|
29
|
+
var { id, title, icon = _jsx(FileSVG, { size: 24 }), expandedIcon = _jsx(FolderOpenSVG, { size: 24 }), collapsedIcon = _jsx(FolderSVG, { size: 24 }), disabled, onClick, nested, className, onChevronClick, onKeyDown, isLoading, parentNode, tabIndexAvailable, hideSelection } = _a, rest = __rest(_a, ["id", "title", "icon", "expandedIcon", "collapsedIcon", "disabled", "onClick", "nested", "className", "onChevronClick", "onKeyDown", "isLoading", "parentNode", "tabIndexAvailable", "hideSelection"]);
|
|
30
30
|
const { isMultiSelect, isSelectable, onNodeClick, selected, expandedNodes, onSelect, nodeActions, parentActions, setFocusPosition, resetFocusPosition, focusedNodeId, setFocusIndex, focusableNodeIds, showToggle, showLines, showIcons, } = useTreeContext();
|
|
31
31
|
const [isDroplistOpen, setDroplistOpen] = useState(false);
|
|
32
32
|
const [isDroplistTriggerFocused, setFocusDroplistTrigger] = useState(false);
|
|
@@ -60,6 +60,7 @@ export const TreeNode = forwardRef((_a, ref) => {
|
|
|
60
60
|
disabled,
|
|
61
61
|
nested,
|
|
62
62
|
onClick,
|
|
63
|
+
// hideSelection // Упадет если раскомментить
|
|
63
64
|
}, e);
|
|
64
65
|
};
|
|
65
66
|
const handleSelect = () => {
|
|
@@ -141,7 +142,7 @@ export const TreeNode = forwardRef((_a, ref) => {
|
|
|
141
142
|
const getNodeActions = nested ? parentActions : nodeActions;
|
|
142
143
|
return (_jsxs("div", Object.assign({ role: 'presentation', className: cn(styles.treeNode, className) }, extractSupportProps(rest), { "data-node-id": id, ref: ref, children: [parentNode && (_jsx(TreeLine, { halfWidth: Boolean(nested), horizontal: true, visible: showLines, "data-test-id": TEST_IDS.line })), !parentNode && !nested && _jsx(TreeLine, { visible: false }), isExpandable && (_jsxs("div", { className: styles.treeNodeExpandButtonWrapper, children: [_jsx(ButtonFunction, { size: 'xs', icon: _jsx(ChevronRightSVG, {}), loading: isLoading, onClick: onChevronClick, "data-expanded": isExpanded || undefined, className: styles.treeNodeExpandButton, tabIndex: -1, "data-test-id": TEST_IDS.chevron }), _jsx(TreeLine, { visible: isExpanded && showLines, height: '100%' })] })), _jsxs("div", { role: 'treeitem', "aria-expanded": isExpanded, "aria-selected": isSelectable
|
|
143
144
|
? isSelected || ((nestedNodesSelection === null || nestedNodesSelection === void 0 ? void 0 : nestedNodesSelection.someSelected) && !isExpanded && !isMultiSelect)
|
|
144
|
-
: undefined, "aria-disabled": disabled, "data-multiselect": isMultiSelect || undefined, "data-droplist-active": isDroplistOpen || isDroplistTriggerFocused || undefined, onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: resetFocusPosition, tabIndex: tabIndexAvailable ? 0 : -1, className: styles.treeNodeContent, "data-test-id": TEST_IDS.item, ref: contentRef, children: [(isMultiSelect || showToggle) && (_jsxs("div", { className: styles.treeNodeCheckboxWrap, children: [isMultiSelect && (_jsx(Checkbox, { size: 's', disabled: disabled, checked: isSelected, indeterminate: !isSelected && (nestedNodesSelection === null || nestedNodesSelection === void 0 ? void 0 : nestedNodesSelection.someSelected), onChange: handleSelect, onClick: stopPropagationClick, "data-test-id": TEST_IDS.checkbox, tabIndex: -1 })), showToggle && (_jsx(Radio, { size: 's', checked: isSelected, disabled: disabled, "data-test-id": TEST_IDS.radio, tabIndex: -1 }))] })), treeNodeIcon && (_jsx("div", { className: styles.treeNodeIcon, "data-test-id": TEST_IDS.icon, children: treeNodeIcon })), _jsxs(Typography.SansBodyM, { tag: 'div', className: styles.treeNodeTitle, children: [typeof title === 'string' && _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }), typeof title !== 'string' && title({ id, disabled, nested })] }), getNodeActions && (_jsx(TreeNodeActions, { getNodeActions: getNodeActions, node: {
|
|
145
|
+
: undefined, "aria-disabled": disabled, "data-multiselect": isMultiSelect || undefined, "data-droplist-active": isDroplistOpen || isDroplistTriggerFocused || undefined, onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: resetFocusPosition, tabIndex: tabIndexAvailable ? 0 : -1, className: styles.treeNodeContent, "data-test-id": TEST_IDS.item, ref: contentRef, children: [(isMultiSelect || showToggle) && !hideSelection && (_jsxs("div", { className: styles.treeNodeCheckboxWrap, children: [isMultiSelect && (_jsx(Checkbox, { size: 's', disabled: disabled, checked: isSelected, indeterminate: !isSelected && (nestedNodesSelection === null || nestedNodesSelection === void 0 ? void 0 : nestedNodesSelection.someSelected), onChange: handleSelect, onClick: stopPropagationClick, "data-test-id": TEST_IDS.checkbox, tabIndex: -1 })), showToggle && (_jsx(Radio, { size: 's', checked: isSelected, disabled: disabled, "data-test-id": TEST_IDS.radio, tabIndex: -1 }))] })), treeNodeIcon && (_jsx("div", { className: styles.treeNodeIcon, "data-test-id": TEST_IDS.icon, children: treeNodeIcon })), _jsxs(Typography.SansBodyM, { tag: 'div', className: styles.treeNodeTitle, children: [typeof title === 'string' && _jsx(TruncateString, { text: title, "data-test-id": TEST_IDS.title }), typeof title !== 'string' && title({ id, disabled, nested })] }), getNodeActions && (_jsx(TreeNodeActions, { getNodeActions: getNodeActions, node: {
|
|
145
146
|
id,
|
|
146
147
|
title,
|
|
147
148
|
disabled,
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type ChildTreeNode = BaseTreeNode & {
|
|
|
21
21
|
nested?: never;
|
|
22
22
|
expandedIcon?: never;
|
|
23
23
|
collapsedIcon?: never;
|
|
24
|
+
hideSelection?: never;
|
|
24
25
|
};
|
|
25
26
|
export type ParentTreeNode = BaseTreeNode & {
|
|
26
27
|
icon?: never;
|
|
@@ -30,10 +31,12 @@ export type ParentTreeNode = BaseTreeNode & {
|
|
|
30
31
|
collapsedIcon?: ReactNode;
|
|
31
32
|
/** Вложенные элементы дерева */
|
|
32
33
|
nested: (ChildTreeNode | ParentTreeNode)[];
|
|
34
|
+
/** Скрываем элемент выбора */
|
|
35
|
+
hideSelection?: boolean;
|
|
33
36
|
title: string | ((value: Pick<ParentTreeNode, 'id' | 'disabled' | 'nested'>) => ReactNode);
|
|
34
37
|
};
|
|
35
38
|
export type TreeNodeProps = ChildTreeNode | ParentTreeNode;
|
|
36
|
-
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested'> & {
|
|
39
|
+
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested' | 'hideSelection'> & {
|
|
37
40
|
parentNode?: ParentNode;
|
|
38
41
|
};
|
|
39
42
|
export type OnNodeClick = (node: TreeNodeProps, e: MouseEvent) => void;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Tree",
|
|
7
|
-
"version": "0.8.
|
|
7
|
+
"version": "0.8.28-preview-dc056d73.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react-transition-state": "2.1.1",
|
|
48
48
|
"uncontrollable": "8.0.4"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a123f7420a510cc0e41acd975a0abcaed546598b"
|
|
51
51
|
}
|
|
@@ -34,6 +34,8 @@ type TreeNodeComponentProps = TreeNodeProps & {
|
|
|
34
34
|
isLoading?: boolean;
|
|
35
35
|
parentNode?: ParentNode;
|
|
36
36
|
tabIndexAvailable?: boolean;
|
|
37
|
+
/** Скрываем элемент выбора */
|
|
38
|
+
hideSelection?: boolean;
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
export const TreeNode = forwardRef<HTMLDivElement, TreeNodeComponentProps>(
|
|
@@ -53,6 +55,7 @@ export const TreeNode = forwardRef<HTMLDivElement, TreeNodeComponentProps>(
|
|
|
53
55
|
isLoading,
|
|
54
56
|
parentNode,
|
|
55
57
|
tabIndexAvailable,
|
|
58
|
+
hideSelection,
|
|
56
59
|
...rest
|
|
57
60
|
},
|
|
58
61
|
ref,
|
|
@@ -119,6 +122,7 @@ export const TreeNode = forwardRef<HTMLDivElement, TreeNodeComponentProps>(
|
|
|
119
122
|
disabled,
|
|
120
123
|
nested,
|
|
121
124
|
onClick,
|
|
125
|
+
// hideSelection // Упадет если раскомментить
|
|
122
126
|
},
|
|
123
127
|
e,
|
|
124
128
|
);
|
|
@@ -269,7 +273,7 @@ export const TreeNode = forwardRef<HTMLDivElement, TreeNodeComponentProps>(
|
|
|
269
273
|
data-test-id={TEST_IDS.item}
|
|
270
274
|
ref={contentRef}
|
|
271
275
|
>
|
|
272
|
-
{(isMultiSelect || showToggle) && (
|
|
276
|
+
{(isMultiSelect || showToggle) && !hideSelection && (
|
|
273
277
|
<div className={styles.treeNodeCheckboxWrap}>
|
|
274
278
|
{isMultiSelect && (
|
|
275
279
|
<Checkbox
|
package/src/types.ts
CHANGED
|
@@ -27,6 +27,7 @@ export type ChildTreeNode = BaseTreeNode & {
|
|
|
27
27
|
nested?: never;
|
|
28
28
|
expandedIcon?: never;
|
|
29
29
|
collapsedIcon?: never;
|
|
30
|
+
hideSelection?: never;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export type ParentTreeNode = BaseTreeNode & {
|
|
@@ -38,12 +39,15 @@ export type ParentTreeNode = BaseTreeNode & {
|
|
|
38
39
|
/** Вложенные элементы дерева */
|
|
39
40
|
nested: (ChildTreeNode | ParentTreeNode)[];
|
|
40
41
|
|
|
42
|
+
/** Скрываем элемент выбора */
|
|
43
|
+
hideSelection?: boolean;
|
|
44
|
+
|
|
41
45
|
title: string | ((value: Pick<ParentTreeNode, 'id' | 'disabled' | 'nested'>) => ReactNode);
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
export type TreeNodeProps = ChildTreeNode | ParentTreeNode;
|
|
45
49
|
|
|
46
|
-
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested'> & { parentNode?: ParentNode };
|
|
50
|
+
export type ParentNode = Pick<TreeNodeProps, 'id' | 'nested' | 'hideSelection'> & { parentNode?: ParentNode };
|
|
47
51
|
|
|
48
52
|
export type OnNodeClick = (node: TreeNodeProps, e: MouseEvent) => void;
|
|
49
53
|
|