Skip to content

Commit

Permalink
Release 0.17.21
Browse files Browse the repository at this point in the history
  • Loading branch information
seeden committed Apr 20, 2017
1 parent 8b99031 commit 435b193
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 33 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-form-controlled",
"version": "0.17.20",
"version": "0.17.21",
"description": "Intuitive react forms for building powerful applications",
"author": {
"name": "Zlatko Fedor",
Expand Down Expand Up @@ -38,12 +38,13 @@
},
"dependencies": {
"diacritics": "^1.3.0",
"lodash": "^4.17.4"
"lodash": "^4.17.4",
"prop-types": "^15.5.8"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.1",
"babel-eslint": "^7.2.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-proto-to-assign": "^6.23.0",
Expand All @@ -60,13 +61,13 @@
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-util": "^3.0.8",
"react": "^15.4.2",
"react-addons-test-utils": "^15.4.2",
"react": "^15.5.4",
"react-addons-test-utils": "^15.5.1",
"eslint-plugin-jsx-a11y": "^4.0.0",
"react-dom": "^15.4.2",
"react-dom": "^15.5.4",
"jest": "^19.0.2",
"jest-cli": "^19.0.2",
"enzyme": "^2.8.0"
"enzyme": "^2.8.2"
},
"peerDependencies": {
"react": "15.x"
Expand Down
3 changes: 2 additions & 1 deletion src/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes, cloneElement } from 'react';
import React, { cloneElement } from 'react';
import PropTypes from 'prop-types';
import Element from './Element';
import wait from './utils/wait';

Expand Down
2 changes: 1 addition & 1 deletion src/Down.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default class Down extends Button {
};

async process() {
return await this.getParent().down();
return this.getParent().down();
}
}
3 changes: 2 additions & 1 deletion src/Element.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, PropTypes } from 'react';
import { Component } from 'react';
import PropTypes from 'prop-types';
import shallowEqual from './utils/shallowCompare';

export default class Element extends Component {
Expand Down
16 changes: 8 additions & 8 deletions src/Fieldset.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PropTypes, createElement } from 'react';
import React, { createElement } from 'react';
import PropTypes from 'prop-types';
import get from 'lodash/get';
import isPlainObject from 'lodash/isPlainObject';
import Element from './Element';
import set from './utils/set';
import traverse from './utils/traverse';
Expand Down Expand Up @@ -35,7 +35,7 @@ export default class Fieldset extends Element {
constructor(...args) {
super(...args);

this.children = [];
this.registeredChildren = [];
}

getIndexes() {
Expand Down Expand Up @@ -67,8 +67,8 @@ export default class Fieldset extends Element {
}

notifyChildren() {
const { children } = this;
children.forEach(child => child.originalValueChanged());
const { registeredChildren } = this;
registeredChildren.forEach(child => child.originalValueChanged());
}

registerChild(child, name) {
Expand All @@ -78,7 +78,7 @@ export default class Fieldset extends Element {
return;
}

this.children.push(child);
this.registeredChildren.push(child);
}

unregisterChild(child, name) {
Expand All @@ -88,9 +88,9 @@ export default class Fieldset extends Element {
return;
}

const pos = this.children.indexOf(child);
const pos = this.registeredChildren.indexOf(child);
if (pos !== -1) {
this.children.splice(pos, 1);
this.registeredChildren.splice(pos, 1);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Form.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropTypes, createElement } from 'react';
import { createElement } from 'react';
import PropTypes from 'prop-types';
import Fieldset from './Fieldset';

export default class Form extends Fieldset {
Expand Down
3 changes: 2 additions & 1 deletion src/If.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropTypes, Children } from 'react';
import { Children } from 'react';
import PropTypes from 'prop-types';
import Element from './Element';

export default class If extends Element {
Expand Down
3 changes: 2 additions & 1 deletion src/Input.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Element from './Element';

function fixUncontrolledValue(value) {
Expand Down
3 changes: 2 additions & 1 deletion src/Integrate.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PropTypes, cloneElement } from 'react';
import { cloneElement } from 'react';
import PropTypes from 'prop-types';
import Element from './Element';

export default class Integrate extends Element {
Expand Down
3 changes: 2 additions & 1 deletion src/ProvideProps.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes, cloneElement } from 'react';
import React, { cloneElement } from 'react';
import PropTypes from 'prop-types';
import Element from './Element';

export default class ProvideProps extends Element {
Expand Down
2 changes: 1 addition & 1 deletion src/Remove.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default class Remove extends Button {
};

async process() {
return await this.getParent().remove();
return this.getParent().remove();
}
}
3 changes: 2 additions & 1 deletion src/Select.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import isPlainObject from 'lodash/isPlainObject';
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Element from './Element';

const PLACEHOLDER_VALUE = ''; // null and undefined is uncontrolled value
Expand Down
3 changes: 2 additions & 1 deletion src/Textarea.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Input from './Input';

export default class Textarea extends Input {
Expand Down
2 changes: 1 addition & 1 deletion src/Up.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default class Up extends Button {
};

async process() {
return await this.getParent().up();
return this.getParent().up();
}
}
1 change: 1 addition & 0 deletions src/Working.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ProvideProps from './ProvideProps';

export default class Working extends ProvideProps {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/markAsDirty.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function markAsDirty(value, originalPath, updateCallback) {
const parts = path.split('.');

let current = start;
for (let i = 0; i < parts.length; i++) {
for (let i = 0; i < parts.length; i += 1) {
const key = parts[i];
current[key] = dirty(current[key]);

Expand Down
13 changes: 8 additions & 5 deletions src/utils/traverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Element from '../Element';

export default function traverse(child, processCallback, replaceCallback) {
if (Array.isArray(child)) {
return Children.map(child, children => traverse(children, processCallback, replaceCallback));
return Children
.map(child, children => traverse(children, processCallback, replaceCallback));
}

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

if (child.props && child.props.children) {
const children = traverse(child.props.children, processCallback, replaceCallback);
// support for preact
const children = (child.props && child.props.children) || child.children;
if (children) {
const traversedChildren = traverse(children, processCallback, replaceCallback);
// speed up
if (children === child.props.children) {
if (traversedChildren === children) {
return child;
}

return cloneElement(child, {}, children);
return cloneElement(child, {}, traversedChildren);
}

return child;
Expand Down

0 comments on commit 435b193

Please sign in to comment.