@devtron-labs/devtron-fe-common-lib 1.10.0 → 1.10.1-beta-2
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-Dd-Rsu69.js → @code-editor-CPKQ3C33.js} +7753 -7058
- package/dist/{@common-rjsf-B1NZSY87.js → @common-rjsf-B71oS2-A.js} +1 -1
- package/dist/Common/Hooks/UseRegisterShortcut/types.d.ts +14 -0
- package/dist/Common/Hooks/UseRegisterShortcut/utils.d.ts +1 -1
- package/dist/Common/Hooks/useStateFilters/types.d.ts +1 -1
- package/dist/Common/Hooks/useUrlFilters/types.d.ts +4 -3
- package/dist/Common/Hooks/useUrlFilters/useUrlFilters.d.ts +1 -1
- package/dist/Common/Hooks/useUrlFilters/utils.d.ts +1 -0
- package/dist/Common/SegmentedControl/Segment.d.ts +3 -0
- package/dist/Common/SegmentedControl/SegmentedControl.component.d.ts +1 -1
- package/dist/Common/SegmentedControl/constants.d.ts +2 -1
- package/dist/Common/SegmentedControl/index.d.ts +1 -1
- package/dist/Common/SegmentedControl/types.d.ts +59 -17
- package/dist/Shared/Components/Button/index.d.ts +1 -0
- package/dist/Shared/Components/Button/types.d.ts +2 -0
- package/dist/Shared/Components/Button/useTriggerAutoClickTimestamp.d.ts +6 -0
- package/dist/Shared/Components/SelectPicker/SelectPicker.component.d.ts +6 -7
- package/dist/Shared/Components/SelectPicker/common.d.ts +0 -1
- package/dist/Shared/Components/SelectPicker/type.d.ts +25 -4
- package/dist/Shared/Components/Table/BulkSelectionActionWidget.d.ts +3 -0
- package/dist/Shared/Components/Table/InternalTable.d.ts +3 -0
- package/dist/Shared/Components/Table/Table.component.d.ts +3 -0
- package/dist/Shared/Components/Table/constants.d.ts +10 -0
- package/dist/Shared/Components/Table/index.d.ts +4 -0
- package/dist/Shared/Components/Table/types.d.ts +194 -0
- package/dist/Shared/Components/Table/useTableWithKeyboardShortcuts.d.ts +6 -0
- package/dist/Shared/Components/Table/utils.d.ts +6 -0
- package/dist/Shared/Components/index.d.ts +1 -0
- package/dist/Shared/types.d.ts +2 -2
- package/dist/assets/@code-editor.css +1 -1
- package/dist/index.js +614 -609
- package/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { j as n, aq as y, as as k, ar as W } from "./@vendor-DXbFZ041.js";
|
2
2
|
import V, { forwardRef as J, useMemo as P } from "react";
|
3
3
|
import K, { getDefaultRegistry as q } from "@rjsf/core";
|
4
|
-
import { T as F, j as N, c as v, b as S, a as Y, i as z, d as w, e as E, S as G } from "./@code-editor-
|
4
|
+
import { T as F, j as N, c as v, b as S, a as Y, i as z, d as w, e as E, S as G } from "./@code-editor-CPKQ3C33.js";
|
5
5
|
import Q, { components as D } from "react-select";
|
6
6
|
import { ReactComponent as X } from "./assets/ic-chevron-down.fc70d7a7.svg";
|
7
7
|
import { getUiOptions as B, getTemplate as $, getSubmitButtonOptions as Z, ADDITIONAL_PROPERTY_FLAG as L, errorId as ee, englishStringTranslator as te, TranslatableString as ne, titleId as re, canExpand as se, deepEquals as ae } from "@rjsf/utils";
|
@@ -7,8 +7,22 @@ export declare const KEYBOARD_KEYS_MAP: {
|
|
7
7
|
readonly E: "E";
|
8
8
|
readonly R: "R";
|
9
9
|
readonly K: "K";
|
10
|
+
readonly X: "X";
|
11
|
+
readonly A: "A";
|
10
12
|
readonly Escape: "Esc";
|
11
13
|
readonly Enter: "↩";
|
14
|
+
readonly ArrowLeft: "←";
|
15
|
+
readonly ArrowRight: "→";
|
16
|
+
readonly ArrowUp: "↑";
|
17
|
+
readonly ArrowDown: "↓";
|
18
|
+
readonly PageUp: "PgUp";
|
19
|
+
readonly PageDown: "PgDn";
|
20
|
+
readonly Home: "Home";
|
21
|
+
readonly End: "End";
|
22
|
+
readonly Backspace: "⌫";
|
23
|
+
readonly Delete: "⌦";
|
24
|
+
readonly '.': ".";
|
25
|
+
readonly Space: "Space";
|
12
26
|
};
|
13
27
|
export type SupportedKeyboardKeysType = keyof typeof KEYBOARD_KEYS_MAP;
|
14
28
|
export interface ShortcutType {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ShortcutType } from './types';
|
2
2
|
export declare const preprocessKeys: (keys: ShortcutType["keys"]) => {
|
3
|
-
keys: ("Escape" | "Control" | "Alt" | "F" | "E" | "R" | "K" | "Shift" | "Meta" | "Enter")[];
|
3
|
+
keys: ("Escape" | "Control" | "Alt" | "F" | "E" | "R" | "K" | "X" | "A" | "Home" | "End" | "." | "Space" | "Shift" | "Meta" | "Enter" | "ArrowLeft" | "ArrowRight" | "ArrowUp" | "ArrowDown" | "PageUp" | "PageDown" | "Backspace" | "Delete")[];
|
4
4
|
id: string;
|
5
5
|
};
|
6
6
|
export declare const verifyCallbackStack: (stack: ShortcutType["callbackStack"]) => void;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { UseUrlFiltersProps, UseUrlFiltersReturnType } from '../useUrlFilters';
|
2
2
|
export interface UseStateFiltersProps<T> extends Pick<UseUrlFiltersProps<T, never>, 'initialSortKey'> {
|
3
3
|
}
|
4
|
-
export interface UseStateFiltersReturnType<T> extends Pick<UseUrlFiltersReturnType<T>, 'sortBy' | 'sortOrder' | 'handleSorting' | 'clearFilters' | 'changePage' | 'changePageSize' | 'offset' | 'pageSize' | 'searchKey' | 'handleSearch'> {
|
4
|
+
export interface UseStateFiltersReturnType<T> extends Pick<UseUrlFiltersReturnType<T>, 'sortBy' | 'sortOrder' | 'handleSorting' | 'clearFilters' | 'changePage' | 'changePageSize' | 'offset' | 'pageSize' | 'searchKey' | 'handleSearch' | 'isFilterApplied'> {
|
5
5
|
}
|
6
6
|
export interface PaginationType<T> extends Pick<UseUrlFiltersReturnType<T>, 'pageSize'> {
|
7
7
|
pageNumber: number;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { SortingOrder } from '../../Constants';
|
2
|
-
export interface UseUrlFiltersProps<T, K> {
|
2
|
+
export interface UseUrlFiltersProps<T, K extends {}> {
|
3
3
|
/**
|
4
4
|
* The key on which the sorting should be applied
|
5
5
|
*/
|
@@ -19,8 +19,8 @@ export interface UseUrlFiltersProps<T, K> {
|
|
19
19
|
*/
|
20
20
|
redirectionMethod?: 'replace' | 'push';
|
21
21
|
}
|
22
|
-
export type UpdateSearchParamsOptionsType<T, K =
|
23
|
-
export type UseUrlFiltersReturnType<T, K =
|
22
|
+
export type UpdateSearchParamsOptionsType<T, K = {}> = Partial<Pick<UseUrlFiltersProps<T, K>, 'redirectionMethod'>>;
|
23
|
+
export type UseUrlFiltersReturnType<T, K = {}> = K & {
|
24
24
|
/**
|
25
25
|
* Currently applied page size
|
26
26
|
*/
|
@@ -67,4 +67,5 @@ export type UseUrlFiltersReturnType<T, K = unknown> = K & {
|
|
67
67
|
* Update the search params with the passed object
|
68
68
|
*/
|
69
69
|
updateSearchParams: (paramsToSerialize: Partial<K>, options?: UpdateSearchParamsOptionsType<T, K>) => void;
|
70
|
+
isFilterApplied: boolean;
|
70
71
|
};
|
@@ -16,5 +16,5 @@ import { UseUrlFiltersProps, UseUrlFiltersReturnType } from './types';
|
|
16
16
|
* ```
|
17
17
|
*
|
18
18
|
*/
|
19
|
-
declare const useUrlFilters: <T = string, K =
|
19
|
+
declare const useUrlFilters: <T = string, K = {}>({ initialSortKey, parseSearchParams, localStorageKey, redirectionMethod, }?: UseUrlFiltersProps<T, K>) => UseUrlFiltersReturnType<T, K>;
|
20
20
|
export default useUrlFilters;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { SegmentedControlProps } from './types';
|
2
|
-
declare const SegmentedControl: ({
|
2
|
+
declare const SegmentedControl: ({ segments, onChange, name, size, value: controlledValue, fullWidth, disabled, }: SegmentedControlProps) => JSX.Element;
|
3
3
|
export default SegmentedControl;
|
@@ -1,2 +1,3 @@
|
|
1
1
|
import { SegmentedControlProps } from './types';
|
2
|
-
export declare const
|
2
|
+
export declare const COMPONENT_SIZE_TO_SEGMENT_CLASS_MAP: Record<SegmentedControlProps['size'], string>;
|
3
|
+
export declare const COMPONENT_SIZE_TO_ICON_CLASS_MAP: Record<SegmentedControlProps['size'], string>;
|
@@ -1,25 +1,67 @@
|
|
1
|
-
import {
|
1
|
+
import { TooltipProps } from '../Tooltip';
|
2
|
+
import { IconsProps, SelectPickerOptionType } from '../../Shared/Components';
|
2
3
|
import { ComponentSizeType } from '../../Shared/constants';
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
import { RefObject } from 'react';
|
5
|
+
type SegmentTooltipProps = Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate' | 'shortcutKeyCombo' | 'placement'>;
|
6
|
+
export type SegmentType = Pick<SelectPickerOptionType, 'value'> & {
|
7
|
+
/**
|
8
|
+
* If true, the segment will be in error state with error icon
|
9
|
+
*/
|
10
|
+
isError?: boolean;
|
11
|
+
} & (({
|
12
|
+
/**
|
13
|
+
* Label for the segment
|
14
|
+
*
|
15
|
+
* Note: Either of label or icon is required
|
16
|
+
*/
|
17
|
+
label: SelectPickerOptionType['label'];
|
18
|
+
/**
|
19
|
+
* Icon for the segment
|
20
|
+
*
|
21
|
+
* Note: Either of label or icon is required
|
22
|
+
*/
|
23
|
+
icon?: IconsProps['name'];
|
24
|
+
/**
|
25
|
+
* Tooltip props for the segment
|
26
|
+
*
|
27
|
+
* Note: Required if only icon is provided
|
28
|
+
*/
|
29
|
+
tooltipProps?: SegmentTooltipProps;
|
30
|
+
ariaLabel?: never;
|
31
|
+
} & Pick<SelectPickerOptionType, 'label'>) | {
|
32
|
+
label?: never;
|
33
|
+
tooltipProps: SegmentTooltipProps;
|
34
|
+
icon: IconsProps['name'];
|
35
|
+
/**
|
36
|
+
* Aria label for the segment
|
37
|
+
*/
|
38
|
+
ariaLabel: string;
|
39
|
+
});
|
40
|
+
export type SegmentedControlProps = {
|
41
|
+
/**
|
42
|
+
* List of segments to be displayed
|
43
|
+
*/
|
44
|
+
segments: SegmentType[];
|
12
45
|
name: string;
|
13
|
-
|
46
|
+
size?: Extract<ComponentSizeType, ComponentSizeType.xs | ComponentSizeType.small | ComponentSizeType.medium>;
|
47
|
+
fullWidth?: boolean;
|
14
48
|
disabled?: boolean;
|
15
|
-
|
16
|
-
|
49
|
+
} & ({
|
50
|
+
value?: never;
|
17
51
|
/**
|
18
|
-
*
|
52
|
+
* On change handler for the component
|
19
53
|
*/
|
20
|
-
|
54
|
+
onChange?: (selectedSegment: SegmentType) => void;
|
55
|
+
} | {
|
21
56
|
/**
|
22
|
-
*
|
57
|
+
* If defined, the component is controlled and onChange needs to be handled by the parent
|
23
58
|
*/
|
24
|
-
|
59
|
+
value: SegmentType['value'];
|
60
|
+
onChange: (selectedSegment: SegmentType) => void;
|
61
|
+
});
|
62
|
+
export interface SegmentProps extends Required<Pick<SegmentedControlProps, 'name' | 'onChange' | 'fullWidth' | 'size' | 'disabled'>> {
|
63
|
+
isSelected: boolean;
|
64
|
+
segment: SegmentType;
|
65
|
+
selectedSegmentRef: RefObject<HTMLDivElement> | undefined;
|
25
66
|
}
|
67
|
+
export {};
|
@@ -88,6 +88,8 @@ export type ButtonProps<ComponentType extends ButtonComponentType = ButtonCompon
|
|
88
88
|
isOpacityHoverChild?: boolean;
|
89
89
|
/**
|
90
90
|
* If provided, the button is clicked automatically after the pre-defined time
|
91
|
+
*
|
92
|
+
* Use from useTriggerAutoClickTimestamp hook
|
91
93
|
*/
|
92
94
|
triggerAutoClickTimestamp?: number | null;
|
93
95
|
} & ({
|
@@ -37,16 +37,15 @@ import { SelectPickerProps } from './type';
|
|
37
37
|
* <SelectPicker ... helperText="Help information" />
|
38
38
|
* ```
|
39
39
|
*
|
40
|
-
* @example Menu list footer
|
40
|
+
* @example Menu list footer config
|
41
41
|
* The footer is sticky by default
|
42
42
|
* ```tsx
|
43
43
|
* <SelectPicker
|
44
44
|
* ...
|
45
|
-
*
|
46
|
-
*
|
47
|
-
*
|
48
|
-
*
|
49
|
-
* )}
|
45
|
+
* menuListFooterConfig={{
|
46
|
+
* type: 'text',
|
47
|
+
* value: 'Info text',
|
48
|
+
* }}
|
50
49
|
* />
|
51
50
|
* ```
|
52
51
|
*
|
@@ -134,5 +133,5 @@ import { SelectPickerProps } from './type';
|
|
134
133
|
* />
|
135
134
|
* ```
|
136
135
|
*/
|
137
|
-
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, shouldMenuAlignRight, fullWidth, customSelectedOptionsCount,
|
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, ...props }: SelectPickerProps<OptionValue, IsMulti>) => JSX.Element;
|
138
137
|
export default SelectPicker;
|
@@ -5,7 +5,6 @@ export declare const SelectPickerClearIndicator: <OptionValue>(props: ClearIndic
|
|
5
5
|
export declare const SelectPickerControl: <OptionValue>(props: ControlProps<SelectPickerOptionType<OptionValue>>) => JSX.Element;
|
6
6
|
export declare const SelectPickerInput: <OptionValue>(props: InputProps<SelectPickerOptionType<OptionValue>>) => JSX.Element;
|
7
7
|
export declare const SelectPickerValueContainer: <OptionValue, IsMulti extends boolean>({ showSelectedOptionsCount, customSelectedOptionsCount, ...props }: ValueContainerProps<SelectPickerOptionType<OptionValue>> & Pick<SelectPickerProps<OptionValue, IsMulti>, "showSelectedOptionsCount" | "customSelectedOptionsCount">) => JSX.Element;
|
8
|
-
export declare const SelectPickerLoadingIndicator: () => JSX.Element;
|
9
8
|
export declare const SelectPickerOption: <OptionValue, IsMulti extends boolean>({ disableDescriptionEllipsis, ...props }: OptionProps<SelectPickerOptionType<OptionValue>> & Pick<SelectPickerProps<OptionValue, IsMulti>, "disableDescriptionEllipsis">) => JSX.Element;
|
10
9
|
export declare const SelectPickerMenuList: <OptionValue>(props: MenuListProps<SelectPickerOptionType<OptionValue>>) => JSX.Element;
|
11
10
|
export declare const SelectPickerMultiValueLabel: <OptionValue, IsMulti extends boolean>({ getIsOptionValid, ...props }: MultiValueProps<SelectPickerOptionType<OptionValue>, true> & Pick<SelectPickerProps<OptionValue, IsMulti>["multiSelectProps"], "getIsOptionValid">) => JSX.Element;
|
@@ -7,6 +7,7 @@ import { CreatableProps } from 'react-select/creatable';
|
|
7
7
|
import { TooltipProps } from '@Common/Tooltip/types';
|
8
8
|
import { ResizableTagTextAreaProps } from '../../../Common/CustomTagSelector';
|
9
9
|
import { FormFieldWrapperProps } from '../FormFieldWrapper/types';
|
10
|
+
import { ButtonComponentType, ButtonProps, ButtonVariantType } from '../Button';
|
10
11
|
export interface SelectPickerOptionType<OptionValue = string | number> extends OptionType<OptionValue, ReactNode> {
|
11
12
|
/**
|
12
13
|
* Description to be displayed for the option
|
@@ -26,16 +27,30 @@ export interface SelectPickerOptionType<OptionValue = string | number> extends O
|
|
26
27
|
tooltipProps?: Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate' | 'shortcutKeyCombo'> | (Omit<TooltipProps, 'alwaysShowTippyOnHover' | 'showOnTruncate' | 'content'> & Required<Pick<TooltipProps, 'shortcutKeyCombo'>>);
|
27
28
|
}
|
28
29
|
type SelectProps<OptionValue, IsMulti extends boolean> = ReactSelectProps<SelectPickerOptionType<OptionValue>, IsMulti, GroupBase<SelectPickerOptionType<OptionValue>>>;
|
30
|
+
type MenuListFooterConfigType = {
|
31
|
+
type: 'text';
|
32
|
+
/**
|
33
|
+
* String is preferred for text type
|
34
|
+
*/
|
35
|
+
value: ReactNode;
|
36
|
+
buttonProps?: never;
|
37
|
+
} | {
|
38
|
+
type: 'button';
|
39
|
+
value?: never;
|
40
|
+
buttonProps: {
|
41
|
+
variant: ButtonVariantType.primary | ButtonVariantType.borderLess;
|
42
|
+
} & Omit<ButtonProps<ButtonComponentType>, 'size' | 'fullWidth' | 'icon' | 'endIcon' | 'variant' | 'style'>;
|
43
|
+
};
|
29
44
|
declare module 'react-select/base' {
|
30
45
|
interface Props<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
|
31
46
|
/**
|
32
|
-
*
|
47
|
+
* Config for the footer at the bottom of menu list. It is sticky by default
|
33
48
|
*/
|
34
|
-
|
49
|
+
menuListFooterConfig?: MenuListFooterConfigType;
|
35
50
|
/**
|
36
51
|
* If true, custom options are rendered in the menuList component of react select
|
37
52
|
*
|
38
|
-
* Note: renderCustomOptions is required to be passed;
|
53
|
+
* Note: renderCustomOptions is required to be passed; menuListFooterConfig is also not used
|
39
54
|
*
|
40
55
|
* @default false
|
41
56
|
*/
|
@@ -80,7 +95,13 @@ export declare enum SelectPickerVariantType {
|
|
80
95
|
DEFAULT = "default",
|
81
96
|
BORDER_LESS = "border-less"
|
82
97
|
}
|
83
|
-
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'> & Partial<Pick<SelectProps<OptionValue, IsMulti>, '
|
98
|
+
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'> & 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'> & {
|
99
|
+
/**
|
100
|
+
* Config for the footer at the bottom of menu list. It is sticky by default
|
101
|
+
*
|
102
|
+
* Note: Re-declaring here since dynamic typing doesn't work with module augmentation
|
103
|
+
*/
|
104
|
+
menuListFooterConfig?: MenuListFooterConfigType;
|
84
105
|
/**
|
85
106
|
* Custom selected options count for use cases like filters
|
86
107
|
*/
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import { InternalTableProps } from './types';
|
2
|
+
declare const InternalTable: ({ filtersVariant, filterData, rows, getRows, columns, ViewWrapper, resizableConfig, emptyStateConfig, additionalProps, areColumnsConfigurable, filter, setVisibleColumns, visibleColumns, stylesConfig, loading, bulkSelectionConfig, bulkSelectionReturnValue, handleClearBulkSelection, handleToggleBulkSelectionOnRow, paginationVariant, RowActionsOnHoverComponent, }: InternalTableProps) => JSX.Element;
|
3
|
+
export default InternalTable;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const SEARCH_SORT_CHANGE_DEBOUNCE_TIME = 350; /** in ms */
|
2
|
+
export declare const LOCAL_STORAGE_EXISTS: boolean;
|
3
|
+
export declare const LOCAL_STORAGE_KEY_FOR_VISIBLE_COLUMNS = "generic-table-configurable-columns";
|
4
|
+
export declare const BULK_ACTION_GUTTER_LABEL = "bulk-action-gutter";
|
5
|
+
export declare const EVENT_TARGET: EventTarget;
|
6
|
+
export declare const DRAG_SELECTOR_IDENTIFIER = "table-drag-selector";
|
7
|
+
export declare const TABLE_ID_MAP: {
|
8
|
+
readonly STORYBOOK: "storybook-table";
|
9
|
+
};
|
10
|
+
export declare const SHIMMER_DUMMY_ARRAY: number[];
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { default as Table } from './Table.component';
|
2
|
+
export { FiltersTypeEnum, PaginationEnum, SignalEnum as TableSignalEnum } from './types';
|
3
|
+
export type { ViewWrapperProps as TableViewWrapperProps, Column as TableColumnType, TableProps, CellComponentProps as TableCellComponentProps, } from './types';
|
4
|
+
export { TABLE_ID_MAP } from './constants';
|
@@ -0,0 +1,194 @@
|
|
1
|
+
import { Dispatch, FunctionComponent, PropsWithChildren, SetStateAction } from 'react';
|
2
|
+
import { SortableTableHeaderCellProps, useResizableTableConfig } from '../../../Common/SortableTableHeaderCell';
|
3
|
+
import { UseStateFiltersProps, UseStateFiltersReturnType, UseUrlFiltersProps } from '../../../Common/Hooks';
|
4
|
+
import { GenericEmptyStateType } from '../../../Common/index';
|
5
|
+
import { GenericFilterEmptyStateProps } from '@Common/EmptyState/types';
|
6
|
+
import { TABLE_ID_MAP } from './constants';
|
7
|
+
import { useBulkSelection, UseBulkSelectionProps } from '../BulkSelection';
|
8
|
+
export interface UseFiltersReturnType extends UseStateFiltersReturnType<string> {
|
9
|
+
}
|
10
|
+
export declare enum SignalEnum {
|
11
|
+
ENTER_PRESSED = "enter-pressed",
|
12
|
+
DELETE_PRESSED = "delete-pressed",
|
13
|
+
ESCAPE_PRESSED = "escape-pressed",
|
14
|
+
OPEN_CONTEXT_MENU = "open-context-menu",
|
15
|
+
ROW_CLICKED = "row-clicked"
|
16
|
+
}
|
17
|
+
export interface SignalsType<T extends string = SignalEnum> extends Pick<EventTarget, 'addEventListener' | 'removeEventListener'> {
|
18
|
+
addEventListener: (type: T, callback: (event: CustomEvent) => void, options?: Parameters<EventTarget['addEventListener']>[2]) => ReturnType<EventTarget['addEventListener']>;
|
19
|
+
removeEventListener: (type: T, callback: (event: CustomEvent) => void, options?: Parameters<EventTarget['removeEventListener']>[2]) => ReturnType<EventTarget['removeEventListener']>;
|
20
|
+
}
|
21
|
+
type SizeType = {
|
22
|
+
/** This signifies this column is resizable */
|
23
|
+
range: {
|
24
|
+
startWidth: number;
|
25
|
+
minWidth: number;
|
26
|
+
maxWidth: number | 'infinite';
|
27
|
+
};
|
28
|
+
/** If we want a fixed width */
|
29
|
+
fixed?: never;
|
30
|
+
} | {
|
31
|
+
range?: never;
|
32
|
+
fixed: number;
|
33
|
+
} | null;
|
34
|
+
type BaseColumnType = {
|
35
|
+
/** This is the key using which we will fetch the data of */
|
36
|
+
field: string;
|
37
|
+
/** This is the string that will be displayed to the user as header text */
|
38
|
+
label?: string;
|
39
|
+
/**
|
40
|
+
* If we want resizable columns, then every column has to have a fixed height
|
41
|
+
* If we specify size to be null then the size be will set to 1fr
|
42
|
+
*/
|
43
|
+
size: SizeType;
|
44
|
+
horizontallySticky?: boolean;
|
45
|
+
};
|
46
|
+
interface AdditionalProps {
|
47
|
+
[key: string]: unknown;
|
48
|
+
}
|
49
|
+
export type RowType = {
|
50
|
+
id: string;
|
51
|
+
data: Record<string, unknown>;
|
52
|
+
};
|
53
|
+
export type RowsType = RowType[];
|
54
|
+
export interface CellComponentProps extends Pick<BaseColumnType, 'field'>, AdditionalProps {
|
55
|
+
signals: SignalsType;
|
56
|
+
value: unknown;
|
57
|
+
row: RowType;
|
58
|
+
filterData: UseFiltersReturnType;
|
59
|
+
isRowActive: boolean;
|
60
|
+
}
|
61
|
+
export type Column = Pick<SortableTableHeaderCellProps, 'showTippyOnTruncate'> & BaseColumnType & {
|
62
|
+
CellComponent?: FunctionComponent<CellComponentProps>;
|
63
|
+
} & ({
|
64
|
+
isSortable: true;
|
65
|
+
/**
|
66
|
+
* Compare two rows when sorting is triggered on this column
|
67
|
+
* Values fed are from the field key in the row's data object
|
68
|
+
* @returns -1 if a < b, 0 if a === b, 1 if a > b
|
69
|
+
*/
|
70
|
+
comparator?: (a: unknown, b: unknown) => number;
|
71
|
+
} | {
|
72
|
+
isSortable?: false;
|
73
|
+
comparator?: never;
|
74
|
+
});
|
75
|
+
type BulkSelectionConfigType = Pick<UseBulkSelectionProps<unknown>, 'getSelectAllDialogStatus'> & {
|
76
|
+
/** Make sure to wrap it in useCallback */
|
77
|
+
onBulkSelectionChanged: (selectedRows: RowsType) => void;
|
78
|
+
BulkActionsComponent: FunctionComponent<{}>;
|
79
|
+
};
|
80
|
+
export declare enum PaginationEnum {
|
81
|
+
PAGINATED = "paginated",
|
82
|
+
INFINITE = "infinite",
|
83
|
+
NOT_PAGINATED = "not-paginated"
|
84
|
+
}
|
85
|
+
export declare enum FiltersTypeEnum {
|
86
|
+
STATE = "state",
|
87
|
+
URL = "url",
|
88
|
+
NONE = "none"
|
89
|
+
}
|
90
|
+
export interface ConfigurableColumnsType {
|
91
|
+
allColumns: Column[];
|
92
|
+
visibleColumns: Column[];
|
93
|
+
setVisibleColumns: Dispatch<SetStateAction<ConfigurableColumnsType['visibleColumns']>>;
|
94
|
+
}
|
95
|
+
interface GetRowsProps extends Pick<UseFiltersReturnType, 'offset' | 'pageSize' | 'searchKey' | 'sortBy' | 'sortOrder'> {
|
96
|
+
}
|
97
|
+
type AdditionalFilterPropsType<T extends Exclude<FiltersTypeEnum, FiltersTypeEnum.NONE>> = T extends FiltersTypeEnum.URL ? Pick<UseUrlFiltersProps<string, unknown>, 'parseSearchParams' | 'localStorageKey' | 'redirectionMethod' | 'initialSortKey'> : Pick<UseStateFiltersProps<string>, 'initialSortKey'>;
|
98
|
+
export type ViewWrapperProps = PropsWithChildren<Pick<UseFiltersReturnType, 'offset' | 'handleSearch' | 'searchKey' | 'sortBy' | 'sortOrder' | 'clearFilters'> & AdditionalProps & Partial<ConfigurableColumnsType> & {
|
99
|
+
areRowsLoading: boolean;
|
100
|
+
}>;
|
101
|
+
export type InternalTableProps = Required<Pick<ConfigurableColumnsType, 'visibleColumns' | 'setVisibleColumns'>> & {
|
102
|
+
id: (typeof TABLE_ID_MAP)[keyof typeof TABLE_ID_MAP];
|
103
|
+
loading?: boolean;
|
104
|
+
paginationVariant: PaginationEnum;
|
105
|
+
/**
|
106
|
+
* Memoize columns before passing as props.
|
107
|
+
*
|
108
|
+
* For columns from backend: initialize as empty array and set loading
|
109
|
+
* to true until API call completes.
|
110
|
+
*/
|
111
|
+
columns: Column[];
|
112
|
+
/** If bulk selections are not a concern omit this prop */
|
113
|
+
bulkSelectionConfig?: BulkSelectionConfigType;
|
114
|
+
emptyStateConfig: {
|
115
|
+
noRowsConfig: Omit<GenericEmptyStateType, 'children'>;
|
116
|
+
noRowsForFilterConfig?: Pick<GenericFilterEmptyStateProps, 'title' | 'subTitle'> & {
|
117
|
+
clearFilters: () => void;
|
118
|
+
};
|
119
|
+
};
|
120
|
+
filterData: UseFiltersReturnType | null;
|
121
|
+
resizableConfig: ReturnType<typeof useResizableTableConfig> | null;
|
122
|
+
/**
|
123
|
+
* Enable this to let users choose which columns to display.
|
124
|
+
* Example: Resource Browser > Node Listing
|
125
|
+
*
|
126
|
+
* Using the provided id for this table, we will store the user's preference in localStorage
|
127
|
+
*/
|
128
|
+
areColumnsConfigurable?: boolean;
|
129
|
+
additionalProps?: AdditionalProps;
|
130
|
+
/** Control the look of the table using this prop */
|
131
|
+
stylesConfig?: {
|
132
|
+
showSeparatorBetweenRows: boolean;
|
133
|
+
};
|
134
|
+
/**
|
135
|
+
* Use this component to display additional content at the end of a row when it is hovered over.
|
136
|
+
*/
|
137
|
+
RowActionsOnHoverComponent?: FunctionComponent<{
|
138
|
+
row: RowType;
|
139
|
+
}>;
|
140
|
+
bulkSelectionReturnValue: ReturnType<typeof useBulkSelection> | null;
|
141
|
+
handleClearBulkSelection: () => void;
|
142
|
+
handleToggleBulkSelectionOnRow: (row: RowType) => void;
|
143
|
+
ViewWrapper?: FunctionComponent<ViewWrapperProps>;
|
144
|
+
} & ({
|
145
|
+
/**
|
146
|
+
* Direct rows data for frontend-only datasets like resource browser.
|
147
|
+
*/
|
148
|
+
rows: RowsType;
|
149
|
+
/**
|
150
|
+
* Use `getRows` function instead for data that needs to be fetched from backend with pagination/sorting/filtering.
|
151
|
+
*/
|
152
|
+
getRows?: never;
|
153
|
+
} | {
|
154
|
+
rows?: never;
|
155
|
+
/** NOTE: Sorting on frontend is only handled if rows is provided instead of getRows */
|
156
|
+
getRows: (props: GetRowsProps) => Promise<RowsType>;
|
157
|
+
}) & ({
|
158
|
+
filtersVariant: FiltersTypeEnum.URL;
|
159
|
+
/**
|
160
|
+
* props for useUrlFilters/useStateFilters hooks
|
161
|
+
*/
|
162
|
+
additionalFilterProps?: AdditionalFilterPropsType<FiltersTypeEnum.URL>;
|
163
|
+
/**
|
164
|
+
* This func is used to filter the rows based on filter data.
|
165
|
+
* Only applicable if filtersVariant is NOT set to NONE
|
166
|
+
*
|
167
|
+
* If filter is only being used for sorting, then send `noop` in this prop
|
168
|
+
*/
|
169
|
+
filter: (row: RowType, filterData: UseFiltersReturnType) => boolean;
|
170
|
+
} | {
|
171
|
+
filtersVariant: FiltersTypeEnum.STATE;
|
172
|
+
additionalFilterProps?: AdditionalFilterPropsType<FiltersTypeEnum.STATE>;
|
173
|
+
filter: (row: RowType, filterData: UseFiltersReturnType) => boolean;
|
174
|
+
} | {
|
175
|
+
filtersVariant: FiltersTypeEnum.NONE;
|
176
|
+
additionalFilterProps?: never;
|
177
|
+
filter?: never;
|
178
|
+
});
|
179
|
+
export type UseResizableTableConfigWrapperProps = Omit<InternalTableProps, 'resizableConfig'>;
|
180
|
+
export type TableWithBulkSelectionProps = Omit<UseResizableTableConfigWrapperProps, 'bulkSelectionReturnValue' | 'handleClearBulkSelection' | 'handleToggleBulkSelectionOnRow'>;
|
181
|
+
export type VisibleColumnsWrapperProps = Omit<TableWithBulkSelectionProps, 'visibleColumns' | 'setVisibleColumns'>;
|
182
|
+
export type FilterWrapperProps = Omit<VisibleColumnsWrapperProps, 'filterData'>;
|
183
|
+
export type TableProps = Pick<FilterWrapperProps, 'additionalFilterProps' | 'bulkSelectionConfig' | 'areColumnsConfigurable' | 'emptyStateConfig' | 'filtersVariant' | 'filter' | 'additionalProps' | 'columns' | 'getRows' | 'rows' | 'paginationVariant' | 'stylesConfig' | 'id' | 'RowActionsOnHoverComponent' | 'loading' | 'ViewWrapper'>;
|
184
|
+
export interface BulkSelectionActionWidgetProps extends Pick<BulkSelectionConfigType, 'BulkActionsComponent'> {
|
185
|
+
count: number;
|
186
|
+
handleClearBulkSelection: () => void;
|
187
|
+
parentRef: React.RefObject<HTMLDivElement>;
|
188
|
+
}
|
189
|
+
export type ConfigurableColumnsConfigType = Record<string, ConfigurableColumnsType['visibleColumns']>;
|
190
|
+
export interface GetFilteringPromiseProps {
|
191
|
+
searchSortTimeoutRef: React.MutableRefObject<number>;
|
192
|
+
callback: () => Promise<RowsType> | RowsType;
|
193
|
+
}
|
194
|
+
export {};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { InternalTableProps, RowsType } from './types';
|
2
|
+
declare const useTableWithKeyboardShortcuts: ({ bulkSelectionConfig, handleToggleBulkSelectionOnRow, bulkSelectionReturnValue, }: Pick<InternalTableProps, "bulkSelectionConfig" | "bulkSelectionReturnValue" | "handleToggleBulkSelectionOnRow">, visibleRows: RowsType) => {
|
3
|
+
activeRowIndex: number;
|
4
|
+
setActiveRowIndex: import('react').Dispatch<import('react').SetStateAction<number>>;
|
5
|
+
};
|
6
|
+
export default useTableWithKeyboardShortcuts;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { Column, ConfigurableColumnsType, GetFilteringPromiseProps, RowsType, TableProps, UseFiltersReturnType } from './types';
|
2
|
+
export declare const searchAndSortRows: (rows: TableProps["rows"], filter: TableProps["filter"], filterData: UseFiltersReturnType, comparator?: Column["comparator"]) => RowsType;
|
3
|
+
export declare const getVisibleColumnsFromLocalStorage: ({ allColumns, id, }: Pick<ConfigurableColumnsType, "allColumns"> & Pick<TableProps, "id">) => Column[];
|
4
|
+
export declare const setVisibleColumnsToLocalStorage: ({ id, visibleColumns, }: Pick<ConfigurableColumnsType, "visibleColumns"> & Pick<TableProps, "id">) => void;
|
5
|
+
export declare const getVisibleColumns: ({ areColumnsConfigurable, columns, id, }: Pick<TableProps, "areColumnsConfigurable" | "columns" | "id">) => Column[];
|
6
|
+
export declare const getFilteringPromise: ({ searchSortTimeoutRef, callback }: GetFilteringPromiseProps) => Promise<RowsType>;
|
package/dist/Shared/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
2
2
|
import { APIOptions, ApprovalConfigDataType } from '../Common/Types';
|
3
|
-
import { OptionType, CommonNodeAttr, VulnerabilityType, DeploymentAppTypes, ServerErrors, SortingParams, TriggerBlockType, ValueConstraintType, VariableType, RefVariableType, PluginType } from '../Common';
|
3
|
+
import { OptionType, CommonNodeAttr, VulnerabilityType, DeploymentAppTypes, ServerErrors, SortingParams, TriggerBlockType, ValueConstraintType, VariableType, RefVariableType, PluginType, SegmentedControlProps } from '../Common';
|
4
4
|
import { BASE_CONFIGURATION_ENV_ID, EnvironmentTypeEnum, PatchOperationType } from './constants';
|
5
5
|
import { SelectPickerOptionType } from './Components';
|
6
6
|
export declare enum EnvType {
|
@@ -598,7 +598,7 @@ export declare enum ConfigurationType {
|
|
598
598
|
GUI = "GUI",
|
599
599
|
YAML = "YAML"
|
600
600
|
}
|
601
|
-
export declare const CONFIGURATION_TYPE_OPTIONS:
|
601
|
+
export declare const CONFIGURATION_TYPE_OPTIONS: SegmentedControlProps['segments'];
|
602
602
|
export interface BaseURLParams {
|
603
603
|
appId: string;
|
604
604
|
envId: string;
|