Skip to content

Commit

Permalink
refactor(DelimitedList): add typescript types (carbon-design-system#4784
Browse files Browse the repository at this point in the history
)

* refactor(DelimitedList): add typescript types

* refactor(DelimitedList): resolve error
  • Loading branch information
anamikaanu96 authored Apr 9, 2024
1 parent d1b4dff commit f58e753
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Import portions of React that are needed.
import React from 'react';
import React, { PropsWithChildren } from 'react';

// Other standard imports.
import PropTypes from 'prop-types';
Expand All @@ -23,12 +23,30 @@ const defaults = {
items: [],
truncate: true,
};
interface DelimitedListProps extends PropsWithChildren {
/**
* Provide an optional class to be applied to the containing node.
*/
className?: string;
/**
* The character(s) used to separate the items.
*/
delimiter?: string;
/**
* Array of items to be listed.
*/
items?: any[];
/**
* Toggle the component's ability to truncate or not.
*/
truncate?: boolean;
}

/**
* `DelimitedList` converts an array of items into a single line of
* comma-separated values.
*/
export let DelimitedList = React.forwardRef(
export let DelimitedList = React.forwardRef<HTMLDivElement, DelimitedListProps>(
(
{
// The component props, in alphabetical order (for consistency).
Expand All @@ -39,7 +57,7 @@ export let DelimitedList = React.forwardRef(
truncate = defaults.truncate,
// Collect any other property values passed in.
...rest
},
}: DelimitedListProps,
ref
) => {
return (
Expand Down

0 comments on commit f58e753

Please sign in to comment.