@michalrakus/x-react-web-lib 1.14.0 → 1.16.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.
@@ -12,6 +12,7 @@ export interface XAutoCompleteProps extends XFormComponentProps<XObject> {
12
12
  assocForm?: JSX.Element;
13
13
  filter?: XFilterProp;
14
14
  sortField?: string | DataTableSortMeta[];
15
+ fields?: string[];
15
16
  suggestions?: any[];
16
17
  lazy?: boolean;
17
18
  width?: string;
@@ -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);
@@ -404,8 +404,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
404
404
  // Dialog pre konkretny form:
405
405
  // <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
406
406
  // formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
407
- return (react_1.default.createElement("div", { className: "x-auto-complete-base" },
408
- react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, field: this.props.field, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createErrorProps(error), { style: { width: this.props.width } })),
407
+ return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width } },
408
+ react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, field: this.props.field, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createErrorProps(error))),
409
409
  dropdownButton,
410
410
  this.props.valueForm != undefined && !readOnly ?
411
411
  react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New row' }, react_1.default.cloneElement(this.props.valueForm, {
@@ -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,8 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { XInput, XInputProps } from "./XInput";
3
+ import { CheckboxChangeEvent } from "primereact/checkbox";
3
4
  export declare class XCheckbox extends XInput<boolean, XInputProps<boolean>> {
4
5
  constructor(props: XInputProps<boolean>);
5
6
  getValue(): boolean | null;
6
- onValueChange(e: any): void;
7
+ checkboxOnValueChange(e: CheckboxChangeEvent): void;
8
+ triStateCheckboxOnValueChange(e: any): void;
7
9
  render(): JSX.Element;
8
10
  }
@@ -22,11 +22,13 @@ exports.XCheckbox = void 0;
22
22
  var react_1 = __importDefault(require("react"));
23
23
  var tristatecheckbox_1 = require("primereact/tristatecheckbox");
24
24
  var XInput_1 = require("./XInput");
