@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.
Files changed (47) hide show
  1. package/lib/ArrayCheckBoxes.d.ts +33 -11
  2. package/lib/ArrayCheckBoxes.js +81 -79
  3. package/lib/ArrayMultiSelect.d.ts +47 -13
  4. package/lib/ArrayMultiSelect.js +49 -47
  5. package/lib/CheckBox.d.ts +37 -11
  6. package/lib/CheckBox.js +62 -60
  7. package/lib/ColorPicker.d.ts +59 -15
  8. package/lib/ColorPicker.js +114 -114
  9. package/lib/DatePicker.d.ts +23 -21
  10. package/lib/DatePicker.js +221 -214
  11. package/lib/DateRangePicker.d.ts +64 -13
  12. package/lib/DateRangePicker.js +143 -132
  13. package/lib/DateTimeUI/Calender.d.ts +7 -8
  14. package/lib/DateTimeUI/Calender.js +180 -180
  15. package/lib/DateTimeUI/Clock.d.ts +9 -10
  16. package/lib/DateTimeUI/Clock.js +153 -153
  17. package/lib/DateTimeUI/DateTimePopup.d.ts +16 -17
  18. package/lib/DateTimeUI/DateTimePopup.js +59 -59
  19. package/lib/DoubleInput.d.ts +58 -12
  20. package/lib/DoubleInput.js +55 -51
  21. package/lib/EnumCheckBoxes.d.ts +41 -9
  22. package/lib/EnumCheckBoxes.js +65 -58
  23. package/lib/HelperMessage.d.ts +37 -10
  24. package/lib/HelperMessage.js +93 -83
  25. package/lib/Input.d.ts +80 -18
  26. package/lib/Input.js +111 -106
  27. package/lib/InputWithButton.d.ts +109 -23
  28. package/lib/InputWithButton.js +107 -107
  29. package/lib/MutliCheckBoxSelect.d.ts +42 -18
  30. package/lib/MutliCheckBoxSelect.js +110 -104
  31. package/lib/RadioButtons.d.ts +15 -0
  32. package/lib/RadioButtons.js +62 -0
  33. package/lib/SearchableSelect.d.ts +60 -18
  34. package/lib/SearchableSelect.js +84 -85
  35. package/lib/Select.d.ts +57 -17
  36. package/lib/Select.js +84 -80
  37. package/lib/StylableSelect.d.ts +53 -17
  38. package/lib/StylableSelect.js +106 -100
  39. package/lib/TextArea.d.ts +54 -14
  40. package/lib/TextArea.js +76 -72
  41. package/lib/TimePicker.d.ts +50 -11
  42. package/lib/TimePicker.js +60 -51
  43. package/lib/ToggleSwitch.d.ts +44 -12
  44. package/lib/ToggleSwitch.js +57 -61
  45. package/lib/index.d.ts +19 -18
  46. package/lib/index.js +61 -59
  47. package/package.json +4 -3
