Skip to content

Commit 31086b9

Browse files
committed
Bump version to 2.2.0 and update dist files
1 parent 33227ed commit 31086b9

File tree

5 files changed

+74
-59
lines changed

5 files changed

+74
-59
lines changed

dist/react-json-form.cjs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,11 @@ class FormFileInput extends React__default["default"].Component {
983983
loading: true
984984
});
985985
let formData = new FormData();
986-
formData.append('field_name', this.context.fieldName);
987-
formData.append('model_name', this.context.modelName);
986+
987+
for (let key in this.context.fileHandlerArgs) {
988+
if (this.context.fileHandlerArgs.hasOwnProperty(key)) formData.append(key, this.context.fileHandlerArgs[key]);
989+
}
990+
988991
formData.append('coords', getCoordsFromName(this.props.name));
989992
formData.append('file', e.target.files[0]);
990993
fetch(endpoint, {
@@ -1762,7 +1765,6 @@ class FileUploader extends React__default["default"].Component {
17621765
name: this.props.name
17631766
}
17641767
};
1765-
this.sendDeleteRequest([this.props.value], 'clear_button');
17661768
this.props.onChange(event);
17671769
}
17681770
};
@@ -1776,12 +1778,10 @@ class FileUploader extends React__default["default"].Component {
17761778
* keepalive: (bool) whether to use keepalive flag or not
17771779
*/
17781780
let endpoint = this.props.handler || this.context.fileHandler;
1779-
let querystring = new URLSearchParams({
1780-
field_name: this.context.fieldName,
1781-
model_name: this.context.modelName,
1781+
let querystring = new URLSearchParams(_extends({}, this.context.fileHandlerArgs, {
17821782
coords: getCoordsFromName(this.props.name),
17831783
trigger: trigger
1784-
});
1784+
}));
17851785

17861786
for (let i = 0; i < values.length; i++) {
17871787
querystring.append('value', values[i]);
@@ -1876,11 +1876,9 @@ class FileUploader extends React__default["default"].Component {
18761876
error: ""
18771877
})), this.state.pane === 'library' && /*#__PURE__*/React__default["default"].createElement(LibraryPane, {
18781878
fileHandler: this.props.handler || this.context.fileHandler,
1879-
fileHandlerArgs: {
1880-
field_name: this.context.fieldName,
1881-
model_name: this.context.modelName,
1879+
fileHandlerArgs: _extends({}, this.context.fileHandlerArgs, {
18821880
coords: getCoordsFromName(this.props.name)
1883-
},
1881+
}),
18841882
onFileSelect: this.handleFileSelect,
18851883
sendDeleteRequest: this.sendDeleteRequest
18861884
})), /*#__PURE__*/React__default["default"].createElement("div", {
@@ -2807,8 +2805,7 @@ class ReactJSONForm extends React__default["default"].Component {
28072805
}, /*#__PURE__*/React__default["default"].createElement(EditorContext.Provider, {
28082806
value: {
28092807
fileHandler: this.props.fileHandler,
2810-
fieldName: this.props.fieldName,
2811-
modelName: this.props.modelName
2808+
fileHandlerArgs: this.props.fileHandlerArgs
28122809
}
28132810
}, this.getFields())));
28142811
}
@@ -3148,9 +3145,9 @@ function FormInstance(config) {
31483145
this.data = config.data;
31493146
this.errorMap = config.errorMap;
31503147
this.fileHandler = config.fileHandler;
3151-
this.fieldName = config.fieldName;
3152-
this.modelName = config.modelName;
3148+
this.fileHandlerArgs = config.fileHandlerArgs || {};
31533149
this.eventListeners = null;
3150+
this._dataSynced = false;
31543151

31553152
this.addEventListener = function (event, listener) {
31563153
if (this.eventListeners === null) this.eventListeners = {};
@@ -3160,6 +3157,13 @@ function FormInstance(config) {
31603157

31613158
this.onChange = function (e) {
31623159
this.data = e.data;
3160+
3161+
if (!this._dataSynced) {
3162+
// this is the first change event for syncing data
3163+
this._dataSynced = true;
3164+
return;
3165+
}
3166+
31633167
if (!this.eventListeners) return;
31643168
if (!this.eventListeners.hasOwnProperty('change') || !this.eventListeners.change.size) return;
31653169
this.eventListeners.change.forEach(cb => cb(e));
@@ -3175,8 +3179,7 @@ function FormInstance(config) {
31753179
data: this.data,
31763180
errorMap: this.errorMap,
31773181
fileHandler: this.fileHandler,
3178-
fieldName: this.fieldName,
3179-
modelName: this.modelName,
3182+
fileHandlerArgs: this.fileHandlerArgs,
31803183
onChange: this.onChange
31813184
}), document.getElementById(this.containerId));
31823185
} catch (error) {
@@ -3238,6 +3241,9 @@ class FormContainer extends React__default["default"].Component {
32383241
}
32393242

32403243
componentDidMount() {
3244+
this.props.onChange({
3245+
data: this.state.editorState.getData()
3246+
});
32413247
this.populateDataInput(this.state.editorState.getData());
32423248
}
32433249

@@ -3272,8 +3278,7 @@ class FormContainer extends React__default["default"].Component {
32723278
editorState: this.state.editorState,
32733279
onChange: this.handleChange,
32743280
fileHandler: this.props.fileHandler,
3275-
fieldName: this.props.fieldName,
3276-
modelName: this.props.modelName,
3281+
fileHandlerArgs: this.props.fileHandlerArgs,
32773282
errorMap: this.props.errorMap
32783283
});
32793284
}

