react-jsonschema-form-extras 0.9.72 → 0.9.73

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/DraftRte.js CHANGED
@@ -74,15 +74,15 @@ function mapFromObject(data, mapping, defVal) {
74
74
  return agg;
75
75
  }, defVal);
76
76
  }
77
- /**
78
- *
79
- * @param {*} data
80
- * @param {*} mapping
81
- * Mapped object is converted to the object mapping takes
77
+ /**
78
+ *
79
+ * @param {*} data
80
+ * @param {*} mapping
81
+ * Mapped object is converted to the object mapping takes
82
82
  */
83
83
  function mapFromSchema(data, mapping) {
84
- /* if (isEmpty(data)) {
85
- return;
84
+ /* if (isEmpty(data)) {
85
+ return;
86
86
  } */
87
87
  if (!mapping || mapping === null) {
88
88
  return data;
@@ -95,11 +95,11 @@ function mapFromSchema(data, mapping) {
95
95
  }
96
96
  }
97
97
 
98
- /**
99
- *
100
- * @param {*} data
101
- * @param {*} mapping
102
- * prepare the String to display
98
+ /**
99
+ *
100
+ * @param {*} data
101
+ * @param {*} mapping
102
+ * prepare the String to display
103
103
  */
104
104
  function optionToString(fields, separator) {
105
105
  return function (option) {
@@ -119,11 +119,11 @@ function optionToString(fields, separator) {
119
119
  }, "");
120
120
  };
121
121
  }
122
- /**
123
- *
124
- * @param {*} data
125
- * @param {*} mapping
126
- * maping the label
122
+ /**
123
+ *
124
+ * @param {*} data
125
+ * @param {*} mapping
126
+ * maping the label
127
127
  */
