@michalrakus/x-react-web-lib 1.17.0 → 1.18.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.
Files changed (30) hide show
  1. package/lib/components/XAutoCompleteBase.d.ts +1 -0
  2. package/lib/components/XAutoCompleteBase.js +35 -19
  3. package/lib/components/XCalendar.d.ts +1 -2
  4. package/lib/components/XCalendar.js +79 -10
  5. package/lib/components/XFormBase.js +5 -1
  6. package/lib/components/XFormComponent.js +9 -6
  7. package/lib/components/XFormDataTable2.d.ts +15 -1
  8. package/lib/components/XFormDataTable2.js +23 -3
  9. package/lib/components/XFormRowCol/XFormCol.d.ts +1 -0
  10. package/lib/components/XFormRowCol/XFormCol.js +1 -1
  11. package/lib/components/XFormRowCol/XFormInlineRow.d.ts +1 -0
  12. package/lib/components/XFormRowCol/XFormInlineRow.js +1 -1
  13. package/lib/components/XFormRowCol/XFormRow.d.ts +1 -0
  14. package/lib/components/XFormRowCol/XFormRow.js +1 -1
  15. package/lib/components/XFormRowCol/XFormRowCol.d.ts +1 -0
  16. package/lib/components/XFormRowCol/XFormRowCol.js +1 -1
  17. package/lib/components/XInputDate.d.ts +0 -1
  18. package/lib/components/XInputDate.js +4 -18
  19. package/lib/components/XInputDateDT.d.ts +9 -10
  20. package/lib/components/XInputDateDT.js +35 -39
  21. package/lib/components/XInputDecimal.js +1 -1
  22. package/lib/components/XInputTextarea.js +1 -1
  23. package/lib/components/XInputTextareaDT.d.ts +12 -0
  24. package/lib/components/XInputTextareaDT.js +44 -0
  25. package/lib/components/XUtilsMetadata.js +1 -1
  26. package/lib/serverApi/XUtilsCommon.d.ts +4 -0
  27. package/lib/serverApi/XUtilsCommon.js +32 -0
  28. package/lib/serverApi/XUtilsConversions.d.ts +1 -0
  29. package/lib/serverApi/XUtilsConversions.js +63 -5
  30. package/package.json +1 -1
@@ -54,6 +54,7 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
54
54
  createDropdownItem(splitButtonItems: MenuItem[]): void;
55
55
  onOpenDropdown(e: any): void;
56
56
  openDropdown(e: any): void;
57
+ onEditAssocValue(): void;
57
58
  computeInputValue(): any;
58
59
  createSearchBrowseParams(): XSearchBrowseParams;
59
60
  render(): JSX.Element;
@@ -287,13 +287,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
287
287
  alert('Please select some row.');
288
288
  }
289
289
  else {
290
- // otvorime dialog na update
291
- if (_this.props.idField === undefined) {
292
- throw "XAutoCompleteBase: property valueForm is defined but property idField is also needed for form editation.";
293
- }
294
- _this.formDialogObjectId = _this.props.value[_this.props.idField];
295
- _this.formDialogInitValuesForInsert = undefined;
296
- _this.setState({ formDialogOpened: true });
290
+ _this.onEditAssocValue();
297
291
  }
298
292
  }
299
293
  }
@@ -349,6 +343,15 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
349
343
  // otvori dropdown (search je metoda popisana v API, volanie sme skopcili zo zdrojakov primereact)
350
344
  this.autoCompleteRef.current.search(e, '', 'dropdown');
351
345
  };
346
+ XAutoCompleteBase.prototype.onEditAssocValue = function () {
347
+ // otvorime dialog na update
348
+ if (this.props.idField === undefined) {
349
+ throw "XAutoCompleteBase: property valueForm is defined but property idField is also needed for form editation.";
350
+ }
351
+ this.formDialogObjectId = this.props.value[this.props.idField];
352
+ this.formDialogInitValuesForInsert = undefined;
353
+ this.setState({ formDialogOpened: true });
354
+ };
352
355
  // vracia objekt (ak inputChanged === false) alebo string (ak inputChanged === true)
353
356
  XAutoCompleteBase.prototype.computeInputValue = function () {
354
357
  var inputValue;
@@ -375,21 +378,34 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
375
378
  var _a;
376
379
  var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
377
380
  var dropdownButton;
378
- if ((this.props.searchBrowse && !readOnly) || this.props.valueForm) {
379
- // mame searchBrowse alebo CRUD operacie, potrebujeme SplitButton
380
- var splitButtonItems = [];
381
- if (this.props.valueForm) {
382
- this.createInsertUpdateItems(splitButtonItems);
381
+ if (!readOnly) {
382
+ if (this.props.searchBrowse || this.props.valueForm) {
383
+ // mame searchBrowse alebo CRUD operacie, potrebujeme SplitButton
384
+ var splitButtonItems = [];
385
+ if (this.props.valueForm) {
386
+ this.createInsertUpdateItems(splitButtonItems);
387
+ }
388
+ if (this.props.searchBrowse && !readOnly) {
389
+ this.createSearchItem(splitButtonItems);
390
+ }
391
+ this.createDropdownItem(splitButtonItems);
392
+ dropdownButton = react_1.default.createElement(splitbutton_1.SplitButton, { model: splitButtonItems, className: 'x-splitbutton-only-dropdown' + XUtils_1.XUtils.mobileCssSuffix(), menuClassName: 'x-splitbutton-only-dropdown-menu' + XUtils_1.XUtils.mobileCssSuffix(), disabled: readOnly });
383
393
  }
384
- if (this.props.searchBrowse && !readOnly) {
385
- this.createSearchItem(splitButtonItems);
394
+ else {
395
+ // mame len 1 operaciu - dame jednoduchy button
396
+ dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.onOpenDropdown(e); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() });
386
397
  }
387
- this.createDropdownItem(splitButtonItems);
388
- dropdownButton = react_1.default.createElement(splitbutton_1.SplitButton, { model: splitButtonItems, className: 'x-splitbutton-only-dropdown' + XUtils_1.XUtils.mobileCssSuffix(), menuClassName: 'x-splitbutton-only-dropdown-menu' + XUtils_1.XUtils.mobileCssSuffix(), disabled: readOnly });
389
398
  }
390
399
  else {
391
- // mame len 1 operaciu - dame jednoduchy button
392
- dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.onOpenDropdown(e); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix(), disabled: readOnly });
400
+ // readOnly
401
+ // ak mame valueForm a mame asociovany objekt, umoznime editovat asociovany objekt
402
+ if (this.props.valueForm && this.props.value !== null) {
403
+ dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-pencil", onClick: function (e) { return _this.onEditAssocValue(); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() });
404
+ }
405
+ else {
406
+ // dame disablovany button (z estetickych dovodov, zachovame sirku)
407
+ dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix(), disabled: true });
408
+ }
393
409
  }
