@gpa-gemstone/react-forms 1.1.105 → 1.1.106
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/ColorPicker.d.ts +6 -21
- package/lib/ColorPicker.js +21 -8
- package/lib/FileUpload.d.ts +1 -1
- package/lib/FileUpload.js +6 -4
- package/lib/MultiSearchableSelect.d.ts +3 -1
- package/lib/MultiSearchableSelect.js +4 -4
- package/package.json +3 -3
package/lib/ColorPicker.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ColorResult } from 'react-color';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Record to be used in the form
|
|
6
|
-
* @type {T}
|
|
7
|
-
*/
|
|
8
|
-
Record: T;
|
|
9
|
-
/**
|
|
10
|
-
* Field of the record to be edited
|
|
11
|
-
* @type {keyof T}
|
|
12
|
-
*/
|
|
13
|
-
Field: keyof T;
|
|
3
|
+
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
4
|
+
interface IProps<T> extends Omit<Gemstone.TSX.Interfaces.IBaseFormProps<T>, "Setter"> {
|
|
14
5
|
/**
|
|
15
6
|
* Setter function to update the Record
|
|
16
7
|
* @param record - Updated record of type T
|
|
@@ -19,17 +10,11 @@ interface IProps<T> {
|
|
|
19
10
|
*/
|
|
20
11
|
Setter: (record: T, color: ColorResult) => void;
|
|
21
12
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
*/
|
|
26
|
-
Label: string;
|
|
27
|
-
/**
|
|
28
|
-
* Flag to disable the input field
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
* @optional
|
|
13
|
+
* Function to determine the validity of a field
|
|
14
|
+
* @param field - Field of the record to check
|
|
15
|
+
* @returns {boolean}
|
|
31
16
|
*/
|
|
32
|
-
|
|
17
|
+
Valid?: (field: keyof T) => boolean;
|
|
33
18
|
/**
|
|
34
19
|
* Feedback message to show when input is invalid
|
|
35
20
|
* @type {string}
|
package/lib/ColorPicker.js
CHANGED
|
@@ -44,9 +44,13 @@ var styled_components_1 = require("styled-components");
|
|
|
44
44
|
var helper_functions_1 = require("@gpa-gemstone/helper-functions");
|
|
45
45
|
var react_portal_1 = require("react-portal");
|
|
46
46
|
var lodash_1 = require("lodash");
|
|
47
|
+
var gpa_symbols_1 = require("@gpa-gemstone/gpa-symbols");
|
|
48
|
+
var ToolTip_1 = require("./ToolTip");
|
|
47
49
|
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"); });
|
|
48
50
|
function ColorPicker(props) {
|
|
49
|
-
var _a, _b, _c, _d, _e
|
|
51
|
+
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];
|
|
50
54
|
var toolTipRef = React.useRef(null);
|
|
51
55
|
var buttonRef = React.useRef(null);
|
|
52
56
|
var _g = React.useState(0), top = _g[0], setTop = _g[1];
|
|
@@ -72,18 +76,27 @@ function ColorPicker(props) {
|
|
|
72
76
|
setLeft(l);
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
props.
|
|
78
|
-
React.createElement("
|
|
79
|
-
|
|
79
|
+
var label = props.Label === undefined ? props.Field : props.Label;
|
|
80
|
+
return (React.createElement("div", { className: "form-group ", style: props.Style },
|
|
81
|
+
props.Help !== undefined || props.Label !== "" ?
|
|
82
|
+
React.createElement("label", { className: "d-flex align-items-center" },
|
|
83
|
+
React.createElement("span", null, props.Label !== "" ? label : ''),
|
|
84
|
+
props.Help !== undefined && (React.createElement("span", { className: "ml-2 d-flex align-items-center", onMouseEnter: function () { return setShowHelp(true); }, onMouseLeave: function () { return setShowHelp(false); }, "data-tooltip": guid },
|
|
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)
|
|
89
|
+
: null,
|
|
90
|
+
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
|
+
React.createElement(react_portal_1.Portal, null, !((_d = props.Disabled) !== null && _d !== void 0 ? _d : false) ?
|
|
80
92
|
React.createElement(WrapperDiv, { className: "popover popover-body border", 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); } },
|
|
81
93
|
React.createElement(react_color_1.BlockPicker, { color: props.Record[props.Field], colors: colors, onChangeComplete: function (updatedColor) {
|
|
82
94
|
var record = __assign({}, props.Record);
|
|
83
95
|
record[props.Field] = updatedColor.hex;
|
|
84
96
|
props.Setter(record, updatedColor);
|
|
85
|
-
}, triangle: (
|
|
86
|
-
: React.createElement(React.Fragment, null))
|
|
97
|
+
}, triangle: (_e = props.Triangle) !== null && _e !== void 0 ? _e : 'hide' }))
|
|
98
|
+
: React.createElement(React.Fragment, null)),
|
|
99
|
+
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? props.Field.toString() + ' is a required field.' : props.Feedback)));
|
|
87
100
|
}
|
|
88
101
|
var GetBestPosition = function (ref, targetTop, targetHeight, targetLeft, targetWidth) {
|
|
89
102
|
if (ref.current === null)
|
package/lib/FileUpload.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface IProps {
|
|
|
6
6
|
/**
|
|
7
7
|
* Callback function that will be called when clear button is clicked
|
|
8
8
|
* */
|
|
9
|
-
OnClearHandler
|
|
9
|
+
OnClearHandler?: () => void;
|
|
10
10
|
/**
|
|
11
11
|
* Attribute used to control what type of files are filtered by default in file explorer
|
|
12
12
|
* @type {string}
|
package/lib/FileUpload.js
CHANGED
|
@@ -56,7 +56,8 @@ var FileUpload = function (props) {
|
|
|
56
56
|
setIsFileUploaded(false);
|
|
57
57
|
setFileName(null);
|
|
58
58
|
setFileSize(null);
|
|
59
|
-
props.OnClearHandler
|
|
59
|
+
if (props.OnClearHandler != null)
|
|
60
|
+
props.OnClearHandler();
|
|
60
61
|
};
|
|
61
62
|
var setMetaData = function (file) {
|
|
62
63
|
setFileName(file.name);
|
|
@@ -76,9 +77,10 @@ var FileUpload = function (props) {
|
|
|
76
77
|
React.createElement("label", { style: { cursor: 'pointer' } },
|
|
77
78
|
React.createElement(gpa_symbols_1.ReactIcons.ShareArrow, { Color: 'var(--info)' }),
|
|
78
79
|
React.createElement("input", { type: "file", accept: props.FileTypeAttribute, style: { display: 'none' }, onChange: handleFileUpload }))),
|
|
79
|
-
React.createElement(
|
|
80
|
-
React.createElement("
|
|
81
|
-
React.createElement(
|
|
80
|
+
props.OnClearHandler == null ? React.createElement(React.Fragment, null) :
|
|
81
|
+
React.createElement("div", { className: 'col-auto pl-0' },
|
|
82
|
+
React.createElement("button", { className: 'btn', onClick: handleOnClear },
|
|
83
|
+
React.createElement(gpa_symbols_1.ReactIcons.CircledX, { Color: 'var(--danger)' })))),
|
|
82
84
|
uploadStatus === 'error' ?
|
|
83
85
|
React.createElement("div", { className: "alert alert-danger fade show" }, "An error occured while uploading file.")
|
|
84
86
|
: null,
|
|
@@ -33,8 +33,10 @@ interface IProps<T> extends Omit<ISearchableSelectProps<T>, 'Valid' | 'Feedback'
|
|
|
33
33
|
/**
|
|
34
34
|
* Setter function to update the Record
|
|
35
35
|
* @param record - Updated Record
|
|
36
|
+
* @param index - Index in array field updated
|
|
37
|
+
* @param selectedOption - Option selected for the update
|
|
36
38
|
*/
|
|
37
|
-
Setter: (record: T, selectedOption?: Gemstone.TSX.Interfaces.ILabelValue<string | number>) => void;
|
|
39
|
+
Setter: (record: T, index: number, selectedOption?: Gemstone.TSX.Interfaces.ILabelValue<string | number>) => void;
|
|
38
40
|
}
|
|
39
41
|
declare function MultiSearchableSelect<T>(props: IProps<T>): JSX.Element;
|
|
40
42
|
export default MultiSearchableSelect;
|
|
@@ -68,7 +68,7 @@ function MultiSearchableSelect(props) {
|
|
|
68
68
|
: null,
|
|
69
69
|
React.createElement("button", { className: 'btn', onClick: function () {
|
|
70
70
|
var _a;
|
|
71
|
-
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = [props.DefaultValue], _a)), { Label: props.DefaultValue.toString(), Value: props.DefaultValue });
|
|
71
|
+
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = [props.DefaultValue], _a)), 0, { Label: props.DefaultValue.toString(), Value: props.DefaultValue });
|
|
72
72
|
} },
|
|
73
73
|
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null))),
|
|
74
74
|
React.createElement(ToolTip_1.default, { Show: showHelp && props.Help != null, Target: guid, Class: "info", Position: "top" }, props.Help))
|
|
@@ -81,13 +81,13 @@ function MultiSearchableSelect(props) {
|
|
|
81
81
|
var _a;
|
|
82
82
|
var newArray = __spreadArray([], fieldArray, true);
|
|
83
83
|
newArray[index] = record[index];
|
|
84
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newArray, _a)), option);
|
|
84
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newArray, _a)), index, option);
|
|
85
85
|
}, Search: props.Search, BtnStyle: props.BtnStyle, GetLabel: props.GetLabel != null ? function () { return props.GetLabel(fieldArray[index], index); } : undefined, ResetSearchOnSelect: props.ResetSearchOnSelect, AllowCustom: props.AllowCustom })),
|
|
86
86
|
React.createElement("div", { className: "col-".concat(index === __spreadArray([], fieldArray, true).length - 1 ? 1 : 2, " ").concat(index === 0 ? 'd-flex align-items-center' : '') },
|
|
87
87
|
React.createElement("button", { className: 'btn', style: ((_c = props.Disabled) !== null && _c !== void 0 ? _c : false) ? { display: 'none' } : undefined, onClick: function () {
|
|
88
88
|
var _a;
|
|
89
89
|
var newRecords = __spreadArray([], fieldArray, true).filter(function (_, i) { return i !== index; });
|
|
90
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newRecords, _a)));
|
|
90
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newRecords, _a)), index);
|
|
91
91
|
} },
|
|
92
92
|
React.createElement(gpa_symbols_1.ReactIcons.TrashCan, { Color: 'red' }))),
|
|
93
93
|
index === __spreadArray([], fieldArray, true).length - 1 ?
|
|
@@ -95,7 +95,7 @@ function MultiSearchableSelect(props) {
|
|
|
95
95
|
React.createElement("button", { className: 'btn', style: ((_f = (((_d = props.DisableAdd) !== null && _d !== void 0 ? _d : false) || ((_e = props.Disabled) !== null && _e !== void 0 ? _e : false))) !== null && _f !== void 0 ? _f : false) ? { display: 'none' } : undefined, onClick: function () {
|
|
96
96
|
var _a;
|
|
97
97
|
var newRecords = __spreadArray(__spreadArray([], __spreadArray([], fieldArray, true), true), [props.DefaultValue], false);
|
|
98
|
-
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newRecords, _a)));
|
|
98
|
+
props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field] = newRecords, _a)), newRecords.length - 1, { Label: props.DefaultValue.toString(), Value: props.DefaultValue });
|
|
99
99
|
} },
|
|
100
100
|
React.createElement(gpa_symbols_1.ReactIcons.CirclePlus, null)))
|
|
101
101
|
: null));
|
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.106",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"typescript": "5.5.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@gpa-gemstone/application-typings": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.92",
|
|
49
49
|
"@gpa-gemstone/gpa-symbols": "0.0.57",
|
|
50
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
50
|
+
"@gpa-gemstone/helper-functions": "0.0.51",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|
|
53
53
|
"lodash": "^4.17.21",
|