@gpa-gemstone/react-forms 1.1.57 → 1.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ArrayCheckBoxes.js +6 -4
- package/lib/ColorPicker.d.ts +10 -6
- package/lib/ColorPicker.js +69 -63
- package/lib/InputWithButton.d.ts +23 -0
- package/lib/InputWithButton.js +107 -0
- package/lib/ToggleSwitch.d.ts +2 -1
- package/lib/ToggleSwitch.js +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +3 -1
package/lib/ArrayCheckBoxes.js
CHANGED
|
@@ -43,6 +43,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
var React = require("react");
|
|
46
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
46
47
|
function ArrayCheckBoxes(props) {
|
|
47
48
|
var Remove = function (cb) {
|
|
48
49
|
var a = __spreadArray([], props.Record[props.Field], true);
|
|
@@ -58,20 +59,21 @@ function ArrayCheckBoxes(props) {
|
|
|
58
59
|
a.sort();
|
|
59
60
|
return a;
|
|
60
61
|
};
|
|
62
|
+
var id = React.useRef("array-checkbox-" + (0, helper_functions_1.CreateGuid)());
|
|
61
63
|
return (React.createElement("div", { className: "form-group" },
|
|
62
64
|
React.createElement("label", null, props.Label == null ? props.Field : props.Label),
|
|
63
65
|
React.createElement("br", null),
|
|
64
66
|
React.createElement("div", { className: "form-check form-check-inline" },
|
|
65
|
-
React.createElement("input", { className: "form-check-input", type: "checkbox", checked: JSON.stringify(props.Record[props.Field]) === JSON.stringify(props.Checkboxes.map(function (x) { return x.ID; })), onChange: function (evt) {
|
|
67
|
+
React.createElement("input", { id: id.current + "-all", className: "form-check-input", type: "checkbox", checked: JSON.stringify(props.Record[props.Field]) === JSON.stringify(props.Checkboxes.map(function (x) { return x.ID; })), onChange: function (evt) {
|
|
66
68
|
var _a;
|
|
67
69
|
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? props.Checkboxes.map(function (x) { return x.ID; }) : [], _a)));
|
|
68
70
|
} }),
|
|
69
|
-
React.createElement("label", { className: "form-check-label" }, "All")),
|
|
71
|
+
React.createElement("label", { htmlFor: id.current + "-all", className: "form-check-label" }, "All")),
|
|
70
72
|
props.Checkboxes.map(function (cb, i) { return (React.createElement("div", { key: i, className: "form-check form-check-inline" },
|
|
71
|
-
React.createElement("input", { className: "form-check-input", type: "checkbox", checked: props.Record[props.Field].find(function (x) { return cb.ID === x; }) !== undefined, onChange: function (evt) {
|
|
73
|
+
React.createElement("input", { id: id.current + "-" + i, className: "form-check-input", type: "checkbox", checked: props.Record[props.Field].find(function (x) { return cb.ID === x; }) !== undefined, onChange: function (evt) {
|
|
72
74
|
var _a;
|
|
73
75
|
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = evt.target.checked ? Add(cb) : Remove(cb), _a)));
|
|
74
76
|
} }),
|
|
75
|
-
React.createElement("label", { className: "form-check-label" }, cb.Label))); })));
|
|
77
|
+
React.createElement("label", { htmlFor: id.current + "-" + i, className: "form-check-label" }, cb.Label))); })));
|
|
76
78
|
}
|
|
77
79
|
exports.default = ArrayCheckBoxes;
|
package/lib/ColorPicker.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ColorResult } from 'react-color';
|
|
3
|
-
interface IProps {
|
|
4
|
-
|
|
3
|
+
interface IProps<T> {
|
|
4
|
+
Record: T;
|
|
5
|
+
Field: keyof T;
|
|
6
|
+
Setter: (record: T, color: ColorResult) => void;
|
|
7
|
+
Label: string;
|
|
8
|
+
Disabled?: boolean;
|
|
9
|
+
Feedback?: string;
|
|
10
|
+
Style?: React.CSSProperties;
|
|
5
11
|
Colors?: string[];
|
|
6
|
-
OnColorChange: (updatedColor: ColorResult) => void;
|
|
7
12
|
Triangle?: ('hide' | 'top');
|
|
8
|
-
BtnText?: string;
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
export
|
|
14
|
+
export default function ColorPicker<T>(props: IProps<T>): JSX.Element;
|
|
15
|
+
export {};
|
package/lib/ColorPicker.js
CHANGED
|
@@ -25,84 +25,90 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
25
25
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
26
26
|
return cooked;
|
|
27
27
|
};
|
|
28
|
+
var __assign = (this && this.__assign) || function () {
|
|
29
|
+
__assign = Object.assign || function(t) {
|
|
30
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
31
|
+
s = arguments[i];
|
|
32
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
33
|
+
t[p] = s[p];
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
return __assign.apply(this, arguments);
|
|
38
|
+
};
|
|
28
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
40
|
var React = require("react");
|
|
30
41
|
var react_color_1 = require("react-color");
|
|
31
42
|
var styled_components_1 = require("styled-components");
|
|
32
43
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
33
44
|
var react_portal_1 = require("react-portal");
|
|
45
|
+
var lodash_1 = require("lodash");
|
|
34
46
|
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: #fff; // Dark theme color\n background: #222; // Dark theme background\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: #fff; // Dark theme color\n background: #222; // Dark theme background\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 props.Top + "px"; }, function (props) { return props.Left + "px"; });
|
|
35
|
-
|
|
36
|
-
var _a, _b, _c;
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var _h = React.useState(0), targetWidth = _h[0], setTargetWidth = _h[1];
|
|
43
|
-
var _j = React.useState(0), targetHeight = _j[0], setTargetHeight = _j[1];
|
|
47
|
+
function ColorPicker(props) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
|
+
var toolTipRef = React.useRef(null);
|
|
50
|
+
var buttonRef = React.useRef(null);
|
|
51
|
+
var _g = React.useState(0), top = _g[0], setTop = _g[1];
|
|
52
|
+
var _h = React.useState(0), left = _h[0], setLeft = _h[1];
|
|
53
|
+
var _j = React.useState({ Top: -999, Left: -999, Width: 0, Height: 0 }), targetPosition = _j[0], setTargetPosition = _j[1];
|
|
44
54
|
var _k = React.useState(false), show = _k[0], setShow = _k[1];
|
|
45
|
-
var
|
|
55
|
+
var colors = (_a = props.Colors) !== null && _a !== void 0 ? _a : ["#A30000", "#0029A3", "#007A29", "#d3d3d3", "#edc240",
|
|
46
56
|
"#afd8f8", "#cb4b4b", "#4da74d", "#9440ed", "#BD9B33", "#EE2E2F",
|
|
47
57
|
"#008C48", "#185AA9", "#F47D23", "#662C91", "#A21D21", "#B43894",
|
|
48
58
|
"#737373", "#ff904f", "#ff9999"];
|
|
49
|
-
React.useEffect(function () {
|
|
50
|
-
var target = document.querySelectorAll("[data-tooltip" + "=\"color-picker\"" + "]");
|
|
51
|
-
if (target.length === 0) {
|
|
52
|
-
setTargetHeight(0);
|
|
53
|
-
setTargetWidth(0);
|
|
54
|
-
setTargetLeft(-999);
|
|
55
|
-
setTargetTop(-999);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
var targetLocation = (0, helper_functions_1.GetNodeSize)(target[0]);
|
|
59
|
-
setTargetHeight(targetLocation.height);
|
|
60
|
-
setTargetWidth(targetLocation.width);
|
|
61
|
-
setTargetLeft(targetLocation.left);
|
|
62
|
-
setTargetTop(targetLocation.top);
|
|
63
|
-
}
|
|
64
|
-
}, []);
|
|
65
59
|
React.useLayoutEffect(function () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
if (buttonRef.current === null)
|
|
61
|
+
return;
|
|
62
|
+
var targetLocation = (0, helper_functions_1.GetNodeSize)(buttonRef.current);
|
|
63
|
+
var newTargetPosition = { Top: targetLocation.top, Left: targetLocation.left, Height: targetLocation.height, Width: targetLocation.width };
|
|
64
|
+
if (!(0, lodash_1.isEqual)(newTargetPosition, targetPosition)) {
|
|
65
|
+
setTargetPosition(newTargetPosition);
|
|
66
|
+
var _a = GetBestPosition(toolTipRef, targetLocation.top, targetLocation.height, targetLocation.left, targetLocation.width), t = _a[0], l = _a[1];
|
|
67
|
+
setTop(t);
|
|
68
|
+
setLeft(l);
|
|
69
|
+
}
|
|
69
70
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
return (React.createElement(React.Fragment, null,
|
|
72
|
+
React.createElement("button", { disabled: (_b = props.Disabled) !== null && _b !== void 0 ? _b : false, ref: buttonRef, className: "btn btn-block", "data-tooltip": "color-picker", onMouseOver: function () { return setShow(true); }, onMouseOut: function () { return setShow(false); }, style: props.Style }, (_c = props.Label) !== null && _c !== void 0 ? _c : ""),
|
|
73
|
+
props.Feedback !== undefined && ((_d = props.Disabled) !== null && _d !== void 0 ? _d : false) ?
|
|
74
|
+
React.createElement("div", { className: "text-danger" }, props.Feedback) : null,
|
|
75
|
+
React.createElement(react_portal_1.Portal, null, !((_e = props.Disabled) !== null && _e !== void 0 ? _e : false) ?
|
|
76
|
+
React.createElement(WrapperDiv, { Show: show, Top: top, Left: left, ref: toolTipRef, onMouseOver: function () { var _a; return ((_a = props.Disabled) !== null && _a !== void 0 ? _a : false) ? {} : setShow(true); }, onMouseOut: function () { return setShow(false); } },
|
|
77
|
+
React.createElement(react_color_1.BlockPicker, { color: props.Record[props.Field], colors: colors, onChangeComplete: function (updatedColor) {
|
|
78
|
+
var record = __assign({}, props.Record);
|
|
79
|
+
record[props.Field] = updatedColor.hex;
|
|
80
|
+
props.Setter(record, updatedColor);
|
|
81
|
+
}, triangle: (_f = props.Triangle) !== null && _f !== void 0 ? _f : 'hide' }))
|
|
82
|
+
: React.createElement(React.Fragment, null))));
|
|
83
|
+
}
|
|
84
|
+
exports.default = ColorPicker;
|
|
85
|
+
var GetBestPosition = function (ref, targetTop, targetHeight, targetLeft, targetWidth) {
|
|
86
|
+
if (ref.current === null)
|
|
87
|
+
return [-999, -999];
|
|
88
|
+
var colorPickerHeight = 280;
|
|
89
|
+
var colorPickerWidth = 180;
|
|
90
|
+
var tipLocation = (0, helper_functions_1.GetNodeSize)(ref.current);
|
|
91
|
+
var windowHeight = window.innerHeight;
|
|
92
|
+
var windowWidth = window.innerWidth;
|
|
93
|
+
var result = [0, 0];
|
|
94
|
+
//start by placing at the bottom of the button and rotating counter clockwise until there is enough space to fit the colorpicker
|
|
95
|
+
result[0] = targetTop + targetHeight;
|
|
96
|
+
result[1] = targetLeft + 0.5 * targetWidth - 0.5 * tipLocation.width;
|
|
97
|
+
//try to place colorpicker to the right of the button if there isnt enough room below
|
|
98
|
+
if (windowHeight - result[0] < colorPickerHeight) {
|
|
99
|
+
result[0] = targetTop + 0.5 * targetHeight - 0.5 * tipLocation.height;
|
|
100
|
+
result[1] = targetLeft + targetWidth;
|
|
101
|
+
//try to place colorpicker on the top of the button if there isnt enough room to the right
|
|
102
|
+
if (windowWidth - result[1] < colorPickerWidth) {
|
|
103
|
+
result[0] = targetTop - tipLocation.height;
|
|
104
|
+
result[1] = targetLeft + 0.5 * targetWidth - 0.5 * tipLocation.width;
|
|
105
|
+
//move colorpicker to the left of the button if there isnt enough space on the top
|
|
106
|
+
if (result[0] < 0) {
|
|
107
|
+
result[0] = targetTop + 0.5 * targetHeight - 0.5 * tipLocation.height;
|
|
108
|
+
result[1] = targetLeft - tipLocation.width;
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
|
-
return result;
|
|
98
111
|
}
|
|
99
|
-
return
|
|
100
|
-
React.createElement("button", { className: "btn btn-block", "data-tooltip": "color-picker", onMouseOver: function () { return setShow(true); }, onMouseOut: function () { return setShow(false); }, style: { backgroundColor: props.CurrentColor, borderColor: props.CurrentColor } }, (_b = props.BtnText) !== null && _b !== void 0 ? _b : "Color"),
|
|
101
|
-
React.createElement(react_portal_1.Portal, null,
|
|
102
|
-
React.createElement(WrapperDiv, { Show: show, Top: top, Left: left, ref: toolTip, onMouseOver: function () { return setShow(true); }, onMouseOut: function () { return setShow(false); } },
|
|
103
|
-
React.createElement(react_color_1.BlockPicker, { color: props.CurrentColor, colors: colorsArray, onChangeComplete: function (updatedColor) {
|
|
104
|
-
props.OnColorChange(updatedColor);
|
|
105
|
-
}, triangle: (_c = props.Triangle) !== null && _c !== void 0 ? _c : 'hide' })))));
|
|
112
|
+
return result;
|
|
106
113
|
};
|
|
107
|
-
exports.default = ColorPicker;
|
|
108
114
|
var templateObject_1;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IProps<T> {
|
|
3
|
+
Record: T;
|
|
4
|
+
Field: keyof T;
|
|
5
|
+
Setter: (record: T) => void;
|
|
6
|
+
Valid: (field: keyof T) => boolean;
|
|
7
|
+
Label?: string;
|
|
8
|
+
Feedback?: string;
|
|
9
|
+
InputDisabled?: boolean;
|
|
10
|
+
Type?: 'number' | 'text' | 'password' | 'email' | 'color' | 'integer';
|
|
11
|
+
Help?: string | JSX.Element;
|
|
12
|
+
InputStyle?: React.CSSProperties;
|
|
13
|
+
AllowNull?: boolean;
|
|
14
|
+
Size?: 'small' | 'large';
|
|
15
|
+
DefaultValue?: number;
|
|
16
|
+
OnBtnClick: (evt: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
17
|
+
BtnLabel: string;
|
|
18
|
+
BtnClass?: string;
|
|
19
|
+
BtnDisabled?: boolean;
|
|
20
|
+
BtnStyle?: React.CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
declare function InputWithButton<T>(props: IProps<T>): JSX.Element;
|
|
23
|
+
export default InputWithButton;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// InputWithButton.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
|
+
// 05/02/2024 - Preston Crawford
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
var __assign = (this && this.__assign) || function () {
|
|
25
|
+
__assign = Object.assign || function(t) {
|
|
26
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
+
s = arguments[i];
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
+
t[p] = s[p];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
return __assign.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
var React = require("react");
|
|
37
|
+
var HelperMessage_1 = require("./HelperMessage");
|
|
38
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
39
|
+
function InputWithButton(props) {
|
|
40
|
+
var internal = React.useRef(false);
|
|
41
|
+
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
42
|
+
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
43
|
+
var _c = React.useState(''), heldVal = _c[0], setHeldVal = _c[1]; // Need to buffer tha value because parseFloat will throw away trailing decimals or zeros
|
|
44
|
+
React.useEffect(function () {
|
|
45
|
+
setGuid((0, helper_functions_1.CreateGuid)());
|
|
46
|
+
}, []);
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
if (!internal.current) {
|
|
49
|
+
setHeldVal(props.Record[props.Field] == null ? '' : props.Record[props.Field].toString());
|
|
50
|
+
}
|
|
51
|
+
internal.current = false;
|
|
52
|
+
}, [props.Record[props.Field]]);
|
|
53
|
+
function onBlur() {
|
|
54
|
+
var _a;
|
|
55
|
+
var _b;
|
|
56
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
57
|
+
if (!allowNull && (props.Type === 'number' || props.Type === 'integer') && heldVal === '') {
|
|
58
|
+
internal.current = false;
|
|
59
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = (_b = props.DefaultValue) !== null && _b !== void 0 ? _b : 0, _a)));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function valueChange(value) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
internal.current = true;
|
|
65
|
+
var allowNull = props.AllowNull === undefined ? false : props.AllowNull;
|
|
66
|
+
if (props.Type === 'number') {
|
|
67
|
+
var v = (value.length > 0 && value[0] === '.' ? ("0" + value) : value);
|
|
68
|
+
if ((0, helper_functions_1.IsNumber)(v) || (v === '' && allowNull)) {
|
|
69
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = v !== '' ? parseFloat(v) : null, _a)));
|
|
70
|
+
setHeldVal(v);
|
|
71
|
+
}
|
|
72
|
+
else if (v === '') {
|
|
73
|
+
setHeldVal(v);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (props.Type === 'integer') {
|
|
77
|
+
if ((0, helper_functions_1.IsInteger)(value) || (value === '' && allowNull)) {
|
|
78
|
+
props.Setter(__assign(__assign({}, props.Record), (_b = {}, _b[props.Field] = value !== '' ? parseFloat(value) : null, _b)));
|
|
79
|
+
setHeldVal(value);
|
|
80
|
+
}
|
|
81
|
+
else if (value === '') {
|
|
82
|
+
setHeldVal(value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
props.Setter(__assign(__assign({}, props.Record), (_c = {}, _c[props.Field] = value !== '' ? value : null, _c)));
|
|
87
|
+
setHeldVal(value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var showLabel = props.Label !== "";
|
|
91
|
+
var showHelpIcon = props.Help !== undefined;
|
|
92
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
93
|
+
return (React.createElement("div", { className: "form-group " + (props.Size === 'large' ? 'form-group-lg' : '') + (props.Size === 'small' ? 'form-group-sm' : ''), style: props.InputStyle },
|
|
94
|
+
showHelpIcon || showLabel ?
|
|
95
|
+
React.createElement("label", null,
|
|
96
|
+
showLabel ? label : '',
|
|
97
|
+
showHelpIcon ? React.createElement("div", { style: { width: 20, height: 20, borderRadius: '50%', display: 'inline-block', background: '#0D6EFD', marginLeft: 10, textAlign: 'center', fontWeight: 'bold' }, onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); } }, " ? ") : null) : null,
|
|
98
|
+
showHelpIcon ?
|
|
99
|
+
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
100
|
+
: null,
|
|
101
|
+
React.createElement("div", { className: "input-group" },
|
|
102
|
+
React.createElement("input", { "data-help": guid, 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' }),
|
|
103
|
+
React.createElement("div", { className: "input-group-prepend" },
|
|
104
|
+
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)),
|
|
105
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback))));
|
|
106
|
+
}
|
|
107
|
+
exports.default = InputWithButton;
|
package/lib/ToggleSwitch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
interface IProps<T> {
|
|
3
3
|
Record: T;
|
|
4
4
|
Field: keyof T;
|
|
@@ -6,6 +6,7 @@ interface IProps<T> {
|
|
|
6
6
|
Label?: string;
|
|
7
7
|
Disabled?: boolean;
|
|
8
8
|
Help?: string | JSX.Element;
|
|
9
|
+
Style?: React.CSSProperties;
|
|
9
10
|
}
|
|
10
11
|
export default function ToggleSwitch<T>(props: IProps<T>): JSX.Element;
|
|
11
12
|
export {};
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -45,7 +45,7 @@ function ToggleSwitch(props) {
|
|
|
45
45
|
setHelpID((0, helper_functions_1.CreateGuid)());
|
|
46
46
|
setSwitchID((0, helper_functions_1.CreateGuid)());
|
|
47
47
|
}, []);
|
|
48
|
-
return (React.createElement("div", { className: "custom-control custom-switch", "data-help": helpID },
|
|
48
|
+
return (React.createElement("div", { className: "custom-control custom-switch", "data-help": helpID, style: props.Style },
|
|
49
49
|
React.createElement("input", { type: "checkbox", className: "custom-control-input", onChange: function (evt) {
|
|
50
50
|
var record = __assign({}, props.Record);
|
|
51
51
|
record[props.Field] = evt.target.checked;
|
package/lib/index.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ import StylableSelect from './StylableSelect';
|
|
|
14
14
|
import ColorPicker from './ColorPicker';
|
|
15
15
|
import SearchableSelect from './SearchableSelect';
|
|
16
16
|
import ToggleSwitch from './ToggleSwitch';
|
|
17
|
-
|
|
17
|
+
import InputWithButton from './InputWithButton';
|
|
18
|
+
export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect, ToggleSwitch, InputWithButton };
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
//
|
|
23
23
|
// ******************************************************************************************************
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
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.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");
|
|
@@ -55,3 +55,5 @@ var SearchableSelect_1 = require("./SearchableSelect");
|
|
|
55
55
|
exports.SearchableSelect = SearchableSelect_1.default;
|
|
56
56
|
var ToggleSwitch_1 = require("./ToggleSwitch");
|
|
57
57
|
exports.ToggleSwitch = ToggleSwitch_1.default;
|
|
58
|
+
var InputWithButton_1 = require("./InputWithButton");
|
|
59
|
+
exports.InputWithButton = InputWithButton_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.59",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"homepage": "https://github.com/GridProtectionAlliance/gpa-gemstone#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^27.0.0",
|
|
36
|
+
"@types/lodash": "^4.14.171",
|
|
36
37
|
"@types/react-color": "^3.0.12",
|
|
37
38
|
"@types/react-portal": "4.0.4",
|
|
38
39
|
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"@gpa-gemstone/helper-functions": "0.0.30",
|
|
48
49
|
"@types/react": "^17.0.14",
|
|
49
50
|
"@types/styled-components": "^5.1.11",
|
|
51
|
+
"lodash": "^4.17.21",
|
|
50
52
|
"moment": "2.29.4",
|
|
51
53
|
"react": "^18.2.0",
|
|
52
54
|
"react-color": "^2.19.3",
|