@devtron-labs/devtron-fe-common-lib 0.0.56 → 0.0.58-beta-3

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.
Files changed (48) hide show
  1. package/.eslintignore +96 -0
  2. package/.eslintrc.js +84 -16
  3. package/.github/pull_request_template.md +25 -0
  4. package/.github/workflows/ci.yml +31 -0
  5. package/.github/workflows/release-package.yml +2 -3
  6. package/.husky/pre-commit +5 -0
  7. package/.lintstagedrc +3 -0
  8. package/.nvmrc +1 -0
  9. package/dist/Common/Common.service.d.ts +2 -2
  10. package/dist/Common/Constants.d.ts +0 -8
  11. package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
  12. package/dist/Common/CustomInput/Types.d.ts +0 -1
  13. package/dist/Common/DebouncedSearch/DebouncedSearch.d.ts +2 -0
  14. package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
  15. package/dist/Common/Helper.d.ts +8 -1
  16. package/dist/Common/Pagination/PageSizeSelector.d.ts +4 -0
  17. package/dist/Common/Pagination/Pagination.d.ts +5 -0
  18. package/dist/Common/Pagination/constants.d.ts +5 -0
  19. package/dist/Common/Pagination/index.d.ts +1 -0
  20. package/dist/Common/Pagination/types.d.ts +51 -0
  21. package/dist/Common/Pagination/utils.d.ts +6 -0
  22. package/dist/Common/SearchBar/SearchBar.component.d.ts +39 -0
  23. package/dist/Common/SearchBar/index.d.ts +2 -0
  24. package/dist/Common/SearchBar/types.d.ts +35 -0
  25. package/dist/Common/Types.d.ts +15 -3
  26. package/dist/Common/index.d.ts +2 -0
  27. package/dist/index.js +462 -229
  28. package/package.json +19 -2
  29. package/src/Assets/Icon/ic-search.svg +6 -0
  30. package/src/Common/Constants.ts +0 -9
  31. package/src/Common/CustomInput/CustomInput.tsx +2 -3
  32. package/src/Common/CustomInput/Types.ts +0 -1
  33. package/src/Common/DebouncedSearch/DebouncedSearch.tsx +2 -0
  34. package/src/Common/EmptyState/GenericEmptyState.tsx +13 -45
  35. package/src/Common/Helper.tsx +45 -16
  36. package/src/Common/Pagination/PageSizeSelector.tsx +78 -0
  37. package/src/Common/Pagination/Pagination.tsx +127 -0
  38. package/src/Common/Pagination/constants.ts +6 -0
  39. package/src/Common/Pagination/index.tsx +3 -0
  40. package/src/Common/Pagination/pagination.scss +123 -0
  41. package/src/Common/Pagination/types.ts +55 -0
  42. package/src/Common/Pagination/utils.tsx +24 -0
  43. package/src/Common/SearchBar/SearchBar.component.tsx +120 -0
  44. package/src/Common/SearchBar/index.ts +2 -0
  45. package/src/Common/SearchBar/searchBar.scss +31 -0
  46. package/src/Common/SearchBar/types.ts +36 -0
  47. package/src/Common/Types.ts +15 -3
  48. package/src/Common/index.ts +2 -0
