@gpa-gemstone/react-forms 1.1.60 → 1.1.62
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/ArrayCheckBoxes.d.ts +33 -11
- package/lib/ArrayCheckBoxes.js +81 -79
- package/lib/ArrayMultiSelect.d.ts +47 -13
- package/lib/ArrayMultiSelect.js +49 -47
- package/lib/CheckBox.d.ts +37 -11
- package/lib/CheckBox.js +62 -60
- package/lib/ColorPicker.d.ts +59 -15
- package/lib/ColorPicker.js +114 -114
- package/lib/DatePicker.d.ts +23 -21
- package/lib/DatePicker.js +221 -214
- package/lib/DateRangePicker.d.ts +64 -13
- package/lib/DateRangePicker.js +143 -132
- package/lib/DateTimeUI/Calender.d.ts +7 -8
- package/lib/DateTimeUI/Calender.js +180 -180
- package/lib/DateTimeUI/Clock.d.ts +9 -10
- package/lib/DateTimeUI/Clock.js +153 -153
- package/lib/DateTimeUI/DateTimePopup.d.ts +16 -17
- package/lib/DateTimeUI/DateTimePopup.js +59 -59
- package/lib/DoubleInput.d.ts +58 -12
- package/lib/DoubleInput.js +55 -51
- package/lib/EnumCheckBoxes.d.ts +41 -9
- package/lib/EnumCheckBoxes.js +65 -58
- package/lib/HelperMessage.d.ts +37 -10
- package/lib/HelperMessage.js +93 -83
- package/lib/Input.d.ts +80 -18
- package/lib/Input.js +111 -106
- package/lib/InputWithButton.d.ts +109 -23
- package/lib/InputWithButton.js +107 -107
- package/lib/MutliCheckBoxSelect.d.ts +42 -18
- package/lib/MutliCheckBoxSelect.js +110 -104
- package/lib/RadioButtons.d.ts +15 -0
- package/lib/RadioButtons.js +62 -0
- package/lib/SearchableSelect.d.ts +60 -18
- package/lib/SearchableSelect.js +84 -85
- package/lib/Select.d.ts +57 -17
- package/lib/Select.js +84 -80
- package/lib/StylableSelect.d.ts +53 -17
- package/lib/StylableSelect.js +106 -101
- package/lib/TextArea.d.ts +54 -14
- package/lib/TextArea.js +76 -72
- package/lib/TimePicker.d.ts +50 -11
- package/lib/TimePicker.js +60 -51
- package/lib/ToggleSwitch.d.ts +44 -12
- package/lib/ToggleSwitch.js +57 -61
- package/lib/index.d.ts +19 -18
- package/lib/index.js +61 -59
- package/package.json +6 -5
package/lib/DateRangePicker.js
CHANGED
|
@@ -1,132 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// DateRangePicker.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
-
//
|
|
7
|
-
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
-
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
-
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
-
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
-
//
|
|
12
|
-
// http://opensource.org/licenses/MIT
|
|
13
|
-
//
|
|
14
|
-
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
-
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
-
// License for the specific language governing permissions and limitations.
|
|
17
|
-
//
|
|
18
|
-
// Code Modification History:
|
|
19
|
-
// ----------------------------------------------------------------------------------------------------
|
|
20
|
-
// 02/05/2020 - Billy Ernest
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
var __assign = (this && this.__assign) || function () {
|
|
25
|
-
__assign = Object.assign || function(t) {
|
|
26
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
-
s = arguments[i];
|
|
28
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
-
t[p] = s[p];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
return __assign.apply(this, arguments);
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
React.useEffect(function () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return ('
|
|
97
|
-
else
|
|
98
|
-
return ('
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// DateRangePicker.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
+
//
|
|
7
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
+
//
|
|
12
|
+
// http://opensource.org/licenses/MIT
|
|
13
|
+
//
|
|
14
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
+
// License for the specific language governing permissions and limitations.
|
|
17
|
+
//
|
|
18
|
+
// Code Modification History:
|
|
19
|
+
// ----------------------------------------------------------------------------------------------------
|
|
20
|
+
// 02/05/2020 - Billy Ernest
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
var __assign = (this && this.__assign) || function () {
|
|
25
|
+
__assign = Object.assign || function(t) {
|
|
26
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
+
s = arguments[i];
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
+
t[p] = s[p];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
return __assign.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = DateRangePicker;
|
|
37
|
+
var React = require("react");
|
|
38
|
+
var moment = require("moment");
|
|
39
|
+
/**
|
|
40
|
+
* DateRangePicker Component.
|
|
41
|
+
* Allows users to select a date range either by choosing predefined durations or by specifying custom dates.
|
|
42
|
+
*/
|
|
43
|
+
function DateRangePicker(props) {
|
|
44
|
+
// Range box vars, need a secondary var to avoid looping react hooks
|
|
45
|
+
var _a = React.useState('Custom'), formRange = _a[0], setFormRange = _a[1];
|
|
46
|
+
var _b = React.useState('Custom'), range = _b[0], setRange = _b[1];
|
|
47
|
+
// Tracks weather or not props.Record changes are due to internal input boxes or externally
|
|
48
|
+
var _c = React.useState(false), internal = _c[0], setInternal = _c[1];
|
|
49
|
+
// Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
|
|
50
|
+
var _d = React.useState(ParseRecord()), boxRecord = _d[0], setBoxRecord = _d[1];
|
|
51
|
+
// Formats that will be used for dateBoxes
|
|
52
|
+
var boxFormat = "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]hh:mm:ss");
|
|
53
|
+
var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]hh:mm:ss.SSS[Z]");
|
|
54
|
+
// Effect for handling changes to the props.Record.
|
|
55
|
+
React.useEffect(function () {
|
|
56
|
+
setRange(ToRange(moment(props.Record[props.ToField], recordFormat).diff(moment(props.Record[props.FromField], recordFormat), 'days')));
|
|
57
|
+
if (!internal)
|
|
58
|
+
setBoxRecord(ParseRecord());
|
|
59
|
+
setInternal(false);
|
|
60
|
+
}, [props.Record]);
|
|
61
|
+
// Effect for handling changes to the formRange state.
|
|
62
|
+
React.useEffect(function () {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
setRange(formRange);
|
|
65
|
+
var toTime = moment(props.Record[props.FromField], recordFormat).add(GetDays(formRange), 'days');
|
|
66
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.ToField] = toTime.format(recordFormat), _a)));
|
|
67
|
+
setBoxRecord(__assign(__assign({}, boxRecord), (_b = {}, _b[props.ToField] = toTime.format(boxFormat), _b)));
|
|
68
|
+
}, [formRange]);
|
|
69
|
+
// Parses the record for display in the date boxes.
|
|
70
|
+
function ParseRecord() {
|
|
71
|
+
var record = __assign({}, props.Record);
|
|
72
|
+
var ParseExternalField = function (field) { return props.Record[field] === null ? '' : moment(props.Record[field], recordFormat).format(boxFormat); };
|
|
73
|
+
record[props.ToField] = ParseExternalField(props.ToField);
|
|
74
|
+
record[props.FromField] = ParseExternalField(props.FromField);
|
|
75
|
+
return record;
|
|
76
|
+
}
|
|
77
|
+
// Converts the selected duration to a number of days.
|
|
78
|
+
function GetDays(val) {
|
|
79
|
+
if (val === '1 Day')
|
|
80
|
+
return 1;
|
|
81
|
+
if (val === '7 Days')
|
|
82
|
+
return 7;
|
|
83
|
+
if (val === '30 Days')
|
|
84
|
+
return 30;
|
|
85
|
+
if (val === '90 Days')
|
|
86
|
+
return 90;
|
|
87
|
+
if (val === '180 Days')
|
|
88
|
+
return 180;
|
|
89
|
+
if (val === '365 Days')
|
|
90
|
+
return 365;
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
// Maps a number of days to a Duration value.
|
|
94
|
+
function ToRange(days) {
|
|
95
|
+
if (days === 1)
|
|
96
|
+
return ('1 Day');
|
|
97
|
+
else if (days === 7)
|
|
98
|
+
return ('7 Days');
|
|
99
|
+
else if (days === 30)
|
|
100
|
+
return ('30 Days');
|
|
101
|
+
else if (days === 90)
|
|
102
|
+
return ('90 Days');
|
|
103
|
+
else if (days === 180)
|
|
104
|
+
return ('180 Days');
|
|
105
|
+
else if (days === 365)
|
|
106
|
+
return ('365 Days');
|
|
107
|
+
else
|
|
108
|
+
return ('Custom');
|
|
109
|
+
}
|
|
110
|
+
// Renders a date input box.
|
|
111
|
+
function dateBox(field) {
|
|
112
|
+
return React.createElement("div", { className: "col" },
|
|
113
|
+
React.createElement("input", { className: "form-control" + (props.Valid(props.FromField, props.ToField) ? '' : ' is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
|
|
114
|
+
var _a;
|
|
115
|
+
var record = __assign({}, props.Record);
|
|
116
|
+
if (evt.target.value !== '')
|
|
117
|
+
record[field] = moment(evt.target.value, boxFormat).format(recordFormat);
|
|
118
|
+
else
|
|
119
|
+
record[field] = null;
|
|
120
|
+
// These two updates should be batched together
|
|
121
|
+
props.Setter(record);
|
|
122
|
+
setBoxRecord(__assign(__assign({}, boxRecord), (_a = {}, _a[field] = evt.target.value, _a)));
|
|
123
|
+
setInternal(true);
|
|
124
|
+
}, value: boxRecord[field], disabled: props.Disabled === undefined ? false : props.Disabled }),
|
|
125
|
+
field !== props.FromField ? null :
|
|
126
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback === undefined ? 'From and to dates required, and from must be before to.' : props.Feedback));
|
|
127
|
+
}
|
|
128
|
+
// Main render method for the component.
|
|
129
|
+
return (React.createElement("div", { className: "form-group" },
|
|
130
|
+
props.Label === "" ? null : React.createElement("label", null, props.Label),
|
|
131
|
+
React.createElement("div", { className: "row" },
|
|
132
|
+
React.createElement("div", { className: "col" },
|
|
133
|
+
React.createElement("select", { className: "form-control", value: range, onChange: function (evt) { return setFormRange(evt.target.value); } },
|
|
134
|
+
React.createElement("option", { value: "Custom" }, "Custom"),
|
|
135
|
+
React.createElement("option", { value: "1 Day" }, "1 Day"),
|
|
136
|
+
React.createElement("option", { value: "7 Days" }, "7 Days"),
|
|
137
|
+
React.createElement("option", { value: "30 Days" }, "30 Days"),
|
|
138
|
+
React.createElement("option", { value: "90 Days" }, "90 Days"),
|
|
139
|
+
React.createElement("option", { value: "180 Days" }, "180 Days"),
|
|
140
|
+
React.createElement("option", { value: "365 Days" }, "365 Days"))),
|
|
141
|
+
dateBox(props.FromField),
|
|
142
|
+
dateBox(props.ToField))));
|
|
143
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export {};
|
|
1
|
+
import * as moment from 'moment';
|
|
2
|
+
interface IProps {
|
|
3
|
+
DateTime: moment.Moment | undefined;
|
|
4
|
+
Setter: (record: moment.Moment) => void;
|
|
5
|
+
}
|
|
6
|
+
export default function Calender(props: IProps): JSX.Element;
|
|
7
|
+
export {};
|