@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/DoubleInput.js
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// DoubleInput.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/07/2021 - C. Lackner
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// DoubleInput.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/07/2021 - C. Lackner
|
|
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 = DoubleInput;
|
|
37
|
+
var React = require("react");
|
|
38
|
+
/**
|
|
39
|
+
* DoubleInput Component.
|
|
40
|
+
* A component that renders two input fields, allowing input for two related fields in a single record.
|
|
41
|
+
*/
|
|
42
|
+
function DoubleInput(props) {
|
|
43
|
+
return (React.createElement("div", { className: "form-group" },
|
|
44
|
+
React.createElement("label", null, props.Label == null ? (props.Field1 + ' ' + props.Field2) : props.Label),
|
|
45
|
+
React.createElement("div", { className: "input-group" },
|
|
46
|
+
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field1) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
|
|
47
|
+
var _a;
|
|
48
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field1] = evt.target.value !== '' ? evt.target.value : null, _a)));
|
|
49
|
+
}, value: props.Record[props.Field1] == null ? '' : props.Record[props.Field1].toString(), disabled: props.Disabled == null ? false : props.Disabled }),
|
|
50
|
+
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field2) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
|
|
51
|
+
var _a;
|
|
52
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field2] = evt.target.value !== '' ? evt.target.value : null, _a)));
|
|
53
|
+
}, value: props.Record[props.Field2] == null ? '' : props.Record[props.Field2].toString(), disabled: props.Disabled == null ? false : props.Disabled })),
|
|
54
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? (props.Field1 + ' ' + props.Field2 + ' is a required field.') : props.Feedback)));
|
|
55
|
+
}
|
package/lib/EnumCheckBoxes.d.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
interface IProps<T> {
|
|
2
|
+
/**
|
|
3
|
+
* Record to be used in form
|
|
4
|
+
* @type {T}
|
|
5
|
+
*/
|
|
6
|
+
Record: T;
|
|
7
|
+
/**
|
|
8
|
+
* Field of the record to be edited
|
|
9
|
+
* @type {keyof T}
|
|
10
|
+
*/
|
|
11
|
+
Field: keyof T;
|
|
12
|
+
/**
|
|
13
|
+
* Setter function to update the Record
|
|
14
|
+
* @param record - Updated Record
|
|
15
|
+
*/
|
|
16
|
+
Setter: (record: T) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Array of enumerable values to create checkboxes for
|
|
19
|
+
* @type {string[]}
|
|
20
|
+
*/
|
|
21
|
+
Enum: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Label to display for the form, defaults to the Field prop
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @optional
|
|
26
|
+
*/
|
|
27
|
+
Label?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Function to determine if a checkbox should be disabled
|
|
30
|
+
* @param item - The enumeration value
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
* @optional
|
|
33
|
+
*/
|
|
34
|
+
IsDisabled?: (item: string) => boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* EnumCheckBoxes Component.
|
|
38
|
+
* Renders a set of checkboxes based on an enumeration, allowing multiple selection.
|
|
39
|
+
*/
|
|
40
|
+
export default function EnumCheckBoxes<T>(props: IProps<T>): JSX.Element;
|
|
41
|
+
export {};
|
package/lib/EnumCheckBoxes.js
CHANGED
|
@@ -1,58 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// EnumCheckBoxes.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
|
-
//
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// EnumCheckBoxes.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
|
+
//
|
|
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 = EnumCheckBoxes;
|
|
37
|
+
var React = require("react");
|
|
38
|
+
/**
|
|
39
|
+
* EnumCheckBoxes Component.
|
|
40
|
+
* Renders a set of checkboxes based on an enumeration, allowing multiple selection.
|
|
41
|
+
*/
|
|
42
|
+
function EnumCheckBoxes(props) {
|
|
43
|
+
// Determine if an enum flag is set.
|
|
44
|
+
/* tslint:disable-next-line:no-bitwise */
|
|
45
|
+
var EquateFlag = function (index) { return ((props.Record[props.Field] / Math.pow(2, index)) & 1) !== 0; };
|
|
46
|
+
// Turn off a flag in the enumeration.
|
|
47
|
+
var DecrementFlag = function (index) { return props.Record[props.Field] - Math.pow(2, index); };
|
|
48
|
+
// Turn on a flag in the enumeration.
|
|
49
|
+
var IncrementFlag = function (index) { return props.Record[props.Field] + Math.pow(2, index); };
|
|
50
|
+
return (React.createElement("div", { className: "form-group" },
|
|
51
|
+
React.createElement("label", null, props.Label == null ? props.Field : props.Label),
|
|
52
|
+
React.createElement("br", null),
|
|
53
|
+
React.createElement("div", { className: "form-check form-check-inline" },
|
|
54
|
+
React.createElement("input", { className: "form-check-input", type: "checkbox", checked: props.Record[props.Field] === (Math.pow(2, props.Enum.length) - 1), onChange: function (evt) {
|
|
55
|
+
var _a;
|
|
56
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? Math.pow(2, props.Enum.length) - 1 : 0, _a)));
|
|
57
|
+
} }),
|
|
58
|
+
React.createElement("label", { className: "form-check-label" }, "All")),
|
|
59
|
+
props.Enum.map(function (flag, i) { return (React.createElement("div", { key: i, className: "form-check form-check-inline" },
|
|
60
|
+
React.createElement("input", { className: "form-check-input", type: "checkbox", checked: EquateFlag(i), disabled: props.IsDisabled !== undefined ? props.IsDisabled(flag) : false, onChange: function (evt) {
|
|
61
|
+
var _a;
|
|
62
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? IncrementFlag(i) : DecrementFlag(i), _a)));
|
|
63
|
+
} }),
|
|
64
|
+
React.createElement("label", { className: "form-check-label" }, flag))); })));
|
|
65
|
+
}
|
package/lib/HelperMessage.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
interface IProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
/**
|
|
4
|
+
* Flag to show the helper message
|
|
5
|
+
* @type {boolean}
|
|
6
|
+
*/
|
|
7
|
+
Show: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Value of the target element's data-help attribute
|
|
10
|
+
* @type {string}
|
|
11
|
+
* @optional
|
|
12
|
+
*/
|
|
13
|
+
Target?: string;
|
|
14
|
+
/**
|
|
15
|
+
* z-index for the helper message
|
|
16
|
+
* @type {number}
|
|
17
|
+
*/
|
|
18
|
+
Zindex?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Text color for the helper message
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @optional
|
|
23
|
+
*/
|
|
24
|
+
Color?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Background color for the helper message
|
|
27
|
+
* @type {string}
|
|
28
|
+
* @optional
|
|
29
|
+
*/
|
|
30
|
+
Background?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* HelperMessage Component.
|
|
34
|
+
* Displays a floating message box.
|
|
35
|
+
*/
|
|
36
|
+
declare const HelperMessage: React.FunctionComponent<IProps>;
|
|
37
|
+
export default HelperMessage;
|
package/lib/HelperMessage.js
CHANGED
|
@@ -1,83 +1,93 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// HelperMessage.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2021, 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/05/2021 - 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
|
-
var React = require("react");
|
|
30
|
-
var styled_components_1 = require("styled-components");
|
|
31
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
32
|
-
var react_portal_1 = require("react-portal");
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// HelperMessage.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2021, 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/05/2021 - 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
|
+
var React = require("react");
|
|
30
|
+
var styled_components_1 = require("styled-components");
|
|
31
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
32
|
+
var react_portal_1 = require("react-portal");
|
|
33
|
+
var lodash_1 = require("lodash");
|
|
34
|
+
// Styled component for the wrapper of the helper message.
|
|
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 pointer-events: none;\n transition: opacity 0.3s ease-out;\n z-index: ", ";\n opacity: ", ";\n color: ", ";;\n background: ", ";\n top: ", ";\n left: ", ";\n width: ", ";\n border: 1px solid transparent;\n }\n ", ""], ["\n & {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n padding: 8px 21px;\n position: fixed;\n pointer-events: none;\n transition: opacity 0.3s ease-out;\n z-index: ", ";\n opacity: ", ";\n color: ", ";;\n background: ", ";\n top: ", ";\n left: ", ";\n width: ", ";\n border: 1px solid transparent;\n }\n ", ""
|
|
36
|
+
/**
|
|
37
|
+
* HelperMessage Component.
|
|
38
|
+
* Displays a floating message box.
|
|
39
|
+
*/
|
|
40
|
+
])), function (props) { return props.Zindex; }, function (props) { return props.Show ? "1.0" : "0"; }, function (props) { var _a; return (_a = props.Color) !== null && _a !== void 0 ? _a : '#000'; }, function (props) { var _a; return (_a = props.Background) !== null && _a !== void 0 ? _a : '#0DCAF0'; }, function (props) { return "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); }, function (props) { return "".concat(props.Width, "px"); }, function (props) {
|
|
41
|
+
var _a;
|
|
42
|
+
return "\n &::before {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 8px solid ".concat((_a = props.Background) !== null && _a !== void 0 ? _a : '#0DCAF0', ";\n left: ").concat(props.TargetLeft - props.Left + props.TargetWidth / 2, "px;\n top: -6px;\n margin-left: -8px;\n content: \"\";\n width: 0px;\n height: 0px;\n position: absolute\n }\n ");
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* HelperMessage Component.
|
|
46
|
+
* Displays a floating message box.
|
|
47
|
+
*/
|
|
48
|
+
var HelperMessage = function (props) {
|
|
49
|
+
var helpMessage = React.useRef(null);
|
|
50
|
+
// State variables for positioning and sizing the helper message.
|
|
51
|
+
var _a = React.useState(0), top = _a[0], setTop = _a[1];
|
|
52
|
+
var _b = React.useState(0), left = _b[0], setLeft = _b[1];
|
|
53
|
+
// State variables for the target element's position and size.
|
|
54
|
+
var _c = React.useState({ Top: -999, Left: -999, Width: 0, Height: 0 }), targetPosition = _c[0], setTargetPosition = _c[1];
|
|
55
|
+
// Effect for updating the target element's position and size.
|
|
56
|
+
React.useEffect(function () {
|
|
57
|
+
var target = document.querySelectorAll("[data-help".concat(props.Target === undefined ? '' : "=\"".concat(props.Target, "\""), "]"));
|
|
58
|
+
if (target.length === 0) {
|
|
59
|
+
setTargetPosition({ Height: 0, Top: -999, Left: -999, Width: 0 });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var targetLocation = (0, helper_functions_1.GetNodeSize)(target[0]);
|
|
63
|
+
var newPosition = { Height: targetLocation.height, Top: targetLocation.top, Left: targetLocation.left, Width: targetLocation.width };
|
|
64
|
+
if (!(0, lodash_1.isEqual)(newPosition, targetPosition))
|
|
65
|
+
setTargetPosition(newPosition);
|
|
66
|
+
}, [props.Show]);
|
|
67
|
+
React.useLayoutEffect(function () {
|
|
68
|
+
var _a = UpdatePosition(helpMessage, targetPosition), t = _a[0], l = _a[1];
|
|
69
|
+
setTop(t);
|
|
70
|
+
setLeft(l);
|
|
71
|
+
}, [targetPosition]);
|
|
72
|
+
var zIndex = (props.Zindex === undefined ? 9999 : props.Zindex);
|
|
73
|
+
return (React.createElement(react_portal_1.Portal, null,
|
|
74
|
+
React.createElement(WrapperDiv, { Show: props.Show, Top: top, Left: left, ref: helpMessage, Zindex: zIndex, Color: props.Color, Background: props.Background, TargetLeft: targetPosition.Left, TargetWidth: targetPosition.Width, Width: targetPosition.Width }, props.children)));
|
|
75
|
+
};
|
|
76
|
+
var UpdatePosition = function (helpMessage, targetPosition) {
|
|
77
|
+
if (helpMessage.current === null)
|
|
78
|
+
return [-999, -999];
|
|
79
|
+
var offset = 5;
|
|
80
|
+
var windowWidth = window.innerWidth;
|
|
81
|
+
var top = targetPosition.Top + targetPosition.Height + offset;
|
|
82
|
+
var left = targetPosition.Left;
|
|
83
|
+
var width = targetPosition.Width;
|
|
84
|
+
// If tooltip goes beyond the right viewport boundary, adjust the left position to fit
|
|
85
|
+
if (left + width >= windowWidth)
|
|
86
|
+
left = windowWidth - width - offset;
|
|
87
|
+
// If tooltip goes beyond the left viewport boundary, adjust the left position to fit
|
|
88
|
+
if (left <= 0)
|
|
89
|
+
left = offset;
|
|
90
|
+
return [top, left, width];
|
|
91
|
+
};
|
|
92
|
+
exports.default = HelperMessage;
|
|
93
|
+
var templateObject_1;
|
package/lib/Input.d.ts
CHANGED
|
@@ -1,18 +1,80 @@
|
|
|
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
|
-
|
|
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 field
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
* @optional
|
|
40
|
+
*/
|
|
41
|
+
Disabled?: 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 form group
|
|
56
|
+
* @type {React.CSSProperties}
|
|
57
|
+
* @optional
|
|
58
|
+
*/
|
|
59
|
+
Style?: 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
|
+
export default function Input<T>(props: IProps<T>): JSX.Element;
|
|
80
|
+
export {};
|