@michalrakus/x-react-web-lib 1.0.0 → 1.2.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 (98) hide show
  1. package/FindParam.d.ts +3 -0
  2. package/FindParam.js +5 -0
  3. package/LICENSE.md +21 -0
  4. package/XButtonIconNarrow.d.ts +3 -0
  5. package/XButtonIconNarrow.js +5 -0
  6. package/XButtonIconSmall.d.ts +3 -0
  7. package/XButtonIconSmall.js +5 -0
  8. package/XFieldChangeEvent.d.ts +3 -0
  9. package/XFieldChangeEvent.js +5 -0
  10. package/XInputTextarea.d.ts +3 -0
  11. package/XInputTextarea.js +5 -0
  12. package/gulpfile.js +5 -0
  13. package/lib/administration/XBrowseMetaBrowse.js +2 -1
  14. package/lib/administration/XBrowseMetaForm.js +4 -2
  15. package/lib/administration/XUserBrowse.js +3 -2
  16. package/lib/administration/XUserForm.js +5 -3
  17. package/lib/components/SearchTableParams.d.ts +8 -2
  18. package/lib/components/SourceCodeLinkEntity.js +3 -2
  19. package/lib/components/XAutoComplete.d.ts +10 -7
  20. package/lib/components/XAutoComplete.js +37 -41
  21. package/lib/components/XAutoCompleteBase.d.ts +8 -5
  22. package/lib/components/XAutoCompleteBase.js +86 -43
  23. package/lib/components/XAutoCompleteDT.d.ts +33 -0
  24. package/lib/components/XAutoCompleteDT.js +141 -0
  25. package/lib/components/XBrowse.js +11 -5
  26. package/lib/components/XButton.d.ts +3 -1
  27. package/lib/components/XButton.js +3 -2
  28. package/lib/components/XButtonIconNarrow.d.ts +10 -0
  29. package/lib/components/XButtonIconNarrow.js +25 -0
  30. package/lib/components/XButtonIconSmall.d.ts +3 -1
  31. package/lib/components/XButtonIconSmall.js +2 -1
  32. package/lib/components/XChangePasswordForm.js +12 -7
  33. package/lib/components/XCheckbox.d.ts +8 -10
  34. package/lib/components/XCheckbox.js +39 -31
  35. package/lib/components/XCheckboxDT.js +2 -1
  36. package/lib/components/XDataTable.js +16 -10
  37. package/lib/components/XDropdown.d.ts +7 -5
  38. package/lib/components/XDropdown.js +24 -45
  39. package/lib/components/XDropdownDT.js +10 -5
  40. package/lib/components/XDropdownDTFilter.js +12 -7
  41. package/lib/components/XDropdownFormDTFilter.js +12 -7
  42. package/lib/components/XEditColumnDialog.js +12 -7
  43. package/lib/components/XErrors.d.ts +1 -0
  44. package/lib/components/XExportRowsDialog.js +13 -8
  45. package/lib/components/XFieldChangeEvent.d.ts +11 -0
  46. package/lib/components/XFieldChangeEvent.js +2 -0
  47. package/lib/components/XFieldSelector.js +11 -6
  48. package/lib/components/XFormBase.d.ts +17 -8
  49. package/lib/components/XFormBase.js +127 -48
  50. package/lib/components/XFormBaseT.js +3 -1
  51. package/lib/components/XFormComponent.d.ts +19 -7
  52. package/lib/components/XFormComponent.js +89 -49
  53. package/lib/components/XFormComponentDT.d.ts +30 -0
  54. package/lib/components/XFormComponentDT.js +119 -0
  55. package/lib/components/XFormDataTable2.d.ts +53 -8
  56. package/lib/components/XFormDataTable2.js +270 -57
  57. package/lib/components/XFormFooter.js +2 -1
  58. package/lib/components/XFormNavigator3.js +18 -7
  59. package/lib/components/XHolders.js +4 -2
  60. package/lib/components/XInput.d.ts +13 -0
  61. package/lib/components/XInput.js +38 -0
  62. package/lib/components/XInputDT.d.ts +11 -0
  63. package/lib/components/XInputDT.js +37 -0
  64. package/lib/components/XInputDate.d.ts +2 -1
  65. package/lib/components/XInputDate.js +7 -4
  66. package/lib/components/XInputDateDT.js +3 -2
  67. package/lib/components/XInputDecimal.d.ts +9 -2
  68. package/lib/components/XInputDecimal.js +63 -45
  69. package/lib/components/XInputDecimalDT.d.ts +10 -8
  70. package/lib/components/XInputDecimalDT.js +59 -36
  71. package/lib/components/XInputText.d.ts +7 -11
  72. package/lib/components/XInputText.js +22 -49
  73. package/lib/components/XInputTextDT.js +4 -4
  74. package/lib/components/XInputTextarea.d.ts +18 -0
  75. package/lib/components/XInputTextarea.js +85 -0
  76. package/lib/components/XLazyDataTable.d.ts +8 -0
  77. package/lib/components/XLazyDataTable.js +187 -85
  78. package/lib/components/XLoginDialog.js +2 -1
  79. package/lib/components/XLoginForm.js +11 -6
  80. package/lib/components/XResponseError.js +4 -2
  81. package/lib/components/XSearchButton.d.ts +8 -7
  82. package/lib/components/XSearchButton.js +32 -51
  83. package/lib/components/XSearchButtonDT.js +15 -10
  84. package/lib/components/XSearchButtonOld.js +13 -8
  85. package/lib/components/XToOneAssocButton.js +2 -1
  86. package/lib/components/XUtils.d.ts +13 -1
  87. package/lib/components/XUtils.js +125 -5
  88. package/lib/components/XUtilsConversions.d.ts +1 -0
  89. package/lib/components/XUtilsConversions.js +24 -3
  90. package/lib/components/XUtilsMetadata.d.ts +4 -1
  91. package/lib/components/XUtilsMetadata.js +62 -14
  92. package/lib/components/useXToken.js +1 -1
  93. package/lib/serverApi/ExportImportParam.d.ts +3 -3
  94. package/lib/serverApi/FindParam.d.ts +12 -14
  95. package/lib/serverApi/FindParam.js +14 -0
  96. package/lib/serverApi/XUtilsCommon.d.ts +1 -0
  97. package/lib/serverApi/XUtilsCommon.js +6 -2
  98. package/package.json +24 -25
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -25,7 +27,11 @@ var __assign = (this && this.__assign) || function () {
25
27
  };
