@gpa-gemstone/react-forms 1.1.65 → 1.1.66

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.
Files changed (2) hide show
  1. package/lib/Select.js +16 -8
  2. package/package.json +2 -2
package/lib/Select.js CHANGED
@@ -51,7 +51,7 @@ function Select(props) {
51
51
  React.useEffect(function () {
52
52
  var _a;
53
53
  var currentValue = GetRecordValue();
54
- if (!((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : false) && props.Options.length > 0 && props.Options.findIndex(function (option) { return option.Value === currentValue; }) === -1) {
54
+ if (!((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : false) && props.Options.length > 0 && props.Options.findIndex(function (option) { return option.Value == currentValue; }) === -1) {
55
55
  SetRecord(props.Options[0].Value);
56
56
  // tslint:disable-next-line
57
57
  console.warn("The current value is not available as an option. Specify EmptyOption=true if the value should be allowed.");
@@ -59,23 +59,31 @@ function Select(props) {
59
59
  }, [props.Options]);
60
60
  // Update the parent component's state with the new value.
61
61
  function SetRecord(value) {
62
+ var _a, _b;
62
63
  var record = __assign({}, props.Record);
63
- if (value !== '')
64
- record[props.Field] = value;
64
+ if (value !== '') {
65
+ var val = (_b = (_a = props.Options.find(function (op) { return op.Value == value; })) === null || _a === void 0 ? void 0 : _a.Value) !== null && _b !== void 0 ? _b : value;
66
+ record[props.Field] = val;
67
+ }
65
68
  else
66
69
  record[props.Field] = null;
67
- props.Setter(record);
70
+ if (record[props.Field] != props.Record[props.Field])
71
+ props.Setter(record);
68
72
  }
69
73
  // Rretrieve the current value of the select field from the record.
70
74
  function GetRecordValue() {
71
75
  return props.Record[props.Field] == null ? '' : props.Record[props.Field];
72
76
  }
77
+ // Variables to control the rendering of label and help icon.
78
+ var showLabel = props.Label !== "";
79
+ var showHelpIcon = props.Help !== undefined;
80
+ var label = props.Label === undefined ? props.Field : props.Label;
73
81
  return (React.createElement("div", { className: "form-group" },
74
- (props.Label !== "") ?
82
+ showHelpIcon || showLabel ?
75
83
  React.createElement("label", null,
76
- props.Label === undefined ? props.Field : props.Label,
77
- props.Help !== undefined ? React.createElement("div", { style: { width: 20, height: 20, borderRadius: '50%', display: 'inline-block', background: '#0D6EFD', marginLeft: 10, textAlign: 'center', fontWeight: 'bold' }, onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } }, " ? ") : null) : null,
78
- props.Help !== undefined ?
84
+ showLabel ? label : '',
85
+ showHelpIcon ? React.createElement("div", { style: { width: 20, height: 20, borderRadius: '50%', display: 'inline-block', background: '#0D6EFD', marginLeft: 10, textAlign: 'center', fontWeight: 'bold' }, onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } }, " ? ") : null) : null,
86
+ showHelpIcon ?
79
87
  React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
80
88
  : null,
81
89
  React.createElement("select", { "data-help": guid, className: "form-control", onChange: function (evt) { return SetRecord(evt.target.value); }, value: GetRecordValue(), disabled: props.Disabled == null ? false : props.Disabled },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-forms",
3
- "version": "1.1.65",
3
+ "version": "1.1.66",
4
4
  "description": "React Form modules for gpa webapps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "typescript": "5.5.3"
46
46
  },
47
47
  "dependencies": {
48
- "@gpa-gemstone/application-typings": "0.0.72",
48
+ "@gpa-gemstone/application-typings": "0.0.73",
49
49
  "@gpa-gemstone/helper-functions": "0.0.32",
50
50
  "@types/react": "^17.0.14",
51
51
  "@types/styled-components": "^5.1.11",