@devtron-labs/devtron-fe-common-lib 0.0.55 → 0.0.56

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/.eslintrc.js +16 -84
  2. package/.github/workflows/release-package.yml +3 -2
  3. package/dist/Common/Common.service.d.ts +2 -2
  4. package/dist/Common/Constants.d.ts +8 -0
  5. package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
  6. package/dist/Common/CustomInput/Types.d.ts +1 -0
  7. package/dist/Common/DebouncedSearch/DebouncedSearch.d.ts +0 -2
  8. package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
  9. package/dist/Common/Helper.d.ts +0 -4
  10. package/dist/Common/Types.d.ts +3 -15
  11. package/dist/Common/index.d.ts +0 -2
  12. package/dist/index.js +214 -430
  13. package/package.json +2 -19
  14. package/src/Common/Constants.ts +9 -0
  15. package/src/Common/CustomInput/CustomInput.tsx +3 -2
  16. package/src/Common/CustomInput/Types.ts +1 -0
  17. package/src/Common/DebouncedSearch/DebouncedSearch.tsx +0 -2
  18. package/src/Common/EmptyState/GenericEmptyState.tsx +45 -13
  19. package/src/Common/Helper.tsx +0 -15
  20. package/src/Common/Types.ts +3 -15
  21. package/src/Common/index.ts +0 -2
  22. package/.eslintignore +0 -96
  23. package/.github/pull_request_template.md +0 -25
  24. package/.github/workflows/ci.yml +0 -31
  25. package/.husky/pre-commit +0 -5
  26. package/.lintstagedrc +0 -3
  27. package/.nvmrc +0 -1
  28. package/dist/Common/Pagination/PageSizeSelector.d.ts +0 -4
  29. package/dist/Common/Pagination/Pagination.d.ts +0 -5
  30. package/dist/Common/Pagination/constants.d.ts +0 -5
  31. package/dist/Common/Pagination/index.d.ts +0 -1
  32. package/dist/Common/Pagination/types.d.ts +0 -51
  33. package/dist/Common/Pagination/utils.d.ts +0 -6
  34. package/dist/Common/SearchBar/SearchBar.component.d.ts +0 -39
  35. package/dist/Common/SearchBar/index.d.ts +0 -2
  36. package/dist/Common/SearchBar/types.d.ts +0 -35
  37. package/src/Assets/Icon/ic-search.svg +0 -6
  38. package/src/Common/Pagination/PageSizeSelector.tsx +0 -78
  39. package/src/Common/Pagination/Pagination.tsx +0 -127
  40. package/src/Common/Pagination/constants.ts +0 -6
  41. package/src/Common/Pagination/index.tsx +0 -3
  42. package/src/Common/Pagination/pagination.scss +0 -123
  43. package/src/Common/Pagination/types.ts +0 -55
  44. package/src/Common/Pagination/utils.tsx +0 -24
  45. package/src/Common/SearchBar/SearchBar.component.tsx +0 -120
  46. package/src/Common/SearchBar/index.ts +0 -2
  47. package/src/Common/SearchBar/searchBar.scss +0 -31
  48. package/src/Common/SearchBar/types.ts +0 -36
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "prepare": "node -e \"try { require('husky').install() } catch (e) {}\"",
8
- "lint": "tsc --noEmit && eslint 'src/**/*.{js,jsx,ts,tsx}' --max-warnings 0",
9
- "lint-fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
10
7
  "test": "exit 0",
11
8
  "build-lib": "rollup -c --bundleConfigAsCjs",
12
- "build-watch": "rollup -c --bundleConfigAsCjs -w",
13
- "lint-staged": "lint-staged"
9
+ "build-watch": "rollup -c --bundleConfigAsCjs -w"
14
10
  },