dist/react-json-form.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-json-form.modern.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,11 @@ class FormFileInput extends React$1.Component {
977977
loading: true
978978
});
979979
let formData = new FormData();
980-
formData.append('field_name', this.context.fieldName);
981-
formData.append('model_name', this.context.modelName);
980+
981+
for (let key in this.context.fileHandlerArgs) {
982+
if (this.context.fileHandlerArgs.hasOwnProperty(key)) formData.append(key, this.context.fileHandlerArgs[key]);
983+
}
984+
982985
formData.append('coords', getCoordsFromName(this.props.name));
983986
formData.append('file', e.target.files[0]);
984987
fetch(endpoint, {
@@ -1756,7 +1759,6 @@ class FileUploader extends React$1.Component {
17561759
name: this.props.name
17571760
}
17581761
};
1759-
this.sendDeleteRequest([this.props.value], 'clear_button');
17601762
this.props.onChange(event);
17611763
}
17621764
};
@@ -1770,12 +1772,10 @@ class FileUploader extends React$1.Component {
17701772
* keepalive: (bool) whether to use keepalive flag or not
17711773
*/
17721774
let endpoint = this.props.handler || this.context.fileHandler;
1773-
let querystring = new URLSearchParams({
1774-
field_name: this.context.fieldName,
1775-
model_name: this.context.modelName,
1775+
let querystring = new URLSearchParams(_extends({}, this.context.fileHandlerArgs, {
17761776
coords: getCoordsFromName(this.props.name),
17771777
trigger: trigger
1778-
});
1778+
}));
17791779

17801780
for (let i = 0; i < values.length; i++) {
17811781
querystring.append('value', values[i]);
@@ -1870,11 +1870,9 @@ class FileUploader extends React$1.Component {
18701870
error: ""
18711871
})), this.state.pane === 'library' && /*#__PURE__*/React$1.createElement(LibraryPane, {
18721872
fileHandler: this.props.handler || this.context.fileHandler,
1873-
fileHandlerArgs: {
1874-
field_name: this.context.fieldName,
1875-
model_name: this.context.modelName,
1873+
fileHandlerArgs: _extends({}, this.context.fileHandlerArgs, {
18761874
coords: getCoordsFromName(this.props.name)
1877-
},
1875+
}),
18781876
onFileSelect: this.handleFileSelect,
18791877
sendDeleteRequest: this.sendDeleteRequest
18801878
})), /*#__PURE__*/React$1.createElement("div", {
@@ -2801,8 +2799,7 @@ class ReactJSONForm extends React$1.Component {
28012799
}, /*#__PURE__*/React$1.createElement(EditorContext.Provider, {
28022800
value: {
28032801
fileHandler: this.props.fileHandler,
2804-
fieldName: this.props.fieldName,
2805-
modelName: this.props.modelName
2802+
fileHandlerArgs: this.props.fileHandlerArgs
28062803
}
28072804
}, this.getFields())));
28082805
}
@@ -3142,9 +3139,9 @@ function FormInstance(config) {
31423139
this.data = config.data;
31433140
this.errorMap = config.errorMap;
31443141
this.fileHandler = config.fileHandler;
3145-
this.fieldName = config.fieldName;
3146-
this.modelName = config.modelName;
3142+
this.fileHandlerArgs = config.fileHandlerArgs || {};
31473143
this.eventListeners = null;
3144+
this._dataSynced = false;
31483145

31493146
this.addEventListener = function (event, listener) {
31503147
if (this.eventListeners === null) this.eventListeners = {};
@@ -3154,6 +3151,13 @@ function FormInstance(config) {
31543151

31553152
this.onChange = function (e) {
31563153
this.data = e.data;
3154+
3155+
if (!this._dataSynced) {
3156+
// this is the first change event for syncing data
3157+
this._dataSynced = true;
3158+
return;
3159+
}
3160+
31573161
if (!this.eventListeners) return;
31583162
if (!this.eventListeners.hasOwnProperty('change') || !this.eventListeners.change.size) return;
31593163
this.eventListeners.change.forEach(cb => cb(e));
@@ -3169,8 +3173,7 @@ function FormInstance(config) {
31693173
data: this.data,
31703174
errorMap: this.errorMap,
31713175
fileHandler: this.fileHandler,
3172-
fieldName: this.fieldName,
3173-
modelName: this.modelName,
3176+
fileHandlerArgs: this.fileHandlerArgs,
31743177
onChange: this.onChange
31753178
}), document.getElementById(this.containerId));
31763179
} catch (error) {
@@ -3232,6 +3235,9 @@ class FormContainer extends React$1.Component {
32323235
}
32333236

32343237
componentDidMount() {
3238+
this.props.onChange({
3239+
data: this.state.editorState.getData()
3240+
});
32353241
this.populateDataInput(this.state.editorState.getData());
32363242
}
32373243

@@ -3266,8 +3272,7 @@ class FormContainer extends React$1.Component {
32663272
editorState: this.state.editorState,
32673273
onChange: this.handleChange,
32683274
fileHandler: this.props.fileHandler,
3269-
fieldName: this.props.fieldName,
3270-
modelName: this.props.modelName,
3275+
fileHandlerArgs: this.props.fileHandlerArgs,
32713276
errorMap: this.props.errorMap
32723277
});
32733278
}

