Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BD-46] feat: defined types for Paragon export #2566

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependent-usage-analyzer/
build-scss.js
component-generator/
example/
*.d.ts
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions src/ActionRow/index.jsx → src/ActionRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

export interface ActionRowProps {
as?: React.ElementType;
isStacked?: boolean;
children?: React.ReactNode;
className?: string;
}

function ActionRow({
as,
as = 'div',
isStacked,
children,
className,
...props
}) {
}: ActionRowProps) {
return React.createElement(
as,
{
...props,
className: classNames(props.className, {
className: classNames(className, {
'pgn__action-row': !isStacked,
'pgn__action-row-stacked': isStacked,
}),
Expand All @@ -39,7 +47,7 @@ ActionRow.defaultProps = {
isStacked: false,
};

function ActionRowSpacer() {
function ActionRowSpacer(): React.ReactElement {
return <span className="pgn__action-row-spacer" />;
}

Expand Down
18 changes: 18 additions & 0 deletions src/Alert/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import BaseAlert, { AlertProps } from 'react-bootstrap/Alert';

declare const ALERT_CLOSE_LABEL_TEXT: string;
export interface BaseAlertProps extends AlertProps {
icon?: React.ReactElement,
actions?: Array<React.ReactElement>,
dismissible?: boolean,
onClose?: () => void,
closeLabel?: React.ReactElement,
stacked?: boolean,
}
declare const Alert: React.ForwardRefExoticComponent<BaseAlertProps> & {
Link: typeof BaseAlert.Link;
Heading: typeof BaseAlert.Heading;
};
export { ALERT_CLOSE_LABEL_TEXT };
export default Alert;
10 changes: 10 additions & 0 deletions src/Annotation/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

export interface AnnotationProps {
className?: string,
variant?: 'error' | 'success' | 'warning' | 'light' | 'dark',
children?: React.ReactNode,
arrowPlacement?: 'top' | 'right' | 'bottom' | 'left',
}
declare const Annotation: React.ForwardRefExoticComponent<AnnotationProps>;
export default Annotation;
9 changes: 9 additions & 0 deletions src/Avatar/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export interface AvatarProps {
alt?: string,
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'huge',
src?: string,
}
declare const Avatar: React.FC<AvatarProps>;
export default Avatar;
9 changes: 9 additions & 0 deletions src/AvatarButton/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export interface AvatarButtonProps {
alt?: string,
size?: 'xs' | 'sm' | 'md',
src?: string,
}
declare const AvatarButton: React.FC<AvatarButtonProps>;
export default AvatarButton;
9 changes: 9 additions & 0 deletions src/Badge/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { BadgeProps } from 'react-bootstrap/Badge';

interface IBadge extends BadgeProps {
children?: React.ReactNode,
}

declare const Badge: React.ForwardRefExoticComponent<IBadge>;
export default Badge;
18 changes: 18 additions & 0 deletions src/Breadcrumb/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';

export interface BreadcrumbProps {
links: Array<{
label: string,
href?: string,
className?: string,
}>,
activeLabel?: string,
spacer?: React.ReactElement,
clickHandler?: Function,
variant?: 'light' | 'dark',
isMobile?: boolean,
ariaLabel?: string,
linkAs?: React.ElementType,
}
declare const Breadcrumb: React.FC<BreadcrumbProps>;
export default Breadcrumb;
4 changes: 3 additions & 1 deletion src/Breadcrumb/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Breadcrumb.propTypes = {
* prop as these objects will get passed down as props to the underlying component defined by `linkAs` prop.
*/
links: PropTypes.arrayOf(PropTypes.shape({
label: PropTypes.string,
label: PropTypes.string.isRequired,
href: PropTypes.string,
className: PropTypes.string,
})).isRequired,
/** allows to add a label that is not a link to the end of the breadcrumb. */
activeLabel: PropTypes.string,
Expand Down
19 changes: 19 additions & 0 deletions src/Button/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { ButtonProps } from 'react-bootstrap/Button';
import { ButtonGroupProps, ButtonToolbarProps } from "react-bootstrap";
import { BsPrefixRefForwardingComponent } from "react-bootstrap/helpers";

export interface BaseButtonProps extends ButtonProps {
iconBefore?: React.ReactElement,
iconAfter?: React.ReactElement,
}

declare type Button = BsPrefixRefForwardingComponent<'button', BaseButtonProps>;
declare type ButtonGroup = BsPrefixRefForwardingComponent<'div', ButtonGroupProps>;
declare type ButtonToolbar = BsPrefixRefForwardingComponent<'div', ButtonToolbarProps>;

declare const Button: Button;
declare const ButtonGroup: ButtonGroup;
declare const ButtonToolbar: ButtonToolbar;
export { ButtonGroup, ButtonToolbar };
export default Button;
8 changes: 8 additions & 0 deletions src/Card/CardBody.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';

export interface CardBodyProps {
className?: string,
children?: React.ReactNode,
}
declare const CardBody: React.ForwardRefExoticComponent<CardBodyProps>;
export default CardBody;
23 changes: 23 additions & 0 deletions src/Card/CardCarousel/CardCarousel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';

export interface CardCarouselProps {
ariaLabel: string,
children: React.ReactNode,
title?: React.ReactNode,
subtitle?: React.ReactNode,
columnSizes?: {
xs?: number,
sm?: number,
md?: number,
lg?: number,
xl?: number,
},
hasInteractiveChildren?: boolean,
canScrollHorizontal?: boolean,
disableOpacityMasks?: boolean,
onScrollPrevious?: Function,
onScrollNext?: Function,
CardCarouselControls?: React.ElementType,
}
declare const CardCarousel: React.ForwardRefExoticComponent<CardCarouselProps>;
export default CardCarousel;
4 changes: 4 additions & 0 deletions src/Card/CardCarousel/CardCarouselControls.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from 'react';

declare const CardCarouselControls: React.FC;
export default CardCarouselControls;
8 changes: 8 additions & 0 deletions src/Card/CardCarousel/CardCarouselHeader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';

export interface CardCarouselHeaderProps {
title?: React.ReactNode,
subtitle?: React.ReactNode,
}
declare const CardCarouselHeader: React.FC<CardCarouselHeaderProps>;
export default CardCarouselHeader;
7 changes: 7 additions & 0 deletions src/Card/CardCarousel/CardCarouselItems.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export interface CardCarouselItemsProps {
children: React.ReactNode,
}
declare const CardCarouselItems: React.FC<CardCarouselItemsProps>;
export default CardCarouselItems;
19 changes: 19 additions & 0 deletions src/Card/CardCarousel/CardCarouselProvider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

export interface CardCarouselProviderProps {
columnSizes?: {
xs?: number,
sm?: number,
md?: number,
lg?: number,
xl?: number,
},
hasInteractiveChildren?: boolean,
canScrollHorizontal?: boolean,
CardCarouselControls?: React.ElementType,
children: React.ReactNode,
}
declare const CardCarouselProvider: React.FC<CardCarouselProviderProps>;
declare const CardCarouselContext: React.Context<{}>;
export { CardCarouselContext };
export default CardCarouselProvider;
9 changes: 9 additions & 0 deletions src/Card/CardCarousel/CardCarouselSubtitle.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

export interface CardCarouselSubtitleProps {
as?: React.ElementType | string
className?: string,
children: React.ReactNode,
}
declare const CardCarouselSubtitle: React.FC<CardCarouselSubtitleProps>;
export default CardCarouselSubtitle;
9 changes: 9 additions & 0 deletions src/Card/CardCarousel/CardCarouselTitle.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export interface CardCarouselTitleProps {
as?: React.ElementType | string
className?: string,
children: React.ReactNode,
}
declare const CardCarouselTitle: React.FC<CardCarouselTitleProps>;
export default CardCarouselTitle;
3 changes: 3 additions & 0 deletions src/Card/CardCarousel/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import CardCarousel from "./CardCarousel";

export default CardCarousel;
12 changes: 12 additions & 0 deletions src/Card/CardContext.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

export interface CardContextProviderProps {
orientation?: 'horizontal' | 'vertical',
isLoading?: boolean,
variant?: 'light' | 'dark' | 'muted',
children?: React.ReactNode,
}
declare const CardContextProvider: React.FC<CardContextProviderProps>;
declare const CardContext: React.Context<{}>;
export { CardContextProvider };
export default CardContext;
19 changes: 19 additions & 0 deletions src/Card/CardDeck.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

export declare const CARD_DECK_ITEM_CLASS_NAME = 'pgn__card-deck-card-item';
export interface CardDeckProps {
columnSizes?: {
xs?: number,
sm?: number,
md?: number,
lg?: number,
xl?: number,
},
hasInteractiveChildren?: boolean,
canScrollHorizontal?: boolean,
hasOverflowScrollItems?: boolean,
className?: string,
children: React.ReactNode,
}
declare const CardDeck: React.ForwardRefExoticComponent<CardDeckProps>;
export default CardDeck;
7 changes: 7 additions & 0 deletions src/Card/CardDivider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export interface CardDividerProps {
className?: string,
}
declare const CardDivider: React.ForwardRefExoticComponent<CardDividerProps>;
export default CardDivider;
13 changes: 13 additions & 0 deletions src/Card/CardFooter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

export interface CardFooterProps {
isStacked?: boolean,
textElement?: React.ReactNode,
skeletonHeight?: number,
skeletonWidth?: number,
orientation?: 'horizontal' | 'vertical',
className?: string,
children?: React.ReactNode,
}
declare const CardFooter: React.ForwardRefExoticComponent<CardFooterProps>;
export default CardFooter;
15 changes: 15 additions & 0 deletions src/Card/CardGrid.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

export interface CardGridProps {
className?: string,
children?: React.ReactNode,
columnSizes?: {
xs?: number,
sm?: number,
md?: number,
lg?: number,
xl?: number,
},
}
declare const CardGrid: React.FC<CardGridProps>;
export default CardGrid;
13 changes: 13 additions & 0 deletions src/Card/CardHeader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

export interface CardHeaderProps {
actions?: React.ReactNode,
size?: 'sm' | 'md',
subtitle?: React.ReactNode,
title?: React.ReactNode,
skeletonHeight?: number,
skeletonWidth?: number,
className?: string,
}
declare const CardHeader: React.ForwardRefExoticComponent<CardHeaderProps>;
export default CardHeader;
19 changes: 19 additions & 0 deletions src/Card/CardImageCap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

export interface CardImageCapProps {
src?: string,
fallbackSrc?: string,
srcAlt?: string,
logoSrc?: string,
fallbackLogoSrc?: string,
logoAlt?: string,
skeletonHeight?: number,
skeletonWidth?: number,
logoSkeleton?: boolean,
logoSkeletonHeight?: number,
logoSkeletonWidth?: number,
className?: string,
children?: React.ReactNode,
}
declare const CardImageCap: React.ForwardRefExoticComponent<CardImageCapProps>;
export default CardImageCap;
13 changes: 13 additions & 0 deletions src/Card/CardSection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

export interface CardSectionProps {
title?: React.ReactNode,
actions?: React.ReactNode,
muted?: boolean,
skeletonHeight?: number,
skeletonWidth?: number,
className?: string,
children?: React.ReactNode,
}
declare const CardSection: React.ForwardRefExoticComponent<CardSectionProps>;
export default CardSection;
11 changes: 11 additions & 0 deletions src/Card/CardStatus.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

export interface CardStatusProps {
variant?: 'success' | 'primary' | 'warning' | 'danger',
icon?: React.ReactElement,
title?: React.ReactNode,
className?: string,
children?: React.ReactNode,
}
declare const CardStatus: React.ForwardRefExoticComponent<CardStatusProps>;
export default CardStatus;
Loading
Loading