26
28
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
29
  if (k2 === undefined) k2 = k;
28
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
29
35
  }) : (function(o, m, k, k2) {
30
36
  if (k2 === undefined) k2 = k;
31
37
  o[k2] = m[k];
@@ -38,7 +44,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
38
44
  var __importStar = (this && this.__importStar) || function (mod) {
39
45
  if (mod && mod.__esModule) return mod;
40
46
  var result = {};
41
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
48
  __setModuleDefault(result, mod);
43
49
  return result;
44
50
  };
@@ -58,9 +64,14 @@ var __read = (this && this.__read) || function (o, n) {
58
64
  }
59
65
  return ar;
60
66
  };
61
- var __spread = (this && this.__spread) || function () {
62
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
63
- return ar;
67
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
68
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
69
+ if (ar || !(i in from)) {
70
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
71
+ ar[i] = from[i];
72
+ }
73
+ }
74
+ return to.concat(ar || Array.prototype.slice.call(from));
64
75
  };
65
76
  Object.defineProperty(exports, "__esModule", { value: true });
66
77
  exports.XAutoCompleteBase = void 0;
@@ -69,6 +80,7 @@ var autocomplete_1 = require("primereact/autocomplete");
69
80
  var splitbutton_1 = require("primereact/splitbutton");
70
81
  var dialog_1 = require("primereact/dialog");
71
82
  var XUtils_1 = require("./XUtils");
