react-jsonschema-form-conditionals 0.3.14 → 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
@@ -76,6 +76,8 @@ function applyRules(schema, uiSchema, rules, Engine) {
76
76
  });
77
77
  }
78
78
 
79
+ var runRules = (0, _rulesRunner2.default)(schema, uiSchema, rules, Engine, extraActions);
80
+
79
81
  return function (FormComponent) {
80
82
  var FormWithConditionals = function (_Component) {
81
83
  _inherits(FormWithConditionals, _Component);
@@ -91,8 +93,12 @@ function applyRules(schema, uiSchema, rules, Engine) {
91
93
  formData = _this$props$formData === undefined ? {} : _this$props$formData;
92
94
 
93
95
 
94
- _this.shouldUpdate = false;
95
- _this.state = { schema: schema, uiSchema: uiSchema };
96
+ _this.state = {
97
+ schema: schema,
98
+ uiSchema: uiSchema,
99
+ formData: formData
100
+ };
101
+
96
102
  _this.updateConf(formData);
97
103
  return _this;
98
104
  }
@@ -100,29 +106,28 @@ function applyRules(schema, uiSchema, rules, Engine) {
100
106
  _createClass(FormWithConditionals, [{
101
107
  key: "componentWillReceiveProps",
102
108
  value: function componentWillReceiveProps(nextProps) {
103
- var formDataChanged = nextProps.formData && !(0, _utils.deepEquals)(nextProps.formData, this.formData);
104
- if (formDataChanged) {
105
- this.updateConf(nextProps.formData);
106
- this.shouldUpdate = true;
107
- } else {
108
- this.shouldUpdate = this.shouldUpdate || !(0, _utils.deepEquals)(nextProps, Object.assign({}, this.props, { formData: nextProps.formData }));
109
- }
109
+ this.updateConf(nextProps.formData);
110
110
  }
111
111
  }, {
112
112
  key: "updateConf",
113
113
  value: function updateConf(formData) {
114
114
  var _this2 = this;
115
115
 
116
- this.formData = formData;
117
- var runRules = (0, _rulesRunner2.default)(this.state.schema, this.state.uiSchema, rules, Engine, extraActions);
118
116
  return runRules(formData).then(function (conf) {
119
- var dataChanged = !(0, _utils.deepEquals)(_this2.formData, conf.formData);
120
- _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
+
121
128
 
122
- var newState = { schema: conf.schema, uiSchema: conf.uiSchema };
123
- var confChanged = !(0, _utils.deepEquals)(newState, _this2.state);
129
+ var confChanged = !(0, _utils.deepEquals)(newState, { schema: schema, uiSchema: uiSchema });
124
130
  if (dataChanged || confChanged) {
125
- _this2.shouldUpdate = true;
126
131
  _this2.setState(newState);
127
132
  }
128
133
 
@@ -145,23 +150,14 @@ function applyRules(schema, uiSchema, rules, Engine) {
145
150
  });
146
151
  }
147
152
  }
148
- }, {
149
- key: "shouldComponentUpdate",
150
- value: function shouldComponentUpdate() {
151
- if (this.shouldUpdate) {
152
- this.shouldUpdate = false;
153
- return true;
154
- }
155
- return false;
156
- }
157
153
  }, {
158
154
  key: "render",
159
155
  value: function render() {
160
156
  // Assignment order is important
161
157
  var formConf = Object.assign({}, this.props, this.state, {
162
- onChange: this.handleChange,
163
- formData: this.formData
158
+ onChange: this.handleChange
164
159
  });
160
+
165
161
  return _react2.default.createElement(FormComponent, formConf);
166
162
  }
167
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.14",
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
+ }