react-jsonschema-form-extras 0.9.65 → 0.9.69

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.
@@ -92,32 +92,6 @@ function getFieldValue(cellValue, type, format, dataFormat) {
92
92
  }
93
93
  return cellValue;
94
94
  }
95
- function isEquivalentObject(a, b) {
96
- // Create arrays of property names
97
- var aProps = Object.getOwnPropertyNames(a);
98
- var bProps = Object.getOwnPropertyNames(b);
99
-
100
- // If number of properties is different,
101
- // objects are not equivalent
102
- if (aProps.length != bProps.length) {
103
- return false;
104
- }
105
-
106
- for (var i = 0; i < aProps.length; i++) {
107
- var propName = aProps[i];
108
-
109
- // If values of same property are not equal,
110
- // objects are not equivalent
111
- if (a[propName] !== b[propName]) {
112
- return false;
113
- }
114
- }
115
-
116
- // If we made it this far, objects
117
- // are considered equivalent
118
-
119
- return true;
120
- }
121
95
 
122
96
  var TableField = function (_Component) {
123
97
  _inherits(TableField, _Component);
@@ -255,31 +229,35 @@ var TableField = function (_Component) {
255
229
  }, {
256
230
  key: "handleRowSelect",
257
231
  value: function handleRowSelect(row, isSelected, e) {
232
+ var onChange = this.props.onChange;
258
233
  var _tableConf3 = this.tableConf,
259
- data = _tableConf3.data,
234
+ _tableConf3$data = _tableConf3.data,
235
+ data = _tableConf3$data === undefined ? [] : _tableConf3$data,
260
236
  _tableConf3$selectRow = _tableConf3.selectRow.onSelectRow.fieldToUpdate,
261
237
  fieldToUpdate = _tableConf3$selectRow === undefined ? "picked" : _tableConf3$selectRow;
262
238
 
263
- var filteredRows = (data || []).map(function (item) {
264
- if (!isSelected && item[fieldToUpdate] !== undefined) {
265
- if (isEquivalentObject(item, row)) {
266
- delete item[fieldToUpdate];
267
- }
268
- } else if (isEquivalentObject(item, row)) {
269
- item[fieldToUpdate] = isSelected;
270
- }
271
- return item;
272
- });
273
- this.props.onChange(filteredRows);
239
+
240
+ row.isRowSelected = isSelected;
241
+
242
+ if (!isSelected) {
243
+ delete row[fieldToUpdate];
244
+ } else {
245
+ row[fieldToUpdate] = isSelected;
246
+ }
247
+
248
+ onChange(data);
274
249
  }
275
250
  }, {
276
251
  key: "handleAllRowSelect",
277
252
  value: function handleAllRowSelect(isSelected, rows, e) {
278
- var _tableConf$selectRow$ = this.tableConf.selectRow.onSelectAllRow.fieldToUpdate,
279
- fieldToUpdate = _tableConf$selectRow$ === undefined ? "picked" : _tableConf$selectRow$;
253
+ var _tableConf4 = this.tableConf,
254
+ data = _tableConf4.data,
255
+ _tableConf4$selectRow = _tableConf4.selectRow.onSelectAllRow.fieldToUpdate,
256
+ fieldToUpdate = _tableConf4$selectRow === undefined ? "picked" : _tableConf4$selectRow;
280
257
 
281
258
 
282
- var filteredRows = (rows || []).map(function (item) {
259
+ var filteredRows = data.map(function (item) {
260
+ item.isRowSelected = isSelected;
283
261
  if (!isSelected && item[fieldToUpdate] !== undefined) {
284
262
  delete item[fieldToUpdate];
285
263
  } else {
@@ -487,12 +465,14 @@ var TableField = function (_Component) {
487
465
  _props2$idSchema = _props2.idSchema;
488
466
  _props2$idSchema = _props2$idSchema === undefined ? {} : _props2$idSchema;
489
467
  var $id = _props2$idSchema.$id,
490
- onChange = _props2.onChange;
468
+ onChange = _props2.onChange,
469
+ selectedItems = _props2.selectedItems;
491
470
 
492
471
 
493
472
  var forceReRenderTable = this.forceReRenderTable;
494
473
 
495
- this.tableConf = (0, _tableConfFactory2.default)(uiSchema, formData, this.handleCellSave, this.handleRowsDelete, this.handleDeletedRow, this.handleRowSelect, this.handleAllRowSelect, this.myRowExpand, this.isRowExpandable, this.expandColumnComponent);
474
+ this.tableConf = (0, _tableConfFactory2.default)(uiSchema, formData, this.handleCellSave, this.handleRowsDelete, this.handleDeletedRow, this.handleRowSelect, this.handleAllRowSelect, this.myRowExpand, this.isRowExpandable, this.expandColumnComponent, selectedItems);
475
+
496
476
  var expandableTableOptions = this.getExpandableTableOptions();
497
477
  this.tableConf.options.insertModal = this.createCustomModal;
498
478
  var boostrapTableOptions = _extends({
@@ -508,7 +488,10 @@ var TableField = function (_Component) {
508
488
  { id: $id },
509
489
  _react2.default.createElement(
510
490
  _reactBootstrapTable.BootstrapTable,
511
- _extends({}, this.tableConf, { trClassName: this.handleRowColorChange, ref: "table" }),
491
+ _extends({}, this.tableConf, {
492
+ trClassName: this.handleRowColorChange,
493
+ ref: "table"
494
+ }),
512
495
  columns.map(function (column, i) {
513
496
  return _react2.default.createElement(
514
497
  _reactBootstrapTable.TableHeaderColumn,
@@ -54,6 +54,7 @@ function tableConfFrom(_ref) {
54
54
  var myRowExpand = arguments[7];
55
55
  var isRowExpandable = arguments[8];
56
56
  var expandColumnComponent = arguments[9];
57
+ var selectedItems = arguments[10];
57
58
  var _table$keyField = table.keyField,
58
59
  keyField = _table$keyField === undefined ? POSITION_KEY : _table$keyField;
59
60
 
@@ -61,16 +62,31 @@ function tableConfFrom(_ref) {
61
62
  formData = addPosition(formData);
62
63
  }
63
64
 
65
+ if (!table.selectRow && selectedItems) {
66
+ table.selectRow = {
67
+ mode: "checkbox"
68
+ };
69
+ }
70
+
71
+ if (selectedItems) {
72
+ table.selectRow.onSelectRow = true, table.selectRow.onSelectAllRow = true;
73
+ }
74
+
75
+ table.selectRow.selected = selectedItems;
76
+
64
77
  var tableConf = Object.assign({ data: formData }, (0, _utils.deepCopy)(DEFAULT_TABLE_CONF), table, { keyField: keyField });
65
78
  tableConf.cellEdit.afterSaveCell = afterSaveCell;
66
79
  tableConf.options.afterDeleteRow = afterDeleteRow;
67
80
  tableConf.trClassName = highlightAfterDelete;
68
- if (tableConf.selectRow !== undefined && tableConf.selectRow.onSelectRow !== undefined) {
81
+
82
+ if (tableConf.selectRow && tableConf.selectRow.onSelectRow) {
69
83
  tableConf.selectRow.onSelect = handleRowSelect;
70
84
  }
71
- if (tableConf.selectRow !== undefined && tableConf.selectRow.onSelectAllRow !== undefined) {
85
+
86
+ if (tableConf.selectRow && tableConf.selectRow.onSelectAllRow) {
72
87
  tableConf.selectRow.onSelectAll = handleAllRowSelect;
73
88
  }
89
+
74
90
  var _table$isTableExpanda = table.isTableExpandable,
75
91
  isTableExpandable = _table$isTableExpanda === undefined ? false : _table$isTableExpanda,
76
92
  _table$allowOneRowExp = table.allowOneRowExpanding,
package/lib/utils.js CHANGED
@@ -9,6 +9,7 @@ exports.isArraySchema = isArraySchema;
9
9
  exports.isStringSchema = isStringSchema;
10
10
  exports.isNumberSchema = isNumberSchema;
11
11
  exports.getDefaultValueForSchema = getDefaultValueForSchema;
12
+ exports.getFieldName = getFieldName;
12
13
  exports.deepCopy = deepCopy;
13
14
  function toArray(el) {
14
15
  if (Array.isArray(el)) {
@@ -53,6 +54,19 @@ function getDefaultValueForSchema(schema) {
53
54
  return "";
54
55
  }
55
56
 
57
+ function getFieldName(name) {
58
+ var DEFAULT_COMPONENT_TYPES = {
59
+ array: "ArrayField",
60
+ boolean: "BooleanField",
61
+ integer: "NumberField",
62
+ number: "NumberField",
63
+ object: "ObjectField",
64
+ string: "StringField"
65
+ };
66
+
67
+ return DEFAULT_COMPONENT_TYPES["" + name] || name;
68
+ }
69
+
56
70
  function deepCopy(obj) {
57
71
  return JSON.parse(JSON.stringify(obj));
58
72
  }
package/package.json CHANGED
@@ -1,136 +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.65",
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
- "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
- "lint-staged": "^6.0.0",
99
- "moment": "^2.20.1",
100
- "prettier": "^1.7.4",
101
- "react": "^16.0.0",
102
- "react-bootstrap-table": "^4.3.0",
103
- "react-bootstrap-typeahead": "^3.2.4",
104
- "react-day-picker": "^7.0.5",
105
- "react-dom": "^16.0.0",
106
- "react-jsonschema-form": "^1.0.0",
107
- "react-rte": "^0.15.0",
108
- "react-test-renderer": "^16.0.0",
109
- "react-transform-catch-errors": "^1.0.2",
110
- "react-transform-hmr": "^1.0.4",
111
- "regenerator-runtime": "^0.11.0",
112
- "rimraf": "^2.6.2",
113
- "selectn": "^1.1.2",
114
- "sinon": "^4.1.1",
115
- "style-loader": "^0.19.0",
116
- "webpack": "^3.9.1",
117
- "webpack-dev-server": "^2.9.3",
118
- "webpack-hot-middleware": "^2.20.0"
119
- },
120
- "directories": {
121
- "test": "test"
122
- },
123
- "repository": {
124
- "type": "git",
125
- "url": "git+https://github.com/RxNT/react-jsonschema-form-extras.git"
126
- },
127
- "keywords": [
128
- "react",
129
- "form",
130
- "json-schema",
131
- "conditional",
132
- "predicate"
133
- ],
134
- "license": "Apache-2.0",
135
- "homepage": "https://github.com/RxNT/react-jsonschema-form-extras#readme"
136
- }
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.69",
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
+ }