@gpa-gemstone/react-forms 1.1.37 → 1.1.39

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/DatePicker.js CHANGED
@@ -39,8 +39,8 @@ var DateTimePopup_1 = require("./DateTimeUI/DateTimePopup");
39
39
  var helper_functions_1 = require("@gpa-gemstone/helper-functions");
40
40
  function DateTimePicker(props) {
41
41
  // Formats that will be used for dateBoxes
42
- var boxFormat = "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]hh:mm:ss");
43
- var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]hh:mm:ss.SSS[Z]");
42
+ var boxFormat = "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss");
43
+ var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss.SSS[Z]");
44
44
  var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
45
45
  var divRef = React.useRef(null);
46
46
  // Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
@@ -111,7 +111,7 @@ function Calender(props) {
111
111
  React.createElement("td", { style: { width: 20, padding: 5 } }, "FR"),
112
112
  React.createElement("td", { style: { width: 20, padding: 5 } }, "SA")) : null),
113
113
  React.createElement("tbody", null,
114
- mode === 'month' ? weeks.map(function (w) { return React.createElement("tr", { key: w.sunday.isoWeekYear(), style: { height: 20, lineHeight: '20px' } },
114
+ mode === 'month' ? weeks.map(function (w) { return React.createElement("tr", { key: w.sunday.isoWeek(), style: { height: 20, lineHeight: '20px' } },
115
115
  React.createElement(DayCell, { date: w.sunday, month: month, day: props.DateTime.date(), onClick: function (evt) { evt.stopPropagation(); setDate(w.sunday); } }),
116
116
  React.createElement(DayCell, { date: w.monday, month: month, day: props.DateTime.date(), onClick: function (evt) { evt.stopPropagation(); setDate(w.monday); } }),
117
117
  React.createElement(DayCell, { date: w.tuesday, month: month, day: props.DateTime.date(), onClick: function (evt) { evt.stopPropagation(); setDate(w.tuesday); } }),
@@ -142,7 +142,7 @@ var DayCell = function (props) {
142
142
  var _b = React.useState(false), hover = _b[0], setHover = _b[1];
143
143
  var _c = React.useState(false), disabled = _c[0], setDisabled = _c[1];
144
144
  React.useEffect(function () {
145
- setActive(props.date.date() === props.day);
145
+ setActive(props.date.date() === props.day && props.month === props.date.month());
146
146
  setDisabled(props.date.month() !== props.month);
147
147
  }, [props.month, props.date, props.day]);
148
148
  var color = (disabled ? '#777' : (active ? '#fff' : undefined));
@@ -46,11 +46,21 @@ function Clock(props) {
46
46
  }, [hour, minute, second]);
47
47
  function increase(type) {
48
48
  var d = moment(props.DateTime).add(1, type);
49
- setHour(d.format("HH"));
49
+ if (type === 'h')
50
+ setHour(d.format("HH"));
51
+ if (type === 'm')
52
+ setMinute(d.format("mm"));
53
+ if (type === 's')
54
+ setSecond(d.format("ss"));
50
55
  }
51
56
  function decrease(type) {
52
57
  var d = moment(props.DateTime).subtract(1, type);
53
- setHour(d.format("HH"));
58
+ if (type === 'h')
59
+ setHour(d.format("HH"));
60
+ if (type === 'm')
61
+ setMinute(d.format("mm"));
62
+ if (type === 's')
63
+ setSecond(d.format("ss"));
54
64
  }
55
65
  return (React.createElement("div", { style: { background: '#f0f0f0', marginTop: 10, opacity: 1 } },
56
66
  React.createElement("table", { style: { textAlign: 'center' } },
package/lib/Input.d.ts CHANGED
@@ -12,6 +12,7 @@ interface IProps<T> {
12
12
  Style?: React.CSSProperties;
13
13
  AllowNull?: boolean;
14
14
  Size?: 'small' | 'large';
15
+ DefaultValue?: number;
15
16
  }
16
17
  export default function Input<T>(props: IProps<T>): JSX.Element;
17
18
  export {};
package/lib/Input.js CHANGED
@@ -52,6 +52,15 @@ function Input(props) {
52
52
  }
53
53
  setInternal(false);
54
54
  }, [props.Record[props.Field]]);
55
+ function onBlur() {
56
+ var _a;
57
+ var _b;
58
+ var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
59
+ if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
60
+ setInternal(false);
61
+ props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
62
+ }
63
+ }
55
64
  function valueChange(value) {
56
65
  var _a, _b, _c;
57
66
  setInternal(true);
@@ -62,12 +71,18 @@ function Input(props) {
62
71
  props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
63
72
  setHeldVal(v);
64
73
  }
74
+ else if (v === '') {
75
+ setHeldVal(v);
76
+ }
65
77
  }
66
78
  else if (props.Type === 'integer') {
67
79
  if ((0, helper_functions_1.IsInteger)(value) || (value === '' && allowNull)) {
68
80
  props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
69
81
  setHeldVal(value);
70
82
  }
83
+ else if (value === '') {
84
+ setHeldVal(value);
85
+ }
71
86
  }
72
87
  else {
73
88
  props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
@@ -77,7 +92,7 @@ function Input(props) {
77
92
  var showLabel = props.Label !== "";
78
93
  var showHelpIcon = props.Help !== undefined;
79
94
  var label = props.Label === undefined ? props.Field : props.Label;
80
- return (React.createElement("div", { className: "form-control " + (props.Size === 'large' ? 'form-control-lg' : '') + (props.Size === 'small' ? 'form-control-sm' : ''), style: props.Style },
95
+ return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.Style },
81
96
  showHelpIcon || showLabel ?
82
97
  React.createElement("label", null,
83
98
  showLabel ? label : '',
@@ -85,7 +100,7 @@ function Input(props) {
85
100
  showHelpIcon ?
86
101
  React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
87
102
  : null,
88
- React.createElement("input", { "data-help": guid, type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal, disabled: props.Disabled == null ? false : props.Disabled }),
103
+ React.createElement("input", { "data-help": guid, type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal, disabled: props.Disabled == null ? false : props.Disabled, onBlur: onBlur }),
89
104
  React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
90
105
  }
91
106
  exports.default = Input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-forms",
3
- "version": "1.1.37",
3
+ "version": "1.1.39",
4
4
  "description": "React Form modules for gpa webapps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",