Skip to content

Fixed exports #27

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

Merged
merged 1 commit into from
Feb 27, 2021
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
6 changes: 1 addition & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties',
['babel-plugin-root-import', {
"rootPathSuffix": "src/",
"rootPathPrefix": "@/"
}]
'@babel/plugin-proposal-class-properties'
],
presets: [
'@babel/typescript',
Expand Down
5 changes: 1 addition & 4 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"setupFilesAfterEnv": ["./setupTests.ts"],
"moduleNameMapper": {
"@/(.*)": "<rootDir>/src/$1"
}
"setupFilesAfterEnv": ["./setupTests.ts"]
}
22,595 changes: 12 additions & 22,583 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@types/react-is": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"babel-plugin-root-import": "^6.6.0",
"dart-sass": "^1.25.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.3",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { Variant } from '@/components';
import { Variant } from '../utils';

export type ButtonComponentTypes = 'button' | 'a';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shallow } from 'enzyme';
import React from 'react';
import { Button } from '@/components/Button';
import { Variant } from '@/components';
import { Variant } from '../../utils';
import Button from '../Button';

describe('Button test', () => {
it('should render button', () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Button } from './Button';
export type { ButtonProps, ButtonComponentTypes } from './Button';
8 changes: 4 additions & 4 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import CardContent from '@/components/Card/Content';
import { ForwardComponentWithStatics } from '@/components/utils/ForwardComponentWithStatics';
import CardHeader from '@/components/Card/Header';
import { Variant } from '@/components';
import CardContent from './Content';
import { ForwardComponentWithStatics } from '../utils/ForwardComponentWithStatics';
import CardHeader from './Header';
import { Variant } from '../utils';

export type CardStatics = {
Content: typeof CardContent;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Card/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';

type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;

const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>((
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render } from 'enzyme';
import React from 'react';
import Card from '@/components/Card/Card';
import CardContent from '@/components/Card/Content';
import CardHeader from '@/components/Card/Header';
import { Variant } from '@/components';
import { Variant } from '../../utils';
import Card from '../Card';
import CardContent from '../Content';
import CardHeader from '../Header';

describe('Card test', () => {
it('should render card', () => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Card/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { default as Card } from './Card';
export type { CardProps, CardStatics } from './Card';

export { default as CardContent } from './Content';
export type { CardContentProps } from './Content';

export { default as CardHeader } from './Header';
export type { CardHeaderProps } from './Header'
2 changes: 1 addition & 1 deletion src/components/Container/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
export interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
fluid?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from 'enzyme';
import React from 'react';
import Container from '@/components/Container/Container';
import Container from '../Container';

describe('Container test', () => {
it('should render container', () => {
Expand Down
1 change: 1 addition & 0 deletions src/components/Container/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Container } from './Container';
export type { ContainerProps } from './Container';
28 changes: 17 additions & 11 deletions src/components/Field/FieldBase.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { Icon, Variant } from '@/components';
import clsx from 'clsx';
import { ReactElement, useState } from 'react';
import { Icon } from '../Icon';
import { FieldContext } from './FieldContext';
import { Variant } from '../utils';

interface FieldBaseProps {
export interface FieldBaseProps {
actions?: React.ReactNode;
className?: string;
label?: React.ReactNode;
valid?: boolean;
variant?: Variant | string;
value?: string | ReadonlyArray<string> | number;
children?: React.ReactNode;
}

export const getStateIcon = (valid: boolean | undefined): ReactElement | undefined => {
Expand All @@ -32,20 +34,23 @@ export const getStateIcon = (valid: boolean | undefined): ReactElement | undefin
);
}

const FieldBaseProps = ({
actions,
className,
children,
label,
variant = Variant.PRIMARY,
valid
}: React.PropsWithChildren<FieldBaseProps>,
const FieldBaseProps = React.forwardRef<HTMLDivElement, FieldBaseProps>((
{
actions,
className,
children,
label,
variant = Variant.PRIMARY,
valid
},
ref
): React.ReactElement => {
const [hasValue, setHasValue] = useState<boolean>(false);
const [hasFocus, setHasFocus] = useState<boolean>(false);

return (
<div
ref={ref}
className={clsx(
'form-field-base',
`form-field-${variant}`,
Expand Down Expand Up @@ -79,10 +84,11 @@ const FieldBaseProps = ({
)}
</div>
);
};
});

export const propTypes = {
actions: PropTypes.node,
className: PropTypes.string,
children: PropTypes.node,
label: PropTypes.node,
onChange: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Field/FieldContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

interface FieldContainerProps extends React.HTMLAttributes<HTMLDivElement> {
export interface FieldContainerProps extends React.HTMLAttributes<HTMLDivElement> {
toggles?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { mount, render } from 'enzyme';
import FieldBase from '@/components/Field/FieldBase';
import { Variant } from '@/components';
import { FieldContext } from '@/components/Field/FieldContext';
import FieldBase from '../FieldBase';
import { Variant } from '../../utils';
import { FieldContext } from '../FieldContext';

describe('FieldBase test', () => {
it('should render field base', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from 'enzyme';
import React from 'react';
import FieldContainer from '@/components/Field/FieldContainer';
import FieldContainer from '../FieldContainer';

describe('FieldBase test', () => {
it('should render field container', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render } from 'enzyme';
import { FieldContext } from '@/components/Field/FieldContext';
import { FieldContext } from '../FieldContext';

describe('FieldContext test', () => {
it('should use default values when no consumer used', () => {
Expand Down
9 changes: 9 additions & 0 deletions src/components/Field/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export { default as FieldBase, propTypes } from './FieldBase';
export type { FieldBaseProps } from './FieldBase';

export { default as FieldContainer } from './FieldContainer';
export type { FieldContainerProps } from './FieldContainer';

export { FieldContext } from './FieldContext';
export type { FieldContextProps } from './FieldContext';

3 changes: 1 addition & 2 deletions src/components/Form/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

interface FormGroupProps extends React.HTMLAttributes<HTMLDivElement> {
}
export type FormGroupProps = React.HTMLAttributes<HTMLDivElement>;

const FormGroup = React.forwardRef<HTMLDivElement, FormGroupProps>((
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

type FormLabelProps = React.LabelHTMLAttributes<HTMLLabelElement>;
export type FormLabelProps = React.LabelHTMLAttributes<HTMLLabelElement>;

const FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>((
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

interface FormMessageProps extends React.HTMLAttributes<HTMLDivElement> {
export interface FormMessageProps extends React.HTMLAttributes<HTMLDivElement> {
className?: string;
valid?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render } from 'enzyme';
import React from 'react';
import FormGroup from '@/components/Form/Group';
import FormLabel from '@/components/Form/Label';
import FormMessage from '@/components/Form/Message';
import FormGroup from '../Group';
import FormLabel from '../Label';
import FormMessage from '../Message';

describe('Form test', () => {
it('should render form-group', () => {
Expand Down
8 changes: 8 additions & 0 deletions src/components/Form/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export { default as FormGroup } from './Group';
export type { FormGroupProps } from './Group';

export { default as FormLabel } from './Label';
export type { FormLabelProps } from './Label';

export { default as FormMessage } from './Message';
export type { FormMessageProps } from './Message';
2 changes: 1 addition & 1 deletion src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
columns?: string | number;
gap?: string | number;
rows?: string | number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Grid/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';

type RowProps = React.HTMLAttributes<HTMLDivElement>;
export type RowProps = React.HTMLAttributes<HTMLDivElement>;

const Row = React.forwardRef<HTMLDivElement, RowProps>((
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render } from 'enzyme';
import React from 'react';
import { Col, Grid, Row } from '@/components';
import Col from '../Col';
import Grid from '../Grid';
import Row from '../Row';

describe('Grid test', () => {
it('should render grid', () => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/Grid/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { default as Grid } from './Grid';
export type { GridProps } from './Grid';

export { default as Row } from './Row';
export type { RowProps } from './Row';

export { default as Col } from './Col';
export type { ColProps } from './Col';
4 changes: 2 additions & 2 deletions src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { IconName } from '@/components/Icon/IconName';
import { IconName } from './IconName';

interface IconProps extends React.HTMLAttributes<HTMLElement> {
export interface IconProps extends React.HTMLAttributes<HTMLElement> {
icon: IconName | string;
size?: string | number;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from 'enzyme';
import { Icon } from '@/components';
import React from 'react';
import Icon from '../Icon';

describe('Icon test', () => {
it('should render icon', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Icon/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { default as Icon } from './Icon';
export type { IconProps } from './Icon';

export type { IconName } from './IconName'
4 changes: 2 additions & 2 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import clsx from 'clsx';
import { createPortal } from 'react-dom';
import { useEffect, useRef, useState } from 'react';
import { mergeRefs } from '@/components/utils/mergeRefs';
import { ModalManager } from '@/components/Modal/modalManager';
import { ModalManager } from './modalManager';
import { mergeRefs } from '../utils/mergeRefs';

let modalManager: ModalManager;

Expand Down
3 changes: 1 addition & 2 deletions src/components/Modal/__tests__/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
import { Modal } from '@/components';
import { ModalProps } from '@/components/Modal/Modal';
import Modal, { ModalProps } from '../Modal';

describe('Test modal', function (): void {
it('should render modal', (): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal/__tests__/modalManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ModalManager } from '@/components/Modal/modalManager';
import { createRef } from 'react';
import { ModalManager } from '../modalManager';

describe('Test modalManager', function () {
it('should add backdrop if modal needs it', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Modal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as Modal, getManager } from './Modal';
export type { ModalProps } from './Modal';

export type { StoredModal } from './modalManager';
1 change: 0 additions & 1 deletion src/components/Modal/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import PropTypes from 'prop-types';
import { Modifier } from '@popperjs/core/lib/types';
import clsx from 'clsx';
import { AnimationFeature, ExitFeature, HTMLMotionProps, m as motion, MotionConfig } from 'framer-motion';
import { motionsMap } from '@/components/animations/motionsMap';
import { motionsMap } from '../animations';

interface OverlayProps {
export interface OverlayProps {
className?: string;
triggerRef: React.MutableRefObject<HTMLElement | undefined>;
placement?: Placement;
Expand Down
Loading