@gpa-gemstone/react-forms 1.1.59 → 1.1.61
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.d.ts +33 -11
- package/lib/ArrayCheckBoxes.js +81 -79
- package/lib/ArrayMultiSelect.d.ts +47 -13
- package/lib/ArrayMultiSelect.js +49 -47
- package/lib/CheckBox.d.ts +37 -11
- package/lib/CheckBox.js +62 -60
- package/lib/ColorPicker.d.ts +59 -15
- package/lib/ColorPicker.js +114 -114
- package/lib/DatePicker.d.ts +23 -21
- package/lib/DatePicker.js +221 -214
- package/lib/DateRangePicker.d.ts +64 -13
- package/lib/DateRangePicker.js +143 -132
- package/lib/DateTimeUI/Calender.d.ts +7 -8
- package/lib/DateTimeUI/Calender.js +180 -180
- package/lib/DateTimeUI/Clock.d.ts +9 -10
- package/lib/DateTimeUI/Clock.js +153 -153
- package/lib/DateTimeUI/DateTimePopup.d.ts +16 -17
- package/lib/DateTimeUI/DateTimePopup.js +59 -59
- package/lib/DoubleInput.d.ts +58 -12
- package/lib/DoubleInput.js +55 -51
- package/lib/EnumCheckBoxes.d.ts +41 -9
- package/lib/EnumCheckBoxes.js +65 -58
- package/lib/HelperMessage.d.ts +37 -10
- package/lib/HelperMessage.js +93 -83
- package/lib/Input.d.ts +80 -18
- package/lib/Input.js +111 -106
- package/lib/InputWithButton.d.ts +109 -23
- package/lib/InputWithButton.js +107 -107
- package/lib/MutliCheckBoxSelect.d.ts +42 -18
- package/lib/MutliCheckBoxSelect.js +110 -104
- package/lib/RadioButtons.d.ts +15 -0
- package/lib/RadioButtons.js +62 -0
- package/lib/SearchableSelect.d.ts +60 -18
- package/lib/SearchableSelect.js +84 -85
- package/lib/Select.d.ts +57 -17
- package/lib/Select.js +84 -80
- package/lib/StylableSelect.d.ts +53 -17
- package/lib/StylableSelect.js +106 -100
- package/lib/TextArea.d.ts +54 -14
- package/lib/TextArea.js +76 -72
- package/lib/TimePicker.d.ts +50 -11
- package/lib/TimePicker.js +60 -51
- package/lib/ToggleSwitch.d.ts +44 -12
- package/lib/ToggleSwitch.js +57 -61
- package/lib/index.d.ts +19 -18
- package/lib/index.js +61 -59
- package/package.json +4 -3
package/lib/ColorPicker.js
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
//******************************************************************************************************
|
|
3
|
-
// ColorPicker.tsx - Gbtc
|
|
4
|
-
//
|
|
5
|
-
// Copyright © 2023, 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/05/2024 - Preston Crawford
|
|
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
|
-
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
"#
|
|
58
|
-
"#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
props.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
record
|
|
80
|
-
props.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
};
|
|
114
|
-
var templateObject_1;
|
|
1
|
+
"use strict";
|
|
2
|
+
//******************************************************************************************************
|
|
3
|
+
// ColorPicker.tsx - Gbtc
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2023, 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/05/2024 - Preston Crawford
|
|
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
|
+
exports.default = ColorPicker;
|
|
41
|
+
var React = require("react");
|
|
42
|
+
var react_color_1 = require("react-color");
|
|
43
|
+
var styled_components_1 = require("styled-components");
|
|
44
|
+
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
45
|
+
var react_portal_1 = require("react-portal");
|
|
46
|
+
var lodash_1 = require("lodash");
|
|
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: #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 "".concat(props.Top, "px"); }, function (props) { return "".concat(props.Left, "px"); });
|
|
48
|
+
function ColorPicker(props) {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
var toolTipRef = React.useRef(null);
|
|
51
|
+
var buttonRef = React.useRef(null);
|
|
52
|
+
var _g = React.useState(0), top = _g[0], setTop = _g[1];
|
|
53
|
+
var _h = React.useState(0), left = _h[0], setLeft = _h[1];
|
|
54
|
+
var _j = React.useState({ Top: -999, Left: -999, Width: 0, Height: 0 }), targetPosition = _j[0], setTargetPosition = _j[1];
|
|
55
|
+
var _k = React.useState(false), show = _k[0], setShow = _k[1];
|
|
56
|
+
var colors = (_a = props.Colors) !== null && _a !== void 0 ? _a : ["#A30000", "#0029A3", "#007A29", "#d3d3d3", "#edc240",
|
|
57
|
+
"#afd8f8", "#cb4b4b", "#4da74d", "#9440ed", "#BD9B33", "#EE2E2F",
|
|
58
|
+
"#008C48", "#185AA9", "#F47D23", "#662C91", "#A21D21", "#B43894",
|
|
59
|
+
"#737373", "#ff904f", "#ff9999"];
|
|
60
|
+
React.useLayoutEffect(function () {
|
|
61
|
+
if (buttonRef.current === null)
|
|
62
|
+
return;
|
|
63
|
+
var targetLocation = (0, helper_functions_1.GetNodeSize)(buttonRef.current);
|
|
64
|
+
var newTargetPosition = { Top: targetLocation.top, Left: targetLocation.left, Height: targetLocation.height, Width: targetLocation.width };
|
|
65
|
+
if (!(0, lodash_1.isEqual)(newTargetPosition, targetPosition)) {
|
|
66
|
+
setTargetPosition(newTargetPosition);
|
|
67
|
+
var _a = GetBestPosition(toolTipRef, targetLocation.top, targetLocation.height, targetLocation.left, targetLocation.width), t = _a[0], l = _a[1];
|
|
68
|
+
setTop(t);
|
|
69
|
+
setLeft(l);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return (React.createElement(React.Fragment, null,
|
|
73
|
+
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 : ""),
|
|
74
|
+
props.Feedback !== undefined && ((_d = props.Disabled) !== null && _d !== void 0 ? _d : false) ?
|
|
75
|
+
React.createElement("div", { className: "text-danger" }, props.Feedback) : null,
|
|
76
|
+
React.createElement(react_portal_1.Portal, null, !((_e = props.Disabled) !== null && _e !== void 0 ? _e : false) ?
|
|
77
|
+
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); } },
|
|
78
|
+
React.createElement(react_color_1.BlockPicker, { color: props.Record[props.Field], colors: colors, onChangeComplete: function (updatedColor) {
|
|
79
|
+
var record = __assign({}, props.Record);
|
|
80
|
+
record[props.Field] = updatedColor.hex;
|
|
81
|
+
props.Setter(record, updatedColor);
|
|
82
|
+
}, triangle: (_f = props.Triangle) !== null && _f !== void 0 ? _f : 'hide' }))
|
|
83
|
+
: React.createElement(React.Fragment, null))));
|
|
84
|
+
}
|
|
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;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
};
|
|
114
|
+
var templateObject_1;
|
package/lib/DatePicker.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import * as moment from 'moment';
|
|
2
|
+
import { Accuracy } from './DateTimeUI/Clock';
|
|
3
|
+
export type TimeUnit = ('datetime-local' | 'date' | 'time');
|
|
4
|
+
interface IProps<T> {
|
|
5
|
+
Record: T;
|
|
6
|
+
Field: keyof T;
|
|
7
|
+
Setter: (record: T) => void;
|
|
8
|
+
Valid: (field: keyof T) => boolean;
|
|
9
|
+
Label?: string;
|
|
10
|
+
Disabled?: boolean;
|
|
11
|
+
Feedback?: string;
|
|
12
|
+
Format?: string;
|
|
13
|
+
Type?: TimeUnit;
|
|
14
|
+
Help?: string | JSX.Element;
|
|
15
|
+
AllowEmpty?: boolean;
|
|
16
|
+
Accuracy?: Accuracy;
|
|
17
|
+
MinDate?: moment.Moment;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Component that allows a user to pick a date or datetime.
|
|
21
|
+
*/
|
|
22
|
+
export default function DateTimePicker<T>(props: IProps<T>): JSX.Element;
|
|
23
|
+
export {};
|