Skip to content

Commit

Permalink
fix(exports): use default exports
Browse files Browse the repository at this point in the history
  • Loading branch information
spudly committed Jul 15, 2022
1 parent 31ab81f commit 644d109
Show file tree
Hide file tree
Showing 102 changed files with 255 additions and 160 deletions.
10 changes: 7 additions & 3 deletions src/_internal/contexts/ExitContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {createContext} from 'react';

export const ExitContext = createContext(() => {
// noop
});
const noop = () => {
// nothing
};

const ExitContext = createContext(noop);

export default ExitContext;
4 changes: 3 additions & 1 deletion src/_internal/hooks/useCloseOnClickOutside.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useEffect} from 'react';
import type {MutableRefObject} from 'react';

export const useCloseOnClickOutside = (
const useCloseOnClickOutside = (
isOpen: boolean,
close: () => void,
containerRef: MutableRefObject<HTMLElement | null>,
Expand All @@ -25,3 +25,5 @@ export const useCloseOnClickOutside = (
}
}, [isOpen, close, containerRef]);
};

export default useCloseOnClickOutside;
2 changes: 1 addition & 1 deletion src/components/a11y/SkipLink.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {SkipLink as SkipLinkComponent} from './SkipLink.js';
import SkipLinkComponent from './SkipLink.js';

