@gpa-gemstone/react-forms 1.1.112 → 1.1.113
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/AutoCompleteInput.d.ts +24 -0
- package/lib/AutoCompleteInput.js +214 -0
- package/lib/AutoCompleteTextArea.d.ts +6 -0
- package/lib/AutoCompleteTextArea.js +151 -0
- package/lib/CheckBox.d.ts +2 -1
- package/lib/CheckBox.js +7 -20
- package/lib/ColorPicker.d.ts +2 -2
- package/lib/ColorPicker.js +13 -18
- package/lib/DateTimeUI/DateTimePicker.js +8 -15
- package/lib/HelpIcon.d.ts +29 -0
- package/lib/HelpIcon.js +44 -0
- package/lib/Input.d.ts +7 -2
- package/lib/Input.js +5 -17
- package/lib/InputWithButton.js +5 -18
- package/lib/MultiInput.js +9 -18
- package/lib/MultiSearchableSelect.js +9 -18
- package/lib/MutliCheckBoxSelect.js +5 -14
- package/lib/RadioButtons.js +2 -13
- package/lib/Select.js +3 -12
- package/lib/StylableSelect.js +3 -9
- package/lib/TextArea.d.ts +14 -2
- package/lib/TextArea.js +7 -12
- package/lib/TimePicker.js +3 -10
- package/lib/ToggleSwitch.js +2 -11
- package/lib/index.d.ts +4 -1
- package/lib/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IProps as IInputProps } from './Input';
|
|
2
|
+
interface IProps<T> extends Omit<IInputProps<T>, 'Type'> {
|
|
3
|
+
Options: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface IVariable {
|
|
6
|
+
Start: number;
|
|
7
|
+
End: number;
|
|
8
|
+
Variable: string | null;
|
|
9
|
+
}
|
|
10
|
+
export default function AutoCompleteInput<T>(props: IProps<T>): JSX.Element;
|
|
11
|
+
export declare const getSuggestions: (variable: IVariable, text: string, options: string[]) => {
|
|
12
|
+
Label: string;
|
|
13
|
+
Value: string;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const getCurrentVariable: (text: string, selection: number) => {
|
|
16
|
+
Start: number;
|
|
17
|
+
End: number;
|
|
18
|
+
Variable: null;
|
|
19
|
+
} | {
|
|
20
|
+
Start: number;
|
|
21
|
+
End: number;
|
|
22
|
+
Variable: string;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// AutoCompleteInput.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2024, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
+
//
|
|
7
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
+
//
|
|
12
|
+
// http://opensource.org/licenses/MIT
|
|
13
|
+
//
|
|
14
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
+
// License for the specific language governing permissions and limitations.
|
|
17
|
+
//
|
|
18
|
+
// Code Modification History:
|
|
19
|
+
// ----------------------------------------------------------------------------------------------------
|
|
20
|
+
// 01/21/2026 - Natalie Beatty
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.getCurrentVariable = exports.getSuggestions = void 0;
|
|
26
|
+
exports.default = AutoCompleteInput;
|
|
27
|
+
var React = require("react");
|
|
28
|
+
var Input_1 = require("./Input");
|
|
29
|
+
var react_portal_1 = require("react-portal");
|
|
30
|
+
var _ = require("lodash");
|
|
31
|
+
function AutoCompleteInput(props) {
|
|
32
|
+
var autoCompleteInput = React.useRef(null);
|
|
33
|
+
var inputElement = React.useRef(null);
|
|
34
|
+
var tableContainer = React.useRef(null);
|
|
35
|
+
var selectTable = React.useRef(null);
|
|
36
|
+
var _a = React.useState([]), suggestions = _a[0], setSuggestions = _a[1];
|
|
37
|
+
var _b = React.useState(null), position = _b[0], setPosition = _b[1];
|
|
38
|
+
var _c = React.useState(true), show = _c[0], setShow = _c[1];
|
|
39
|
+
// Handle showing and hiding of the dropdown.
|
|
40
|
+
var HandleShow = React.useCallback(function (evt) {
|
|
41
|
+
var _a;
|
|
42
|
+
// Ignore if disabled or not a mousedown event
|
|
43
|
+
if ((props.Disabled === undefined ? false : props.Disabled)
|
|
44
|
+
|| evt.type !== 'mousedown') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
//ignore the click if it was inside the table or table container
|
|
48
|
+
if ((selectTable.current != null && selectTable.current.contains(evt.target)) || (tableContainer.current != null && tableContainer.current.contains(evt.target))) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (inputElement.current !== null && !((_a = inputElement.current) === null || _a === void 0 ? void 0 : _a.contains(evt.target))) {
|
|
52
|
+
setShow(false);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setShow(true);
|
|
56
|
+
}
|
|
57
|
+
}, [props.Disabled]);
|
|
58
|
+
// update dropdown position
|
|
59
|
+
React.useLayoutEffect(function () {
|
|
60
|
+
if ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) == 0) {
|
|
61
|
+
setPosition(null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var updatePosition = _.debounce(function () {
|
|
65
|
+
if (inputElement.current == null) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var rect = inputElement.current.getBoundingClientRect();
|
|
69
|
+
setPosition({ Top: rect.bottom, Left: rect.left, Width: rect.width, Height: rect.height });
|
|
70
|
+
}, 200);
|
|
71
|
+
var handleScroll = function () {
|
|
72
|
+
if (tableContainer.current == null)
|
|
73
|
+
return;
|
|
74
|
+
updatePosition();
|
|
75
|
+
};
|
|
76
|
+
updatePosition();
|
|
77
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
78
|
+
window.addEventListener('resize', updatePosition);
|
|
79
|
+
return function () {
|
|
80
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
81
|
+
window.removeEventListener('resize', updatePosition);
|
|
82
|
+
updatePosition.cancel();
|
|
83
|
+
};
|
|
84
|
+
}, [suggestions]);
|
|
85
|
+
// listen for changes in input caret position
|
|
86
|
+
React.useEffect(function () {
|
|
87
|
+
var autoComplete = inputElement.current;
|
|
88
|
+
if (autoComplete == null)
|
|
89
|
+
return;
|
|
90
|
+
autoComplete.addEventListener("keyup", handleCaretPosition);
|
|
91
|
+
autoComplete.addEventListener("click", handleCaretPosition);
|
|
92
|
+
window.addEventListener('mousedown', HandleShow, false);
|
|
93
|
+
return function () {
|
|
94
|
+
autoComplete.removeEventListener("keyup", handleCaretPosition);
|
|
95
|
+
autoComplete.removeEventListener("click", handleCaretPosition);
|
|
96
|
+
window.removeEventListener('mousedown', HandleShow, false);
|
|
97
|
+
};
|
|
98
|
+
}, [HandleShow]);
|
|
99
|
+
// edit input text when suggestion is selected
|
|
100
|
+
var handleOptionClick = function (option) {
|
|
101
|
+
var _a, _b, _c, _d, _e;
|
|
102
|
+
if (inputElement.current == null)
|
|
103
|
+
return;
|
|
104
|
+
var currentPos = (_a = inputElement.current.selectionStart) !== null && _a !== void 0 ? _a : 0;
|
|
105
|
+
var optionLength = option.Value.length;
|
|
106
|
+
props.Record[props.Field] = option.Value;
|
|
107
|
+
props.Setter(props.Record);
|
|
108
|
+
var textLength = (_c = (_b = inputElement.current.textContent) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
109
|
+
var newCaretPos = (optionLength > textLength ? textLength - 1 : optionLength + currentPos);
|
|
110
|
+
(_d = inputElement.current) === null || _d === void 0 ? void 0 : _d.focus();
|
|
111
|
+
(_e = inputElement.current) === null || _e === void 0 ? void 0 : _e.setSelectionRange(newCaretPos, newCaretPos);
|
|
112
|
+
setSuggestions([]);
|
|
113
|
+
};
|
|
114
|
+
// update variable when caret position changes
|
|
115
|
+
var handleCaretPosition = function () {
|
|
116
|
+
var _a, _b, _c, _d, _e;
|
|
117
|
+
if (inputElement.current !== null) {
|
|
118
|
+
var selection = ((_a = inputElement.current.selectionStart) !== null && _a !== void 0 ? _a : 0);
|
|
119
|
+
var variable = (0, exports.getCurrentVariable)((_c = (_b = inputElement.current) === null || _b === void 0 ? void 0 : _b.getAttribute('value')) !== null && _c !== void 0 ? _c : "", selection);
|
|
120
|
+
var suggests = (0, exports.getSuggestions)(variable, (_e = (_d = inputElement.current) === null || _d === void 0 ? void 0 : _d.getAttribute('value')) !== null && _e !== void 0 ? _e : "", props.Options);
|
|
121
|
+
setSuggestions(suggests);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return (React.createElement("div", { ref: autoCompleteInput },
|
|
125
|
+
React.createElement(Input_1.default, { Valid: props.Valid, Record: props.Record, Setter: props.Setter, Field: props.Field, Feedback: props.Feedback, Style: props.Style, AllowNull: props.AllowNull, Size: props.Size, DefaultValue: props.DefaultValue, InputRef: inputElement }),
|
|
126
|
+
position == null || !show ? null :
|
|
127
|
+
React.createElement(react_portal_1.Portal, null,
|
|
128
|
+
React.createElement("div", { ref: tableContainer, className: 'popover', style: {
|
|
129
|
+
maxHeight: window.innerHeight - position.Top,
|
|
130
|
+
overflowY: 'auto',
|
|
131
|
+
padding: '10 5',
|
|
132
|
+
display: 'block',
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
zIndex: 9999,
|
|
135
|
+
top: "".concat(position.Top, "px"),
|
|
136
|
+
left: "".concat(position.Left, "px"),
|
|
137
|
+
minWidth: "".concat(position.Width, "px"),
|
|
138
|
+
maxWidth: '100%'
|
|
139
|
+
} },
|
|
140
|
+
React.createElement("table", { className: "table table-hover", style: { margin: 0 }, ref: selectTable },
|
|
141
|
+
React.createElement("tbody", null, suggestions.map(function (f, i) { return (f.Value === props.Record[props.Field] ? null :
|
|
142
|
+
React.createElement("tr", { key: i, onMouseDown: function (_) { return handleOptionClick(f); } },
|
|
143
|
+
React.createElement("td", null, f.Label))); })))))));
|
|
144
|
+
}
|
|
145
|
+
var getSuggestions = function (variable, text, options) {
|
|
146
|
+
if (!(variable.Variable != null)) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
// if variable is valid option and hasEndBracket, assume it doesn't need autocompletion.
|
|
150
|
+
if (options.includes(variable.Variable)) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
if (text === "") {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
// Find suggestions for the variable
|
|
157
|
+
var possibleVariables = options.filter(function (v) { var _a; return v.toLowerCase().includes(((_a = variable.Variable) !== null && _a !== void 0 ? _a : "").toLowerCase()); });
|
|
158
|
+
var before = text.substring(0, (variable.Start) - 1);
|
|
159
|
+
var after = text.substring(variable.End);
|
|
160
|
+
var hasEndBracket = (text[variable.End] === '}');
|
|
161
|
+
// Generate suggestions
|
|
162
|
+
var suggestions = possibleVariables.map(function (pv) {
|
|
163
|
+
// Ensure we have braces around the variable and add closing '}' if it was missing
|
|
164
|
+
var variableWithBraces = hasEndBracket ? "{".concat(pv) : "{".concat(pv, "}");
|
|
165
|
+
return { Label: "".concat(variableWithBraces).concat(hasEndBracket ? '}' : ''), Value: "".concat(before).concat(variableWithBraces).concat(after) };
|
|
166
|
+
});
|
|
167
|
+
return suggestions;
|
|
168
|
+
};
|
|
169
|
+
exports.getSuggestions = getSuggestions;
|
|
170
|
+
var getCurrentVariable = function (text, selection) {
|
|
171
|
+
var thisVariable = {
|
|
172
|
+
Start: 0,
|
|
173
|
+
End: 0,
|
|
174
|
+
Variable: null
|
|
175
|
+
};
|
|
176
|
+
if (text === "") {
|
|
177
|
+
return thisVariable;
|
|
178
|
+
}
|
|
179
|
+
// easy returns if selection start could not have a curly bracket before it
|
|
180
|
+
if (selection === null || selection < 0 || selection > text.length) {
|
|
181
|
+
return thisVariable;
|
|
182
|
+
}
|
|
183
|
+
// check backwards from the caret to find the nearest open curly bracket or space
|
|
184
|
+
var start = selection;
|
|
185
|
+
while (start > 0) {
|
|
186
|
+
// check for open curly bracket. if found, assign and break as start of valid variable expression
|
|
187
|
+
if (/{/g.test(text[start - 1])) {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
// if space is encountered first, return
|
|
191
|
+
if (/[\s}]/g.test(text[start - 1])) {
|
|
192
|
+
return thisVariable;
|
|
193
|
+
}
|
|
194
|
+
start--;
|
|
195
|
+
}
|
|
196
|
+
// if no variable found, return
|
|
197
|
+
if (start == 0) {
|
|
198
|
+
return thisVariable;
|
|
199
|
+
}
|
|
200
|
+
thisVariable.Start = start;
|
|
201
|
+
// then, get the rest of the word.
|
|
202
|
+
var end = start !== null && start !== void 0 ? start : 0;
|
|
203
|
+
while (end < text.length) {
|
|
204
|
+
if (/[}{\s}]/.test(text[end])) {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
end++;
|
|
208
|
+
}
|
|
209
|
+
thisVariable.End = end;
|
|
210
|
+
// get variable as substring of text
|
|
211
|
+
var variable = text.substring(start, end);
|
|
212
|
+
return { Start: thisVariable.Start, End: thisVariable.End, Variable: variable };
|
|
213
|
+
};
|
|
214
|
+
exports.getCurrentVariable = getCurrentVariable;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = AutoCompleteTextArea;
|
|
4
|
+
var React = require("react");
|
|
5
|
+
var TextArea_1 = require("./TextArea");
|
|
6
|
+
var react_portal_1 = require("react-portal");
|
|
7
|
+
var _ = require("lodash");
|
|
8
|
+
var AutoCompleteInput_1 = require("./AutoCompleteInput");
|
|
9
|
+
function AutoCompleteTextArea(props) {
|
|
10
|
+
var autoCompleteTextArea = React.useRef(null);
|
|
11
|
+
var tableContainer = React.useRef(null);
|
|
12
|
+
var selectTable = React.useRef(null);
|
|
13
|
+
var textAreaElement = React.useRef(null);
|
|
14
|
+
var _a = React.useState([]), suggestions = _a[0], setSuggestions = _a[1];
|
|
15
|
+
var _b = React.useState(null), position = _b[0], setPosition = _b[1];
|
|
16
|
+
var _c = React.useState({ Start: 0, End: 0, Variable: "" }), variable = _c[0], setVariable = _c[1];
|
|
17
|
+
var _d = React.useState(true), show = _d[0], setShow = _d[1];
|
|
18
|
+
// Handle showing and hiding of the dropdown.
|
|
19
|
+
var HandleShow = React.useCallback(function (evt) {
|
|
20
|
+
var _a;
|
|
21
|
+
// Ignore if disabled or not a mousedown event
|
|
22
|
+
if ((props.Disabled === undefined ? false : props.Disabled)
|
|
23
|
+
|| evt.type !== 'mousedown') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
//ignore the click if it was inside the table or table container
|
|
27
|
+
if ((selectTable.current != null && selectTable.current.contains(evt.target)) || (tableContainer.current != null && tableContainer.current.contains(evt.target))) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (textAreaElement.current !== null && !((_a = textAreaElement.current) === null || _a === void 0 ? void 0 : _a.contains(evt.target))) {
|
|
31
|
+
setShow(false);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setShow(true);
|
|
35
|
+
}
|
|
36
|
+
}, [props.Disabled]);
|
|
37
|
+
// add listeners to follow caret
|
|
38
|
+
React.useEffect(function () {
|
|
39
|
+
var autoComplete = textAreaElement.current;
|
|
40
|
+
if (autoComplete == null)
|
|
41
|
+
return;
|
|
42
|
+
autoComplete.addEventListener("keyup", handleCaretPosition);
|
|
43
|
+
autoComplete.addEventListener("click", handleCaretPosition);
|
|
44
|
+
return function () {
|
|
45
|
+
autoComplete.removeEventListener("keyup", handleCaretPosition);
|
|
46
|
+
autoComplete.removeEventListener("click", handleCaretPosition);
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
// set position of the suggestion dropdown
|
|
50
|
+
React.useLayoutEffect(function () {
|
|
51
|
+
if ((suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) == 0) {
|
|
52
|
+
setPosition(null);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var updatePosition = _.debounce(function () {
|
|
56
|
+
if (textAreaElement.current == null) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var rect = textAreaElement.current.getBoundingClientRect();
|
|
60
|
+
var _a = getTextDimensions(textAreaElement, variable.Start - 1, "\n"), caret_X = _a[0], caret_Y = _a[1];
|
|
61
|
+
setPosition({ Top: rect.top + caret_Y, Left: rect.left + caret_X, Width: rect.width, Height: rect.height });
|
|
62
|
+
}, 200);
|
|
63
|
+
var handleScroll = function () {
|
|
64
|
+
if (tableContainer.current == null)
|
|
65
|
+
return;
|
|
66
|
+
updatePosition();
|
|
67
|
+
};
|
|
68
|
+
updatePosition();
|
|
69
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
70
|
+
window.addEventListener('resize', updatePosition);
|
|
71
|
+
window.addEventListener('mousedown', HandleShow, false);
|
|
72
|
+
return function () {
|
|
73
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
74
|
+
window.removeEventListener('resize', updatePosition);
|
|
75
|
+
window.removeEventListener('mousedown', HandleShow, false);
|
|
76
|
+
updatePosition.cancel();
|
|
77
|
+
};
|
|
78
|
+
}, [suggestions, HandleShow]);
|
|
79
|
+
// update variable and suggestions when caret position changes
|
|
80
|
+
var handleCaretPosition = function () {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
if (textAreaElement.current !== null) {
|
|
83
|
+
var selection = textAreaElement.current.selectionStart;
|
|
84
|
+
var variable_1 = (0, AutoCompleteInput_1.getCurrentVariable)((_b = (_a = textAreaElement.current) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "", selection);
|
|
85
|
+
setVariable(variable_1);
|
|
86
|
+
var suggests = (0, AutoCompleteInput_1.getSuggestions)(variable_1, (_d = (_c = textAreaElement.current) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : "", props.Options);
|
|
87
|
+
setSuggestions(suggests);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// edit text area contents with selected suggestion
|
|
91
|
+
var handleOptionClick = function (option) {
|
|
92
|
+
var _a, _b, _c, _d;
|
|
93
|
+
var currentPos = textAreaElement.current !== null ? textAreaElement.current.selectionStart : 0;
|
|
94
|
+
var optionLength = option.Value.length;
|
|
95
|
+
props.Record[props.Field] = option.Value;
|
|
96
|
+
props.Setter(props.Record);
|
|
97
|
+
var textLength = textAreaElement.current !== null ? (_b = (_a = textAreaElement.current.textContent) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
98
|
+
var newCaretPos = (optionLength > textLength ? textLength - 1 : optionLength + currentPos);
|
|
99
|
+
(_c = textAreaElement.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
100
|
+
(_d = textAreaElement.current) === null || _d === void 0 ? void 0 : _d.setSelectionRange(newCaretPos, newCaretPos);
|
|
101
|
+
setSuggestions([]);
|
|
102
|
+
};
|
|
103
|
+
return (React.createElement("div", { ref: autoCompleteTextArea },
|
|
104
|
+
React.createElement(TextArea_1.default, { Valid: props.Valid, Record: props.Record, Setter: props.Setter, Field: props.Field, Rows: props.Rows, TextAreaRef: textAreaElement, SpellCheck: false }),
|
|
105
|
+
position == null || !show ? React.createElement(React.Fragment, null) :
|
|
106
|
+
React.createElement(react_portal_1.Portal, null,
|
|
107
|
+
React.createElement("div", { ref: tableContainer, className: 'popover', style: {
|
|
108
|
+
maxHeight: window.innerHeight - position.Top,
|
|
109
|
+
overflowY: 'auto',
|
|
110
|
+
padding: '10 5',
|
|
111
|
+
display: 'block',
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
zIndex: 9999,
|
|
114
|
+
maxWidth: '100%',
|
|
115
|
+
top: "".concat(position.Top, "px"),
|
|
116
|
+
left: "".concat(position.Left, "px"),
|
|
117
|
+
minWidth: "".concat(position.Width, "px")
|
|
118
|
+
} },
|
|
119
|
+
React.createElement("table", { className: "table table-hover", style: { margin: 0 }, ref: selectTable },
|
|
120
|
+
React.createElement("tbody", null, suggestions.map(function (f, i) { return (f.Value === props.Record[props.Field] ? null :
|
|
121
|
+
React.createElement("tr", { key: i, onMouseDown: function (_) { return handleOptionClick(f); } },
|
|
122
|
+
React.createElement("td", null, f.Label))); })))))));
|
|
123
|
+
}
|
|
124
|
+
var getTextDimensions = function (textArea, selection, prefix) {
|
|
125
|
+
var _a;
|
|
126
|
+
if (textArea.current == null)
|
|
127
|
+
return [0, 0];
|
|
128
|
+
var textarea = textArea.current;
|
|
129
|
+
if (textarea.parentNode == null)
|
|
130
|
+
return [0, 0];
|
|
131
|
+
var hiddenDiv = document.createElement('div');
|
|
132
|
+
var style = getComputedStyle(textarea);
|
|
133
|
+
Array.from(style).forEach(function (propertyName) {
|
|
134
|
+
var value = style.getPropertyValue(propertyName);
|
|
135
|
+
hiddenDiv.style.setProperty(propertyName, value);
|
|
136
|
+
});
|
|
137
|
+
// Set text content up to caret
|
|
138
|
+
var beforeSelection = textarea.value.substring(0, selection);
|
|
139
|
+
var afterSelection = (_a = textarea.value.substring(selection)) !== null && _a !== void 0 ? _a : '.';
|
|
140
|
+
hiddenDiv.textContent = (prefix !== null && prefix !== void 0 ? prefix : "") + beforeSelection;
|
|
141
|
+
// Create a span to mark caret position
|
|
142
|
+
var span = document.createElement('span');
|
|
143
|
+
span.textContent = afterSelection[0];
|
|
144
|
+
hiddenDiv.appendChild(span);
|
|
145
|
+
textarea.parentNode.appendChild(hiddenDiv);
|
|
146
|
+
// Get caret's vertical position relative to textarea
|
|
147
|
+
var caretX = span.offsetLeft - hiddenDiv.offsetLeft - hiddenDiv.scrollLeft;
|
|
148
|
+
var caretY = span.offsetTop - hiddenDiv.offsetTop - textarea.scrollTop;
|
|
149
|
+
textarea.parentNode.removeChild(hiddenDiv);
|
|
150
|
+
return [caretX, caretY];
|
|
151
|
+
};
|
package/lib/CheckBox.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
2
|
-
|
|
2
|
+
declare const CheckBox: <T>(props: Gemstone.TSX.Interfaces.IBaseFormProps<T>) => JSX.Element;
|
|
3
|
+
export default CheckBox;
|
package/lib/CheckBox.js
CHANGED
|
@@ -33,20 +33,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
33
33
|
return __assign.apply(this, arguments);
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = CheckBox;
|
|
37
36
|
var React = require("react");
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
|
-
function CheckBox(props) {
|
|
42
|
-
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
43
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
44
|
-
// Runs once, setting a unique GUID for each checkbox instance.
|
|
45
|
-
React.useEffect(function () {
|
|
46
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
47
|
-
}, []);
|
|
37
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
38
|
+
var CheckBox = function (props) {
|
|
48
39
|
var showLabel = props.Label !== "";
|
|
49
|
-
var showHelpIcon = props.Help !== undefined;
|
|
50
40
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
51
41
|
return (React.createElement("div", { className: "form-check" },
|
|
52
42
|
React.createElement("input", { type: "checkbox", className: "form-check-input", style: { zIndex: 1 }, onChange: function (evt) {
|
|
@@ -54,13 +44,10 @@ function CheckBox(props) {
|
|
|
54
44
|
record[props.Field] = evt.target.checked;
|
|
55
45
|
props.Setter(record);
|
|
56
46
|
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled }),
|
|
57
|
-
|
|
58
|
-
React.createElement("label", { className: "
|
|
47
|
+
showLabel ?
|
|
48
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
59
49
|
React.createElement("span", null, showLabel ? label : ''),
|
|
60
|
-
|
|
61
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
62
|
-
: null,
|
|
63
|
-
showHelpIcon ?
|
|
64
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
50
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
65
51
|
: null));
|
|
66
|
-
}
|
|
52
|
+
};
|
|
53
|
+
exports.default = CheckBox;
|
package/lib/ColorPicker.d.ts
CHANGED
|
@@ -40,5 +40,5 @@ interface IProps<T> extends Omit<Gemstone.TSX.Interfaces.IBaseFormProps<T>, "Set
|
|
|
40
40
|
*/
|
|
41
41
|
Triangle?: 'hide' | 'top';
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
export
|
|
43
|
+
declare const ColorPicker: <T>(props: IProps<T>) => JSX.Element;
|
|
44
|
+
export default ColorPicker;
|
package/lib/ColorPicker.js
CHANGED
|
@@ -37,26 +37,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
37
37
|
return __assign.apply(this, arguments);
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.default = ColorPicker;
|
|
41
40
|
var React = require("react");
|
|
42
41
|
var react_color_1 = require("react-color");
|
|
43
42
|
var styled_components_1 = require("styled-components");
|
|
44
43
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
45
44
|
var react_portal_1 = require("react-portal");
|
|
46
45
|
var lodash_1 = require("lodash");
|
|
47
|
-
var
|
|
48
|
-
var ToolTip_1 = require("./ToolTip");
|
|
46
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
49
47
|
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;\n position: fixed;\n transition: opacity 0.3s ease-out;\n z-index: 99999;\n pointer-events: ", ";\n opacity: ", ";\n color: currentColor;\n top: ", ";\n left: ", ";\n border: 1px solid transparent;\n }\n"], ["\n & {\n border-radius: 3px;\n display: inline-block;\n font-size: 13px;\n padding: 8px;\n position: fixed;\n transition: opacity 0.3s ease-out;\n z-index: 99999;\n pointer-events: ", ";\n opacity: ", ";\n color: currentColor;\n top: ", ";\n left: ", ";\n border: 1px solid transparent;\n }\n"])), function (props) { return props.Show ? 'auto' : 'none'; }, function (props) { return props.Show ? "0.9" : "0"; }, function (props) { return "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); });
|
|
50
|
-
function
|
|
48
|
+
var ColorPicker = function (props) {
|
|
51
49
|
var _a, _b, _c, _d, _e;
|
|
52
|
-
var guid = React.useState(helper_functions_1.CreateGuid)[0];
|
|
53
|
-
var _f = React.useState(false), showHelp = _f[0], setShowHelp = _f[1];
|
|
54
50
|
var toolTipRef = React.useRef(null);
|
|
55
51
|
var buttonRef = React.useRef(null);
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
var
|
|
52
|
+
var _f = React.useState(0), top = _f[0], setTop = _f[1];
|
|
53
|
+
var _g = React.useState(0), left = _g[0], setLeft = _g[1];
|
|
54
|
+
var _h = React.useState({ Top: -999, Left: -999, Width: 0, Height: 0 }), targetPosition = _h[0], setTargetPosition = _h[1];
|
|
55
|
+
var _j = React.useState(false), show = _j[0], setShow = _j[1];
|
|
60
56
|
var colors = (_a = props.Colors) !== null && _a !== void 0 ? _a : [
|
|
61
57
|
"#A30000", "#0029A3", "#007A29", "#d3d3d3", "#FF0000",
|
|
62
58
|
"#0066CC", "#33CC33", "#4287f5", "#edc240", "#afd8f8",
|
|
@@ -76,16 +72,14 @@ function ColorPicker(props) {
|
|
|
76
72
|
setLeft(l);
|
|
77
73
|
}
|
|
78
74
|
});
|
|
75
|
+
// Variables to control the rendering of label and help icon.
|
|
76
|
+
var showLabel = props.Label !== "";
|
|
79
77
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
80
78
|
return (React.createElement("div", { className: "form-group ", style: props.Style },
|
|
81
|
-
|
|
79
|
+
showLabel ?
|
|
82
80
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
83
|
-
React.createElement("span", null,
|
|
84
|
-
|
|
85
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
86
|
-
: null,
|
|
87
|
-
props.Help !== undefined ?
|
|
88
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
81
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
82
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
89
83
|
: null,
|
|
90
84
|
React.createElement("button", { disabled: (_b = props.Disabled) !== null && _b !== void 0 ? _b : false, ref: buttonRef, className: "btn btn-block form-control".concat(props.Valid == null || props.Valid(props.Field) ? '' : ' is-invalid'), "data-tooltip": "color-picker", onMouseOver: function () { return setShow(true); }, onMouseOut: function () { return setShow(false); }, style: __assign(__assign({}, props.Style), { backgroundColor: props.Record[props.Field], color: "#ffffff" }) }, (_c = props.Record[props.Field]) !== null && _c !== void 0 ? _c : ""),
|
|
91
85
|
React.createElement(react_portal_1.Portal, null, !((_d = props.Disabled) !== null && _d !== void 0 ? _d : false) ?
|
|
@@ -97,7 +91,7 @@ function ColorPicker(props) {
|
|
|
97
91
|
}, triangle: (_e = props.Triangle) !== null && _e !== void 0 ? _e : 'hide' }))
|
|
98
92
|
: React.createElement(React.Fragment, null)),
|
|
99
93
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
100
|
-
}
|
|
94
|
+
};
|
|
101
95
|
var GetBestPosition = function (ref, targetTop, targetHeight, targetLeft, targetWidth) {
|
|
102
96
|
if (ref.current === null)
|
|
103
97
|
return [-999, -999];
|
|
@@ -127,4 +121,5 @@ var GetBestPosition = function (ref, targetTop, targetHeight, targetLeft, target
|
|
|
127
121
|
}
|
|
128
122
|
return result;
|
|
129
123
|
};
|
|
124
|
+
exports.default = ColorPicker;
|
|
130
125
|
var templateObject_1;
|
|
@@ -41,7 +41,7 @@ var moment = require("moment");
|
|
|
41
41
|
var DateTimePopup_1 = require("./DateTimePopup");
|
|
42
42
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
43
43
|
var ToolTip_1 = require("../ToolTip");
|
|
44
|
-
var
|
|
44
|
+
var HelpIcon_1 = require("../HelpIcon");
|
|
45
45
|
/**
|
|
46
46
|
* Component that allows a user to pick a date or datetime.
|
|
47
47
|
*/
|
|
@@ -59,14 +59,12 @@ function DateTimePickerBase(props) {
|
|
|
59
59
|
var recordFormat = props.Format !== undefined ? props.Format : "YYYY-MM-DD" + (props.Type === undefined || props.Type === 'date' ? "" : "[T]HH:mm:ss.SSS[Z]");
|
|
60
60
|
// Parse the date from the record.
|
|
61
61
|
var parse = function (r) { return moment(props.Record[props.Field], recordFormat); };
|
|
62
|
-
var helpGuid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
63
|
-
var _d = React.useState(false), showHelp = _d[0], setShowHelp = _d[1];
|
|
64
62
|
// Adds a buffer between the outside props and what the box is reading to prevent box overwriting every render with a keystroke
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
63
|
+
var _d = React.useState(parse(props.Record).format(boxFormat)), boxRecord = _d[0], setBoxRecord = _d[1];
|
|
64
|
+
var _e = React.useState(parse(props.Record)), pickerRecord = _e[0], setPickerRecord = _e[1];
|
|
65
|
+
var _f = React.useState(""), feedbackMessage = _f[0], setFeedbackMessage = _f[1];
|
|
66
|
+
var _g = React.useState(0), top = _g[0], setTop = _g[1];
|
|
67
|
+
var _h = React.useState(0), left = _h[0], setLeft = _h[1];
|
|
70
68
|
var allowNull = React.useMemo(function () { var _a; return (_a = props.AllowEmpty) !== null && _a !== void 0 ? _a : false; }, [props.AllowEmpty]);
|
|
71
69
|
React.useEffect(function () {
|
|
72
70
|
if (props.Record[props.Field] != null) {
|
|
@@ -170,7 +168,6 @@ function DateTimePickerBase(props) {
|
|
|
170
168
|
}
|
|
171
169
|
// Variables for rendering labels and help icons.
|
|
172
170
|
var showLabel = props.Label !== "";
|
|
173
|
-
var showHelpIcon = props.Help !== undefined;
|
|
174
171
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
175
172
|
var step = props.Accuracy === 'millisecond' ? '0.001' : (props.Accuracy === 'minute' ? '60' : '1');
|
|
176
173
|
var IsValid = function () {
|
|
@@ -199,14 +196,10 @@ function DateTimePickerBase(props) {
|
|
|
199
196
|
setIsTextOverflowing(inputWidth > width);
|
|
200
197
|
}, [width, boxRecord, step]);
|
|
201
198
|
return (React.createElement("div", { className: "form-group", ref: divRef },
|
|
202
|
-
|
|
199
|
+
showLabel ?
|
|
203
200
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
204
201
|
React.createElement("span", null, showLabel ? label : ''),
|
|
205
|
-
|
|
206
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
207
|
-
: null,
|
|
208
|
-
showHelpIcon ?
|
|
209
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: helpGuid, Class: "info", Position: "top" }, props.Help)
|
|
202
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
210
203
|
: null,
|
|
211
204
|
React.createElement("input", { className: "gpa-gemstone-datetime form-control ".concat(IsValid() ? '' : 'is-invalid'), type: props.Type === undefined ? 'date' : props.Type, onChange: function (evt) {
|
|
212
205
|
valueChange(evt.target.value);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface IProps {
|
|
2
|
+
/**
|
|
3
|
+
* Help content to display in the tooltip.
|
|
4
|
+
* If undefined, nothing is rendered.
|
|
5
|
+
* @type {string | JSX.Element}
|
|
6
|
+
*/
|
|
7
|
+
Help?: string | JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Optional icon size in pixels. Defaults to 20.
|
|
10
|
+
* @type {number}
|
|
11
|
+
*/
|
|
12
|
+
Size?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Optional icon color. Defaults to 'var(--info)'.
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
17
|
+
Color?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional CSS class for the icon.
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
Class?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* HelpIcon component.
|
|
26
|
+
* Renders a question-mark icon that displays a tooltip on hover.
|
|
27
|
+
*/
|
|
28
|
+
declare const HelpIcon: (props: IProps) => JSX.Element | null;
|
|
29
|
+
export default HelpIcon;
|
package/lib/HelpIcon.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// HelpIcon.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
|
+
// 02/19/2026 - Preston Crawford
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var React = require("react");
|
|
26
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
27
|
+
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
28
|
+
var ToolTip_1 = require("./ToolTip");
|
|
29
|
+
/**
|
|
30
|
+
* HelpIcon component.
|
|
31
|
+
* Renders a question-mark icon that displays a tooltip on hover.
|
|
32
|
+
*/
|
|
33
|
+
var HelpIcon = function (props) {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
var _d = React.useState(false), showHelp = _d[0], setShowHelp = _d[1];
|
|
36
|
+
var guid = React.useRef((0, helper_functions_1.CreateGuid)());
|
|
37
|
+
if (props.Help == null || props.Help === '')
|
|
38
|
+
return null;
|
|
39
|
+
return (React.createElement(React.Fragment, null,
|
|
40
|
+
React.createElement("span", { className: (_a = props.Class) !== null && _a !== void 0 ? _a : "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid.current },
|
|
41
|
+
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: (_b = props.Color) !== null && _b !== void 0 ? _b : "var(--info)", Size: (_c = props.Size) !== null && _c !== void 0 ? _c : 20 })),
|
|
42
|
+
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid.current, Class: "info", Position: "top" }, props.Help)));
|
|
43
|
+
};
|
|
44
|
+
exports.default = HelpIcon;
|
package/lib/Input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
3
|
-
interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
3
|
+
export interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
4
4
|
/**
|
|
5
5
|
* Function to determine the validity of a field
|
|
6
6
|
* @param field - Field of the record to check
|
|
@@ -43,6 +43,11 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
43
43
|
* @optional
|
|
44
44
|
*/
|
|
45
45
|
DefaultValue?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Optional reference to internal input for features like autocomplete.
|
|
48
|
+
* @type {React.RefObject<HTMLInputElement>}
|
|
49
|
+
* @optional
|
|
50
|
+
*/
|
|
51
|
+
InputRef?: React.RefObject<HTMLInputElement>;
|
|
46
52
|
}
|
|
47
53
|
export default function Input<T>(props: IProps<T>): JSX.Element;
|
|
48
|
-
export {};
|
package/lib/Input.js
CHANGED
|
@@ -37,18 +37,11 @@ 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 ToolTip_1 = require("./ToolTip");
|
|
41
40
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
42
|
-
var
|
|
41
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
43
42
|
function Input(props) {
|
|
44
43
|
var internal = React.useRef(false);
|
|
45
|
-
var _a = React.useState(
|
|
46
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
47
|
-
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
48
|
-
// Effect to generate a unique ID for the component.
|
|
49
|
-
React.useEffect(function () {
|
|
50
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
51
|
-
}, []);
|
|
44
|
+
var _a = React.useState(''), heldVal = _a[0], setHeldVal = _a[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
52
45
|
// Handle changes to the record's field value.
|
|
53
46
|
React.useEffect(function () {
|
|
54
47
|
var rawValue = props.Record[props.Field] == null ? '' : props.Record[props.Field].toString();
|
|
@@ -102,18 +95,13 @@ function Input(props) {
|
|
|
102
95
|
}
|
|
103
96
|
// Variables to control the rendering of label and help icon.
|
|
104
97
|
var showLabel = props.Label !== "";
|
|
105
|
-
var showHelpIcon = props.Help !== undefined;
|
|
106
98
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
107
99
|
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.Style },
|
|
108
|
-
|
|
100
|
+
showLabel ?
|
|
109
101
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
110
102
|
React.createElement("span", null, showLabel ? label : ''),
|
|
111
|
-
|
|
112
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
113
|
-
: null,
|
|
114
|
-
showHelpIcon ?
|
|
115
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
103
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
116
104
|
: null,
|
|
117
|
-
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' }),
|
|
105
|
+
React.createElement("input", { ref: props.InputRef, 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' }),
|
|
118
106
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
119
107
|
}
|
package/lib/InputWithButton.js
CHANGED
|
@@ -34,17 +34,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
var React = require("react");
|
|
37
|
-
var ToolTip_1 = require("./ToolTip");
|
|
38
37
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
-
var
|
|
38
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
40
39
|
function InputWithButton(props) {
|
|
41
40
|
var internal = React.useRef(false);
|
|
42
|
-
var _a = React.useState(
|
|
43
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
44
|
-
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
45
|
-
React.useEffect(function () {
|
|
46
|
-
setGuid((0, helper_functions_1.CreateGuid)());
|
|
47
|
-
}, []);
|
|
41
|
+
var _a = React.useState(''), heldVal = _a[0], setHeldVal = _a[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
48
42
|
React.useEffect(function () {
|
|
49
43
|
if (!internal.current) {
|
|
50
44
|
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
@@ -89,19 +83,12 @@ function InputWithButton(props) {
|
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
var showLabel = props.Label !== "";
|
|
92
|
-
var showHelpIcon = props.Help !== undefined;
|
|
93
86
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
94
87
|
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.InputStyle },
|
|
95
|
-
|
|
96
|
-
React.createElement("label", { className:
|
|
88
|
+
showLabel ?
|
|
89
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
97
90
|
React.createElement("span", null, showLabel ? label : ''),
|
|
98
|
-
|
|
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,
|
|
103
|
-
showHelpIcon ?
|
|
104
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
91
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
105
92
|
: null,
|
|
106
93
|
React.createElement("div", { className: "input-group" },
|
|
107
94
|
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' }),
|
package/lib/MultiInput.js
CHANGED
|
@@ -44,34 +44,25 @@ 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 ToolTip_1 = require("./ToolTip");
|
|
48
47
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
49
|
-
var
|
|
48
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
50
49
|
//Only supporting string/number arrays for now
|
|
51
50
|
function MultiInput(props) {
|
|
52
|
-
var _a;
|
|
53
|
-
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
54
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
55
51
|
var fieldArray = props.Record[props.Field];
|
|
56
52
|
if ((fieldArray === null || fieldArray === void 0 ? void 0 : fieldArray.constructor) !== Array) {
|
|
57
53
|
console.warn("MultiInput: ".concat(props.Field.toString(), " is not of type array."));
|
|
58
54
|
return React.createElement(React.Fragment, null);
|
|
59
55
|
}
|
|
56
|
+
// Variables to control the rendering of label and help icon.
|
|
57
|
+
var showLabel = props.Label !== "";
|
|
58
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
60
59
|
return (React.createElement(React.Fragment, null,
|
|
61
60
|
fieldArray.length === 0 ?
|
|
62
|
-
React.createElement(React.Fragment, null,
|
|
63
|
-
React.createElement("label", { className:
|
|
64
|
-
React.createElement("span", null,
|
|
65
|
-
props.Help
|
|
66
|
-
|
|
67
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))
|
|
68
|
-
: null,
|
|
69
|
-
React.createElement("button", { className: 'btn', onClick: function () {
|
|
70
|
-
var _a;
|
|
71
|
-
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = [props.DefaultValue], _a)));
|
|
72
|
-
} },
|
|
73
|
-
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null))),
|
|
74
|
-
React.createElement(ToolTip_1.default, { Show: showHelp && props.Help != null, Target: guid, Class: "info", Position: "top" }, props.Help))
|
|
61
|
+
React.createElement(React.Fragment, null, showLabel ?
|
|
62
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
63
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
64
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
65
|
+
: null)
|
|
75
66
|
: null,
|
|
76
67
|
fieldArray.map(function (r, index) {
|
|
77
68
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -44,34 +44,25 @@ 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 SearchableSelect_1 = require("./SearchableSelect");
|
|
47
|
-
var ToolTip_1 = require("./ToolTip");
|
|
48
47
|
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
49
|
-
var
|
|
48
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
50
49
|
//Only supporting string/number arrays for now
|
|
51
50
|
function MultiSearchableSelect(props) {
|
|
52
|
-
var _a;
|
|
53
|
-
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
54
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
55
51
|
var fieldArray = props.Record[props.Field];
|
|
56
52
|
if ((fieldArray === null || fieldArray === void 0 ? void 0 : fieldArray.constructor) !== Array) {
|
|
57
53
|
console.warn("MultiInput: ".concat(props.Field.toString(), " is not of type array."));
|
|
58
54
|
return React.createElement(React.Fragment, null);
|
|
59
55
|
}
|
|
56
|
+
// Variables to control the rendering of label and help icon.
|
|
57
|
+
var showLabel = props.Label !== "";
|
|
58
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
60
59
|
return (React.createElement(React.Fragment, null,
|
|
61
60
|
fieldArray.length === 0 ?
|
|
62
|
-
React.createElement(React.Fragment, null,
|
|
63
|
-
React.createElement("label", { className:
|
|
64
|
-
React.createElement("span", null,
|
|
65
|
-
props.Help
|
|
66
|
-
|
|
67
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))
|
|
68
|
-
: null,
|
|
69
|
-
React.createElement("button", { className: 'btn', onClick: function () {
|
|
70
|
-
var _a;
|
|
71
|
-
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = [props.DefaultValue], _a)), 0, { Label: props.DefaultValue.toString(), Value: props.DefaultValue });
|
|
72
|
-
} },
|
|
73
|
-
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null))),
|
|
74
|
-
React.createElement(ToolTip_1.default, { Show: showHelp && props.Help != null, Target: guid, Class: "info", Position: "top" }, props.Help))
|
|
61
|
+
React.createElement(React.Fragment, null, showLabel ?
|
|
62
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
63
|
+
React.createElement("span", null, showLabel ? label : ''),
|
|
64
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
65
|
+
: null)
|
|
75
66
|
: null,
|
|
76
67
|
fieldArray.map(function (r, index) {
|
|
77
68
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -27,7 +27,7 @@ var React = require("react");
|
|
|
27
27
|
var ToolTip_1 = require("./ToolTip");
|
|
28
28
|
var react_portal_1 = require("react-portal");
|
|
29
29
|
var _ = require("lodash");
|
|
30
|
-
var
|
|
30
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
31
31
|
var MultiSelect = function (props) {
|
|
32
32
|
var _a;
|
|
33
33
|
// State hooks for managing the visibility of the dropdown and help message.
|
|
@@ -35,14 +35,11 @@ var MultiSelect = function (props) {
|
|
|
35
35
|
var selectTable = React.useRef(null);
|
|
36
36
|
var tableContainer = React.useRef(null);
|
|
37
37
|
var _b = React.useState(false), show = _b[0], setShow = _b[1];
|
|
38
|
-
var _c = React.useState(false),
|
|
39
|
-
var _d = React.useState(false), showItems = _d[0], setShowItems = _d[1];
|
|
38
|
+
var _c = React.useState(false), showItems = _c[0], setShowItems = _c[1];
|
|
40
39
|
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
41
|
-
var helperGuid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
42
40
|
var showLabel = React.useMemo(function () { return props.Label !== ""; }, [props.Label]);
|
|
43
|
-
var showHelpIcon = React.useMemo(function () { return props.Help !== undefined; }, [props.Help]);
|
|
44
41
|
var selectedOptions = React.useMemo(function () { return props.Options.filter(function (opt) { return opt.Selected; }); }, [props.Options]);
|
|
45
|
-
var
|
|
42
|
+
var _d = React.useState({ Top: 0, Left: 0, Width: 0, Height: 0 }), position = _d[0], setPosition = _d[1];
|
|
46
43
|
React.useEffect(function () {
|
|
47
44
|
var updatePosition = _.debounce(function () {
|
|
48
45
|
if (multiSelect.current != null) {
|
|
@@ -90,17 +87,11 @@ var MultiSelect = function (props) {
|
|
|
90
87
|
};
|
|
91
88
|
}, []);
|
|
92
89
|
return (React.createElement("div", { className: "form-group" },
|
|
93
|
-
showLabel
|
|
90
|
+
showLabel ?
|
|
94
91
|
React.createElement("label", { className: 'd-flex align-items-center' },
|
|
95
92
|
React.createElement("span", null, showLabel ?
|
|
96
93
|
(props.Label === undefined ? 'Select' : props.Label) : ''),
|
|
97
|
-
|
|
98
|
-
React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": helperGuid },
|
|
99
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))
|
|
100
|
-
: null) : null,
|
|
101
|
-
showHelpIcon ?
|
|
102
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: helperGuid, Class: "info", Position: "top" }, props.Help)
|
|
103
|
-
: null,
|
|
94
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help })) : null,
|
|
104
95
|
((_a = props.ShowToolTip) !== null && _a !== void 0 ? _a : false) ?
|
|
105
96
|
React.createElement(ToolTip_1.default, { Show: showItems, Target: guid, Position: "top" },
|
|
106
97
|
React.createElement("p", null, "Selected Options:"),
|
package/lib/RadioButtons.js
CHANGED
|
@@ -35,24 +35,13 @@ var __assign = (this && this.__assign) || function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.default = RadioButtons;
|
|
37
37
|
var React = require("react");
|
|
38
|
-
var
|
|
39
|
-
var ToolTip_1 = require("./ToolTip");
|
|
40
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
38
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
41
39
|
function RadioButtons(props) {
|
|
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 showHelpIcon = props.Help !== undefined;
|
|
46
40
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
47
41
|
return (React.createElement("div", { className: "form-group", style: props.Style },
|
|
48
42
|
React.createElement("label", { className: "form-check-label w-100 d-flex align-items-center" },
|
|
49
43
|
React.createElement("span", null, label),
|
|
50
|
-
|
|
51
|
-
React.createElement(React.Fragment, null,
|
|
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: "top" }, props.Help))
|
|
55
|
-
: null),
|
|
44
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help })),
|
|
56
45
|
props.Options.map(function (option, index) {
|
|
57
46
|
var _a;
|
|
58
47
|
return (React.createElement("div", { key: index, className: "form-check ".concat(props.Position == 'vertical' ? '' : 'form-check-inline') },
|
package/lib/Select.js
CHANGED
|
@@ -37,13 +37,9 @@ 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
|
|
41
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
42
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
40
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
43
41
|
function Select(props) {
|
|
44
42
|
var _a;
|
|
45
|
-
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
46
|
-
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
47
43
|
// Effect to validate the current value against the available options.
|
|
48
44
|
React.useEffect(function () {
|
|
49
45
|
var _a;
|
|
@@ -74,17 +70,12 @@ function Select(props) {
|
|
|
74
70
|
}
|
|
75
71
|
// Variables to control the rendering of label and help icon.
|
|
76
72
|
var showLabel = props.Label !== "";
|
|
77
|
-
var showHelpIcon = props.Help !== undefined;
|
|
78
73
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
79
74
|
return (React.createElement("div", { className: "form-group" },
|
|
80
|
-
|
|
75
|
+
showLabel ?
|
|
81
76
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
82
77
|
React.createElement("span", null, showLabel ? label : ''),
|
|
83
|
-
|
|
84
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
85
|
-
: null,
|
|
86
|
-
showHelpIcon ?
|
|
87
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
78
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
88
79
|
: null,
|
|
89
80
|
React.createElement("select", { className: "form-control", onChange: function (evt) {
|
|
90
81
|
var val = evt.target.value;
|
package/lib/StylableSelect.js
CHANGED
|
@@ -35,12 +35,11 @@ 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 ToolTip_1 = require("./ToolTip");
|
|
39
38
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
39
|
var lodash_1 = require("lodash");
|
|
41
40
|
var react_portal_1 = require("react-portal");
|
|
42
41
|
var _ = require("lodash");
|
|
43
|
-
var
|
|
42
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
44
43
|
function StylableSelect(props) {
|
|
45
44
|
var _a, _b, _c, _d;
|
|
46
45
|
// State hooks and ref for managing component state and interactions.
|
|
@@ -129,17 +128,12 @@ function StylableSelect(props) {
|
|
|
129
128
|
};
|
|
130
129
|
// Variables to control the rendering of label and help icon.
|
|
131
130
|
var showLabel = props.Label !== "";
|
|
132
|
-
var showHelpIcon = props.Help !== undefined;
|
|
133
131
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
134
132
|
return (React.createElement("div", { ref: stylableSelect, className: "form-group", style: { position: 'relative', display: 'inline-block', width: 'inherit' } },
|
|
135
|
-
|
|
133
|
+
showLabel ?
|
|
136
134
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
137
135
|
React.createElement("span", null, showLabel ? label : ''),
|
|
138
|
-
|
|
139
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
140
|
-
: null,
|
|
141
|
-
props.Help !== undefined ?
|
|
142
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
136
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
143
137
|
: null,
|
|
144
138
|
React.createElement("button", { type: "button", style: __assign({ padding: '.375rem .75rem' }, ((_a = props.BtnStyle) !== null && _a !== void 0 ? _a : {})), className: "dropdown-toggle form-control ".concat(((_c = (_b = props.Valid) === null || _b === void 0 ? void 0 : _b.call(props, props.Field)) !== null && _c !== void 0 ? _c : true) ? '' : 'is-invalid'), onClick: HandleShow, disabled: props.Disabled === undefined ? false : props.Disabled },
|
|
145
139
|
React.createElement("div", { style: props.Style }, (_d = props.Options[selectedOptionIndex]) === null || _d === void 0 ? void 0 : _d.Element)),
|
package/lib/TextArea.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
2
|
-
interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
3
|
+
export interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
3
4
|
/**
|
|
4
5
|
* Number of rows for the textarea
|
|
5
6
|
* @type {number}
|
|
@@ -23,6 +24,17 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
23
24
|
* @optional
|
|
24
25
|
*/
|
|
25
26
|
Help?: string | JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Optional reference to internal text area for features like autocomplete.
|
|
29
|
+
* @type {React.RefObject<HTMLTextAreaElement>}
|
|
30
|
+
* @optional
|
|
31
|
+
*/
|
|
32
|
+
TextAreaRef?: React.RefObject<HTMLTextAreaElement>;
|
|
33
|
+
/**
|
|
34
|
+
* Optional setting to enable/disable spellcheck.
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @optional
|
|
37
|
+
*/
|
|
38
|
+
SpellCheck?: boolean;
|
|
26
39
|
}
|
|
27
40
|
export default function TextArea<T>(props: IProps<T>): JSX.Element;
|
|
28
|
-
export {};
|
package/lib/TextArea.js
CHANGED
|
@@ -38,14 +38,14 @@ exports.default = TextArea;
|
|
|
38
38
|
// ******************************************************************************************************
|
|
39
39
|
var React = require("react");
|
|
40
40
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
41
|
-
var
|
|
42
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
41
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
43
42
|
function TextArea(props) {
|
|
43
|
+
var _a;
|
|
44
44
|
// Internal ref and state hooks for managing the component state.
|
|
45
45
|
var internal = React.useRef(false);
|
|
46
46
|
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
47
|
-
var
|
|
48
|
-
var
|
|
47
|
+
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
48
|
+
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1];
|
|
49
49
|
// Effect to handle changes to the record's field value.
|
|
50
50
|
React.useEffect(function () {
|
|
51
51
|
if (!internal.current) {
|
|
@@ -62,18 +62,13 @@ function TextArea(props) {
|
|
|
62
62
|
}
|
|
63
63
|
// Variables to control the rendering of label and help icon.
|
|
64
64
|
var showLabel = props.Label !== "";
|
|
65
|
-
var showHelpIcon = props.Help !== undefined;
|
|
66
65
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
67
66
|
return (React.createElement("div", { className: "form-group" },
|
|
68
|
-
|
|
67
|
+
showLabel ?
|
|
69
68
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
70
69
|
React.createElement("span", null, showLabel ? label : ''),
|
|
71
|
-
|
|
72
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
70
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
73
71
|
: null,
|
|
74
|
-
|
|
75
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help)
|
|
76
|
-
: null,
|
|
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 }),
|
|
72
|
+
React.createElement("textarea", { ref: props.TextAreaRef, 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, spellCheck: (_a = props.SpellCheck) !== null && _a !== void 0 ? _a : true }),
|
|
78
73
|
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field + ' is a required field.' : props.Feedback)));
|
|
79
74
|
}
|
package/lib/TimePicker.js
CHANGED
|
@@ -35,24 +35,17 @@ 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
|
|
39
|
-
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
40
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
38
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
41
39
|
function DatePicker(props) {
|
|
42
|
-
var guid = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
43
|
-
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
44
40
|
// Variables to control the rendering of label and help icon.
|
|
45
41
|
var showLabel = props.Label !== "";
|
|
46
|
-
var showHelpIcon = props.Help !== undefined;
|
|
47
42
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
48
43
|
return (React.createElement("div", { className: "form-group" },
|
|
49
|
-
|
|
44
|
+
showLabel ?
|
|
50
45
|
React.createElement("label", { className: "d-flex align-items-center" },
|
|
51
46
|
React.createElement("span", null, showLabel ? label : ''),
|
|
52
|
-
|
|
53
|
-
React.createElement(gpa_symbols_1.ReactIcons.QuestionMark, { Color: "var(--info)", Size: 20 }))))
|
|
47
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))
|
|
54
48
|
: null,
|
|
55
|
-
React.createElement(ToolTip_1.default, { Show: showHelp, Target: guid, Class: "info", Position: "top" }, props.Help),
|
|
56
49
|
React.createElement("input", { className: 'form-control' + (props.Valid(props.Field) ? '' : ' is-invalid'), type: "time", step: props.Step === null ? 60 : props.Step, onChange: function (evt) {
|
|
57
50
|
var record = __assign({}, props.Record);
|
|
58
51
|
if (evt.target.value !== '')
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -36,14 +36,10 @@ 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
|
|
40
|
-
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
39
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
41
40
|
function ToggleSwitch(props) {
|
|
42
|
-
var helpID = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
43
41
|
var switchID = React.useState((0, helper_functions_1.CreateGuid)())[0];
|
|
44
|
-
var _a = React.useState(false), showHelp = _a[0], setShowHelp = _a[1];
|
|
45
42
|
// Variables to control the rendering of label and help icon.
|
|
46
|
-
var showHelpIcon = props.Help !== undefined;
|
|
47
43
|
var label = props.Label === undefined ? props.Field : props.Label;
|
|
48
44
|
return (React.createElement("div", { className: "custom-control custom-switch form-group", style: props.Style },
|
|
49
45
|
React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
|
|
@@ -53,10 +49,5 @@ function ToggleSwitch(props) {
|
|
|
53
49
|
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field], disabled: props.Disabled == null ? false : props.Disabled, id: switchID }),
|
|
54
50
|
React.createElement("label", { className: "custom-control-label d-flex align-items-center", htmlFor: switchID },
|
|
55
51
|
React.createElement("span", null, label),
|
|
56
|
-
|
|
57
|
-
React.createElement(React.Fragment, null,
|
|
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: "top" }, props.Help))
|
|
61
|
-
: null)));
|
|
52
|
+
React.createElement(HelpIcon_1.default, { Help: props.Help }))));
|
|
62
53
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -20,4 +20,7 @@ import FileUpload from './FileUpload';
|
|
|
20
20
|
import MultiInput from './MultiInput';
|
|
21
21
|
import ToolTip from './ToolTip';
|
|
22
22
|
import MultiSearchableSelect from './MultiSearchableSelect';
|
|
23
|
-
|
|
23
|
+
import AutoCompleteTextArea from './AutoCompleteTextArea';
|
|
24
|
+
import AutoCompleteInput from './AutoCompleteInput';
|
|
25
|
+
import HelpIcon from './HelpIcon';
|
|
26
|
+
export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect, ToggleSwitch, InputWithButton, RadioButtons, FileUpload, MultiInput, ToolTip, MultiSearchableSelect, HelpIcon, AutoCompleteTextArea, AutoCompleteInput };
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
//
|
|
23
23
|
// ******************************************************************************************************
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.MultiSearchableSelect = 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;
|
|
25
|
+
exports.AutoCompleteInput = exports.AutoCompleteTextArea = exports.HelpIcon = exports.MultiSearchableSelect = 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");
|
|
@@ -67,3 +67,9 @@ var ToolTip_1 = require("./ToolTip");
|
|
|
67
67
|
exports.ToolTip = ToolTip_1.default;
|
|
68
68
|
var MultiSearchableSelect_1 = require("./MultiSearchableSelect");
|
|
69
69
|
exports.MultiSearchableSelect = MultiSearchableSelect_1.default;
|
|
70
|
+
var AutoCompleteTextArea_1 = require("./AutoCompleteTextArea");
|
|
71
|
+
exports.AutoCompleteTextArea = AutoCompleteTextArea_1.default;
|
|
72
|
+
var AutoCompleteInput_1 = require("./AutoCompleteInput");
|
|
73
|
+
exports.AutoCompleteInput = AutoCompleteInput_1.default;
|
|
74
|
+
var HelpIcon_1 = require("./HelpIcon");
|
|
75
|
+
exports.HelpIcon = HelpIcon_1.default;
|