Skip to content

Commit 545e9af

Browse files
committed
Bump version 2.13.4 and update dist files
1 parent 88a1548 commit 545e9af

File tree

5 files changed

+86
-5
lines changed

5 files changed

+86
-5
lines changed

dist/react-json-form.cjs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,31 @@ function getKey(obj, key, default_value) {
183183
let val = obj[key];
184184
return typeof val !== 'undefined' ? val : default_value;
185185
}
186+
function choicesValueTitleMap(choices) {
187+
/* Returns a mapping of {value: title} for the given choices.
188+
* E.g.:
189+
* Input: [{'title': 'One', 'value': 1}, 2]
190+
* Output: {1: 'One', 2: 2}
191+
*/
192+
let map = {};
193+
194+
for (let i = 0; i < choices.length; i++) {
195+
let choice = choices[i];
196+
let value, title;
197+
198+
if (actualType(choice) === 'object') {
199+
value = choice.value;
200+
title = choice.title;
201+
} else {
202+
value = choice;
203+
title = choice;
204+
}
205+
206+
map[value] = title;
207+
}
208+
209+
return map;
210+
}
186211
function valueInChoices(schema, value) {
187212
/* Checks whether the given value is in schema choices or not.
188213
If schema doesn't have choices, returns true.
@@ -1170,6 +1195,7 @@ class FormMultiSelectInput extends React__default["default"].Component {
11701195
inputRef: this.input,
11711196
onClick: this.toggleOptions,
11721197
value: this.props.value,
1198+
options: this.props.options,
11731199
onChange: this.handleChange,
11741200
disabled: this.props.readOnly,
11751201
placeholder: this.props.placeholder
@@ -1204,6 +1230,7 @@ class FormMultiSelectInputField extends React__default["default"].Component {
12041230
}
12051231

12061232
render() {
1233+
let valueTitleMap = choicesValueTitleMap(this.props.options);
12071234
return /*#__PURE__*/React__default["default"].createElement("div", {
12081235
className: "rjf-multiselect-field-input",
12091236
onClick: this.props.onClick,
@@ -1212,7 +1239,7 @@ class FormMultiSelectInputField extends React__default["default"].Component {
12121239
}, this.props.value.length ? this.props.value.map((item, index) => /*#__PURE__*/React__default["default"].createElement("span", {
12131240
className: "rjf-multiselect-field-input-item",
12141241
key: item + '_' + index
1215-
}, /*#__PURE__*/React__default["default"].createElement("span", null, item), this.props.disabled || /*#__PURE__*/React__default["default"].createElement("button", {
1242+
}, /*#__PURE__*/React__default["default"].createElement("span", null, valueTitleMap[item]), this.props.disabled || /*#__PURE__*/React__default["default"].createElement("button", {
12161243
title: "Remove",
12171244
type: "button",
12181245
onClick: e => this.handleRemove(e, index)

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: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,31 @@ function getKey(obj, key, default_value) {
177177
let val = obj[key];
178178
return typeof val !== 'undefined' ? val : default_value;
179179
}
180+
function choicesValueTitleMap(choices) {
181+
/* Returns a mapping of {value: title} for the given choices.
182+
* E.g.:
183+
* Input: [{'title': 'One', 'value': 1}, 2]
184+
* Output: {1: 'One', 2: 2}
185+
*/
186+
let map = {};
187+
188+
for (let i = 0; i < choices.length; i++) {
189+
let choice = choices[i];
190+
let value, title;
191+
192+
if (actualType(choice) === 'object') {
193+
value = choice.value;
194+
title = choice.title;
195+
} else {
196+
value = choice;
197+
title = choice;
198+
}
199+
200+
map[value] = title;
201+
}
202+
203+
return map;
204+
}
180205
function valueInChoices(schema, value) {
181206
/* Checks whether the given value is in schema choices or not.
182207
If schema doesn't have choices, returns true.
@@ -1164,6 +1189,7 @@ class FormMultiSelectInput extends React$1.Component {
11641189
inputRef: this.input,
11651190
onClick: this.toggleOptions,
11661191
value: this.props.value,
1192+
options: this.props.options,
11671193
onChange: this.handleChange,
11681194
disabled: this.props.readOnly,
11691195
placeholder: this.props.placeholder
@@ -1198,6 +1224,7 @@ class FormMultiSelectInputField extends React$1.Component {
11981224
}
11991225

12001226
render() {
1227+
let valueTitleMap = choicesValueTitleMap(this.props.options);
12011228
return /*#__PURE__*/React$1.createElement("div", {
12021229
className: "rjf-multiselect-field-input",
12031230
onClick: this.props.onClick,
@@ -1206,7 +1233,7 @@ class FormMultiSelectInputField extends React$1.Component {
12061233
}, this.props.value.length ? this.props.value.map((item, index) => /*#__PURE__*/React$1.createElement("span", {
12071234
className: "rjf-multiselect-field-input-item",
12081235
key: item + '_' + index
1209-
}, /*#__PURE__*/React$1.createElement("span", null, item), this.props.disabled || /*#__PURE__*/React$1.createElement("button", {
1236+
}, /*#__PURE__*/React$1.createElement("span", null, valueTitleMap[item]), this.props.disabled || /*#__PURE__*/React$1.createElement("button", {
12101237
title: "Remove",
12111238
type: "button",
12121239
onClick: e => this.handleRemove(e, index)

dist/react-json-form.module.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,31 @@ function getKey(obj, key, default_value) {
177177
let val = obj[key];
178178
return typeof val !== 'undefined' ? val : default_value;
179179
}
180+
function choicesValueTitleMap(choices) {
181+
/* Returns a mapping of {value: title} for the given choices.
182+
* E.g.:
183+
* Input: [{'title': 'One', 'value': 1}, 2]
184+
* Output: {1: 'One', 2: 2}
185+
*/
186+
let map = {};
187+
188+
for (let i = 0; i < choices.length; i++) {
189+
let choice = choices[i];
190+
let value, title;
191+
192+
if (actualType(choice) === 'object') {
193+
value = choice.value;
194+
title = choice.title;
195+
} else {
196+
value = choice;
197+
title = choice;
198+
}
199+
200+
map[value] = title;
201+
}
202+
203+
return map;
204+
}
180205
function valueInChoices(schema, value) {
181206
/* Checks whether the given value is in schema choices or not.
182207
If schema doesn't have choices, returns true.
@@ -1164,6 +1189,7 @@ class FormMultiSelectInput extends React$1.Component {
11641189
inputRef: this.input,
11651190
onClick: this.toggleOptions,
11661191
value: this.props.value,
1192+
options: this.props.options,
11671193
onChange: this.handleChange,
11681194
disabled: this.props.readOnly,
11691195
placeholder: this.props.placeholder
@@ -1198,6 +1224,7 @@ class FormMultiSelectInputField extends React$1.Component {
11981224
}
11991225

12001226
render() {
1227+
let valueTitleMap = choicesValueTitleMap(this.props.options);
12011228
return /*#__PURE__*/React$1.createElement("div", {
12021229
className: "rjf-multiselect-field-input",
12031230
onClick: this.props.onClick,
@@ -1206,7 +1233,7 @@ class FormMultiSelectInputField extends React$1.Component {
12061233
}, this.props.value.length ? this.props.value.map((item, index) => /*#__PURE__*/React$1.createElement("span", {
12071234
className: "rjf-multiselect-field-input-item",
12081235
key: item + '_' + index
1209-
}, /*#__PURE__*/React$1.createElement("span", null, item), this.props.disabled || /*#__PURE__*/React$1.createElement("button", {
1236+
}, /*#__PURE__*/React$1.createElement("span", null, valueTitleMap[item]), this.props.disabled || /*#__PURE__*/React$1.createElement("button", {
12101237
title: "Remove",
12111238
type: "button",
12121239
onClick: e => this.handleRemove(e, index)

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.13.3",
3+
"version": "2.13.4",
44
"description": "Create forms using JSON Schema",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)