const meta = {
title: 'Base/A11y/SkipLink',
Expand Down
4 changes: 3 additions & 1 deletion src/components/a11y/SkipLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Props = {
children?: ReactNode;
};

export const SkipLink: FC<Props> = ({href, children = 'Skip to Content'}) => {
const SkipLink: FC<Props> = ({href, children = 'Skip to Content'}) => {
if (!isValidHashHref(href)) {
throw new Error('Hash link href is invalid!');
}
Expand All @@ -20,3 +20,5 @@ export const SkipLink: FC<Props> = ({href, children = 'Skip to Content'}) => {
</a>
);
};

export default SkipLink;
2 changes: 1 addition & 1 deletion src/components/buttons/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Button as Component} from './Button.js';
import Component from './Button.js';

const meta = {
title: 'Base/Buttons/Button',
Expand Down
4 changes: 3 additions & 1 deletion src/components/buttons/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type StyleData = {
type Props = StyleableProps<JSX.IntrinsicElements['button'], StyleData> &
StyleData & {remove?: () => void};

export const Button = forwardRef<HTMLButtonElement, Props>(
const Button = forwardRef<HTMLButtonElement, Props>(
(
{
type = 'button',
Expand Down Expand Up @@ -42,3 +42,5 @@ export const Button = forwardRef<HTMLButtonElement, Props>(
);
},
);

export default Button;
4 changes: 2 additions & 2 deletions src/components/buttons/ButtonGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {FC} from 'react';
import {ButtonGroup as Component} from './ButtonGroup.js';
import {Button} from './Button.js';
import Component from './ButtonGroup.js';
import Button from './Button.js';

const meta = {
title: 'Base/Buttons/ButtonGroup',
Expand Down
6 changes: 4 additions & 2 deletions src/components/buttons/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {ComponentProps, ReactElement, ReactNode, FC} from 'react';
import {cloneElement, isValidElement, Children} from 'react';
import type {DockConfig} from '../../_internal/utils/dock.js';
import {mergeDockConfigs} from '../../_internal/utils/dock.js';
import {Button} from './Button.js';
import Button from './Button.js';

type ButtonElement = ReactElement<ComponentProps<typeof Button>, typeof Button>;

Expand All @@ -14,7 +14,7 @@ type Props = {
const isButton = (child: ReactNode): child is ButtonElement =>
isValidElement(child) && child.type === Button;

export const ButtonGroup: FC<Props> = ({dock, children}) => {
const ButtonGroup: FC<Props> = ({dock, children}) => {
const buttons = Children.toArray(children).filter(isButton);
return (
<div className="flex">
Expand All @@ -31,3 +31,5 @@ export const ButtonGroup: FC<Props> = ({dock, children}) => {
</div>
);
};

export default ButtonGroup;
2 changes: 1 addition & 1 deletion src/components/buttons/DropdownButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {DropdownButton as DropdownButtonComponent} from './DropdownButton.js';
import DropdownButtonComponent from './DropdownButton.js';

const meta = {
title: 'Base/Buttons/DropdownButton',
Expand Down
12 changes: 7 additions & 5 deletions src/components/buttons/DropdownButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {ComponentProps, FC, ReactNode} from 'react';
import {ExitContext} from '../../_internal/contexts/ExitContext.js';
import ExitContext from '../../_internal/contexts/ExitContext.js';
import {useToggle} from '../../_internal/hooks/useToggle.js';
import {CollapsibleIcon} from '../icons/CollapsibleIcon.js';
import {Dropdown} from '../overlays/Dropdown.js';
import {Button} from './Button.js';
import CollapsibleIcon from '../icons/CollapsibleIcon.js';
import Dropdown from '../overlays/Dropdown.js';
import Button from './Button.js';

type Props = ComponentProps<typeof Button> &
Omit<
Expand All @@ -13,7 +13,7 @@ type Props = ComponentProps<typeof Button> &
label: ReactNode;
};

export const DropdownButton: FC<Props> = ({
const DropdownButton: FC<Props> = ({
placement,
children,
label,
Expand All @@ -35,3 +35,5 @@ export const DropdownButton: FC<Props> = ({
</Dropdown>
);
};

export default DropdownButton;
2 changes: 1 addition & 1 deletion src/components/buttons/IconButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {FC} from 'react';
import {MdAdd} from 'react-icons/md/index.js';
import {IconButton as IconButtonComponent} from './IconButton.js';
import IconButtonComponent from './IconButton.js';

const meta = {
title: 'Base/Buttons/IconButton',
Expand Down
4 changes: 3 additions & 1 deletion src/components/buttons/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {FC} from 'react';
import type {Unstyled} from '../../_internal/utils/types.js';

export const IconButton: FC<Unstyled<'button'> & {title: string}> = props => (
const IconButton: FC<Unstyled<'button'> & {title: string}> = props => (
<button
{...props}
type="button"
className="transform p-1 duration-75 hover:scale-150"
/>
);

export default IconButton;
2 changes: 1 addition & 1 deletion src/components/buttons/LinkButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {LinkButton as LinkButtonComponent} from './LinkButton.js';
import LinkButtonComponent from './LinkButton.js';

const meta = {
title: 'Base/Buttons/Link Button',
Expand Down
4 changes: 3 additions & 1 deletion src/components/buttons/LinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import type {FC} from 'react';
import type {Unstyled} from '../../_internal/utils/types.js';
import {getHyperlinkClasses} from '../../_internal/utils/getHyperlinkClasses.js';

export const LinkButton: FC<Unstyled<'button'>> = ({children, ...rest}) => (
const LinkButton: FC<Unstyled<'button'>> = ({children, ...rest}) => (
<button {...rest} type="button" className={getHyperlinkClasses()}>
{children}
</button>
);

export default LinkButton;
2 changes: 1 addition & 1 deletion src/components/buttons/TabButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {FC} from 'react';
import {MdBrowserNotSupported} from 'react-icons/md/index.js';
import {TabButton as Component} from './TabButton.js';
import Component from './TabButton.js';

const meta = {
title: 'Base/Buttons/TabButton',
Expand Down
6 changes: 4 additions & 2 deletions src/components/buttons/TabButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {FC, ComponentProps} from 'react';
import type {DockConfig} from '../../_internal/utils/dock.js';
import {Button} from './Button.js';
import Button from './Button.js';

const DEFAULT_DOCK: DockConfig = {bottom: true};

export const TabButton: FC<ComponentProps<typeof Button>> = ({
const TabButton: FC<ComponentProps<typeof Button>> = ({
dock = DEFAULT_DOCK,
...rest
}) => <Button dock={dock} {...rest} />;

export default TabButton;
4 changes: 2 additions & 2 deletions src/components/buttons/TabButtonGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {FC} from 'react';
import {MdClose} from 'react-icons/md/index.js';
import {Button} from './Button.js';
import {TabButtonGroup as Component} from './TabButtonGroup.js';
import Button from './Button.js';
import Component from './TabButtonGroup.js';

const meta = {
title: 'Base/Buttons/TabButtonGroup',
Expand Down
6 changes: 4 additions & 2 deletions src/components/buttons/TabButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {FC, ComponentProps} from 'react';
import type {DockConfig} from '../../_internal/utils/dock.js';
import {ButtonGroup} from './ButtonGroup.js';
import ButtonGroup from './ButtonGroup.js';

const DEFAULT_DOCK: DockConfig = {bottom: true};

export const TabButtonGroup: FC<ComponentProps<typeof ButtonGroup>> = ({
const TabButtonGroup: FC<ComponentProps<typeof ButtonGroup>> = ({
dock = DEFAULT_DOCK,
...rest
}) => <ButtonGroup dock={dock} {...rest} />;

export default TabButtonGroup;
2 changes: 1 addition & 1 deletion src/components/feedback/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Alert as AlertComponent} from './Alert.js';
import AlertComponent from './Alert.js';

const meta = {
title: 'Base/Feedback/Alert',
Expand Down
4 changes: 3 additions & 1 deletion src/components/feedback/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {FC, ReactNode} from 'react';

const clsx = defaultImport(_clsx);

export const Alert: FC<{
const Alert: FC<{
type?: 'danger' | 'error' | 'info' | 'success' | 'warning';
children?: ReactNode;
}> = ({type = 'info', children}) => (
Expand All @@ -30,3 +30,5 @@ export const Alert: FC<{
{children}
</div>
);

export default Alert;
2 changes: 1 addition & 1 deletion src/components/feedback/ProgressSpinner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {ProgressSpinner as Component} from './ProgressSpinner.js';
import Component from './ProgressSpinner.js';

const meta = {
title: 'Base/Feedback/Progress Spinner',
Expand Down
4 changes: 3 additions & 1 deletion src/components/feedback/ProgressSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {defaultImport} from 'default-import';

const clsx = defaultImport(_clsx);

export const ProgressSpinner: FC<{progress: number; grow?: boolean}> = ({
const ProgressSpinner: FC<{progress: number; grow?: boolean}> = ({
progress,
grow,
}) => {
Expand Down Expand Up @@ -49,3 +49,5 @@ export const ProgressSpinner: FC<{progress: number; grow?: boolean}> = ({
</div>
);
};

export default ProgressSpinner;
2 changes: 1 addition & 1 deletion src/components/feedback/Spinner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Spinner as Component} from './Spinner.js';
import Component from './Spinner.js';

const meta = {
title: 'Base/Feedback/Spinner',
Expand Down
7 changes: 3 additions & 4 deletions src/components/feedback/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import {defaultImport} from 'default-import';

const clsx = defaultImport(_clsx);

export const Spinner: FC<{grow?: boolean; delay?: number}> = ({
grow,
delay = 100,
}) => {
const Spinner: FC<{grow?: boolean; delay?: number}> = ({grow, delay = 100}) => {
const [shouldShow, setShouldShow] = useState(delay === 0);

useEffect(() => {
Expand Down Expand Up @@ -81,3 +78,5 @@ export const Spinner: FC<{grow?: boolean; delay?: number}> = ({
</div>
);
};

export default Spinner;
2 changes: 1 addition & 1 deletion src/components/form-controls/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Checkbox as Component} from './Checkbox.js';
import Component from './Checkbox.js';

const meta = {
title: 'Base/Forms/Controls/Checkbox',
Expand Down
4 changes: 3 additions & 1 deletion src/components/form-controls/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {FC} from 'react';
import type {FieldMeta} from '../../_internal/utils/types.js';
import {getFieldClasses} from '../../_internal/utils/getFieldClasses.js';

export const Checkbox: FC<
const Checkbox: FC<
JSX.IntrinsicElements['input'] & {
meta?: Omit<FieldMeta, 'dock' | 'isCheckbox' | 'isRadio'>;
}
Expand All @@ -14,3 +14,5 @@ export const Checkbox: FC<
className={getFieldClasses({...meta, block: false, isCheckbox: true})}
/>
);

export default Checkbox;
2 changes: 1 addition & 1 deletion src/components/form-controls/Radio.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Radio as Component} from './Radio.js';
import Component from './Radio.js';

const meta = {
title: 'Base/Forms/Controls/Radio',
Expand Down
4 changes: 3 additions & 1 deletion src/components/form-controls/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {FC} from 'react';
import type {FieldMeta} from '../../_internal/utils/types.js';
import {getFieldClasses} from '../../_internal/utils/getFieldClasses.js';

export const Radio: FC<
const Radio: FC<
JSX.IntrinsicElements['input'] & {meta?: Omit<FieldMeta, 'dock' | 'isRadio'>}
> = ({meta, ...rest}) => (
<input
Expand All @@ -11,3 +11,5 @@ export const Radio: FC<
className={getFieldClasses({...meta, block: false, isRadio: true})}
/>
);

export default Radio;
2 changes: 1 addition & 1 deletion src/components/form-controls/RadioSelect.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {RadioSelect as Component} from './RadioSelect.js';
import Component from './RadioSelect.js';

const meta = {
title: 'Base/Forms/Controls/RadioSelect',
Expand Down
8 changes: 5 additions & 3 deletions src/components/form-controls/RadioSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type {ChangeEvent, FC, ReactNode} from 'react';
import {Children} from 'react';
import type {FieldMeta} from '../../_internal/utils/types.js';
import {Label} from '../form-layout/Label.js';
import Label from '../form-layout/Label.js';
import {getOptionLabel} from '../../_internal/utils/getOptionLabel.js';
import {getOptionValue} from '../../_internal/utils/getOptionValue.js';
import {isOptionElement} from '../../_internal/utils/isOptionElement.js';
import {Radio} from './Radio.js';
import Radio from './Radio.js';

export const RadioSelect: FC<{
const RadioSelect: FC<{
name: string;
value?: string;
defaultValue?: string;
Expand Down Expand Up @@ -41,3 +41,5 @@ export const RadioSelect: FC<{
</div>
);
};

export default RadioSelect;
2 changes: 1 addition & 1 deletion src/components/form-controls/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {FC} from 'react';
import {Select as Component} from './Select.js';
import Component from './Select.js';

const meta = {
title: 'Base/Forms/Controls/Select',
Expand Down
4 changes: 3 additions & 1 deletion src/components/form-controls/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {MdExpandMore} from 'react-icons/md/index.js';
import type {FieldMeta, Unstyled} from '../../_internal/utils/types.js';
import {getFieldClasses} from '../../_internal/utils/getFieldClasses.js';

export const Select: FC<Unstyled<'select'> & {meta?: FieldMeta}> = ({
const Select: FC<Unstyled<'select'> & {meta?: FieldMeta}> = ({
meta,
...props
}) => (
Expand All @@ -18,3 +18,5 @@ export const Select: FC<Unstyled<'select'> & {meta?: FieldMeta}> = ({
</div>
</div>
);

export default Select;
Loading

0 comments on commit 644d109

Please sign in to comment.