@gpa-gemstone/react-forms 1.1.60 → 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 -101
- package/lib/TextArea.d.ts +54 -14
- package/lib/TextArea.js +76 -72
- package/lib/TimePicker.d.ts +50 -11
- package/lib/TimePicker.js +60 -51
- package/lib/ToggleSwitch.d.ts +44 -12
- package/lib/ToggleSwitch.js +57 -61
- package/lib/index.d.ts +19 -18
- package/lib/index.js +61 -59
- package/package.json +4 -3
|
@@ -1,104 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// MultiCheckBoxSelect.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
|
-
// 07/17/2020 - Billy Ernest
|
|
21
|
-
// Generated original version of source code.
|
|
22
|
-
//
|
|
23
|
-
// ******************************************************************************************************
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
26
|
-
var React = require("react");
|
|
27
|
-
var HelperMessage_1 = require("./HelperMessage");
|
|
28
|
-
var MultiSelect = function (props) {
|
|
29
|
-
var _a;
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
React.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: null,
|
|
71
|
-
|
|
72
|
-
React.createElement(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
React.createElement("
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
React.createElement("td", null,
|
|
103
|
-
};
|
|
104
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// MultiCheckBoxSelect.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
|
+
// 07/17/2020 - Billy Ernest
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
26
|
+
var React = require("react");
|
|
27
|
+
var HelperMessage_1 = require("./HelperMessage");
|
|
28
|
+
var MultiSelect = function (props) {
|
|
29
|
+
var _a;
|
|
30
|
+
// State hooks for managing the visibility of the dropdown and help message.
|
|
31
|
+
var _b = React.useState(false), show = _b[0], setShow = _b[1];
|
|
32
|
+
var _c = React.useState(false), showHelp = _c[0], setShowHelp = _c[1];
|
|
33
|
+
var _d = React.useState(false), showItems = _d[0], setShowItems = _d[1];
|
|
34
|
+
var _e = React.useState(""), guid = _e[0], setGuid = _e[1];
|
|
35
|
+
var multiSelect = React.useRef(null);
|
|
36
|
+
var showLabel = React.useMemo(function () { return props.Label !== ""; }, [props.Label]);
|
|
37
|
+
var showHelpIcon = React.useMemo(function () { return props.Help !== undefined; }, [props.Help]);
|
|
38
|
+
var selectedOptions = React.useMemo(function () { return props.Options.filter(function (opt) { return opt.Selected; }); }, [props.Options]);
|
|
39
|
+
// Effect to generate a unique ID for the component.
|
|
40
|
+
React.useEffect(function () {
|
|
41
|
+
setGuid((0, helper_functions_1.CreateGuid)());
|
|
42
|
+
}, []);
|
|
43
|
+
// Handle showing and hiding of the dropdown.
|
|
44
|
+
function HandleShow(evt) {
|
|
45
|
+
if (multiSelect.current === null)
|
|
46
|
+
setShow(!show);
|
|
47
|
+
else if (!multiSelect.current.contains(evt.target))
|
|
48
|
+
setShow(false);
|
|
49
|
+
else
|
|
50
|
+
setShow(true);
|
|
51
|
+
}
|
|
52
|
+
// Effect to add and remove event listener for clicking outside the component.
|
|
53
|
+
React.useEffect(function () {
|
|
54
|
+
document.addEventListener('mousedown', HandleShow, false);
|
|
55
|
+
return function () {
|
|
56
|
+
document.removeEventListener('mousedown', HandleShow, false);
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
return (React.createElement("div", { className: "form-group" },
|
|
60
|
+
showLabel || showHelpIcon ?
|
|
61
|
+
React.createElement("label", null,
|
|
62
|
+
showLabel ?
|
|
63
|
+
(props.Label === undefined ? 'Select' : props.Label)
|
|
64
|
+
: '',
|
|
65
|
+
showHelpIcon ?
|
|
66
|
+
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); } }, " ?")
|
|
67
|
+
: null) : null,
|
|
68
|
+
showHelpIcon ?
|
|
69
|
+
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
70
|
+
: null,
|
|
71
|
+
((_a = props.ItemTooltip) !== null && _a !== void 0 ? _a : 'no-tip') !== 'no-tip' ?
|
|
72
|
+
React.createElement(HelperMessage_1.default, { Show: showItems, Target: guid, Background: props.ItemTooltip === 'dark' ? "#222" : '#fff', Color: props.ItemTooltip === 'dark' ? "#fff" : '#222' },
|
|
73
|
+
React.createElement("p", null, "Selected Options:"),
|
|
74
|
+
selectedOptions.slice(0, 10).map(function (opt) { return React.createElement("p", null, opt.Text); }),
|
|
75
|
+
selectedOptions.length > 10 ? React.createElement("p", null, "and ".concat(selectedOptions.length - 10, " other(s)")) : null)
|
|
76
|
+
: null,
|
|
77
|
+
React.createElement("div", { ref: multiSelect, style: { position: 'relative', display: 'block', width: 'inherit' } },
|
|
78
|
+
React.createElement("button", { "data-help": guid, type: "button", style: { border: '1px solid #ced4da', padding: '.375rem .75rem', fontSize: '1rem', borderRadius: '.25rem' }, className: "btn form-control dropdown-toggle", onClick: HandleShow, onMouseEnter: function () { return setShowItems(true); }, onMouseLeave: function () { return setShowItems(false); } },
|
|
79
|
+
props.Options.filter(function (x) { return x.Selected; }).length !== props.Options.length
|
|
80
|
+
? props.Options.filter(function (x) { return x.Selected; }).length
|
|
81
|
+
: 'All ',
|
|
82
|
+
' ',
|
|
83
|
+
"Selected"),
|
|
84
|
+
React.createElement("div", { style: {
|
|
85
|
+
maxHeight: window.innerHeight * 0.75,
|
|
86
|
+
overflowY: 'auto',
|
|
87
|
+
padding: '10 5',
|
|
88
|
+
display: show ? 'block' : 'none',
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
backgroundColor: '#fff',
|
|
91
|
+
color: 'black',
|
|
92
|
+
boxShadow: '0px 8px 16px 0px rgba(0,0,0,0.2)',
|
|
93
|
+
zIndex: 401,
|
|
94
|
+
minWidth: '100%',
|
|
95
|
+
} },
|
|
96
|
+
React.createElement("table", { className: "table", style: { margin: 0 } },
|
|
97
|
+
React.createElement("tbody", null,
|
|
98
|
+
React.createElement("tr", { onClick: function (evt) {
|
|
99
|
+
evt.preventDefault();
|
|
100
|
+
props.OnChange(evt, props.Options.filter(function (x) { return x.Selected === (props.Options.filter(function (o) { return o.Selected; }).length === props.Options.length); }));
|
|
101
|
+
} },
|
|
102
|
+
React.createElement("td", null,
|
|
103
|
+
React.createElement("input", { type: "checkbox", checked: props.Options.filter(function (x) { return x.Selected; }).length === props.Options.length, onChange: function () { return null; } })),
|
|
104
|
+
React.createElement("td", null, "All")),
|
|
105
|
+
props.Options.map(function (f, i) { return (React.createElement("tr", { key: i, onClick: function (evt) { return props.OnChange(evt, [f]); } },
|
|
106
|
+
React.createElement("td", null,
|
|
107
|
+
React.createElement("input", { type: "checkbox", checked: f.Selected, onChange: function () { return null; } })),
|
|
108
|
+
React.createElement("td", null, f.Text))); })))))));
|
|
109
|
+
};
|
|
110
|
+
exports.default = MultiSelect;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface IProps<T> {
|
|
2
|
+
Record: T;
|
|
3
|
+
Field: keyof T;
|
|
4
|
+
Setter: (record: T) => void;
|
|
5
|
+
Help?: string | JSX.Element;
|
|
6
|
+
Position?: ('vertical' | 'horizontal');
|
|
7
|
+
Options: {
|
|
8
|
+
Value: string;
|
|
9
|
+
Label: string;
|
|
10
|
+
Disabled?: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
Label?: string;
|
|
13
|
+
}
|
|
14
|
+
export default function RadioButtons<T>(props: IProps<T>): JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// RadioButtons.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
|
+
// 06/10/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 = RadioButtons;
|
|
37
|
+
var React = require("react");
|
|
38
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
+
var HelperMessage_1 = require("./HelperMessage");
|
|
40
|
+
function RadioButtons(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
|
+
var showHelpIcon = props.Help !== undefined;
|
|
45
|
+
return (React.createElement("div", { className: "form-group", "data-help": guid.current },
|
|
46
|
+
React.createElement("label", { className: "form-check-label d-block" }, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field),
|
|
47
|
+
props.Options.map(function (option, index) {
|
|
48
|
+
var _a;
|
|
49
|
+
return (React.createElement("div", { key: index, className: "form-check ".concat(props.Position == 'vertical' ? '' : 'form-check-inline') },
|
|
50
|
+
React.createElement("input", { type: "radio", className: "form-check-input", style: { zIndex: 1 }, onChange: function () {
|
|
51
|
+
var record = __assign({}, props.Record);
|
|
52
|
+
record[props.Field] = option.Value;
|
|
53
|
+
props.Setter(record);
|
|
54
|
+
}, value: option.Value, checked: props.Record[props.Field] === option.Value, disabled: (_a = option.Disabled) !== null && _a !== void 0 ? _a : false, id: "".concat(option.Label, "-").concat(index) }),
|
|
55
|
+
React.createElement("label", { className: "form-check-label", htmlFor: "".concat(option.Label, "-").concat(index) }, option.Label)));
|
|
56
|
+
}),
|
|
57
|
+
showHelpIcon ?
|
|
58
|
+
React.createElement(React.Fragment, null,
|
|
59
|
+
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); } }, "?"),
|
|
60
|
+
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid.current }, props.Help))
|
|
61
|
+
: null));
|
|
62
|
+
}
|
|
@@ -1,18 +1,60 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
interface IOption {
|
|
3
|
-
Value: string;
|
|
4
|
-
Label: string;
|
|
5
|
-
}
|
|
6
|
-
interface IProps<T> {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IOption {
|
|
3
|
+
Value: string;
|
|
4
|
+
Label: string;
|
|
5
|
+
}
|
|
6
|
+
interface IProps<T> {
|
|
7
|
+
/**
|
|
8
|
+
* Record to be used in form
|
|
9
|
+
* @type {T}
|
|
10
|
+
*/
|
|
11
|
+
Record: T;
|
|
12
|
+
/**
|
|
13
|
+
* Field of the record to be edited
|
|
14
|
+
* @type {keyof T}
|
|
15
|
+
*/
|
|
16
|
+
Field: keyof T;
|
|
17
|
+
/**
|
|
18
|
+
* Setter function to update the Record
|
|
19
|
+
* @param record - Updated Record
|
|
20
|
+
*/
|
|
21
|
+
Setter: (record: T) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Flag to allow custom input values
|
|
24
|
+
* @type {boolean}
|
|
25
|
+
* @optional
|
|
26
|
+
*/
|
|
27
|
+
AllowCustom?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Function to perform a search and return a promise with a list of IOption and an optional callback
|
|
30
|
+
* @param search - Search string
|
|
31
|
+
* @returns {[promise: Promise<IOption[]>, callback?: () => void]}
|
|
32
|
+
*/
|
|
33
|
+
Search: (search: string) => [promise: Promise<IOption[]>, callback?: () => void];
|
|
34
|
+
/**
|
|
35
|
+
* Label to display for the form, defaults to the Field prop
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @optional
|
|
38
|
+
*/
|
|
39
|
+
Label?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Flag to disable the input field
|
|
42
|
+
* @type {boolean}
|
|
43
|
+
* @optional
|
|
44
|
+
*/
|
|
45
|
+
Disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Help message or element to display
|
|
48
|
+
* @type {string | JSX.Element}
|
|
49
|
+
* @optional
|
|
50
|
+
*/
|
|
51
|
+
Help?: string | JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* CSS styles to apply to the form group
|
|
54
|
+
* @type {React.CSSProperties}
|
|
55
|
+
* @optional
|
|
56
|
+
*/
|
|
57
|
+
Style?: React.CSSProperties;
|
|
58
|
+
}
|
|
59
|
+
export default function SearchableSelect<T>(props: IProps<T>): JSX.Element;
|
|
60
|
+
export {};
|
package/lib/SearchableSelect.js
CHANGED
|
@@ -1,85 +1,84 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ******************************************************************************************************
|
|
3
|
-
// SearchableSelect.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
|
-
// 03/17/2024 - 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
|
-
var __assign = (this && this.__assign) || function () {
|
|
29
|
-
__assign = Object.assign || function(t) {
|
|
30
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
31
|
-
s = arguments[i];
|
|
32
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
33
|
-
t[p] = s[p];
|
|
34
|
-
}
|
|
35
|
-
return t;
|
|
36
|
-
};
|
|
37
|
-
return __assign.apply(this, arguments);
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
React.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
r.push.apply(r, results.filter(function (f) { return f.Value !== search && f.Value !== props.Record[props.Field]; }));
|
|
70
|
-
if (!((_c = props.AllowCustom) !== null && _c !== void 0 ? _c : false))
|
|
71
|
-
r.push({ Value: 'search-' + props.Record[props.Field], Element: React.createElement("p", null, props.Record[props.Field]) });
|
|
72
|
-
return r;
|
|
73
|
-
}, [search, props.Record[props.Field], results, props.Disabled, loading]);
|
|
74
|
-
var update = React.useCallback(function (record) {
|
|
75
|
-
if (record[props.Field].toString().startsWith('search-'))
|
|
76
|
-
return;
|
|
77
|
-
props.Setter(record);
|
|
78
|
-
setSearch(record[props.Field].toString());
|
|
79
|
-
}, [props.Setter, props.Field]);
|
|
80
|
-
return React.createElement(StylableSelect_1.default, { Record: props.Record, Field: props.Field, Setter: update, Label: props.Label, Disabled: props.Disabled, Help: props.Help, Style: props.Style, Options: options });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var templateObject_1, templateObject_2;
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// SearchableSelect.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
|
+
// 03/17/2024 - 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
|
+
var __assign = (this && this.__assign) || function () {
|
|
29
|
+
__assign = Object.assign || function(t) {
|
|
30
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
31
|
+
s = arguments[i];
|
|
32
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
33
|
+
t[p] = s[p];
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
return __assign.apply(this, arguments);
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.default = SearchableSelect;
|
|
41
|
+
var React = require("react");
|
|
42
|
+
var StylableSelect_1 = require("./StylableSelect");
|
|
43
|
+
var styled_components_1 = require("styled-components");
|
|
44
|
+
function SearchableSelect(props) {
|
|
45
|
+
var _a = React.useState(props.Record[props.Field].toString()), search = _a[0], setSearch = _a[1];
|
|
46
|
+
var _b = React.useState([]), results = _b[0], setResults = _b[1];
|
|
47
|
+
var _c = React.useState(false), loading = _c[0], setLoading = _c[1];
|
|
48
|
+
React.useEffect(function () {
|
|
49
|
+
setLoading(true);
|
|
50
|
+
var _a = props.Search(search), h = _a[0], c = _a[1];
|
|
51
|
+
h.then(function (d) { setResults(d.map(function (o) { return ({ Value: o.Value, Element: React.createElement("p", null, o.Label) }); })); setLoading(false); });
|
|
52
|
+
return c;
|
|
53
|
+
}, [search]);
|
|
54
|
+
var options = React.useMemo(function () {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
var r = [];
|
|
57
|
+
if ((_a = props.AllowCustom) !== null && _a !== void 0 ? _a : false)
|
|
58
|
+
r.push({ Value: search, Element: React.createElement("p", null, search) });
|
|
59
|
+
r.push({
|
|
60
|
+
Value: props.Record[props.Field], Element: React.createElement("div", { className: 'input-group' },
|
|
61
|
+
React.createElement("input", { type: "text", className: "form-control", value: search, onChange: function (d) { return setSearch(d.target.value); }, onBlur: (((_b = props.AllowCustom) !== null && _b !== void 0 ? _b : false) ? function () {
|
|
62
|
+
var _a;
|
|
63
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = search, _a)));
|
|
64
|
+
} : function () { return setSearch(props.Record[props.Field].toString()); }) }),
|
|
65
|
+
React.createElement("div", { className: "input-group-append" },
|
|
66
|
+
React.createElement("span", { className: "input-group-text" },
|
|
67
|
+
React.createElement(Icon, null))))
|
|
68
|
+
});
|
|
69
|
+
r.push.apply(r, results.filter(function (f) { return f.Value !== search && f.Value !== props.Record[props.Field]; }));
|
|
70
|
+
if (!((_c = props.AllowCustom) !== null && _c !== void 0 ? _c : false))
|
|
71
|
+
r.push({ Value: 'search-' + props.Record[props.Field], Element: React.createElement("p", null, props.Record[props.Field]) });
|
|
72
|
+
return r;
|
|
73
|
+
}, [search, props.Record[props.Field], results, props.Disabled, loading]);
|
|
74
|
+
var update = React.useCallback(function (record) {
|
|
75
|
+
if (record[props.Field].toString().startsWith('search-'))
|
|
76
|
+
return;
|
|
77
|
+
props.Setter(record);
|
|
78
|
+
setSearch(record[props.Field].toString());
|
|
79
|
+
}, [props.Setter, props.Field]);
|
|
80
|
+
return React.createElement(StylableSelect_1.default, { Record: props.Record, Field: props.Field, Setter: update, Label: props.Label, Disabled: props.Disabled, Help: props.Help, Style: props.Style, Options: options });
|
|
81
|
+
}
|
|
82
|
+
var spin = (0, styled_components_1.keyframes)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"], ["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"])));
|
|
83
|
+
var Icon = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tanimation: ", " 1s linear infinite;\n\tborder: 5px solid #f3f3f3;\n\tborder-Top: 5px solid #555;\n\tborder-Radius: 50%;\n\twidth: 25px;\n\theight: 25px\n"], ["\n\tanimation: ", " 1s linear infinite;\n\tborder: 5px solid #f3f3f3;\n\tborder-Top: 5px solid #555;\n\tborder-Radius: 50%;\n\twidth: 25px;\n\theight: 25px\n"])), spin);
|
|
84
|
+
var templateObject_1, templateObject_2;
|