@devtron-labs/devtron-fe-common-lib 1.17.0-pre-3 → 1.17.0-pre-6
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/{@code-editor-DkUhYcbr.js → @code-editor-CIT4e7hG.js} +8697 -8278
- package/dist/@common-rjsf-D62eDBEJ.js +609 -0
- package/dist/Common/Hooks/UseIsTextTruncated/UseIsTextTruncated.d.ts +5 -0
- package/dist/Common/Hooks/UseIsTextTruncated/constants.d.ts +1 -0
- package/dist/Common/Hooks/UseIsTextTruncated/index.d.ts +1 -0
- package/dist/Common/Hooks/index.d.ts +1 -0
- package/dist/Common/RJSF/constants.d.ts +0 -1
- package/dist/Common/RJSF/utils.d.ts +1 -1
- package/dist/Common/Tooltip/constants.d.ts +0 -1
- package/dist/Pages/ResourceBrowser/ResourceBrowser.Types.d.ts +0 -1
- package/dist/Shared/Components/ActionMenu/types.d.ts +2 -33
- package/dist/Shared/Components/CollapsibleList/CollapsibleList.component.d.ts +3 -0
- package/dist/Shared/Components/Icon/Icon.d.ts +1 -0
- package/dist/Shared/Components/Security/SecurityModal/config/Sidebar.d.ts +6 -3
- package/dist/Shared/Components/Security/SecurityModal/config/index.d.ts +1 -1
- package/dist/Shared/Components/Security/SecurityModal/index.d.ts +2 -2
- package/dist/Shared/Components/Security/SecurityModal/types.d.ts +0 -6
- package/dist/Shared/Components/Security/types.d.ts +5 -1
- package/dist/Shared/Components/SelectPicker/type.d.ts +1 -1
- package/dist/Shared/Components/TrailingItem/TrailingItem.component.d.ts +3 -0
- package/dist/Shared/Components/TrailingItem/index.d.ts +2 -0
- package/dist/Shared/Components/TrailingItem/types.d.ts +39 -0
- package/dist/Shared/Components/TreeView/TreeView.component.d.ts +3 -0
- package/dist/Shared/Components/TreeView/TreeViewNodeContent.d.ts +3 -0
- package/dist/Shared/Components/TreeView/constants.d.ts +4 -0
- package/dist/Shared/Components/TreeView/index.d.ts +2 -0
- package/dist/Shared/Components/TreeView/types.d.ts +204 -0
- package/dist/Shared/Components/TreeView/utils.d.ts +22 -0
- package/dist/Shared/Components/index.d.ts +1 -0
- package/dist/assets/@code-editor.css +1 -1
- package/dist/assets/@common-rjsf.css +1 -1
- package/dist/assets/ic-helm-app.a20cfeb3.svg +4 -0
- package/dist/index.js +418 -414
- package/package.json +1 -1
- package/dist/@common-rjsf-CA1sJuar.js +0 -598
@@ -1,12 +1,8 @@
|
|
1
|
-
import { LegacyRef, MouseEvent,
|
1
|
+
import { LegacyRef, MouseEvent, Ref } from 'react';
|
2
2
|
import { LinkProps } from 'react-router-dom';
|
3
|
-
import { OmitNever } from '../../types';
|
4
|
-
import { ButtonProps } from '../Button';
|
5
|
-
import { IconsProps } from '../Icon';
|
6
|
-
import { NumbersCountProps } from '../NumbersCount';
|
7
3
|
import { PopoverProps, UsePopoverProps } from '../Popover';
|
8
4
|
import { SelectPickerOptionType, SelectPickerProps } from '../SelectPicker';
|
9
|
-
import {
|
5
|
+
import { ActionMenuItemIconType, TrailingItemType } from '../TrailingItem';
|
10
6
|
type ConditionalActionMenuComponentType = {
|
11
7
|
/**
|
12
8
|
* @default 'button'
|
@@ -25,33 +21,6 @@ type ConditionalActionMenuComponentType = {
|
|
25
21
|
to: LinkProps['to'];
|
26
22
|
href?: never;
|
27
23
|
};
|
28
|
-
type ActionMenuItemIconType = Pick<IconsProps, 'name'> & {
|
29
|
-
/** @default 'N800' */
|
30
|
-
color?: IconsProps['color'];
|
31
|
-
};
|
32
|
-
type TrailingItemType = {
|
33
|
-
type: 'icon';
|
34
|
-
config: ActionMenuItemIconType;
|
35
|
-
} | {
|
36
|
-
type: 'text';
|
37
|
-
config: {
|
38
|
-
value: string;
|
39
|
-
icon?: ActionMenuItemIconType;
|
40
|
-
};
|
41
|
-
} | {
|
42
|
-
type: 'counter';
|
43
|
-
config: {
|
44
|
-
value: NumbersCountProps['count'];
|
45
|
-
};
|
46
|
-
} | {
|
47
|
-
type: 'switch';
|
48
|
-
config: Pick<DTSwitchProps, 'ariaLabel' | 'isChecked' | 'indeterminate' | 'isDisabled' | 'isLoading' | 'name' | 'onChange' | 'tooltipContent'>;
|
49
|
-
} | {
|
50
|
-
type: 'button';
|
51
|
-
config: OmitNever<Omit<Extract<ButtonProps, {
|
52
|
-
icon: ReactElement;
|
53
|
-
}>, 'size' | 'variant'>>;
|
54
|
-
};
|
55
24
|
export type ActionMenuItemType<T extends string | number = string | number> = Omit<SelectPickerOptionType, 'label' | 'value' | 'endIcon' | 'startIcon'> & {
|
56
25
|
/** A unique identifier for the action menu item. */
|
57
26
|
id: T;
|
@@ -1,2 +1,5 @@
|
|
1
1
|
import { CollapsibleListProps, TabOptions } from './CollapsibleList.types';
|
2
|
+
/**
|
3
|
+
* @deprecated - Please use `TreeView` component instead.
|
4
|
+
*/
|
2
5
|
export declare const CollapsibleList: <TabType extends TabOptions>({ config, tabType, onCollapseBtnClick, }: CollapsibleListProps<TabType>) => JSX.Element;
|
@@ -111,6 +111,7 @@ export declare const iconMap: {
|
|
111
111
|
'ic-heart-green': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
112
112
|
'ic-heart-red-animated': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
113
113
|
'ic-heart-red': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
114
|
+
'ic-helm-app': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
114
115
|
'ic-helm': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
115
116
|
'ic-help-filled': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
116
117
|
'ic-help-outline': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
@@ -1,3 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
|
1
|
+
import { TreeViewProps } from '../../../TreeView';
|
2
|
+
import { GetSidebarDataParamsType } from '../../types';
|
3
|
+
import { SidebarDataChildType } from '../types';
|
4
|
+
export declare const getSecurityModalSidebarId: ({ category, subCategory }: SidebarDataChildType["value"]) => string;
|
5
|
+
export declare const getSecurityModalSidebarChildFromId: (id: string) => SidebarDataChildType["value"];
|
6
|
+
export declare const getSidebarData: ({ imageScan, codeScan, kubernetesManifest, imageScanLicenseRisks, selectedId, scanResult, }: GetSidebarDataParamsType) => TreeViewProps["nodes"];
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { getProgressingStateForStatus } from './ImageScan';
|
2
2
|
export { getInfoCardData } from './InfoCard';
|
3
|
-
export { getSidebarData } from './Sidebar';
|
3
|
+
export { getSecurityModalSidebarChildFromId, getSecurityModalSidebarId, getSidebarData } from './Sidebar';
|
4
4
|
export { getTableData } from './Table';
|
@@ -1,7 +1,7 @@
|
|
1
|
-
export { getProgressingStateForStatus, getSidebarData } from './config';
|
1
|
+
export { getProgressingStateForStatus, getSecurityModalSidebarChildFromId, getSecurityModalSidebarId, getSidebarData, } from './config';
|
2
2
|
export { CATEGORY_LABELS } from './constants';
|
3
3
|
export { default as SecurityModal } from './SecurityModal';
|
4
4
|
export { getSecurityScan } from './service';
|
5
|
-
export type { GetResourceScanDetailsPayloadType, GetResourceScanDetailsResponseType, ScanResultDTO, SidebarDataChildType,
|
5
|
+
export type { GetResourceScanDetailsPayloadType, GetResourceScanDetailsResponseType, ScanResultDTO, SidebarDataChildType, SidebarPropsType, } from './types';
|
6
6
|
export { SeveritiesDTO } from './types';
|
7
7
|
export { getSecurityScanSeveritiesCount, getTotalVulnerabilityCount, parseGetResourceScanDetailsResponse, } from './utils';
|
@@ -224,12 +224,6 @@ export type SidebarDataChildType = {
|
|
224
224
|
subCategory: ScanSubCategories;
|
225
225
|
};
|
226
226
|
};
|
227
|
-
export type SidebarDataType = {
|
228
|
-
label: string;
|
229
|
-
isExpanded: boolean;
|
230
|
-
children: NonNullable<SidebarDataChildType[]>;
|
231
|
-
hideInHelmApp?: boolean;
|
232
|
-
};
|
233
227
|
export type EmptyStateType = Pick<GenericEmptyStateType, 'image' | 'SvgImage' | 'subTitle' | 'title' | 'children'>;
|
234
228
|
export declare const VulnerabilityState: {
|
235
229
|
readonly [-1]: "Failed";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CATEGORIES, SUB_CATEGORIES } from './SecurityModal/types';
|
1
|
+
import { CATEGORIES, ScanResultDTO, SUB_CATEGORIES } from './SecurityModal/types';
|
2
2
|
export type ScanCategories = (typeof CATEGORIES)[keyof typeof CATEGORIES];
|
3
3
|
export type ScanSubCategories = (typeof SUB_CATEGORIES)[keyof typeof SUB_CATEGORIES];
|
4
4
|
export type ScanCategoriesWithLicense = ScanCategories | 'imageScanLicenseRisks';
|
@@ -16,4 +16,8 @@ export interface SecurityConfigType {
|
|
16
16
|
codeScan?: SecurityConfigCategoryType;
|
17
17
|
kubernetesManifest?: SecurityConfigCategoryType;
|
18
18
|
}
|
19
|
+
export interface GetSidebarDataParamsType extends Record<ScanCategoriesWithLicense, boolean> {
|
20
|
+
selectedId: string;
|
21
|
+
scanResult: ScanResultDTO;
|
22
|
+
}
|
19
23
|
export {};
|
@@ -101,7 +101,7 @@ export declare enum SelectPickerVariantType {
|
|
101
101
|
BORDER_LESS = "border-less",
|
102
102
|
COMPACT = "compact"
|
103
103
|
}
|
104
|
-
export type SelectPickerProps<OptionValue = number | string, IsMulti extends boolean = false> = Pick<SelectProps<OptionValue, IsMulti>, 'name' | 'classNamePrefix' | 'options' | 'value' | 'onChange' | 'isSearchable' | 'isClearable' | 'hideSelectedOptions' | 'controlShouldRenderValue' | 'closeMenuOnSelect' | 'isDisabled' | 'isLoading' | 'required' | 'isOptionDisabled' | 'placeholder' | 'menuPosition' | 'getOptionLabel' | 'getOptionValue' | 'isOptionSelected' | 'menuIsOpen' | 'onMenuOpen' | 'onMenuClose' | 'autoFocus' | 'onBlur' | 'onKeyDown' | 'formatOptionLabel' | 'onInputChange' | 'inputValue' | 'filterOption' | 'noOptionsMessage' | 'defaultMenuIsOpen'
|
104
|
+
export type SelectPickerProps<OptionValue = number | string, IsMulti extends boolean = false> = Pick<SelectProps<OptionValue, IsMulti>, 'name' | 'classNamePrefix' | 'options' | 'value' | 'onChange' | 'isSearchable' | 'isClearable' | 'hideSelectedOptions' | 'controlShouldRenderValue' | 'closeMenuOnSelect' | 'isDisabled' | 'isLoading' | 'required' | 'isOptionDisabled' | 'placeholder' | 'menuPosition' | 'getOptionLabel' | 'getOptionValue' | 'isOptionSelected' | 'menuIsOpen' | 'onMenuOpen' | 'onMenuClose' | 'autoFocus' | 'onBlur' | 'onKeyDown' | 'formatOptionLabel' | 'onInputChange' | 'inputValue' | 'filterOption' | 'noOptionsMessage' | 'defaultMenuIsOpen'> & Partial<Pick<SelectProps<OptionValue, IsMulti>, 'shouldRenderCustomOptions' | 'renderCustomOptions' | 'icon' | 'showSelectedOptionIcon' | 'renderOptionsFooter' | 'shouldRenderTextArea'>> & Required<Pick<SelectProps<OptionValue, IsMulti>, 'inputId'>> & Partial<Pick<CreatableProps<SelectPickerOptionType<OptionValue>, IsMulti, GroupBase<SelectPickerOptionType<OptionValue>>>, 'onCreateOption' | 'formatCreateLabel' | 'menuPortalTarget'>> & Omit<FormFieldWrapperProps, 'children'> & {
|
105
105
|
/**
|
106
106
|
* Config for the footer at the bottom of menu list. It is sticky by default
|
107
107
|
*
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { ReactElement } from 'react';
|
2
|
+
import { OmitNever } from '../../types';
|
3
|
+
import { ButtonProps } from '../Button';
|
4
|
+
import { IconsProps } from '../Icon';
|
5
|
+
import { NumbersCountProps } from '../NumbersCount';
|
6
|
+
import { DTSwitchProps } from '../Switch';
|
7
|
+
export type ActionMenuItemIconType = Pick<IconsProps, 'name'> & {
|
8
|
+
/** @default 'N800' */
|
9
|
+
color?: IconsProps['color'];
|
10
|
+
};
|
11
|
+
export type TrailingItemType = {
|
12
|
+
type: 'icon';
|
13
|
+
config: ActionMenuItemIconType;
|
14
|
+
} | {
|
15
|
+
type: 'text';
|
16
|
+
config: {
|
17
|
+
value: string;
|
18
|
+
icon?: ActionMenuItemIconType;
|
19
|
+
};
|
20
|
+
} | {
|
21
|
+
type: 'counter';
|
22
|
+
config: {
|
23
|
+
value: NumbersCountProps['count'];
|
24
|
+
} & Pick<NumbersCountProps, 'isSelected'>;
|
25
|
+
} | {
|
26
|
+
type: 'switch';
|
27
|
+
config: Pick<DTSwitchProps, 'ariaLabel' | 'isChecked' | 'indeterminate' | 'isDisabled' | 'isLoading' | 'name' | 'onChange' | 'tooltipContent'>;
|
28
|
+
} | {
|
29
|
+
type: 'button';
|
30
|
+
config: OmitNever<Omit<Extract<ButtonProps, {
|
31
|
+
icon: ReactElement;
|
32
|
+
}>, 'size' | 'variant'>>;
|
33
|
+
};
|
34
|
+
export type TrailingItemProps = TrailingItemType & {
|
35
|
+
/**
|
36
|
+
* @default 'neutral'
|
37
|
+
*/
|
38
|
+
variant?: 'neutral' | 'negative';
|
39
|
+
};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { TreeViewProps } from './types';
|
2
|
+
declare const TreeView: <DataAttributeType = null>({ nodes, isControlled, expandedMap: expandedMapProp, selectedId, onToggle: onToggleProp, onSelect, depth, mode, flatNodeList: flatNodeListProp, getUpdateItemsRefMap: getUpdateItemsRefMapProp, variant, defaultExpandedMap, }: TreeViewProps<DataAttributeType>) => JSX.Element;
|
3
|
+
export default TreeView;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { TreeViewProps } from './types';
|
2
|
+
export declare const DEFAULT_NO_ITEMS_TEXT = "No items found";
|
3
|
+
export declare const VARIANT_TO_BG_CLASS_MAP: Record<TreeViewProps['variant'], string>;
|
4
|
+
export declare const VARIANT_TO_HOVER_CLASS_MAP: Record<TreeViewProps['variant'], string>;
|
@@ -0,0 +1,204 @@
|
|
1
|
+
import { SyntheticEvent } from 'react';
|
2
|
+
import { TooltipProps } from '../../../Common/Tooltip';
|
3
|
+
import { DataAttributes, Never } from '../../types';
|
4
|
+
import { IconsProps } from '../Icon';
|
5
|
+
import { TrailingItemProps } from '../TrailingItem';
|
6
|
+
export type TreeNode<DataAttributeType = null> = TreeHeading<DataAttributeType> | TreeItem<DataAttributeType>;
|
7
|
+
/**
|
8
|
+
* Represents a base node structure for a tree view component.
|
9
|
+
*
|
10
|
+
* @typeParam DataAttributeType - The type for data attributes, defaults to null. If it extends `DataAttributes`, the node can have `dataAttributes` of this type.
|
11
|
+
*
|
12
|
+
* @property id - Unique identifier for the node.
|
13
|
+
* @property title - The main title text displayed for the node.
|
14
|
+
* @property subtitle - Optional subtitle text for the node.
|
15
|
+
* @property customTooltipConfig - Optional configuration for a custom tooltip.
|
16
|
+
* @property strikeThrough - If true, the title will be rendered with a line-through style.
|
17
|
+
* @property startIconConfig - Optional configuration for a start icon, which can be either a standard icon (with `name` and `color`) or a custom JSX element.
|
18
|
+
* @property trailingItem - Optional configuration for a trailing item (e.g., button, icon) displayed at the end of the node.
|
19
|
+
* @property dataAttributes - Optional data attributes, present only if `DataAttributeType` extends `DataAttributes`.
|
20
|
+
*/
|
21
|
+
type BaseNode<DataAttributeType = null> = {
|
22
|
+
/**
|
23
|
+
* id - Unique identifier for the node.
|
24
|
+
*/
|
25
|
+
id: string;
|
26
|
+
/**
|
27
|
+
* The title of the list item.
|
28
|
+
*/
|
29
|
+
title: string;
|
30
|
+
/**
|
31
|
+
* The subtitle of the list item.
|
32
|
+
*/
|
33
|
+
subtitle?: string;
|
34
|
+
/**
|
35
|
+
* Optional configuration for a custom tooltip.
|
36
|
+
*/
|
37
|
+
customTooltipConfig?: TooltipProps;
|
38
|
+
/**
|
39
|
+
* If true, the title will be rendered with line-through.
|
40
|
+
*/
|
41
|
+
strikeThrough?: boolean;
|
42
|
+
/**
|
43
|
+
* Optional configuration for a start icon, which can be either a standard icon (with `name` and `color`) or a custom JSX element.
|
44
|
+
*/
|
45
|
+
startIconConfig?: {
|
46
|
+
tooltipContent?: string;
|
47
|
+
} & ((Pick<IconsProps, 'name' | 'color'> & {
|
48
|
+
customIcon?: never;
|
49
|
+
}) | (Never<Pick<IconsProps, 'name' | 'color'>> & {
|
50
|
+
customIcon?: JSX.Element;
|
51
|
+
}));
|
52
|
+
trailingItem?: TrailingItemProps;
|
53
|
+
} & (DataAttributeType extends DataAttributes ? {
|
54
|
+
dataAttributes?: DataAttributeType;
|
55
|
+
} : {
|
56
|
+
dataAttributes?: never;
|
57
|
+
});
|
58
|
+
export type TreeHeading<DataAttributeType = null> = BaseNode<DataAttributeType> & {
|
59
|
+
type: 'heading';
|
60
|
+
items?: TreeNode<DataAttributeType>[];
|
61
|
+
/**
|
62
|
+
* Text to display when there are no items in the list.
|
63
|
+
* @default DEFAULT_NO_ITEMS_TEXT
|
64
|
+
*/
|
65
|
+
noItemsText?: string;
|
66
|
+
};
|
67
|
+
export type NodeElementType = HTMLDivElement | HTMLButtonElement | HTMLAnchorElement;
|
68
|
+
/**
|
69
|
+
* Represents an item node in a tree structure, supporting different rendering modes.
|
70
|
+
*
|
71
|
+
* @template DataAttributeType - The type for custom data attributes, defaults to null.
|
72
|
+
*
|
73
|
+
* A `TreeItem` can be rendered as a button, link, or div, each with its own set of properties:
|
74
|
+
* - When `as` is `'button'` (default), it can have an `onClick` handler.
|
75
|
+
* - When `as` is `'link'`, it requires an `href`, can have an `onClick` handler, and supports clearing query parameters on navigation.
|
76
|
+
* - When `as` is `'div'`, it is a non-interactive container.
|
77
|
+
*
|
78
|
+
* @property {'item'} type - Identifies the node as an item.
|
79
|
+
* @property {boolean} [isDisabled=false] - If true, disables the item.
|
80
|
+
* @property {'button' | 'link' | 'div'} [as] - Determines the rendered element type.
|
81
|
+
* @property {(e: SyntheticEvent) => void} [onClick] - Callback for click events (button or link only).
|
82
|
+
* @property {string} [href] - The navigation URL (link only).
|
83
|
+
* @property {boolean} [clearQueryParamsOnNavigation=false] - If true, clears query parameters during navigation (link only).
|
84
|
+
*/
|
85
|
+
export type TreeItem<DataAttributeType = null> = BaseNode<DataAttributeType> & {
|
86
|
+
type: 'item';
|
87
|
+
/**
|
88
|
+
* @default false
|
89
|
+
*/
|
90
|
+
isDisabled?: boolean;
|
91
|
+
} & ({
|
92
|
+
as?: 'button';
|
93
|
+
/**
|
94
|
+
* The callback function to handle click events on the button.
|
95
|
+
*/
|
96
|
+
onClick?: (e: SyntheticEvent) => void;
|
97
|
+
href?: never;
|
98
|
+
clearQueryParamsOnNavigation?: never;
|
99
|
+
} | {
|
100
|
+
as: 'link';
|
101
|
+
href: string;
|
102
|
+
/**
|
103
|
+
* The callback function to handle click events on the nav link.
|
104
|
+
*/
|
105
|
+
onClick?: (e: SyntheticEvent) => void;
|
106
|
+
/**
|
107
|
+
* If `true`, clears query parameters during navigation.
|
108
|
+
* @default false
|
109
|
+
*/
|
110
|
+
clearQueryParamsOnNavigation?: boolean;
|
111
|
+
} | {
|
112
|
+
as: 'div';
|
113
|
+
href?: never;
|
114
|
+
onClick?: never;
|
115
|
+
clearQueryParamsOnNavigation?: never;
|
116
|
+
});
|
117
|
+
/**
|
118
|
+
* Props for the TreeView component.
|
119
|
+
*
|
120
|
+
* @template DataAttributeType - The type for data attributes associated with tree nodes.
|
121
|
+
*
|
122
|
+
* @property nodes - An array of tree nodes to be rendered in the tree view.
|
123
|
+
* @property selectedId - (Optional) The ID of the currently selected tree item.
|
124
|
+
* @property onSelect - (Optional) Callback invoked when a tree item is selected.
|
125
|
+
* @property mode - (Optional) Determines the navigation mode of the tree view.
|
126
|
+
* - `'navigation'`: Enables keyboard navigation and focuses only the selected item.
|
127
|
+
* - `'form'`: Leaves navigation to the browser.
|
128
|
+
* - @default 'navigation'
|
129
|
+
* @property variant - (Optional) Visual variant of the tree view.
|
130
|
+
* - `'primary'`: Uses primary background and hover colors.
|
131
|
+
* - `'secondary'`: Uses secondary background and hover colors.
|
132
|
+
* - @default 'primary'
|
133
|
+
* @property defaultExpandedMap - (Optional) Initial map of node IDs to their expanded state.
|
134
|
+
* - @default {}
|
135
|
+
*
|
136
|
+
* @property depth - (Internal use only) The current depth level in the tree.
|
137
|
+
* @property getUpdateItemsRefMap - (Internal use only) Function to update the ref map for item buttons/anchors.
|
138
|
+
* @property flatNodeList - (Internal use only) List of all visible node IDs for keyboard navigation.
|
139
|
+
* @property onToggle - (Internal use only) Callback invoked when a tree heading is toggled.
|
140
|
+
* @property expandedMap - (Internal use only) Map of node IDs to their expanded state.
|
141
|
+
* @property isControlled - (Internal use only) Indicates if the tree view is controlled.
|
142
|
+
*/
|
143
|
+
export type TreeViewProps<DataAttributeType = null> = {
|
144
|
+
nodes: TreeNode<DataAttributeType>[];
|
145
|
+
selectedId?: string;
|
146
|
+
onSelect?: (item: TreeItem<DataAttributeType>) => void;
|
147
|
+
/**
|
148
|
+
* If navigation mode, the tree view will provide navigation through keyboard actions and make the only selected item focusable.
|
149
|
+
* If form mode, will leave the navigation to browser.
|
150
|
+
* @default 'navigation'
|
151
|
+
*/
|
152
|
+
mode?: 'navigation' | 'form';
|
153
|
+
/**
|
154
|
+
* If primary the background color will be bg__primary and bg__hover--opaque, if secondary the background color will be bg__secondary bg__hover-secondary--opaque.
|
155
|
+
* @default 'primary'
|
156
|
+
*/
|
157
|
+
variant?: 'primary' | 'secondary';
|
158
|
+
/**
|
159
|
+
* @default {}
|
160
|
+
*/
|
161
|
+
defaultExpandedMap?: Record<string, boolean>;
|
162
|
+
} /**
|
163
|
+
* WARNING: For internal use only.
|
164
|
+
*/ & ({
|
165
|
+
depth: number;
|
166
|
+
/**
|
167
|
+
* Would pass this to item button/ref and store it in out ref map through this function.
|
168
|
+
*/
|
169
|
+
getUpdateItemsRefMap: (id: string) => (element: NodeElementType) => void;
|
170
|
+
/**
|
171
|
+
* List of all nodes visible in tree view for keyboard navigation.
|
172
|
+
*/
|
173
|
+
flatNodeList: string[];
|
174
|
+
/**
|
175
|
+
* Would be called when the user toggles a heading.
|
176
|
+
*/
|
177
|
+
onToggle: (item: TreeHeading<DataAttributeType>) => void;
|
178
|
+
/**
|
179
|
+
* Map of id to whether the item is expanded or not.
|
180
|
+
*/
|
181
|
+
expandedMap: Record<string, boolean>;
|
182
|
+
isControlled: true;
|
183
|
+
} | {
|
184
|
+
depth?: never;
|
185
|
+
getUpdateItemsRefMap?: never;
|
186
|
+
flatNodeList?: never;
|
187
|
+
onToggle?: never;
|
188
|
+
expandedMap?: never;
|
189
|
+
isControlled?: false;
|
190
|
+
});
|
191
|
+
export interface TreeViewNodeContentProps extends Pick<BaseNode, 'startIconConfig' | 'title' | 'subtitle' | 'customTooltipConfig' | 'strikeThrough'> {
|
192
|
+
type: 'heading' | 'item';
|
193
|
+
isSelected: boolean;
|
194
|
+
}
|
195
|
+
export interface GetSelectedIdParentNodesProps<DataAttributeType = null> extends Pick<TreeViewProps<DataAttributeType>, 'nodes' | 'selectedId'> {
|
196
|
+
}
|
197
|
+
export interface FindSelectedIdParentNodesProps<DataAttributeType = null> extends Pick<GetSelectedIdParentNodesProps<DataAttributeType>, 'selectedId'> {
|
198
|
+
node: TreeNode<DataAttributeType>;
|
199
|
+
onFindParentNode: (id: string) => void;
|
200
|
+
}
|
201
|
+
export interface GetVisibleNodesProps<DataAttributeType = null> extends Pick<TreeViewProps<DataAttributeType>, 'expandedMap'> {
|
202
|
+
nodeList: TreeNode<DataAttributeType>[];
|
203
|
+
}
|
204
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { GetSelectedIdParentNodesProps, GetVisibleNodesProps } from './types';
|
2
|
+
/**
|
3
|
+
* Retrieves an array of parent node IDs for the currently selected node.
|
4
|
+
*
|
5
|
+
* Iterates through the provided tree nodes and collects the IDs of all parent nodes
|
6
|
+
* leading to the node identified by `selectedId`. If no node is selected, returns an empty array.
|
7
|
+
*
|
8
|
+
* @returns {string[]} An array of parent node IDs for the selected node, or an empty array if no node is selected.
|
9
|
+
*/
|
10
|
+
export declare const getSelectedIdParentNodes: <DataAttributeType = null>({ nodes, selectedId, }: GetSelectedIdParentNodesProps<DataAttributeType>) => string[];
|
11
|
+
/**
|
12
|
+
* Recursively traverses a list of tree nodes and returns an array of all node IDs that are present in DOM.
|
13
|
+
*
|
14
|
+
* For each node in the provided list:
|
15
|
+
* - Adds the node's `id` to the result array.
|
16
|
+
* - If the node is of type `'heading'`, is expanded (as per `expandedMap`), and has child items,
|
17
|
+
* recursively traverses its child items and includes their IDs as well.
|
18
|
+
*
|
19
|
+
* @param nodeList - The list of nodes to traverse.
|
20
|
+
* @returns An array of strings representing the IDs of all traversed nodes.
|
21
|
+
*/
|
22
|
+
export declare const getVisibleNodes: <DataAttributeType = null>({ nodeList, expandedMap, }: GetVisibleNodesProps<DataAttributeType>) => string[];
|
@@ -85,6 +85,7 @@ export * from './TargetPlatforms';
|
|
85
85
|
export * from './Textarea';
|
86
86
|
export * from './ThemeSwitcher';
|
87
87
|
export * from './ToggleResolveScopedVariables';
|
88
|
+
export * from './TreeView';
|
88
89
|
export * from './Typewriter';
|
89
90
|
export * from './UnsavedChanges';
|
90
91
|
export * from './UnsavedChangesDialog';
|