mirror of https://github.com/acid-info/lsd.git
fix(lsd-react): omit common props before passing down props to html elements; closes #39
This commit is contained in:
parent
db0763a162
commit
ea24ee7906
|
@ -7,7 +7,12 @@ import { DropdownMenu } from '../DropdownMenu'
|
||||||
import { Portal } from '../PortalProvider/Portal'
|
import { Portal } from '../PortalProvider/Portal'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { autocompleteClasses } from './Autocomplete.classes'
|
import { autocompleteClasses } from './Autocomplete.classes'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
pickCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
|
|
||||||
export type AutocompleteProps = CommonProps &
|
export type AutocompleteProps = CommonProps &
|
||||||
Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'value'> &
|
Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'value'> &
|
||||||
|
@ -87,7 +92,7 @@ export const Autocomplete: React.FC<AutocompleteProps> & {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
props.className,
|
props.className,
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
|
@ -142,7 +147,7 @@ export const Autocomplete: React.FC<AutocompleteProps> & {
|
||||||
open={isOpen}
|
open={isOpen}
|
||||||
onClose={() => setOpen(false)}
|
onClose={() => setOpen(false)}
|
||||||
size={size}
|
size={size}
|
||||||
genericFontFamily={props.genericFontFamily}
|
{...pickCommonProps(props)}
|
||||||
>
|
>
|
||||||
{suggestions.map((opt, idx: number) => (
|
{suggestions.map((opt, idx: number) => (
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { badgeClasses } from './Badge.classes'
|
import { badgeClasses } from './Badge.classes'
|
||||||
|
|
||||||
|
@ -29,7 +33,7 @@ export const Badge: React.FC<BadgeProps> & {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
aria-label={children as string}
|
aria-label={children as string}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
props.className,
|
props.className,
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
pickCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { BreadcrumbItem } from '../BreadcrumbItem'
|
import { BreadcrumbItem } from '../BreadcrumbItem'
|
||||||
import { breadcrumbItemClasses } from '../BreadcrumbItem/BreadcrumbItem.classes'
|
import { breadcrumbItemClasses } from '../BreadcrumbItem/BreadcrumbItem.classes'
|
||||||
import { DropdownMenu } from '../DropdownMenu'
|
import { DropdownMenu } from '../DropdownMenu'
|
||||||
|
@ -79,7 +84,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
props.className,
|
props.className,
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
|
@ -96,6 +101,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> & {
|
||||||
label={'...'}
|
label={'...'}
|
||||||
onClick={onTrigger}
|
onClick={onTrigger}
|
||||||
size={size}
|
size={size}
|
||||||
|
{...pickCommonProps(props)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderItems(visible)}
|
{renderItems(visible)}
|
||||||
|
@ -109,6 +115,7 @@ export const Breadcrumb: React.FC<BreadcrumbProps> & {
|
||||||
className={clsx(breadcrumbClasses.listBox)}
|
className={clsx(breadcrumbClasses.listBox)}
|
||||||
size={size}
|
size={size}
|
||||||
genericFontFamily={props.genericFontFamily}
|
genericFontFamily={props.genericFontFamily}
|
||||||
|
{...pickCommonProps(props)}
|
||||||
>
|
>
|
||||||
{collapsed.map((opt, idx) => (
|
{collapsed.map((opt, idx) => (
|
||||||
<BreadcrumbItem
|
<BreadcrumbItem
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { breadcrumbItemClasses } from './BreadcrumbItem.classes'
|
import { breadcrumbItemClasses } from './BreadcrumbItem.classes'
|
||||||
|
|
||||||
|
@ -37,7 +41,7 @@ export const BreadcrumbItem: React.FC<BreadcrumbItemProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
breadcrumbItemClasses.root,
|
breadcrumbItemClasses.root,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { buttonClasses } from './Button.classes'
|
import { buttonClasses } from './Button.classes'
|
||||||
|
|
||||||
export type ButtonProps = CommonProps &
|
export type ButtonProps = CommonProps &
|
||||||
|
@ -18,7 +22,7 @@ export const Button: React.FC<ButtonProps> & {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { cardClasses } from './Card.classes'
|
import { cardClasses } from './Card.classes'
|
||||||
import { CardContext } from './Card.context'
|
import { CardContext } from './Card.context'
|
||||||
|
|
||||||
|
@ -17,7 +21,7 @@ export const Card: React.FC<CardProps> & {
|
||||||
return (
|
return (
|
||||||
<CardContext.Provider value={{ size }}>
|
<CardContext.Provider value={{ size }}>
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
cardClasses.root,
|
cardClasses.root,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { cardBodyClasses } from './CardBody.classes'
|
import { cardBodyClasses } from './CardBody.classes'
|
||||||
|
|
||||||
export type CardBodyProps = CommonProps &
|
export type CardBodyProps = CommonProps &
|
||||||
|
@ -13,7 +17,7 @@ export const CardBody: React.FC<CardBodyProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useCardContext } from '../Card/Card.context'
|
import { useCardContext } from '../Card/Card.context'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { cardHeaderClasses } from './CardHeader.classes'
|
import { cardHeaderClasses } from './CardHeader.classes'
|
||||||
|
@ -19,7 +23,7 @@ export const CardHeader: React.FC<CardHeaderProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useInput } from '../../utils/useInput'
|
import { useInput } from '../../utils/useInput'
|
||||||
import { useCheckboxGroupContext } from '../CheckboxGroup/CheckboxGroup.context'
|
import { useCheckboxGroupContext } from '../CheckboxGroup/CheckboxGroup.context'
|
||||||
import { CheckboxFilledIcon, CheckboxIcon } from '../Icons'
|
import { CheckboxFilledIcon, CheckboxIcon } from '../Icons'
|
||||||
|
@ -71,7 +75,7 @@ export const Checkbox: React.FC<CheckboxProps> & {
|
||||||
variant={size === 'large' ? 'label1' : 'label2'}
|
variant={size === 'large' ? 'label1' : 'label2'}
|
||||||
component="label"
|
component="label"
|
||||||
aria-disabled={disabled ? 'true' : 'false'}
|
aria-disabled={disabled ? 'true' : 'false'}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -3,7 +3,12 @@ import React from 'react'
|
||||||
import { CheckboxGroupContext } from './CheckboxGroup.context'
|
import { CheckboxGroupContext } from './CheckboxGroup.context'
|
||||||
import { checkboxGroupClasses } from './CheckboxGroup.classes'
|
import { checkboxGroupClasses } from './CheckboxGroup.classes'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
pickCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
|
|
||||||
export type ActiveCheckboxType = string | number | readonly string[]
|
export type ActiveCheckboxType = string | number | readonly string[]
|
||||||
|
|
||||||
|
@ -21,7 +26,7 @@ export const CheckboxGroup: React.FC<CheckboxGroupProps> & {
|
||||||
return (
|
return (
|
||||||
<CheckboxGroupContext.Provider value={{ size }}>
|
<CheckboxGroupContext.Provider value={{ size }}>
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
@ -32,6 +37,7 @@ export const CheckboxGroup: React.FC<CheckboxGroupProps> & {
|
||||||
component="span"
|
component="span"
|
||||||
variant={size === 'small' ? 'label2' : 'label1'}
|
variant={size === 'small' ? 'label2' : 'label1'}
|
||||||
className={checkboxGroupClasses.label}
|
className={checkboxGroupClasses.label}
|
||||||
|
{...pickCommonProps(props)}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
pickCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { CollapseHeader } from '../CollapseHeader'
|
import { CollapseHeader } from '../CollapseHeader'
|
||||||
import { collapseClasses } from './Collapse.classes'
|
import { collapseClasses } from './Collapse.classes'
|
||||||
|
|
||||||
|
@ -44,7 +49,7 @@ export const Collapse: React.FC<CollapseProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
globalProps.className,
|
globalProps.className,
|
||||||
|
@ -61,6 +66,7 @@ export const Collapse: React.FC<CollapseProps> & {
|
||||||
size={size}
|
size={size}
|
||||||
onTrigger={onTrigger}
|
onTrigger={onTrigger}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
{...pickCommonProps(props)}
|
||||||
/>
|
/>
|
||||||
{open && <div className={collapseClasses.content}>{children}</div>}
|
{open && <div className={collapseClasses.content}>{children}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { ArrowDownIcon, ArrowUpIcon } from '../Icons'
|
import { ArrowDownIcon, ArrowUpIcon } from '../Icons'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { collapseHeaderClasses } from './CollapseHeader.classes'
|
import { collapseHeaderClasses } from './CollapseHeader.classes'
|
||||||
|
@ -30,7 +34,7 @@ export const CollapseHeader: React.FC<CollapseHeaderProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { SelectOption, useSelect } from '../../utils/useSelect'
|
import { SelectOption, useSelect } from '../../utils/useSelect'
|
||||||
import { DropdownItem } from '../DropdownItem'
|
import { DropdownItem } from '../DropdownItem'
|
||||||
import { DropdownMenu } from '../DropdownMenu'
|
import { DropdownMenu } from '../DropdownMenu'
|
||||||
|
@ -72,7 +76,7 @@ export const Dropdown: React.FC<DropdownProps> & {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { CheckboxFilledIcon, CheckboxIcon, LsdIconProps } from '../Icons'
|
import { CheckboxFilledIcon, CheckboxIcon, LsdIconProps } from '../Icons'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { dropdownItemClasses } from './DropdownItem.classes'
|
import { dropdownItemClasses } from './DropdownItem.classes'
|
||||||
|
@ -36,7 +40,7 @@ export const DropdownItem: React.FC<DropdownItemProps> & {
|
||||||
<div
|
<div
|
||||||
role="option"
|
role="option"
|
||||||
aria-selected={selected ? 'true' : 'false'}
|
aria-selected={selected ? 'true' : 'false'}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
className,
|
className,
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { useClickAway } from 'react-use'
|
import { useClickAway } from 'react-use'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { dropdownMenuClasses } from './DropdownMenu.classes'
|
import { dropdownMenuClasses } from './DropdownMenu.classes'
|
||||||
|
|
||||||
export type DropdownMenuProps = CommonProps &
|
export type DropdownMenuProps = CommonProps &
|
||||||
|
@ -51,7 +55,7 @@ export const DropdownMenu: React.FC<DropdownMenuProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul
|
<ul
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
role="listbox"
|
role="listbox"
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useIconButtonGroupContext } from '../IconButtonGroup/IconButtonGroup.context'
|
import { useIconButtonGroupContext } from '../IconButtonGroup/IconButtonGroup.context'
|
||||||
import { iconButtonClasses } from './IconButton.classes'
|
import { iconButtonClasses } from './IconButton.classes'
|
||||||
|
|
||||||
|
@ -28,7 +32,7 @@ export const IconButton: React.FC<IconButtonProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { iconButtonGroupClasses } from './IconButtonGroup.classes'
|
import { iconButtonGroupClasses } from './IconButtonGroup.classes'
|
||||||
import { IconButtonGroupContext } from './IconButtonGroup.context'
|
import { IconButtonGroupContext } from './IconButtonGroup.context'
|
||||||
|
|
||||||
|
@ -24,7 +28,7 @@ export const IconButtonGroup: React.FC<IconButtonGroupProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../../utils/useCommonProps'
|
||||||
import { lsdIconClasses } from './LsdIcon.classes'
|
import { lsdIconClasses } from './LsdIcon.classes'
|
||||||
|
|
||||||
export type LsdIconProps = CommonProps &
|
export type LsdIconProps = CommonProps &
|
||||||
|
@ -39,7 +43,7 @@ export const LsdIcon = (
|
||||||
metadata?.filled && lsdIconClasses.filled,
|
metadata?.filled && lsdIconClasses.filled,
|
||||||
metadata?.stroked && lsdIconClasses.stroked,
|
metadata?.stroked && lsdIconClasses.stroked,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { quoteClasses } from './Quote.classes'
|
import { quoteClasses } from './Quote.classes'
|
||||||
|
|
||||||
|
@ -17,7 +21,7 @@ export const Quote: React.FC<QuoteProps> & {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useRef } from 'react'
|
import React, { useRef } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useInput } from '../../utils/useInput'
|
import { useInput } from '../../utils/useInput'
|
||||||
import { RadioButtonFilledIcon, RadioButtonIcon } from '../Icons'
|
import { RadioButtonFilledIcon, RadioButtonIcon } from '../Icons'
|
||||||
import { useRadioButtonGroupContext } from '../RadioButtonGroup/RadioButtonGroup.context'
|
import { useRadioButtonGroupContext } from '../RadioButtonGroup/RadioButtonGroup.context'
|
||||||
|
@ -66,7 +70,7 @@ export const RadioButton: React.FC<RadioButtonProps> & {
|
||||||
variant={size === 'large' ? 'label1' : 'label2'}
|
variant={size === 'large' ? 'label1' : 'label2'}
|
||||||
component="label"
|
component="label"
|
||||||
aria-disabled={disabled ? 'true' : 'false'}
|
aria-disabled={disabled ? 'true' : 'false'}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { radioButtonGroupClasses } from './RadioButtonGroup.classes'
|
import { radioButtonGroupClasses } from './RadioButtonGroup.classes'
|
||||||
import { RadioButtonGroupContext } from './RadioButtonGroup.context'
|
import { RadioButtonGroupContext } from './RadioButtonGroup.context'
|
||||||
|
@ -36,7 +40,7 @@ export const RadioButtonGroup: React.FC<RadioButtonGroupProps> & {
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { omit } from 'lodash'
|
import omit from 'lodash/omit'
|
||||||
import React, { MutableRefObject, useEffect, useRef, useState } from 'react'
|
import React, { MutableRefObject, useEffect, useRef, useState } from 'react'
|
||||||
import { settleSync } from '../../utils/promise.utils'
|
import { settleSync } from '../../utils/promise.utils'
|
||||||
import { ResizeObserverContext } from './ResizeObserverContext'
|
import { ResizeObserverContext } from './ResizeObserverContext'
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useTabsContext } from '../Tabs/Tab.context'
|
import { useTabsContext } from '../Tabs/Tab.context'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { tabItemClasses } from './TabItem.classes'
|
import { tabItemClasses } from './TabItem.classes'
|
||||||
|
@ -39,7 +43,7 @@ export const TabItem: React.FC<TabItemProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { DropdownOption } from '../Dropdown'
|
import { DropdownOption } from '../Dropdown'
|
||||||
import { TableBody } from '../TableBody'
|
import { TableBody } from '../TableBody'
|
||||||
import { TableHeader } from '../TableHeader'
|
import { TableHeader } from '../TableHeader'
|
||||||
|
@ -32,7 +36,7 @@ export const Table: React.FC<TableProps> & {
|
||||||
return (
|
return (
|
||||||
<TableContext.Provider value={{ size, type, headerOptions }}>
|
<TableContext.Provider value={{ size, type, headerOptions }}>
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
tableClasses.root,
|
tableClasses.root,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { DropdownOption } from '../Dropdown'
|
import { DropdownOption } from '../Dropdown'
|
||||||
import { tableBodyClasses } from './TableBody.classes'
|
import { tableBodyClasses } from './TableBody.classes'
|
||||||
|
|
||||||
|
@ -26,7 +30,7 @@ export const TableBody: React.FC<TableBodyProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { tableHeaderClasses } from './TableHeader.classes'
|
import { tableHeaderClasses } from './TableHeader.classes'
|
||||||
|
|
||||||
export type TableHeaderProps = CommonProps &
|
export type TableHeaderProps = CommonProps &
|
||||||
|
@ -15,7 +19,7 @@ export const TableHeader: React.FC<TableHeaderProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useTableContext } from '../Table/Table.context'
|
import { useTableContext } from '../Table/Table.context'
|
||||||
import { tableItemClasses } from './TableItem.classes'
|
import { tableItemClasses } from './TableItem.classes'
|
||||||
|
|
||||||
|
@ -18,7 +22,7 @@ export const TableItem: React.FC<TableItemProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<td
|
<td
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Checkbox } from '../Checkbox'
|
import { Checkbox } from '../Checkbox'
|
||||||
import { RadioButton } from '../RadioButton'
|
import { RadioButton } from '../RadioButton'
|
||||||
import { useTableContext } from '../Table/Table.context'
|
import { useTableContext } from '../Table/Table.context'
|
||||||
|
@ -27,7 +31,7 @@ export const TableRow: React.FC<TableRowProps> & {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr
|
<tr
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useHorizontalScroll } from '../../utils/useHorizontalScroll'
|
import { useHorizontalScroll } from '../../utils/useHorizontalScroll'
|
||||||
import { NavigateBeforeIcon, NavigateNextIcon } from '../Icons'
|
import { NavigateBeforeIcon, NavigateNextIcon } from '../Icons'
|
||||||
import { TabItem } from '../TabItem'
|
import { TabItem } from '../TabItem'
|
||||||
|
@ -48,7 +52,7 @@ export const Tabs: React.FC<TabsProps> & {
|
||||||
<TabsContext.Provider value={{ activeTab: value, setActiveTab, size }}>
|
<TabsContext.Provider value={{ activeTab: value, setActiveTab, size }}>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { Typography } from '../Typography'
|
import { Typography } from '../Typography'
|
||||||
import { tagClasses } from './Tag.classes'
|
import { tagClasses } from './Tag.classes'
|
||||||
|
|
||||||
|
@ -29,7 +33,7 @@ export const Tag: React.FC<TagProps> & {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
aria-label={children as string}
|
aria-label={children as string}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React, { useRef } from 'react'
|
import React, { useRef } from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { useInput } from '../../utils/useInput'
|
import { useInput } from '../../utils/useInput'
|
||||||
import { IconButton } from '../IconButton'
|
import { IconButton } from '../IconButton'
|
||||||
import { CloseIcon, ErrorIcon } from '../Icons'
|
import { CloseIcon, ErrorIcon } from '../Icons'
|
||||||
|
@ -52,7 +56,7 @@ export const TextField: React.FC<TextFieldProps> & {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
aria-disabled={disabled ? 'true' : 'false'}
|
aria-disabled={disabled ? 'true' : 'false'}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
commonProps.className,
|
commonProps.className,
|
||||||
props.className,
|
props.className,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { CommonProps, useCommonProps } from '../../utils/useCommonProps'
|
import {
|
||||||
|
CommonProps,
|
||||||
|
omitCommonProps,
|
||||||
|
useCommonProps,
|
||||||
|
} from '../../utils/useCommonProps'
|
||||||
import { TypographyVariants } from '../Theme'
|
import { TypographyVariants } from '../Theme'
|
||||||
import { typographyClasses } from './Typography.classes'
|
import { typographyClasses } from './Typography.classes'
|
||||||
|
|
||||||
|
@ -66,7 +70,7 @@ export const Typography: React.FC<TypographyProps> & {
|
||||||
color && typographyClasses[color],
|
color && typographyClasses[color],
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...omitCommonProps(props)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Component>
|
</Component>
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
|
import omit from 'lodash/omit'
|
||||||
|
import pick from 'lodash/pick'
|
||||||
import { GlobalTypographyStyles } from '../components/Theme'
|
import { GlobalTypographyStyles } from '../components/Theme'
|
||||||
import { typographyClasses } from '../components/Typography/Typography.classes'
|
import { typographyClasses } from '../components/Typography/Typography.classes'
|
||||||
|
|
||||||
|
@ -6,6 +8,8 @@ export type CommonProps = {
|
||||||
genericFontFamily?: 'inherit' | GlobalTypographyStyles['genericFontFamily']
|
genericFontFamily?: 'inherit' | GlobalTypographyStyles['genericFontFamily']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const commonPropKeys: [keyof CommonProps] = ['genericFontFamily']
|
||||||
|
|
||||||
export const useCommonProps = ({ genericFontFamily }: CommonProps) => {
|
export const useCommonProps = ({ genericFontFamily }: CommonProps) => {
|
||||||
return {
|
return {
|
||||||
className: clsx(
|
className: clsx(
|
||||||
|
@ -15,3 +19,9 @@ export const useCommonProps = ({ genericFontFamily }: CommonProps) => {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const pickCommonProps = <T extends CommonProps>(props: T) =>
|
||||||
|
pick(props, commonPropKeys)
|
||||||
|
|
||||||
|
export const omitCommonProps = <T extends CommonProps>(props: T) =>
|
||||||
|
omit(props, commonPropKeys)
|
||||||
|
|
Loading…
Reference in New Issue