25
+ var checkbox_1 = require("primereact/checkbox");
25
26
  var XCheckbox = /** @class */ (function (_super) {
26
27
  __extends(XCheckbox, _super);
27
28
  function XCheckbox(props) {
28
29
  var _this = _super.call(this, props) || this;
29
- _this.onValueChange = _this.onValueChange.bind(_this);
30
+ _this.checkboxOnValueChange = _this.checkboxOnValueChange.bind(_this);
31
+ _this.triStateCheckboxOnValueChange = _this.triStateCheckboxOnValueChange.bind(_this);
30
32
  return _this;
31
33
  }
32
34
  XCheckbox.prototype.getValue = function () {
@@ -34,7 +36,10 @@ var XCheckbox = /** @class */ (function (_super) {
34
36
  var value = this.getValueFromObject();
35
37
  return value;
36
38
  };
37
- XCheckbox.prototype.onValueChange = function (e) {
39
+ XCheckbox.prototype.checkboxOnValueChange = function (e) {
40
+ this.onValueChangeBase(e.checked, this.props.onChange);
41
+ };
42
+ XCheckbox.prototype.triStateCheckboxOnValueChange = function (e) {
38
43
  var newValue = e.value;
39
44
  // pri klikani na TriStateCheckbox prichadza v newValue cyklicky: true -> false -> null
40
45
  // ak mame not null atribut, tak pri null hodnote skocime rovno na true
@@ -47,10 +52,19 @@ var XCheckbox = /** @class */ (function (_super) {
47
52
  this.onValueChangeBase(newValue, this.props.onChange);
48
53
  };
49
54
  XCheckbox.prototype.render = function () {
55
+ var _a;
50
56
  // note: style overrides size (width of the input according to character count)
51
- return (react_1.default.createElement("div", { className: "field grid" },
52
- react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
53
- react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, disabled: this.isReadOnly(), style: this.props.inputStyle })));
57
+ // pre not null atributy pouzijeme standardny checkbox aby sme pre false mali prazdny biely checkbox - TODO - pomenit ikonky na TriStateCheckbox aby to pekne sedelo
58
+ var element = this.isNotNull()
59
+ ? react_1.default.createElement(checkbox_1.Checkbox, { id: this.props.field, checked: (_a = this.getValue()) !== null && _a !== void 0 ? _a : false, onChange: this.checkboxOnValueChange, disabled: this.isReadOnly(), style: this.props.inputStyle, tooltip: this.props.tooltip })
60
+ : react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { id: this.props.field, value: this.getValue(), onChange: this.triStateCheckboxOnValueChange, disabled: this.isReadOnly(), style: this.props.inputStyle, tooltip: this.props.tooltip });
61
+ if (!this.props.onlyInput) {
62
+ var label = this.getLabel();
63
+ element = react_1.default.createElement("div", { className: "field grid" },
64
+ label !== undefined ? react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, label) : null,
65
+ element);
66
+ }
67
+ return element;
54
68
  };
55
69
  return XCheckbox;
56
70
  }(XInput_1.XInput));
@@ -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
- //console.log("zavolany onClickSave");
388
- if (!this.validateSave()) {
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 = 1;
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
- object = _a.sent();
411
- return [3 /*break*/, 4];
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 4:
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
- var e_5, _a, e_6, _b;
442
- var xErrorMap = this.validateForm();
443
- // zatial takto jednoducho
444
- var msg = XUtils_1.XUtils.getErrorMessages(xErrorMap);
445
- try {
446
- // este spracujeme editovatelne tabulky
447
- for (var _c = __values(this.xFormDataTableList), _d = _c.next(); !_d.done; _d = _c.next()) {
448
- var xFormDataTable = _d.value;
449
- //msg += xFormDataTable.getErrorMessages();
450
- msg += this.getErrorMessagesForAssoc(xFormDataTable.props.assocField);
451
- }
452
- }
453
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
454
- finally {
455
- try {
456
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
457
- }
458
- finally { if (e_5) throw e_5.error; }
459
- }
460
- try {
461
- // este spracujeme oneToMany asociacie, ktore boli explicitne uvedene, ze ich treba validovat
462
- // (validaciu treba nakodit vo formulari, zavolat z metody validate() a ukoncit zavolanim XFormBase.saveErrorsIntoXRowTechData)
463
- for (var _e = __values(this.assocToValidateList), _f = _e.next(); !_f.done; _f = _e.next()) {
464
- var assocToValidate = _f.value;
465
- msg += this.getErrorMessagesForAssoc(assocToValidate);
466
- }
467
- }
468
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
469
- finally {
470
- try {
471
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
472
- }
473
- finally { if (e_6) throw e_6.error; }
474
- }
475
- var ok = true;
476
- if (msg !== "") {
477
- alert(msg);
478
- ok = false;
479
- }
480
- return ok;
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
- var e_7, _a;
484
- var xErrorMap = this.fieldValidation();
485
- // form validation
486
- var xErrors = this.validate(this.getXObject());
487
- try {
488
- for (var _b = __values(Object.entries(xErrors)), _c = _b.next(); !_c.done; _c = _b.next()) {
489
- var _d = __read(_c.value, 2), field = _d[0], error = _d[1];
490
- if (error) {
491
- // skusime zistit label
492
- var xFormComponent = this.findXFormComponent(field);
493
- var fieldLabel = xFormComponent ? xFormComponent.getLabel() : undefined;
494
- xErrorMap[field] = __assign(__assign({}, xErrorMap[field]), { form: error, fieldLabel: fieldLabel });
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) {
@@ -10,19 +10,22 @@ export type XFilterProp = XCustomFilter | ((object: any) => XCustomFilter | unde
10
10
  export interface XFormComponentProps<T> {
11
11
  form: XFormBase;
12
12
  label?: string;
13
+ tooltip?: string;
13
14
  readOnly?: XReadOnlyProp;
14
15
  labelStyle?: React.CSSProperties;
15
16
  inline?: boolean;
16
17
  onChange?: XFieldOnChange;
18
+ onlyInput?: boolean;
17
19
  }
18
20
  export declare abstract class XFormComponent<T, P extends XFormComponentProps<T>> extends Component<P> {
21
+ private valueChanged;
19
22
  protected constructor(props: P);
20
23
  abstract getField(): string;
21
24
  getValueFromObject(): any;
22
25
  onValueChangeBase(value: any, onChange?: XFieldOnChange, assocObjectChange?: OperationType): void;
23
26
  abstract isNotNull(): boolean;
24
27
  isReadOnly(): boolean;
25
- getLabel(): string;
28
+ getLabel(): string | undefined;
26
29
  getLabelStyle(): React.CSSProperties;
27
30
  validate(): {
28
31
  field: string;
@@ -21,8 +21,10 @@ var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
21
21
  var XUtils_1 = require("./XUtils");
22
22
  var XFormComponent = /** @class */ (function (_super) {
23
23
  __extends(XFormComponent, _super);
24
+ // mali sme problem ze aplikacny onChange sa volal aj ked uzivatel iba klikol do inputu a odisiel z neho
24
25
  function XFormComponent(props) {
25
26
  var _this = _super.call(this, props) || this;
27
+ _this.valueChanged = false;
26
28
  props.form.addXFormComponent(_this);
27
29
  return _this;
28
30
  }
@@ -45,6 +47,7 @@ var XFormComponent = /** @class */ (function (_super) {
45
47
  XFormComponent.prototype.onValueChangeBase = function (value, onChange, assocObjectChange) {
46
48
  var error = this.validateOnChange(value);
47
49
  this.props.form.onFieldChange(this.getField(), value, error, onChange, assocObjectChange);
50
+ this.valueChanged = true;
48
51
  };
49
52
  XFormComponent.prototype.isReadOnly = function () {
50
53
  var readOnly;
@@ -76,12 +79,14 @@ var XFormComponent = /** @class */ (function (_super) {
76
79
  }
77
80
  return readOnly;
78
81
  };
82
+ // ak je label undefined, label element sa nevykresli
79
83
  XFormComponent.prototype.getLabel = function () {
80
- var _a;
81
- var label = (_a = this.props.label) !== null && _a !== void 0 ? _a : this.getField();
82
- // test na readOnly je tu hlavne koli tomu aby sme nemali * pri ID atribute, ktory sa pri inserte generuje az pri zapise do DB
83
- if (this.isNotNull() && !this.isReadOnly()) {
84
- label = XUtils_1.XUtils.markNotNull(label);
84
+ var label = this.props.label;
85
+ if (label !== undefined) {
86
+ // test na readOnly je tu hlavne koli tomu aby sme nemali * pri ID atribute, ktory sa pri inserte generuje az pri zapise do DB
87
+ if (this.isNotNull() && !this.isReadOnly()) {
88
+ label = XUtils_1.XUtils.markNotNull(label);
89
+ }
85
90
  }
86
91
  return label;
87
92
  };
@@ -147,12 +152,13 @@ var XFormComponent = /** @class */ (function (_super) {
147
152
  return error ? XUtils_1.XUtils.getErrorMessage(error) : undefined;
148
153
  };
149
154
  XFormComponent.prototype.callOnChangeFromOnBlur = function () {
150
- if (this.props.onChange) {
155
+ if (this.valueChanged && this.props.onChange) {
151
156
  var object = this.props.form.getXObject();
152
157
  // developer v onChange nastavi atributy na object-e
153
158
  this.props.onChange({ object: object });
154
159
  // rovno zavolame form.setState({...}), nech to nemusi robit developer
155
160
  this.props.form.setStateXForm();
161
+ this.valueChanged = false; // resetneme na false (dalsi onChange volame az ked user zmeni hodnotu)
156
162
  }
157
163
  };
158
164
  // len pre assoc fieldy sa pouziva
@@ -12,6 +12,7 @@ export interface XFormComponentDTProps {
12
12
  onChange?: XTableFieldOnChange;
13
13
  }
14
14
  export declare abstract class XFormComponentDT<P extends XFormComponentDTProps> extends Component<P> {
15
+ private valueChanged;
15
16
  protected constructor(props: P);
16
17
  abstract getField(): string;
17
18
  getValueFromRowData(): any;
@@ -24,6 +24,7 @@ var XFormComponentDT = /** @class */ (function (_super) {
24
24
  __extends(XFormComponentDT, _super);
25
25
  function XFormComponentDT(props) {
26
26
  var _this = _super.call(this, props) || this;
27
+ _this.valueChanged = false;
27
28
  XFormBase_1.XFormBase.getXRowTechData(props.rowData).xFormComponentDTList.push(_this);
28
29
  return _this;
29
30
  }
@@ -46,6 +47,7 @@ var XFormComponentDT = /** @class */ (function (_super) {
46
47
  XFormComponentDT.prototype.onValueChangeBase = function (value, onChange, assocObjectChange) {
47
48
  var error = this.validateOnChange(value);
48
49
  this.props.form.onTableFieldChange(this.props.rowData, this.getField(), value, error, onChange, assocObjectChange);
50
+ this.valueChanged = true;
49
51
  };
50
52
  XFormComponentDT.prototype.isReadOnly = function () {
51
53
  var readOnly;
@@ -114,12 +116,13 @@ var XFormComponentDT = /** @class */ (function (_super) {
114
116
  return error ? XUtils_1.XUtils.getErrorMessage(error) : undefined;
115
117
  };
116
118
  XFormComponentDT.prototype.callOnChangeFromOnBlur = function () {
117
- if (this.props.onChange) {
119
+ if (this.valueChanged && this.props.onChange) {
118
120
  var object = this.props.form.getXObject();
119
121
  // developer v onChange nastavi atributy na object-e
120
122
  this.props.onChange({ object: object, tableRow: this.props.rowData, assocObjectChange: undefined });
121
123
  // rovno zavolame form.setState({...}), nech to nemusi robit developer
122
124
  this.props.form.setStateXForm();
125
+ this.valueChanged = false; // resetneme na false (dalsi onChange volame az ked user zmeni hodnotu)
123
126
  }
124
127
  };
125
128
  // len pre assoc fieldy sa pouziva, aj to nie pre vsetky
@@ -1,6 +1,7 @@
1
1
  import { XFormBase } from "./XFormBase";
2
- import { Component, ReactChild } from "react";
2
+ import React, { Component, ReactChild } from "react";
3
3
  import { DataTableFilterMeta } from "primereact/datatable";
4
+ import { ColumnBodyOptions } from "primereact/column";
4
5
  import { XEntity, XField } from "../serverApi/XEntityMetadata";
5
6
  import { XViewStatusOrBoolean } from "./XUtils";
6
7
  import { FilterMatchMode } from "primereact/api";
@@ -91,7 +92,7 @@ export type XTableFieldOnChange = (e: XTableFieldChangeEvent<any, any>) => void;
91
92
  export type XTableFieldReadOnlyProp = boolean | ((object: any, tableRow: any) => boolean);
92
93
  export type XTableFieldFilterProp = XCustomFilter | ((object: any, rowData: any) => XCustomFilter | undefined);
93
94
  export interface XFormColumnBaseProps {
94
- type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton";
95
+ type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton" | "custom";
95
96
  header?: any;
96
97
  readOnly?: XTableFieldReadOnlyProp;
97
98
  dropdownInFilter?: boolean;
@@ -122,6 +123,10 @@ export interface XFormSearchButtonColumnProps extends XFormColumnBaseProps {
122
123
  displayField: string;
123
124
  searchBrowse: JSX.Element;
124
125
  }
126
+ export interface XFormCustomColumnProps extends XFormColumnBaseProps {
127
+ body: React.ReactNode | ((data: any, options: ColumnBodyOptions) => React.ReactNode);
128
+ field?: string;
129
+ }
125
130
  export declare const XFormColumn: {
126
131
  (props: XFormColumnProps): null;
127
132
  defaultProps: {
@@ -150,3 +155,10 @@ export declare const XFormSearchButtonColumn: {
150
155
  columnViewStatus: boolean;
151
156
  };
152
157
  };
158
+ export declare const XFormCustomColumn: {
159
+ (props: XFormCustomColumnProps): null;
160
+ defaultProps: {
161
+ type: string;
162
+ columnViewStatus: boolean;
163
+ };
164
+ };
@@ -60,7 +60,7 @@ var __values = (this && this.__values) || function(o) {
60
60
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
61
61
  };
62
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
- exports.XFormSearchButtonColumn = exports.XFormAutoCompleteColumn = exports.XFormDropdownColumn = exports.XFormColumn = exports.XFormDataTable2 = void 0;
63
+ exports.XFormCustomColumn = exports.XFormSearchButtonColumn = exports.XFormAutoCompleteColumn = exports.XFormDropdownColumn = exports.XFormColumn = exports.XFormDataTable2 = void 0;
64
64
  var XFormBase_1 = require("./XFormBase");
65
65
  var react_1 = __importStar(require("react"));
66
66
  var XDropdownDT_1 = require("./XDropdownDT");
@@ -118,8 +118,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
118
118
  for (var _b = __values(props.children), _c = _b.next(); !_c.done; _c = _b.next()) {
119
119
  var child = _c.value;
120
120
  var childColumn = child; // nevedel som to krajsie...
121
- var field = props.assocField + '.' + _this.getPathForColumn(childColumn.props);
122
- props.form.addField(field);
121
+ if (childColumn.props.type !== "custom") {
122
+ var field = props.assocField + '.' + _this.getPathForColumn(childColumn.props);
123
+ props.form.addField(field);
124
+ }
123
125
  }
124
126
  }
125
127
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -231,24 +233,27 @@ var XFormDataTable2 = /** @class */ (function (_super) {
231
233
  for (var _b = __values(this.props.children), _c = _b.next(); !_c.done; _c = _b.next()) {
232
234
  var child = _c.value;
233
235
  var childColumn = child; // nevedel som to krajsie...
234
- var field = this.getPathForColumn(childColumn.props);
235
- var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field);
236
- // TODO column.props.dropdownInFilter - pre "menu" by bolo fajn mat zoznam "enumov"
237
- var filterMatchMode = this.getFilterMatchMode(xField);
238
- var filterItem = void 0;
239
- if (this.props.filterDisplay === "menu") {
240
- // DataTableOperatorFilterMetaData: operator + filter values
241
- filterItem = {
242
- operator: api_1.FilterOperator.OR,
243
- constraints: [{ value: null, matchMode: filterMatchMode }]
244
- };
245
- }
246
- else {
247
- // props.filterDisplay === "row"
248
- // DataTableFilterMetaData: filter value
249
- filterItem = { value: null, matchMode: filterMatchMode };
236
+ // zatial nepodporujeme filter pre custom stlpce
237
+ if (childColumn.props.type !== "custom") {
238
+ var field = this.getPathForColumn(childColumn.props);
239
+ var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field);
240
+ // TODO column.props.dropdownInFilter - pre "menu" by bolo fajn mat zoznam "enumov"
241
+ var filterMatchMode = this.getFilterMatchMode(xField);
242
+ var filterItem = void 0;
243
+ if (this.props.filterDisplay === "menu") {
244
+ // DataTableOperatorFilterMetaData: operator + filter values
245
+ filterItem = {
246
+ operator: api_1.FilterOperator.OR,
247
+ constraints: [{ value: null, matchMode: filterMatchMode }]
248
+ };
249
+ }
250
+ else {
251
+ // props.filterDisplay === "row"
252
+ // DataTableFilterMetaData: filter value
253
+ filterItem = { value: null, matchMode: filterMatchMode };
254
+ }
255
+ initFilters[field] = filterItem;
250
256
  }
251
- initFilters[field] = filterItem;
252
257
  }
253
258
  }
254
259
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -562,72 +567,95 @@ var XFormDataTable2 = /** @class */ (function (_super) {
562
567
  // (vzdy musime robit manipulacie so stlpcom, lebo potrebujeme pridat filter={true} sortable={true}
563
568
  var childColumn = child; // nevedel som to krajsie...
564
569
  var childColumnProps = childColumn.props;
565
- // je dolezite, aby field obsahoval cely path az po zobrazovany atribut, lebo podla neho sa vykonava filtrovanie a sortovanie
566
- // (aj ked, da sa to prebit na stlpcoch (na elemente Column), su na to atributy)
567
- var field = thisLocal.getPathForColumn(childColumnProps);
568
- // TODO - toto by sa mohlo vytiahnut vyssie, aj v bodyTemplate sa vola metoda XUtilsMetadata.getXFieldByPath
569
- var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field);
570
- // *********** header ***********
571
- var header = XFormDataTable2.getHeader(childColumnProps, xEntity, field, xField);
572
- // *********** filterElement ***********
570
+ var fieldParam;
571
+ var header;
573
572
  var filterElement;
574
- if (thisLocal.props.filterDisplay !== "none") {
575
- if (xField.type === "boolean") {
576
- var checkboxValue = thisLocal.getCheckboxFilterValue(field);
577
- filterElement = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: checkboxValue, onChange: function (e) { return thisLocal.onCheckboxFilterChange(field, e.value); } });
578
- }
579
- else if (childColumnProps.dropdownInFilter) {
580
- var dropdownValue = thisLocal.getDropdownFilterValue(field);
581
- filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: thisLocal.getEntity(), path: field, value: dropdownValue, onValueChange: thisLocal.onDropdownFilterChange });
582
- }
573
+ var showFilterMenu;
574
+ var width;
575
+ var align;
576
+ var body;
577
+ if (childColumnProps.type === "custom") {
578
+ // len jednoduche hodnoty, zatial nebude takmer ziadna podpora
579
+ var columnPropsCustom = childColumnProps;
580
+ fieldParam = columnPropsCustom.field;
581
+ header = columnPropsCustom.header;
582
+ filterElement = undefined;
583
+ showFilterMenu = false;
584
+ width = XUtils_1.XUtils.processPropWidth(columnPropsCustom.width);
585
+ align = undefined;
586
+ body = columnPropsCustom.body;
583
587
  }
584
- // *********** showFilterMenu ***********
585
- var showFilterMenu = false;
586
- if (thisLocal.props.filterDisplay !== "none") {
587
- if (childColumnProps.showFilterMenu !== undefined) {
588
- showFilterMenu = childColumnProps.showFilterMenu;
588
+ else {
589
+ // fieldy ktore su v modeli (existuje xField)
590
+ // je dolezite, aby field obsahoval cely path az po zobrazovany atribut, lebo podla neho sa vykonava filtrovanie a sortovanie
591
+ // (aj ked, da sa to prebit na stlpcoch (na elemente Column), su na to atributy)
592
+ var field_1 = thisLocal.getPathForColumn(childColumnProps);
593
+ // TODO - toto by sa mohlo vytiahnut vyssie, aj v bodyTemplate sa vola metoda XUtilsMetadata.getXFieldByPath
594
+ var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field_1);
595
+ // *********** header ***********
596
+ header = XFormDataTable2.getHeader(childColumnProps, xEntity, field_1, xField);
597
+ // *********** filterElement ***********
598
+ if (thisLocal.props.filterDisplay !== "none") {
599
+ if (xField.type === "boolean") {
600
+ var checkboxValue = thisLocal.getCheckboxFilterValue(field_1);
601
+ filterElement = react_1.default.createElement(tristatecheckbox_1.TriStateCheckbox, { value: checkboxValue, onChange: function (e) { return thisLocal.onCheckboxFilterChange(field_1, e.value); } });
602
+ }
603
+ else if (childColumnProps.dropdownInFilter) {
604
+ var dropdownValue = thisLocal.getDropdownFilterValue(field_1);
605
+ filterElement = react_1.default.createElement(XDropdownDTFilter_1.XDropdownDTFilter, { entity: thisLocal.getEntity(), path: field_1, value: dropdownValue, onValueChange: thisLocal.onDropdownFilterChange });
606
+ }
589
607
  }
590
- else {
591
- showFilterMenu = true; // default
592
- if (thisLocal.props.filterDisplay === "row") {
593
- if (xField.type === "boolean" || childColumnProps.dropdownInFilter) {
594
- showFilterMenu = false;
608
+ // *********** showFilterMenu ***********
609
+ showFilterMenu = false;
610
+ if (thisLocal.props.filterDisplay !== "none") {
611
+ if (childColumnProps.showFilterMenu !== undefined) {
612
+ showFilterMenu = childColumnProps.showFilterMenu;
613
+ }
614
+ else {
615
+ showFilterMenu = true; // default
616
+ if (thisLocal.props.filterDisplay === "row") {
617
+ if (xField.type === "boolean" || childColumnProps.dropdownInFilter) {
618
+ showFilterMenu = false;
619
+ }
595
620
  }
596
621
  }
597
622
  }
623
+ // *********** width/headerStyle ***********
624
+ width = XUtils_1.XUtils.processPropWidth(childColumn.props.width);
625
+ if (width === undefined || width === "default") {
626
+ var filterMenuInFilterRow = thisLocal.props.filterDisplay === "row" && showFilterMenu;
627
+ var sortableButtonInHeader = thisLocal.props.sortable;
628
+ var filterButtonInHeader = thisLocal.props.filterDisplay === "menu";
629
+ width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, undefined, filterMenuInFilterRow, childColumnProps.type, header, sortableButtonInHeader, filterButtonInHeader);
630
+ }
631
+ // *********** align ***********
632
+ align = undefined; // default undefined (left)
633
+ // do buducna
634
+ // if (childColumnProps.align !== undefined) {
635
+ // align = childColumnProps.align;
636
+ // }
637
+ // else {
638
+ // decimal defaultne zarovnavame doprava
639
+ // if (xField.type === "decimal") {
640
+ // align = "right";
641
+ // }
642
+ // else
643
+ if (xField.type === "boolean") {
644
+ align = "center";
645
+ }
646
+ // }
647
+ // *********** body ***********
648
+ body = function (rowData) { return thisLocal.bodyTemplate(childColumnProps, readOnly, rowData, xEntity); };
649
+ fieldParam = field_1;
598
650
  }
599
651
  // *********** showClearButton ***********
600
652
  // pre filterDisplay = "row" nechceme clear button, chceme setrit miesto
601
653
  var showClearButton = thisLocal.props.filterDisplay === "menu";
602
- // *********** width/headerStyle ***********
603
- var width = XUtils_1.XUtils.processPropWidth(childColumn.props.width);
604
- if (width === undefined || width === "default") {
605
- var filterMenuInFilterRow = thisLocal.props.filterDisplay === "row" && showFilterMenu;
606
- var sortableButtonInHeader = thisLocal.props.sortable;
607
- var filterButtonInHeader = thisLocal.props.filterDisplay === "menu";
608
- width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, undefined, filterMenuInFilterRow, childColumnProps.type, header, sortableButtonInHeader, filterButtonInHeader);
609
- }
610
654
  var headerStyle = {};
611
655
  if (width !== undefined) {
612
656
  headerStyle = { width: width };
613
657
  }
614
- // *********** align ***********
615
- var align = undefined; // default undefined (left)
616
- // do buducna
617
- // if (childColumnProps.align !== undefined) {
618
- // align = childColumnProps.align;
619
- // }
620
- // else {
621
- // decimal defaultne zarovnavame doprava
622
- // if (xField.type === "decimal") {
623
- // align = "right";
624
- // }
625
- // else
626
- if (xField.type === "boolean") {
627
- align = "center";
628
- }
629
- // }
630
- return react_1.default.createElement(column_1.Column, { field: field, header: header, filter: thisLocal.props.filterDisplay !== "none", sortable: thisLocal.props.sortable, filterElement: filterElement, showFilterMenu: showFilterMenu, showClearButton: showClearButton, headerStyle: headerStyle, align: align, body: function (rowData) { return thisLocal.bodyTemplate(childColumnProps, readOnly, rowData, xEntity); } });
658
+ return react_1.default.createElement(column_1.Column, { field: fieldParam, header: header, filter: thisLocal.props.filterDisplay !== "none", sortable: thisLocal.props.sortable, filterElement: filterElement, showFilterMenu: showFilterMenu, showClearButton: showClearButton, headerStyle: headerStyle, align: align, body: body });
631
659
  });
632
660
  if (this.props.showAddRemoveButtons && this.props.removeButtonInRow) {
633
661
  // je dolezite nastavit sirku header-a, lebo inac ma stlpec sirku 0 a nevidno ho
@@ -695,3 +723,9 @@ var XFormSearchButtonColumn = function (props) {
695
723
  };
696
724
  exports.XFormSearchButtonColumn = XFormSearchButtonColumn;
697
725
  exports.XFormSearchButtonColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "searchButton" });
726
+ var XFormCustomColumn = function (props) {
727
+ // nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
728
+ return (null);
729
+ };
730
+ exports.XFormCustomColumn = XFormCustomColumn;
731
+ exports.XFormCustomColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "custom" });
@@ -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
- // klonujeme len nase X* komponenty (napr. XInputText), child.type.name vracia nazov komponenty (napr. XInputText)
16
- // ak vyklonujeme cudziu komponentu, funguje, ale prida do nej property labelstyle=[object Object]
17
- if (child.type.name && child.type.name.startsWith("X")) {
18
- 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 });
19
- }
20
- else {
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));
@@ -69,8 +69,9 @@ var XInputDecimal = /** @class */ (function (_super) {
69
69
  var _b = XUtilsMetadata_1.XUtilsMetadata.getParamsForInputNumber(this.xField), useGrouping = _b.useGrouping, fractionDigits = _b.fractionDigits, min = _b.min, max = _b.max, size = _b.size;
70
70
  var sizeInput = (_a = this.props.size) !== null && _a !== void 0 ? _a : size;
71
71
  // note: style overrides size (width of the input according to character count)
72
+ var label = this.getLabel();
72
73
  return (react_1.default.createElement("div", { className: "field grid" },
73
- react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
74
+ label !== undefined ? react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, label) : null,
74
75
  react_1.default.createElement(inputnumber_1.InputNumber, __assign({ id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), mode: "decimal", locale: "de-DE", useGrouping: useGrouping, minFractionDigits: fractionDigits, maxFractionDigits: fractionDigits, min: min, max: max, size: sizeInput, style: this.props.inputStyle }, this.getClassNameTooltip(), { onBlur: this.onBlur }))));
75
76
  };
76
77
  return XInputDecimal;
@@ -9,4 +9,5 @@ export declare const XInputDecimalBase: (props: {
9
9
  min?: number | undefined;
10
10
  max?: number | undefined;
11
11
  size?: number | undefined;
12
+ className?: string | undefined;
12
13
  }) => JSX.Element;
@@ -13,6 +13,6 @@ var XInputDecimalBase = function (props) {
13
13
  props.onChange(e.value);
14
14
  };
15
15
  // null konvertujeme na undefined (zevraj InputNumber nechce null)
16
- return (react_1.default.createElement(inputnumber_1.InputNumber, { id: props.id, value: props.value !== null ? props.value : undefined, onChange: onChange, readOnly: props.readOnly, mode: "decimal", locale: "de-DE", useGrouping: props.useGrouping, minFractionDigits: props.fractionDigits, maxFractionDigits: props.fractionDigits, min: props.min, max: props.max, size: props.size }));
16
+ return (react_1.default.createElement(inputnumber_1.InputNumber, { id: props.id, value: props.value !== null ? props.value : undefined, onChange: onChange, readOnly: props.readOnly, mode: "decimal", locale: "de-DE", useGrouping: props.useGrouping, minFractionDigits: props.fractionDigits, maxFractionDigits: props.fractionDigits, min: props.min, max: props.max, size: props.size, className: props.className }));
17
17
  };
18
18
  exports.XInputDecimalBase = XInputDecimalBase;
@@ -60,8 +60,9 @@ var XInputText = /** @class */ (function (_super) {
60
60
  var _a;
61
61
  var size = (_a = this.props.size) !== null && _a !== void 0 ? _a : this.xField.length;
62
62
  // note: style overrides size (width of the input according to character count)
63
+ var label = this.getLabel();
63
64
  return (react_1.default.createElement("div", { className: "field grid" },
64
- react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
65
+ label !== undefined ? react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, label) : null,
65
66
  react_1.default.createElement(inputtext_1.InputText, __assign({ id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, size: size, style: this.props.inputStyle }, this.getClassNameTooltip(), { onBlur: this.onBlur }))));
66
67
  };
67
68
  return XInputText;
@@ -634,7 +634,7 @@ var XLazyDataTable = function (props) {
634
634
  if (props.scrollWidth !== "none") {
635
635
  scrollWidth = props.scrollWidth;
636
636
  if (scrollWidth === "viewport") {
637
- scrollWidth = 'calc(100vw - 1.4rem)'; // 20px okraje
637
+ scrollWidth = 'calc(100vw - 2.2rem)'; // povodne bolo 1.4rem (20px okraje) ale pri vela stlpcoch vznikal horizontalny scrollbar
638
638
  }
639
639
  }
640
640
  if (props.scrollHeight !== "none") {
@@ -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(10, 0.25 + 1.25 + 0.25); // napr. 31.12.2021, 1.25 rem date picker button
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
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",