83
+ var button_1 = require("primereact/button");
72
84
  var XAutoCompleteBase = /** @class */ (function (_super) {
73
85
  __extends(XAutoCompleteBase, _super);
74
86
  function XAutoCompleteBase(props) {
@@ -87,6 +99,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
87
99
  _this.onBlur = _this.onBlur.bind(_this);
88
100
  _this.formDialogOnSaveOrCancel = _this.formDialogOnSaveOrCancel.bind(_this);
89
101
  _this.formDialogOnHide = _this.formDialogOnHide.bind(_this);
102
+ _this.itemTemplate = _this.itemTemplate.bind(_this);
90
103
  return _this;
91
104
  }
92
105
  XAutoCompleteBase.prototype.componentDidMount = function () {
@@ -94,16 +107,27 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
94
107
  this.setFocusToInput();
95
108
  }
96
109
  };
110
+ XAutoCompleteBase.prototype.getDisplayValue = function (suggestion) {
111
+ var displayValue;
112
+ if (typeof this.props.field === 'string') {
113
+ displayValue = suggestion[this.props.field];
114
+ }
115
+ else {
116
+ // this.props.field is function returning string
117
+ displayValue = this.props.field(suggestion);
118
+ }
119
+ return displayValue;
120
+ };
97
121
  XAutoCompleteBase.prototype.completeMethod = function (event) {
98
122
  var _this = this;
99
123
  var filteredSuggestions;
100
124
  if (!event.query.trim().length) {
101
- filteredSuggestions = __spread(this.props.suggestions);
125
+ filteredSuggestions = __spreadArray([], __read(this.props.suggestions), false);
102
126
  }
103
127
  else {
104
128
  var queryNormalized_1 = XUtils_1.XUtils.normalizeString(event.query);
105
129
  filteredSuggestions = this.props.suggestions.filter(function (suggestion) {
106
- var fieldValue = suggestion[_this.props.field];
130
+ var fieldValue = _this.getDisplayValue(suggestion);
107
131
  // bolo:
108
132
  //return XUtils.normalizeString(fieldValue).startsWith(queryNormalized);
109
133
  return XUtils_1.XUtils.normalizeString(fieldValue).indexOf(queryNormalized_1) !== -1;
@@ -153,6 +177,9 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
153
177
  //console.log('onBlur - setujem timeout');
154
178
  //setTimeout(() => {this.onBlurInvalidInput();}, 100);
155
179
  // najnovsi sposob
180
+ // TODO - problem - ak zapisem nejake znaky a vyselektujem nejaky zaznam tak vznikne cerveny preblik (az nasledny onSelect zrusi state.notValid = true)
181
+ // zial neviem odlisit event sposobeny selektnutim zaznamu a event sposobeny kliknutim niekam vedla
182
+ //console.log(e);
156
183
  this.setState({ notValid: true }); // ocervenime input
157
184
  this.props.onErrorChange(this.createErrorMessage()); // ohlasime nevalidnost parentovi
158
185
  }
@@ -160,7 +187,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
160
187
  }
161
188
  };
162
189
  XAutoCompleteBase.prototype.createErrorMessage = function () {
163
- return "Value \"" + this.state.inputValueState + "\" was not found among valid values.";
190
+ return "Value \"".concat(this.state.inputValueState, "\" was not found among valid values.");
164
191
  };
165
192
  /*
166
193
  onBlurInvalidInput() {
@@ -186,18 +213,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
186
213
  }
187
214
  */
188
215
  XAutoCompleteBase.prototype.setFocusToInput = function () {
189
- if (this.autoCompleteRef.current.inputRef !== undefined) {
190
- // funguje ak je XAutoCompleteBase priamo v projekte, tiez funguje ak sa pouziva lib-ka z npmjs.com
191
- // nefunguje ak mame lib-ku priamo nalinkovanu na projekt (zmeny lib-ky pocas vyvoja)(minimalne next projekt kvm-next-web-app nefungoval)
192
- this.autoCompleteRef.current.inputRef.current.focus();
193
- }
194
- else {
195
- // pozor! nefunguje ak sa lib-ka pouziva z npmjs.com,
196
- // je tu koli tomu ked je lib-ka priamo nalinkovana na projekt
197
- // je to hack ale neviem to lepsie vyriesit
198
- console.log('Warning! this.autoCompleteRef.current.inputRef is undefined - we try to use this.autoCompleteRef.current.inputEl instead');
199
- this.autoCompleteRef.current.inputEl.focus();
200
- }
216
+ this.autoCompleteRef.current.focus();
201
217
  };
202
218
  XAutoCompleteBase.prototype.setObjectValue = function (object, objectChange) {
203
219
  this.setState({ inputChanged: false, notValid: false });
@@ -231,18 +247,28 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
231
247
  if (!this.state.inputChanged) {
232
248
  // poznamka: ak object === null tak treba do inputu zapisovat prazdny retazec, ak by sme pouzili null, neprejavila by sa zmena v modeli na null
233
249
  var object = this.props.value;
234
- inputValue = (object !== null) ? object : ""; // TODO - je "" ok?
250
+ if (typeof this.props.field === 'string') {
251
+ inputValue = (object !== null) ? object : ""; // TODO - je "" ok?
252
+ }
253
+ else {
254
+ inputValue = (object !== null) ? this.props.field(object) : "";
255
+ }
235
256
  }
236
257
  else {
237
258
  inputValue = this.state.inputValueState;
238
259
  }
239
260
  return inputValue;
240
261
  };
262
+ XAutoCompleteBase.prototype.itemTemplate = function (suggestion, index) {
263
+ // @ts-ignore
264
+ return this.props.field(suggestion);
265
+ };
241
266
  XAutoCompleteBase.prototype.render = function () {
242
267
  var _this = this;
243
- // menu na pripadne CRUD operacie
244
- var splitButtonItems = [];
268
+ var dropdownButton;
245
269
  if (this.props.valueForm) {
270
+ // mame CRUD operacie, potrebujeme SplitButton
271
+ var splitButtonItems = [];
246
272
  splitButtonItems.push({
247
273
  icon: 'pi pi-plus',
248
274
  command: function (e) {
@@ -250,7 +276,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
250
276
  _this.formDialogObjectId = undefined;
251
277
  _this.formDialogInitObjectForInsert = {};
252
278
  // ak mame nevalidnu hodnotu, tak ju predplnime (snaha o user friendly)
253
- if (_this.state.inputChanged) {
279
+ if (_this.state.inputChanged && typeof _this.props.field === 'string') {
254
280
  _this.formDialogInitObjectForInsert[_this.props.field] = _this.state.inputValueState;
255
281
  }
256
282
  _this.setState({ formDialogOpened: true });
@@ -260,7 +286,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
260
286
  icon: 'pi pi-pencil',
261
287
  command: function (e) {
262
288
  if (_this.state.inputChanged) {
263
- alert("Value \"" + _this.state.inputValueState + "\" was not found among valid values, please enter some valid value.");
289
+ alert("Value \"".concat(_this.state.inputValueState, "\" was not found among valid values, please enter some valid value."));
264
290
  _this.setFocusToInput();
265
291
  }
266
292
  else {
@@ -279,24 +305,41 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
279
305
  }
280
306
  }
281
307
  });
308
+ // remove nebudeme podporovat, je technicky problematicky - nemozme vymazat zaznam z DB koli FK constraintu
309
+ // {
310
+ // icon: 'pi pi-times',
311
+ // command: (e: any) => {
312
+ // console.log('remove');
313
+ // }
314
+ // },
315
+ splitButtonItems.push({
316
+ icon: 'pi pi-chevron-down',
317
+ command: function (e) {
318
+ // zobrazi cely suggestions list, zide sa ak chceme vidiet vsetky moznosti
319
+ // neprakticke ak mame vela poloziek v suggestions list
320
+ // krasne zobrazi cely objekt!
321
+ // this.autoCompleteRef.current je element <AutoComplete .../>, ktory vytvarame v render metode
322
+ //console.log(this.autoCompleteRef.current);
323
+ // otvori dropdown (search je metoda popisana v API, volanie sme skopcili zo zdrojakov primereact)
324
+ _this.autoCompleteRef.current.search(e, '', 'dropdown');
325
+ }
326
+ });
327
+ 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() });
328
+ }
329
+ else {
330
+ // mame len 1 operaciu - dame jednoduchy button
331
+ dropdownButton = react_1.default.createElement(button_1.Button, { icon: "pi pi-chevron-down", onClick: function (e) { return _this.autoCompleteRef.current.search(e, '', 'dropdown'); }, className: 'x-dropdownbutton' + XUtils_1.XUtils.mobileCssSuffix() });
282
332
  }
283
- // remove nebudeme podporovat, je technicky problematicky - nemozme vymazat zaznam z DB koli FK constraintu
284
- // {
285
- // icon: 'pi pi-times',
286
- // command: (e: any) => {
287
- // console.log('remove');
288
- // }
289
- // },
290
- splitButtonItems.push({
291
- icon: 'pi pi-chevron-down',
292
- command: function (e) {
293
- // zobrazi cely suggestions list, zide sa ak chceme vidiet vsetky moznosti
294
- // neprakticke ak mame vela poloziek v suggestions list
295
- _this.autoCompleteRef.current.onDropdownClick();
296
- }
297
- });
298
333
  // vypocitame inputValue
299
334
  var inputValue = this.computeInputValue();
335
+ // poznamka: asi by sa dalo pouzivat vzdy len itemTemplate (nepouzivat field)
336
+ var fieldOrItemTemplate;
337
+ if (typeof this.props.field === 'string') {
338
+ fieldOrItemTemplate = { field: this.props.field };
339
+ }
340
+ else {
341
+ fieldOrItemTemplate = { itemTemplate: this.itemTemplate };
342
+ }
300
343
  var error;
301
344
  if (this.state.notValid) {
302
345
  // ak je v nevalidnom stave, tak ma tato chybova hlaska prednost pred ostatnymi (ak nahodou su)
@@ -309,8 +352,8 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
309
352
  // <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitObjectForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
310
353
  // formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
311
354
  return (react_1.default.createElement("div", { className: "x-auto-complete-base" },
312
- 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 }, XUtils_1.XUtils.createErrorProps(error))),
313
- 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() }),
355
+ react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod }, fieldOrItemTemplate, { onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, maxLength: this.props.maxLength, ref: this.autoCompleteRef }, XUtils_1.XUtils.createErrorProps(error))),
356
+ dropdownButton,
314
357
  this.props.valueForm != undefined ?