394
410
  // vypocitame inputValue
395
411
  var inputValue = this.computeInputValue();
@@ -407,7 +423,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
407
423
  return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width } },
408
424
  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
425
  dropdownButton,
410
- this.props.valueForm != undefined && !readOnly ?
426
+ this.props.valueForm != undefined ?
411
427
  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, {
412
428
  id: this.formDialogObjectId, initValues: this.formDialogInitValuesForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
413
429
  } /*, this.props.valueForm.children*/))
@@ -1,9 +1,8 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  export declare const XCalendar: (props: {
3
3
  id?: string | undefined;
4
4
  value: Date | null;
5
5
  onChange: (value: Date | null) => void;
6
- onBlur?: ((event: React.FocusEvent<HTMLInputElement, Element>) => void) | undefined;
7
6
  readOnly?: boolean | undefined;
8
7
  error?: string | undefined;
9
8
  datetime?: boolean | undefined;
@@ -10,30 +10,99 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
15
51
  };
16
52
  Object.defineProperty(exports, "__esModule", { value: true });
17
53
  exports.XCalendar = void 0;
18
- var react_1 = __importDefault(require("react"));
54
+ var react_1 = __importStar(require("react"));
19
55
  var calendar_1 = require("primereact/calendar");
20
56
  var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
21
57
  var XUtils_1 = require("./XUtils");
22
58
  // wrapper for Calendar component, maybe better name would be XInputDateBase
59
+ // TODO - nefunguje rezim datetime pre zapis - dorobit konverziu!
23
60
  var XCalendar = function (props) {
24
61
  var _a;
62
+ // true, ak uzivatel typuje hodnotu
63
+ // false, ak uz uzivatel dotypoval (zavolal sa onBlur) - hodnotu berieme "z hora" (z prop.value)
64
+ var _b = __read((0, react_1.useState)(false), 2), inputChanged = _b[0], setInputChanged = _b[1];
65
+ // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
66
+ var _c = __read((0, react_1.useState)(undefined), 2), inputValueState = _c[0], setInputValueState = _c[1];
25
67
  var onChange = function (e) {
26
- // z Calendar prichadza e.value - typ Date alebo null
68
+ // standardne prichadza z Calendar e.value - typ Date alebo null
27
69
  // typ Date prichadza ak uzivatel vyplnil validny datum, null (typeof e.value vracia "object") prichadza ak uzivatel vymazal datum
28
70
  // alebo je este datum nekompletny (uzivatel prave zadava datum)
29
- // ak nastavime keepInvalid={true}, tak bude chodit nevalidny string (typeof e.value vracia "string")
30
- //console.log(typeof e.value);
31
- //console.log(e.value instanceof Date);
32
- if (e.value instanceof Date || e.value === null) {
33
- props.onChange(e.value);
71
+ // nastavili sme keepInvalid={true} -> bude chodit nevalidny string (typeof e.value vracia "string")
72
+ // naviac sme vypli parsovanie na datum (metoda parseDateTime), takze vzdy chodi "string" a konverziu robime v onBlur
73
+ setInputChanged(true);
74
+ setInputValueState(e.value); // vzdycky string
75
+ };
76
+ var onSelect = function (e) {
77
+ // musime tu zavolat props.onChange lebo event select zavola aj onChange ale my umyselne v onChange nevolame props.onChange
78
+ // (cakame na event blur, ktory po selecte nepride)
79
+ props.onChange(e.value); // vzdycky Date
80
+ // pre poriadok resetneme stav
81
+ setInputChanged(false);
82
+ setInputValueState(undefined);
83
+ };
84
+ var onBlur = function (e) {
85
+ if (inputChanged) {
86
+ // poznamka: e.target.value aj inputValueState obsahuju tu istu string hodnotu
87
+ var value = (0, XUtilsConversions_1.dateFromUI)(e.target.value);
88
+ props.onChange(value !== null && value !== void 0 ? value : null); // nekorektnu hodnotu reprezentovanu cez undefined budeme riesit akokeby user zadal null (field sa vyprazdni)
89
+ setInputChanged(false);
90
+ setInputValueState(undefined); // pre poriadok
91
+ }
92
+ };
93
+ var getInputValue = function () {
94
+ var inputValue;
95
+ if (inputChanged) {
96
+ inputValue = inputValueState; // vzdycky string
97
+ }
98
+ else {
99
+ inputValue = (0, XUtilsConversions_1.dateFromModel)(props.value);
34
100
  }
101
+ return inputValue;
35
102
  };
36
103
  var datetime = (_a = props.datetime) !== null && _a !== void 0 ? _a : false;
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))));
104
+ // poznamka: parseDateTime nerobi ziadny parse, nechceme aby Calendar "rusil" uzivatela pri typovani datumu
105
+ // konverzia (a volanie props.onChange) sa robi az pri onBlur
106
+ return (react_1.default.createElement(calendar_1.Calendar, __assign({ id: props.id, value: getInputValue(), onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), keepInvalid: true, parseDateTime: function (text) { return text; }, showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date', onSelect: onSelect, onBlur: onBlur }, XUtils_1.XUtils.createErrorProps(props.error))));
38
107
  };
39
108
  exports.XCalendar = XCalendar;
@@ -92,6 +92,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
92
92
  exports.XFormBase = exports.Form = void 0;
93
93
  var react_1 = require("react");
94
94
  var XUtils_1 = require("./XUtils");
95
+ var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
95
96
  // class decorator ktory nastavuje property entity (dalo by sa to nastavovat v konstruktore ale decorator je menej ukecany)
96
97
  // ma sa pouzivat len na triedach odvodenych od XFormBase - obmedzenie som vsak nevedel nakodit
97
98
  // property sa nastavi az po zbehnuti konstruktora
@@ -217,8 +218,11 @@ var XFormBase = /** @class */ (function (_super) {
217
218
  return this.props.id === undefined;
218
219
  };
219
220
  XFormBase.prototype.onFieldChange = function (field, value, error, onChange, assocObjectChange) {
221
+ // field moze byt aj na asociovanom objekte (field length > 1, napr.: <assocX>.<fieldY>)
222
+ // v takom pripade sa do errorMap zapise ako key cely field <assocX>.<fieldY>
223
+ // (zlozitejsie riesenie by bolo zapisovat errors do specialneho technickeho atributu asociovaneho objektu ale zatial to nechame takto jednoducho)
220
224
  var object = this.getXObject();
221
- object[field] = value;
225
+ XUtilsCommon_1.XUtilsCommon.setValueByPath(object, field, value);
222
226
  var errorMap = this.state.errorMap;
223
227
  errorMap[field] = __assign(__assign({}, errorMap[field]), { onChange: error });
224
228
  // tu zavolame onChange komponentu - object uz ma zapisanu zmenenu hodnotu, onChange nasledne zmeni dalsie hodnoty a nasledne sa zavola setState
@@ -51,13 +51,9 @@ var XFormComponent = /** @class */ (function (_super) {
51
51
  };
52
52
  XFormComponent.prototype.isReadOnly = function () {
53
53
  var readOnly;
54
- if (!XUtilsCommon_1.XUtilsCommon.isSingleField(this.getField())) {
55
- // if the length of field is 2 or more, then readOnly
56
- readOnly = true;
57
- }
58
54
  // the purpose of formReadOnly is to put the whole form to read only mode,
59
55
  // that's why the formReadOnly has higher prio then property this.props.readOnly
60
- else if (this.props.form.formReadOnlyBase(this.getField())) {
56
+ if (this.props.form.formReadOnlyBase(this.getField())) {
61
57
  readOnly = true;
62
58
  }
63
59
  else if (typeof this.props.readOnly === 'boolean') {
@@ -75,7 +71,14 @@ var XFormComponent = /** @class */ (function (_super) {
75
71
  }
76
72
  else {
77
73
  // readOnly is undefined
78
- readOnly = false;
74
+ if (!XUtilsCommon_1.XUtilsCommon.isSingleField(this.getField())) {
75
+ // if the length of field is 2 or more, then readOnly
76
+ readOnly = true;
77
+ }
78
+ else {
79
+ // length of field is 1, default readOnly = false
80
+ readOnly = false;
81
+ }
79
82
  }
80
83
  return readOnly;
81
84
  };
@@ -92,7 +92,7 @@ export type XTableFieldOnChange = (e: XTableFieldChangeEvent<any, any>) => void;
92
92
  export type XTableFieldReadOnlyProp = boolean | ((object: any, tableRow: any) => boolean);
93
93
  export type XTableFieldFilterProp = XCustomFilter | ((object: any, rowData: any) => XCustomFilter | undefined);
94
94
  export interface XFormColumnBaseProps {
95
- type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton" | "custom";
95
+ type: "inputSimple" | "dropdown" | "autoComplete" | "searchButton" | "textarea" | "custom";
96
96
  header?: any;
97
97
  readOnly?: XTableFieldReadOnlyProp;
98
98
  dropdownInFilter?: boolean;
@@ -123,6 +123,11 @@ export interface XFormSearchButtonColumnProps extends XFormColumnBaseProps {
123
123
  displayField: string;
124
124
  searchBrowse: JSX.Element;
125
125
  }
126
+ export interface XFormTextareaColumnProps extends XFormColumnBaseProps {
127
+ field: string;
128
+ rows: number;
129
+ autoResize?: boolean;
130
+ }
126
131
  export interface XFormCustomColumnProps extends XFormColumnBaseProps {
127
132
  body: React.ReactNode | ((data: any, options: ColumnBodyOptions) => React.ReactNode);
128
133
  field?: string;
@@ -155,6 +160,15 @@ export declare const XFormSearchButtonColumn: {
155
160
  columnViewStatus: boolean;
156
161
  };
157
162
  };
163
+ export declare const XFormTextareaColumn: {
164
+ (props: XFormTextareaColumnProps): null;
165
+ defaultProps: {
166
+ type: string;
167
+ rows: number;
168
+ autoResize: boolean;
169
+ columnViewStatus: boolean;
170
+ };
171
+ };
158
172
  export declare const XFormCustomColumn: {
159
173
  (props: XFormCustomColumnProps): null;
160
174
  defaultProps: {
@@ -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.XFormCustomColumn = exports.XFormSearchButtonColumn = exports.XFormAutoCompleteColumn = exports.XFormDropdownColumn = exports.XFormColumn = exports.XFormDataTable2 = void 0;
63
+ exports.XFormCustomColumn = exports.XFormTextareaColumn = 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");
@@ -83,6 +83,7 @@ var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
83
83
  var XLocale_1 = require("./XLocale");
84
84
  var XInputIntervalDT_1 = require("./XInputIntervalDT");
85
85
  var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
86
+ var XInputTextareaDT_1 = require("./XInputTextareaDT");
86
87
  var XFormDataTable2 = /** @class */ (function (_super) {
87
88
  __extends(XFormDataTable2, _super);
88
89
  function XFormDataTable2(props) {
@@ -150,6 +151,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
150
151
  var columnPropsSearchButton = columnProps;
151
152
  return columnPropsSearchButton.assocField + '.' + columnPropsSearchButton.displayField;
152
153
  }
154
+ else if (columnProps.type === "textarea") {
155
+ var columnPropsTextarea = columnProps;
156
+ return columnPropsTextarea.field;
157
+ }
153
158
  else {
154
159
  throw "Unknown prop type = " + columnProps.type;
155
160
  }
@@ -183,6 +188,11 @@ var XFormDataTable2 = /** @class */ (function (_super) {
183
188
  isNullable = xAssoc.isNullable;
184
189
  readOnly = XFormDataTable2.isReadOnlyHeader(undefined, columnProps.readOnly);
185
190
  }
191
+ else if (columnProps.type === "textarea") {
192
+ var columnPropsTextarea = columnProps;
193
+ isNullable = xField.isNullable;
194
+ readOnly = XFormDataTable2.isReadOnlyHeader(columnPropsTextarea.field, columnProps.readOnly);
195
+ }
186
196
  else {
187
197
  throw "Unknown prop type = " + columnProps.type;
188
198
  }
@@ -375,10 +385,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
375
385
  body = react_1.default.createElement(XInputDecimalDT_1.XInputDecimalDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
376
386
  }
377
387
  else if (xField.type === "date" || xField.type === "datetime") {
378
- body = react_1.default.createElement(XInputDateDT_1.XInputDateDT, { form: this.props.form, xField: xField, field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly });
388
+ body = react_1.default.createElement(XInputDateDT_1.XInputDateDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
379
389
  }
380
390
  else if (xField.type === "interval") {
381
- body = react_1.default.createElement(XInputIntervalDT_1.XInputIntervalDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly });
391
+ body = react_1.default.createElement(XInputIntervalDT_1.XInputIntervalDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly, onChange: columnPropsInputSimple.onChange });
382
392
  }
383
393
  else if (xField.type === "boolean") {
384
394
  body = react_1.default.createElement(XCheckboxDT_1.XCheckboxDT, { form: this.props.form, xField: xField, field: columnPropsInputSimple.field, rowData: rowData, readOnly: readOnly });
@@ -400,6 +410,10 @@ var XFormDataTable2 = /** @class */ (function (_super) {
400
410
  var columnPropsSearchButton = columnProps;
401
411
  body = react_1.default.createElement(XSearchButtonDT_1.XSearchButtonDT, { form: this.props.form, entity: this.getEntity(), assocField: columnPropsSearchButton.assocField, displayField: columnPropsSearchButton.displayField, searchBrowse: columnPropsSearchButton.searchBrowse, rowData: rowData, readOnly: columnPropsSearchButton.readOnly });
402
412
  }
413
+ else if (columnProps.type === "textarea") {
414
+ var columnPropsTextarea = columnProps;
415
+ body = react_1.default.createElement(XInputTextareaDT_1.XInputTextareaDT, { form: this.props.form, entity: this.getEntity(), field: columnPropsTextarea.field, rows: columnPropsTextarea.rows, autoResize: columnPropsTextarea.autoResize, rowData: rowData, readOnly: columnPropsTextarea.readOnly });
416
+ }
403
417
  else {
404
418
  throw "Unknown prop type = " + columnProps.type;
405
419
  }
@@ -723,6 +737,12 @@ var XFormSearchButtonColumn = function (props) {
723
737
  };
724
738
  exports.XFormSearchButtonColumn = XFormSearchButtonColumn;
725
739
  exports.XFormSearchButtonColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "searchButton" });
740
+ var XFormTextareaColumn = function (props) {
741
+ // nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
742
+ return (null);
743
+ };
744
+ exports.XFormTextareaColumn = XFormTextareaColumn;
745
+ exports.XFormTextareaColumn.defaultProps = __assign(__assign({}, XFormColumnBase_defaultProps), { type: "textarea", rows: 1, autoResize: true });
726
746
  var XFormCustomColumn = function (props) {
727
747
  // nevadi ze tu nic nevraciame, field a header vieme precitat a zvysok by sme aj tak zahodili lebo vytvarame novy element
728
748
  return (null);
@@ -3,6 +3,7 @@ import { XFormBase } from "../XFormBase";
3
3
  export interface XFormColProps {
4
4
  form?: XFormBase;
5
5
  labelStyle?: React.CSSProperties;
6
+ style?: React.CSSProperties;
6
7
  children: JSX.Element | JSX.Element[];
7
8
  }
8
9
  export declare const XFormCol: (props: XFormColProps) => JSX.Element;
@@ -7,6 +7,6 @@ exports.XFormCol = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var XFormRowCol_1 = require("./XFormRowCol");
9
9
  var XFormCol = function (props) {
10
- return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-col", form: props.form, labelStyle: props.labelStyle, children: props.children });
10
+ return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-col", form: props.form, labelStyle: props.labelStyle, style: props.style, children: props.children });
11
11
  };
12
12
  exports.XFormCol = XFormCol;
@@ -3,6 +3,7 @@ import { XFormBase } from "../XFormBase";
3
3
  export interface XFormInlineRowProps {
4
4
  form?: XFormBase;
5
5
  labelStyle?: React.CSSProperties;
6
+ style?: React.CSSProperties;
6
7
  children: JSX.Element | JSX.Element[];
7
8
  }
8
9
  export declare const XFormInlineRow: (props: XFormInlineRowProps) => JSX.Element;
@@ -7,6 +7,6 @@ exports.XFormInlineRow = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var XFormRowCol_1 = require("./XFormRowCol");
9
9
  var XFormInlineRow = function (props) {
10
- return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-inline-row", form: props.form, labelStyle: props.labelStyle, children: props.children });
10
+ return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-inline-row", form: props.form, labelStyle: props.labelStyle, style: props.style, children: props.children });
11
11
  };
12
12
  exports.XFormInlineRow = XFormInlineRow;
@@ -3,6 +3,7 @@ import { XFormBase } from "../XFormBase";
3
3
  export interface XFormRowProps {
4
4
  form?: XFormBase;
5
5
  labelStyle?: React.CSSProperties;
6
+ style?: React.CSSProperties;
6
7
  children: JSX.Element | JSX.Element[];
7
8
  }
8
9
  export declare const XFormRow: (props: XFormRowProps) => JSX.Element;
@@ -7,6 +7,6 @@ exports.XFormRow = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var XFormRowCol_1 = require("./XFormRowCol");
9
9
  var XFormRow = function (props) {
10
- return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-row", form: props.form, labelStyle: props.labelStyle, children: props.children });
10
+ return react_1.default.createElement(XFormRowCol_1.XFormRowCol, { className: "x-form-row", form: props.form, labelStyle: props.labelStyle, style: props.style, children: props.children });
11
11
  };
12
12
  exports.XFormRow = XFormRow;
@@ -4,6 +4,7 @@ export interface XFormRowColProps {
4
4
  className: "x-form-row" | "x-form-inline-row" | "x-form-col";
5
5
  form?: XFormBase;
6
6
  labelStyle?: React.CSSProperties;
7
+ style?: React.CSSProperties;
7
8
  children: JSX.Element | JSX.Element[];
8
9
  }
9
10
  export declare const XFormRowCol: (props: XFormRowColProps) => JSX.Element;
@@ -27,6 +27,6 @@ var XFormRowCol = function (props) {
27
27
  else {
28
28
  childElemList = props.children; // netreba klonovat - viac menej koli performance
29
29
  }
30
- return react_1.default.createElement("div", { className: props.className }, childElemList);
30
+ return react_1.default.createElement("div", { className: props.className, style: props.style }, childElemList);
31
31
  };
32
32
  exports.XFormRowCol = XFormRowCol;
@@ -8,6 +8,5 @@ export declare class XInputDate extends XInput<Date, XInputDateProps> {
8
8
  constructor(props: XInputDateProps);
9
9
  getValue(): Date | null;
10
10
  onValueChange(value: Date | null): void;
11
- onBlur(e: any): void;
12
11
  render(): JSX.Element;
13
12
  }
@@ -22,41 +22,27 @@ exports.XInputDate = void 0;
22
22
  var react_1 = __importDefault(require("react"));
23
23
  var XCalendar_1 = require("./XCalendar");
24
24
  var XInput_1 = require("./XInput");
25
+ var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
25
26
  var XInputDate = /** @class */ (function (_super) {
26
27
  __extends(XInputDate, _super);
27
28
  function XInputDate(props) {
28
29
  var _this = _super.call(this, props) || this;
29
30
  _this.onValueChange = _this.onValueChange.bind(_this);
30
- _this.onBlur = _this.onBlur.bind(_this);
31
31
  return _this;
32
32
  }
33
33
  XInputDate.prototype.getValue = function () {
34
- var value = null;
35
- var objectValue = this.getValueFromObject();
36
- // tuto zatial hack, mal by prist Date
37
- if (typeof objectValue === 'string') {
38
- value = new Date(objectValue);
39
- }
40
- else if (typeof objectValue === 'object' && objectValue instanceof Date) {
41
- value = objectValue;
42
- }
43
- // value zostalo null ak nebol vykonany ziaden if
34
+ var value = (0, XUtilsConversions_1.dateFromModel)(this.getValueFromObject());
44
35
  return value;
45
36
  };
46
37
  XInputDate.prototype.onValueChange = function (value) {
47
38
  // z XCalendar prichadza value - typ Date alebo null
48
- this.onValueChangeBase(value);
49
- };
50
- // nedame do onChange inputu, lebo by sa nas onChange volal po kazdej zmene pismenka
51
- // ak bude treba, mozme este dorobit metodu "onChange2", ktora sa bude volat po kazdej zmene pismenka (asi iba do XInputText)
52
- XInputDate.prototype.onBlur = function (e) {
53
- this.callOnChangeFromOnBlur();
39
+ this.onValueChangeBase(value, this.props.onChange);
54
40
  };
55
41
  XInputDate.prototype.render = function () {
56
42
  // note: style overrides size (width of the input according to character count)
57
43
  return (react_1.default.createElement("div", { className: "field grid" },
58
44
  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(), error: this.getError(), datetime: this.xField.type === 'datetime', onBlur: this.onBlur })));
45
+ 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' })));
60
46
  };
61
47
  return XInputDate;
62
48
  }(XInput_1.XInput));
@@ -1,11 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { XFormBase } from "./XFormBase";
3
- import { XField } from "../serverApi/XEntityMetadata";
4
- import { XTableFieldReadOnlyProp } from "./XFormDataTable2";
5
- export declare const XInputDateDT: (props: {
6
- form: XFormBase;
7
- xField: XField;
8
- field: string;
9
- rowData: any;
10
- readOnly?: XTableFieldReadOnlyProp | undefined;
11
- }) => JSX.Element;
2
+ import { XInputDT, XInputDTProps } from "./XInputDT";
3
+ export interface XInputDateDTProps extends XInputDTProps {
4
+ }
5
+ export declare class XInputDateDT extends XInputDT<XInputDateDTProps> {
6
+ constructor(props: XInputDateDTProps);
7
+ getValue(): Date | null;
8
+ onValueChange(value: Date | null): void;
9
+ render(): JSX.Element;
10
+ }
@@ -1,48 +1,44 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
19
  };
5
20
  Object.defineProperty(exports, "__esModule", { value: true });
6
21
  exports.XInputDateDT = void 0;
7
- var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
8
- var calendar_1 = require("primereact/calendar");
9
22
  var react_1 = __importDefault(require("react"));
10
- var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
11
- var XUtils_1 = require("./XUtils");
12
- var XInputDateDT = function (props) {
13
- var showTime = (props.xField.type === 'datetime');
14
- var cssClassName = showTime ? 'x-input-datetime' : 'x-input-date';
15
- var onValueChange = function (field, rowData, newValue) {
16
- // z Calendar prichadza e.value - typ Date alebo null
17
- // zmenime hodnotu v modeli (odtial sa hodnota cita)
18
- rowData[field] = newValue;
19
- // kedze "rowData" je sucastou "props.form.state.object", tak nam staci zavolat setState({object: object}), aby sa zmena prejavila
20
- props.form.onObjectDataChange();
21
- };
22
- var fieldValue = undefined;
23
- // test na undefined je tu koli insertu noveho riadku
24
- if (props.rowData !== undefined && props.rowData !== null) {
25
- var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(props.rowData, props.field);
26
- // pre istotu dame na null, null je standard
27
- //if (rowDataValue === undefined) {
28
- // rowDataValue = null;
29
- //}
30
- // TODO - konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli
31
- // - otestovat ci zmena na null funguje dobre -
32
- //fieldValue = stringAsUI(rowDataValue);
33
- // tuto zatial hack, mal by prist Date
34
- if (typeof rowDataValue === 'string') {
35
- fieldValue = new Date(rowDataValue);
36
- }
37
- else if (typeof rowDataValue === 'object' && rowDataValue instanceof Date) {
38
- fieldValue = rowDataValue;
39
- }
40
- // fieldValue zostalo undefined (konvertujeme null -> undefined) - Calendar pozaduje undefined, nechce null
23
+ var XInputDT_1 = require("./XInputDT");
24
+ var XCalendar_1 = require("./XCalendar");
25
+ var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
26
+ var XInputDateDT = /** @class */ (function (_super) {
27
+ __extends(XInputDateDT, _super);
28
+ function XInputDateDT(props) {
29
+ var _this = _super.call(this, props) || this;
30
+ _this.onValueChange = _this.onValueChange.bind(_this);
31
+ return _this;
41
32
  }
42
- var readOnly = XUtils_1.XUtils.isReadOnlyTableField(props.field, props.readOnly, props.form.state.object, props.rowData);
43
- // TODO - nefunguje dobre pridavanie noveho riadku - su tam stare neupdatnute hodnoty - este to asi neopravili https://github.com/primefaces/primereact/issues/1277
44
- // test mame na TestovaciForm
45
- // appendTo={document.body} appenduje overlay panel na element body - eliminuje problem s overflow (pozri poznamku v XDropdownDTFilter)
46
- return (react_1.default.createElement(calendar_1.Calendar, { appendTo: document.body, id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.value); }, disabled: readOnly, showIcon: true, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: showTime, showSeconds: showTime, inputClassName: cssClassName, showOnFocus: false }));
47
- };
33
+ XInputDateDT.prototype.getValue = function () {
34
+ return (0, XUtilsConversions_1.dateFromModel)(this.getValueFromRowData());
35
+ };
36
+ XInputDateDT.prototype.onValueChange = function (value) {
37
+ this.onValueChangeBase(value, this.props.onChange);
38
+ };
39
+ XInputDateDT.prototype.render = function () {
40
+ return (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' }));
41
+ };
42
+ return XInputDateDT;
43
+ }(XInputDT_1.XInputDT));
48
44
  exports.XInputDateDT = XInputDateDT;
@@ -72,7 +72,7 @@ var XInputDecimal = /** @class */ (function (_super) {
72
72
  var label = this.getLabel();
73
73
  return (react_1.default.createElement("div", { className: "field grid" },
74
74
  label !== undefined ? react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, label) : null,
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
+ 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, inputStyle: this.props.inputStyle }, this.getClassNameTooltip(), { onBlur: this.onBlur }))));
76
76
  };
77
77
  return XInputDecimal;
78
78
  }(XInput_1.XInput));
@@ -34,7 +34,7 @@ var XInputTextarea = /** @class */ (function (_super) {
34
34
  return this.getValueFromObject();
35
35
  };
36
36
  XInputTextarea.prototype.onValueChange = function (value) {
37
- this.onValueChangeBase(value);
37
+ this.onValueChangeBase(value, this.props.onChange);
38
38
  };
39
39
  XInputTextarea.prototype.getLabelStyle = function () {
40
40
  var _a;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { XInputDT, XInputDTProps } from "./XInputDT";
3
+ export interface XInputTextareaDTProps extends XInputDTProps {
4
+ rows: number;
5
+ autoResize?: boolean;
6
+ }
7
+ export declare class XInputTextareaDT extends XInputDT<XInputTextareaDTProps> {
8
+ constructor(props: XInputTextareaDTProps);
9
+ getValue(): string | null;
10
+ onValueChange(value: string | null): void;
11
+ render(): JSX.Element;
12
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.XInputTextareaDT = void 0;
22
+ var react_1 = __importDefault(require("react"));
23
+ var XInputDT_1 = require("./XInputDT");
24
+ var XInputTextareaBase_1 = require("./XInputTextareaBase");
25
+ var XInputTextareaDT = /** @class */ (function (_super) {
26
+ __extends(XInputTextareaDT, _super);
27
+ function XInputTextareaDT(props) {
28
+ var _this = _super.call(this, props) || this;
29
+ _this.onValueChange = _this.onValueChange.bind(_this);
30
+ return _this;
31
+ }
32
+ XInputTextareaDT.prototype.getValue = function () {
33
+ return this.getValueFromRowData();
34
+ };
35
+ XInputTextareaDT.prototype.onValueChange = function (value) {
36
+ this.onValueChangeBase(value, this.props.onChange);
37
+ };
38
+ // pouzivame cols = undefined, sirka je urcena sirkou stlpca (width: 100%)
39
+ XInputTextareaDT.prototype.render = function () {
40
+ return (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: { width: '100%' }, rows: this.props.rows, cols: undefined, autoResize: this.props.autoResize, error: this.getError() }));
41
+ };
42
+ return XInputTextareaDT;
43
+ }(XInputDT_1.XInputDT));
44
+ exports.XInputTextareaDT = XInputTextareaDT;
@@ -143,7 +143,7 @@ var XUtilsMetadata = /** @class */ (function () {
143
143
  }
144
144
  else {
145
145
  // form datatable (formColumnType is defined)
146
- if (formColumnType === "inputSimple") {
146
+ if (formColumnType === "inputSimple" || formColumnType === "textarea") {
147
147
  var padding = 0.21 + 0.07 + 0.5; // padding is 2.94px + 1px border + 7px padding in input
148
148
  if (xField.type === "string") {
149
149
  width = XUtilsMetadata.computeColumnWidthBase(xField.length, padding + padding); // padding left + right
@@ -2,14 +2,18 @@ export declare class XUtilsCommon {
2
2
  static newLine: string;
3
3
  static getValueByPath(object: any, path: string): any;
4
4
  static getValueOrValueListByPath(object: any, path: string): any | any[];
5
+ static setValueByPath(object: any, path: string, value: any): void;
5
6
  static getFieldListForPath(path: string): string[];
6
7
  static getFieldAndRestPath(path: string): [string, string | null];
7
8
  static getPathToAssoc(path: string): string;
9
+ static getPathToAssocAndField(path: string): [string | null, string];
8
10
  static isSingleField(path: string): boolean;
9
11
  static objectAsJSON(value: any): string;
10
12
  static getDayName(date: Date | null | undefined): string | undefined;
11
13
  static dateAddDays(date: Date | null, days: number): Date | null;
12
14
  static findFirstMatch(pattern: RegExp, value: string): string | null;
13
15
  static sqlMaxDateIfNull(sqlExp: string): string;
16
+ static today(): Date;
17
+ static isInt(stringValue: string): boolean;
14
18
  }
15
19
  export declare const dateFormat: any;
@@ -108,6 +108,20 @@ var XUtilsCommon = /** @class */ (function () {
108
108
  }
109
109
  }
110
110
  };
111
+ XUtilsCommon.setValueByPath = function (object, path, value) {
112
+ var _a = __read(XUtilsCommon.getPathToAssocAndField(path), 2), pathToAssoc = _a[0], field = _a[1];
113
+ if (pathToAssoc !== null) {
114
+ var assocObject = XUtilsCommon.getValueByPath(object, pathToAssoc);
115
+ // if null or undefined or is not object, then error
116
+ if (assocObject === null || assocObject === undefined || typeof assocObject !== 'object') {
117
+ console.log("XUtilsCommon.setValueByPath: could not set value ".concat(value, " into object property ").concat(path, ". Assoc object not found (found value: ").concat(assocObject, "). Main object:"));
118
+ console.log(object);
119
+ throw "setValueByPath: could not set value ".concat(value, " into object property ").concat(path, ". Assoc object not found. The main object can be seen in log.");
120
+ }
121
+ object = assocObject;
122
+ }
123
+ object[field] = value;
124
+ };
111
125
  XUtilsCommon.getFieldListForPath = function (path) {
112
126
  return path.split('.');
113
127
  };
@@ -131,6 +145,15 @@ var XUtilsCommon = /** @class */ (function () {
131
145
  return path.substring(0, posDot);
132
146
  }
133
147
  };
148
+ XUtilsCommon.getPathToAssocAndField = function (path) {
149
+ var posDot = path.lastIndexOf(".");
150
+ if (posDot === -1) {
151
+ return [null, path];
152
+ }
153
+ else {
154
+ return [path.substring(0, posDot), path.substring(posDot + 1)];
155
+ }
156
+ };
134
157
  XUtilsCommon.isSingleField = function (path) {
135
158
  return path.indexOf(".") === -1;
136
159
  };
@@ -176,6 +199,15 @@ var XUtilsCommon = /** @class */ (function () {
176
199
  XUtilsCommon.sqlMaxDateIfNull = function (sqlExp) {
177
200
  return "coalesce(".concat(sqlExp, ", '9999-12-31'::DATE)");
178
201
  };
202
+ XUtilsCommon.today = function () {
203
+ var today = new Date();
204
+ today.setHours(0, 0, 0, 0);
205
+ return today;
206
+ };
207
+ // vrati true ak sa string sklada iba z cislic, moze mat + alebo - na zaciatku
208
+ XUtilsCommon.isInt = function (stringValue) {
209
+ return /^[-+]?\d+$/.test(stringValue);
210
+ };
179
211
  XUtilsCommon.newLine = '\n';
180
212
  return XUtilsCommon;
181
213
  }());
@@ -7,6 +7,7 @@ export declare function intFromUI(stringValue: string): number | null | undefine
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;
10
+ export declare function dateFromUI(valueString: string): Date | null | undefined;
10
11
  export declare function dateAsUI(value: Date | null): string;
11
12
  export declare function datetimeAsUI(value: Date | null): string;
12
13
  export declare function timeFromModel(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.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
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.dateFromUI = 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");
@@ -54,14 +54,17 @@ exports.stringAsDB = stringAsDB;
54
54
  function intFromUI(stringValue) {
55
55
  // convert stringValue (e.g. 1234) into integer number
56
56
  // if stringValue is invalid, returns undefined
57
- var value;
57
+ var value = undefined;
58
58
  if (stringValue === '') {
59
59
  value = null;
60
60
  }
61
61
  else {
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;
62
+ if (XUtilsCommon_1.XUtilsCommon.isInt(stringValue)) {
63
+ // 1234xxx vrati number 1234, preto sme spravili test isInt
64
+ value = parseInt(stringValue, 10);
65
+ if (isNaN(value)) {
66
+ value = undefined;
67
+ }
65
68
  }
66
69
  }
67
70
  return value;
@@ -105,6 +108,61 @@ function dateFromModel(value) {
105
108
  return dateValue;
106
109
  }
107
110
  exports.dateFromModel = dateFromModel;
111
+ function dateFromUI(valueString) {
112
+ // converts valueString (e.g. 21.2.2024) into Date
113
+ // if stringValue is invalid, returns undefined
114
+ var valueDate = undefined;
115
+ if (valueString === '') {
116
+ valueDate = null;
117
+ }
118
+ else {
119
+ // null znamena nezadane (doplni sa podla aktualneho datumu), undefined znamena zadana nekorektna hodnota
120
+ var day = void 0;
121
+ var month = null;
122
+ var year = null;
123
+ var posDot = valueString.indexOf('.');
124
+ if (posDot === -1) {
125
+ day = intFromUI(valueString);
126
+ }
127
+ else {
128
+ day = intFromUI(valueString.substring(0, posDot));
129
+ var rest = valueString.substring(posDot + 1);
130
+ var posDot2 = rest.indexOf('.');
131
+ if (posDot2 === -1) {
132
+ month = intFromUI(rest);
133
+ }
134
+ else {
135
+ month = intFromUI(rest.substring(0, posDot2));
136
+ year = intFromUI(rest.substring(posDot2 + 1));
137
+ }
138
+ }
139
+ // doplnime mesiac a rok ak uzivatel nezadal (ak mame undefined, tak umyselne nedoplname)
140
+ if (month === null) {
141
+ month = XUtilsCommon_1.XUtilsCommon.today().getMonth() + 1; // o 1 mesiac viac (januar je 0)
142
+ }
143
+ if (year === null) {
144
+ year = XUtilsCommon_1.XUtilsCommon.today().getFullYear();
145
+ }
146
+ // ak day alebo month alebo year zostal undefined, tak user zadal nekorektnu hodnotu - vratime undefined
147
+ if (day && month && year) {
148
+ var monthStr = month.toString();
149
+ if (monthStr.length < 2) {
150
+ monthStr = "0" + monthStr;
151
+ }
152
+ var dayStr = day.toString();
153
+ if (dayStr.length < 2) {
154
+ dayStr = "0" + dayStr;
155
+ }
156
+ valueDate = new Date("".concat(year, "-").concat(monthStr, "-").concat(dayStr));
157
+ if (isNaN(valueDate)) {
158
+ // ak je nekorektny datum (napr. 2024-13-01)
159
+ valueDate = undefined;
160
+ }
161
+ }
162
+ }
163
+ return valueDate;
164
+ }
165
+ exports.dateFromUI = dateFromUI;
108
166
  function dateAsUI(value) {
109
167
  if (value !== null) {
110
168
  return (0, XUtilsCommon_1.dateFormat)(value, dateFormatUI());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michalrakus/x-react-web-lib",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "clean": "rimraf lib",