react-jsonschema-form-conditionals 0.3.15 → 0.3.17
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/LICENSE +201 -201
- package/README.md +752 -752
- package/dist/main.js +15 -15
- package/dist/main.js.map +1 -1
- package/lib/applyRules.js +12 -34
- package/package.json +123 -123
package/lib/applyRules.js
CHANGED
@@ -16,9 +16,7 @@ var _propTypes = require("prop-types");
|
|
16
16
|
|
17
17
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
18
18
|
|
19
|
-
var _utils = require("
|
20
|
-
|
21
|
-
var _utils2 = require("./utils");
|
19
|
+
var _utils = require("./utils");
|
22
20
|
|
23
21
|
var _rulesRunner = require("./rulesRunner");
|
24
22
|
|
@@ -41,7 +39,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
41
39
|
function applyRules(schema, uiSchema, rules, Engine) {
|
42
40
|
var extraActions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
43
41
|
|
44
|
-
if ((0,
|
42
|
+
if ((0, _utils.isDevelopment)()) {
|
45
43
|
var propTypes = {
|
46
44
|
Engine: _propTypes2.default.func.isRequired,
|
47
45
|
rules: _propTypes2.default.arrayOf(_propTypes2.default.shape({
|
@@ -68,7 +66,7 @@ function applyRules(schema, uiSchema, rules, Engine) {
|
|
68
66
|
// Find associated action
|
69
67
|
var action = extraActions[type] ? extraActions[type] : _actions.DEFAULT_ACTIONS[type];
|
70
68
|
if (action === undefined) {
|
71
|
-
(0,
|
69
|
+
(0, _utils.toError)("Rule contains invalid action \"" + type + "\"");
|
72
70
|
return;
|
73
71
|
}
|
74
72
|
|
@@ -93,8 +91,7 @@ function applyRules(schema, uiSchema, rules, Engine) {
|
|
93
91
|
formData = _this$props$formData === undefined ? {} : _this$props$formData;
|
94
92
|
|
95
93
|
|
96
|
-
_this.
|
97
|
-
_this.state = { schema: schema, uiSchema: uiSchema };
|
94
|
+
_this.state = { schema: schema, uiSchema: uiSchema, formData: formData };
|
98
95
|
_this.updateConf(formData);
|
99
96
|
return _this;
|
100
97
|
}
|
@@ -102,29 +99,19 @@ function applyRules(schema, uiSchema, rules, Engine) {
|
|
102
99
|
_createClass(FormWithConditionals, [{
|
103
100
|
key: "componentWillReceiveProps",
|
104
101
|
value: function componentWillReceiveProps(nextProps) {
|
105
|
-
|
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
|
-
}
|
102
|
+
this.updateConf(nextProps.formData);
|
112
103
|
}
|
113
104
|
}, {
|
114
105
|
key: "updateConf",
|
115
106
|
value: function updateConf(formData) {
|
116
107
|
var _this2 = this;
|
117
108
|
|
118
|
-
this.formData = formData;
|
119
109
|
return runRules(formData).then(function (conf) {
|
120
|
-
var
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
if (dataChanged || confChanged) {
|
126
|
-
_this2.shouldUpdate = true;
|
127
|
-
_this2.setState(newState);
|
110
|
+
var newConf = JSON.stringify(conf);
|
111
|
+
var oldConf = JSON.stringify(_this2.state);
|
112
|
+
|
113
|
+
if (newConf !== oldConf) {
|
114
|
+
_this2.setState(conf);
|
128
115
|
}
|
129
116
|
|
130
117
|
return conf;
|
@@ -146,23 +133,14 @@ function applyRules(schema, uiSchema, rules, Engine) {
|
|
146
133
|
});
|
147
134
|
}
|
148
135
|
}
|
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
136
|
}, {
|
159
137
|
key: "render",
|
160
138
|
value: function render() {
|
161
139
|
// Assignment order is important
|
162
140
|
var formConf = Object.assign({}, this.props, this.state, {
|
163
|
-
onChange: this.handleChange
|
164
|
-
formData: this.formData
|
141
|
+
onChange: this.handleChange
|
165
142
|
});
|
143
|
+
|
166
144
|
return _react2.default.createElement(FormComponent, formConf);
|
167
145
|
}
|
168
146
|
}]);
|
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.
|
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.17",
|
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
|
+
}
|