@gpa-gemstone/react-forms 1.1.53 → 1.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/CheckBox.js +1 -3
- package/lib/ColorPicker.js +10 -10
- package/lib/DatePicker.js +2 -10
- package/lib/SearchableSelect.d.ts +18 -0
- package/lib/SearchableSelect.js +85 -0
- package/lib/Select.js +4 -3
- package/lib/StylableSelect.d.ts +1 -1
- package/lib/StylableSelect.js +4 -3
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/package.json +2 -2
package/lib/CheckBox.js
CHANGED
|
@@ -40,8 +40,6 @@ function CheckBox(props) {
|
|
|
40
40
|
var _a = React.useState(""), guid = _a[0], setGuid = _a[1];
|
|
41
41
|
var _b = React.useState(false), showHelp = _b[0], setShowHelp = _b[1];
|
|
42
42
|
var showHelpIcon = props.Help !== undefined;
|
|
43
|
-
var showLabel = props.Label !== "";
|
|
44
|
-
var label = props.Label === undefined ? props.Field : props.Label;
|
|
45
43
|
React.useEffect(function () {
|
|
46
44
|
setGuid((0, helper_functions_1.CreateGuid)());
|
|
47
45
|
}, []);
|
|
@@ -50,7 +48,7 @@ function CheckBox(props) {
|
|
|
50
48
|
var record = __assign({}, props.Record);
|
|
51
49
|
record[props.Field] = evt.target.checked;
|
|
52
50
|
props.Setter(record);
|
|
53
|
-
}, value: props.Record[props.Field] ? 'on' : 'off', checked: props.Record[props.Field] ? true : false, disabled: props.Disabled == null ? false : props.Disabled }),
|
|
51
|
+
}, value: props.Record[props.Field] != null ? 'on' : 'off', checked: props.Record[props.Field] != null ? true : false, disabled: props.Disabled == null ? false : props.Disabled }),
|
|
54
52
|
React.createElement("label", { className: "form-check-label" }, props.Label == null ? props.Field : props.Label),
|
|
55
53
|
showHelpIcon ?
|
|
56
54
|
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); } }, "?")
|
package/lib/ColorPicker.js
CHANGED
|
@@ -33,15 +33,15 @@ var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
|
33
33
|
var react_portal_1 = require("react-portal");
|
|
34
34
|
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
35
|
var ColorPicker = function (props) {
|
|
36
|
-
var _a;
|
|
36
|
+
var _a, _b, _c;
|
|
37
37
|
var toolTip = React.useRef(null);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
38
|
+
var _d = React.useState(0), top = _d[0], setTop = _d[1];
|
|
39
|
+
var _e = React.useState(0), left = _e[0], setLeft = _e[1];
|
|
40
|
+
var _f = React.useState(0), targetLeft = _f[0], setTargetLeft = _f[1];
|
|
41
|
+
var _g = React.useState(0), targetTop = _g[0], setTargetTop = _g[1];
|
|
42
|
+
var _h = React.useState(0), targetWidth = _h[0], setTargetWidth = _h[1];
|
|
43
|
+
var _j = React.useState(0), targetHeight = _j[0], setTargetHeight = _j[1];
|
|
44
|
+
var _k = React.useState(false), show = _k[0], setShow = _k[1];
|
|
45
45
|
var colorsArray = (_a = props.Colors) !== null && _a !== void 0 ? _a : ["#A30000", "#0029A3", "#007A29", "#d3d3d3", "#edc240",
|
|
46
46
|
"#afd8f8", "#cb4b4b", "#4da74d", "#9440ed", "#BD9B33", "#EE2E2F",
|
|
47
47
|
"#008C48", "#185AA9", "#F47D23", "#662C91", "#A21D21", "#B43894",
|
|
@@ -97,12 +97,12 @@ var ColorPicker = function (props) {
|
|
|
97
97
|
return result;
|
|
98
98
|
}
|
|
99
99
|
return (React.createElement(React.Fragment, null,
|
|
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 } }, props.BtnText ?
|
|
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
101
|
React.createElement(react_portal_1.Portal, null,
|
|
102
102
|
React.createElement(WrapperDiv, { Show: show, Top: top, Left: left, ref: toolTip, onMouseOver: function () { return setShow(true); }, onMouseOut: function () { return setShow(false); } },
|
|
103
103
|
React.createElement(react_color_1.BlockPicker, { color: props.CurrentColor, colors: colorsArray, onChangeComplete: function (updatedColor) {
|
|
104
104
|
props.OnColorChange(updatedColor);
|
|
105
|
-
}, triangle: props.Triangle ?
|
|
105
|
+
}, triangle: (_c = props.Triangle) !== null && _c !== void 0 ? _c : 'hide' })))));
|
|
106
106
|
};
|
|
107
107
|
exports.default = ColorPicker;
|
|
108
108
|
var templateObject_1;
|
package/lib/DatePicker.js
CHANGED
|
@@ -114,16 +114,8 @@ function DateTimePicker(props) {
|
|
|
114
114
|
setShowOverlay(false);
|
|
115
115
|
}
|
|
116
116
|
function getBoxFormat(type, accuracy) {
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
if (!type)
|
|
120
|
-
dateTime = 'date';
|
|
121
|
-
else
|
|
122
|
-
dateTime = type;
|
|
123
|
-
if (!accuracy)
|
|
124
|
-
timeUnit = 'second';
|
|
125
|
-
else
|
|
126
|
-
timeUnit = accuracy;
|
|
117
|
+
var dateTime = type !== null && type !== void 0 ? type : 'date';
|
|
118
|
+
var timeUnit = accuracy !== null && accuracy !== void 0 ? accuracy : 'second';
|
|
127
119
|
if (dateTime === 'time') {
|
|
128
120
|
if (timeUnit === 'minute') {
|
|
129
121
|
return "HH:mm";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface IOption {
|
|
3
|
+
Value: string;
|
|
4
|
+
Label: string;
|
|
5
|
+
}
|
|
6
|
+
interface IProps<T> {
|
|
7
|
+
Record: T;
|
|
8
|
+
Field: keyof T;
|
|
9
|
+
Setter: (record: T) => void;
|
|
10
|
+
AllowCustom?: boolean;
|
|
11
|
+
Search: (search: string) => [promise: Promise<IOption[]>, callback?: () => void];
|
|
12
|
+
Label?: string;
|
|
13
|
+
Disabled?: boolean;
|
|
14
|
+
Help?: string | JSX.Element;
|
|
15
|
+
Style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export default function SearchableSelect<T>(props: IProps<T>): JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ******************************************************************************************************
|
|
3
|
+
// SearchableSelect.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2024, Grid Protection Alliance. All Rights Reserved.
|
|
6
|
+
//
|
|
7
|
+
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
|
|
8
|
+
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
|
|
9
|
+
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
|
|
10
|
+
// file except in compliance with the License. You may obtain a copy of the License at:
|
|
11
|
+
//
|
|
12
|
+
// http://opensource.org/licenses/MIT
|
|
13
|
+
//
|
|
14
|
+
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
|
|
15
|
+
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
|
|
16
|
+
// License for the specific language governing permissions and limitations.
|
|
17
|
+
//
|
|
18
|
+
// Code Modification History:
|
|
19
|
+
// ----------------------------------------------------------------------------------------------------
|
|
20
|
+
// 03/17/2024 - C. Lackner
|
|
21
|
+
// Generated original version of source code.
|
|
22
|
+
//
|
|
23
|
+
// ******************************************************************************************************
|
|
24
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
25
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
26
|
+
return cooked;
|
|
27
|
+
};
|
|
28
|
+
var __assign = (this && this.__assign) || function () {
|
|
29
|
+
__assign = Object.assign || function(t) {
|
|
30
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
31
|
+
s = arguments[i];
|
|
32
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
33
|
+
t[p] = s[p];
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
return __assign.apply(this, arguments);
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
var React = require("react");
|
|
41
|
+
var StylableSelect_1 = require("./StylableSelect");
|
|
42
|
+
var styled_components_1 = require("styled-components");
|
|
43
|
+
function SearchableSelect(props) {
|
|
44
|
+
var _a = React.useState(props.Record[props.Field].toString()), search = _a[0], setSearch = _a[1];
|
|
45
|
+
var _b = React.useState([]), results = _b[0], setResults = _b[1];
|
|
46
|
+
var _c = React.useState(false), loading = _c[0], setLoading = _c[1];
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
setLoading(true);
|
|
49
|
+
var _a = props.Search(search), h = _a[0], c = _a[1];
|
|
50
|
+
h.then(function (d) { setResults(d.map(function (o) { return ({ Value: o.Value, Element: React.createElement("p", null, o.Label) }); })); setLoading(false); });
|
|
51
|
+
return c;
|
|
52
|
+
}, [search]);
|
|
53
|
+
var options = React.useMemo(function () {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
var r = [];
|
|
56
|
+
if ((_a = props.AllowCustom) !== null && _a !== void 0 ? _a : false)
|
|
57
|
+
r.push({ Value: search, Element: React.createElement("p", null, search) });
|
|
58
|
+
r.push({
|
|
59
|
+
Value: props.Record[props.Field], Element: React.createElement("div", { className: 'input-group' },
|
|
60
|
+
React.createElement("input", { type: "text", className: "form-control", value: search, onChange: function (d) { return setSearch(d.target.value); }, onBlur: (((_b = props.AllowCustom) !== null && _b !== void 0 ? _b : false) ? function () {
|
|
61
|
+
var _a;
|
|
62
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = search, _a)));
|
|
63
|
+
} : function () { return setSearch(props.Record[props.Field].toString()); }) }),
|
|
64
|
+
React.createElement("div", { className: "input-group-append" },
|
|
65
|
+
React.createElement("span", { className: "input-group-text" },
|
|
66
|
+
React.createElement(Icon, null))),
|
|
67
|
+
"s")
|
|
68
|
+
});
|
|
69
|
+
r.push.apply(r, results.filter(function (f) { return f.Value !== search && f.Value !== props.Record[props.Field]; }));
|
|
70
|
+
if (!((_c = props.AllowCustom) !== null && _c !== void 0 ? _c : false))
|
|
71
|
+
r.push({ Value: 'search-' + props.Record[props.Field], Element: React.createElement("p", null, props.Record[props.Field]) });
|
|
72
|
+
return r;
|
|
73
|
+
}, [search, props.Record[props.Field], results, props.Disabled, loading]);
|
|
74
|
+
var update = React.useCallback(function (record) {
|
|
75
|
+
if (record[props.Field].toString().startsWith('search-'))
|
|
76
|
+
return;
|
|
77
|
+
props.Setter(record);
|
|
78
|
+
setSearch(record[props.Field].toString());
|
|
79
|
+
}, [props.Setter, props.Field]);
|
|
80
|
+
return React.createElement(StylableSelect_1.default, { Record: props.Record, Field: props.Field, Setter: update, Label: props.Label, Disabled: props.Disabled, Help: props.Help, Style: props.Style, Options: options });
|
|
81
|
+
}
|
|
82
|
+
exports.default = SearchableSelect;
|
|
83
|
+
var spin = (0, styled_components_1.keyframes)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"], ["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"])));
|
|
84
|
+
var Icon = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tanimation: ", " 1s linear infinite;\n\tborder: 5px solid #f3f3f3;\n\tborder-Top: 5px solid #555;\n\tborder-Radius: 50%;\n\twidth: 25px;\n\theight: 25px\n"], ["\n\tanimation: ", " 1s linear infinite;\n\tborder: 5px solid #f3f3f3;\n\tborder-Top: 5px solid #555;\n\tborder-Radius: 50%;\n\twidth: 25px;\n\theight: 25px\n"])), spin);
|
|
85
|
+
var templateObject_1, templateObject_2;
|
package/lib/Select.js
CHANGED
|
@@ -39,8 +39,9 @@ var React = require("react");
|
|
|
39
39
|
var HelperMessage_1 = require("./HelperMessage");
|
|
40
40
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
41
41
|
function Select(props) {
|
|
42
|
-
var _a
|
|
43
|
-
var _b = React.useState(
|
|
42
|
+
var _a;
|
|
43
|
+
var _b = React.useState(""), guid = _b[0], setGuid = _b[1];
|
|
44
|
+
var _c = React.useState(false), showHelp = _c[0], setShowHelp = _c[1];
|
|
44
45
|
React.useEffect(function () {
|
|
45
46
|
setGuid((0, helper_functions_1.CreateGuid)());
|
|
46
47
|
}, []);
|
|
@@ -73,7 +74,7 @@ function Select(props) {
|
|
|
73
74
|
React.createElement(HelperMessage_1.default, { Show: showHelp, Target: guid }, props.Help)
|
|
74
75
|
: null,
|
|
75
76
|
React.createElement("select", { "data-help": guid, className: "form-control", onChange: function (evt) { return SetRecord(evt.target.value); }, value: GetRecordValue(), disabled: props.Disabled == null ? false : props.Disabled },
|
|
76
|
-
props.EmptyOption ? React.createElement("option", { value: "" }, props.EmptyLabel !== undefined ? props.EmptyLabel : '') : null,
|
|
77
|
+
((_a = props.EmptyOption) !== null && _a !== void 0 ? _a : true) ? React.createElement("option", { value: "" }, props.EmptyLabel !== undefined ? props.EmptyLabel : '') : null,
|
|
77
78
|
props.Options.map(function (a, i) { return (React.createElement("option", { key: i, value: a.Value }, a.Label)); }))));
|
|
78
79
|
}
|
|
79
80
|
exports.default = Select;
|
package/lib/StylableSelect.d.ts
CHANGED
package/lib/StylableSelect.js
CHANGED
|
@@ -70,7 +70,7 @@ function StylableSelect(props) {
|
|
|
70
70
|
React.useEffect(function () {
|
|
71
71
|
var element = props.Options.find(function (e) { return e.Value === props.Record[props.Field]; });
|
|
72
72
|
setSelected(element !== undefined ? element.Element : React.createElement("div", null));
|
|
73
|
-
}, [props.Record]);
|
|
73
|
+
}, [props.Record, props.Options]);
|
|
74
74
|
return (React.createElement("div", { ref: stylableSelect, style: { position: 'relative', display: 'inline-block', width: 'inherit' } },
|
|
75
75
|
(props.Label !== "") ?
|
|
76
76
|
React.createElement("label", null,
|
|
@@ -93,7 +93,8 @@ function StylableSelect(props) {
|
|
|
93
93
|
minWidth: '100%',
|
|
94
94
|
} },
|
|
95
95
|
React.createElement("table", { className: "table", style: { margin: 0 } },
|
|
96
|
-
React.createElement("tbody", null, props.Options.map(function (f, i) { return (
|
|
97
|
-
React.createElement("
|
|
96
|
+
React.createElement("tbody", null, props.Options.map(function (f, i) { return (f.Value == props.Record[props.Field] ? null :
|
|
97
|
+
React.createElement("tr", { key: i, onClick: function (evt) { evt.preventDefault(); SetRecord(f); setShow(false); } },
|
|
98
|
+
React.createElement("td", null, f.Element))); }))))));
|
|
98
99
|
}
|
|
99
100
|
exports.default = StylableSelect;
|
package/lib/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ import DoubleInput from './DoubleInput';
|
|
|
12
12
|
import TimePicker from './TimePicker';
|
|
13
13
|
import StylableSelect from './StylableSelect';
|
|
14
14
|
import ColorPicker from './ColorPicker';
|
|
15
|
-
|
|
15
|
+
import SearchableSelect from './SearchableSelect';
|
|
16
|
+
export { CheckBox, Input, DatePicker, Select, TextArea, DateRangePicker, EnumCheckBoxes, ArrayMultiSelect, ArrayCheckBoxes, MultiCheckBoxSelect, DoubleInput, TimePicker, StylableSelect, ColorPicker, SearchableSelect };
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
//
|
|
23
23
|
// ******************************************************************************************************
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
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.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");
|
|
@@ -51,3 +51,5 @@ var StylableSelect_1 = require("./StylableSelect");
|
|
|
51
51
|
exports.StylableSelect = StylableSelect_1.default;
|
|
52
52
|
var ColorPicker_1 = require("./ColorPicker");
|
|
53
53
|
exports.ColorPicker = ColorPicker_1.default;
|
|
54
|
+
var SearchableSelect_1 = require("./SearchableSelect");
|
|
55
|
+
exports.SearchableSelect = SearchableSelect_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.55",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "4.4.4"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
47
|
+
"@gpa-gemstone/helper-functions": "0.0.30",
|
|
48
48
|
"@types/react": "^17.0.14",
|
|
49
49
|
"@types/styled-components": "^5.1.11",
|
|
50
50
|
"moment": "2.29.4",
|