Skip to content

Commit 6ef313f

Browse files
committed
fix: typing for collapsible list
1 parent 4371daa commit 6ef313f

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
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.1-beta-1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

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

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ import React from 'react'
22
import { TippyProps } from '@tippyjs/react'
33
import { NavLinkProps } from 'react-router-dom'
44

5-
interface ButtonTab {
6-
/**
7-
* Is tab active ( for button tab )
8-
*/
9-
isActive: boolean
5+
interface ButtonTab extends Required<Pick<NavLinkProps, 'isActive'>> {
106
/**
117
* The callback function to handle click events on the button.
128
*/
139
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void
1410
href?: never
1511
}
1612

17-
interface NavLinkTab {
13+
interface NavLinkTab extends Pick<NavLinkProps, 'isActive'> {
1814
/**
1915
* The URL of the nav link.
2016
*/
@@ -30,38 +26,37 @@ export type TabOptions = 'button' | 'navLink'
3026

3127
type ConditionalTabType<TabType extends TabOptions> = TabType extends 'button' ? ButtonTab : NavLinkTab
3228

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
29+
export type CollapsibleListItem<TabType extends TabOptions = 'navLink'> = ConditionalTabType<TabType> & {
30+
/**
31+
* The title of the list item.
32+
*/
33+
title: string
34+
/**
35+
* The subtitle of the list item.
36+
*/
37+
subtitle?: string
38+
/**
39+
* If true, the title will be rendered with line-through.
40+
*/
41+
strikeThrough?: boolean
42+
/**
43+
* Configuration for the icon.
44+
*/
45+
iconConfig?: {
3946
/**
40-
* The subtitle of the list item.
47+
* A React component representing an icon to be displayed with the list item.
4148
*/
42-
subtitle?: string
49+
Icon: React.FunctionComponent<React.SVGProps<SVGSVGElement>>
4350
/**
44-
* If true, the title will be rendered with line-through.
51+
* Properties for the icon component.
4552
*/
46-
strikeThrough?: boolean
53+
props?: React.SVGProps<SVGSVGElement>
4754
/**
48-
* Configuration for the icon.
55+
* Properties for the tooltip component of the icon.
4956
*/
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-
}
57+
tooltipProps?: TippyProps
6458
}
59+
}
6560

6661
export interface CollapsibleListConfig<TabType extends 'button' | 'navLink'> {
6762
/**

0 commit comments

Comments
 (0)