@gpa-gemstone/react-forms 1.1.59 → 1.1.61
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 -100
- 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 +4 -3
package/lib/Input.js
CHANGED
|
@@ -1,106 +1,111 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// Input.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
|
-
// 01/22/2020 - Billy Ernest
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
// 05/05/2021 - C. Lackner
|
|
23
|
-
// Added Help Message.
|
|
24
|
-
//
|
|
25
|
-
// ******************************************************************************************************
|
|
26
|
-
var __assign = (this && this.__assign) || function () {
|
|
27
|
-
__assign = Object.assign || function(t) {
|
|
28
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29
|
-
s = arguments[i];
|
|
30
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
31
|
-
t[p] = s[p];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
};
|
|
35
|
-
return __assign.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
React.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
internal.current
|
|
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
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// Input.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
|
+
// 01/22/2020 - Billy Ernest
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
// 05/05/2021 - C. Lackner
|
|
23
|
+
// Added Help Message.
|
|
24
|
+
//
|
|
25
|
+
// ******************************************************************************************************
|
|
26
|
+
var __assign = (this && this.__assign) || function () {
|
|
27
|
+
__assign = Object.assign || function(t) {
|
|
28
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29
|
+
s = arguments[i];
|
|
30
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
31
|
+
t[p] = s[p];
|
|
32
|
+
}
|
|
33
|
+
return t;
|
|
34
|
+
};
|
|
35
|
+
return __assign.apply(this, arguments);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.default = Input;
|
|
39
|
+
var React = require("react");
|
|
40
|
+
var HelperMessage_1 = require("./HelperMessage");
|
|
41
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
42
|
+
function Input(props) {
|
|
43
|
+
var internal = React.useRef(false);
|
|
44
|
+
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
45
|
+
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
46
|
+
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
47
|
+
// Effect to generate a unique ID for the component.
|
|
48
|
+
React.useEffect(function () {
|
|
49
|
+
setGuid((0, helper_functions_1.CreateGuid)());
|
|
50
|
+
}, []);
|
|
51
|
+
// Handle changes to the record's field value.
|
|
52
|
+
React.useEffect(function () {
|
|
53
|
+
if (!internal.current) {
|
|
54
|
+
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
55
|
+
}
|
|
56
|
+
internal.current = false;
|
|
57
|
+
}, [props.Record[props.Field]]);
|
|
58
|
+
// Handle blur event (loss of focus) on the input.
|
|
59
|
+
function onBlur() {
|
|
60
|
+
var _a;
|
|
61
|
+
var _b;
|
|
62
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
63
|
+
if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
|
|
64
|
+
internal.current = false;
|
|
65
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Handle value change of the input.
|
|
69
|
+
function valueChange(value) {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
internal.current = true;
|
|
72
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
73
|
+
if (props.Type === 'number') {
|
|
74
|
+
var v = (value.length > 0 && value[0] === '.' ? ("0" + value) : value);
|
|
75
|
+
if ((0, helper_functions_1.IsNumber)(v) || (v === '' && allowNull)) {
|
|
76
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
|
|
77
|
+
setHeldVal(v);
|
|
78
|
+
}
|
|
79
|
+
else if (v === '') {
|
|
80
|
+
setHeldVal(v);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (props.Type === 'integer') {
|
|
84
|
+
if ((0, helper_functions_1.IsInteger)(value) || (value === '' && allowNull)) {
|
|
85
|
+
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
|
|
86
|
+
setHeldVal(value);
|
|
87
|
+
}
|
|
88
|
+
else if (value === '') {
|
|
89
|
+
setHeldVal(value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
|
|
94
|
+
setHeldVal(value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Variables to control the rendering of label and help icon.
|
|
98
|
+
var showLabel = props.Label !== "";
|
|
99
|
+
var showHelpIcon = props.Help !== undefined;
|
|
100
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
101
|
+
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.Style },
|
|
102
|
+
showHelpIcon || showLabel ?
|
|
103
|
+
React.createElement("label", null,
|
|
104
|
+
showLabel ? label : '',
|
|
105
|
+
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,
|
|
106
|
+
showHelpIcon ?
|
|
107
|
+
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
108
|
+
: null,
|
|
109
|
+
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, step: 'any' }),
|
|
110
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
111
|
+
}
|
package/lib/InputWithButton.d.ts
CHANGED
|
@@ -1,23 +1,109 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
interface IProps<T> {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Record to be used in form
|
|
5
|
+
* @type {T}
|
|
6
|
+
*/
|
|
7
|
+
Record: T;
|
|
8
|
+
/**
|
|
9
|
+
* Field of the record to be edited
|
|
10
|
+
* @type {keyof T}
|
|
11
|
+
*/
|
|
12
|
+
Field: keyof T;
|
|
13
|
+
/**
|
|
14
|
+
* Setter function to update the Record
|
|
15
|
+
* @param record - Updated Record
|
|
16
|
+
*/
|
|
17
|
+
Setter: (record: T) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Function to determine the validity of a field
|
|
20
|
+
* @param field - Field of the record to check
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
Valid: (field: keyof T) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Label to display for the form, defaults to the Field prop
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @optional
|
|
28
|
+
*/
|
|
29
|
+
Label?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Feedback message to show when input is invalid
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @optional
|
|
34
|
+
*/
|
|
35
|
+
Feedback?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Flag to disable the input element
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
* @optional
|
|
40
|
+
*/
|
|
41
|
+
InputDisabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Type of the input field
|
|
44
|
+
* @type {'number' | 'text' | 'password' | 'email' | 'color' | 'integer'}
|
|
45
|
+
* @optional
|
|
46
|
+
*/
|
|
47
|
+
Type?: 'number' | 'text' | 'password' | 'email' | 'color' | 'integer';
|
|
48
|
+
/**
|
|
49
|
+
* Help message or element to display
|
|
50
|
+
* @type {string | JSX.Element}
|
|
51
|
+
* @optional
|
|
52
|
+
*/
|
|
53
|
+
Help?: string | JSX.Element;
|
|
54
|
+
/**
|
|
55
|
+
* CSS styles to apply to the input group
|
|
56
|
+
* @type {React.CSSProperties}
|
|
57
|
+
* @optional
|
|
58
|
+
*/
|
|
59
|
+
InputStyle?: React.CSSProperties;
|
|
60
|
+
/**
|
|
61
|
+
* Flag to allow null values
|
|
62
|
+
* @type {boolean}
|
|
63
|
+
* @optional
|
|
64
|
+
*/
|
|
65
|
+
AllowNull?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Size of the input field
|
|
68
|
+
* @type {'small' | 'large'}
|
|
69
|
+
* @optional
|
|
70
|
+
*/
|
|
71
|
+
Size?: 'small' | 'large';
|
|
72
|
+
/**
|
|
73
|
+
* Default value for the input field if it's null
|
|
74
|
+
* @type {number}
|
|
75
|
+
* @optional
|
|
76
|
+
*/
|
|
77
|
+
DefaultValue?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Function to handle button click event
|
|
80
|
+
* @param evt - React mouse event
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
OnBtnClick: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Label for the button
|
|
86
|
+
* @type {string}
|
|
87
|
+
*/
|
|
88
|
+
BtnLabel: string;
|
|
89
|
+
/**
|
|
90
|
+
* CSS class for the button
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @optional
|
|
93
|
+
*/
|
|
94
|
+
BtnClass?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Flag to disable the button
|
|
97
|
+
* @type {boolean}
|
|
98
|
+
* @optional
|
|
99
|
+
*/
|
|
100
|
+
BtnDisabled?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* CSS styles to apply to the button
|
|
103
|
+
* @type {React.CSSProperties}
|
|
104
|
+
* @optional
|
|
105
|
+
*/
|
|
106
|
+
BtnStyle?: React.CSSProperties;
|
|
107
|
+
}
|
|
108
|
+
declare function InputWithButton<T>(props: IProps<T>): JSX.Element;
|
|
109
|
+
export default InputWithButton;
|
package/lib/InputWithButton.js
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// InputWithButton.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright
|
|
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/02/2024 - Preston Crawford
|
|
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
|
-
var React = require("react");
|
|
37
|
-
var HelperMessage_1 = require("./HelperMessage");
|
|
38
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
-
function InputWithButton(props) {
|
|
40
|
-
var internal = React.useRef(false);
|
|
41
|
-
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
42
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
43
|
-
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
44
|
-
React.useEffect(function () {
|
|
45
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
46
|
-
}, []);
|
|
47
|
-
React.useEffect(function () {
|
|
48
|
-
if (!internal.current) {
|
|
49
|
-
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
50
|
-
}
|
|
51
|
-
internal.current = false;
|
|
52
|
-
}, [props.Record[props.Field]]);
|
|
53
|
-
function onBlur() {
|
|
54
|
-
var _a;
|
|
55
|
-
var _b;
|
|
56
|
-
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
57
|
-
if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
|
|
58
|
-
internal.current = false;
|
|
59
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function valueChange(value) {
|
|
63
|
-
var _a, _b, _c;
|
|
64
|
-
internal.current = true;
|
|
65
|
-
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
66
|
-
if (props.Type === 'number') {
|
|
67
|
-
var v = (value.length > 0 && value[0] === '.' ? ("0" + value) : value);
|
|
68
|
-
if ((0, helper_functions_1.IsNumber)(v) || (v === '' && allowNull)) {
|
|
69
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
|
|
70
|
-
setHeldVal(v);
|
|
71
|
-
}
|
|
72
|
-
else if (v === '') {
|
|
73
|
-
setHeldVal(v);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (props.Type === 'integer') {
|
|
77
|
-
if ((0, helper_functions_1.IsInteger)(value) || (value === '' && allowNull)) {
|
|
78
|
-
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
|
|
79
|
-
setHeldVal(value);
|
|
80
|
-
}
|
|
81
|
-
else if (value === '') {
|
|
82
|
-
setHeldVal(value);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
|
|
87
|
-
setHeldVal(value);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
var showLabel = props.Label !== "";
|
|
91
|
-
var showHelpIcon = props.Help !== undefined;
|
|
92
|
-
var label = props.Label === undefined ? props.Field : props.Label;
|
|
93
|
-
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.InputStyle },
|
|
94
|
-
showHelpIcon || showLabel ?
|
|
95
|
-
React.createElement("label", null,
|
|
96
|
-
showLabel ? label : '',
|
|
97
|
-
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,
|
|
98
|
-
showHelpIcon ?
|
|
99
|
-
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
100
|
-
: null,
|
|
101
|
-
React.createElement("div", { className: "input-group" },
|
|
102
|
-
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.InputDisabled == null ? false : props.InputDisabled, onBlur: onBlur, step: 'any' }),
|
|
103
|
-
React.createElement("div", { className: "input-group-prepend" },
|
|
104
|
-
React.createElement("button", { className: props.BtnClass != null ? props.BtnClass : "btn btn-outline-secondary", style: props.BtnStyle, disabled: props.BtnDisabled == null ? false : props.BtnDisabled, type: "button", onClick: function (evt) { return props.OnBtnClick(evt); } }, props.BtnLabel)),
|
|
105
|
-
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback))));
|
|
106
|
-
}
|
|
107
|
-
exports.default = InputWithButton;
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// InputWithButton.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2024, 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/02/2024 - Preston Crawford
|
|
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
|
+
var React = require("react");
|
|
37
|
+
var HelperMessage_1 = require("./HelperMessage");
|
|
38
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
+
function InputWithButton(props) {
|
|
40
|
+
var internal = React.useRef(false);
|
|
41
|
+
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
42
|
+
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
43
|
+
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
44
|
+
React.useEffect(function () {
|
|
45
|
+
setGuid((0, helper_functions_1.CreateGuid)());
|
|
46
|
+
}, []);
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
if (!internal.current) {
|
|
49
|
+
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
50
|
+
}
|
|
51
|
+
internal.current = false;
|
|
52
|
+
}, [props.Record[props.Field]]);
|
|
53
|
+
function onBlur() {
|
|
54
|
+
var _a;
|
|
55
|
+
var _b;
|
|
56
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
57
|
+
if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
|
|
58
|
+
internal.current = false;
|
|
59
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function valueChange(value) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
internal.current = true;
|
|
65
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
66
|
+
if (props.Type === 'number') {
|
|
67
|
+
var v = (value.length > 0 && value[0] === '.' ? ("0" + value) : value);
|
|
68
|
+
if ((0, helper_functions_1.IsNumber)(v) || (v === '' && allowNull)) {
|
|
69
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
|
|
70
|
+
setHeldVal(v);
|
|
71
|
+
}
|
|
72
|
+
else if (v === '') {
|
|
73
|
+
setHeldVal(v);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (props.Type === 'integer') {
|
|
77
|
+
if ((0, helper_functions_1.IsInteger)(value) || (value === '' && allowNull)) {
|
|
78
|
+
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
|
|
79
|
+
setHeldVal(value);
|
|
80
|
+
}
|
|
81
|
+
else if (value === '') {
|
|
82
|
+
setHeldVal(value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
|
|
87
|
+
setHeldVal(value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var showLabel = props.Label !== "";
|
|
91
|
+
var showHelpIcon = props.Help !== undefined;
|
|
92
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
93
|
+
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.InputStyle },
|
|
94
|
+
showHelpIcon || showLabel ?
|
|
95
|
+
React.createElement("label", null,
|
|
96
|
+
showLabel ? label : '',
|
|
97
|
+
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,
|
|
98
|
+
showHelpIcon ?
|
|
99
|
+
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
100
|
+
: null,
|
|
101
|
+
React.createElement("div", { className: "input-group" },
|
|
102
|
+
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.InputDisabled == null ? false : props.InputDisabled, onBlur: onBlur, step: 'any' }),
|
|
103
|
+
React.createElement("div", { className: "input-group-prepend" },
|
|
104
|
+
React.createElement("button", { className: props.BtnClass != null ? props.BtnClass : "btn btn-outline-secondary", style: props.BtnStyle, disabled: props.BtnDisabled == null ? false : props.BtnDisabled, type: "button", onClick: function (evt) { return props.OnBtnClick(evt); } }, props.BtnLabel)),
|
|
105
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback))));
|
|
106
|
+
}
|
|
107
|
+
exports.default = InputWithButton;
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
interface IProps {
|
|
2
|
+
/**
|
|
3
|
+
* Label to display for the form, defaults to the Field prop
|
|
4
|
+
* @type {string}
|
|
5
|
+
* @optional
|
|
6
|
+
*/
|
|
7
|
+
Label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Array of options for the multi-select checkboxe
|
|
10
|
+
* @type {{ Value: number | string; Text: string; Selected: boolean }[]}
|
|
11
|
+
*/
|
|
12
|
+
Options: {
|
|
13
|
+
Value: number | string;
|
|
14
|
+
Text: string;
|
|
15
|
+
Selected: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
/**
|
|
18
|
+
* Function to handle changes in the selection
|
|
19
|
+
* @param evt - The change event
|
|
20
|
+
* @param Options - The updated options array
|
|
21
|
+
* @returns {void}
|
|
22
|
+
*/
|
|
23
|
+
OnChange: (evt: any, Options: {
|
|
24
|
+
Value: number | string;
|
|
25
|
+
Text: string;
|
|
26
|
+
Selected: boolean;
|
|
27
|
+
}[]) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Help message or element to display
|
|
30
|
+
* @type {string | JSX.Element}
|
|
31
|
+
* @optional
|
|
32
|
+
*/
|
|
33
|
+
Help?: string | JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* Tooltip style for the items
|
|
36
|
+
* @type {'no-tip' | 'dark' | 'light'}
|
|
37
|
+
* @optional
|
|
38
|
+
*/
|
|
39
|
+
ItemTooltip?: 'no-tip' | 'dark' | 'light';
|
|
40
|
+
}
|
|
41
|
+
declare const MultiSelect: (props: IProps) => JSX.Element;
|
|
42
|
+
export default MultiSelect;
|