package/lib/TextArea.js CHANGED
@@ -1,72 +1,76 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- // ******************************************************************************************************
15
- // TextArea.tsx - Gbtc
16
- //
17
- // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
18
- //
19
- // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
20
- // the NOTICE file distributed with this work for additional information regarding copyright ownership.
21
- // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
22
- // file except in compliance with the License. You may obtain a copy of the License at:
23
- //
24
- // http://opensource.org/licenses/MIT
25
- //
26
- // Unless agreed to in writing, the subject software distributed under the License is distributed on an
27
- // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
28
- // License for the specific language governing permissions and limitations.
29
- //
30
- // Code Modification History:
31
- // ----------------------------------------------------------------------------------------------------
32
- // 01/22/2020 - Billy Ernest
33
- // Generated original version of source code.
34
- // 11/03/2023 - C Lackner
35
- // Added internal state to avoid cursor jumping.
36
- //
37
- // ******************************************************************************************************
38
- var React = require("react");
39
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
40
- var HelperMessage_1 = require("./HelperMessage");
41
- function TextArea(props) {
42
- var internal = React.useRef(false);
43
- var guid = React.useRef((0, helper_functions_1.CreateGuid)());
44
- var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
45
- var _b = React.useState(''), heldVal = _b[0], setHeldVal = _b[1];
46
- React.useEffect(function () {
47
- if (!internal.current) {
48
- setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
49
- }
50
- internal.current = false;
51
- }, [props.Record[props.Field]]);
52
- function valueChange(value) {
53
- var _a;
54
- internal.current = true;
55
- props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = value !== '' ? value : null, _a)));
56
- setHeldVal(value);
57
- }
58
- var showLabel = props.Label !== "";
59
- var showHelpIcon = props.Help !== undefined;
60
- var label = props.Label === undefined ? props.Field : props.Label;
61
- return (React.createElement("div", { className: "form-group", "data-help": guid.current },
62
- showHelpIcon || showLabel ?
63
- React.createElement("label", null,
64
- showLabel ? label : '',
65
- 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,
66
- showHelpIcon ?
67
- React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid.current }, props.Help)
68
- : null,
69
- React.createElement("textarea", { rows: props.Rows, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal == null ? '' : heldVal, disabled: props.Disabled == null ? false : props.Disabled }),
70
- React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
71
- }
72
- exports.default = TextArea;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.default = TextArea;
15
+ // ******************************************************************************************************
16
+ // TextArea.tsx - Gbtc
17
+ //
18
+ // Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
19
+ //
20
+ // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
21
+ // the NOTICE file distributed with this work for additional information regarding copyright ownership.
22
+ // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
23
+ // file except in compliance with the License. You may obtain a copy of the License at:
24
+ //
25
+ // http://opensource.org/licenses/MIT
26
+ //
27
+ // Unless agreed to in writing, the subject software distributed under the License is distributed on an
28
+ // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
29
+ // License for the specific language governing permissions and limitations.
30
+ //
31
+ // Code Modification History:
32
+ // ----------------------------------------------------------------------------------------------------
33
+ // 01/22/2020 - Billy Ernest
34
+ // Generated original version of source code.
35
+ // 11/03/2023 - C Lackner
36
+ // Added internal state to avoid cursor jumping.
37
+ //
38
+ // ******************************************************************************************************
39
+ var React = require("react");
40
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
41
+ var HelperMessage_1 = require("./HelperMessage");
42
+ function TextArea(props) {
43
+ // Internal ref and state hooks for managing the component state.
44
+ var internal = React.useRef(false);
45
+ var guid = React.useRef((0, helper_functions_1.CreateGuid)());
46
+ var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
47
+ var _b = React.useState(''), heldVal = _b[0], setHeldVal = _b[1];
48
+ // Effect to handle changes to the record's field value.
49
+ React.useEffect(function () {
50
+ if (!internal.current) {
51
+ setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
52
+ }
53
+ internal.current = false;
54
+ }, [props.Record[props.Field]]);
55
+ // Handle value change of the textarea.
56
+ function valueChange(value) {
57
+ var _a;
58
+ internal.current = true;
59
+ props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = value !== '' ? value : null, _a)));
60
+ setHeldVal(value);
61
+ }
62
+ // Variables to control the rendering of label and help icon.
63
+ var showLabel = props.Label !== "";
64
+ var showHelpIcon = props.Help !== undefined;
65
+ var label = props.Label === undefined ? props.Field : props.Label;
66
+ return (React.createElement("div", { className: "form-group", "data-help": guid.current },
67
+ showHelpIcon || showLabel ?
68
+ React.createElement("label", null,
69
+ showLabel ? label : '',
70
+ 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,
71
+ showHelpIcon ?
72
+ React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid.current }, props.Help)
73
+ : null,
74
+ React.createElement("textarea", { rows: props.Rows, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal == null ? '' : heldVal, disabled: props.Disabled == null ? false : props.Disabled }),
75
+ React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
76
+ }
@@ -1,11 +1,50 @@
1
- /// <reference types="react" />
2
- export default function DatePicker<T>(props: {
3
- Record: T;
4
- Field: keyof T;
5
- Setter: (record: T) => void;
6
- Valid: (field: keyof T) => boolean;
7
- Label?: string;
8
- Disabled?: boolean;
9
- Feedback?: string;
10
- Step?: number;
11
- }): JSX.Element;
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
+ * Function to determine the validity of a field
19
+ * @param field - Field of the record to check
20
+ * @returns {boolean}
21
+ */
22
+ Valid: (field: keyof T) => boolean;
23
+ /**
24
+ * Label to display for the form, defaults to the Field prop
25
+ * @type {string}
26
+ * @optional
27
+ */
28
+ Label?: string;
29
+ /**
30
+ * Flag to disable the input field
31
+ * @type {boolean}
32
+ * @optional
33
+ */
34
+ Disabled?: boolean;
35
+ /**
36
+ * Feedback message to show when input is invalid
37
+ * @type {string}
38
+ * @optional
39
+ */
40
+ Feedback?: string;
41
+ /**
42
+ * Defines the number of intervals for time value
43
+ * @type {number}
44
+ * @optional
45
+ */
46
+ Step?: number;
47
+ Help?: string | JSX.Element;
48
+ }
49
+ export default function DatePicker<T>(props: IProps<T>): JSX.Element;
50
+ export {};
package/lib/TimePicker.js CHANGED
@@ -1,51 +1,60 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // TimePicker.tsx - Gbtc
4
- //
5
- // Copyright © 2022, 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
- // 03/21/2022 - 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
- var React = require("react");
37
- function DatePicker(props) {
38
- return (React.createElement("div", { className: "form-group" },
39
- (props.Label !== "") ?
40
- React.createElement("label", null, props.Label == null ? props.Field : props.Label) : null,
41
- React.createElement("input", { className: 'form-control' + (props.Valid(props.Field) ? '' : ' is-invalid'), type: "time", step: props.Step === null ? 60 : props.Step, onChange: function (evt) {
42
- var record = __assign({}, props.Record);
43
- if (evt.target.value !== '')
44
- record[props.Field] = evt.target.value;
45
- else
46
- record[props.Field] = null;
47
- props.Setter(record);
48
- }, value: props.Record[props.Field] == null ? '' : props.Record[props.Field].toString(), disabled: props.Disabled == null ? false : props.Disabled }),
49
- React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
50
- }
51
- exports.default = DatePicker;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // TimePicker.tsx - Gbtc
4
+ //
5
+ // Copyright © 2022, 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
+ // 03/21/2022 - 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 = DatePicker;
37
+ var React = require("react");
38
+ var HelperMessage_1 = require("./HelperMessage");
39
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
40
+ function DatePicker(props) {
41
+ var _a;
42
+ var guid = React.useRef((0, helper_functions_1.CreateGuid)());
43
+ var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
44
+ return (React.createElement("div", { className: "form-group" },
45
+ (props.Help != null || props.Label !== "") ?
46
+ React.createElement("label", null, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field,
47
+ props.Help != null ?
48
+ 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); } }, " ? ") : React.createElement(React.Fragment, null))
49
+ : React.createElement(React.Fragment, null),
50
+ React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid.current }, props.Help),
51
+ React.createElement("input", { className: 'form-control' + (props.Valid(props.Field) ? '' : ' is-invalid'), type: "time", step: props.Step === null ? 60 : props.Step, onChange: function (evt) {
52
+ var record = __assign({}, props.Record);
53
+ if (evt.target.value !== '')
54
+ record[props.Field] = evt.target.value;
55
+ else
56
+ record[props.Field] = null;
57
+ props.Setter(record);
58
+ }, value: props.Record[props.Field] == null ? '' : props.Record[props.Field].toString(), disabled: props.Disabled == null ? false : props.Disabled }),
59
+ React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
60
+ }
@@ -1,12 +1,44 @@
1
- import * as React from 'react';
2
- interface IProps<T> {
3
- Record: T;
4
- Field: keyof T;
5
- Setter: (record: T) => void;
6
- Label?: string;
7
- Disabled?: boolean;
8
- Help?: string | JSX.Element;
9
- Style?: React.CSSProperties;
10
- }
11
- export default function ToggleSwitch<T>(props: IProps<T>): JSX.Element;
12
- export {};
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
+ * Label to display for the form, defaults to the Field prop
20
+ * @type {string}
21
+ * @optional
22
+ */
23
+ Label?: string;
24
+ /**
25
+ * Flag to disable the input field
26
+ * @type {boolean}
27
+ * @optional
28
+ */
29
+ Disabled?: boolean;
30
+ /**
31
+ * Help message or element to display
32
+ * @type {string | JSX.Element}
33
+ * @optional
34
+ */
35
+ Help?: string | JSX.Element;
36
+ /**
37
+ * CSS styles to apply to the form group
38
+ * @type {React.CSSProperties}
39
+ * @optional
40
+ */
41
+ Style?: React.CSSProperties;
42
+ }
43
+ export default function ToggleSwitch<T>(props: IProps<T>): JSX.Element;
44
+ export {};
@@ -1,61 +1,57 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // ToggleSwitch.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
- // 04/19/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 helper_functions_1 = require("@gpa-gemstone/helper-functions");
38
- var HelperMessage_1 = require("./HelperMessage");
39
- function ToggleSwitch(props) {
40
- var _a = React.useState(""), helpID = _a[0], setHelpID = _a[1];
41
- var _b = React.useState(''), switchID = _b[0], setSwitchID = _b[1];
42
- var _c = React.useState(false), showHelp = _c[0], setShowHelp = _c[1];
43
- var showHelpIcon = props.Help !== undefined;
44
- React.useEffect(function () {
45
- setHelpID((0, helper_functions_1.CreateGuid)());
46
- setSwitchID((0, helper_functions_1.CreateGuid)());
47
- }, []);
48
- return (React.createElement("div", { className: "custom-control custom-switch", "data-help": helpID, style: props.Style },
49
- React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
50
- var record = __assign({}, props.Record);
51
- record[props.Field] = evt.target.checked;
52
- props.Setter(record);
53
- }, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled, id: switchID }),
54
- React.createElement("label", { className: "custom-control-label", htmlFor: switchID }, props.Label == null ? props.Field : props.Label),
55
- showHelpIcon ?
56
- React.createElement(React.Fragment, null,
57
- 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); } }, "?"),
58
- React.createElement(HelperMessage_1.default, { Show: showHelp, Target: helpID, Zindex: 9999 }, props.Help))
59
- : null));
60
- }
61
- exports.default = ToggleSwitch;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // ToggleSwitch.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
+ // 04/19/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
+ exports.default = ToggleSwitch;
37
+ var React = require("react");
38
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
39
+ var HelperMessage_1 = require("./HelperMessage");
40
+ function ToggleSwitch(props) {
41
+ var helpID = React.useRef((0, helper_functions_1.CreateGuid)());
42
+ var switchID = React.useRef((0, helper_functions_1.CreateGuid)());
43
+ var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
44
+ var showHelpIcon = props.Help !== undefined;
45
+ return (React.createElement("div", { className: "custom-control custom-switch", "data-help": helpID.current, style: props.Style },
46
+ React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
47
+ var record = __assign({}, props.Record);
48
+ record[props.Field] = evt.target.checked;
49
+ props.Setter(record);
50
+ }, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled, id: switchID.current }),
51
+ React.createElement("label", { className: "custom-control-label", htmlFor: switchID.current }, props.Label == null ? props.Field : props.Label),
52
+ showHelpIcon ?
53
+ React.createElement(React.Fragment, null,
54
+ 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); } }, "?"),
55
+ React.createElement(HelperMessage_1.default, { Show: showHelp, Target: helpID.current, Zindex: 9999 }, props.Help))
56
+ : null));
57
+ }
package/lib/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
- import CheckBox from './CheckBox';
2
- import Input from './Input';
3
- import DatePicker from './DatePicker';
4
- import Select from './Select';
5
- import TextArea from './TextArea';
6
- import DateRangePicker from './DateRangePicker';
7
- import EnumCheckBoxes from './EnumCheckBoxes';
8
- import ArrayMultiSelect from './ArrayMultiSelect';
9
- import ArrayCheckBoxes from './ArrayCheckBoxes';
10
- import MultiCheckBoxSelect from './MutliCheckBoxSelect';
11
- import DoubleInput from './DoubleInput';
12
- import TimePicker from './TimePicker';
13
- import StylableSelect from './StylableSelect';
14
- import ColorPicker from './ColorPicker';
15
- import SearchableSelect from './SearchableSelect';
16
- import ToggleSwitch from './ToggleSwitch';
17
- import InputWithButton from './InputWithButton';
18
- export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect, ToggleSwitch, InputWithButton };
1
+ import CheckBox from './CheckBox';
2
+ import Input from './Input';
3
+ import DatePicker from './DatePicker';
4
+ import Select from './Select';
5
+ import TextArea from './TextArea';
6
+ import DateRangePicker from './DateRangePicker';
7
+ import EnumCheckBoxes from './EnumCheckBoxes';
8
+ import ArrayMultiSelect from './ArrayMultiSelect';
9
+ import ArrayCheckBoxes from './ArrayCheckBoxes';
10
+ import MultiCheckBoxSelect from './MutliCheckBoxSelect';
11
+ import DoubleInput from './DoubleInput';
12
+ import TimePicker from './TimePicker';
13
+ import StylableSelect from './StylableSelect';
14
+ import ColorPicker from './ColorPicker';
15
+ import SearchableSelect from './SearchableSelect';
16
+ import ToggleSwitch from './ToggleSwitch';
17
+ import InputWithButton from './InputWithButton';
18
+ import RadioButtons from './RadioButtons';
19
+ export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect, ToggleSwitch, InputWithButton, RadioButtons };