@gpa-gemstone/react-forms 1.1.32 → 1.1.33

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/Input.d.ts CHANGED
@@ -7,7 +7,7 @@ interface IProps<T> {
7
7
  Label?: string;
8
8
  Feedback?: string;
9
9
  Disabled?: boolean;
10
- Type?: 'number' | 'text' | 'password' | 'email' | 'color';
10
+ Type?: 'number' | 'text' | 'password' | 'email' | 'color' | 'integer';
11
11
  Help?: string | JSX.Element;
12
12
  }
13
13
  export default function Input<T>(props: IProps<T>): JSX.Element;
package/lib/Input.js CHANGED
@@ -53,7 +53,7 @@ function Input(props) {
53
53
  setInternal(false);
54
54
  }, [props.Record[props.Field]]);
55
55
  function valueChange(value) {
56
- var _a, _b;
56
+ var _a, _b, _c;
57
57
  setInternal(true);
58
58
  if (props.Type === 'number') {
59
59
  if ((0, helper_functions_1.IsNumber)(value)) {
@@ -61,8 +61,14 @@ function Input(props) {
61
61
  setHeldVal(value);
62
62
  }
63
63
  }
64
+ else if (props.Type === 'integer') {
65
+ if ((0, helper_functions_1.IsInteger)(value)) {
66
+ props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
67
+ setHeldVal(value);
68
+ }
69
+ }
64
70
  else {
65
- props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? value : null, _b)));
71
+ props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
66
72
  setHeldVal(value);
67
73
  }
68
74
  }
package/lib/Select.js CHANGED
@@ -44,6 +44,28 @@ function Select(props) {
44
44
  React.useEffect(function () {
45
45
  setGuid((0, helper_functions_1.CreateGuid)());
46
46
  }, []);
47
+ React.useEffect(function () {
48
+ var _a;
49
+ var currentValue = GetRecordValue();
50
+ if (!((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : false) && props.Options.length > 0 && props.Options.findIndex(function (option) { return option.Value === currentValue; }) === -1) {
51
+ SetRecord(props.Options[0].Value);
52
+ // tslint:disable-next-line
53
+ console.warn("The current value is not available as an option. Specify EmptyOption=true if the value should be allowed.");
54
+ }
55
+ }, [props.Options]);
56
+ function SetRecord(value) {
57
+ var record = __assign({}, props.Record);
58
+ if (value !== '')
59
+ record[props.Field] = value;
60
+ else
61
+ record[props.Field] = null;
62
+ props.Setter(record);
63
+ }
64
+ ;
65
+ function GetRecordValue() {
66
+ return props.Record[props.Field] == null ? '' : props.Record[props.Field].toString();
67
+ }
68
+ ;
47
69
  return (React.createElement("div", { className: "form-group" },
48
70
  (props.Label !== "") ?
49
71
  React.createElement("label", null,
@@ -52,14 +74,7 @@ function Select(props) {
52
74
  props.Help !== undefined ?
53
75
  React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
54
76
  : null,
55
- React.createElement("select", { "data-help": guid, className: "form-control", onChange: function (evt) {
56
- var record = __assign({}, props.Record);
57
- if (evt.target.value !== '')
58
- record[props.Field] = evt.target.value;
59
- else
60
- record[props.Field] = null;
61
- props.Setter(record);
62
- }, value: props.Record[props.Field] == null ? '' : props.Record[props.Field].toString(), disabled: props.Disabled == null ? false : props.Disabled },
77
+ 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 },
63
78
  props.EmptyOption ? React.createElement("option", { value: "" }, props.EmptyLabel !== undefined ? props.EmptyLabel : '') : null,
64
79
  props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
65
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-forms",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "React Form modules for gpa webapps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",