Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit 855e0c7

Browse files
committed
feat: update packages
1 parent 0ae6f22 commit 855e0c7

File tree

21 files changed

+4101
-3177
lines changed

21 files changed

+4101
-3177
lines changed

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = {
1717
collectCoverageFrom: ['src/@(components|utils)/**/*.@(ts|tsx)'],
1818
globals: {
1919
'ts-jest': {
20-
'tsConfigFile': './tsconfig.jest.json',
20+
'tsConfig': './tsconfig.jest.json',
21+
'isolatedModules': 'true'
2122
},
2223
},
2324
};

package-lock.json

Lines changed: 3952 additions & 3069 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,48 +34,49 @@
3434
"tslib": "^1.9.3"
3535
},
3636
"peerDependencies": {
37-
"react": "^16.4.1"
37+
"react-dom": "^16.5.2",
38+
"react": "^16.5.2"
3839
},
3940
"devDependencies": {
40-
"@commitlint/cli": "^7.0.0",
41-
"@commitlint/config-conventional": "^7.0.1",
42-
"@commitlint/travis-cli": "^7.0.0",
43-
"@types/enzyme-adapter-react-16": "^1.0.2",
44-
"@types/enzyme": "^3.1.12",
45-
"@types/jest": "^23.3.0",
46-
"@types/node": "^10.5.4",
47-
"@types/prop-types": "^15.5.3",
48-
"@types/react-dom": "^16.0.6",
49-
"@types/react": "^16.4.6",
50-
"all-contributors-cli": "^5.3.0",
41+
"@commitlint/cli": "^7.1.2",
42+
"@commitlint/config-conventional": "^7.1.2",
43+
"@commitlint/travis-cli": "^7.1.2",
44+
"@types/enzyme-adapter-react-16": "^1.0.3",
45+
"@types/enzyme": "^3.1.14",
46+
"@types/jest": "^23.3.2",
47+
"@types/node": "^10.11.2",
48+
"@types/prop-types": "^15.5.6",
49+
"@types/react-dom": "^16.0.8",
50+
"@types/react": "^16.4.14",
51+
"all-contributors-cli": "^5.4.0",
5152
"coveralls": "^3.0.2",
52-
"enzyme-adapter-react-16": "^1.4.0",
53+
"enzyme-adapter-react-16": "^1.5.0",
5354
"enzyme": "^3.6.0",
5455
"faker": "^4.1.0",
55-
"husky": "^1.0.0-rc.13",
56-
"jest": "^23.4.1",
57-
"lint-staged": "^7.2.0",
58-
"prettier": "^1.13.7",
59-
"react-docgen-typescript": "^1.6.2",
60-
"react-dom": "^16.4.1",
61-
"react-styleguidist": "^7.1.3",
62-
"react": "^16.4.1",
56+
"husky": "^1.0.1",
57+
"jest": "^23.6.0",
58+
"lint-staged": "^7.3.0",
59+
"prettier": "^1.14.3",
60+
"react-docgen-typescript": "^1.9.1",
61+
"react-dom": "^16.5.2",
62+
"react-styleguidist": "^7.3.8",
63+
"react": "^16.5.2",
6364
"rimraf": "^2.6.2",
64-
"rollup-plugin-commonjs": "^9.1.4",
65+
"rollup-plugin-commonjs": "^9.1.8",
6566
"rollup-plugin-filesize": "^4.0.1",
66-
"rollup-plugin-node-resolve": "^3.3.0",
67+
"rollup-plugin-node-resolve": "^3.4.0",
6768
"rollup-plugin-terser": "^3.0.0",
6869
"rollup-plugin-typescript2": "^0.17.0",
69-
"rollup-plugin-uglify": "^5.0.2",
70-
"rollup": "^0.66.0",
71-
"ts-jest": "^23.0.1",
72-
"ts-loader": "^4.4.2",
73-
"tslint-config-prettier": "^1.14.0",
70+
"rollup-plugin-uglify": "^6.0.0",
71+
"rollup": "^0.66.2",
72+
"ts-jest": "^23.10.1",
73+
"ts-loader": "^5.2.0",
74+
"tslint-config-prettier": "^1.15.0",
7475
"tslint-plugin-prettier": "^2.0.0",
7576
"tslint-react": "^3.6.0",
7677
"tslint": "^5.11.0",
77-
"typescript": "^3.0.1",
78-
"webpack": "^4.16.2"
78+
"typescript": "^3.1.1",
79+
"webpack": "^4.20.1"
7980
},
8081
"scripts": {
8182
"build": "npm run clean:build && rollup -c && npm run copy:build",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import pkg from './package.json';
99
const createConfig = ({ output, plugins, ...restConfig } = {}) => ({
1010
input: 'src/index.ts',
1111
output,
12-
external: ['react', 'prop-types', 'tslib'],
12+
external: ['react', 'react-dom', 'prop-types', 'tslib'],
1313
plugins: [
1414
typescript({
1515
tsconfig: './tsconfig.json',

src/components/List/List.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import * as PropTypes from 'prop-types';
22
import * as React from 'react';
33

4+
import { Map } from '../../types';
5+
46
export interface IListProps {
57
/** Array to map. */
68
items: any[];
79

810
/** Shorthand for primary content. */
9-
render?: (item?: any, index?: number, array?: any[]) => React.ReactNode;
11+
render?: Map;
1012

1113
/** Primary content. */
12-
children?: any;
14+
children?: Map;
1315
}
1416

1517
/**
1618
* Renders content from specified callback function from either `render` or `children` on each element of `items`.
1719
*/
18-
export const List: React.SFC<IListProps> = ({ items, render, children }) => {
20+
export const List: React.SFC<IListProps> = ({ items, children, render }) => {
1921
const itemRender = children ? children : render;
2022

2123
if (!itemRender) {

src/components/Show/Show.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import * as PropTypes from 'prop-types';
2-
import * as React from 'react';
32

4-
import { corePropTypes, getChildrenOrRender, ICoreProps } from '../../utils';
3+
import { IRenderProps, renderPropsPropTypes } from '../../types';
4+
import { getChildrenOrRender, renderIf } from '../../utils';
55

6-
export interface IShowProps extends ICoreProps {
6+
export interface IShowProps extends IRenderProps {
77
/** Conditional statement. */
88
when: boolean;
99
}
1010

1111
/**
1212
* Renders content if `when` equals true.
1313
*/
14-
export const Show: React.SFC<IShowProps> = ({ when, render, children }) => {
15-
return when ? getChildrenOrRender(children, render) : null;
14+
export const Show: React.SFC<IShowProps> = ({ when, children, render }) => {
15+
return renderIf(when)(getChildrenOrRender(children, render));
1616
};
1717

1818
Show.propTypes = {
1919
when: PropTypes.bool.isRequired,
20-
...corePropTypes,
20+
...renderPropsPropTypes,
2121
};
2222

2323
export default Show;

src/components/Switch/Switch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as PropTypes from 'prop-types';
22
import * as React from 'react';
33

4+
import { renderIf } from '../../utils';
45
import SwitchCase, { ISwitchCaseProps } from './SwitchCase';
56
import SwitchDefault from './SwitchDefault';
67

@@ -33,7 +34,7 @@ const isValidSwitchChild = (child: any): child is SwitchElement => {
3334
/**
3435
* Renders content from first `Switch.Case` that matches `value`, else `Switch.Default` if it exists.
3536
*/
36-
export const Switch: SwitchComponent = ({ value, children }) => {
37+
export const Switch: SwitchComponent = ({ children, value }) => {
3738
const switchValue = value;
3839
let match = false;
3940
let child: any;
@@ -52,11 +53,10 @@ export const Switch: SwitchComponent = ({ value, children }) => {
5253
}
5354

5455
// Return case if its a match.
55-
return match ? React.cloneElement(child) : null;
56+
return renderIf(match)(React.cloneElement(child));
5657
};
5758

5859
Switch.Case = SwitchCase;
59-
6060
Switch.Default = SwitchDefault;
6161

6262
Switch.propTypes = {

src/components/Switch/SwitchCase.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import * as PropTypes from 'prop-types';
2-
import * as React from 'react';
32

4-
import { corePropTypes, getChildrenOrRender, ICoreProps } from '../../utils/';
3+
import { IRenderProps, renderPropsPropTypes } from '../../types';
4+
import { getChildrenOrRender } from '../../utils/';
55

6-
export interface ISwitchCaseProps extends ICoreProps {
6+
export interface ISwitchCaseProps extends IRenderProps {
77
/** Conditional statement. */
88
value: any;
99
}
1010

1111
/**
1212
* Helper component that is accessed from `Switch` component.
1313
*/
14-
// @ts-ignore `value` prop is used by parent component Switch.
15-
export const SwitchCase: React.SFC<ISwitchCaseProps> = ({ value, render, children }) => {
14+
export const SwitchCase: React.SFC<ISwitchCaseProps> = ({ children, render }) => {
1615
return getChildrenOrRender(children, render);
1716
};
1817

1918
SwitchCase.propTypes = {
2019
value: PropTypes.any.isRequired,
21-
...corePropTypes,
20+
...renderPropsPropTypes,
2221
};
2322

2423
export default SwitchCase;
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import * as React from 'react';
2-
3-
import {
4-
corePropTypes,
5-
getChildrenOrRender,
6-
ICoreProps as ISwitchDefaultProps,
7-
} from '../../utils';
1+
import { IRenderProps, renderPropsPropTypes } from '../../types';
2+
import { getChildrenOrRender } from '../../utils/';
83

94
/**
105
* Helper component that is accessed from `Switch` component.
116
*/
12-
export const SwitchDefault: React.SFC<ISwitchDefaultProps> = ({ render, children }) => {
7+
export const SwitchDefault: React.SFC<IRenderProps> = ({ render, children }) => {
138
return getChildrenOrRender(children, render);
149
};
1510

16-
SwitchDefault.propTypes = corePropTypes;
11+
SwitchDefault.propTypes = renderPropsPropTypes;
1712

1813
export default SwitchDefault;

src/index.d.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
/// <reference types="react" />
22

3-
interface ICoreProps {
4-
/** Shorthand for primary content. */
5-
render?: () => React.ReactNode;
3+
type Render = (() => React.ReactNode) | null;
4+
5+
type Children = React.ReactNode | (() => React.ReactNode) | null;
66

7+
interface IRenderProps {
8+
/** Shorthand for primary content. */
9+
render?: Render;
710
/** Primary content. */
8-
children?: any;
11+
children?: Children;
912
}
1013

14+
type MapCallback =
15+
| ((item?: any, index?: number, array?: any[]) => React.ReactNode)
16+
| null;
17+
1118
declare module 'react-semantic-render/List' {
1219
interface IListProps {
1320
/** Array to map. */
1421
items: any[];
1522
/** Shorthand for primary content. */
16-
render?: (item?: any, index?: number, array?: any[]) => React.ReactNode;
23+
render?: MapCallback;
1724
/** Primary content. */
18-
children?: any;
25+
children?: MapCallback;
1926
}
2027

2128
/**
@@ -27,7 +34,7 @@ declare module 'react-semantic-render/List' {
2734
}
2835

2936
declare module 'react-semantic-render/Show' {
30-
interface IShowProps extends ICoreProps {
37+
interface IShowProps extends IRenderProps {
3138
/** Conditional statement. */
3239
when: boolean;
3340
}
@@ -76,7 +83,7 @@ declare module 'react-semantic-render/Switch' {
7683
children: React.ReactNode;
7784
}
7885

79-
interface ISwitchCaseProps extends ICoreProps {
86+
interface ISwitchCaseProps extends IRenderProps {
8087
/** Conditional statement. */
8188
value: any;
8289
}
@@ -89,7 +96,7 @@ declare module 'react-semantic-render/Switch' {
8996
/**
9097
* Helper component that is accessed from `Switch` component.
9198
*/
92-
const SwitchDefault: React.SFC<ICoreProps>;
99+
const SwitchDefault: React.SFC<IRenderProps>;
93100

94101
type SwitchComponent = React.SFC<ISwitchProps> & {
95102
Case?: typeof SwitchCase;

0 commit comments

Comments
 (0)