@gpa-gemstone/react-forms 1.1.82 → 1.1.84
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 +8 -9
- package/lib/DatePicker.js +8 -7
- package/lib/Input.js +8 -9
- package/lib/InputWithButton.js +8 -6
- package/lib/MultiInput.js +7 -6
- package/lib/MutliCheckBoxSelect.js +9 -8
- package/lib/RadioButtons.js +11 -9
- package/lib/SearchableSelect.js +1 -1
- package/lib/Select.js +10 -15
- package/lib/StylableSelect.d.ts +2 -2
- package/lib/StylableSelect.js +14 -10
- package/lib/TextArea.js +9 -10
- package/lib/TimePicker.js +14 -11
- package/lib/ToggleSwitch.js +12 -10
- 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 +4 -4
- 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,20 +48,19 @@ 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;
|
|
55
55
|
props.Setter(record);
|
|
56
56
|
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled }),
|
|
57
57
|
showHelpIcon || showLabel ?
|
|
58
|
-
React.createElement("label", { className:
|
|
59
|
-
showLabel ? label : '',
|
|
60
|
-
showHelpIcon
|
|
61
|
-
React.createElement(
|
|
62
|
-
|
|
63
|
-
: null) : null,
|
|
58
|
+
React.createElement("label", { className: "form-check-label d-flex align-items-center" },
|
|
59
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
60
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
61
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
62
|
+
: null,
|
|
64
63
|
showHelpIcon ?
|
|
65
|
-
React.createElement(
|
|
64
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
66
65
|
: null));
|
|
67
66
|
}
|
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.
|
|
@@ -216,14 +216,15 @@ function DateTimePicker(props) {
|
|
|
216
216
|
}
|
|
217
217
|
return (React.createElement("div", { className: "form-group", ref: divRef },
|
|
218
218
|
showHelpIcon || showLabel ?
|
|
219
|
-
React.createElement("label", { className:
|
|
220
|
-
showLabel ? label : '',
|
|
221
|
-
showHelpIcon
|
|
222
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
219
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
220
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
221
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
222
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
223
|
+
: null,
|
|
223
224
|
showHelpIcon ?
|
|
224
|
-
React.createElement(
|
|
225
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
225
226
|
: null,
|
|
226
|
-
React.createElement("input", {
|
|
227
|
+
React.createElement("input", { className: "gpa-gemstone-datetime form-control ".concat(IsValid() ? '' : 'is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
|
|
227
228
|
valueChange(evt.target.value);
|
|
228
229
|
}, onFocus: function () { setShowOverlay(true); }, value: boxRecord, disabled: props.Disabled === undefined ? false : props.Disabled, onClick: function (e) { e.preventDefault(); }, step: step }),
|
|
229
230
|
React.createElement("div", { className: "invalid-feedback" }, getFeedbackMessage()),
|
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) {
|
|
@@ -104,15 +104,14 @@ function Input(props) {
|
|
|
104
104
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
105
105
|
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.Style },
|
|
106
106
|
showHelpIcon || showLabel ?
|
|
107
|
-
React.createElement("label", { className:
|
|
108
|
-
showLabel ? label : '',
|
|
109
|
-
showHelpIcon
|
|
110
|
-
React.createElement(
|
|
111
|
-
|
|
112
|
-
: null) : null,
|
|
107
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
108
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
109
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
110
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
111
|
+
: null,
|
|
113
112
|
showHelpIcon ?
|
|
114
|
-
React.createElement(
|
|
113
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
115
114
|
: null,
|
|
116
|
-
React.createElement("input", {
|
|
115
|
+
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
116
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
118
117
|
}
|
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) {
|
|
@@ -94,15 +94,17 @@ function InputWithButton(props) {
|
|
|
94
94
|
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.InputStyle },
|
|
95
95
|
showHelpIcon || showLabel ?
|
|
96
96
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
97
|
-
showLabel ? label : '',
|
|
97
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
98
98
|
showHelpIcon ?
|
|
99
|
-
React.createElement("
|
|
100
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
99
|
+
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
100
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))
|
|
101
|
+
: null)
|
|
102
|
+
: null,
|
|
101
103
|
showHelpIcon ?
|
|
102
|
-
React.createElement(
|
|
104
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
103
105
|
: null,
|
|
104
106
|
React.createElement("div", { className: "input-group" },
|
|
105
|
-
React.createElement("input", {
|
|
107
|
+
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
108
|
React.createElement("div", { className: "input-group-prepend" },
|
|
107
109
|
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
110
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback))));
|
package/lib/MultiInput.js
CHANGED
|
@@ -44,13 +44,13 @@ 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
|
|
51
51
|
function MultiInput(props) {
|
|
52
52
|
var _a;
|
|
53
|
-
var guid = React.
|
|
53
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
54
54
|
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
55
55
|
var fieldArray = props.Record[props.Field];
|
|
56
56
|
if ((fieldArray === null || fieldArray === void 0 ? void 0 : fieldArray.constructor) !== Array) {
|
|
@@ -60,10 +60,11 @@ 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' },
|
|
64
|
+
React.createElement("span", null, (_a = props.Label) !== null && _a !== void 0 ? _a : props.Field),
|
|
64
65
|
props.Help != null ?
|
|
65
|
-
React.createElement("
|
|
66
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
66
|
+
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
67
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))
|
|
67
68
|
: null,
|
|
68
69
|
React.createElement("button", { className: 'btn', onClick: function () {
|
|
69
70
|
var _a;
|
|
@@ -72,7 +73,7 @@ function MultiInput(props) {
|
|
|
72
73
|
" ",
|
|
73
74
|
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null),
|
|
74
75
|
" ")),
|
|
75
|
-
React.createElement(
|
|
76
|
+
React.createElement(ToolTip_1.default, { Show: showHelp && props.Help != null, Target: guid, Class: "info", Position: "bottom" }, props.Help))
|
|
76
77
|
: null,
|
|
77
78
|
fieldArray.map(function (r, index) {
|
|
78
79
|
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]);
|
|
@@ -95,23 +96,23 @@ var MultiSelect = function (props) {
|
|
|
95
96
|
return (React.createElement("div", { className: "form-group" },
|
|
96
97
|
showLabel || showHelpIcon ?
|
|
97
98
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
98
|
-
showLabel ?
|
|
99
|
-
(props.Label === undefined ? 'Select' : props.Label) : '',
|
|
99
|
+
React.createElement("span", null, showLabel ?
|
|
100
|
+
(props.Label === undefined ? 'Select' : props.Label) : ''),
|
|
100
101
|
showHelpIcon ?
|
|
101
|
-
React.createElement("
|
|
102
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
102
|
+
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": helperGuid },
|
|
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,22 @@ 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
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
42
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
43
|
+
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
44
|
+
// Variables to control the rendering of label and help icon.
|
|
45
45
|
var showHelpIcon = props.Help !== undefined;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
47
|
+
return (React.createElement("div", { className: "form-group" },
|
|
48
|
+
React.createElement("label", { className: "form-check-label w-100 d-flex align-items-center" },
|
|
49
|
+
React.createElement("span", null, label),
|
|
48
50
|
showHelpIcon ?
|
|
49
51
|
React.createElement(React.Fragment, null,
|
|
50
|
-
React.createElement("
|
|
51
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
52
|
-
React.createElement(
|
|
52
|
+
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
53
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 })),
|
|
54
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help))
|
|
53
55
|
: null),
|
|
54
56
|
props.Options.map(function (option, index) {
|
|
55
57
|
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,17 +37,13 @@ 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) {
|
|
44
44
|
var _a;
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
// Effect to generate a unique ID for the component.
|
|
48
|
-
React.useEffect(function () {
|
|
49
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
50
|
-
}, []);
|
|
45
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
46
|
+
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
51
47
|
// Effect to validate the current value against the available options.
|
|
52
48
|
React.useEffect(function () {
|
|
53
49
|
var _a;
|
|
@@ -81,16 +77,15 @@ function Select(props) {
|
|
|
81
77
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
82
78
|
return (React.createElement("div", { className: "form-group" },
|
|
83
79
|
showHelpIcon || showLabel ?
|
|
84
|
-
React.createElement("label", { className:
|
|
85
|
-
showLabel ? label : '',
|
|
86
|
-
showHelpIcon
|
|
87
|
-
React.createElement(
|
|
88
|
-
|
|
89
|
-
: null) : null,
|
|
80
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
81
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
82
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
83
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
84
|
+
: null,
|
|
90
85
|
showHelpIcon ?
|
|
91
|
-
React.createElement(
|
|
86
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
92
87
|
: null,
|
|
93
|
-
React.createElement("select", {
|
|
88
|
+
React.createElement("select", { className: "form-control", onChange: function (evt) { return SetRecord(evt.target.value); }, value: GetRecordValue(), disabled: props.Disabled == null ? false : props.Disabled },
|
|
94
89
|
((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : false) ? React.createElement("option", { value: "" }, props.EmptyLabel !== undefined ? props.EmptyLabel : '') : null,
|
|
95
90
|
props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
|
|
96
91
|
}
|
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");
|
|
@@ -117,18 +117,21 @@ function StylableSelect(props) {
|
|
|
117
117
|
SetRecord(option);
|
|
118
118
|
setShow(false);
|
|
119
119
|
};
|
|
120
|
+
// Variables to control the rendering of label and help icon.
|
|
121
|
+
var showLabel = props.Label !== "";
|
|
122
|
+
var showHelpIcon = props.Help !== undefined;
|
|
123
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
120
124
|
return (React.createElement("div", { ref: stylableSelect, style: { position: 'relative', display: 'inline-block', width: 'inherit' } },
|
|
121
|
-
|
|
122
|
-
React.createElement("label", { className:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
React.createElement(
|
|
126
|
-
|
|
127
|
-
: null) : null,
|
|
125
|
+
showHelpIcon || showLabel ?
|
|
126
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
127
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
128
|
+
showHelpIcon && (React.createElement("span", { onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid, className: "ml-2 d-flex align-items-center" },
|
|
129
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
130
|
+
: null,
|
|
128
131
|
props.Help !== undefined ?
|
|
129
|
-
React.createElement(
|
|
132
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
130
133
|
: 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 : {})),
|
|
134
|
+
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
135
|
React.createElement("div", { style: props.Style }, selected)),
|
|
133
136
|
React.createElement(react_portal_1.Portal, null,
|
|
134
137
|
React.createElement("div", { ref: tableContainer, className: 'popover', style: {
|
|
@@ -140,6 +143,7 @@ function StylableSelect(props) {
|
|
|
140
143
|
zIndex: 9999,
|
|
141
144
|
top: "".concat(position.Top, "px"),
|
|
142
145
|
left: "".concat(position.Left, "px"),
|
|
146
|
+
minWidth: "".concat(position.Width, "px"),
|
|
143
147
|
maxWidth: '100%'
|
|
144
148
|
} },
|
|
145
149
|
React.createElement("table", { className: "table table-hover", style: { margin: 0 }, ref: selectTable },
|
package/lib/TextArea.js
CHANGED
|
@@ -38,12 +38,12 @@ 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.
|
|
45
45
|
var internal = React.useRef(false);
|
|
46
|
-
var guid = React.
|
|
46
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
47
47
|
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
48
48
|
var _b = React.useState(''), heldVal = _b[0], setHeldVal = _b[1];
|
|
49
49
|
// Effect to handle changes to the record's field value.
|
|
@@ -64,16 +64,15 @@ 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
|
-
React.createElement("label", { className:
|
|
70
|
-
showLabel ? label : '',
|
|
71
|
-
showHelpIcon
|
|
72
|
-
React.createElement(
|
|
73
|
-
|
|
74
|
-
: null) : null,
|
|
69
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
70
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
71
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
72
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
73
|
+
: null,
|
|
75
74
|
showHelpIcon ?
|
|
76
|
-
React.createElement(
|
|
75
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help)
|
|
77
76
|
: null,
|
|
78
77
|
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
78
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
|
package/lib/TimePicker.js
CHANGED
|
@@ -35,21 +35,24 @@ 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) {
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
42
|
+
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
43
|
+
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
44
|
+
// Variables to control the rendering of label and help icon.
|
|
45
|
+
var showLabel = props.Label !== "";
|
|
46
|
+
var showHelpIcon = props.Help !== undefined;
|
|
47
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
45
48
|
return (React.createElement("div", { className: "form-group" },
|
|
46
|
-
|
|
47
|
-
React.createElement("label", { className:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:
|
|
52
|
-
React.createElement(
|
|
49
|
+
showHelpIcon || showLabel ?
|
|
50
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
51
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
52
|
+
showHelpIcon && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
53
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
54
|
+
: null,
|
|
55
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "bottom" }, props.Help),
|
|
53
56
|
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
57
|
var record = __assign({}, props.Record);
|
|
55
58
|
if (evt.target.value !== '')
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -36,25 +36,27 @@ 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
|
-
var helpID = React.
|
|
43
|
-
var switchID = React.
|
|
42
|
+
var helpID = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
43
|
+
var switchID = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
44
44
|
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
45
|
+
// Variables to control the rendering of label and help icon.
|
|
45
46
|
var showHelpIcon = props.Help !== undefined;
|
|
46
|
-
|
|
47
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
48
|
+
return (React.createElement("div", { className: "custom-control custom-switch", style: props.Style },
|
|
47
49
|
React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
|
|
48
50
|
var record = __assign({}, props.Record);
|
|
49
51
|
record[props.Field] = evt.target.checked;
|
|
50
52
|
props.Setter(record);
|
|
51
|
-
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled, id: switchID
|
|
52
|
-
React.createElement("label", { className: "custom-control-label", htmlFor: switchID
|
|
53
|
-
|
|
53
|
+
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled, id: switchID }),
|
|
54
|
+
React.createElement("label", { className: "custom-control-label d-flex align-items-center", htmlFor: switchID },
|
|
55
|
+
React.createElement("span", null, label),
|
|
54
56
|
showHelpIcon ?
|
|
55
57
|
React.createElement(React.Fragment, null,
|
|
56
|
-
React.createElement("
|
|
57
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color:
|
|
58
|
-
React.createElement(
|
|
58
|
+
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": helpID },
|
|
59
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 })),
|
|
60
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: helpID, Zindex: 9999, Class: "info", Position: "bottom" }, props.Help))
|
|
59
61
|
: null)));
|
|
60
62
|
}
|
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.84",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
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.
|
|
50
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.83",
|
|
49
|
+
"@gpa-gemstone/gpa-symbols": "0.0.49",
|
|
50
|
+
"@gpa-gemstone/helper-functions": "0.0.38",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|
|
53
53
|
"lodash": "^4.17.21",
|
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;
|