@michalrakus/x-react-web-lib 1.15.0 → 1.17.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/XInputTextareaBase.d.ts +3 -0
- package/XInputTextareaBase.js +5 -0
- package/gulpfile.js +1 -0
- package/lib/components/XAutoComplete.d.ts +1 -0
- package/lib/components/XAutoComplete.js +1 -1
- package/lib/components/XCalendar.d.ts +1 -0
- package/lib/components/XCalendar.js +13 -1
- package/lib/components/XEnvVars.d.ts +2 -0
- package/lib/components/XEnvVars.js +2 -0
- package/lib/components/XFormBase.d.ts +3 -3
- package/lib/components/XFormBase.js +96 -76
- package/lib/components/XFormRowCol/XFormRowCol.js +10 -8
- package/lib/components/XInputDate.js +1 -1
- package/lib/components/XInputTextarea.d.ts +4 -3
- package/lib/components/XInputTextarea.js +7 -19
- package/lib/components/XInputTextareaBase.d.ts +13 -0
- package/lib/components/XInputTextareaBase.js +92 -0
- package/lib/components/XLazyDataTable.d.ts +2 -0
- package/lib/components/XLazyDataTable.js +22 -8
- package/lib/components/XUtilsMetadata.js +1 -1
- package/lib/serverApi/XUtilsCommon.d.ts +1 -0
- package/lib/serverApi/XUtilsCommon.js +4 -0
- package/lib/serverApi/XUtilsConversions.d.ts +1 -1
- package/lib/serverApi/XUtilsConversions.js +9 -4
- package/package.json +2 -2
package/gulpfile.js
CHANGED
|
@@ -55,6 +55,7 @@ function generateApi(cb) {
|
|
|
55
55
|
"./lib/components/XInputIntervalBase",
|
|
56
56
|
"./lib/components/XInputText",
|
|
57
57
|
"./lib/components/XInputTextarea",
|
|
58
|
+
"./lib/components/XInputTextareaBase",
|
|
58
59
|
"./lib/components/XLazyDataTable",
|
|
59
60
|
"./lib/components/XLocale",
|
|
60
61
|
"./lib/components/XLoginDialog",
|
|
@@ -89,7 +89,7 @@ var XAutoComplete = /** @class */ (function (_super) {
|
|
|
89
89
|
switch (_b.label) {
|
|
90
90
|
case 0:
|
|
91
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)];
|
|
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
93
|
case 1:
|
|
94
94
|
suggestions = _b.sent();
|
|
95
95
|
this.setState({ suggestions: suggestions }, setStateCallback);
|
|
@@ -5,5 +5,6 @@ export declare const XCalendar: (props: {
|
|
|
5
5
|
onChange: (value: Date | null) => void;
|
|
6
6
|
onBlur?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
7
7
|
readOnly?: boolean | undefined;
|
|
8
|
+
error?: string | undefined;
|
|
8
9
|
datetime?: boolean | undefined;
|
|
9
10
|
}) => JSX.Element;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -7,6 +18,7 @@ exports.XCalendar = void 0;
|
|
|
7
18
|
var react_1 = __importDefault(require("react"));
|
|
8
19
|
var calendar_1 = require("primereact/calendar");
|
|
9
20
|
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
21
|
+
var XUtils_1 = require("./XUtils");
|
|
10
22
|
// wrapper for Calendar component, maybe better name would be XInputDateBase
|
|
11
23
|
var XCalendar = function (props) {
|
|
12
24
|
var _a;
|
|
@@ -22,6 +34,6 @@ var XCalendar = function (props) {
|
|
|
22
34
|
}
|
|
23
35
|
};
|
|
24
36
|
var datetime = (_a = props.datetime) !== null && _a !== void 0 ? _a : false;
|
|
25
|
-
return (react_1.default.createElement(calendar_1.Calendar, { id: props.id, value: props.value, onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date', onBlur: props.onBlur }));
|
|
37
|
+
return (react_1.default.createElement(calendar_1.Calendar, __assign({ id: props.id, value: props.value, onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date', onBlur: props.onBlur }, XUtils_1.XUtils.createErrorProps(props.error))));
|
|
26
38
|
};
|
|
27
39
|
exports.XCalendar = XCalendar;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare enum XEnvVar {
|
|
2
2
|
REACT_APP_BACKEND_URL = "REACT_APP_BACKEND_URL",
|
|
3
3
|
REACT_APP_AUTH = "REACT_APP_AUTH",
|
|
4
|
+
REACT_APP_AUTH_OFF_USERNAME = "REACT_APP_AUTH_OFF_USERNAME",
|
|
4
5
|
REACT_APP_AUTH0_DOMAIN = "REACT_APP_AUTH0_DOMAIN",
|
|
5
6
|
REACT_APP_AUTH0_CLIENT_ID = "REACT_APP_AUTH0_CLIENT_ID",
|
|
6
7
|
REACT_APP_AUTH0_AUDIENCE = "REACT_APP_AUTH0_AUDIENCE",
|
|
@@ -9,6 +10,7 @@ export declare enum XEnvVar {
|
|
|
9
10
|
REACT_APP_MS_ENTRA_ID_BACKEND_SCOPE = "REACT_APP_MS_ENTRA_ID_BACKEND_SCOPE"
|
|
10
11
|
}
|
|
11
12
|
export declare enum XReactAppAuth {
|
|
13
|
+
OFF = "OFF",
|
|
12
14
|
LOCAL = "LOCAL",
|
|
13
15
|
AUTH0 = "AUTH0",
|
|
14
16
|
MS_ENTRA_ID = "MS_ENTRA_ID"
|
|
@@ -6,6 +6,7 @@ var XEnvVar;
|
|
|
6
6
|
(function (XEnvVar) {
|
|
7
7
|
XEnvVar["REACT_APP_BACKEND_URL"] = "REACT_APP_BACKEND_URL";
|
|
8
8
|
XEnvVar["REACT_APP_AUTH"] = "REACT_APP_AUTH";
|
|
9
|
+
XEnvVar["REACT_APP_AUTH_OFF_USERNAME"] = "REACT_APP_AUTH_OFF_USERNAME";
|
|
9
10
|
XEnvVar["REACT_APP_AUTH0_DOMAIN"] = "REACT_APP_AUTH0_DOMAIN";
|
|
10
11
|
XEnvVar["REACT_APP_AUTH0_CLIENT_ID"] = "REACT_APP_AUTH0_CLIENT_ID";
|
|
11
12
|
XEnvVar["REACT_APP_AUTH0_AUDIENCE"] = "REACT_APP_AUTH0_AUDIENCE";
|
|
@@ -17,6 +18,7 @@ var XEnvVar;
|
|
|
17
18
|
// enum for values of the environment variable REACT_APP_AUTH
|
|
18
19
|
var XReactAppAuth;
|
|
19
20
|
(function (XReactAppAuth) {
|
|
21
|
+
XReactAppAuth["OFF"] = "OFF";
|
|
20
22
|
XReactAppAuth["LOCAL"] = "LOCAL";
|
|
21
23
|
XReactAppAuth["AUTH0"] = "AUTH0";
|
|
22
24
|
XReactAppAuth["MS_ENTRA_ID"] = "MS_ENTRA_ID";
|
|
@@ -55,15 +55,15 @@ export declare abstract class XFormBase extends Component<XFormProps> {
|
|
|
55
55
|
formReadOnlyBase(field: string): boolean;
|
|
56
56
|
onClickSave(): Promise<void>;
|
|
57
57
|
onClickCancel(): void;
|
|
58
|
-
validateSave(): boolean
|
|
59
|
-
validateForm(): XErrorMap
|
|
58
|
+
validateSave(): Promise<boolean>;
|
|
59
|
+
validateForm(): Promise<XErrorMap>;
|
|
60
60
|
fieldValidation(): XErrorMap;
|
|
61
61
|
getErrorMessagesForAssoc(oneToManyAssoc: string): string;
|
|
62
62
|
static saveErrorsIntoXRowTechData(row: any, xErrors: XErrors): void;
|
|
63
63
|
formReadOnly(object: XObject, field: string): boolean;
|
|
64
64
|
createNewObject(): XObject;
|
|
65
65
|
preInitForm(object: XObject, operationType: OperationType.Insert | OperationType.Update): void;
|
|
66
|
-
validate(object: XObject): XErrors
|
|
66
|
+
validate(object: XObject): Promise<XErrors>;
|
|
67
67
|
preSave(object: XObject): void;
|
|
68
68
|
saveRow(): Promise<any>;
|
|
69
69
|
}
|
|
@@ -383,9 +383,9 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
383
383
|
var isAddRow, object, e_4;
|
|
384
384
|
return __generator(this, function (_a) {
|
|
385
385
|
switch (_a.label) {
|
|
386
|
-
case 0:
|
|
387
|
-
|
|
388
|
-
if (!
|
|
386
|
+
case 0: return [4 /*yield*/, this.validateSave()];
|
|
387
|
+
case 1:
|
|
388
|
+
if (!(_a.sent())) {
|
|
389
389
|
return [2 /*return*/];
|
|
390
390
|
}
|
|
391
391
|
// docasne na testovanie
|
|
@@ -402,18 +402,18 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
402
402
|
// }
|
|
403
403
|
this.preSave(this.state.object);
|
|
404
404
|
isAddRow = this.isAddRow();
|
|
405
|
-
_a.label =
|
|
406
|
-
case 1:
|
|
407
|
-
_a.trys.push([1, 3, , 4]);
|
|
408
|
-
return [4 /*yield*/, this.saveRow()];
|
|
405
|
+
_a.label = 2;
|
|
409
406
|
case 2:
|
|
410
|
-
|
|
411
|
-
return [
|
|
407
|
+
_a.trys.push([2, 4, , 5]);
|
|
408
|
+
return [4 /*yield*/, this.saveRow()];
|
|
412
409
|
case 3:
|
|
410
|
+
object = _a.sent();
|
|
411
|
+
return [3 /*break*/, 5];
|
|
412
|
+
case 4:
|
|
413
413
|
e_4 = _a.sent();
|
|
414
414
|
XUtils_1.XUtils.showErrorMessage("Save row failed.", e_4);
|
|
415
415
|
return [2 /*return*/]; // zostavame vo formulari
|
|
416
|
-
case
|
|
416
|
+
case 5:
|
|
417
417
|
if (this.props.onSaveOrCancel !== undefined) {
|
|
418
418
|
// formular je zobrazeny v dialogu
|
|
419
419
|
this.props.onSaveOrCancel(object, isAddRow ? XUtils_1.OperationType.Insert : XUtils_1.OperationType.Update);
|
|
@@ -438,74 +438,90 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
440
|
XFormBase.prototype.validateSave = function () {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
441
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
442
|
+
var xErrorMap, msg, _a, _b, xFormDataTable, _c, _d, assocToValidate, ok;
|
|
443
|
+
var e_5, _e, e_6, _f;
|
|
444
|
+
return __generator(this, function (_g) {
|
|
445
|
+
switch (_g.label) {
|
|
446
|
+
case 0: return [4 /*yield*/, this.validateForm()];
|
|
447
|
+
case 1:
|
|
448
|
+
xErrorMap = _g.sent();
|
|
449
|
+
msg = XUtils_1.XUtils.getErrorMessages(xErrorMap);
|
|
450
|
+
try {
|
|
451
|
+
// este spracujeme editovatelne tabulky
|
|
452
|
+
for (_a = __values(this.xFormDataTableList), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
453
|
+
xFormDataTable = _b.value;
|
|
454
|
+
//msg += xFormDataTable.getErrorMessages();
|
|
455
|
+
msg += this.getErrorMessagesForAssoc(xFormDataTable.props.assocField);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
459
|
+
finally {
|
|
460
|
+
try {
|
|
461
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
462
|
+
}
|
|
463
|
+
finally { if (e_5) throw e_5.error; }
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
// este spracujeme oneToMany asociacie, ktore boli explicitne uvedene, ze ich treba validovat
|
|
467
|
+
// (validaciu treba nakodit vo formulari, zavolat z metody validate() a ukoncit zavolanim XFormBase.saveErrorsIntoXRowTechData)
|
|
468
|
+
for (_c = __values(this.assocToValidateList), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
469
|
+
assocToValidate = _d.value;
|
|
470
|
+
msg += this.getErrorMessagesForAssoc(assocToValidate);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
474
|
+
finally {
|
|
475
|
+
try {
|
|
476
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
477
|
+
}
|
|
478
|
+
finally { if (e_6) throw e_6.error; }
|
|
479
|
+
}
|
|
480
|
+
ok = true;
|
|
481
|
+
if (msg !== "") {
|
|
482
|
+
alert(msg);
|
|
483
|
+
ok = false;
|
|
484
|
+
}
|
|
485
|
+
return [2 /*return*/, ok];
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
});
|
|
481
489
|
};
|
|
482
490
|
XFormBase.prototype.validateForm = function () {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
492
|
+
var xErrorMap, xErrors, _a, _b, _c, field, error, xFormComponent, fieldLabel;
|
|
493
|
+
var e_7, _d;
|
|
494
|
+
return __generator(this, function (_e) {
|
|
495
|
+
switch (_e.label) {
|
|
496
|
+
case 0:
|
|
497
|
+
xErrorMap = this.fieldValidation();
|
|
498
|
+
return [4 /*yield*/, this.validate(this.getXObject())];
|
|
499
|
+
case 1:
|
|
500
|
+
xErrors = _e.sent();
|
|
501
|
+
try {
|
|
502
|
+
for (_a = __values(Object.entries(xErrors)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
503
|
+
_c = __read(_b.value, 2), field = _c[0], error = _c[1];
|
|
504
|
+
if (error) {
|
|
505
|
+
xFormComponent = this.findXFormComponent(field);
|
|
506
|
+
fieldLabel = xFormComponent ? xFormComponent.getLabel() : undefined;
|
|
507
|
+
xErrorMap[field] = __assign(__assign({}, xErrorMap[field]), { form: error, fieldLabel: fieldLabel });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
512
|
+
finally {
|
|
513
|
+
try {
|
|
514
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
515
|
+
}
|
|
516
|
+
finally { if (e_7) throw e_7.error; }
|
|
517
|
+
}
|
|
518
|
+
// TODO - optimalizacia - netreba setovat stav ak by sme sli prec z formulara (ak by zbehla validacia aj save a isli by sme naspet do browsu)
|
|
519
|
+
// setujeme aj this.state.object, lebo mohli pribudnut/odbudnut chyby na rowData v editovatelnych tabulkach
|
|
520
|
+
this.setState({ object: this.state.object, errorMap: xErrorMap });
|
|
521
|
+
return [2 /*return*/, xErrorMap];
|
|
495
522
|
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
499
|
-
finally {
|
|
500
|
-
try {
|
|
501
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
502
|
-
}
|
|
503
|
-
finally { if (e_7) throw e_7.error; }
|
|
504
|
-
}
|
|
505
|
-
// TODO - optimalizacia - netreba setovat stav ak by sme sli prec z formulara (ak by zbehla validacia aj save a isli by sme naspet do browsu)
|
|
506
|
-
// setujeme aj this.state.object, lebo mohli pribudnut/odbudnut chyby na rowData v editovatelnych tabulkach
|
|
507
|
-
this.setState({ object: this.state.object, errorMap: xErrorMap });
|
|
508
|
-
return xErrorMap;
|
|
523
|
+
});
|
|
524
|
+
});
|
|
509
525
|
};
|
|
510
526
|
XFormBase.prototype.fieldValidation = function () {
|
|
511
527
|
var e_8, _a, e_9, _b;
|
|
@@ -603,7 +619,11 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
603
619
|
};
|
|
604
620
|
// this method can be overriden in subclass if needed (custom validation)
|
|
605
621
|
XFormBase.prototype.validate = function (object) {
|
|
606
|
-
return {
|
|
622
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
623
|
+
return __generator(this, function (_a) {
|
|
624
|
+
return [2 /*return*/, {}];
|
|
625
|
+
});
|
|
626
|
+
});
|
|
607
627
|
};
|
|
608
628
|
// this method can be overriden in subclass if needed (to modify object before save)
|
|
609
629
|
XFormBase.prototype.preSave = function (object) {
|
|
@@ -11,15 +11,17 @@ var XFormRowCol = function (props) {
|
|
|
11
11
|
// ak chceme zmenit child element, tak treba bud vytvorit novy alebo vyklonovat
|
|
12
12
|
// priklad je na https://soshace.com/building-react-components-using-children-props-and-context-api/
|
|
13
13
|
childElemList = react_1.default.Children.map(props.children, function (child) {
|
|
14
|
+
// chceli by sme klonovat len nase X* komponenty (napr. XInputText)
|
|
15
|
+
// ak vyklonujeme cudziu komponentu (napr. div), funguje, ale prida do nej property labelstyle=[object Object]
|
|
16
|
+
// child.type.name vracia nazov komponenty (napr. XInputText) ale ked sa vytvori optimalizovany build, uz to nefunguje (uz je tam napr. "t")
|
|
17
|
+
// takze zatial klonujeme vzdy
|
|
14
18
|
var _a, _b;
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return child;
|
|
22
|
-
}
|
|
19
|
+
//if (child.type.name && child.type.name.startsWith("X")) {
|
|
20
|
+
return react_1.default.cloneElement(child, { form: (_a = child.props.form) !== null && _a !== void 0 ? _a : props.form, labelStyle: (_b = child.props.labelStyle) !== null && _b !== void 0 ? _b : props.labelStyle });
|
|
21
|
+
//}
|
|
22
|
+
//else {
|
|
23
|
+
// return child;
|
|
24
|
+
//}
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
@@ -56,7 +56,7 @@ var XInputDate = /** @class */ (function (_super) {
|
|
|
56
56
|
// note: style overrides size (width of the input according to character count)
|
|
57
57
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
58
58
|
react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
59
|
-
react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), datetime: this.xField.type === 'datetime', onBlur: this.onBlur })));
|
|
59
|
+
react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), datetime: this.xField.type === 'datetime', onBlur: this.onBlur })));
|
|
60
60
|
};
|
|
61
61
|
return XInputDate;
|
|
62
62
|
}(XInput_1.XInput));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { XInput, XInputProps } from "./XInput";
|
|
3
3
|
export interface XInputTextareaProps extends XInputProps<string> {
|
|
4
|
-
rows
|
|
4
|
+
rows?: number;
|
|
5
5
|
cols?: number | "full";
|
|
6
6
|
labelOnTop?: boolean;
|
|
7
|
+
autoResize?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare class XInputTextarea extends XInput<string, XInputTextareaProps> {
|
|
9
10
|
static defaultProps: {
|
|
@@ -11,8 +12,8 @@ export declare class XInputTextarea extends XInput<string, XInputTextareaProps>
|
|
|
11
12
|
labelOnTop: boolean;
|
|
12
13
|
};
|
|
13
14
|
constructor(props: XInputTextareaProps);
|
|
14
|
-
getValue(): string;
|
|
15
|
-
onValueChange(
|
|
15
|
+
getValue(): string | null;
|
|
16
|
+
onValueChange(value: string | null): void;
|
|
16
17
|
getLabelStyle(): React.CSSProperties;
|
|
17
18
|
render(): JSX.Element;
|
|
18
19
|
}
|
|
@@ -14,27 +14,15 @@ 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 __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
19
|
};
|
|
31
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
21
|
exports.XInputTextarea = void 0;
|
|
33
22
|
var react_1 = __importDefault(require("react"));
|
|
34
|
-
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
35
23
|
var XInput_1 = require("./XInput");
|
|
36
|
-
var inputtextarea_1 = require("primereact/inputtextarea");
|
|
37
24
|
var XUtils_1 = require("./XUtils");
|
|
25
|
+
var XInputTextareaBase_1 = require("./XInputTextareaBase");
|
|
38
26
|
var XInputTextarea = /** @class */ (function (_super) {
|
|
39
27
|
__extends(XInputTextarea, _super);
|
|
40
28
|
function XInputTextarea(props) {
|
|
@@ -43,12 +31,9 @@ var XInputTextarea = /** @class */ (function (_super) {
|
|
|
43
31
|
return _this;
|
|
44
32
|
}
|
|
45
33
|
XInputTextarea.prototype.getValue = function () {
|
|
46
|
-
|
|
47
|
-
var value = this.getValueFromObject();
|
|
48
|
-
return (0, XUtilsConversions_1.stringAsUI)(value);
|
|
34
|
+
return this.getValueFromObject();
|
|
49
35
|
};
|
|
50
|
-
XInputTextarea.prototype.onValueChange = function (
|
|
51
|
-
var value = (0, XUtilsConversions_1.stringFromUI)(e.target.value);
|
|
36
|
+
XInputTextarea.prototype.onValueChange = function (value) {
|
|
52
37
|
this.onValueChangeBase(value);
|
|
53
38
|
};
|
|
54
39
|
XInputTextarea.prototype.getLabelStyle = function () {
|
|
@@ -72,9 +57,12 @@ var XInputTextarea = /** @class */ (function (_super) {
|
|
|
72
57
|
// aj tak sa asi vzdy bude pouzivat "full"
|
|
73
58
|
cols = this.props.cols;
|
|
74
59
|
}
|
|
60
|
+
// InputTextarea renderujeme az ked mame nacitany object, lebo inac pri autoResize sa nam nenastavi spravna velkost (hodnota nie je k dispozicii pri prvom renderingu)
|
|
75
61
|
return (react_1.default.createElement("div", { className: !this.props.labelOnTop ? 'field grid' : 'field grid x-inputtextarea-label-on-top' },
|
|
76
62
|
react_1.default.createElement("label", { htmlFor: this.props.field, className: !this.props.labelOnTop ? 'col-fixed' : undefined, style: this.getLabelStyle() }, this.getLabel()),
|
|
77
|
-
|
|
63
|
+
this.props.form.state.object ?
|
|
64
|
+
react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: inputStyle, rows: this.props.rows, cols: cols, autoResize: this.props.autoResize, error: this.getError() })
|
|
65
|
+
: null));
|
|
78
66
|
};
|
|
79
67
|
XInputTextarea.defaultProps = {
|
|
80
68
|
cols: "full",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const XInputTextareaBase: (props: {
|
|
3
|
+
id?: string | undefined;
|
|
4
|
+
value: string | null;
|
|
5
|
+
onChange: (value: string | null) => void;
|
|
6
|
+
rows?: number | undefined;
|
|
7
|
+
cols?: number | undefined;
|
|
8
|
+
autoResize?: boolean | undefined;
|
|
9
|
+
readOnly?: boolean | undefined;
|
|
10
|
+
error?: string | undefined;
|
|
11
|
+
style?: React.CSSProperties | undefined;
|
|
12
|
+
maxLength?: number | undefined;
|
|
13
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
+
if (!m) return o;
|
|
39
|
+
var i = m.call(o), r, ar = [], e;
|
|
40
|
+
try {
|
|
41
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) { e = { error: error }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e) throw e.error; }
|
|
49
|
+
}
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.XInputTextareaBase = void 0;
|
|
54
|
+
var react_1 = __importStar(require("react"));
|
|
55
|
+
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
56
|
+
var XUtils_1 = require("./XUtils");
|
|
57
|
+
var inputtextarea_1 = require("primereact/inputtextarea");
|
|
58
|
+
// koli optimalizacii - typovany text si zapisuje do svojej stavovej premennej a onChange zavola az z onBlur
|
|
59
|
+
// pri velkych formularoch je totiz volanie zmeny stavu this.setState({object: this.state.object, errorMap: this.state.errorMap}); pomale
|
|
60
|
+
var XInputTextareaBase = function (props) {
|
|
61
|
+
// true, ak uzivatel typuje hodnotu ale hodnota sa este neda skonvertovat na korektny interval (este nevieme vytvorit IPostgresInterval)
|
|
62
|
+
// false, ak uz mame v inpute korektnu hodnotu - vtedy zavolame props.onChange a posleme mu IPostgresInterval
|
|
63
|
+
var _a = __read((0, react_1.useState)(false), 2), inputChanged = _a[0], setInputChanged = _a[1];
|
|
64
|
+
// pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
|
|
65
|
+
var _b = __read((0, react_1.useState)(undefined), 2), inputValueState = _b[0], setInputValueState = _b[1];
|
|
66
|
+
var onChange = function (e) {
|
|
67
|
+
// conversion to IPostgresInterval will be done in onBlur
|
|
68
|
+
setInputChanged(true);
|
|
69
|
+
setInputValueState(e.target.value);
|
|
70
|
+
};
|
|
71
|
+
var onBlur = function (e) {
|
|
72
|
+
// optimalizacia - testujeme len ak inputChanged === true
|
|
73
|
+
if (inputChanged) {
|
|
74
|
+
var value = (0, XUtilsConversions_1.stringFromUI)(e.target.value);
|
|
75
|
+
props.onChange(value);
|
|
76
|
+
setInputChanged(false);
|
|
77
|
+
setInputValueState(undefined); // pre poriadok
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var getInputValue = function () {
|
|
81
|
+
var inputValue;
|
|
82
|
+
if (inputChanged) {
|
|
83
|
+
inputValue = inputValueState;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
inputValue = (0, XUtilsConversions_1.stringAsUI)(props.value);
|
|
87
|
+
}
|
|
88
|
+
return inputValue;
|
|
89
|
+
};
|
|
90
|
+
return (react_1.default.createElement(inputtextarea_1.InputTextarea, __assign({ id: props.id, value: getInputValue(), onChange: onChange, onBlur: onBlur, readOnly: props.readOnly, maxLength: props.maxLength, style: props.style, rows: props.rows, cols: props.cols, autoResize: props.autoResize }, XUtils_1.XUtils.createErrorProps(props.error))));
|
|
91
|
+
};
|
|
92
|
+
exports.XInputTextareaBase = XInputTextareaBase;
|
|
@@ -53,6 +53,7 @@ export interface XLazyDataTableProps {
|
|
|
53
53
|
customFilter?: XCustomFilter;
|
|
54
54
|
sortField?: string;
|
|
55
55
|
fullTextSearch: boolean | string[];
|
|
56
|
+
multiLineSwitch: boolean;
|
|
56
57
|
searchBrowseParams?: XSearchBrowseParams;
|
|
57
58
|
width?: string;
|
|
58
59
|
dataLoadedState?: [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
@@ -68,6 +69,7 @@ export declare const XLazyDataTable: {
|
|
|
68
69
|
rows: number;
|
|
69
70
|
filterDisplay: string;
|
|
70
71
|
fullTextSearch: boolean;
|
|
72
|
+
multiLineSwitch: boolean;
|
|
71
73
|
scrollable: boolean;
|
|
72
74
|
scrollWidth: string;
|
|
73
75
|
scrollHeight: string;
|
|
@@ -117,6 +117,7 @@ var XInputDecimalBase_1 = require("./XInputDecimalBase");
|
|
|
117
117
|
var XLocale_1 = require("./XLocale");
|
|
118
118
|
var XFtsInput_1 = require("./XFtsInput");
|
|
119
119
|
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
120
|
+
var inputswitch_1 = require("primereact/inputswitch");
|
|
120
121
|
var XLazyDataTable = function (props) {
|
|
121
122
|
var _a;
|
|
122
123
|
// must be here, is used in createInitFilters()
|
|
@@ -226,13 +227,14 @@ var XLazyDataTable = function (props) {
|
|
|
226
227
|
var _f = __read((0, react_1.useState)(filtersInit), 2), filters = _f[0], setFilters = _f[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
|
|
227
228
|
var initFtsInputValue = props.fullTextSearch ? createInitFtsInputValue() : undefined;
|
|
228
229
|
var _g = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValue = _g[0], setFtsInputValue = _g[1];
|
|
229
|
-
var _h = __read((0, react_1.useState)(
|
|
230
|
-
var _j = __read((0, react_1.useState)(
|
|
231
|
-
var _k = __read((
|
|
232
|
-
var _l = __read((0, react_1.useState)(false), 2),
|
|
233
|
-
var _m = __read((0, react_1.useState)(), 2),
|
|
234
|
-
var _o = __read((0, react_1.useState)(
|
|
235
|
-
var _p = __read((0, react_1.useState)(
|
|
230
|
+
var _h = __read((0, react_1.useState)(true), 2), multiLineSwitchValue = _h[0], setMultiLineSwitchValue = _h[1];
|
|
231
|
+
var _j = __read((0, react_1.useState)(props.sortField ? [{ field: props.sortField, order: 1 }] : []), 2), multiSortMeta = _j[0], setMultiSortMeta = _j[1];
|
|
232
|
+
var _k = __read((0, react_1.useState)(null), 2), selectedRow = _k[0], setSelectedRow = _k[1];
|
|
233
|
+
var _l = __read((_a = props.dataLoadedState) !== null && _a !== void 0 ? _a : (0, react_1.useState)(false), 2), dataLoaded = _l[0], setDataLoaded = _l[1]; // priznak kde si zapiseme, ci uz sme nacitali data
|
|
234
|
+
var _m = __read((0, react_1.useState)(false), 2), exportRowsDialogOpened = _m[0], setExportRowsDialogOpened = _m[1];
|
|
235
|
+
var _o = __read((0, react_1.useState)(), 2), exportRowsDialogRowCount = _o[0], setExportRowsDialogRowCount = _o[1]; // param pre dialog
|
|
236
|
+
var _p = __read((0, react_1.useState)(filtersInit), 2), filtersAfterFiltering = _p[0], setFiltersAfterFiltering = _p[1]; // sem si odkladame stav filtra po kliknuti na button Filter (chceme exportovat presne to co vidno vyfiltrovane)
|
|
237
|
+
var _q = __read((0, react_1.useState)(initFtsInputValue), 2), ftsInputValueAfterFiltering = _q[0], setFtsInputValueAfterFiltering = _q[1]; // tak isto ako filtersAfterFiltering
|
|
236
238
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
237
239
|
(0, react_1.useEffect)(function () {
|
|
238
240
|
// jednoduchy sposob - nepouzivame parameter props.displayed a priznak dataLoaded
|
|
@@ -612,6 +614,16 @@ var XLazyDataTable = function (props) {
|
|
|
612
614
|
// ine typy - convertValue vrati string
|
|
613
615
|
// mame zapnutu konverziu fromModel, lebo z json-u nam prichadzaju objekty typu string (napr. pri datumoch)
|
|
614
616
|
valueResult = (0, XUtilsConversions_1.convertValue)(xField, value, true, XUtilsConversions_1.AsUIType.Form);
|
|
617
|
+
// ak mame viacriadkovy text a zapnuty multiLineSwitch (defaultne je zapnuty aj ked nie je zobrazeny)
|
|
618
|
+
if (multiLineSwitchValue) {
|
|
619
|
+
if (xField.type === "string" && typeof valueResult === "string" && valueResult) {
|
|
620
|
+
var lines = valueResult.split(XUtilsCommon_1.XUtilsCommon.newLine);
|
|
621
|
+
if (lines.length >= 2) {
|
|
622
|
+
var elemList = lines.map(function (value, index) { return react_1.default.createElement("div", { key: index }, value); });
|
|
623
|
+
valueResult = react_1.default.createElement("div", null, elemList);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
615
627
|
}
|
|
616
628
|
return valueResult;
|
|
617
629
|
};
|
|
@@ -872,7 +884,8 @@ var XLazyDataTable = function (props) {
|
|
|
872
884
|
react_1.default.createElement("div", { className: "flex justify-content-center align-items-center" },
|
|
873
885
|
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
874
886
|
react_1.default.createElement(XButton_1.XButton, { key: "filter", label: (0, XLocale_1.xLocaleOption)('filter'), onClick: onClickFilter }),
|
|
875
|
-
react_1.default.createElement(XButton_1.XButton, { key: "clearFilter", label: (0, XLocale_1.xLocaleOption)('clearFilter'), onClick: onClickClearFilter })
|
|
887
|
+
react_1.default.createElement(XButton_1.XButton, { key: "clearFilter", label: (0, XLocale_1.xLocaleOption)('clearFilter'), onClick: onClickClearFilter }),
|
|
888
|
+
props.multiLineSwitch ? react_1.default.createElement(inputswitch_1.InputSwitch, { checked: multiLineSwitchValue, onChange: function (e) { return setMultiLineSwitchValue(e.value); }, className: "m-1" }) : null),
|
|
876
889
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
877
890
|
react_1.default.createElement(datatable_1.DataTable, { value: value.rowList, dataKey: dataKey, paginator: props.paginator, rows: rows, totalRecords: value.totalRecords, lazy: true, first: first, onPage: onPage, loading: loading, filterDisplay: props.filterDisplay, filters: filters, onFilter: onFilter, sortMode: "multiple", removableSort: true, multiSortMeta: multiSortMeta, onSort: onSort, selectionMode: "single", selection: selectedRow, onSelectionChange: onSelectionChange, onRowDoubleClick: onRowDoubleClick, ref: dataTableEl, className: "p-datatable-sm x-lazy-datatable", resizableColumns: true, columnResizeMode: "expand", tableStyle: tableStyle, paginatorLeft: paginatorLeft, paginatorRight: paginatorRight, scrollable: props.scrollable, scrollHeight: scrollHeight, style: style }, columnElemList)),
|
|
878
891
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
@@ -891,6 +904,7 @@ exports.XLazyDataTable.defaultProps = {
|
|
|
891
904
|
rows: 10,
|
|
892
905
|
filterDisplay: "row",
|
|
893
906
|
fullTextSearch: true,
|
|
907
|
+
multiLineSwitch: false,
|
|
894
908
|
scrollable: true,
|
|
895
909
|
scrollWidth: 'viewport',
|
|
896
910
|
scrollHeight: 'viewport',
|
|
@@ -126,7 +126,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
126
126
|
width = XUtilsMetadata.computeColumnWidthBase(size, 0.5 + 0.5);
|
|
127
127
|
}
|
|
128
128
|
else if (xField.type === "date") {
|
|
129
|
-
width = XUtilsMetadata.computeColumnWidthBase(
|
|
129
|
+
width = XUtilsMetadata.computeColumnWidthBase(11, 0.25 + 1.25 + 0.25); // napr. 31.12.2021 (poznamka: dal som 11 lebo vo filtri nebolo vidno cely datum), 1.25 rem date picker button
|
|
130
130
|
}
|
|
131
131
|
else if (xField.type === "datetime") {
|
|
132
132
|
width = XUtilsMetadata.computeColumnWidthBase(10 + 9, 0.25 + 1.25 + 0.25); // napr. 31.12.2021 03:03:00
|
|
@@ -10,5 +10,6 @@ export declare class XUtilsCommon {
|
|
|
10
10
|
static getDayName(date: Date | null | undefined): string | undefined;
|
|
11
11
|
static dateAddDays(date: Date | null, days: number): Date | null;
|
|
12
12
|
static findFirstMatch(pattern: RegExp, value: string): string | null;
|
|
13
|
+
static sqlMaxDateIfNull(sqlExp: string): string;
|
|
13
14
|
}
|
|
14
15
|
export declare const dateFormat: any;
|
|
@@ -172,6 +172,10 @@ var XUtilsCommon = /** @class */ (function () {
|
|
|
172
172
|
var match = pattern.exec(value);
|
|
173
173
|
return match != null ? match[0] : null;
|
|
174
174
|
};
|
|
175
|
+
// to be used in sql expressions
|
|
176
|
+
XUtilsCommon.sqlMaxDateIfNull = function (sqlExp) {
|
|
177
|
+
return "coalesce(".concat(sqlExp, ", '9999-12-31'::DATE)");
|
|
178
|
+
};
|
|
175
179
|
XUtilsCommon.newLine = '\n';
|
|
176
180
|
return XUtilsCommon;
|
|
177
181
|
}());
|
|
@@ -3,7 +3,7 @@ import { XField } from "./XEntityMetadata";
|
|
|
3
3
|
export declare function stringFromUI(stringValue: string): string | null;
|
|
4
4
|
export declare function stringAsUI(value: string | null): string;
|
|
5
5
|
export declare function stringAsDB(value: string | null): string;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function intFromUI(stringValue: string): number | null | undefined;
|
|
7
7
|
export declare function numberAsUI(value: number | null, fractionDigits?: number): string;
|
|
8
8
|
export declare function numberFromModel(value: any): number | null;
|
|
9
9
|
export declare function dateFromModel(value: any): Date | null;
|
|
@@ -27,7 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.
|
|
30
|
+
exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsUI = exports.dateFromModel = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
31
31
|
var XUtilsCommon_1 = require("./XUtilsCommon");
|
|
32
32
|
var XLocale_1 = require("../components/XLocale");
|
|
33
33
|
var XUtilsMetadataCommon_1 = require("./XUtilsMetadataCommon");
|
|
@@ -51,17 +51,22 @@ function stringAsDB(value) {
|
|
|
51
51
|
return value !== null ? "'".concat(value.replaceAll("'", "''"), "'") : "NULL";
|
|
52
52
|
}
|
|
53
53
|
exports.stringAsDB = stringAsDB;
|
|
54
|
-
function
|
|
54
|
+
function intFromUI(stringValue) {
|
|
55
|
+
// convert stringValue (e.g. 1234) into integer number
|
|
56
|
+
// if stringValue is invalid, returns undefined
|
|
55
57
|
var value;
|
|
56
58
|
if (stringValue === '') {
|
|
57
59
|
value = null;
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
|
-
value = parseInt(stringValue, 10);
|
|
62
|
+
value = parseInt(stringValue, 10); // 1234xxx vrati number 1234, preto testujeme aj value.toString() !== stringValue
|
|
63
|
+
if (isNaN(value) || value.toString() !== stringValue) {
|
|
64
|
+
value = undefined;
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
return value;
|
|
63
68
|
}
|
|
64
|
-
exports.
|
|
69
|
+
exports.intFromUI = intFromUI;
|
|
65
70
|
function numberAsUI(value, fractionDigits) {
|
|
66
71
|
if (fractionDigits === undefined) {
|
|
67
72
|
fractionDigits = 2; // default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michalrakus/x-react-web-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"primeflex": "^3.3.1",
|
|
42
42
|
"primeicons": "^6.0.1",
|
|
43
|
-
"primereact": "~
|
|
43
|
+
"primereact": "~10.4.0",
|
|
44
44
|
"react": "^18.2.0",
|
|
45
45
|
"react-dom": "^18.2.0",
|
|
46
46
|
"react-transition-group": "^4.4.5"
|