react-jsonschema-form-conditionals 0.3.15 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/applyRules.js CHANGED
@@ -93,8 +93,12 @@ function applyRules(schema, uiSchema, rules, Engine) {
93
93
  formData = _this$props$formData === undefined ? {} : _this$props$formData;
94
94
 
95
95
 
96
- _this.shouldUpdate = false;
97
- _this.state = { schema: schema, uiSchema: uiSchema };
96
+ _this.state = {
97
+ schema: schema,
98
+ uiSchema: uiSchema,
99
+ formData: formData
100
+ };
101
+
98
102
  _this.updateConf(formData);
99
103
  return _this;
100
104
  }
@@ -102,28 +106,28 @@ function applyRules(schema, uiSchema, rules, Engine) {
102
106
  _createClass(FormWithConditionals, [{
103
107
  key: "componentWillReceiveProps",
104
108
  value: function componentWillReceiveProps(nextProps) {
105
- var formDataChanged = nextProps.formData && !(0, _utils.deepEquals)(nextProps.formData, this.formData);
106
- if (formDataChanged) {
107
- this.updateConf(nextProps.formData);
108
- this.shouldUpdate = true;
109
- } else {
110
- this.shouldUpdate = this.shouldUpdate || !(0, _utils.deepEquals)(nextProps, Object.assign({}, this.props, { formData: nextProps.formData }));
111
- }
109
+ this.updateConf(nextProps.formData);
112
110
  }
113
111
  }, {
114
112
  key: "updateConf",
115
113
  value: function updateConf(formData) {
116
114
  var _this2 = this;
117
115
 
118
- this.formData = formData;
119
116
  return runRules(formData).then(function (conf) {
120
- var dataChanged = !(0, _utils.deepEquals)(_this2.formData, conf.formData);
121
- _this2.formData = conf.formData;
117
+ var dataChanged = !(0, _utils.deepEquals)(formData, conf.formData);
118
+
119
+ var newState = {
120
+ schema: conf.schema,
121
+ uiSchema: conf.uiSchema,
122
+ formData: formData
123
+ };
124
+ var _state = _this2.state,
125
+ schema = _state.schema,
126
+ uiSchema = _state.uiSchema;
127
+
122
128
 
123
- var newState = { schema: conf.schema, uiSchema: conf.uiSchema };
124
- var confChanged = !(0, _utils.deepEquals)(newState, _this2.state);
129
+ var confChanged = !(0, _utils.deepEquals)(newState, { schema: schema, uiSchema: uiSchema });
125
130
  if (dataChanged || confChanged) {
126
- _this2.shouldUpdate = true;
127
131
  _this2.setState(newState);
128
132
  }
129
133
 
@@ -146,23 +150,14 @@ function applyRules(schema, uiSchema, rules, Engine) {
146
150
  });
147
151
  }
148
152
  }
149
- }, {
150
- key: "shouldComponentUpdate",
151
- value: function shouldComponentUpdate() {
152
- if (this.shouldUpdate) {
153
- this.shouldUpdate = false;
154
- return true;
155
- }
156
- return false;
157
- }
158
153
  }, {
159
154
  key: "render",
160
155
  value: function render() {
161
156
  // Assignment order is important
162
157
  var formConf = Object.assign({}, this.props, this.state, {
163
- onChange: this.handleChange,
164
- formData: this.formData
158
+ onChange: this.handleChange
165
159
  });
160
+
166
161
  return _react2.default.createElement(FormComponent, formConf);
167
162
  }
168
163
  }]);
package/package.json CHANGED
@@ -1,123 +1,123 @@
1
- {
2
- "name": "react-jsonschema-form-conditionals",
3
- "description": "Extension of react-jsonschema-form with conditional field support",
4
- "private": false,
5
- "author": "mavarazy@gmail.com",
6
- "version": "0.3.15",
7
- "scripts": {
8
- "build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/",
9
- "build:dist": "rimraf dist && cross-env NODE_ENV=production webpack --config webpack.config.dist.js --optimize-minimize",
10
- "build:playground": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js --optimize-minimize && cp playground/index.prod.html build/index.html",
11
- "cs-check": "prettier -l $npm_package_prettierOptions '{playground,src,test}/**/*.js'",
12
- "cs-format": "prettier $npm_package_prettierOptions '{playground,src,test}/**/*.js' --write",
13
- "dist": "npm run build:lib && npm run build:dist",
14
- "lint": "eslint src test playground",
15
- "precommit": "lint-staged",
16
- "prepush": "npm test",
17
- "publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
18
- "publish-to-npm": "npm run dist && npm publish && npm version patch",
19
- "start": "webpack-dev-server",
20
- "tdd": "jest --watchAll",
21
- "test": "jest"
22
- },
23
- "jest": {
24
- "verbose": true,
25
- "collectCoverage": true,
26
- "collectCoverageFrom": [
27
- "src/**/*.{js,jsx}"
28
- ]
29
- },
30
- "prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi",
31
- "lint-staged": {
32
- "{playground,src,test}/**/*.js": [
33
- "npm run lint",
34
- "npm run cs-format",
35
- "git add"
36
- ]
37
- },
38
- "main": "lib/index.js",
39
- "files": [
40
- "dist",
41
- "lib"
42
- ],
43
- "engineStrict": false,
44
- "engines": {
45
- "node": ">=8"
46
- },
47
- "peerDependencies": {
48
- "prop-types": "^15.5.10",
49
- "react": "^16.0.0",
50
- "react-jsonschema-form": "^1.0.0"
51
- },
52
- "dependencies": {
53
- "deepcopy": "^0.6.3",
54
- "selectn": "^1.1.2"
55
- },
56
- "devDependencies": {
57
- "atob": "^2.0.3",
58
- "babel-cli": "^6.0.0",
59
- "babel-core": "^6.0.0",
60
- "babel-eslint": "^8.0.1",
61
- "babel-jest": "^21.0.2",
62
- "babel-loader": "^7.1.2",
63
- "babel-plugin-transform-class-properties": "^6.24.1",
64
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
65
- "babel-polyfill": "^6.26.0",
66
- "babel-preset-env": "^1.6.0",
67
- "babel-preset-react": "^6.24.1",
68
- "babel-preset-stage-0": "^6.24.1",
69
- "babel-register": "^6.26.0",
70
- "coveralls": "^3.0.0",
71
- "cross-env": "^5.0.5",
72
- "css-loader": "^0.28.7",
73
- "enzyme": "^3.1.0",
74
- "enzyme-adapter-react-16": "^1.0.3",
75
- "eslint": "^4.6.1",
76
- "eslint-plugin-jest": "^21.0.2",
77
- "eslint-plugin-react": "^7.3.0",
78
- "eslint-plugin-standard": "^3.0.1",
79
- "exit-hook": "^1.1.1",
80
- "express": "^4.15.4",
81
- "extract-text-webpack-plugin": "^3.0.0",
82
- "gh-pages": "^1.0.0",
83
- "has-flag": "^2.0.0",
84
- "html": "1.0.0",
85
- "husky": "^0.14.3",
86
- "jest": "^21.0.2",
87
- "jest-cli": "^21.1.0",
88
- "jsdom": "^11.2.0",
89
- "json-rules-engine": "^2.0.2",
90
- "json-rules-engine-simplified": "^0.1.11",
91
- "lint-staged": "^4.1.3",
92
- "prettier": "^1.6.1",
93
- "react": "^16.0.0",
94
- "react-dom": "^16.0.0",
95
- "react-jsonschema-form": "^1.0.0",
96
- "react-test-renderer": "^16.0.0",
97
- "react-transform-catch-errors": "^1.0.2",
98
- "react-transform-hmr": "^1.0.4",
99
- "regenerator-runtime": "^0.11.0",
100
- "rimraf": "^2.6.1",
101
- "sinon": "^4.0.2",
102
- "style-loader": "^0.19.0",
103
- "webpack": "^3.5.6",
104
- "webpack-dev-server": "^2.7.1",
105
- "webpack-hot-middleware": "^2.19.1"
106
- },
107
- "directories": {
108
- "test": "test"
109
- },
110
- "repository": {
111
- "type": "git",
112
- "url": "git+https://github.com/RxNT/react-jsonschema-form-conditionals.git"
113
- },
114
- "keywords": [
115
- "react",
116
- "form",
117
- "json-schema",
118
- "conditional",
119
- "predicate"
120
- ],
121
- "license": "Apache-2.0",
122
- "homepage": "https://github.com/RxNT/react-jsonschema-form-conditionals#readme"
123
- }
1
+ {
2
+ "name": "react-jsonschema-form-conditionals",
3
+ "description": "Extension of react-jsonschema-form with conditional field support",
4
+ "private": false,
5
+ "author": "mavarazy@gmail.com",
6
+ "version": "0.3.16",
7
+ "scripts": {
8
+ "build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/",
9
+ "build:dist": "rimraf dist && cross-env NODE_ENV=production webpack --config webpack.config.dist.js --optimize-minimize",
10
+ "build:playground": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js --optimize-minimize && cp playground/index.prod.html build/index.html",
11
+ "cs-check": "prettier -l $npm_package_prettierOptions '{playground,src,test}/**/*.js'",
12
+ "cs-format": "prettier $npm_package_prettierOptions '{playground,src,test}/**/*.js' --write",
13
+ "dist": "npm run build:lib && npm run build:dist",
14
+ "lint": "eslint --fix src test playground",
15
+ "precommit": "lint-staged",
16
+ "prepush": "npm test",
17
+ "publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
18
+ "publish-to-npm": "npm run dist && npm publish && npm version patch",
19
+ "start": "webpack-dev-server",
20
+ "tdd": "jest --watchAll",
21
+ "test": "jest"
22
+ },
23
+ "jest": {
24
+ "verbose": true,
25
+ "collectCoverage": true,
26
+ "collectCoverageFrom": [
27
+ "src/**/*.{js,jsx}"
28
+ ]
29
+ },
30
+ "prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi",
31
+ "lint-staged": {
32
+ "{playground,src,test}/**/*.js": [
33
+ "npm run lint",
34
+ "npm run cs-format",
35
+ "git add"
36
+ ]
37
+ },
38
+ "main": "lib/index.js",
39
+ "files": [
40
+ "dist",
41
+ "lib"
42
+ ],
43
+ "engineStrict": false,
44
+ "engines": {
45
+ "node": ">=8"
46
+ },
47
+ "peerDependencies": {
48
+ "prop-types": "^15.5.10",
49
+ "react": "^16.0.0",
50
+ "react-jsonschema-form": "^1.0.0"
51
+ },
52
+ "dependencies": {
53
+ "deepcopy": "^0.6.3",
54
+ "selectn": "^1.1.2"
55
+ },
56
+ "devDependencies": {
57
+ "atob": "^2.0.3",
58
+ "babel-cli": "^6.0.0",
59
+ "babel-core": "^6.0.0",
60
+ "babel-eslint": "^8.0.1",
61
+ "babel-jest": "^21.0.2",
62
+ "babel-loader": "^7.1.2",
63
+ "babel-plugin-transform-class-properties": "^6.24.1",
64
+ "babel-plugin-transform-object-rest-spread": "^6.26.0",
65
+ "babel-polyfill": "^6.26.0",
66
+ "babel-preset-env": "^1.6.0",
67
+ "babel-preset-react": "^6.24.1",
68
+ "babel-preset-stage-0": "^6.24.1",
69
+ "babel-register": "^6.26.0",
70
+ "coveralls": "^3.0.0",
71
+ "cross-env": "^5.0.5",
72
+ "css-loader": "^0.28.7",
73
+ "enzyme": "^3.1.0",
74
+ "enzyme-adapter-react-16": "^1.0.3",
75
+ "eslint": "^4.6.1",
76
+ "eslint-plugin-jest": "^21.0.2",
77
+ "eslint-plugin-react": "^7.3.0",
78
+ "eslint-plugin-standard": "^3.0.1",
79
+ "exit-hook": "^1.1.1",
80
+ "express": "^4.15.4",
81
+ "extract-text-webpack-plugin": "^3.0.0",
82
+ "gh-pages": "^1.0.0",
83
+ "has-flag": "^2.0.0",
84
+ "html": "1.0.0",
85
+ "husky": "^0.14.3",
86
+ "jest": "^21.0.2",
87
+ "jest-cli": "^21.1.0",
88
+ "jsdom": "^11.2.0",
89
+ "json-rules-engine": "^2.0.2",
90
+ "json-rules-engine-simplified": "^0.1.11",
91
+ "lint-staged": "^4.1.3",
92
+ "prettier": "^1.6.1",
93
+ "react": "^16.0.0",
94
+ "react-dom": "^16.0.0",
95
+ "react-jsonschema-form": "^1.0.0",
96
+ "react-test-renderer": "^16.0.0",
97
+ "react-transform-catch-errors": "^1.0.2",
98
+ "react-transform-hmr": "^1.0.4",
99
+ "regenerator-runtime": "^0.11.0",
100
+ "rimraf": "^2.6.1",
101
+ "sinon": "^4.0.2",
102
+ "style-loader": "^0.19.0",
103
+ "webpack": "^3.5.6",
104
+ "webpack-dev-server": "^2.7.1",
105
+ "webpack-hot-middleware": "^2.19.1"
106
+ },
107
+ "directories": {
108
+ "test": "test"
109
+ },
110
+ "repository": {
111
+ "type": "git",
112
+ "url": "git+https://github.com/RxNT/react-jsonschema-form-conditionals.git"
113
+ },
114
+ "keywords": [
115
+ "react",
116
+ "form",
117
+ "json-schema",
118
+ "conditional",
119
+ "predicate"
120
+ ],
121
+ "license": "Apache-2.0",
122
+ "homepage": "https://github.com/RxNT/react-jsonschema-form-conditionals#readme"
123
+ }