@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.
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 -101
  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 +6 -5
@@ -1,11 +1,33 @@
1
- /// <reference types="react" />
2
- export default function ArrayCheckBoxes<T>(props: {
3
- Record: T;
4
- Field: keyof T;
5
- Setter: (record: T) => void;
6
- Checkboxes: {
7
- ID: string;
8
- Label: string;
9
- }[];
10
- Label?: string;
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
+ * Array of checkboxes with their IDs and labels
19
+ * @type {{ ID: string; Label: string }[]}
20
+ */
21
+ Checkboxes: {
22
+ ID: string;
23
+ Label: string;
24
+ }[];
25
+ /**
26
+ * Label to display for the form, defaults to the Field prop
27
+ * @type {string}
28
+ * @optional
29
+ */
30
+ Label?: string;
31
+ }
32
+ export default function ArrayCheckBoxes<T>(props: IProps<T>): JSX.Element;
33
+ export {};
@@ -1,79 +1,81 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // ArrayCheckBoxes.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
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
36
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
37
- if (ar || !(i in from)) {
38
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
39
- ar[i] = from[i];
40
- }
41
- }
42
- return to.concat(ar || Array.prototype.slice.call(from));
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- var React = require("react");
46
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
47
- function ArrayCheckBoxes(props) {
48
- var Remove = function (cb) {
49
- var a = __spreadArray([], props.Record[props.Field], true);
50
- var i = a.indexOf(cb.ID);
51
- a.splice(i, 1);
52
- return a;
53
- };
54
- var Add = function (cb) {
55
- var a = __spreadArray([], props.Record[props.Field], true);
56
- var i = a.indexOf(cb.ID);
57
- if (i < 0)
58
- a.push(cb.ID);
59
- a.sort();
60
- return a;
61
- };
62
- var id = React.useRef("array-checkbox-" + (0, helper_functions_1.CreateGuid)());
63
- return (React.createElement("div", { className: "form-group" },
64
- React.createElement("label", null, props.Label == null ? props.Field : props.Label),
65
- React.createElement("br", null),
66
- React.createElement("div", { className: "form-check form-check-inline" },
67
- React.createElement("input", { id: id.current + "-all", className: "form-check-input", type: "checkbox", checked: JSON.stringify(props.Record[props.Field]) === JSON.stringify(props.Checkboxes.map(function (x) { return x.ID; })), onChange: function (evt) {
68
- var _a;
69
- return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? props.Checkboxes.map(function (x) { return x.ID; }) : [], _a)));
70
- } }),
71
- React.createElement("label", { htmlFor: id.current + "-all", className: "form-check-label" }, "All")),
72
- props.Checkboxes.map(function (cb, i) { return (React.createElement("div", { key: i, className: "form-check form-check-inline" },
73
- React.createElement("input", { id: id.current + "-" + i, className: "form-check-input", type: "checkbox", checked: props.Record[props.Field].find(function (x) { return cb.ID === x; }) !== undefined, onChange: function (evt) {
74
- var _a;
75
- return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? Add(cb) : Remove(cb), _a)));
76
- } }),
77
- React.createElement("label", { htmlFor: id.current + "-" + i, className: "form-check-label" }, cb.Label))); })));
78
- }
79
- exports.default = ArrayCheckBoxes;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // ArrayCheckBoxes.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
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
36
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
37
+ if (ar || !(i in from)) {
38
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
39
+ ar[i] = from[i];
40
+ }
41
+ }
42
+ return to.concat(ar || Array.prototype.slice.call(from));
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.default = ArrayCheckBoxes;
46
+ var React = require("react");
47
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
48
+ function ArrayCheckBoxes(props) {
49
+ // Remove an ID from the array
50
+ var Remove = function (cb) {
51
+ var a = __spreadArray([], props.Record[props.Field], true);
52
+ var i = a.indexOf(cb.ID);
53
+ a.splice(i, 1);
54
+ return a;
55
+ };
56
+ // Add an ID to the array making sure there are no duplicates and array is sorted
57
+ var Add = function (cb) {
58
+ var a = __spreadArray([], props.Record[props.Field], true);
59
+ var i = a.indexOf(cb.ID);
60
+ if (i < 0)
61
+ a.push(cb.ID);
62
+ a.sort();
63
+ return a;
64
+ };
65
+ var id = React.useRef("array-checkbox-" + (0, helper_functions_1.CreateGuid)());
66
+ return (React.createElement("div", { className: "form-group" },
67
+ React.createElement("label", null, props.Label == null ? props.Field : props.Label),
68
+ React.createElement("br", null),
69
+ React.createElement("div", { className: "form-check form-check-inline" },
70
+ React.createElement("input", { id: "".concat(id.current, "-all"), className: "form-check-input", type: "checkbox", checked: JSON.stringify(props.Record[props.Field]) === JSON.stringify(props.Checkboxes.map(function (x) { return x.ID; })), onChange: function (evt) {
71
+ var _a;
72
+ return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? props.Checkboxes.map(function (x) { return x.ID; }) : [], _a)));
73
+ } }),
74
+ React.createElement("label", { htmlFor: "".concat(id.current, "-all"), className: "form-check-label" }, "All")),
75
+ props.Checkboxes.map(function (cb, i) { return (React.createElement("div", { key: i, className: "form-check form-check-inline" },
76
+ React.createElement("input", { id: "".concat(id.current, "-").concat(i), className: "form-check-input", type: "checkbox", checked: props.Record[props.Field].find(function (x) { return cb.ID === x; }) !== undefined, onChange: function (evt) {
77
+ var _a;
78
+ return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? Add(cb) : Remove(cb), _a)));
79
+ } }),
80
+ React.createElement("label", { htmlFor: "".concat(id.current, "-").concat(i), className: "form-check-label" }, cb.Label))); })));
81
+ }
@@ -1,13 +1,47 @@
1
- import * as React from 'react';
2
- export default function ArrayMultiSelect<T>(props: {
3
- Record: T;
4
- Field: keyof T;
5
- Setter: (record: T) => void;
6
- Options: {
7
- Value: string;
8
- Label: string;
9
- }[];
10
- Label?: string;
11
- Disabled?: boolean;
12
- Style?: React.CSSProperties;
13
- }): JSX.Element;
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
+ * Options for the select dropdown
15
+ * @type {{ Value: string; Label: string }[]}
16
+ */
17
+ Options: {
18
+ Value: string;
19
+ Label: string;
20
+ }[];
21
+ /**
22
+ * Setter function to update the Record
23
+ * @param record - Updated Record
24
+ */
25
+ Setter: (record: T) => void;
26
+ /**
27
+ * Label to display for the form, defaults to the Field prop
28
+ * @type {string}
29
+ * @optional
30
+ */
31
+ Label?: string;
32
+ /**
33
+ * Flag to disable the input field
34
+ * @type {boolean}
35
+ * @optional
36
+ */
37
+ Disabled?: boolean;
38
+ /**
39
+ * CSS styles to apply to the select element
40
+ * @type {React.CSSProperties}
41
+ * @optional
42
+ */
43
+ Style?: React.CSSProperties;
44
+ GroupStyle?: React.CSSProperties;
45
+ }
46
+ export default function ArrayMultiSelect<T>(props: IProps<T>): JSX.Element;
47
+ export {};
@@ -1,47 +1,49 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // ArrayMultiSelect.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
- var React = require("react");
37
- function ArrayMultiSelect(props) {
38
- var _a;
39
- return (React.createElement("div", { className: "form-group" },
40
- React.createElement("label", null, props.Label == null ? props.Field : props.Label),
41
- React.createElement("select", { multiple: true, className: "form-control", onChange: function (evt) {
42
- var _a;
43
- var record = __assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = Array.from(evt.target.selectedOptions).map(function (a) { return a.value; }), _a));
44
- props.Setter(record);
45
- }, value: (_a = props.Record[props.Field]) !== null && _a !== void 0 ? _a : [], disabled: props.Disabled == null ? false : props.Disabled, style: props.Style }, props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
46
- }
47
- exports.default = ArrayMultiSelect;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // ArrayMultiSelect.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 = ArrayMultiSelect;
37
+ var React = require("react");
38
+ // Generic component designed for selecting multiple options from a dropdown
39
+ function ArrayMultiSelect(props) {
40
+ var _a;
41
+ return (React.createElement("div", { className: "form-group", style: props.GroupStyle },
42
+ React.createElement("label", null, props.Label == null ? props.Field : props.Label),
43
+ React.createElement("select", { multiple: true, className: "form-control", onChange: function (evt) {
44
+ var _a;
45
+ // On change, update the record's field with the changes.
46
+ var record = __assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = Array.from(evt.target.selectedOptions).map(function (a) { return a.value; }), _a));
47
+ props.Setter(record);
48
+ }, value: (_a = props.Record[props.Field]) !== null && _a !== void 0 ? _a : [], disabled: props.Disabled == null ? false : props.Disabled, style: props.Style }, props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
49
+ }
package/lib/CheckBox.d.ts CHANGED
@@ -1,11 +1,37 @@
1
- /// <reference types="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
- }
10
- export default function CheckBox<T>(props: IProps<T>): JSX.Element;
11
- export {};
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
+ * Label to display for the form, defaults to the Field prop
19
+ * @type {string}
20
+ * @optional
21
+ */
22
+ Label?: string;
23
+ /**
24
+ * Flag to disable the input field
25
+ * @type {boolean}
26
+ * @optional
27
+ */
28
+ Disabled?: boolean;
29
+ /**
30
+ * Help message or element to display
31
+ * @type {string | JSX.Element}
32
+ * @optional
33
+ */
34
+ Help?: string | JSX.Element;
35
+ }
36
+ export default function CheckBox<T>(props: IProps<T>): JSX.Element;
37
+ export {};
package/lib/CheckBox.js CHANGED
@@ -1,60 +1,62 @@
1
- "use strict";
2
- // ******************************************************************************************************
3
- // CheckBox.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
- var React = require("react");
37
- var helper_functions_1 = require("@gpa-gemstone/helper-functions");
38
- var HelperMessage_1 = require("./HelperMessage");
39
- function CheckBox(props) {
40
- var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
41
- var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
42
- var showHelpIcon = props.Help !== undefined;
43
- React.useEffect(function () {
44
- setGuid((0, helper_functions_1.CreateGuid)());
45
- }, []);
46
- return (React.createElement("div", { className: "form-check", "data-help": guid },
47
- React.createElement("input", { type: "checkbox", className: "form-check-input", style: { zIndex: 1 }, onChange: function (evt) {
48
- var record = __assign({}, props.Record);
49
- record[props.Field] = evt.target.checked;
50
- props.Setter(record);
51
- }, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled }),
52
- React.createElement("label", { className: "form-check-label" }, props.Label == null ? props.Field : props.Label),
53
- showHelpIcon ?
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
- : null,
56
- showHelpIcon ?
57
- React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
58
- : null));
59
- }
60
- exports.default = CheckBox;
1
+ "use strict";
2
+ // ******************************************************************************************************
3
+ // CheckBox.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 = CheckBox;
37
+ var React = require("react");
38
+ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
39
+ var HelperMessage_1 = require("./HelperMessage");
40
+ function CheckBox(props) {
41
+ var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
42
+ var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
43
+ // Determines whether to show help icon and label.
44
+ var showHelpIcon = props.Help !== undefined;
45
+ // Runs once, setting a unique GUID for each checkbox instance.
46
+ React.useEffect(function () {
47
+ setGuid((0, helper_functions_1.CreateGuid)());
48
+ }, []);
49
+ return (React.createElement("div", { className: "form-check", "data-help": guid },
50
+ React.createElement("input", { type: "checkbox", className: "form-check-input", style: { zIndex: 1 }, onChange: function (evt) {
51
+ var record = __assign({}, props.Record);
52
+ record[props.Field] = evt.target.checked;
53
+ props.Setter(record);
54
+ }, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled }),
55
+ React.createElement("label", { className: "form-check-label" }, props.Label == null ? props.Field : props.Label),
56
+ showHelpIcon ?
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
+ : null,
59
+ showHelpIcon ?
60
+ React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
61
+ : null));
62
+ }
@@ -1,15 +1,59 @@
1
- import * as React from 'react';
2
- import { ColorResult } from 'react-color';
3
- interface IProps<T> {
4
- Record: T;
5
- Field: keyof T;
6
- Setter: (record: T, color: ColorResult) => void;
7
- Label: string;
8
- Disabled?: boolean;
9
- Feedback?: string;
10
- Style?: React.CSSProperties;
11
- Colors?: string[];
12
- Triangle?: ('hide' | 'top');
13
- }
14
- export default function ColorPicker<T>(props: IProps<T>): JSX.Element;
15
- export {};
1
+ import * as React from 'react';
2
+ import { ColorResult } from 'react-color';
3
+ interface IProps<T> {
4
+ /**
5
+ * Record to be used in the form
6
+ * @type {T}
7
+ */
8
+ Record: T;
9
+ /**
10
+ * Field of the record to be edited
11
+ * @type {keyof T}
12
+ */
13
+ Field: keyof T;
14
+ /**
15
+ * Setter function to update the Record
16
+ * @param record - Updated record of type T
17
+ * @param color - Color result from the picker
18
+ * @returns {void}
19
+ */
20
+ Setter: (record: T, color: ColorResult) => void;
21
+ /**
22
+ * Label to display for the form, defaults to the Field prop
23
+ * @type {string}
24
+ * @optional
25
+ */
26
+ Label: string;
27
+ /**
28
+ * Flag to disable the input field
29
+ * @type {boolean}
30
+ * @optional
31
+ */
32
+ Disabled?: boolean;
33
+ /**
34
+ * Feedback message to show when input is invalid
35
+ * @type {string}
36
+ * @optional
37
+ */
38
+ Feedback?: string;
39
+ /**
40
+ * CSS styles to apply to the button
41
+ * @type {React.CSSProperties}
42
+ * @optional
43
+ */
44
+ Style?: React.CSSProperties;
45
+ /**
46
+ * List of colors to be used in the color picker
47
+ * @type {string[]}
48
+ * @optional
49
+ */
50
+ Colors?: string[];
51
+ /**
52
+ * Position of the triangle pointer in the color picker
53
+ * @type {'hide' | 'top'}
54
+ * @optional
55
+ */
56
+ Triangle?: 'hide' | 'top';
57
+ }
58
+ export default function ColorPicker<T>(props: IProps<T>): JSX.Element;
59
+ export {};