dist/react-json-form.module.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,11 @@ class FormFileInput extends React$1.Component {
977977
loading: true
978978
});
979979
let formData = new FormData();
980-
formData.append('field_name', this.context.fieldName);
981-
formData.append('model_name', this.context.modelName);
980+
981+
for (let key in this.context.fileHandlerArgs) {
982+
if (this.context.fileHandlerArgs.hasOwnProperty(key)) formData.append(key, this.context.fileHandlerArgs[key]);
983+
}
984+
982985
formData.append('coords', getCoordsFromName(this.props.name));
983986
formData.append('file', e.target.files[0]);
984987
fetch(endpoint, {
@@ -1756,7 +1759,6 @@ class FileUploader extends React$1.Component {
17561759
name: this.props.name
17571760
}
17581761
};
1759-
this.sendDeleteRequest([this.props.value], 'clear_button');
17601762
this.props.onChange(event);
17611763
}
17621764
};
@@ -1770,12 +1772,10 @@ class FileUploader extends React$1.Component {
17701772
* keepalive: (bool) whether to use keepalive flag or not
17711773
*/
17721774
let endpoint = this.props.handler || this.context.fileHandler;
1773-
let querystring = new URLSearchParams({
1774-
field_name: this.context.fieldName,
1775-
model_name: this.context.modelName,
1775+
let querystring = new URLSearchParams(_extends({}, this.context.fileHandlerArgs, {
17761776
coords: getCoordsFromName(this.props.name),
17771777
trigger: trigger
1778-
});
1778+
}));
17791779

17801780
for (let i = 0; i < values.length; i++) {
17811781
querystring.append('value', values[i]);
@@ -1870,11 +1870,9 @@ class FileUploader extends React$1.Component {
18701870
error: ""
18711871
})), this.state.pane === 'library' && /*#__PURE__*/React$1.createElement(LibraryPane, {
18721872
fileHandler: this.props.handler || this.context.fileHandler,
1873-
fileHandlerArgs: {
1874-
field_name: this.context.fieldName,
1875-
model_name: this.context.modelName,
1873+
fileHandlerArgs: _extends({}, this.context.fileHandlerArgs, {
18761874
coords: getCoordsFromName(this.props.name)
1877-
},
1875+
}),
18781876
onFileSelect: this.handleFileSelect,
18791877
sendDeleteRequest: this.sendDeleteRequest
18801878
})), /*#__PURE__*/React$1.createElement("div", {
@@ -2801,8 +2799,7 @@ class ReactJSONForm extends React$1.Component {
28012799
}, /*#__PURE__*/React$1.createElement(EditorContext.Provider, {
28022800
value: {
28032801
fileHandler: this.props.fileHandler,
2804-
fieldName: this.props.fieldName,
2805-
modelName: this.props.modelName
2802+
fileHandlerArgs: this.props.fileHandlerArgs
28062803
}
28072804
}, this.getFields())));
28082805
}
@@ -3142,9 +3139,9 @@ function FormInstance(config) {
31423139
this.data = config.data;
31433140
this.errorMap = config.errorMap;
31443141
this.fileHandler = config.fileHandler;
3145-
this.fieldName = config.fieldName;
3146-
this.modelName = config.modelName;
3142+
this.fileHandlerArgs = config.fileHandlerArgs || {};
31473143
this.eventListeners = null;
3144+
this._dataSynced = false;
31483145

31493146
this.addEventListener = function (event, listener) {
31503147
if (this.eventListeners === null) this.eventListeners = {};
@@ -3154,6 +3151,13 @@ function FormInstance(config) {
31543151

31553152
this.onChange = function (e) {
31563153
this.data = e.data;
3154+
3155+
if (!this._dataSynced) {
3156+
// this is the first change event for syncing data
3157+
this._dataSynced = true;
3158+
return;
3159+
}
3160+
31573161
if (!this.eventListeners) return;
31583162
if (!this.eventListeners.hasOwnProperty('change') || !this.eventListeners.change.size) return;
31593163
this.eventListeners.change.forEach(cb => cb(e));
@@ -3169,8 +3173,7 @@ function FormInstance(config) {
31693173
data: this.data,
31703174
errorMap: this.errorMap,
31713175
fileHandler: this.fileHandler,
3172-
fieldName: this.fieldName,
3173-
modelName: this.modelName,
3176+
fileHandlerArgs: this.fileHandlerArgs,
31743177
onChange: this.onChange
31753178
}), document.getElementById(this.containerId));
31763179
} catch (error) {
@@ -3232,6 +3235,9 @@ class FormContainer extends React$1.Component {
32323235
}
32333236

32343237
componentDidMount() {
3238+
this.props.onChange({
3239+
data: this.state.editorState.getData()
3240+
});
32353241
this.populateDataInput(this.state.editorState.getData());
32363242
}
32373243

@@ -3266,8 +3272,7 @@ class FormContainer extends React$1.Component {
32663272
editorState: this.state.editorState,
32673273
onChange: this.handleChange,
32683274
fileHandler: this.props.fileHandler,
3269-
fieldName: this.props.fieldName,
3270-
modelName: this.props.modelName,
3275+
fileHandlerArgs: this.props.fileHandlerArgs,
32713276
errorMap: this.props.errorMap
32723277
});
32733278
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bhch/react-json-form",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Create forms using JSON Schema",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)