315
358
  react_1.default.createElement(dialog_1.Dialog, { visible: this.state.formDialogOpened, onHide: this.formDialogOnHide, header: this.formDialogObjectId ? 'Modification' : 'New record' }, react_1.default.cloneElement(this.props.valueForm, {
316
359
  id: this.formDialogObjectId, object: this.formDialogInitObjectForInsert, onSaveOrCancel: this.formDialogOnSaveOrCancel
@@ -0,0 +1,33 @@
1
+ /// <reference types="react" />
2
+ import { XFormComponentDT, XFormComponentDTProps } from "./XFormComponentDT";
3
+ import { XAssoc } from "../serverApi/XEntityMetadata";
4
+ import { OperationType } from "./XUtils";
5
+ import { XError } from "./XErrors";
6
+ import { XTableFieldFilterProp } from "./XFormDataTable2";
7
+ export interface XAutoCompleteDTProps extends XFormComponentDTProps {
8
+ assocField: string;
9
+ displayField: string | ((suggestion: any) => string);
10
+ searchTable?: any;
11
+ assocForm?: any;
12
+ filter?: XTableFieldFilterProp;
13
+ }
14
+ export declare class XAutoCompleteDT extends XFormComponentDT<XAutoCompleteDTProps> {
15
+ protected xAssoc: XAssoc;
16
+ protected errorInBase: string | undefined;
17
+ state: {
18
+ suggestions: any[];
19
+ };
20
+ constructor(props: XAutoCompleteDTProps);
21
+ componentDidMount(): void;
22
+ readAndSetSuggestions(): Promise<void>;
23
+ getField(): string;
24
+ isNotNull(): boolean;
25
+ getValue(): any | null;
26
+ onChangeAutoCompleteBase(object: any, objectChange: OperationType): void;
27
+ onErrorChangeAutoCompleteBase(error: string | undefined): void;
28
+ validate(): {
29
+ field: string;
30
+ xError: XError;
31
+ } | undefined;
32
+ render(): JSX.Element;
33
+ }
@@ -0,0 +1,141 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.XAutoCompleteDT = void 0;
58
+ var XUtilsMetadata_1 = require("./XUtilsMetadata");
59
+ var react_1 = __importDefault(require("react"));
60
+ var XFormComponentDT_1 = require("./XFormComponentDT");
61
+ var XUtils_1 = require("./XUtils");
62
+ var XAutoCompleteBase_1 = require("./XAutoCompleteBase");
63
+ var XAutoCompleteDT = /** @class */ (function (_super) {
64
+ __extends(XAutoCompleteDT, _super);
65
+ function XAutoCompleteDT(props) {
66
+ var _this = _super.call(this, props) || this;
67
+ _this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.entity), props.assocField);
68
+ _this.errorInBase = undefined;
69
+ _this.state = {
70
+ suggestions: []
71
+ };
72
+ _this.onChangeAutoCompleteBase = _this.onChangeAutoCompleteBase.bind(_this);
73
+ _this.onErrorChangeAutoCompleteBase = _this.onErrorChangeAutoCompleteBase.bind(_this);
74
+ return _this;
75
+ }
76
+ XAutoCompleteDT.prototype.componentDidMount = function () {
77
+ this.readAndSetSuggestions();
78
+ };
79
+ XAutoCompleteDT.prototype.readAndSetSuggestions = function () {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ var suggestions;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, this.getFilterBase(this.props.filter), typeof this.props.displayField === 'string' ? this.props.displayField : undefined)];
85
+ case 1:
86
+ suggestions = _a.sent();
87
+ // ak mame funkciu, zosortujeme tu
88
+ if (typeof this.props.displayField === 'function') {
89
+ suggestions = XUtils_1.XUtils.arraySort(suggestions, this.props.displayField);
90
+ }
91
+ this.setState({ suggestions: suggestions });
92
+ return [2 /*return*/];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ XAutoCompleteDT.prototype.getField = function () {
98
+ return this.props.assocField;
99
+ };
100
+ XAutoCompleteDT.prototype.isNotNull = function () {
101
+ return !this.xAssoc.isNullable;
102
+ };
103
+ XAutoCompleteDT.prototype.getValue = function () {
104
+ var assocObject = this.getValueFromRowData();
105
+ return assocObject;
106
+ };
107
+ XAutoCompleteDT.prototype.onChangeAutoCompleteBase = function (object, objectChange) {
108
+ this.onValueChangeBase(object, this.props.onChange, objectChange);
109
+ if (objectChange !== XUtils_1.OperationType.None) {
110
+ // zmenil sa zaznam dobrovolnika v DB
111
+ // zatial len refreshneme z DB
112
+ // ak by bol reqest pomaly, mozme pri inserte (nove id) / update (existujuce id) upravit zoznam a usetrime tym request do DB
113
+ // ak bol delete (dobrovolnik === null), treba urobit refresh do DB (alebo si poslat id-cko zmazaneho zaznamu)
114
+ this.readAndSetSuggestions();
115
+ }
116
+ };
117
+ XAutoCompleteDT.prototype.onErrorChangeAutoCompleteBase = function (error) {
118
+ this.errorInBase = error; // odlozime si error
119
+ };
120
+ // overrides method in XFormComponent
121
+ XAutoCompleteDT.prototype.validate = function () {
122
+ if (this.errorInBase) {
123
+ // error message dame na onChange, mohli by sme aj na onSet (predtym onBlur), je to jedno viac-menej
124
+ // TODO - fieldLabel
125
+ return { field: this.getField(), xError: { onChange: this.errorInBase, fieldLabel: undefined } };
126
+ }
127
+ // zavolame povodnu metodu
128
+ return _super.prototype.validate.call(this);
129
+ };
130
+ XAutoCompleteDT.prototype.render = function () {
131
+ var xEntityAssoc = XUtilsMetadata_1.XUtilsMetadata.getXEntity(this.xAssoc.entityName);
132
+ //const xDisplayField = XUtilsMetadata.getXFieldByPath(xEntityAssoc, this.props.displayField);
133
+ // TODO - readOnly
134
+ // TODO - size
135
+ //const size = this.props.size ?? xDisplayField.length;
136
+ // div className="col" nam zabezpeci aby XAutoCompleteBase nezaberal celu dlzku grid-u (ma nastaveny width=100% vdaka "formgroup-inline")
137
+ return (react_1.default.createElement(XAutoCompleteBase_1.XAutoCompleteBase, { value: this.getValue(), suggestions: this.state.suggestions, onChange: this.onChangeAutoCompleteBase, field: this.props.displayField, valueForm: this.props.assocForm, idField: xEntityAssoc.idField, error: this.getError(), onErrorChange: this.onErrorChangeAutoCompleteBase }));
138
+ };
139
+ return XAutoCompleteDT;
140
+ }(XFormComponentDT_1.XFormComponentDT));
141
+ exports.XAutoCompleteDT = XAutoCompleteDT;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -14,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
14
16
  })();
