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(typescript): add various typescript typings #13234

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
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,27 @@
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes';
import { usePrefix } from '../../internal/usePrefix';
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes';

export interface TableToolbarProps
extends React.HTMLAttributes<HTMLDivElement> {
/**
* Pass in the children that will be rendered inside the TableToolbar
*/
children: React.ReactNode;

/**
* `lg` Change the row height of table
*/
size?: 'sm' | 'lg';
}

const TableToolbar = ({ children, size, ...rest }) => {
const TableToolbar: React.FC<TableToolbarProps> = ({
children,
size,
...rest
}) => {
const prefix = usePrefix();
const className = cx({
[`${prefix}--table-toolbar`]: true,
Expand Down
23 changes: 0 additions & 23 deletions packages/react/src/components/DataTable/TableToolbarAction.js

This file was deleted.

44 changes: 44 additions & 0 deletions packages/react/src/components/DataTable/TableToolbarAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import PropTypes from 'prop-types';
import React from 'react';
import OverflowMenuItem from '../OverflowMenuItem';
import { ForwardRefReturn } from '../../types/common';

export interface TableToolbarActionProps
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'> {
/**
* Pass in the children that will be rendered inside the TableToolbarAction
*/
children?: React.ReactNode;

/**
* onClick handler for the TableToolbarAction
*/
onClick: (event: React.MouseEvent<HTMLDivElement>) => void;
}

export type TableToolbarActionComponent = ForwardRefReturn<
HTMLDivElement,
TableToolbarActionProps
>;

const TableToolbarAction: TableToolbarActionComponent = React.forwardRef(
({ children, ...rest }, ref) => {
return <OverflowMenuItem ref={ref} itemText={children} {...rest} />;
}
);

TableToolbarAction.displayName = 'TableToolbarAction';
TableToolbarAction.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
onClick: PropTypes.func.isRequired,
};

export default TableToolbarAction;
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,34 @@
* LICENSE file in the root directory of this source tree.
*/

import { Settings } from '@carbon/icons-react';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import OverflowMenu from '../OverflowMenu';
import { Settings } from '@carbon/icons-react';
import { usePrefix } from '../../internal/usePrefix';
import OverflowMenu from '../OverflowMenu';

export interface TableToolbarMenuProps
extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode;

/**
* Provide an optional class name for the toolbar menu
*/
className?: string;

/**
* The description of the menu icon.
*/
iconDescription: string;

/**
* Optional prop to allow overriding the default menu icon
*/
renderIcon?: React.ReactNode;
}

const TableToolbarMenu = ({
const TableToolbarMenu: React.FC<TableToolbarMenuProps> = ({
className,
renderIcon,
iconDescription,
Expand Down
187 changes: 0 additions & 187 deletions packages/react/src/components/OverflowMenuItem/OverflowMenuItem.js

This file was deleted.

Loading