@michalrakus/x-react-web-lib 1.17.0 → 1.19.0
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/components/XAutoComplete.d.ts +9 -9
- package/lib/components/XAutoComplete.js +7 -78
- package/lib/components/XAutoCompleteBase.d.ts +39 -7
- package/lib/components/XAutoCompleteBase.js +351 -64
- package/lib/components/XAutoCompleteDT.d.ts +10 -6
- package/lib/components/XAutoCompleteDT.js +3 -69
- package/lib/components/XCalendar.d.ts +1 -2
- package/lib/components/XCalendar.js +79 -10
- package/lib/components/XFormBase.js +5 -1
- package/lib/components/XFormComponent.js +9 -6
- package/lib/components/XFormDataTable2.d.ts +15 -1
- package/lib/components/XFormDataTable2.js +24 -4
- package/lib/components/XFormRowCol/XFormCol.d.ts +1 -0
- package/lib/components/XFormRowCol/XFormCol.js +1 -1
- package/lib/components/XFormRowCol/XFormInlineRow.d.ts +1 -0
- package/lib/components/XFormRowCol/XFormInlineRow.js +1 -1
- package/lib/components/XFormRowCol/XFormRow.d.ts +1 -0
- package/lib/components/XFormRowCol/XFormRow.js +1 -1
- package/lib/components/XFormRowCol/XFormRowCol.d.ts +1 -0
- package/lib/components/XFormRowCol/XFormRowCol.js +1 -1
- package/lib/components/XInputDate.d.ts +0 -1
- package/lib/components/XInputDate.js +4 -18
- package/lib/components/XInputDateDT.d.ts +9 -10
- package/lib/components/XInputDateDT.js +35 -39
- package/lib/components/XInputDecimal.js +1 -1
- package/lib/components/XInputTextarea.js +1 -1
- package/lib/components/XInputTextareaDT.d.ts +12 -0
- package/lib/components/XInputTextareaDT.js +44 -0
- package/lib/components/XLazyDataTable.d.ts +4 -2
- package/lib/components/XLazyDataTable.js +17 -4
- package/lib/components/XSearchBrowseParams.d.ts +2 -2
- package/lib/components/XSearchButton.js +2 -2
- package/lib/components/XSearchButtonDT.js +2 -2
- package/lib/components/XUtils.d.ts +4 -0
- package/lib/components/XUtils.js +51 -11
- package/lib/components/XUtilsMetadata.js +1 -1
- package/lib/serverApi/FindParam.d.ts +12 -2
- package/lib/serverApi/FindParam.js +3 -2
- package/lib/serverApi/XUtilsCommon.d.ts +5 -0
- package/lib/serverApi/XUtilsCommon.js +43 -0
- package/lib/serverApi/XUtilsConversions.d.ts +1 -0
- package/lib/serverApi/XUtilsConversions.js +63 -5
- package/package.json +1 -1
|
@@ -2,37 +2,37 @@ import React from "react";
|
|
|
2
2
|
import { XFilterProp, XFormComponent, XFormComponentProps } from "./XFormComponent";
|
|
3
3
|
import { XAssoc } from "../serverApi/XEntityMetadata";
|
|
4
4
|
import { OperationType } from "./XUtils";
|
|
5
|
+
import { XSuggestionsLoadProp } from "./XAutoCompleteBase";
|
|
5
6
|
import { XError } from "./XErrors";
|
|
6
7
|
import { XObject } from "./XObject";
|
|
7
8
|
import { DataTableSortMeta } from "primereact/datatable";
|
|
8
9
|
export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
|
|
9
10
|
assocField: string;
|
|
10
|
-
displayField: string;
|
|
11
|
+
displayField: string | string[];
|
|
11
12
|
searchBrowse?: JSX.Element;
|
|
12
13
|
assocForm?: JSX.Element;
|
|
14
|
+
suggestions?: any[];
|
|
15
|
+
suggestionsLoad?: XSuggestionsLoadProp;
|
|
16
|
+
lazyLoadMaxRows?: number;
|
|
17
|
+
splitQueryValue?: boolean;
|
|
18
|
+
minLength?: number;
|
|
13
19
|
filter?: XFilterProp;
|
|
14
20
|
sortField?: string | DataTableSortMeta[];
|
|
15
21
|
fields?: string[];
|
|
16
|
-
suggestions?: any[];
|
|
17
|
-
lazy?: boolean;
|
|
18
22
|
width?: string;
|
|
23
|
+
scrollHeight?: string;
|
|
19
24
|
inputStyle?: React.CSSProperties;
|
|
20
25
|
}
|
|
21
26
|
export declare class XAutoComplete extends XFormComponent<XObject, XAutoCompleteProps> {
|
|
22
27
|
protected xAssoc: XAssoc;
|
|
23
28
|
protected errorInBase: string | undefined;
|
|
24
|
-
state: {
|
|
25
|
-
suggestions: any[];
|
|
26
|
-
};
|
|
27
29
|
constructor(props: XAutoCompleteProps);
|
|
28
|
-
componentDidMount(): void;
|
|
29
|
-
readAndSetSuggestions(setStateCallback?: () => void): Promise<void>;
|
|
30
30
|
getField(): string;
|
|
31
31
|
isNotNull(): boolean;
|
|
32
|
+
getFirstDisplayField(): string;
|
|
32
33
|
getValue(): any | null;
|
|
33
34
|
onChangeAutoCompleteBase(object: any, objectChange: OperationType): void;
|
|
34
35
|
onErrorChangeAutoCompleteBase(error: string | undefined): void;
|
|
35
|
-
onSearchStart(finishSearchStart?: () => void): void;
|
|
36
36
|
validate(): {
|
|
37
37
|
field: string;
|
|
38
38
|
xError: XError;
|
|
@@ -14,42 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
19
|
};
|
|
@@ -57,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
57
21
|
exports.XAutoComplete = void 0;
|
|
58
22
|
var react_1 = __importDefault(require("react"));
|
|
59
23
|
var XFormComponent_1 = require("./XFormComponent");
|
|
60
|
-
var XUtils_1 = require("./XUtils");
|
|
61
24
|
var XAutoCompleteBase_1 = require("./XAutoCompleteBase");
|
|
62
25
|
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
63
26
|
var XAutoComplete = /** @class */ (function (_super) {
|
|
@@ -66,65 +29,32 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
66
29
|
var _this = _super.call(this, props) || this;
|
|
67
30
|
_this.xAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXAssocToOne(XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.form.getEntity()), props.assocField);
|
|
68
31
|
_this.errorInBase = undefined;
|
|
69
|
-
_this.state = {
|
|
70
|
-
suggestions: []
|
|
71
|
-
};
|
|
72
32
|
_this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
|
|
73
33
|
_this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
|
|
74
|
-
|
|
75
|
-
props.form.addField(props.assocField + '.' + props.displayField);
|
|
34
|
+
props.form.addField(props.assocField + '.' + _this.getFirstDisplayField());
|
|
76
35
|
return _this;
|
|
77
36
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!this.props.lazy) {
|
|
81
|
-
this.readAndSetSuggestions();
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
XAutoComplete.prototype.readAndSetSuggestions = function (setStateCallback) {
|
|
85
|
-
var _a;
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var suggestions;
|
|
88
|
-
return __generator(this, function (_b) {
|
|
89
|
-
switch (_b.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
if (!(this.props.suggestions === undefined)) return [3 /*break*/, 2];
|
|
92
|
-
return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), (_a = this.props.sortField) !== null && _a !== void 0 ? _a : this.props.displayField, this.props.fields)];
|
|
93
|
-
case 1:
|
|
94
|
-
suggestions = _b.sent();
|
|
95
|
-
this.setState({ suggestions: suggestions }, setStateCallback);
|
|
96
|
-
_b.label = 2;
|
|
97
|
-
case 2: return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
};
|
|
37
|
+
// componentDidMount() {
|
|
38
|
+
// }
|
|
102
39
|
XAutoComplete.prototype.getField = function () {
|
|
103
40
|
return this.props.assocField;
|
|
104
41
|
};
|
|
105
42
|
XAutoComplete.prototype.isNotNull = function () {
|
|
106
43
|
return !this.xAssoc.isNullable;
|
|
107
44
|
};
|
|
45
|
+
XAutoComplete.prototype.getFirstDisplayField = function () {
|
|
46
|
+
return Array.isArray(this.props.displayField) ? this.props.displayField[0] : this.props.displayField;
|
|
47
|
+
};
|
|
108
48
|
XAutoComplete.prototype.getValue = function () {
|
|
109
49
|
var assocObject = this.getValueFromObject();
|
|
110
50
|
return assocObject;
|
|
111
51
|
};
|
|
112
52
|
XAutoComplete.prototype.onChangeAutoCompleteBase = function (object, objectChange) {
|
|
113
53
|
this.onValueChangeBase(object, this.props.onChange, objectChange);
|
|
114
|
-
if (objectChange !== XUtils_1.OperationType.None) {
|
|
115
|
-
// zmenil sa zaznam dobrovolnika v DB
|
|
116
|
-
// zatial len refreshneme z DB
|
|
117
|
-
// ak by bol reqest pomaly, mozme pri inserte (nove id) / update (existujuce id) upravit zoznam a usetrime tym request do DB
|
|
118
|
-
// ak bol delete (dobrovolnik === null), treba urobit refresh do DB (alebo si poslat id-cko zmazaneho zaznamu)
|
|
119
|
-
this.readAndSetSuggestions();
|
|
120
|
-
}
|
|
121
54
|
};
|
|
122
55
|
XAutoComplete.prototype.onErrorChangeAutoCompleteBase = function (error) {
|
|
123
56
|
this.errorInBase = error; // odlozime si error
|
|
124
57
|
};
|
|
125
|
-
XAutoComplete.prototype.onSearchStart = function (finishSearchStart) {
|
|
126
|
-
this.readAndSetSuggestions(finishSearchStart);
|
|
127
|
-
};
|
|
128
58
|
// overrides method in XFormComponent
|
|
129
59
|
XAutoComplete.prototype.validate = function () {
|
|
130
60
|
if (this.errorInBase) {
|
|
@@ -136,12 +66,11 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
136
66
|
};
|
|
137
67
|
XAutoComplete.prototype.render = function () {
|
|
138
68
|
var _this = this;
|
|
139
|
-
var _a;
|
|
140
69
|
var xEntityAssoc = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.xAssoc.entityName);
|
|
141
70
|
// div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
|
|
142
71
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
143
72
|
react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
144
|
-
react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(),
|
|
73
|
+
react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(), onChange: this.onChangeAutoCompleteBase, field: this.props.displayField, searchBrowse: this.props.searchBrowse, valueForm: this.props.assocForm, idField: xEntityAssoc.idField, readOnly: this.isReadOnly(), error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase, width: this.props.width, scrollHeight: this.props.scrollHeight, suggestions: this.props.suggestions, suggestionsLoad: this.props.suggestionsLoad, lazyLoadMaxRows: this.props.lazyLoadMaxRows, splitQueryValue: this.props.splitQueryValue, minLength: this.props.minLength, suggestionsQuery: { entity: this.xAssoc.entityName, filter: function () { return _this.getFilterBase(_this.props.filter); }, sortField: this.props.sortField, fields: this.props.fields } })));
|
|
145
74
|
};
|
|
146
75
|
return XAutoComplete;
|
|
147
76
|
}(XFormComponent_1.XFormComponent));
|
|
@@ -4,41 +4,69 @@ import { OperationType } from "./XUtils";
|
|
|
4
4
|
import { MenuItem } from "primereact/menuitem";
|
|
5
5
|
import { XSearchBrowseParams } from "./XSearchBrowseParams";
|
|
6
6
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
7
|
+
import { DataTableSortMeta } from "primereact/datatable";
|
|
8
|
+
export type XSuggestionsLoadProp = "eager" | "onSearchStart" | "lazy";
|
|
9
|
+
export type XSuggestionsLoadType = "suggestions" | XSuggestionsLoadProp;
|
|
10
|
+
export type XFilterOrFunction = XCustomFilter | (() => XCustomFilter | undefined);
|
|
11
|
+
export interface XQuery {
|
|
12
|
+
entity: string;
|
|
13
|
+
filter?: XFilterOrFunction;
|
|
14
|
+
sortField?: string | DataTableSortMeta[];
|
|
15
|
+
fields?: string[];
|
|
16
|
+
}
|
|
7
17
|
export interface XAutoCompleteBaseProps {
|
|
8
18
|
value: any;
|
|
9
|
-
suggestions: any[];
|
|
10
19
|
onChange: (object: any, objectChange: OperationType) => void;
|
|
11
|
-
|
|
20
|
+
suggestions?: any[];
|
|
21
|
+
suggestionsLoad?: XSuggestionsLoadProp;
|
|
22
|
+
suggestionsQuery?: XQuery;
|
|
23
|
+
lazyLoadMaxRows: number;
|
|
24
|
+
field: string | string[];
|
|
25
|
+
splitQueryValue: boolean;
|
|
12
26
|
searchBrowse?: JSX.Element;
|
|
13
27
|
valueForm?: JSX.Element;
|
|
14
28
|
idField?: string;
|
|
15
|
-
|
|
29
|
+
minLength?: number;
|
|
16
30
|
width?: string;
|
|
31
|
+
scrollHeight?: string;
|
|
17
32
|
readOnly?: boolean;
|
|
18
33
|
error?: string;
|
|
19
34
|
onErrorChange: (error: string | undefined) => void;
|
|
20
35
|
setFocusOnCreate?: boolean;
|
|
21
|
-
customFilterFunction?: () => XCustomFilter | undefined;
|
|
22
|
-
onSearchStart?: (finishSearchStart?: () => void) => void;
|
|
23
36
|
}
|
|
24
37
|
export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps> {
|
|
38
|
+
private static valueMoreSuggestions;
|
|
39
|
+
static defaultProps: {
|
|
40
|
+
lazyLoadMaxRows: number;
|
|
41
|
+
splitQueryValue: boolean;
|
|
42
|
+
minLength: number;
|
|
43
|
+
scrollHeight: string;
|
|
44
|
+
};
|
|
25
45
|
autoCompleteRef: any;
|
|
26
46
|
state: {
|
|
27
47
|
inputChanged: boolean;
|
|
28
48
|
inputValueState: string | undefined;
|
|
29
49
|
notValid: boolean;
|
|
50
|
+
suggestions: any[] | undefined;
|
|
30
51
|
filteredSuggestions: any[] | undefined;
|
|
31
52
|
formDialogOpened: boolean;
|
|
32
53
|
searchDialogOpened: boolean;
|
|
33
54
|
};
|
|
34
|
-
|
|
55
|
+
suggestionsLoadedForOSS: boolean;
|
|
56
|
+
wasOnChangeCalled: boolean;
|
|
35
57
|
formDialogObjectId: number | undefined;
|
|
36
58
|
formDialogInitValuesForInsert: any | undefined;
|
|
37
59
|
constructor(props: XAutoCompleteBaseProps);
|
|
60
|
+
getXSuggestionsLoadType(): XSuggestionsLoadType;
|
|
61
|
+
getFields(): string[];
|
|
62
|
+
getFirstField(): string;
|
|
38
63
|
componentDidMount(): void;
|
|
64
|
+
loadSuggestions(): Promise<void>;
|
|
65
|
+
fetchSuggestions(): Promise<any[]>;
|
|
66
|
+
getSortField(): string | DataTableSortMeta[] | undefined;
|
|
39
67
|
completeMethod(event: {
|
|
40
68
|
query: string;
|
|
41
|
-
}): void
|
|
69
|
+
}): Promise<void>;
|
|
42
70
|
onChange(e: AutoCompleteChangeEvent): void;
|
|
43
71
|
onSelect(e: any): void;
|
|
44
72
|
onBlur(e: React.FocusEvent<HTMLInputElement>): void;
|
|
@@ -54,7 +82,11 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
54
82
|
createDropdownItem(splitButtonItems: MenuItem[]): void;
|
|
55
83
|
onOpenDropdown(e: any): void;
|
|
56
84
|
openDropdown(e: any): void;
|
|
85
|
+
onEditAssocValue(): void;
|
|
57
86
|
computeInputValue(): any;
|
|
87
|
+
itemTemplate(suggestion: any, index: number): React.ReactNode;
|
|
88
|
+
computeDisplayValue(suggestion: any): string;
|
|
89
|
+
static isMoreSuggestions(suggestion: any): boolean;
|
|
58
90
|
createSearchBrowseParams(): XSearchBrowseParams;
|
|
59
91
|
render(): JSX.Element;
|
|
60
92
|
}
|