package/.eslintignore ADDED
@@ -0,0 +1,96 @@
1
+ .eslintrc.js
2
+
3
+ # Files with ESLint errors/warnings
4
+ src/Common/AddCDButton/AddCDButton.tsx
5
+ src/Common/AddCDButton/utils.tsx
6
+ src/Common/Api.ts
7
+ src/Common/AppStatus/AppStatus.tsx
8
+ src/Common/AppStatus/index.ts
9
+ src/Common/AppStatus/utils.ts
10
+ src/Common/BreadCrumb/BreadCrumb.tsx
11
+ src/Common/BreadCrumb/BreadcrumbStore.tsx
12
+ src/Common/BreadCrumb/Types.ts
13
+ src/Common/CIPipeline.Types.ts
14
+ src/Common/ChartVersionAndTypeSelector.tsx
15
+ src/Common/Checkbox.tsx
16
+ src/Common/ClipboardButton/ClipboardButton.tsx
17
+ src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx
18
+ src/Common/Common.service.ts
19
+ src/Common/Constants.ts
20
+ src/Common/CustomInput/CustomInput.tsx
21
+ src/Common/CustomInput/Types.ts
22
+ src/Common/CustomInput/index.ts
23
+ src/Common/CustomTagSelector/PropagateTagInfo.tsx
24
+ src/Common/CustomTagSelector/ResizableTagTextArea.tsx
25
+ src/Common/CustomTagSelector/TagDetails.tsx
26
+ src/Common/CustomTagSelector/TagLabelSelect.tsx
27
+ src/Common/CustomTagSelector/TagLabelValueSelector.tsx
28
+ src/Common/CustomTagSelector/TagSelector.utils.ts
29
+ src/Common/CustomTagSelector/Types.ts
30
+ src/Common/CustomTagSelector/ValidationRules.ts
31
+ src/Common/CustomTagSelector/index.ts
32
+ src/Common/DebouncedSearch/DebouncedSearch.tsx
33
+ src/Common/DebouncedSearch/Utils.ts
34
+ src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx
35
+ src/Common/DeleteComponentModal/DeleteComponent.tsx
36
+ src/Common/DeleteComponentModal/types.ts
37
+ src/Common/DevtronProgressing/DevtronProgressing.tsx
38
+ src/Common/Dialogs/ConfirmationDialog.tsx
39
+ src/Common/Dialogs/DeleteDialog.tsx
40
+ src/Common/Dialogs/DialogForm.tsx
41
+ src/Common/Dialogs/ForceDeleteDialog.tsx
42
+ src/Common/Dialogs/Types.ts
43
+ src/Common/Dialogs/index.ts
44
+ src/Common/DraggableWrapper/DraggableButton.tsx
45
+ src/Common/DraggableWrapper/DraggableWrapper.tsx
46
+ src/Common/Drawer/Drawer.tsx
47
+ src/Common/EmptyState/EmptyState.tsx
48
+ src/Common/EmptyState/GenericEmptyState.tsx
49
+ src/Common/Error.tsx
50
+ src/Common/ErrorScreenNotFound.tsx
51
+ src/Common/Grid/Grid.tsx
52
+ src/Common/Helper.tsx
53
+ src/Common/Hooks/UseClickOutside/UseClickOutside.tsx
54
+ src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx
55
+ src/Common/Hooks/UseWindowSize/UseWindowSize.tsx
56
+ src/Common/ImageTags.Types.ts
57
+ src/Common/ImageTags.tsx
58
+ src/Common/InfoColorBar/InfoColourbar.tsx
59
+ src/Common/Modals/Modal.tsx
60
+ src/Common/Modals/OpaqueModal.tsx
61
+ src/Common/Modals/VisibleModal.tsx
62
+ src/Common/Modals/VisibleModal2.tsx
63
+ src/Common/MultiSelectCustomization.tsx
64
+ src/Common/Policy.Types.ts
65
+ src/Common/PopupMenu.tsx
66
+ src/Common/Progressing.tsx
67
+ src/Common/RJSF/Form.tsx
68
+ src/Common/RJSF/common/FieldRow.tsx
69
+ src/Common/RJSF/config.ts
70
+ src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx
71
+ src/Common/RJSF/templates/ArrayFieldTemplate.tsx
72
+ src/Common/RJSF/templates/BaseInput.tsx
73
+ src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx
74
+ src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx
75
+ src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx
76
+ src/Common/RJSF/templates/Description.tsx
77
+ src/Common/RJSF/templates/Field.tsx
78
+ src/Common/RJSF/templates/FieldErrorTemplate.tsx
79
+ src/Common/RJSF/templates/ObjectFieldTemplate.tsx
80
+ src/Common/RJSF/templates/TitleField.tsx
81
+ src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx
82
+ src/Common/RJSF/utils.ts
83
+ src/Common/RJSF/widgets/Checkbox.tsx
84
+ src/Common/RJSF/widgets/Select.tsx
85
+ src/Common/RadioGroup.tsx
86
+ src/Common/RadioGroup/RadioGroup.tsx
87
+ src/Common/Reload.tsx
88
+ src/Common/ResizableTextarea.tsx
89
+ src/Common/Security/ScanVulnerabilitiesTable.tsx
90
+ src/Common/ServerError.ts
91
+ src/Common/TippyCustomized.tsx
92
+ src/Common/ToastBody.tsx
93
+ src/Common/Toggle/Toggle.tsx
94
+ src/Common/Types.ts
95
+ src/custom.d.ts
96
+ src/index.ts
package/.eslintrc.js CHANGED
@@ -1,41 +1,109 @@
1
1
  module.exports = {
2
2
  parser: '@typescript-eslint/parser',
3
- plugins: ['@typescript-eslint'],
3
+ plugins: ['@typescript-eslint', 'react', 'prettier'],
4
4
  env: {
5
- commonjs: true,
6
5
  browser: true,
7
- es6: true,
6
+ es2021: true,
8
7
  },
9
8
  parserOptions: {
10
- ecmaVersion: 2018,
9
+ ecmaVersion: 2021,
11
10
  sourceType: 'module',
12
11
  ecmaFeatures: {
13
12
  jsx: true,
14
13
  },
15
14
  project: ['./tsconfig.json'],
16
15
  },
16
+ globals: {
17
+ JSX: true,
18
+ },
19
+ extends: [
20
+ 'eslint:recommended',
21
+ 'plugin:react/recommended',
22
+ 'plugin:react/jsx-runtime',
23
+ 'plugin:@typescript-eslint/eslint-recommended',
24
+ 'airbnb',
25
+ 'airbnb/hooks',
26
+ 'prettier',
27
+ ],
17
28
  rules: {
29
+ 'prettier/prettier': ['error'],
30
+ 'linebreak-style': ['error', 'unix'],
31
+ 'no-console': 'warn',
18
32
  'no-var': 'error',
19
33
  'no-duplicate-imports': 'error',
34
+ 'no-shadow': 'off',
35
+ '@typescript-eslint/no-shadow': 'warn',
20
36
  '@typescript-eslint/explicit-function-return-type': 'off',
21
- '@typescript-eslint/no-explicit-any': 'off',
22
- '@typescript-eslint/no-use-before-define': 'off',
23
37
  '@typescript-eslint/explicit-member-accessibility': 'off',
24
- curly: [2, 'all'],
25
- 'keyword-spacing': 'error',
26
- 'prettier/prettier': ['error', { semi: false }],
38
+ // Since we are using typescript, we can disable the no-unused-vars rule for enum,etc
39
+ 'no-unused-vars': 'off',
40
+ '@typescript-eslint/no-unused-vars': 'error',
41
+ 'react/jsx-filename-extension': [
42
+ 'error',
43
+ {
44
+ extensions: ['tsx'],
45
+ },
46
+ ],
47
+ 'react/jsx-props-no-spreading': 'off',
48
+ 'react/prefer-stateless-function': 'off',
49
+ 'jsx-a11y/click-events-have-key-events': 'off',
50
+ 'jsx-a11y/no-static-element-interactions': 'off',
51
+ 'jsx-a11y/no-noninteractive-element-interactions': 'off',
52
+ 'no-underscore-dangle': 'off',
53
+ 'import/no-extraneous-dependencies': [
54
+ 'warn',
55
+ {
56
+ devDependencies: true,
57
+ },
58
+ ],
59
+ 'no-plusplus': [
60
+ 'error',
61
+ {
62
+ allowForLoopAfterthoughts: true,
63
+ },
64
+ ],
65
+ // Since we dont use prop-types, we can disable this rule
66
+ 'react/require-default-props': 'off',
67
+ 'react-hooks/exhaustive-deps': 'off',
68
+ 'react/function-component-definition': [
69
+ 'warn',
70
+ {
71
+ namedComponents: 'arrow-function',
72
+ unnamedComponents: 'arrow-function',
73
+ },
74
+ ],
75
+ 'react/jsx-uses-react': 'off',
76
+ 'react/react-in-jsx-scope': 'off',
77
+ // additional rules:
78
+ '@typescript-eslint/no-floating-promises': 'error',
79
+ 'import/extensions': [
80
+ 'warn',
81
+ 'ignorePackages',
82
+ {
83
+ js: 'never',
84
+ jsx: 'never',
85
+ ts: 'never',
86
+ tsx: 'never',
87
+ },
88
+ ],
27
89
  },
28
- extends: [
29
- 'eslint:recommended',
30
- 'plugin:@typescript-eslint/eslint-recommended',
31
- 'plugin:@typescript-eslint/recommended',
32
- 'prettier/@typescript-eslint',
33
- 'plugin:prettier/recommended',
34
- 'plugin:react/recommended',
90
+ overrides: [
91
+ {
92
+ files: ['*.ts', '*.tsx'],
93
+ rules: {
94
+ 'no-undef': 'off',
95
+ },
96
+ },
35
97
  ],
36
98
  settings: {
37
99
  react: {
38
100
  version: 'detect',
39
101
  },
102
+ 'import/resolver': {
103
+ node: {
104
+ moduleDirectory: ['src', 'node_modules'],
105
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
106
+ },
107
+ },
40
108
  },
41
109
  }
@@ -0,0 +1,25 @@
1
+ # Description
2
+
3
+ Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4
+
5
+ ## Type of change
6
+
7
+ - [ ] Bug fix (non-breaking change which fixes an issue)
8
+ - [ ] New feature (non-breaking change which adds functionality)
9
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10
+ - [ ] This change requires a documentation update
11
+
12
+ ## How Has This Been Tested?
13
+
14
+ Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
15
+
16
+ - [ ] Test A
17
+ - [ ] Test B
18
+
19
+ ## Checklist
20
+
21
+ - [ ] The title of the PR states what changed and the related issues number (used for the release note).
22
+ - [ ] Does this PR require documentation updates?
23
+ - [ ] I've updated documentation as required by this PR.
24
+ - [ ] I have performed a self-review of my own code
25
+ - [ ] I have commented my code, particularly in hard-to-understand areas
@@ -0,0 +1,31 @@
1
+ name: Common Lib CI
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - synchronize
8
+ - edited
9
+ - reopened
10
+
11
+ jobs:
12
+ ci:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v3
17
+
18
+ - name: Use Node.js
19
+ uses: actions/setup-node@v3
20
+ with:
21
+ node-version-file: '.nvmrc'
22
+ cache: 'npm'
23
+
24
+ - name: Install dependencies
25
+ run: npm ci
26
+
27
+ - name: Check linting issues
28
+ run: npm run lint
29
+
30
+ - name: Build Lib
31
+ run: npm run build-lib
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v3
12
12
  - uses: actions/setup-node@v3
13
13
  with:
14
- node-version: 16
14
+ node-version-file: '.nvmrc'
15
15
  - run: npm ci
16
16
  - run: npm test
17
17
 
@@ -25,7 +25,7 @@ jobs:
25
25
  - uses: actions/checkout@v3
26
26
  - uses: actions/setup-node@v3
27
27
  with:
28
- node-version: 16
28
+ node-version-file: '.nvmrc'
29
29
  registry-url: https://npm.pkg.github.com/
30
30
  - run: npm ci
31
31
  - run: npm run build-lib
@@ -46,4 +46,3 @@ jobs:
46
46
  - run: npm publish --access public
47
47
  env:
48
48
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49
-
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx tsc --noEmit
5
+ npm run lint-staged
package/.lintstagedrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "*.{js,jsx,ts,tsx}": ["npx eslint"]
3
+ }
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ v16.13.0
@@ -12,9 +12,9 @@ export declare const SourceTypeMap: {
12
12
  BranchRegex: string;
13
13
  };
