@gpa-gemstone/react-forms 1.1.89 → 1.1.91
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.
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
interface IOption {
|
|
2
|
+
Value: number | string;
|
|
3
|
+
Label: string | JSX.Element;
|
|
4
|
+
Selected: boolean;
|
|
5
|
+
}
|
|
1
6
|
interface IProps {
|
|
2
7
|
/**
|
|
3
8
|
* Label to display for the form, defaults to the Field prop
|
|
@@ -9,22 +14,14 @@ interface IProps {
|
|
|
9
14
|
* Array of options for the multi-select checkboxe
|
|
10
15
|
* @type {{ Value: number | string; Text: string; Selected: boolean }[]}
|
|
11
16
|
*/
|
|
12
|
-
Options:
|
|
13
|
-
Value: number | string;
|
|
14
|
-
Text: string;
|
|
15
|
-
Selected: boolean;
|
|
16
|
-
}[];
|
|
17
|
+
Options: IOption[];
|
|
17
18
|
/**
|
|
18
19
|
* Function to handle changes in the selection
|
|
19
20
|
* @param evt - The change event
|
|
20
21
|
* @param Options - The updated options array
|
|
21
22
|
* @returns {void}
|
|
22
23
|
*/
|
|
23
|
-
OnChange: (evt: any, Options:
|
|
24
|
-
Value: number | string;
|
|
25
|
-
Text: string;
|
|
26
|
-
Selected: boolean;
|
|
27
|
-
}[]) => void;
|
|
24
|
+
OnChange: (evt: any, Options: IOption[]) => void;
|
|
28
25
|
/**
|
|
29
26
|
* Help message or element to display
|
|
30
27
|
* @type {string | JSX.Element}
|
|
@@ -108,7 +108,7 @@ var MultiSelect = function (props) {
|
|
|
108
108
|
((_a = props.ItemTooltip) !== null && _a !== void 0 ? _a : 'no-tip') !== 'no-tip' ?
|
|
109
109
|
React.createElement(ToolTip_1.default, { Show: showItems, Target: guid, Position: "bottom" },
|
|
110
110
|
React.createElement("p", null, "Selected Options:"),
|
|
111
|
-
selectedOptions.slice(0, 10).map(function (opt) { return React.createElement("p", null, opt.
|
|
111
|
+
selectedOptions.slice(0, 10).map(function (opt) { return React.createElement("p", null, opt.Label); }),
|
|
112
112
|
selectedOptions.length > 10 ? React.createElement("p", null, "and ".concat(selectedOptions.length - 10, " other(s)")) : null)
|
|
113
113
|
: null,
|
|
114
114
|
React.createElement("div", { ref: multiSelect, style: { position: 'relative', display: 'block', width: 'inherit' } },
|
|
@@ -142,6 +142,6 @@ var MultiSelect = function (props) {
|
|
|
142
142
|
props.Options.map(function (f, i) { return (React.createElement("tr", { key: i, onClick: function (evt) { return props.OnChange(evt, [f]); } },
|
|
143
143
|
React.createElement("td", null,
|
|
144
144
|
React.createElement("input", { type: "checkbox", checked: f.Selected, onChange: function () { return null; } })),
|
|
145
|
-
React.createElement("td", null, f.
|
|
145
|
+
React.createElement("td", null, f.Label))); }))))))));
|
|
146
146
|
};
|
|
147
147
|
exports.default = MultiSelect;
|
package/lib/RadioButtons.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
2
|
+
interface IOption extends Gemstone.TSX.Interfaces.ILabelValue<string | number> {
|
|
3
|
+
Disabled?: boolean;
|
|
4
|
+
}
|
|
2
5
|
interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
3
6
|
/**
|
|
4
7
|
* Position to display radion buttons in
|
|
@@ -8,13 +11,9 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
8
11
|
Position?: ('vertical' | 'horizontal');
|
|
9
12
|
/**
|
|
10
13
|
* Options for the radion buttons
|
|
11
|
-
* @type {
|
|
14
|
+
* @type {IOption[]}
|
|
12
15
|
*/
|
|
13
|
-
Options:
|
|
14
|
-
Value: string | number;
|
|
15
|
-
Label: string;
|
|
16
|
-
Disabled?: boolean;
|
|
17
|
-
}[];
|
|
16
|
+
Options: IOption[];
|
|
18
17
|
}
|
|
19
18
|
export default function RadioButtons<T>(props: IProps<T>): JSX.Element;
|
|
20
19
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Gemstone } from '@gpa-gemstone/application-typings';
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
Label: string;
|
|
3
|
+
export interface AbortablePromise<T> extends PromiseLike<T> {
|
|
4
|
+
abort?: () => void;
|
|
6
5
|
}
|
|
7
6
|
interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
8
7
|
/**
|
|
@@ -14,9 +13,9 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
14
13
|
/**
|
|
15
14
|
* Function to perform a search and return a promiselike object with a list of IOption and an optional callback
|
|
16
15
|
* @param search - Search string
|
|
17
|
-
* @returns {
|
|
16
|
+
* @returns {AbortablePromise<T>}
|
|
18
17
|
*/
|
|
19
|
-
Search: (search: string) =>
|
|
18
|
+
Search: (search: string) => AbortablePromise<Gemstone.TSX.Interfaces.ILabelValue<string | number>[]>;
|
|
20
19
|
/**
|
|
21
20
|
* CSS styles to apply to the form group
|
|
22
21
|
* @type {React.CSSProperties}
|
|
@@ -29,7 +28,7 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
29
28
|
* @optional
|
|
30
29
|
*/
|
|
31
30
|
BtnStyle?: React.CSSProperties;
|
|
32
|
-
GetLabel?: () =>
|
|
31
|
+
GetLabel?: () => AbortablePromise<string>;
|
|
33
32
|
/**
|
|
34
33
|
* Flag to reset search text to an empty string when a user selects an option. Defaulting to false
|
|
35
34
|
*/
|
package/lib/SearchableSelect.js
CHANGED
|
@@ -45,23 +45,24 @@ function SearchableSelect(props) {
|
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
setLoading(true);
|
|
48
|
-
var
|
|
49
|
-
|
|
48
|
+
var handle_1 = props.GetLabel();
|
|
49
|
+
handle_1.then(function (lab) {
|
|
50
50
|
setLabel(lab);
|
|
51
51
|
setSearch(lab);
|
|
52
52
|
setLoading(false);
|
|
53
53
|
});
|
|
54
|
-
return
|
|
54
|
+
return function () {
|
|
55
|
+
if ((handle_1 === null || handle_1 === void 0 ? void 0 : handle_1.abort) != null)
|
|
56
|
+
handle_1.abort();
|
|
57
|
+
};
|
|
55
58
|
}
|
|
56
|
-
}, [props.GetLabel]);
|
|
59
|
+
}, [props.GetLabel, props.Record[props.Field], props.ResetSearchOnSelect]);
|
|
57
60
|
// Call props.Search every 500ms to avoid hammering the server while typing
|
|
58
61
|
React.useEffect(function () {
|
|
59
62
|
setLoading(true);
|
|
60
63
|
var searchHandle;
|
|
61
|
-
var searchCallback;
|
|
62
64
|
var timeoutHandle = setTimeout(function () {
|
|
63
|
-
|
|
64
|
-
_a = props.Search(search), searchHandle = _a[0], searchCallback = _a[1];
|
|
65
|
+
searchHandle = props.Search(search);
|
|
65
66
|
searchHandle.then(function (d) {
|
|
66
67
|
setResults(d.map(function (o) { return ({ Value: o.Value, Element: o.Label }); }));
|
|
67
68
|
setLoading(false);
|
|
@@ -70,8 +71,8 @@ function SearchableSelect(props) {
|
|
|
70
71
|
});
|
|
71
72
|
}, 500);
|
|
72
73
|
return function () {
|
|
73
|
-
if (
|
|
74
|
-
|
|
74
|
+
if ((searchHandle === null || searchHandle === void 0 ? void 0 : searchHandle.abort) != null)
|
|
75
|
+
searchHandle.abort();
|
|
75
76
|
if (timeoutHandle != null)
|
|
76
77
|
clearTimeout(timeoutHandle);
|
|
77
78
|
};
|
package/lib/Select.d.ts
CHANGED
|
@@ -4,10 +4,7 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
|
|
|
4
4
|
* Options for the select dropdown
|
|
5
5
|
* @type {{ Value: string; Label: string }[]}
|
|
6
6
|
*/
|
|
7
|
-
Options:
|
|
8
|
-
Value: string | number;
|
|
9
|
-
Label: string;
|
|
10
|
-
}[];
|
|
7
|
+
Options: Gemstone.TSX.Interfaces.ILabelValue<string | number>[];
|
|
11
8
|
/**
|
|
12
9
|
* Flag to include an empty option in the select dropdown
|
|
13
10
|
* @type {boolean}
|
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.91",
|
|
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.
|
|
49
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
50
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.86",
|
|
49
|
+
"@gpa-gemstone/gpa-symbols": "0.0.52",
|
|
50
|
+
"@gpa-gemstone/helper-functions": "0.0.42",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|
|
53
53
|
"lodash": "^4.17.21",
|