128
128
  function mapLabelKey(labelKey) {
129
129
  if (Array.isArray(labelKey)) {
@@ -140,10 +140,10 @@ function mapLabelKey(labelKey) {
140
140
  var DraftRTE = function (_Component) {
141
141
  _inherits(DraftRTE, _Component);
142
142
 
143
- /**
144
- *
145
- * @param {*} props
146
- * Currently only supports HTML
143
+ /**
144
+ *
145
+ * @param {*} props
146
+ * Currently only supports HTML
147
147
  */
148
148
  function DraftRTE(props) {
149
149
  _classCallCheck(this, DraftRTE);
@@ -183,24 +183,24 @@ var DraftRTE = function (_Component) {
183
183
  };
184
184
  return _this;
185
185
  }
186
- /**
187
- * updates formData by calling parent's onChange function with current html content
186
+ /**
187
+ * updates formData by calling parent's onChange function with current html content
188
188
  */
189
189
 
190
190
 
191
- /**
192
- * handles editor's onChange
193
- * handles logic to update form data based on props supplied to the component
191
+ /**
192
+ * handles editor's onChange
193
+ * handles logic to update form data based on props supplied to the component
194
194
  */
195
195
  //will only be executed if debounce is present
196
196
 
197
- /**
198
- * handles the logic to update formData on blur
197
+ /**
198
+ * handles the logic to update formData on blur
199
199
  */
200
200
 
201
201
 
202
- /**
203
- * handles the logic to load the suggestions on the time of focus
202
+ /**
203
+ * handles the logic to load the suggestions on the time of focus
204
204
  */
205
205
 
206
206
 
@@ -208,8 +208,8 @@ var DraftRTE = function (_Component) {
208
208
  key: "render",
209
209
 
210
210
 
211
- /**
212
- * react render function
211
+ /**
212
+ * react render function
213
213
  */
214
214
  value: function render() {
215
215
  var _this2 = this;
@@ -154,11 +154,11 @@ function mapFromObject(data, mapping, defVal) {
154
154
  return agg;
155
155
  }, defVal);
156
156
  }
157
- /**
158
- *
159
- * @param {*} data
160
- * @param {*} mapping
161
- * Mapped object is converted to the object mapping takes
157
+ /**
158
+ *
159
+ * @param {*} data
160
+ * @param {*} mapping
161
+ * Mapped object is converted to the object mapping takes
162
162
  */
163
163
  function mapFromSchema(data, mapping) {
164
164
  if (isEmpty(data)) {
@@ -223,9 +223,9 @@ function isFunction(functionToCheck) {
223
223
  return functionToCheck instanceof Function;
224
224
  }
225
225
 
226
- /*
227
- this is done to prevent an edge case with a typeahead wrapped inside a table that has an item selected & uses a function as a labelKey
228
- TODO: Need to find a better solution for this
226
+ /*
227
+ this is done to prevent an edge case with a typeahead wrapped inside a table that has an item selected & uses a function as a labelKey
228
+ TODO: Need to find a better solution for this
229
229
  */
230
230
  function transformLabelKey(labelKey, schema, selected) {
231
231
  if (isFunction(labelKey) && selected && selected.length > 0 && schema.type === "string" && selected.every(function (x) {
@@ -1,10 +1,10 @@
1
- /*Collapsible header items*/
2
- .header-elements-wrapper {
3
- align-items: center;
4
- color: #fff;
5
- display: inline-flex;
6
- flex-direction: row;
7
- justify-content: flex-start;
8
- padding-left: 20px;
9
- white-space: nowrap;
1
+ /*Collapsible header items*/
2
+ .header-elements-wrapper {
3
+ align-items: center;
4
+ color: #fff;
5
+ display: inline-flex;
6
+ flex-direction: row;
7
+ justify-content: flex-start;
8
+ padding-left: 20px;
9
+ white-space: nowrap;
10
10
  }
@@ -283,9 +283,14 @@ var TableField = function (_Component) {
283
283
  key: "componentDidUpdate",
284
284
  value: function componentDidUpdate() {
285
285
  if (this.adding) {
286
- var _props$uiSchema$table = this.props.uiSchema.table,
286
+ var _props = this.props,
287
+ _props$uiSchema$table = _props.uiSchema.table,
287
288
  focusOnAdd = _props$uiSchema$table.focusOnAdd,
288
- focusRowIndex = _props$uiSchema$table.focusRowIndex;
289
+ focusRowIndex = _props$uiSchema$table.focusRowIndex,
290
+ _props$uiSchema$table2 = _props$uiSchema$table.tableCols,
291
+ tableCols = _props$uiSchema$table2 === undefined ? [] : _props$uiSchema$table2,
292
+ _props$formData = _props.formData,
293
+ formData = _props$formData === undefined ? [] : _props$formData;
289
294
 
290
295
 
291
296
  var body = this.refs.table.refs.body ? this.refs.table.refs.body : this.refs.table.body;
@@ -293,7 +298,19 @@ var TableField = function (_Component) {
293
298
  console.error("Can't find body in the table");
294
299
  return;
295
300
  }
296
- body.handleEditCell(focusRowIndex ? focusRowIndex : this.props.formData.length, focusOnAdd);
301
+ var allowToFocusField = true;
302
+ if (focusOnAdd) {
303
+ var _ref2 = tableCols[focusOnAdd] || {},
304
+ _ref2$dataField = _ref2.dataField,
305
+ dataField = _ref2$dataField === undefined ? "" : _ref2$dataField;
306
+
307
+ var addedRowIndex = focusRowIndex ? focusRowIndex : this.props.formData.length;
308
+ var addedRow = formData[addedRowIndex - 1];
309
+ if (dataField !== "" && addedRow[dataField]) {
310
+ allowToFocusField = false;
311
+ }
312
+ }
313
+ body.handleEditCell(focusRowIndex ? focusRowIndex : this.props.formData.length, allowToFocusField ? focusOnAdd : undefined);
297
314
  }
298
315
  }
299
316
  }, {
@@ -304,11 +321,11 @@ var TableField = function (_Component) {
304
321
  }, {
305
322
  key: "myRowExpand",
306
323
  value: function myRowExpand(currentTableData) {
307
- var _props = this.props,
308
- _props$schema$items$p = _props.schema.items.properties,
309
- properties = _props$schema$items$p === undefined ? [] : _props$schema$items$p,
310
- _props$uiSchema$table2 = _props.uiSchema.table.tableCols,
311
- tableCols = _props$uiSchema$table2 === undefined ? [] : _props$uiSchema$table2;
324
+ var _props2 = this.props,
325
+ _props2$schema$items$ = _props2.schema.items.properties,
326
+ properties = _props2$schema$items$ === undefined ? [] : _props2$schema$items$,
327
+ _props2$uiSchema$tabl = _props2.uiSchema.table.tableCols,
328
+ tableCols = _props2$uiSchema$tabl === undefined ? [] : _props2$uiSchema$tabl;
312
329
 
313
330
 
314
331
  var tableList = tableCols.map(function (item) {
@@ -428,9 +445,9 @@ var TableField = function (_Component) {
428
445
  }
429
446
  }, {
430
447
  key: "expandColumnComponent",
431
- value: function expandColumnComponent(_ref2) {
432
- var isExpandableRow = _ref2.isExpandableRow,
433
- isExpanded = _ref2.isExpanded;
448
+ value: function expandColumnComponent(_ref3) {
449
+ var isExpandableRow = _ref3.isExpandableRow,
450
+ isExpanded = _ref3.isExpanded;
434
451
 
435
452
  var icon = _react2.default.createElement("span", { className: "fa fa-plus glyphicon" });
436
453
 
@@ -445,10 +462,10 @@ var TableField = function (_Component) {
445
462
  key: "getExpandableTableOptions",
446
463
  value: function getExpandableTableOptions() {
447
464
  if (this.props.uiSchema.table && (this.props.uiSchema.table.isTableExpandable || this.props.uiSchema.table.isTableExpandable !== undefined)) {
448
- var _ref3 = this.props.uiSchema.table.expandableTableOptions || {},
449
- _ref3$expandBy = _ref3.expandBy,
450
- expandBy = _ref3$expandBy === undefined ? "column" : _ref3$expandBy,
451
- otherTableOptions = _objectWithoutProperties(_ref3, ["expandBy"]); // expandableTableOptions is option from the uischema
465
+ var _ref4 = this.props.uiSchema.table.expandableTableOptions || {},
466
+ _ref4$expandBy = _ref4.expandBy,
467
+ expandBy = _ref4$expandBy === undefined ? "column" : _ref4$expandBy,
468
+ otherTableOptions = _objectWithoutProperties(_ref4, ["expandBy"]); // expandableTableOptions is option from the uischema
452
469
 
453
470
 
454
471
  return _extends({ expandBy: expandBy }, otherTableOptions);
@@ -457,16 +474,16 @@ var TableField = function (_Component) {
457
474
  }, {
458
475
  key: "render",
459
476
  value: function render() {
460
- var _props2 = this.props,
461
- uiSchema = _props2.uiSchema,
462
- schema = _props2.schema,
463
- formData = _props2.formData,
464
- fields = _props2.registry.fields,
465
- _props2$idSchema = _props2.idSchema;
466
- _props2$idSchema = _props2$idSchema === undefined ? {} : _props2$idSchema;
467
- var $id = _props2$idSchema.$id,
468
- onChange = _props2.onChange,
469
- selectedItems = _props2.selectedItems;
477
+ var _props3 = this.props,
478
+ uiSchema = _props3.uiSchema,
479
+ schema = _props3.schema,
480
+ formData = _props3.formData,
481
+ fields = _props3.registry.fields,
482
+ _props3$idSchema = _props3.idSchema;
483
+ _props3$idSchema = _props3$idSchema === undefined ? {} : _props3$idSchema;
484
+ var $id = _props3$idSchema.$id,
485
+ onChange = _props3.onChange,
486
+ selectedItems = _props3.selectedItems;
470
487
 
471
488
 
472
489
  var forceReRenderTable = this.forceReRenderTable;
package/package.json CHANGED
@@ -1,138 +1,138 @@
1
- {
2
- "name": "react-jsonschema-form-extras",
3
- "description": "Extra widgets for Mozilla's react-jsonschema-form",
4
- "private": false,
5
- "author": "mavarazy@gmail.com",
6
- "version": "0.9.72",
7
- "scripts": {
8
- "build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/ --copy-files",
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 --fix",
15
- "precommit": "lint-staged",
16
- "publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
17
- "publish-to-npm": "npm run dist && npm publish && npm version patch",
18
- "start": "webpack-dev-server",
19
- "tdd": "jest --watchAll",
20
- "test": "jest"
21
- },
22
- "jest": {
23
- "verbose": true,
24
- "collectCoverage": true
25
- },
26
- "prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi",
27
- "lint-staged": {
28
- "{playground,src,test}/**/*.js": [
29
- "npm run lint",
30
- "npm run cs-format",
31
- "git add"
32
- ]
33
- },
34
- "main": "lib/index.js",
35
- "files": [
36
- "lib",
37
- "dist"
38
- ],
39
- "engineStrict": false,
40
- "engines": {
41
- "npm": "^5.0.4",
42
- "node": ">=8.0.0"
43
- },
44
- "peerDependencies": {
45
- "moment": "^2.20.0",
46
- "prop-types": "^15.x",
47
- "react": "^16.x",
48
- "react-bootstrap-table": "^4.x",
49
- "react-bootstrap-typeahead": "^3.3.2",
50
- "react-day-picker": "^7.x",
51
- "react-rte": "^0.15.0"
52
- },
53
- "dependencies": {
54
- "classnames": "^2.2.6",
55
- "draftjs-to-html": "^0.8.4",
56
- "es6-shim": "^0.35.5",
57
- "html-to-draftjs": "^1.4.0",
58
- "lodash.debounce": "^4.0.8",
59
- "react-draft-wysiwyg": "^1.12.13",
60
- "react-render-html": "^0.6.0",
61
- "selectn": "^1.1.2"
62
- },
63
- "devDependencies": {
64
- "atob": "^2.1.1",
65
- "babel-cli": "^6.0.0",
66
- "babel-core": "^6.26.3",
67
- "babel-eslint": "^8.0.1",
68
- "babel-jest": "^21.2.0",
69
- "babel-loader": "^7.1.2",
70
- "babel-plugin-add-module-exports": "^0.2.1",
71
- "babel-plugin-transform-class-properties": "^6.24.1",
72
- "babel-plugin-transform-object-rest-spread": "^6.26.0",
73
- "babel-polyfill": "^6.26.0",
74
- "babel-preset-env": "^1.7.0",
75
- "babel-preset-es2015": "^6.24.1",
76
- "babel-preset-react": "^6.24.1",
77
- "babel-preset-stage-2": "^6.24.1",
78
- "babel-register": "^6.26.0",
79
- "bootstrap": "^3.3.7",
80
- "coveralls": "^3.0.0",
81
- "cross-env": "^5.1.0",
82
- "css-loader": "^0.28.7",
83
- "eslint": "^4.9.0",
84
- "eslint-plugin-jest": "^21.2.0",
85
- "eslint-plugin-react": "^7.4.0",
86
- "eslint-plugin-standard": "^3.0.1",
87
- "exit-hook": "^1.1.1",
88
- "express": "^4.16.2",
89
- "extract-text-webpack-plugin": "^3.0.1",
90
- "gh-pages": "^1.2.0",
91
- "has-flag": "^2.0.0",
92
- "html": "1.0.0",
93
- "husky": "^0.14.3",
94
- "istanbul-api": "1.2.2",
95
- "istanbul-reports": "1.1.4",
96
- "jest": "^23.6.0",
97
- "jsdom": "^11.12.0",
98
- "json-rules-engine-simplified": "^0.1.17",
99
- "lint-staged": "^6.0.0",
100
- "moment": "^2.20.1",
101
- "prettier": "^1.7.4",
102
- "react": "^16.0.0",
103
- "react-bootstrap-table": "^4.3.0",
104
- "react-bootstrap-typeahead": "^3.2.4",
105
- "react-day-picker": "^7.0.5",
106
- "react-dom": "^16.0.0",
107
- "react-jsonschema-form": "^1.0.0",
108
- "react-jsonschema-form-conditionals": "^0.3.15",
109
- "react-rte": "^0.15.0",
110
- "react-test-renderer": "^16.0.0",
111
- "react-transform-catch-errors": "^1.0.2",
112
- "react-transform-hmr": "^1.0.4",
113
- "regenerator-runtime": "^0.11.0",
114
- "rimraf": "^2.6.2",
115
- "selectn": "^1.1.2",
116
- "sinon": "^4.1.1",
117
- "style-loader": "^0.19.0",
118
- "webpack": "^3.9.1",
119
- "webpack-dev-server": "^2.9.3",
120
- "webpack-hot-middleware": "^2.20.0"
121
- },
122
- "directories": {
123
- "test": "test"
124
- },
125
- "repository": {
126
- "type": "git",
127
- "url": "git+https://github.com/RxNT/react-jsonschema-form-extras.git"
128
- },
129
- "keywords": [
130
- "react",
131
- "form",
132
- "json-schema",
133
- "conditional",
134
- "predicate"
135
- ],
136
- "license": "Apache-2.0",
137
- "homepage": "https://github.com/RxNT/react-jsonschema-form-extras#readme"
138
- }
1
+ {
2
+ "name": "react-jsonschema-form-extras",
3
+ "description": "Extra widgets for Mozilla's react-jsonschema-form",
4
+ "private": false,
5
+ "author": "mavarazy@gmail.com",
6
+ "version": "0.9.73",
7
+ "scripts": {
8
+ "build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/ --copy-files",
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 --fix",
15
+ "precommit": "lint-staged",
16
+ "publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
17
+ "publish-to-npm": "npm run dist && npm publish && npm version patch",
18
+ "start": "webpack-dev-server",
19
+ "tdd": "jest --watchAll",
20
+ "test": "jest"
21
+ },
22
+ "jest": {
23
+ "verbose": true,
24
+ "collectCoverage": true
25
+ },
26
+ "prettierOptions": "--jsx-bracket-same-line --trailing-comma es5 --semi",
27
+ "lint-staged": {
28
+ "{playground,src,test}/**/*.js": [
29
+ "npm run lint",
30
+ "npm run cs-format",
31
+ "git add"
32
+ ]
33
+ },
34
+ "main": "lib/index.js",
35
+ "files": [
36
+ "lib",
37
+ "dist"
38
+ ],
39
+ "engineStrict": false,
40
+ "engines": {
41
+ "npm": "^5.0.4",
42
+ "node": ">=8.0.0"
43
+ },
44
+ "peerDependencies": {
45
+ "moment": "^2.20.0",
46
+ "prop-types": "^15.x",
47
+ "react": "^16.x",
48
+ "react-bootstrap-table": "^4.x",
49
+ "react-bootstrap-typeahead": "^3.3.2",
50
+ "react-day-picker": "^7.x",
51
+ "react-rte": "^0.15.0"
52
+ },
53
+ "dependencies": {
54
+ "classnames": "^2.2.6",
55
+ "draftjs-to-html": "^0.8.4",
56
+ "es6-shim": "^0.35.5",
57
+ "html-to-draftjs": "^1.4.0",
58
+ "lodash.debounce": "^4.0.8",
59
+ "react-draft-wysiwyg": "^1.12.13",
60
+ "react-render-html": "^0.6.0",
61
+ "selectn": "^1.1.2"
62
+ },
63
+ "devDependencies": {
64
+ "atob": "^2.1.1",
65
+ "babel-cli": "^6.0.0",
66
+ "babel-core": "^6.26.3",
67
+ "babel-eslint": "^8.0.1",
68
+ "babel-jest": "^21.2.0",
69
+ "babel-loader": "^7.1.2",
70
+ "babel-plugin-add-module-exports": "^0.2.1",
71
+ "babel-plugin-transform-class-properties": "^6.24.1",
72
+ "babel-plugin-transform-object-rest-spread": "^6.26.0",
73
+ "babel-polyfill": "^6.26.0",
74
+ "babel-preset-env": "^1.7.0",
75
+ "babel-preset-es2015": "^6.24.1",
76
+ "babel-preset-react": "^6.24.1",
77
+ "babel-preset-stage-2": "^6.24.1",
78
+ "babel-register": "^6.26.0",
79
+ "bootstrap": "^3.3.7",
80
+ "coveralls": "^3.0.0",
81
+ "cross-env": "^5.1.0",
82
+ "css-loader": "^0.28.7",
83
+ "eslint": "^4.9.0",
84
+ "eslint-plugin-jest": "^21.2.0",
85
+ "eslint-plugin-react": "^7.4.0",
86
+ "eslint-plugin-standard": "^3.0.1",
87
+ "exit-hook": "^1.1.1",
88
+ "express": "^4.16.2",
89
+ "extract-text-webpack-plugin": "^3.0.1",
90
+ "gh-pages": "^1.2.0",
91
+ "has-flag": "^2.0.0",
92
+ "html": "1.0.0",
93
+ "husky": "^0.14.3",
94
+ "istanbul-api": "1.2.2",
95
+ "istanbul-reports": "1.1.4",
96
+ "jest": "^23.6.0",
97
+ "jsdom": "^11.12.0",
98
+ "json-rules-engine-simplified": "^0.1.17",
99
+ "lint-staged": "^6.0.0",
100
+ "moment": "^2.20.1",
101
+ "prettier": "^1.7.4",
102
+ "react": "^16.0.0",
103
+ "react-bootstrap-table": "^4.3.0",
104
+ "react-bootstrap-typeahead": "^3.2.4",
105
+ "react-day-picker": "^7.0.5",
106
+ "react-dom": "^16.0.0",
107
+ "react-jsonschema-form": "^1.0.0",
108
+ "react-jsonschema-form-conditionals": "^0.3.15",
109
+ "react-rte": "^0.15.0",
110
+ "react-test-renderer": "^16.0.0",
111
+ "react-transform-catch-errors": "^1.0.2",
112
+ "react-transform-hmr": "^1.0.4",
113
+ "regenerator-runtime": "^0.11.0",
114
+ "rimraf": "^2.6.2",
115
+ "selectn": "^1.1.2",
116
+ "sinon": "^4.1.1",
117
+ "style-loader": "^0.19.0",
118
+ "webpack": "^3.9.1",
119
+ "webpack-dev-server": "^2.9.3",
120
+ "webpack-hot-middleware": "^2.20.0"
121
+ },
122
+ "directories": {
123
+ "test": "test"
124
+ },
125
+ "repository": {
126
+ "type": "git",
127
+ "url": "git+https://github.com/RxNT/react-jsonschema-form-extras.git"
128
+ },
129
+ "keywords": [
130
+ "react",
131
+ "form",
132
+ "json-schema",
133
+ "conditional",
134
+ "predicate"
135
+ ],
136
+ "license": "Apache-2.0",
137
+ "homepage": "https://github.com/RxNT/react-jsonschema-form-extras#readme"
138
+ }