14
14
  export declare function getUserRole(appName?: string): Promise<UserRole>;
15
- export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
15
+ export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType<any>>;
16
16
  export declare const genericCDMaterialsService: (serviceType: CDMaterialServiceEnum, cdMaterialID: number, stage: DeploymentNodeType, signal: AbortSignal, queryParams?: CDMaterialServiceQueryParams) => Promise<CDMaterialResponseType>;
17
17
  export declare function extractImage(image: string): string;
18
18
  export declare function createGitCommitUrl(url: string, revision: string): string;
19
- export declare function fetchChartTemplateVersions(): Promise<ResponseType>;
19
+ export declare function fetchChartTemplateVersions(): Promise<ResponseType<any>>;
20
20
  export {};
@@ -64,12 +64,4 @@ export declare const RepositoryAction: {
64
64
  CHART_PULL: string;
65
65
  CHART_PUSH: string;
66
66
  };
67
- export declare enum APPROVAL_MODAL_TYPE {
68
- CONFIG = "CONFIG",
69
- DEPLOYMENT = "DEPLOYMENT"
70
- }
71
67
  export declare const MAX_Z_INDEX = 2147483647;
72
- export declare const SELECTED_APPROVAL_TAB_STATE: {
73
- APPROVAL: string;
74
- PENDING: string;
75
- };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { CustomInputProps } from './Types';
3
- export declare function CustomInput({ name, value, error, onChange, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, helperText, handleOnBlur, readOnly, noTrim, ref, onKeyPress, defaultValue, onKeyDown, required, additionalErrorInfo, inputWrapClassName, }: CustomInputProps): JSX.Element;
3
+ export declare function CustomInput({ name, value, error, onChange, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, helperText, handleOnBlur, readOnly, noTrim, ref, onKeyPress, defaultValue, onKeyDown, required, additionalErrorInfo }: CustomInputProps): JSX.Element;
@@ -26,5 +26,4 @@ export interface CustomInputProps {
26
26
  onKeyDown?: (e: any) => void;
27
27
  required?: boolean;
28
28
  additionalErrorInfo?: React.ReactNode;
29
- inputWrapClassName?: string;
30
29
  }
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { DebouncedSearchProps } from './Types';
3
3
  /**
4
+ * @deprecated Use `SearchBar` component instead.
5
+ *
4
6
  * @param onSearch - Callback function to be called on search
5
7
  * @param Icon - (Optional) Icon to be shown before the input
6
8
  * @param iconClass - (Optional) Class for the icon
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { GenericEmptyStateType } from '../Types';
3
3
  import './emptyState.scss';
4
- declare function GenericEmptyState({ title, image, subTitle, isButtonAvailable, classname, styles, heightToDeduct, imageType, renderButton, imageClassName, children, SvgImage, noImage, layout, contentClassName, imageStyles, }: GenericEmptyStateType): JSX.Element;
4
+ declare function GenericEmptyState({ title, image, subTitle, isButtonAvailable, classname, styles, heightToDeduct, imageType, renderButton, imageClassName, children, SvgImage, noImage, layout, contentClassName }: GenericEmptyStateType): JSX.Element;
5
5
  export default GenericEmptyState;
@@ -55,6 +55,13 @@ export declare const customStyles: {
55
55
  dropdownIndicator: (base: any, state: any) => any;
56
56
  };
57
57
  export declare const getFilteredChartVersions: (charts: any, selectedChartType: any) => any;
58
- export declare function getUnlockedJSON(json: any, jsonPathArray: any): any;
58
+ export declare function getUnlockedJSON(json: any, jsonPathArray: any, removeParentKeysAndEmptyArrays?: boolean): {
59
+ newDocument: any;
60
+ removedPatches: any[];
61
+ };
59
62
  export declare function getLockedJSON(json: any, jsonPathArray: string[]): any;
63
+ /**
64
+ * Returns a debounced variant of the function
65
+ */
66
+ export declare const debounce: (func: any, timeout?: number) => (this: any, ...args: any[]) => void;
60
67
  export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { PageSizeSelectorProps } from './types';
