@gpa-gemstone/react-forms 1.1.81 → 1.1.83
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/CheckBox.js +4 -4
- package/lib/DatePicker.js +30 -15
- package/lib/DateTimeUI/DateTimePopup.js +2 -2
- package/lib/Input.js +4 -4
- package/lib/InputWithButton.js +4 -4
- package/lib/MultiInput.js +4 -4
- package/lib/MutliCheckBoxSelect.js +6 -5
- package/lib/RadioButtons.js +4 -4
- package/lib/SearchableSelect.js +1 -1
- package/lib/Select.js +4 -4
- package/lib/StylableSelect.d.ts +2 -2
- package/lib/StylableSelect.js +5 -5
- package/lib/TextArea.js +4 -4
- package/lib/TimePicker.js +3 -3
- package/lib/ToggleSwitch.js +4 -4
- package/lib/ToolTip.d.ts +10 -0
- package/lib/ToolTip.js +136 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +3 -3
- package/lib/HelperMessage.d.ts +0 -25
- package/lib/HelperMessage.js +0 -90
package/lib/CheckBox.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.default = CheckBox;
|
|
37
37
|
var React = require("react");
|
|
38
38
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
-
var
|
|
39
|
+
var ToolTip_1 = require("./ToolTip");
|
|
40
40
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
41
|
function CheckBox(props) {
|
|
42
42
|
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
@@ -48,7 +48,7 @@ function CheckBox(props) {
|
|
|
48
48
|
var showLabel = props.Label !== "";
|
|
49
49
|
var showHelpIcon = props.Help !== undefined;
|
|
50
50
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
51
|
-
return (React.createElement("div", { className: "form-check"
|
|
51
|
+
return (React.createElement("div", { className: "form-check" },
|
|
52
52
|
React.createElement("input", { type: "checkbox", className: "form-check-input", style: { zIndex: 1 }, onChange: function (evt) {
|
|
53
53
|
var record = __assign({}, props.Record);
|
|
54
54
|
record[props.Field] = evt.target.checked;
|
|
@@ -58,10 +58,10 @@ function CheckBox(props) {
|
|
|
58
58
|
React.createElement("label", { className: 'form-check-label' },
|
|
59
59
|
showLabel ? label : '',
|
|
60
60
|
showHelpIcon ?
|
|
61
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
61
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
62
62
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
63
63
|
: null) : null,
|
|
64
64
|
showHelpIcon ?
|
|
65
|
-
React.createElement(
|
|
65
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
66
66
|
: null));
|
|
67
67
|
}
|
package/lib/DatePicker.js
CHANGED
|
@@ -38,7 +38,7 @@ var React = require("react");
|
|
|
38
38
|
var moment = require("moment");
|
|
39
39
|
var DateTimePopup_1 = require("./DateTimeUI/DateTimePopup");
|
|
40
40
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
41
|
-
var
|
|
41
|
+
var ToolTip_1 = require("./ToolTip");
|
|
42
42
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
43
43
|
/**
|
|
44
44
|
* Component that allows a user to pick a date or datetime.
|
|
@@ -51,19 +51,16 @@ function DateTimePicker(props) {
|
|
|
51
51
|
var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
|
|
52
52
|
// State and ref declarations.
|
|
53
53
|
var divRef = React.useRef(null);
|
|
54
|
-
var
|
|
55
|
-
var
|
|
54
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
55
|
+
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
56
56
|
// Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
57
|
+
var _b = React.useState(parse(props.Record).format(boxFormat)), boxRecord = _b[0], setBoxRecord = _b[1];
|
|
58
|
+
var _c = React.useState(parse(props.Record)), pickerRecord = _c[0], setPickerRecord = _c[1];
|
|
59
|
+
var _d = React.useState(""), feedbackMessage = _d[0], setFeedbackMessage = _d[1];
|
|
60
|
+
var _e = React.useState(false), showOverlay = _e[0], setShowOverlay = _e[1];
|
|
61
|
+
var _f = React.useState(0), top = _f[0], setTop = _f[1];
|
|
62
|
+
var _g = React.useState(0), left = _g[0], setLeft = _g[1];
|
|
63
63
|
var allowNull = React.useMemo(function () { var _a; return (_a = props.AllowEmpty) !== null && _a !== void 0 ? _a : false; }, [props.AllowEmpty]);
|
|
64
|
-
React.useEffect(function () {
|
|
65
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
66
|
-
}, []);
|
|
67
64
|
React.useEffect(function () {
|
|
68
65
|
if (props.Record[props.Field] !== null) {
|
|
69
66
|
setPickerRecord(parse(props.Record));
|
|
@@ -84,6 +81,24 @@ function DateTimePicker(props) {
|
|
|
84
81
|
setLeft(node.left + 0.5 * node.width);
|
|
85
82
|
setTop(node.top + node.height + 10);
|
|
86
83
|
});
|
|
84
|
+
//Effect to set top and left on a scroll event
|
|
85
|
+
React.useEffect(function () {
|
|
86
|
+
function updatePosition() {
|
|
87
|
+
if (divRef.current != null) {
|
|
88
|
+
var node = (0, helper_functions_1.GetNodeSize)(divRef.current);
|
|
89
|
+
setLeft(node.left + 0.5 * node.width);
|
|
90
|
+
setTop(node.top + node.height + 10);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
document.addEventListener('scroll', updatePosition, true);
|
|
94
|
+
window.addEventListener('resize', updatePosition);
|
|
95
|
+
updatePosition(); // Initial update
|
|
96
|
+
return function () {
|
|
97
|
+
document.removeEventListener('scroll', updatePosition, true);
|
|
98
|
+
window.removeEventListener('resize', updatePosition);
|
|
99
|
+
};
|
|
100
|
+
}, []);
|
|
101
|
+
//Effect to handle click events on the window
|
|
87
102
|
React.useEffect(function () {
|
|
88
103
|
if (showOverlay) {
|
|
89
104
|
window.addEventListener('click', onWindowClick);
|
|
@@ -203,12 +218,12 @@ function DateTimePicker(props) {
|
|
|
203
218
|
showHelpIcon || showLabel ?
|
|
204
219
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
205
220
|
showLabel ? label : '',
|
|
206
|
-
showHelpIcon ? React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
221
|
+
showHelpIcon ? React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
207
222
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 })) : null) : null,
|
|
208
223
|
showHelpIcon ?
|
|
209
|
-
React.createElement(
|
|
224
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
210
225
|
: null,
|
|
211
|
-
React.createElement("input", {
|
|
226
|
+
React.createElement("input", { className: "gpa-gemstone-datetime form-control ".concat(IsValid() ? '' : 'is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
|
|
212
227
|
valueChange(evt.target.value);
|
|
213
228
|
}, onFocus: function () { setShowOverlay(true); }, value: boxRecord, disabled: props.Disabled === undefined ? false : props.Disabled, onClick: function (e) { e.preventDefault(); }, step: step }),
|
|
214
229
|
React.createElement("div", { className: "invalid-feedback" }, getFeedbackMessage()),
|
|
@@ -50,9 +50,9 @@ function DateTimePopup(props) {
|
|
|
50
50
|
}, [props.Type]);
|
|
51
51
|
if (!props.Show)
|
|
52
52
|
return null;
|
|
53
|
-
var
|
|
53
|
+
var left = Math.max(props.Center - 0.5 * width, 0);
|
|
54
54
|
return (React.createElement(react_portal_1.Portal, null,
|
|
55
|
-
React.createElement(WrapperDiv, { Top: props.Top, Left:
|
|
55
|
+
React.createElement(WrapperDiv, { Top: props.Top, Left: left, Indicator: 50, ref: divRef, className: 'gpa-gemstone-datetime' },
|
|
56
56
|
showDate ? React.createElement(Calender_1.default, { DateTime: props.DateTime, Setter: props.Setter }) : null,
|
|
57
57
|
showTime ? React.createElement(Clock_1.default, { DateTime: props.DateTime, Setter: props.Setter, Accuracy: props.Accuracy }) : null)));
|
|
58
58
|
}
|
package/lib/Input.js
CHANGED
|
@@ -37,7 +37,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.default = Input;
|
|
39
39
|
var React = require("react");
|
|
40
|
-
var
|
|
40
|
+
var ToolTip_1 = require("./ToolTip");
|
|
41
41
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
42
42
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
43
43
|
function Input(props) {
|
|
@@ -107,12 +107,12 @@ function Input(props) {
|
|
|
107
107
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
108
108
|
showLabel ? label : '',
|
|
109
109
|
showHelpIcon ?
|
|
110
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
110
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
111
111
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
112
112
|
: null) : null,
|
|
113
113
|
showHelpIcon ?
|
|
114
|
-
React.createElement(
|
|
114
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
115
115
|
: null,
|
|
116
|
-
React.createElement("input", {
|
|
116
|
+
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal, disabled: props.Disabled == null ? false : props.Disabled, onBlur: onBlur, step: 'any' }),
|
|
117
117
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
118
118
|
}
|
package/lib/InputWithButton.js
CHANGED
|
@@ -34,7 +34,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
var React = require("react");
|
|
37
|
-
var
|
|
37
|
+
var ToolTip_1 = require("./ToolTip");
|
|
38
38
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
39
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
40
40
|
function InputWithButton(props) {
|
|
@@ -96,13 +96,13 @@ function InputWithButton(props) {
|
|
|
96
96
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
97
97
|
showLabel ? label : '',
|
|
98
98
|
showHelpIcon ?
|
|
99
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
99
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
100
100
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 })) : null) : null,
|
|
101
101
|
showHelpIcon ?
|
|
102
|
-
React.createElement(
|
|
102
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
103
103
|
: null,
|
|
104
104
|
React.createElement("div", { className: "input-group" },
|
|
105
|
-
React.createElement("input", {
|
|
105
|
+
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) { return valueChange(evt.target.value); }, value: heldVal, disabled: props.InputDisabled == null ? false : props.InputDisabled, onBlur: onBlur, step: 'any' }),
|
|
106
106
|
React.createElement("div", { className: "input-group-prepend" },
|
|
107
107
|
React.createElement("button", { className: props.BtnClass != null ? props.BtnClass : "btn btn-outline-secondary", style: props.BtnStyle, disabled: props.BtnDisabled == null ? false : props.BtnDisabled, type: "button", onClick: function (evt) { return props.OnBtnClick(evt); } }, props.BtnLabel)),
|
|
108
108
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback))));
|
package/lib/MultiInput.js
CHANGED
|
@@ -44,7 +44,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
var React = require("react");
|
|
46
46
|
var Input_1 = require("./Input");
|
|
47
|
-
var
|
|
47
|
+
var ToolTip_1 = require("./ToolTip");
|
|
48
48
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
49
49
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
50
50
|
//Only supporting string/number arrays for now
|
|
@@ -60,9 +60,9 @@ function MultiInput(props) {
|
|
|
60
60
|
return (React.createElement(React.Fragment, null,
|
|
61
61
|
fieldArray.length === 0 ?
|
|
62
62
|
React.createElement(React.Fragment, null,
|
|
63
|
-
React.createElement("label", { className: 'd-flex align-items-center'
|
|
63
|
+
React.createElement("label", { className: 'd-flex align-items-center' }, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field,
|
|
64
64
|
props.Help != null ?
|
|
65
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
65
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid.current },
|
|
66
66
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
67
67
|
: null,
|
|
68
68
|
React.createElement("button", { className: 'btn', onClick: function () {
|
|
@@ -72,7 +72,7 @@ function MultiInput(props) {
|
|
|
72
72
|
" ",
|
|
73
73
|
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null),
|
|
74
74
|
" ")),
|
|
75
|
-
React.createElement(
|
|
75
|
+
React.createElement(ToolTip_1.default, { Show: showHelp && props.Help != null, Target: guid.current, Class: "info", Position: "bottom" }, props.Help))
|
|
76
76
|
: null,
|
|
77
77
|
fieldArray.map(function (r, index) {
|
|
78
78
|
var _a, _b;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
26
26
|
var React = require("react");
|
|
27
|
-
var
|
|
27
|
+
var ToolTip_1 = require("./ToolTip");
|
|
28
28
|
var react_portal_1 = require("react-portal");
|
|
29
29
|
var _ = require("lodash");
|
|
30
30
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
@@ -38,6 +38,7 @@ var MultiSelect = function (props) {
|
|
|
38
38
|
var _c = React.useState(false), showHelp = _c[0], setShowHelp = _c[1];
|
|
39
39
|
var _d = React.useState(false), showItems = _d[0], setShowItems = _d[1];
|
|
40
40
|
var _e = React.useState(""), guid = _e[0], setGuid = _e[1];
|
|
41
|
+
var helperGuid = React.useState("")[0];
|
|
41
42
|
var showLabel = React.useMemo(function () { return props.Label !== ""; }, [props.Label]);
|
|
42
43
|
var showHelpIcon = React.useMemo(function () { return props.Help !== undefined; }, [props.Help]);
|
|
43
44
|
var selectedOptions = React.useMemo(function () { return props.Options.filter(function (opt) { return opt.Selected; }); }, [props.Options]);
|
|
@@ -98,20 +99,20 @@ var MultiSelect = function (props) {
|
|
|
98
99
|
showLabel ?
|
|
99
100
|
(props.Label === undefined ? 'Select' : props.Label) : '',
|
|
100
101
|
showHelpIcon ?
|
|
101
|
-
React.createElement("button", { className: 'btn btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
102
|
+
React.createElement("button", { className: 'btn btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": helperGuid },
|
|
102
103
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
103
104
|
: null) : null,
|
|
104
105
|
showHelpIcon ?
|
|
105
|
-
React.createElement(
|
|
106
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: helperGuid, Class: "info", Position: "bottom" }, props.Help)
|
|
106
107
|
: null,
|
|
107
108
|
((_a = props.ItemTooltip) !== null && _a !== void 0 ? _a : 'no-tip') !== 'no-tip' ?
|
|
108
|
-
React.createElement(
|
|
109
|
+
React.createElement(ToolTip_1.default, { Show: showItems, Target: guid, Position: "bottom" },
|
|
109
110
|
React.createElement("p", null, "Selected Options:"),
|
|
110
111
|
selectedOptions.slice(0, 10).map(function (opt) { return React.createElement("p", null, opt.Text); }),
|
|
111
112
|
selectedOptions.length > 10 ? React.createElement("p", null, "and ".concat(selectedOptions.length - 10, " other(s)")) : null)
|
|
112
113
|
: null,
|
|
113
114
|
React.createElement("div", { ref: multiSelect, style: { position: 'relative', display: 'block', width: 'inherit' } },
|
|
114
|
-
React.createElement("button", { "data-
|
|
115
|
+
React.createElement("button", { "data-tooltip": guid, type: "button", style: { padding: '.375rem .75rem', fontSize: '1rem', color: 'currentColor', backgroundColor: 'inherit' }, className: "btn border form-control dropdown-toggle", onClick: HandleShow, onMouseEnter: function () { return setShowItems(true); }, onMouseLeave: function () { return setShowItems(false); } },
|
|
115
116
|
props.Options.filter(function (x) { return x.Selected; }).length !== props.Options.length ? props.Options.filter(function (x) { return x.Selected; }).length : 'All ',
|
|
116
117
|
' ',
|
|
117
118
|
" Selected"),
|
package/lib/RadioButtons.js
CHANGED
|
@@ -36,20 +36,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.default = RadioButtons;
|
|
37
37
|
var React = require("react");
|
|
38
38
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
-
var
|
|
39
|
+
var ToolTip_1 = require("./ToolTip");
|
|
40
40
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
41
|
function RadioButtons(props) {
|
|
42
42
|
var _a;
|
|
43
43
|
var guid = React.useRef((0, helper_functions_1.CreateGuid)());
|
|
44
44
|
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
45
45
|
var showHelpIcon = props.Help !== undefined;
|
|
46
|
-
return (React.createElement("div", { className: "form-group"
|
|
46
|
+
return (React.createElement("div", { className: "form-group" },
|
|
47
47
|
React.createElement("label", { className: "form-check-label w-100 d-flex align-items-center" }, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field,
|
|
48
48
|
showHelpIcon ?
|
|
49
49
|
React.createElement(React.Fragment, null,
|
|
50
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
50
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid.current },
|
|
51
51
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 })),
|
|
52
|
-
React.createElement(
|
|
52
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid.current, Class: "info", Position: "bottom" }, props.Help))
|
|
53
53
|
: null),
|
|
54
54
|
props.Options.map(function (option, index) {
|
|
55
55
|
var _a;
|
package/lib/SearchableSelect.js
CHANGED
|
@@ -64,7 +64,7 @@ function SearchableSelect(props) {
|
|
|
64
64
|
handle.then(function (d) {
|
|
65
65
|
setResults(d.map(function (o) { return ({ Value: o.Value, Element: o.Label }); }));
|
|
66
66
|
setLoading(false);
|
|
67
|
-
});
|
|
67
|
+
}).catch(function () { return setLoading(false); });
|
|
68
68
|
return callback;
|
|
69
69
|
}, [search]);
|
|
70
70
|
var handleOnBlur = React.useCallback(function () {
|
package/lib/Select.js
CHANGED
|
@@ -37,7 +37,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.default = Select;
|
|
39
39
|
var React = require("react");
|
|
40
|
-
var
|
|
40
|
+
var ToolTip_1 = require("./ToolTip");
|
|
41
41
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
42
42
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
43
43
|
function Select(props) {
|
|
@@ -84,13 +84,13 @@ function Select(props) {
|
|
|
84
84
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
85
85
|
showLabel ? label : '',
|
|
86
86
|
showHelpIcon ?
|
|
87
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
87
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
88
88
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
89
89
|
: null) : null,
|
|
90
90
|
showHelpIcon ?
|
|
91
|
-
React.createElement(
|
|
91
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
92
92
|
: null,
|
|
93
|
-
React.createElement("select", {
|
|
93
|
+
React.createElement("select", { className: "form-control", onChange: function (evt) { return SetRecord(evt.target.value); }, value: GetRecordValue(), disabled: props.Disabled == null ? false : props.Disabled },
|
|
94
94
|
((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : false) ? React.createElement("option", { value: "" }, props.EmptyLabel !== undefined ? props.EmptyLabel : '') : null,
|
|
95
95
|
props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
|
|
96
96
|
}
|
package/lib/StylableSelect.d.ts
CHANGED
|
@@ -16,10 +16,10 @@ interface IProps<T> {
|
|
|
16
16
|
Field: keyof T;
|
|
17
17
|
/**
|
|
18
18
|
* Label to display for the form, defaults to the Field prop
|
|
19
|
-
* @type {string}
|
|
19
|
+
* @type {string | JSX.Element}
|
|
20
20
|
* @optional
|
|
21
21
|
*/
|
|
22
|
-
Label?: string;
|
|
22
|
+
Label?: string | JSX.Element;
|
|
23
23
|
/**
|
|
24
24
|
* Help message or element to display
|
|
25
25
|
* @type {string | JSX.Element}
|
package/lib/StylableSelect.js
CHANGED
|
@@ -35,7 +35,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.default = StylableSelect;
|
|
37
37
|
var React = require("react");
|
|
38
|
-
var
|
|
38
|
+
var ToolTip_1 = require("./ToolTip");
|
|
39
39
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
40
|
var lodash_1 = require("lodash");
|
|
41
41
|
var react_portal_1 = require("react-portal");
|
|
@@ -122,13 +122,13 @@ function StylableSelect(props) {
|
|
|
122
122
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
123
123
|
props.Label === undefined ? props.Field : props.Label,
|
|
124
124
|
props.Help !== undefined ?
|
|
125
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
125
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
126
126
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
127
127
|
: null) : null,
|
|
128
128
|
props.Help !== undefined ?
|
|
129
|
-
React.createElement(
|
|
129
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
130
130
|
: null,
|
|
131
|
-
React.createElement("button", { type: "button", style: __assign({ border: '1px solid #ced4da', padding: '.375rem .75rem', fontSize: '1rem', borderRadius: '.25rem' }, ((_a = props.BtnStyle) !== null && _a !== void 0 ? _a : {})),
|
|
131
|
+
React.createElement("button", { type: "button", style: __assign({ border: '1px solid #ced4da', padding: '.375rem .75rem', fontSize: '1rem', borderRadius: '.25rem' }, ((_a = props.BtnStyle) !== null && _a !== void 0 ? _a : {})), className: "btn form-control dropdown-toggle", onClick: HandleShow, disabled: props.Disabled === undefined ? false : props.Disabled },
|
|
132
132
|
React.createElement("div", { style: props.Style }, selected)),
|
|
133
133
|
React.createElement(react_portal_1.Portal, null,
|
|
134
134
|
React.createElement("div", { ref: tableContainer, className: 'popover', style: {
|
|
@@ -140,7 +140,7 @@ function StylableSelect(props) {
|
|
|
140
140
|
zIndex: 9999,
|
|
141
141
|
top: "".concat(position.Top, "px"),
|
|
142
142
|
left: "".concat(position.Left, "px"),
|
|
143
|
-
|
|
143
|
+
minWidth: "".concat(position.Width, "px"),
|
|
144
144
|
maxWidth: '100%'
|
|
145
145
|
} },
|
|
146
146
|
React.createElement("table", { className: "table table-hover", style: { margin: 0 }, ref: selectTable },
|
package/lib/TextArea.js
CHANGED
|
@@ -38,7 +38,7 @@ exports.default = TextArea;
|
|
|
38
38
|
// ******************************************************************************************************
|
|
39
39
|
var React = require("react");
|
|
40
40
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
41
|
-
var
|
|
41
|
+
var ToolTip_1 = require("./ToolTip");
|
|
42
42
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
43
43
|
function TextArea(props) {
|
|
44
44
|
// Internal ref and state hooks for managing the component state.
|
|
@@ -64,16 +64,16 @@ function TextArea(props) {
|
|
|
64
64
|
var showLabel = props.Label !== "";
|
|
65
65
|
var showHelpIcon = props.Help !== undefined;
|
|
66
66
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
67
|
-
return (React.createElement("div", { className: "form-group"
|
|
67
|
+
return (React.createElement("div", { className: "form-group" },
|
|
68
68
|
showHelpIcon || showLabel ?
|
|
69
69
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
70
70
|
showLabel ? label : '',
|
|
71
71
|
showHelpIcon ?
|
|
72
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
72
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid.current },
|
|
73
73
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 }))
|
|
74
74
|
: null) : null,
|
|
75
75
|
showHelpIcon ?
|
|
76
|
-
React.createElement(
|
|
76
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid.current, Class: "info", Position: "bottom" }, props.Help)
|
|
77
77
|
: null,
|
|
78
78
|
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 }),
|
|
79
79
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
|
package/lib/TimePicker.js
CHANGED
|
@@ -35,7 +35,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.default = DatePicker;
|
|
37
37
|
var React = require("react");
|
|
38
|
-
var
|
|
38
|
+
var ToolTip_1 = require("./ToolTip");
|
|
39
39
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
40
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
41
|
function DatePicker(props) {
|
|
@@ -46,10 +46,10 @@ function DatePicker(props) {
|
|
|
46
46
|
(props.Help != null || props.Label !== "") ?
|
|
47
47
|
React.createElement("label", { className: 'd-flex align-items-center' }, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field,
|
|
48
48
|
props.Help != null ?
|
|
49
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
49
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid.current },
|
|
50
50
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 })) : React.createElement(React.Fragment, null))
|
|
51
51
|
: React.createElement(React.Fragment, null),
|
|
52
|
-
React.createElement(
|
|
52
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid.current, Class: "info", Position: "bottom" }, props.Help),
|
|
53
53
|
React.createElement("input", { className: 'form-control' + (props.Valid(props.Field) ? '' : ' is-invalid'), type: "time", step: props.Step === null ? 60 : props.Step, onChange: function (evt) {
|
|
54
54
|
var record = __assign({}, props.Record);
|
|
55
55
|
if (evt.target.value !== '')
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -36,14 +36,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.default = ToggleSwitch;
|
|
37
37
|
var React = require("react");
|
|
38
38
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
-
var
|
|
39
|
+
var ToolTip_1 = require("./ToolTip");
|
|
40
40
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
41
|
function ToggleSwitch(props) {
|
|
42
42
|
var helpID = React.useRef((0, helper_functions_1.CreateGuid)());
|
|
43
43
|
var switchID = React.useRef((0, helper_functions_1.CreateGuid)());
|
|
44
44
|
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
45
45
|
var showHelpIcon = props.Help !== undefined;
|
|
46
|
-
return (React.createElement("div", { className: "custom-control custom-switch",
|
|
46
|
+
return (React.createElement("div", { className: "custom-control custom-switch", style: props.Style },
|
|
47
47
|
React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
|
|
48
48
|
var record = __assign({}, props.Record);
|
|
49
49
|
record[props.Field] = evt.target.checked;
|
|
@@ -53,8 +53,8 @@ function ToggleSwitch(props) {
|
|
|
53
53
|
props.Label == null ? props.Field : props.Label,
|
|
54
54
|
showHelpIcon ?
|
|
55
55
|
React.createElement(React.Fragment, null,
|
|
56
|
-
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } },
|
|
56
|
+
React.createElement("button", { className: 'btn mb-1 pt-0 pb-0', onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": helpID.current },
|
|
57
57
|
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: 'var(--info)', Size: 20 })),
|
|
58
|
-
React.createElement(
|
|
58
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: helpID.current, Zindex: 9999, Class: "info", Position: "bottom" }, props.Help))
|
|
59
59
|
: null)));
|
|
60
60
|
}
|
package/lib/ToolTip.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps {
|
|
3
|
+
Show: boolean;
|
|
4
|
+
Position?: ('top' | 'bottom' | 'left' | 'right');
|
|
5
|
+
Target?: string;
|
|
6
|
+
Zindex?: number;
|
|
7
|
+
Class?: 'primary' | 'secondary' | 'success' | 'danger' | 'info';
|
|
8
|
+
}
|
|
9
|
+
export declare const Tooltip: React.FunctionComponent<IProps>;
|
|
10
|
+
export default Tooltip;
|
package/lib/ToolTip.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// ToolTip.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/14/2021 - Christoph Lackner
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
// ******************************************************************************************************
|
|
23
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
24
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
25
|
+
return cooked;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.Tooltip = void 0;
|
|
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
|
+
// The styled tooltip wrapper component.
|
|
35
|
+
var PopoverDiv = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & {\n display: inline-block;\n font-size: 13px;\n position: fixed;\n pointer-events: none;\n transition: opacity 0.3s ease-out;\n z-index: ", ";\n opacity: ", ";\n top: ", ";\n left: ", ";\n max-width: 100%;\n background-color: ", ";\n color: ", ";\n border: ", ";\n padding: 0.1em;\n }\n"], ["\n & {\n display: inline-block;\n font-size: 13px;\n position: fixed;\n pointer-events: none;\n transition: opacity 0.3s ease-out;\n z-index: ", ";\n opacity: ", ";\n top: ", ";\n left: ", ";\n max-width: 100%;\n background-color: ", ";\n color: ", ";\n border: ", ";\n padding: 0.1em;\n }\n"])), function (props) { return props.Zindex; }, function (props) { return props.Show ? "0.9" : "0"; }, function (props) { return "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); }, function (props) { return props.BgColor; }, function (props) { return props.Color; }, function (props) { return "1px solid ".concat(props.Color); });
|
|
36
|
+
//Arrow needs to be a styled div as the arrow class has pseduo elements
|
|
37
|
+
var Arrow = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &.arrow {\n ", "\n &::after {\n content: '';\n position: absolute;\n ", "\n ", "\n ", "\n ", "\n }\n }\n"], ["\n &.arrow {\n ", "\n &::after {\n content: '';\n position: absolute;\n ", "\n ", "\n ", "\n ", "\n }\n }\n"])), function (props) { return (props.Position === 'left' || props.Position === 'right')
|
|
38
|
+
? "top: calc(".concat(props.ArrowPositionPercent, "% - 1em);")
|
|
39
|
+
: "left: calc(".concat(props.ArrowPositionPercent, "% - 1em);"); }, function (props) { return props.Position === 'top' && "border-top-color: ".concat(props.BackgroundColor, ";"); }, function (props) { return props.Position === 'bottom' && "border-bottom-color: ".concat(props.BackgroundColor, ";"); }, function (props) { return props.Position === 'left' && "border-left-color: ".concat(props.BackgroundColor, ";"); }, function (props) { return props.Position === 'right' && "border-right-color: ".concat(props.BackgroundColor, ";"); });
|
|
40
|
+
var defaultTargetPosition = { Top: -999, Left: -999, Width: 0, Height: 0 };
|
|
41
|
+
// The other element needs to have data-tooltip attribute equal the target prop used for positioning
|
|
42
|
+
var Tooltip = function (props) {
|
|
43
|
+
var _a;
|
|
44
|
+
var position = (_a = props.Position) !== null && _a !== void 0 ? _a : 'top';
|
|
45
|
+
var toolTip = React.useRef(null);
|
|
46
|
+
var _b = React.useState(0), top = _b[0], setTop = _b[1];
|
|
47
|
+
var _c = React.useState(0), left = _c[0], setLeft = _c[1];
|
|
48
|
+
var _d = React.useState(50), arrowPositionPercent = _d[0], setArrowPositionPercent = _d[1];
|
|
49
|
+
var _e = React.useState(defaultTargetPosition), targetPosition = _e[0], setTargetPosition = _e[1];
|
|
50
|
+
var alertRef = React.useRef(null);
|
|
51
|
+
var _f = React.useState('green'), backgroundColor = _f[0], setBackgroundColor = _f[1];
|
|
52
|
+
var _g = React.useState('red'), color = _g[0], setColor = _g[1];
|
|
53
|
+
var alarmClass = React.useMemo(function () { return props.Class != null ? "alert-".concat(props.Class, " d-none") : 'popover d-none'; }, [props.Class]);
|
|
54
|
+
React.useLayoutEffect(function () {
|
|
55
|
+
if (alertRef.current == null)
|
|
56
|
+
return;
|
|
57
|
+
var style = getComputedStyle(alertRef.current);
|
|
58
|
+
setBackgroundColor(style.backgroundColor);
|
|
59
|
+
setColor(style.color);
|
|
60
|
+
});
|
|
61
|
+
React.useEffect(function () {
|
|
62
|
+
var target = document.querySelectorAll("[data-tooltip".concat(props.Target === undefined ? '' : "=\"".concat(props.Target, "\""), "]"));
|
|
63
|
+
if (target.length === 0) {
|
|
64
|
+
setTargetPosition(defaultTargetPosition);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var targetLocation = (0, helper_functions_1.GetNodeSize)(target[0]);
|
|
68
|
+
var newPosition = { Height: targetLocation.height, Top: targetLocation.top, Left: targetLocation.left, Width: targetLocation.width };
|
|
69
|
+
if (!(0, lodash_1.isEqual)(newPosition, targetPosition))
|
|
70
|
+
setTargetPosition(newPosition);
|
|
71
|
+
}, [props.Show, props.Target, targetPosition]);
|
|
72
|
+
React.useLayoutEffect(function () {
|
|
73
|
+
var _a = getPosition(toolTip, targetPosition, position), t = _a[0], l = _a[1], arrowLeft = _a[2];
|
|
74
|
+
setTop(t);
|
|
75
|
+
setLeft(l);
|
|
76
|
+
setArrowPositionPercent(arrowLeft);
|
|
77
|
+
}, [targetPosition, props === null || props === void 0 ? void 0 : props.children, position]);
|
|
78
|
+
var zIndex = (props.Zindex === undefined ? 9999 : props.Zindex);
|
|
79
|
+
return (React.createElement(React.Fragment, null,
|
|
80
|
+
React.createElement("div", { className: alarmClass, ref: alertRef }),
|
|
81
|
+
React.createElement(react_portal_1.Portal, null,
|
|
82
|
+
React.createElement(PopoverDiv, { className: "popover bs-popover-".concat(position), Show: props.Show, Top: top, Left: left, ref: toolTip, Zindex: zIndex, BgColor: backgroundColor, Color: color },
|
|
83
|
+
React.createElement(Arrow, { className: 'arrow', Position: position, ArrowPositionPercent: arrowPositionPercent, BackgroundColor: backgroundColor, Color: color }),
|
|
84
|
+
React.createElement("div", { className: 'popover-body', style: { backgroundColor: backgroundColor, color: color } }, props.children)))));
|
|
85
|
+
};
|
|
86
|
+
exports.Tooltip = Tooltip;
|
|
87
|
+
//Helper function
|
|
88
|
+
var getPosition = function (toolTip, targetPosition, position) {
|
|
89
|
+
if (toolTip.current === null)
|
|
90
|
+
return [-999, -999];
|
|
91
|
+
var tipLocation = (0, helper_functions_1.GetNodeSize)(toolTip.current);
|
|
92
|
+
var offset = 5;
|
|
93
|
+
var top = 0;
|
|
94
|
+
var left = 0;
|
|
95
|
+
var windowWidth = window.innerWidth;
|
|
96
|
+
if (position === 'left') {
|
|
97
|
+
top = targetPosition.Top + 0.5 * targetPosition.Height - 0.5 * tipLocation.height;
|
|
98
|
+
left = targetPosition.Left - tipLocation.width - offset;
|
|
99
|
+
}
|
|
100
|
+
else if (position === 'right') {
|
|
101
|
+
top = targetPosition.Top + 0.5 * targetPosition.Height - 0.5 * tipLocation.height;
|
|
102
|
+
left = targetPosition.Left + targetPosition.Width + offset;
|
|
103
|
+
}
|
|
104
|
+
else if (position === 'top' || position === undefined) {
|
|
105
|
+
top = targetPosition.Top - tipLocation.height - offset;
|
|
106
|
+
left = targetPosition.Left + 0.5 * targetPosition.Width - 0.5 * tipLocation.width;
|
|
107
|
+
// If tooltip goes beyond right viewport boundary adjust left position to fit
|
|
108
|
+
if (left + tipLocation.width > windowWidth)
|
|
109
|
+
left = windowWidth - tipLocation.width - offset;
|
|
110
|
+
// If tooltip goes beyond left viewport boundary adjust left position to fit
|
|
111
|
+
if (left < 0)
|
|
112
|
+
left = offset;
|
|
113
|
+
}
|
|
114
|
+
else if (position === 'bottom') {
|
|
115
|
+
top = targetPosition.Top + targetPosition.Height + offset;
|
|
116
|
+
left = targetPosition.Left + 0.5 * targetPosition.Width - 0.5 * tipLocation.width;
|
|
117
|
+
//If tooltip goes beyond right viewport boundary adjust left position to fit
|
|
118
|
+
if (left + tipLocation.width >= windowWidth)
|
|
119
|
+
left = windowWidth - tipLocation.width - offset;
|
|
120
|
+
//If tooltip goes beyond left viewport boundary adjust left position to fit
|
|
121
|
+
if (left <= 0)
|
|
122
|
+
left = offset;
|
|
123
|
+
}
|
|
124
|
+
var arrowPositionPercent = 50; // Default to center
|
|
125
|
+
if (position === 'top' || position === 'bottom') {
|
|
126
|
+
var targetCenter = targetPosition.Left + 0.5 * targetPosition.Width;
|
|
127
|
+
arrowPositionPercent = ((targetCenter - left) / tipLocation.width) * 100;
|
|
128
|
+
}
|
|
129
|
+
else if (position === 'left' || position === 'right') {
|
|
130
|
+
var targetCenter = targetPosition.Top + 0.5 * targetPosition.Height;
|
|
131
|
+
arrowPositionPercent = ((targetCenter - top) / tipLocation.height) * 100;
|
|
132
|
+
}
|
|
133
|
+
return [top, left, arrowPositionPercent];
|
|
134
|
+
};
|
|
135
|
+
exports.default = exports.Tooltip;
|
|
136
|
+
var templateObject_1, templateObject_2;
|
package/lib/index.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ import InputWithButton from './InputWithButton';
|
|
|
18
18
|
import RadioButtons from './RadioButtons';
|
|
19
19
|
import FileUpload from './FileUpload';
|
|
20
20
|
import MultiInput from './MultiInput';
|
|
21
|
-
|
|
21
|
+
import ToolTip from './ToolTip';
|
|
22
|
+
export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect, ToggleSwitch, InputWithButton, RadioButtons, FileUpload, MultiInput, ToolTip };
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
//
|
|
23
23
|
// ******************************************************************************************************
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.MultiInput = exports.FileUpload = exports.RadioButtons = exports.InputWithButton = exports.ToggleSwitch = exports.SearchableSelect = exports.ColorPicker = exports.StylableSelect = exports.TimePicker = exports.DoubleInput = exports.MultiCheckBoxSelect = exports.ArrayCheckBoxes = exports.ArrayMultiSelect = exports.EnumCheckBoxes = exports.DateRangePicker = exports.TextArea = exports.Select = exports.DatePicker = exports.Input = exports.CheckBox = void 0;
|
|
25
|
+
exports.ToolTip = exports.MultiInput = exports.FileUpload = exports.RadioButtons = exports.InputWithButton = exports.ToggleSwitch = exports.SearchableSelect = exports.ColorPicker = exports.StylableSelect = exports.TimePicker = exports.DoubleInput = exports.MultiCheckBoxSelect = exports.ArrayCheckBoxes = exports.ArrayMultiSelect = exports.EnumCheckBoxes = exports.DateRangePicker = exports.TextArea = exports.Select = exports.DatePicker = exports.Input = exports.CheckBox = void 0;
|
|
26
26
|
var CheckBox_1 = require("./CheckBox");
|
|
27
27
|
exports.CheckBox = CheckBox_1.default;
|
|
28
28
|
var Input_1 = require("./Input");
|
|
@@ -63,3 +63,5 @@ var FileUpload_1 = require("./FileUpload");
|
|
|
63
63
|
exports.FileUpload = FileUpload_1.default;
|
|
64
64
|
var MultiInput_1 = require("./MultiInput");
|
|
65
65
|
exports.MultiInput = MultiInput_1.default;
|
|
66
|
+
var ToolTip_1 = require("./ToolTip");
|
|
67
|
+
exports.ToolTip = ToolTip_1.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpa-gemstone/react-forms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.83",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "5.5.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@gpa-gemstone/application-typings": "0.0.
|
|
49
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.82",
|
|
49
|
+
"@gpa-gemstone/gpa-symbols": "0.0.48",
|
|
50
50
|
"@gpa-gemstone/helper-functions": "0.0.37",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|
package/lib/HelperMessage.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
/**
|
|
21
|
-
* HelperMessage Component.
|
|
22
|
-
* Displays a floating message box.
|
|
23
|
-
*/
|
|
24
|
-
declare const HelperMessage: React.FunctionComponent<IProps>;
|
|
25
|
-
export default HelperMessage;
|
package/lib/HelperMessage.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
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 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 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) { return "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); }, function (props) { return "".concat(props.Width, "px"); }, function (props) { return "\n &::before {\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 8px solid var(--info);\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 "); });
|
|
41
|
-
/**
|
|
42
|
-
* HelperMessage Component.
|
|
43
|
-
* Displays a floating message box.
|
|
44
|
-
*/
|
|
45
|
-
var HelperMessage = function (props) {
|
|
46
|
-
var helpMessage = React.useRef(null);
|
|
47
|
-
// State variables for positioning and sizing the helper message.
|
|
48
|
-
var _a = React.useState(0), top = _a[0], setTop = _a[1];
|
|
49
|
-
var _b = React.useState(0), left = _b[0], setLeft = _b[1];
|
|
50
|
-
// State variables for the target element's position and size.
|
|
51
|
-
var _c = React.useState({ Top: -999, Left: -999, Width: 0, Height: 0 }), targetPosition = _c[0], setTargetPosition = _c[1];
|
|
52
|
-
// Effect for updating the target element's position and size.
|
|
53
|
-
React.useEffect(function () {
|
|
54
|
-
var target = document.querySelectorAll("[data-help".concat(props.Target === undefined ? '' : "=\"".concat(props.Target, "\""), "]"));
|
|
55
|
-
if (target.length === 0) {
|
|
56
|
-
setTargetPosition({ Height: 0, Top: -999, Left: -999, Width: 0 });
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
var targetLocation = (0, helper_functions_1.GetNodeSize)(target[0]);
|
|
60
|
-
var newPosition = { Height: targetLocation.height, Top: targetLocation.top, Left: targetLocation.left, Width: targetLocation.width };
|
|
61
|
-
if (!(0, lodash_1.isEqual)(newPosition, targetPosition))
|
|
62
|
-
setTargetPosition(newPosition);
|
|
63
|
-
}, [props.Show]);
|
|
64
|
-
React.useLayoutEffect(function () {
|
|
65
|
-
var _a = UpdatePosition(helpMessage, targetPosition), t = _a[0], l = _a[1];
|
|
66
|
-
setTop(t);
|
|
67
|
-
setLeft(l);
|
|
68
|
-
}, [targetPosition]);
|
|
69
|
-
var zIndex = (props.Zindex === undefined ? 9999 : props.Zindex);
|
|
70
|
-
return (React.createElement(react_portal_1.Portal, null,
|
|
71
|
-
React.createElement(WrapperDiv, { className: 'bg-info', Show: props.Show, Top: top, Left: left, ref: helpMessage, Zindex: zIndex, TargetLeft: targetPosition.Left, TargetWidth: targetPosition.Width, Width: targetPosition.Width }, props.children)));
|
|
72
|
-
};
|
|
73
|
-
var UpdatePosition = function (helpMessage, targetPosition) {
|
|
74
|
-
if (helpMessage.current === null)
|
|
75
|
-
return [-999, -999];
|
|
76
|
-
var offset = 5;
|
|
77
|
-
var windowWidth = window.innerWidth;
|
|
78
|
-
var top = targetPosition.Top + targetPosition.Height + offset;
|
|
79
|
-
var left = targetPosition.Left;
|
|
80
|
-
var width = targetPosition.Width;
|
|
81
|
-
// If tooltip goes beyond the right viewport boundary, adjust the left position to fit
|
|
82
|
-
if (left + width >= windowWidth)
|
|
83
|
-
left = windowWidth - width - offset;
|
|
84
|
-
// If tooltip goes beyond the left viewport boundary, adjust the left position to fit
|
|
85
|
-
if (left <= 0)
|
|
86
|
-
left = offset;
|
|
87
|
-
return [top, left, width];
|
|
88
|
-
};
|
|
89
|
-
exports.default = HelperMessage;
|
|
90
|
-
var templateObject_1;
|