@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/DateTimeUI/Clock.js
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// Clock.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
|
-
// 05/15/2023 - C. Lackner
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
React.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
React.createElement("td", { style: { width:
|
|
86
|
-
React.createElement("td", { style: { width:
|
|
87
|
-
(
|
|
88
|
-
|
|
89
|
-
React.createElement("td", { style: { width:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
React.createElement("td", { style: { width:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
React.createElement("td", { style: { width:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
React.createElement("td", { style: { width:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
React.createElement("td", { style: { width:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
React.createElement("td", { style: { width:
|
|
118
|
-
React.createElement("td", { style: { width:
|
|
119
|
-
(
|
|
120
|
-
|
|
121
|
-
React.createElement("td", { style: { width:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
React.createElement("td", { style: { width:
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var TimeInput = function (props) {
|
|
128
|
-
var _a = React.useState(props.value.toString()), val = _a[0], setVal = _a[1];
|
|
129
|
-
var _b = React.useState(false), error = _b[0], setError = _b[1];
|
|
130
|
-
React.useEffect(function () {
|
|
131
|
-
if (props.value.length > 5) {
|
|
132
|
-
setVal("");
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
setVal(props.value.toString());
|
|
136
|
-
}, [props.value]);
|
|
137
|
-
React.useEffect(function () {
|
|
138
|
-
if (!(0, helper_functions_1.IsInteger)(val))
|
|
139
|
-
return;
|
|
140
|
-
var v = parseInt(val, 10);
|
|
141
|
-
if (v > props.max || v < 0) {
|
|
142
|
-
setError(true);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
setError(false);
|
|
146
|
-
props.setValue(val);
|
|
147
|
-
}, [val, error]);
|
|
148
|
-
return React.createElement("div", { className: "form-group form-group-sm", style: { width: 52 } },
|
|
149
|
-
React.createElement("input", { type: "text", className: !error ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
|
|
150
|
-
if ((0, helper_functions_1.IsInteger)(evt.target.value))
|
|
151
|
-
setVal(evt.target.value);
|
|
152
|
-
}, value: val }));
|
|
153
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// Clock.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
|
+
// 05/15/2023 - C. Lackner
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.default = Clock;
|
|
26
|
+
var React = require("react");
|
|
27
|
+
var moment = require("moment");
|
|
28
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
29
|
+
function Clock(props) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
31
|
+
var _j = React.useState((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.format("HH")) !== null && _b !== void 0 ? _b : '00'), hour = _j[0], setHour = _j[1];
|
|
32
|
+
var _k = React.useState((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.format("mm")) !== null && _d !== void 0 ? _d : '00'), minute = _k[0], setMinute = _k[1];
|
|
33
|
+
var _l = React.useState((_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.format("ss")) !== null && _f !== void 0 ? _f : '00'), second = _l[0], setSecond = _l[1];
|
|
34
|
+
var _m = React.useState((_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.format("SSS")) !== null && _h !== void 0 ? _h : '000'), millisecond = _m[0], setMilliSecond = _m[1];
|
|
35
|
+
var _o = React.useState('none'), hover = _o[0], setHover = _o[1];
|
|
36
|
+
React.useEffect(function () {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
38
|
+
setHour((_b = (_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.format("HH")) !== null && _b !== void 0 ? _b : '00');
|
|
39
|
+
setMinute((_d = (_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.format("mm")) !== null && _d !== void 0 ? _d : '00');
|
|
40
|
+
setSecond((_f = (_e = props.DateTime) === null || _e === void 0 ? void 0 : _e.format("ss")) !== null && _f !== void 0 ? _f : '00');
|
|
41
|
+
setMilliSecond((_h = (_g = props.DateTime) === null || _g === void 0 ? void 0 : _g.format("SSS")) !== null && _h !== void 0 ? _h : '000');
|
|
42
|
+
}, [props.DateTime]);
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
var h = parseInt(hour, 10);
|
|
46
|
+
var m = parseInt(minute, 10);
|
|
47
|
+
var s = parseInt(second, 10);
|
|
48
|
+
var ms = parseInt(millisecond, 10);
|
|
49
|
+
if (isNaN(h) || isNaN(m) || isNaN(s) || isNaN(ms))
|
|
50
|
+
return;
|
|
51
|
+
if (h !== ((_a = props.DateTime) === null || _a === void 0 ? void 0 : _a.hour()) || m !== ((_b = props.DateTime) === null || _b === void 0 ? void 0 : _b.minute()) || s !== ((_c = props.DateTime) === null || _c === void 0 ? void 0 : _c.second()) || ms !== ((_d = props.DateTime) === null || _d === void 0 ? void 0 : _d.millisecond())) {
|
|
52
|
+
var d = moment(props.DateTime);
|
|
53
|
+
if (!d.isValid())
|
|
54
|
+
d = moment.utc().startOf('d');
|
|
55
|
+
d.hour(h).minute(m).second(s).millisecond(ms);
|
|
56
|
+
props.Setter(d);
|
|
57
|
+
}
|
|
58
|
+
}, [hour, minute, second, millisecond]);
|
|
59
|
+
function increase(type) {
|
|
60
|
+
var d = moment(props.DateTime).add(1, type);
|
|
61
|
+
if (type === 'h')
|
|
62
|
+
setHour(d.format("HH"));
|
|
63
|
+
if (type === 'm')
|
|
64
|
+
setMinute(d.format("mm"));
|
|
65
|
+
if (type === 's')
|
|
66
|
+
setSecond(d.format("ss"));
|
|
67
|
+
if (type === 'ms')
|
|
68
|
+
setMilliSecond(d.format("SSS"));
|
|
69
|
+
}
|
|
70
|
+
function decrease(type) {
|
|
71
|
+
var d = moment(props.DateTime).subtract(1, type);
|
|
72
|
+
if (type === 'h')
|
|
73
|
+
setHour(d.format("HH"));
|
|
74
|
+
if (type === 'm')
|
|
75
|
+
setMinute(d.format("mm"));
|
|
76
|
+
if (type === 's')
|
|
77
|
+
setSecond(d.format("ss"));
|
|
78
|
+
if (type === 'ms')
|
|
79
|
+
setMilliSecond(d.format("SSS"));
|
|
80
|
+
}
|
|
81
|
+
return (React.createElement("div", { style: { background: '#f0f0f0', marginTop: 10, opacity: 1 } },
|
|
82
|
+
React.createElement("table", { style: { textAlign: 'center' } },
|
|
83
|
+
React.createElement("tbody", null,
|
|
84
|
+
React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
|
|
85
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'increase_h' ? '#d3d3d3' : undefined) }, onClick: function () { return increase('h'); }, onMouseEnter: function () { return setHover('increase_h'); }, onMouseLeave: function () { return setHover('none'); } }, " ^ "),
|
|
86
|
+
React.createElement("td", { style: { width: 20, padding: 5 } }),
|
|
87
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'increase_m' ? '#d3d3d3' : undefined) }, onClick: function () { return increase('m'); }, onMouseEnter: function () { return setHover('increase_m'); }, onMouseLeave: function () { return setHover('none'); } }, " ^ "),
|
|
88
|
+
(props.Accuracy === 'second' || props.Accuracy === 'millisecond') && (React.createElement(React.Fragment, null,
|
|
89
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }),
|
|
90
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'increase_s' ? '#d3d3d3' : undefined) }, onClick: function () { return increase('s'); }, onMouseEnter: function () { return setHover('increase_s'); }, onMouseLeave: function () { return setHover('none'); } }, " ^ "))),
|
|
91
|
+
props.Accuracy === 'millisecond' && (React.createElement(React.Fragment, null,
|
|
92
|
+
React.createElement("td", { style: { width: 20, padding: 5 } }),
|
|
93
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'increase_ms' ? '#d3d3d3' : undefined) }, onClick: function () { return increase('ms'); }, onMouseEnter: function () { return setHover('increase_ms'); }, onMouseLeave: function () { return setHover('none'); } }, " ^ ")))),
|
|
94
|
+
React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
|
|
95
|
+
React.createElement("td", { style: { width: 52, padding: 5, } },
|
|
96
|
+
" ",
|
|
97
|
+
React.createElement(TimeInput, { value: hour, setValue: setHour, max: 23 }),
|
|
98
|
+
" "),
|
|
99
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }, " : "),
|
|
100
|
+
React.createElement("td", { style: { width: 52, padding: 5, } },
|
|
101
|
+
" ",
|
|
102
|
+
React.createElement(TimeInput, { value: minute, setValue: setMinute, max: 59 }),
|
|
103
|
+
" "),
|
|
104
|
+
(props.Accuracy === 'second' || props.Accuracy === 'millisecond') && (React.createElement(React.Fragment, null,
|
|
105
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }, " : "),
|
|
106
|
+
React.createElement("td", { style: { width: 52, padding: 5, } },
|
|
107
|
+
" ",
|
|
108
|
+
React.createElement(TimeInput, { value: second, setValue: setSecond, max: 59 }),
|
|
109
|
+
" "))),
|
|
110
|
+
props.Accuracy === 'millisecond' && (React.createElement(React.Fragment, null,
|
|
111
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }, " : "),
|
|
112
|
+
React.createElement("td", { style: { width: 52, padding: 5, } },
|
|
113
|
+
" ",
|
|
114
|
+
React.createElement(TimeInput, { value: millisecond, setValue: setMilliSecond, max: 999 }),
|
|
115
|
+
" ")))),
|
|
116
|
+
React.createElement("tr", { style: { height: 20, lineHeight: '20px' } },
|
|
117
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'decrease_h' ? '#d3d3d3' : undefined) }, onClick: function () { return decrease('h'); }, onMouseEnter: function () { return setHover('decrease_h'); }, onMouseLeave: function () { return setHover('none'); } }, " v "),
|
|
118
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }),
|
|
119
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'decrease_m' ? '#d3d3d3' : undefined) }, onClick: function () { return decrease('m'); }, onMouseEnter: function () { return setHover('decrease_m'); }, onMouseLeave: function () { return setHover('none'); } }, " v "),
|
|
120
|
+
(props.Accuracy === 'second' || props.Accuracy === 'millisecond') && (React.createElement(React.Fragment, null,
|
|
121
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }),
|
|
122
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'decrease_s' ? '#d3d3d3' : undefined) }, onClick: function () { return decrease('s'); }, onMouseEnter: function () { return setHover('decrease_s'); }, onMouseLeave: function () { return setHover('none'); } }, " v "))),
|
|
123
|
+
props.Accuracy === 'millisecond' && (React.createElement(React.Fragment, null,
|
|
124
|
+
React.createElement("td", { style: { width: 20, padding: 5, } }),
|
|
125
|
+
React.createElement("td", { style: { width: 52, padding: 5, cursor: 'pointer', background: (hover === 'decrease_ms' ? '#d3d3d3' : undefined) }, onClick: function () { return decrease('ms'); }, onMouseEnter: function () { return setHover('decrease_ms'); }, onMouseLeave: function () { return setHover('none'); } }, " v "))))))));
|
|
126
|
+
}
|
|
127
|
+
var TimeInput = function (props) {
|
|
128
|
+
var _a = React.useState(props.value.toString()), val = _a[0], setVal = _a[1];
|
|
129
|
+
var _b = React.useState(false), error = _b[0], setError = _b[1];
|
|
130
|
+
React.useEffect(function () {
|
|
131
|
+
if (props.value.length > 5) {
|
|
132
|
+
setVal("");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
setVal(props.value.toString());
|
|
136
|
+
}, [props.value]);
|
|
137
|
+
React.useEffect(function () {
|
|
138
|
+
if (!(0, helper_functions_1.IsInteger)(val))
|
|
139
|
+
return;
|
|
140
|
+
var v = parseInt(val, 10);
|
|
141
|
+
if (v > props.max || v < 0) {
|
|
142
|
+
setError(true);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setError(false);
|
|
146
|
+
props.setValue(val);
|
|
147
|
+
}, [val, error]);
|
|
148
|
+
return React.createElement("div", { className: "form-group form-group-sm", style: { width: 52 } },
|
|
149
|
+
React.createElement("input", { type: "text", className: !error ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
|
|
150
|
+
if ((0, helper_functions_1.IsInteger)(evt.target.value))
|
|
151
|
+
setVal(evt.target.value);
|
|
152
|
+
}, value: val }));
|
|
153
|
+
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export {};
|
|
1
|
+
import * as moment from 'moment';
|
|
2
|
+
import { TimeUnit } from '../DatePicker';
|
|
3
|
+
import { Accuracy } from './Clock';
|
|
4
|
+
interface IProps {
|
|
5
|
+
DateTime: moment.Moment | undefined;
|
|
6
|
+
Setter: (record: moment.Moment) => void;
|
|
7
|
+
Valid: boolean;
|
|
8
|
+
Feedback?: string;
|
|
9
|
+
Type: TimeUnit;
|
|
10
|
+
Show: boolean;
|
|
11
|
+
Top: number;
|
|
12
|
+
Center: number;
|
|
13
|
+
Accuracy?: Accuracy;
|
|
14
|
+
}
|
|
15
|
+
export default function DateTimePopup(props: IProps): JSX.Element | null;
|
|
16
|
+
export {};
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// DateTimePopup.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2023, 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
|
-
// 05/15/2023 - C. Lackner
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
25
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
26
|
-
return cooked;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
React.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
var templateObject_1;
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// DateTimePopup.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2023, 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
|
+
// 05/15/2023 - C. Lackner
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
25
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
26
|
+
return cooked;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.default = DateTimePopup;
|
|
30
|
+
var React = require("react");
|
|
31
|
+
var react_portal_1 = require("react-portal");
|
|
32
|
+
var styled_components_1 = require("styled-components");
|
|
33
|
+
var Calender_1 = require("./Calender");
|
|
34
|
+
var Clock_1 = require("./Clock");
|
|
35
|
+
var WrapperDiv = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n padding: 8px 21px;\n position: fixed;\n transition: opacity 0.3s ease-out;\n z-index: 9999;\n opacity: 0.9;\n background: #222;\n top: ", ";\n left: ", ";\n border: 1px solid transparent;\n }\n &::before {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 8px solid #222;\n left: ", ";\n top: -6px;\n margin-left: -8px;\n content: \"\";\n width: 0px;\n height: 0px;\n position: absolute\n }"], ["\n & {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n padding: 8px 21px;\n position: fixed;\n transition: opacity 0.3s ease-out;\n z-index: 9999;\n opacity: 0.9;\n background: #222;\n top: ", ";\n left: ", ";\n border: 1px solid transparent;\n }\n &::before {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 8px solid #222;\n left: ", ";\n top: -6px;\n margin-left: -8px;\n content: \"\";\n width: 0px;\n height: 0px;\n position: absolute\n }"])), function (props) { return "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); }, function (props) { return "".concat(props.Indicator, "%"); });
|
|
36
|
+
function DateTimePopup(props) {
|
|
37
|
+
var divRef = React.useRef(null);
|
|
38
|
+
var _a = React.useState(props.Type !== 'date'), showTime = _a[0], setShowTime = _a[1];
|
|
39
|
+
var _b = React.useState(props.Type !== 'time'), showDate = _b[0], setShowDate = _b[1];
|
|
40
|
+
var _c = React.useState(0), width = _c[0], setWidth = _c[1];
|
|
41
|
+
var _d = React.useState(0), height = _d[0], setHeight = _d[1];
|
|
42
|
+
React.useLayoutEffect(function () {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
setWidth((_b = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) !== null && _b !== void 0 ? _b : width);
|
|
45
|
+
setHeight((_d = (_c = divRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : height);
|
|
46
|
+
});
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
setShowTime(props.Type !== 'date');
|
|
49
|
+
setShowDate(props.Type !== 'time');
|
|
50
|
+
}, [props.Type]);
|
|
51
|
+
if (!props.Show)
|
|
52
|
+
return null;
|
|
53
|
+
var l = Math.max(props.Center - 0.5 * width, 0);
|
|
54
|
+
return (React.createElement(react_portal_1.Portal, null,
|
|
55
|
+
React.createElement(WrapperDiv, { Top: props.Top, Left: l, Indicator: 50, ref: divRef, className: 'gpa-gemstone-datetime' },
|
|
56
|
+
showDate ? React.createElement(Calender_1.default, { DateTime: props.DateTime, Setter: props.Setter }) : null,
|
|
57
|
+
showTime ? React.createElement(Clock_1.default, { DateTime: props.DateTime, Setter: props.Setter, Accuracy: props.Accuracy }) : null)));
|
|
58
|
+
}
|
|
59
|
+
var templateObject_1;
|
package/lib/DoubleInput.d.ts
CHANGED
|
@@ -1,12 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Record
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
interface IProps<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Record to be used in form
|
|
4
|
+
* @type {T}
|
|
5
|
+
*/
|
|
6
|
+
Record: T;
|
|
7
|
+
/**
|
|
8
|
+
* First field of the record to be edited
|
|
9
|
+
* @type {keyof T}
|
|
10
|
+
*/
|
|
11
|
+
Field1: keyof T;
|
|
12
|
+
/**
|
|
13
|
+
* Second field of the record to be edited
|
|
14
|
+
* @type {keyof T}
|
|
15
|
+
*/
|
|
16
|
+
Field2: keyof T;
|
|
17
|
+
/**
|
|
18
|
+
* Setter function to update the Record
|
|
19
|
+
* @param record - Updated Record
|
|
20
|
+
*/
|
|
21
|
+
Setter: (record: T) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Function to determine the validity of a field
|
|
24
|
+
* @param field - Field of the record to check
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
Valid: (field: keyof T) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Label to display for the form, defaults to the Field prop
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @optional
|
|
32
|
+
*/
|
|
33
|
+
Label?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Feedback message to show when input is invalid
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @optional
|
|
38
|
+
*/
|
|
39
|
+
Feedback?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Flag to disable the input field
|
|
42
|
+
* @type {boolean}
|
|
43
|
+
* @optional
|
|
44
|
+
*/
|
|
45
|
+
Disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Type of the input fields
|
|
48
|
+
* @type {'number' | 'text' | 'password' | 'email' | 'color'}
|
|
49
|
+
* @optional
|
|
50
|
+
*/
|
|
51
|
+
Type?: 'number' | 'text' | 'password' | 'email' | 'color';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* DoubleInput Component.
|
|
55
|
+
* A component that renders two input fields, allowing input for two related fields in a single record.
|
|
56
|
+
*/
|
|
57
|
+
export default function DoubleInput<T>(props: IProps<T>): JSX.Element;
|
|
58
|
+
export {};
|