3
+ declare const PageSizeSelector: ({ pageSizeOptions, pageSize, changePageSize }: PageSizeSelectorProps) => JSX.Element;
4
+ export default PageSizeSelector;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { PaginationProps } from './types';
3
+ import './pagination.scss';
4
+ declare const Pagination: ({ size, pageSize, offset, changePage, changePageSize, isPageSizeFix, pageSizeOptions, rootClassName, }: PaginationProps) => JSX.Element;
5
+ export default Pagination;
@@ -0,0 +1,5 @@
1
+ export declare const VISIBLE_PAGES_LIMIT = 5;
2
+ export declare const FALLBACK_PAGE_SIZE_OPTIONS: {
3
+ value: number;
4
+ selected: boolean;
5
+ }[];
@@ -0,0 +1 @@
1
+ export { default as Pagination } from './Pagination';
@@ -0,0 +1,51 @@
1
+ /// <reference types="react" />
2
+ export interface PageSizeOption {
3
+ value: number;
4
+ selected: boolean;
5
+ }
6
+ export interface PaginationProps {
7
+ /**
8
+ * number of items
9
+ */
10
+ size: number;
11
+ /**
12
+ * pageSize
13
+ */
14
+ pageSize: number;
15
+ offset: number;
16
+ changePage: (pageNo: number) => void;
17
+ changePageSize?: (pageSize: number) => void;
18
+ /**
19
+ * If true will not show page size selector
20
+ */
21
+ isPageSizeFix?: boolean;
22
+ /**
23
+ * If given would show these options in page size selector else [20,40,50] with 20 as selected
24
+ */
25
+ pageSizeOptions?: PageSizeOption[];
26
+ /**
27
+ * class for wrapper
28
+ */
29
+ rootClassName?: string;
30
+ }
31
+ export interface Page {
32
+ value: number;
33
+ selected: boolean;
34
+ isVisible: boolean;
35
+ }
36
+ export interface CreatePageArrType extends Pick<PaginationProps, 'size' | 'pageSize'> {
37
+ selectedPageNo: number;
38
+ }
39
+ export interface PageSizeSelectorProps extends Pick<PaginationProps, 'pageSizeOptions' | 'pageSize' | 'changePageSize'> {
40
+ }
41
+ export interface PageSizeItemsProps extends Pick<PageSizeSelectorProps, 'changePageSize'> {
42
+ optionValue: PageSizeOption['value'];
43
+ options: PageSizeOption[];
44
+ setOptions: React.Dispatch<React.SetStateAction<PageSizeOption[]>>;
45
+ handleCloseDropdown: () => void;
46
+ }
47
+ export interface PageValueItemProps {
48
+ value: PageSizeOption['value'];
49
+ isSelected: PageSizeOption['selected'];
50
+ selectPage: (selectedPageNo: number) => void;
51
+ }
@@ -0,0 +1,6 @@
1
+ import { CreatePageArrType, Page, PageSizeOption } from './types';
2
+ /**
3
+ * Returns an array of pages numbers and whether they are selected, visible or not
4
+ */
5
+ export declare const createPageArr: ({ size, pageSize, selectedPageNo }: CreatePageArrType) => Page[];
6
+ export declare const getDefaultPageValueOptions: (pageSizeOptions: PageSizeOption[]) => PageSizeOption[];
@@ -0,0 +1,39 @@
1
+ /// <reference types="react" />
2
+ import { SearchBarProps } from './types';
3
+ import './searchBar.scss';
4
+ /**
5
+ * Generic search input component with support for enter based and debounced search
6
+ * Note: The component is uncontrolled
7
+ *
8
+ * @example Usage with default debounced search
9
+ * ```tsx
10
+ * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce />
11
+ * ```
12
+ *
13
+ * @example Initial search text
14
+ * ```tsx
15
+ * <SearchBar initialSearchText="Keyword" />
16
+ * ```
17
+ *
18
+ * @example Custom width
19
+ * ```tsx
20
+ * <SearchBar containerClassName="w-300" />
21
+ * ```
22
+ *
23
+ * @example Trigger search on enter key press
24
+ * ```tsx
25
+ * <SearchBar handleEnter={triggerSearchApi} />
26
+ * ```
27
+ *
28
+ * @example Custom timeout for debounced search
29
+ * ```tsx
30
+ * <SearchBar handleSearchChange={triggerSearchApi} shouldDebounce debounceTimeout={500} />
31
+ * ```
32
+ *
33
+ * @example Placeholder for the search
34
+ * ```tsx
35
+ * <SearchBar inputProps={{ placeholder: 'Enter search text' }} />
36
+ * ```
37
+ */
38
+ declare const SearchBar: ({ initialSearchText, handleSearchChange, handleEnter, inputProps, containerClassName, shouldDebounce, debounceTimeout, }: SearchBarProps) => JSX.Element;
39
+ export default SearchBar;
@@ -0,0 +1,2 @@
1
+ export { default as SearchBar } from './SearchBar.component';
2
+ export type { SearchBarProps } from './types';
@@ -0,0 +1,35 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export interface SearchBarProps {
3
+ /**
4
+ * Initial search text
5
+ *
6
+ * @default ''
7
+ */
8
+ initialSearchText?: string;
9
+ /**
10
+ * Search handler for the search input
11
+ */
12
+ handleSearchChange?: (searchText: string) => void;
13
+ /**
14
+ * Enter event handler for the search input
15
+ */
16
+ handleEnter?: (searchText: string) => void;
17
+ /**
18
+ * Input props for the search input
19
+ */
20
+ inputProps?: InputHTMLAttributes<HTMLInputElement>;
21
+ /**
22
+ * Class name for the container; can be used for handling width
23
+ */
24
+ containerClassName?: string;
25
+ /**
26
+ * If true, the change handler would be triggered with debounce
27
+ *
28
+ * @default false
29
+ */
30
+ shouldDebounce?: boolean;
31
+ /**
32
+ * Timeout for the debounce handler to be triggered
33
+ */
34
+ debounceTimeout?: number;
35
+ }
@@ -2,10 +2,23 @@ import React, { ReactNode, CSSProperties } from 'react';
2
2
  import { Placement } from 'tippy.js';