15
11
  "repository": {
16
12
  "type": "git",
@@ -34,20 +30,7 @@
34
30
  "@types/react": "17.0.39",
35
31
  "@types/react-dom": "17.0.13",
36
32
  "@types/react-router-dom": "^5.3.3",
37
- "@typescript-eslint/eslint-plugin": "^6.17.0",
38
- "@typescript-eslint/parser": "^6.17.0",
39
- "eslint": "^8.56.0",
40
- "eslint-config-airbnb": "^19.0.4",
41
- "eslint-config-prettier": "^9.1.0",
42
- "eslint-plugin-import": "^2.29.1",
43
- "eslint-plugin-jsx-a11y": "^6.8.0",
44
- "eslint-plugin-prettier": "^5.1.2",
45
- "eslint-plugin-react": "^7.33.2",
46
- "eslint-plugin-react-hooks": "^4.6.0",
47
- "husky": "^7.0.4",
48
- "lint-staged": "^12.5.0",
49
33
  "moment": "^2.29.4",
50
- "prettier": "^3.1.1",
51
34
  "react-select": "5.2.2",
52
35
  "react-toastify": "^8.2.0",
53
36
  "rollup": "^3.10.0",
@@ -242,4 +242,13 @@ export const RepositoryAction = {
242
242
  CHART_PUSH: "CHART_PUSH"
243
243
  }
244
244
 
245
+ export enum APPROVAL_MODAL_TYPE {
246
+ CONFIG = 'CONFIG',
247
+ DEPLOYMENT = 'DEPLOYMENT',
248
+ }
245
249
  export const MAX_Z_INDEX = 2147483647
250
+
251
+ export const SELECTED_APPROVAL_TAB_STATE = {
252
+ APPROVAL: 'approval',
253
+ PENDING: 'pending',
254
+ }
@@ -28,7 +28,8 @@ export function CustomInput({
28
28
  defaultValue,
29
29
  onKeyDown,
30
30
  required,
31
- additionalErrorInfo
31
+ additionalErrorInfo,
32
+ inputWrapClassName = '',
32
33
  }: CustomInputProps) {
33
34
 
34
35
  function handleError(error: any): any[] {
@@ -92,7 +93,7 @@ export function CustomInput({
92
93
  }
93
94
 
94
95
  return (
95
- <div className="flex column left top">
96
+ <div className={`flex column left top ${inputWrapClassName}`}>
96
97
  {renderInputLabel()}
97
98
  <input
98
99
  data-testid={dataTestid}
@@ -27,4 +27,5 @@ export interface CustomInputProps {
27
27
  onKeyDown?: (e) => void
28
28
  required?: boolean
29
29
  additionalErrorInfo?: React.ReactNode
30
+ inputWrapClassName?: string
30
31
  }
@@ -4,8 +4,6 @@ import { ReactComponent as ICClear } from '../../Assets/Icon/ic-error-cross.svg'
4
4
  import { DebouncedSearchProps } from './Types'
5
5
 
6
6
  /**
7
- * @deprecated Use `SearchBar` component instead.
8
- *
9
7
  * @param onSearch - Callback function to be called on search
10
8
  * @param Icon - (Optional) Icon to be shown before the input
11
9
  * @param iconClass - (Optional) Class for the icon
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from 'react'
2
2
  import AppNotDeployed from '../../Assets/Img/app-not-deployed.png'
3
3
  import { GenericEmptyStateType, ImageType } from '../Types'
4
4
 
@@ -19,24 +19,56 @@ function GenericEmptyState({
19
19
  SvgImage,
20
20
  noImage,
21
21
  layout = 'column',
22
- contentClassName = ''
22
+ contentClassName = '',
23
+ imageStyles = {},
23
24
  }: GenericEmptyStateType): JSX.Element {
24
- const isRowLayout = layout === 'row';
25
-
25
+ const isRowLayout = layout === 'row'
26
+
27
+ const getImageSize = () => {
28
+ switch (imageType) {
29
+ case ImageType.Large:
30
+ return { width: '250px', height: '200px' }
31
+ default:
32
+ return { width: '200px', height: '160px' }
33
+ }
34
+ }
35
+
26
36
  return (
27
37
  <div
28
- className={`flex ${isRowLayout ? 'dc__gap-32' : 'column dc__gap-20'} empty-state ${classname ? classname : ''}`}
38
+ className={`flex ${isRowLayout ? 'dc__gap-32' : 'column dc__gap-20'} empty-state ${
39
+ classname ? classname : ''
40
+ }`}
29
41
  style={styles}
30
42
  data-testid="generic-empty-state"
31
43
  {...(heightToDeduct >= 0 && { style: { ...styles, height: `calc(100vh - ${heightToDeduct}px)` } })}
32
- >
33
- {!SvgImage ? !noImage && <img className={imageClassName ? imageClassName : ''}
34
- src={image || AppNotDeployed}
35
- width={imageType === ImageType.Medium ? '200' : '250'}
36
- height={imageType === ImageType.Medium ? '160' : '200'}
37
- alt="empty-state"
38
- /> : <SvgImage />}
39
- <div className={`flex column dc__gap-10 dc__mxw-300 ${isRowLayout ? 'dc__align-start' : ''} ${contentClassName}`}>
44
+ >
45
+ {!SvgImage ? (
46
+ !noImage && (
47
+ <img
48
+ className={imageClassName ? imageClassName : ''}
49
+ src={image || AppNotDeployed}
50
+ style={{
51
+ ...imageStyles,
52
+ width: `${getImageSize().width}`,
53
+ height: `${getImageSize().height}`,
54
+ }}
55
+ alt="empty-state"
56
+ />
57
+ )
58
+ ) : (
59
+ <SvgImage
60
+ style={{
61
+ ...imageStyles,
62
+ width: `${getImageSize().width}`,
63
+ height: `${getImageSize().height}`,
64
+ }}
65
+ />
66
+ )}
67
+ <div
68
+ className={`flex column dc__gap-10 dc__mxw-300 ${
69
+ isRowLayout ? 'dc__align-start' : ''
70
+ } ${contentClassName}`}
71
+ >
40
72
  <h4 className="title fw-6 cn-9 mt-0 mb-0">{title}</h4>
41
73
  {subTitle && <p className={`subtitle ${isRowLayout ? 'subtitle--text-start' : ''}`}>{subTitle}</p>}
42
74
  {isButtonAvailable && renderButton()}
@@ -559,18 +559,3 @@ export function getLockedJSON(json, jsonPathArray: string[]) {
559
559
  return resultJson['$']
560
560
  }
561
561
 
562
- /**
563
- * Returns a debounced variant of the function
564
- */
565
- export const debounce = (func, timeout = 500) => {
566
- let timer
567
-
568
- return function (this, ...args) {
569
- const context = this
570
- if (timer) clearTimeout(timer)
571
- timer = setTimeout(() => {
572
- timer = null
573
- func.apply(context, args)
574
- }, timeout)
575
- }
576
- }
@@ -3,23 +3,10 @@ import { Placement } from 'tippy.js'
3
3
  import { ImageComment, ReleaseTag } from './ImageTags.Types'
4
4
  import { DockerConfigOverrideType, TaskErrorObj } from '.'
5
5
 
6
- /**
7
- * Generic response type object with support for overriding the result type
8
- *
9
- * @example Default usage:
10
- * ```ts
11
- * interface UserResponse extends ResponseType {}
12
- * ```
13
- *
14
- * @example Override the response type:
15
- * ```ts
16
- * interface UserResponse extends ResponseType<Record<string, string>> {}
17
- * ```
18
- */
19
- export interface ResponseType<T = any> {
6
+ export interface ResponseType {
20
7
  code: number
21
8
  status: string
22
- result?: T
9
+ result?: any
23
10
  errors?: any
24
11
  }
25
12
 
@@ -107,6 +94,7 @@ export interface GenericEmptyStateType {
107
94
  imageClassName?: string
108
95
  children?: ReactNode
109
96
  noImage?: boolean
97
+ imageStyles?: CSSProperties
110
98
  /**
111
99
  * @default 'column'
112
100
  */
@@ -26,7 +26,6 @@ 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'
30
29
  export { default as Toggle } from './Toggle/Toggle'
31
30
  export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable'
32
31
  export { default as StyledRadioGroup } from './RadioGroup/RadioGroup'
@@ -47,4 +46,3 @@ export { default as ChartVersionAndTypeSelector } from './ChartVersionAndTypeSel
47
46
  export * from './AddCDButton'
48
47
  export * from './CustomInput'
49
48
  export * from './DraggableWrapper'
50
- export * from './Pagination'
package/.eslintignore DELETED
@@ -1,96 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,31 +0,0 @@
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
package/.husky/pre-commit DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- npx tsc --noEmit
5
- npm run lint-staged
package/.lintstagedrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "*.{js,jsx,ts,tsx}": ["npx eslint"]
3
- }
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v16.13.0
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { PageSizeSelectorProps } from './types';
3
- declare const PageSizeSelector: ({ pageSizeOptions, pageSize, changePageSize }: PageSizeSelectorProps) => JSX.Element;
4
- export default PageSizeSelector;
@@ -1,5 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- export declare const VISIBLE_PAGES_LIMIT = 5;
2
- export declare const FALLBACK_PAGE_SIZE_OPTIONS: {
3
- value: number;
4
- selected: boolean;
5
- }[];
@@ -1 +0,0 @@
1
- export { default as Pagination } from './Pagination';
@@ -1,51 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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[];
@@ -1,39 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- export { default as SearchBar } from './SearchBar.component';
2
- export type { SearchBarProps } from './types';
@@ -1,35 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
- <g fill="none" fill-rule="evenodd">
3
- <path d="M0 0h24v24H0z"/>
4
- <path fill="#959BA1" d="M10 2a8 8 0 0 1 6.32 12.905l5.044 5.045a1 1 0 1 1-1.414 1.414l-5.045-5.043A8 8 0 1 1 10 2zm0 2a6 6 0 1 0 0 12 6 6 0 0 0 0-12z"/>
5
- </g>
6
- </svg>
@@ -1,78 +0,0 @@
1
- import { useRef, useState } from 'react'
2
- import { PageSizeItemsProps, PageSizeOption, PageSizeSelectorProps } from './types'
3
- import { useClickOutside } from '../Hooks'
4
- import { getDefaultPageValueOptions } from './utils'
5
-
6
- const PageSizeItems = ({
7
- optionValue,
8
- options,
9
- setOptions,
10
- handleCloseDropdown,
11
- changePageSize,
12
- }: PageSizeItemsProps) => {
13
- const handlePageSizeSelect = () => {
14
- const newOptions = options.map((_option) => ({
15
- value: _option.value,
16
- selected: _option.value === optionValue,
17
- }))
18
- setOptions([...newOptions])
19
- handleCloseDropdown()
20
- changePageSize(optionValue)
21
- }
22
-
23
- return (
24
- <div key={optionValue} className="select__item" onClick={handlePageSizeSelect}>
25
- {optionValue}
26
- </div>
27
- )
28
- }
29
-
30
- const PageSizeSelector = ({ pageSizeOptions, pageSize, changePageSize }: PageSizeSelectorProps) => {
31
- const defaultOptions = getDefaultPageValueOptions(pageSizeOptions).map((option) => ({
32
- value: option.value,
33
- selected: option.value === pageSize,
34
- }))
35
-
36
- const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false)
37
- const [options, setOptions] = useState<PageSizeOption[]>(defaultOptions)
38
-
39
- const handleCloseDropdown = () => {
40
- setIsDropdownOpen(false)
41
- }
42
-
43
- const handleDropdownToggle = () => {
44
- setIsDropdownOpen(!isDropdownOpen)
45
- }
46
-
47
- const dropdownRef = useRef<HTMLDivElement>(null)
48
- useClickOutside(dropdownRef, handleCloseDropdown)
49
-
50
- const selectedOption = options.find((option) => option.selected)
51
- const font = isDropdownOpen ? 'fa fa-caret-up' : 'fa fa-caret-down'
52
- return (
53
- <div ref={dropdownRef}>
54
- {isDropdownOpen && (
55
- <div className="pagination__select-menu">
56
- {options.map((_option) => (
57
- <PageSizeItems
58
- optionValue={_option.value}
59
- options={options}
60
- setOptions={setOptions}
61
- handleCloseDropdown={handleCloseDropdown}
62
- changePageSize={changePageSize}
63
- />
64
- ))}
65
- </div>
66
- )}
67
-
68
- <button type="button" className="select__button" onClick={handleDropdownToggle}>
69
- <span>{selectedOption ? selectedOption.value : ''}</span>
70
- <span className="select__icon">
71
- <i className={font} />
72
- </span>
73
- </button>
74
- </div>
75
- )
76
- }
77
-
78
- export default PageSizeSelector