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

feat(containedlist): added index.ts file for type generation #16302

Merged
Merged
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
12 changes: 9 additions & 3 deletions packages/react/src/components/ContainedList/ContainedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import classNames from 'classnames';
import { LayoutConstraint } from '../Layout';
import { useId } from '../../internal/useId';
import { usePrefix } from '../../internal/usePrefix';
import ContainedListItem from './ContainedListItem';

const variants = ['on-page', 'disclosed'] as const;

type Variants = (typeof variants)[number];
interface ContainedListType extends React.FC<ContainedListProps> {
ContainedListItem: typeof ContainedListItem;
}

export type Variants = (typeof variants)[number];

interface ContainedListProps {
export interface ContainedListProps {
/**
* A slot for a possible interactive element to render.
*/
Expand Down Expand Up @@ -89,7 +94,7 @@ function renderChildren(children) {
return children;
}

const ContainedList: React.FC<ContainedListProps> = ({
const ContainedList: ContainedListType = ({
action,
children,
className,
Expand Down Expand Up @@ -199,4 +204,5 @@ ContainedList.propTypes = {
size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl']),
};

ContainedList.ContainedListItem = ContainedListItem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This threw me for a loop, I thought we had deprecated all instances where we were placing subcomponents as fields on the parent component object. Turns out this has been in there since the inception of this component.

It's not something we need to do in this PR, but I think it would make sense to deprecate this like we did for TextInput.PasswordInput here

// what's currently possible, a bit out of convention
<ContainedList>
  <ContainedList.ContainedListItem/>
  <ContainedList.ContainedListItem/>
</ContainedList>

// following the general convention we have would mean 
// it wouldn't be a field on the object. The above 
// wouldn't work, instead:
<ContainedList>
  <ContainedListItem/>
  <ContainedListItem/>
</ContainedList>

I can open a new issue for this 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export default ContainedList;
Loading