15
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
18
  if (k2 === undefined) k2 = k;
17
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
18
24
  }) : (function(o, m, k, k2) {
19
25
  if (k2 === undefined) k2 = k;
20
26
  o[k2] = m[k];
@@ -27,7 +33,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
27
33
  var __importStar = (this && this.__importStar) || function (mod) {
28
34
  if (mod && mod.__esModule) return mod;
29
35
  var result = {};
30
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
37
  __setModuleDefault(result, mod);
32
38
  return result;
33
39
  };
@@ -46,7 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
52
  function verb(n) { return function (v) { return step([n, v]); }; }
47
53
  function step(op) {
48
54
  if (f) throw new TypeError("Generator is already executing.");
49
- while (_) try {
55
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
50
56
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
51
57
  if (y = 0, t) op = [op[0] & 2, t.value];
52
58
  switch (op[0]) {
@@ -312,7 +318,7 @@ var XBrowse = /** @class */ (function (_super) {
312
318
  this.props.openForm(formElementCloned);
313
319
  }
314
320
  else {
315
- console.log("XBrowse entity = " + this.props.entity + ": form not found/registered.");
321
+ console.log("XBrowse entity = ".concat(this.props.entity, ": form not found/registered."));
316
322
  }
317
323
  };
318
324
  XBrowse.prototype.render = function () {
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
+ import { ButtonProps } from "primereact/button";
3
+ import { IconType } from "primereact/utils";
2
4
  export declare const XButton: (props: {
3
5
  label?: string | undefined;
4
- icon?: string | undefined;
6
+ icon?: IconType<ButtonProps>;
5
7
  onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
6
8
  disabled?: boolean | undefined;
7
9
  }) => JSX.Element;
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.XButton = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var button_1 = require("primereact/button");
9
- exports.XButton = function (props) {
10
- // zatial iba pridany class x-button, aby sme vedeli nastavit margin "m-1" (1rem)
9
+ var XButton = function (props) {
10
+ // zatial iba pridany class x-button, aby sme vedeli nastavit margin "m-1" (0.25rem)
11
11
  return (react_1.default.createElement(button_1.Button, { label: props.label, icon: props.icon, onClick: props.onClick, disabled: props.disabled, className: "m-1" }));
12
12
  };
13
+ exports.XButton = XButton;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { ButtonProps } from "primereact/button";
3
+ import { IconType } from "primereact/utils";
4
+ export declare const XButtonIconNarrow: (props: {
5
+ icon: IconType<ButtonProps>;
6
+ onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
7
+ disabled?: boolean | undefined;
8
+ tooltip?: any;
9
+ addMargin?: boolean | undefined;
10
+ }) => JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.XButtonIconNarrow = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var button_1 = require("primereact/button");
9
+ var XUtils_1 = require("./XUtils");
10
+ // button s ikonkou, zuzeny na 1.5rem (21px), na mobile nezuzeny, defaultne s marginom "m-1" (0.25rem) (ako XButton), margin sa da vypnut (pouzivane pre editovatelnu tabulku)
11
+ // zmyslom narrow buttonu je setrit miesto
12
+ var XButtonIconNarrow = function (props) {
13
+ var className = '';
14
+ if (!XUtils_1.XUtils.isMobile()) {
15
+ className += 'x-button-icon-narrow';
16
+ }
17
+ if (props.addMargin === undefined || props.addMargin === true) {
18
+ if (className !== '') {
19
+ className += ' ';
20
+ }
21
+ className += 'm-1';
22
+ }
23
+ return (react_1.default.createElement(button_1.Button, { icon: props.icon, onClick: props.onClick, disabled: props.disabled, className: className !== '' ? className : undefined, tooltip: props.tooltip }));
24
+ };
25
+ exports.XButtonIconNarrow = XButtonIconNarrow;
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
+ import { ButtonProps } from "primereact/button";
3
+ import { IconType } from "primereact/utils";
2
4
  export declare const XButtonIconSmall: (props: {
3
- icon: string;
5
+ icon: IconType<ButtonProps>;
4
6
  onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
5
7
  disabled?: boolean | undefined;
6
8
  tooltip?: any;
@@ -7,6 +7,7 @@ exports.XButtonIconSmall = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var button_1 = require("primereact/button");
9
9
  var XUtils_1 = require("./XUtils");
10
- exports.XButtonIconSmall = function (props) {
10
+ var XButtonIconSmall = function (props) {
11
11
  return (react_1.default.createElement(button_1.Button, { icon: props.icon, onClick: props.onClick, disabled: props.disabled, className: XUtils_1.XUtils.isMobile() ? undefined : 'x-button-icon-small p-button-sm', tooltip: props.tooltip }));
12
12
  };
13
+ exports.XButtonIconSmall = XButtonIconSmall;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -33,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
33
37
  function verb(n) { return function (v) { return step([n, v]); }; }
34
38
  function step(op) {
35
39
  if (f) throw new TypeError("Generator is already executing.");
36
- while (_) try {
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
37
41
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
38
42
  if (y = 0, t) op = [op[0] & 2, t.value];
39
43
  switch (op[0]) {
@@ -77,11 +81,11 @@ var XUtils_1 = require("./XUtils");
77
81
  var password_1 = require("primereact/password");
78
82
  var button_1 = require("primereact/button");
79
83
  var inputtext_1 = require("primereact/inputtext");
80
- exports.XChangePasswordForm = function (props) {
84
+ var XChangePasswordForm = function (props) {
81
85
  var _a;
82
- var _b = __read(react_1.useState(""), 2), passwordCurrent = _b[0], setPasswordCurrent = _b[1];
83
- var _c = __read(react_1.useState(""), 2), passwordNew = _c[0], setPasswordNew = _c[1];
84
- var _d = __read(react_1.useState(""), 2), passwordNewConfirm = _d[0], setPasswordNewConfirm = _d[1];
86
+ var _b = __read((0, react_1.useState)(""), 2), passwordCurrent = _b[0], setPasswordCurrent = _b[1];
87
+ var _c = __read((0, react_1.useState)(""), 2), passwordNew = _c[0], setPasswordNew = _c[1];
88
+ var _d = __read((0, react_1.useState)(""), 2), passwordNewConfirm = _d[0], setPasswordNewConfirm = _d[1];
85
89
  var onClickSave = function () { return __awaiter(void 0, void 0, void 0, function () {
86
90
  var xToken, e_1;
87
91
  return __generator(this, function (_a) {
@@ -153,3 +157,4 @@ exports.XChangePasswordForm = function (props) {
153
157
  react_1.default.createElement("div", { className: "flex justify-content-center" },
154
158
  react_1.default.createElement(button_1.Button, { label: "Save", onClick: onClickSave }))));
155
159
  };
160
+ exports.XChangePasswordForm = XChangePasswordForm;
@@ -1,10 +1,8 @@
1
- import React from "react";
2
- import { XFormBase } from "./XFormBase";
3
- export declare const XCheckbox: (props: {
4
- form: XFormBase;
5
- field: string;
6
- label?: string | undefined;
7
- readOnly?: boolean | undefined;
8
- inputStyle?: React.CSSProperties | undefined;
9
- labelStyle?: React.CSSProperties | undefined;
10
- }) => JSX.Element;
1
+ /// <reference types="react" />
2
+ import { XInput, XInputProps } from "./XInput";
3
+ export declare class XCheckbox extends XInput<boolean, XInputProps<boolean>> {
4
+ constructor(props: XInputProps<boolean>);
5
+ getValue(): boolean | null;
6
+ onValueChange(e: any): void;
7
+ render(): JSX.Element;
8
+ }