@devtron-labs/devtron-fe-common-lib 1.17.0-beta-4 → 1.17.0-beta-7
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-CHmXQoJu.js → @code-editor-CuHkeuO1.js} +10303 -9795
- package/dist/@common-rjsf-COvKctSh.js +598 -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 +1 -0
- 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 +4 -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/GroupedFilterSelectPicker.d.ts +2 -0
- package/dist/Shared/Components/SelectPicker/SelectPicker.component.d.ts +1 -1
- package/dist/Shared/Components/SelectPicker/index.d.ts +1 -0
- package/dist/Shared/Components/SelectPicker/type.d.ts +7 -2
- 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-activity.abf111c7.svg +3 -0
- package/dist/assets/ic-folder.8038c019.svg +3 -0
- package/dist/assets/ic-helm-app.a20cfeb3.svg +4 -0
- package/dist/assets/ic-namespace.8980221f.svg +3 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +651 -646
- package/package.json +1 -1
- package/dist/@common-rjsf-kLdUrmr1.js +0 -609
@@ -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;
|
@@ -2,6 +2,7 @@ import { IconBaseProps } from './types';
|
|
2
2
|
export declare const iconMap: {
|
3
3
|
'ic-73strings': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
4
4
|
'ic-aborted': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
5
|
+
'ic-activity': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
5
6
|
'ic-add': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
6
7
|
'ic-amazon-eks': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
7
8
|
'ic-apica': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
@@ -92,6 +93,7 @@ export declare const iconMap: {
|
|
92
93
|
'ic-flask': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
93
94
|
'ic-folder-color': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
94
95
|
'ic-folder-user': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
96
|
+
'ic-folder': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
95
97
|
'ic-gavel': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
96
98
|
'ic-gear': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
97
99
|
'ic-gift-gradient': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
@@ -109,6 +111,7 @@ export declare const iconMap: {
|
|
109
111
|
'ic-heart-green': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
110
112
|
'ic-heart-red-animated': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
111
113
|
'ic-heart-red': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
114
|
+
'ic-helm-app': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
112
115
|
'ic-helm': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
113
116
|
'ic-help-filled': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
114
117
|
'ic-help-outline': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
@@ -147,6 +150,7 @@ export declare const iconMap: {
|
|
147
150
|
'ic-mobile': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
148
151
|
'ic-monitoring': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
149
152
|
'ic-more-vertical': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
153
|
+
'ic-namespace': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
150
154
|
'ic-new': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
151
155
|
'ic-node-script': import('react').FunctionComponent<import('react').SVGProps<SVGSVGElement>>;
|
152
156
|
'ic-oidc': 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 {};
|
@@ -133,5 +133,5 @@ import { SelectPickerProps } from './type';
|
|
133
133
|
* />
|
134
134
|
* ```
|
135
135
|
*/
|
136
|
-
declare const SelectPicker: <OptionValue, IsMulti extends boolean>({ error, icon, helperText, placeholder, label, showSelectedOptionIcon, size, disabledTippyContent, showSelectedOptionsCount, menuSize, optionListError, reloadOptionList, menuPosition, variant, disableDescriptionEllipsis, multiSelectProps, isMulti, name, classNamePrefix, shouldRenderCustomOptions, isSearchable, selectRef: refFromConsumer, shouldMenuAlignRight, fullWidth, customSelectedOptionsCount, menuListFooterConfig, isCreatable, onCreateOption, closeMenuOnSelect, shouldShowNoOptionsMessage, shouldRenderTextArea, onKeyDown, shouldHideMenu, warningText, layout, ariaLabel, borderConfig, borderRadiusConfig, labelTippyCustomizedConfig, labelTooltipConfig, hideFormFieldInfo, ...props }: SelectPickerProps<OptionValue, IsMulti>) => JSX.Element;
|
136
|
+
declare const SelectPicker: <OptionValue, IsMulti extends boolean>({ error, icon, helperText, placeholder, label, showSelectedOptionIcon, size, disabledTippyContent, showSelectedOptionsCount, menuSize, optionListError, reloadOptionList, menuPosition, variant, disableDescriptionEllipsis, multiSelectProps, isMulti, name, classNamePrefix, shouldRenderCustomOptions, isSearchable, selectRef: refFromConsumer, shouldMenuAlignRight, fullWidth, customSelectedOptionsCount, menuListFooterConfig, isCreatable, onCreateOption, closeMenuOnSelect, shouldShowNoOptionsMessage, shouldRenderTextArea, onKeyDown, shouldHideMenu, warningText, layout, ariaLabel, borderConfig, borderRadiusConfig, labelTippyCustomizedConfig, labelTooltipConfig, hideFormFieldInfo, autoFocus, ...props }: SelectPickerProps<OptionValue, IsMulti>) => JSX.Element;
|
137
137
|
export default SelectPicker;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { ValueContainerWithLoadingShimmer } from './common';
|
2
2
|
export { default as FilterSelectPicker } from './FilterSelectPicker';
|
3
|
+
export * from './GroupedFilterSelectPicker';
|
3
4
|
export { default as SelectPicker } from './SelectPicker.component';
|
4
5
|
export * from './SelectPickerTextArea.component';
|
5
6
|
export * from './type';
|
@@ -6,6 +6,7 @@ import { ServerErrors } from '../../../Common/ServerError';
|
|
6
6
|
import { TooltipProps } from '../../../Common/Tooltip';
|
7
7
|
import { OptionType } from '../../../Common/Types';
|
8
8
|
import { ComponentSizeType } from '../../constants';
|
9
|
+
import { ActionMenuProps } from '../ActionMenu';
|
9
10
|
import { ButtonComponentType, ButtonProps, ButtonVariantType } from '../Button';
|
10
11
|
import { FormFieldWrapperProps } from '../FormFieldWrapper/types';
|
11
12
|
export interface SelectPickerOptionType<OptionValue = string | number> extends OptionType<OptionValue, ReactNode> {
|
@@ -100,7 +101,7 @@ export declare enum SelectPickerVariantType {
|
|
100
101
|
BORDER_LESS = "border-less",
|
101
102
|
COMPACT = "compact"
|
102
103
|
}
|
103
|
-
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'> & {
|
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' | 'onFocus'> & 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'> & {
|
104
105
|
/**
|
105
106
|
* Config for the footer at the bottom of menu list. It is sticky by default
|
106
107
|
*
|
@@ -215,9 +216,13 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
|
|
215
216
|
export type SelectPickerGroupHeadingProps<OptionValue> = GroupHeadingProps<SelectPickerOptionType<OptionValue>> & {
|
216
217
|
isGroupHeadingSelectable: boolean;
|
217
218
|
};
|
218
|
-
export interface FilterSelectPickerProps extends Required<Pick<SelectPickerProps<number | string, true>, 'options' | 'isDisabled' | 'placeholder' | 'isLoading'>>, Pick<SelectPickerProps<number | string, true>, 'selectRef' | 'inputId' | 'menuPosition' | 'autoFocus' | 'shouldMenuAlignRight' | 'optionListError' | 'reloadOptionList' | 'getOptionValue' | 'isOptionDisabled'> {
|
219
|
+
export interface FilterSelectPickerProps extends Required<Pick<SelectPickerProps<number | string, true>, 'options' | 'isDisabled' | 'placeholder' | 'isLoading'>>, Pick<SelectPickerProps<number | string, true>, 'selectRef' | 'inputId' | 'menuPosition' | 'autoFocus' | 'shouldMenuAlignRight' | 'optionListError' | 'reloadOptionList' | 'getOptionValue' | 'isOptionDisabled' | 'onMenuClose' | 'menuIsOpen' | 'onKeyDown'> {
|
219
220
|
appliedFilterOptions: SelectPickerOptionType[];
|
220
221
|
handleApplyFilter: (filtersToApply: SelectPickerOptionType<number | string>[]) => void;
|
221
222
|
}
|
222
223
|
export type SelectPickerTextAreaProps = Omit<SelectPickerProps<string, false>, 'selectRef' | 'inputValue' | 'onInputChange' | 'controlShouldRenderValue' | 'onKeyDown' | 'onCreateOption' | 'shouldRenderTextArea'> & Pick<ResizableTagTextAreaProps, 'maxHeight' | 'minHeight' | 'refVar' | 'dependentRefs'>;
|
224
|
+
export interface GroupedFilterSelectPickerProps<T extends string | number = string | number> extends Omit<ActionMenuProps<T>, 'onClick' | 'disableDescriptionEllipsis' | 'children' | 'buttonProps' | 'isSearchable'> {
|
225
|
+
isFilterApplied?: boolean;
|
226
|
+
filterSelectPickerPropsMap: Record<T, Omit<FilterSelectPickerProps, 'autoFocus' | 'menuIsOpen' | 'onMenuClose' | 'onKeyDown'>>;
|
227
|
+
}
|
223
228
|
export {};
|
@@ -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[];
|
@@ -86,6 +86,7 @@ export * from './TargetPlatforms';
|
|
86
86
|
export * from './Textarea';
|
87
87
|
export * from './ThemeSwitcher';
|
88
88
|
export * from './ToggleResolveScopedVariables';
|
89
|
+
export * from './TreeView';
|
89
90
|
export * from './Typewriter';
|
90
91
|
export * from './UnsavedChanges';
|
91
92
|
export * from './UnsavedChangesDialog';
|