Skip to content

Commit 435b193

Browse files
committed
Release 0.17.21
1 parent 8b99031 commit 435b193

17 files changed

+47
-33
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-form-controlled",
3-
"version": "0.17.20",
3+
"version": "0.17.21",
44
"description": "Intuitive react forms for building powerful applications",
55
"author": {
66
"name": "Zlatko Fedor",
@@ -38,12 +38,13 @@
3838
},
3939
"dependencies": {
4040
"diacritics": "^1.3.0",
41-
"lodash": "^4.17.4"
41+
"lodash": "^4.17.4",
42+
"prop-types": "^15.5.8"
4243
},
4344
"devDependencies": {
4445
"babel-cli": "^6.24.1",
4546
"babel-core": "^6.24.1",
46-
"babel-eslint": "^7.2.1",
47+
"babel-eslint": "^7.2.2",
4748
"babel-plugin-transform-class-properties": "^6.24.1",
4849
"babel-plugin-transform-decorators-legacy": "^1.3.4",
4950
"babel-plugin-transform-proto-to-assign": "^6.23.0",
@@ -60,13 +61,13 @@
6061
"gulp": "^3.9.1",
6162
"gulp-babel": "^6.1.2",
6263
"gulp-util": "^3.0.8",
63-
"react": "^15.4.2",
64-
"react-addons-test-utils": "^15.4.2",
64+
"react": "^15.5.4",
65+
"react-addons-test-utils": "^15.5.1",
6566
"eslint-plugin-jsx-a11y": "^4.0.0",
66-
"react-dom": "^15.4.2",
67+
"react-dom": "^15.5.4",
6768
"jest": "^19.0.2",
6869
"jest-cli": "^19.0.2",
69-
"enzyme": "^2.8.0"
70+
"enzyme": "^2.8.2"
7071
},
7172
"peerDependencies": {
7273
"react": "15.x"

src/Button.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes, cloneElement } from 'react';
1+
import React, { cloneElement } from 'react';
2+
import PropTypes from 'prop-types';
23
import Element from './Element';
34
import wait from './utils/wait';
45

src/Down.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default class Down extends Button {
66
};
77

88
async process() {
9-
return await this.getParent().down();
9+
return this.getParent().down();
1010
}
1111
}

src/Element.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, PropTypes } from 'react';
1+
import { Component } from 'react';
2+
import PropTypes from 'prop-types';
23
import shallowEqual from './utils/shallowCompare';
34

45
export default class Element extends Component {

src/Fieldset.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { PropTypes, createElement } from 'react';
1+
import React, { createElement } from 'react';
2+
import PropTypes from 'prop-types';
23
import get from 'lodash/get';
3-
import isPlainObject from 'lodash/isPlainObject';
44
import Element from './Element';
55
import set from './utils/set';
66
import traverse from './utils/traverse';
@@ -35,7 +35,7 @@ export default class Fieldset extends Element {
3535
constructor(...args) {
3636
super(...args);
3737

38-
this.children = [];
38+
this.registeredChildren = [];
3939
}
4040

4141
getIndexes() {
@@ -67,8 +67,8 @@ export default class Fieldset extends Element {
6767
}
6868

6969
notifyChildren() {
70-
const { children } = this;
71-
children.forEach(child => child.originalValueChanged());
70+
const { registeredChildren } = this;
71+
registeredChildren.forEach(child => child.originalValueChanged());
7272
}
7373

7474
registerChild(child, name) {
@@ -78,7 +78,7 @@ export default class Fieldset extends Element {
7878
return;
7979
}
8080

81-
this.children.push(child);
81+
this.registeredChildren.push(child);
8282
}
8383

8484
unregisterChild(child, name) {
@@ -88,9 +88,9 @@ export default class Fieldset extends Element {
8888
return;
8989
}
9090

91-
const pos = this.children.indexOf(child);
91+
const pos = this.registeredChildren.indexOf(child);
9292
if (pos !== -1) {
93-
this.children.splice(pos, 1);
93+
this.registeredChildren.splice(pos, 1);
9494
}
9595
}
9696

src/Form.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PropTypes, createElement } from 'react';
1+
import { createElement } from 'react';
2+
import PropTypes from 'prop-types';
23
import Fieldset from './Fieldset';
34

45
export default class Form extends Fieldset {

src/If.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PropTypes, Children } from 'react';
1+
import { Children } from 'react';
2+
import PropTypes from 'prop-types';
23
import Element from './Element';
34

45
export default class If extends Element {

src/Input.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import Element from './Element';
34

45
function fixUncontrolledValue(value) {

src/Integrate.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PropTypes, cloneElement } from 'react';
1+
import { cloneElement } from 'react';
2+
import PropTypes from 'prop-types';
23
import Element from './Element';
34

45
export default class Integrate extends Element {

src/ProvideProps.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes, cloneElement } from 'react';
1+
import React, { cloneElement } from 'react';
2+
import PropTypes from 'prop-types';
23
import Element from './Element';
34

45
export default class ProvideProps extends Element {

src/Remove.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default class Remove extends Button {
66
};
77

88
async process() {
9-
return await this.getParent().remove();
9+
return this.getParent().remove();
1010
}
1111
}

src/Select.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import isPlainObject from 'lodash/isPlainObject';
2-
import React, { PropTypes } from 'react';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
34
import Element from './Element';
45

56
const PLACEHOLDER_VALUE = ''; // null and undefined is uncontrolled value

src/Textarea.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import Input from './Input';
34

45
export default class Textarea extends Input {

src/Up.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default class Up extends Button {
66
};
77

88
async process() {
9-
return await this.getParent().up();
9+
return this.getParent().up();
1010
}
1111
}

src/Working.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react';
12
import ProvideProps from './ProvideProps';
23

34
export default class Working extends ProvideProps {

src/utils/markAsDirty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function markAsDirty(value, originalPath, updateCallback) {
2424
const parts = path.split('.');
2525

2626
let current = start;
27-
for (let i = 0; i < parts.length; i++) {
27+
for (let i = 0; i < parts.length; i += 1) {
2828
const key = parts[i];
2929
current[key] = dirty(current[key]);
3030

src/utils/traverse.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Element from '../Element';
33

44
export default function traverse(child, processCallback, replaceCallback) {
55
if (Array.isArray(child)) {
6-
return Children.map(child, children => traverse(children, processCallback, replaceCallback));
6+
return Children
7+
.map(child, children => traverse(children, processCallback, replaceCallback));
78
}
89

910
if (!child || typeof child === 'string') {
@@ -28,14 +29,16 @@ export default function traverse(child, processCallback, replaceCallback) {
2829
}
2930
}
3031

31-
if (child.props && child.props.children) {
32-
const children = traverse(child.props.children, processCallback, replaceCallback);
32+
// support for preact
33+
const children = (child.props && child.props.children) || child.children;
34+
if (children) {
35+
const traversedChildren = traverse(children, processCallback, replaceCallback);
3336
// speed up
34-
if (children === child.props.children) {
37+
if (traversedChildren === children) {
3538
return child;
3639
}
3740

38-
return cloneElement(child, {}, children);
41+
return cloneElement(child, {}, traversedChildren);
3942
}
4043

4144
return child;

0 commit comments

Comments
 (0)