Skip to content

Commit 9909800

Browse files
authored
Merge pull request #399 from devtron-labs/chore/sync-kubecon-2024
fix: typing for collapsible list
2 parents 30d37da + 391e874 commit 9909800

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CollapsibleList/CollapsibleList.types.ts

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ButtonTab {
1414
href?: never
1515
}
1616

17-
interface NavLinkTab {
17+
interface NavLinkTab extends Pick<NavLinkProps, 'isActive'> {
1818
/**
1919
* The URL of the nav link.
2020
*/
@@ -23,47 +23,45 @@ interface NavLinkTab {
2323
* The callback function to handle click events on the nav link.
2424
*/
2525
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void
26-
isActive?: never
2726
}
2827

2928
export type TabOptions = 'button' | 'navLink'
3029

3130
type ConditionalTabType<TabType extends TabOptions> = TabType extends 'button' ? ButtonTab : NavLinkTab
3231

33-
export type CollapsibleListItem<TabType extends TabOptions> = Pick<NavLinkProps, 'isActive'> &
34-
ConditionalTabType<TabType> & {
35-
/**
36-
* The title of the list item.
37-
*/
38-
title: string
32+
export type CollapsibleListItem<TabType extends TabOptions = 'navLink'> = ConditionalTabType<TabType> & {
33+
/**
34+
* The title of the list item.
35+
*/
36+
title: string
37+
/**
38+
* The subtitle of the list item.
39+
*/
40+
subtitle?: string
41+
/**
42+
* If true, the title will be rendered with line-through.
43+
*/
44+
strikeThrough?: boolean
45+
/**
46+
* Configuration for the icon.
47+
*/
48+
iconConfig?: {
3949
/**
40-
* The subtitle of the list item.
50+
* A React component representing an icon to be displayed with the list item.
4151
*/
42-
subtitle?: string
52+
Icon: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
4353
/**
44-
* If true, the title will be rendered with line-through.
54+
* Properties for the icon component.
4555
*/
46-
strikeThrough?: boolean
56+
props?: React.SVGProps<SVGSVGElement>
4757
/**
48-
* Configuration for the icon.
58+
* Properties for the tooltip component of the icon.
4959
*/
50-
iconConfig?: {
51-
/**
52-
* A React component representing an icon to be displayed with the list item.
53-
*/
54-
Icon: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
55-
/**
56-
* Properties for the icon component.
57-
*/
58-
props?: React.SVGProps<SVGSVGElement>
59-
/**
60-
* Properties for the tooltip component of the icon.
61-
*/
62-
tooltipProps?: TippyProps
63-
}
60+
tooltipProps?: TippyProps
6461
}
62+
}
6563

66-
export interface CollapsibleListConfig<TabType extends 'button' | 'navLink'> {
64+
export interface CollapsibleListConfig<TabType extends TabOptions = 'navLink'> {
6765
/**
6866
* The unique identifier for the collapsible list.
6967
*/
@@ -108,7 +106,7 @@ export interface CollapsibleListConfig<TabType extends 'button' | 'navLink'> {
108106
isExpanded?: boolean
109107
}
110108

111-
export interface CollapsibleListProps<TabType extends TabOptions> {
109+
export interface CollapsibleListProps<TabType extends TabOptions = 'navLink'> {
112110
/**
113111
* An array of collapsible list configurations.
114112
*/

0 commit comments

Comments
 (0)