3
3
  import { ImageComment, ReleaseTag } from './ImageTags.Types';
4
4
  import { DockerConfigOverrideType, TaskErrorObj } from '.';
5
- export interface ResponseType {
5
+ /**
6
+ * Generic response type object with support for overriding the result type
7
+ *
8
+ * @example Default usage:
9
+ * ```ts
10
+ * interface UserResponse extends ResponseType {}
11
+ * ```
12
+ *
13
+ * @example Override the response type:
14
+ * ```ts
15
+ * interface UserResponse extends ResponseType<Record<string, string>> {}
16
+ * ```
17
+ */
18
+ export interface ResponseType<T = any> {
6
19
  code: number;
7
20
  status: string;
8
- result?: any;
21
+ result?: T;
9
22
  errors?: any;
10
23
  }
11
24
  export interface APIOptions {
@@ -87,7 +100,6 @@ export interface GenericEmptyStateType {
87
100
  imageClassName?: string;
88
101
  children?: ReactNode;
89
102
  noImage?: boolean;
90
- imageStyles?: CSSProperties;
91
103
  /**
92
104
  * @default 'column'
93
105
  */
@@ -26,6 +26,7 @@ export * from './Common.service';
26
26
  export * from './Checkbox';
27
27
  export { default as EmptyState } from './EmptyState/EmptyState';
28
28
  export { default as GenericEmptyState } from './EmptyState/GenericEmptyState';
29
+ export * from './SearchBar';
29
30
  export { default as Toggle } from './Toggle/Toggle';
30
31
  export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable';
31
32
  export { default as StyledRadioGroup } from './RadioGroup/RadioGroup';
@@ -46,3 +47,4 @@ export { default as ChartVersionAndTypeSelector } from './ChartVersionAndTypeSel
46
47
  export * from './AddCDButton';
47
48
  export * from './CustomInput';
48
49
  export * from './DraggableWrapper';
50
+ export * from './Pagination';