@michalrakus/x-react-web-lib 1.1.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 (61) hide show
  1. package/FindParam.d.ts +3 -0
  2. package/FindParam.js +5 -0
  3. package/XButtonIconNarrow.d.ts +3 -0
  4. package/XButtonIconNarrow.js +5 -0
  5. package/XButtonIconSmall.d.ts +3 -0
  6. package/XButtonIconSmall.js +5 -0
  7. package/XFieldChangeEvent.d.ts +3 -0
  8. package/XFieldChangeEvent.js +5 -0
  9. package/gulpfile.js +4 -0
  10. package/lib/components/SearchTableParams.d.ts +8 -2
  11. package/lib/components/XAutoComplete.d.ts +7 -4
  12. package/lib/components/XAutoComplete.js +21 -6
  13. package/lib/components/XAutoCompleteBase.d.ts +7 -4
  14. package/lib/components/XAutoCompleteBase.js +65 -26
  15. package/lib/components/XAutoCompleteDT.d.ts +33 -0
  16. package/lib/components/XAutoCompleteDT.js +141 -0
  17. package/lib/components/XButton.d.ts +3 -1
  18. package/lib/components/XButton.js +1 -1
  19. package/lib/components/XButtonIconNarrow.d.ts +10 -0
  20. package/lib/components/XButtonIconNarrow.js +25 -0
  21. package/lib/components/XButtonIconSmall.d.ts +3 -1
  22. package/lib/components/XCheckbox.d.ts +2 -2
  23. package/lib/components/XDropdown.d.ts +3 -2
  24. package/lib/components/XDropdown.js +1 -1
  25. package/lib/components/XFieldChangeEvent.d.ts +11 -0
  26. package/lib/components/XFieldChangeEvent.js +2 -0
  27. package/lib/components/XFormBase.d.ts +17 -9
  28. package/lib/components/XFormBase.js +85 -34
  29. package/lib/components/XFormComponent.d.ts +11 -3
  30. package/lib/components/XFormComponent.js +29 -3
  31. package/lib/components/XFormComponentDT.d.ts +30 -0
  32. package/lib/components/XFormComponentDT.js +119 -0
  33. package/lib/components/XFormDataTable2.d.ts +46 -6
  34. package/lib/components/XFormDataTable2.js +170 -40
  35. package/lib/components/XInput.d.ts +2 -2
  36. package/lib/components/XInputDT.d.ts +11 -0
  37. package/lib/components/XInputDT.js +37 -0
  38. package/lib/components/XInputDate.d.ts +2 -1
  39. package/lib/components/XInputDate.js +4 -2
  40. package/lib/components/XInputDecimal.d.ts +9 -2
  41. package/lib/components/XInputDecimal.js +62 -45
  42. package/lib/components/XInputDecimalDT.d.ts +10 -8
  43. package/lib/components/XInputDecimalDT.js +58 -36
  44. package/lib/components/XInputText.d.ts +3 -2
  45. package/lib/components/XInputText.js +7 -1
  46. package/lib/components/XInputTextarea.d.ts +2 -2
  47. package/lib/components/XLazyDataTable.d.ts +5 -0
  48. package/lib/components/XLazyDataTable.js +38 -23
  49. package/lib/components/XSearchButton.d.ts +6 -4
  50. package/lib/components/XSearchButton.js +19 -17
  51. package/lib/components/XSearchButtonDT.js +3 -3
  52. package/lib/components/XUtils.d.ts +12 -2
  53. package/lib/components/XUtils.js +94 -1
  54. package/lib/components/XUtilsConversions.d.ts +1 -0
  55. package/lib/components/XUtilsConversions.js +14 -1
  56. package/lib/components/XUtilsMetadata.d.ts +4 -1
  57. package/lib/components/XUtilsMetadata.js +46 -7
  58. package/lib/serverApi/FindParam.d.ts +10 -2
  59. package/lib/serverApi/XUtilsCommon.d.ts +1 -0
  60. package/lib/serverApi/XUtilsCommon.js +4 -0
  61. package/package.json +1 -1
@@ -1,4 +1,30 @@
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
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
2
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
30
  };
@@ -7,55 +33,46 @@ exports.XInputDecimal = void 0;
7
33
  var react_1 = __importDefault(require("react"));
8
34
  var inputnumber_1 = require("primereact/inputnumber");
9
35
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
10
- var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
11
- var XUtils_1 = require("./XUtils");
12
- var XInputDecimal = function (props) {
13
- var _a, _b, _c;
14
- props.form.addField(props.field);
15
- var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPathStr(props.form.getEntity(), props.field);
16
- var _d = XUtilsMetadata_1.XUtilsMetadata.getParamsForInputNumber(xField), useGrouping = _d.useGrouping, fractionDigits = _d.fractionDigits, min = _d.min, max = _d.max, size = _d.size;
17
- var label = (_a = props.label) !== null && _a !== void 0 ? _a : props.field;
18
- var readOnly = XUtils_1.XUtils.isReadOnly(props.field, props.readOnly);
19
- if (!xField.isNullable && !readOnly) {
20
- label = XUtils_1.XUtils.markNotNull(label);
21
- }
22
- var sizeInput = props.size !== undefined ? props.size : size;
23
- var inline = (_b = props.inline) !== null && _b !== void 0 ? _b : false;
24
- var labelStyle = (_c = props.labelStyle) !== null && _c !== void 0 ? _c : {};
25
- if (!inline) {
26
- XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { width: XUtils_1.XUtils.FIELD_LABEL_WIDTH });
36
+ var XInput_1 = require("./XInput");
37
+ var XInputDecimal = /** @class */ (function (_super) {
38
+ __extends(XInputDecimal, _super);
39
+ function XInputDecimal(props) {
40
+ var _this = _super.call(this, props) || this;
41
+ _this.onValueChange = _this.onValueChange.bind(_this);
42
+ _this.onBlur = _this.onBlur.bind(_this);
43
+ return _this;
27
44
  }
28
- else {
29
- XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { width: 'auto' }); // podla dlzky labelu
30
- XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { marginLeft: '1rem' });
31
- }
32
- var onValueChange = function (e) {
33
- // z InputNumber prichadza e.value - typ number alebo null
34
- props.form.onFieldChange(props.field, e.value);
35
- };
36
- var fieldValue = undefined;
37
- var object = props.form.state.object;
38
- if (object !== null) {
39
- var objectValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(object, props.field);
40
- // pre istotu dame na null, null je standard
41
- //if (objectValue === undefined) {
42
- // objectValue = null;
43
- //}
44
- // TODO - konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli
45
- // - otestovat ci zmena na null funguje dobre -
46
- //fieldValue = stringAsUI(objectValue);
45
+ XInputDecimal.prototype.getValue = function () {
46
+ var value = undefined;
47
+ var objectValue = this.getValueFromObject();
47
48
  // tuto zatial hack, mal by prist number
48
49
  if (typeof objectValue === 'string') {
49
- fieldValue = parseFloat(objectValue);
50
+ value = parseFloat(objectValue);
50
51
  }
51
52
  else if (typeof objectValue === 'number') {
52
- fieldValue = objectValue;
53
+ value = objectValue;
53
54
  }
54
- // fieldValue zostalo undefined (konvertujeme null -> undefined) - InputNumber pozaduje undefined, nechce null
55
- }
56
- // note: style overrides size (width of the input according to character count)
57
- return (react_1.default.createElement("div", { className: "field grid" },
58
- react_1.default.createElement("label", { htmlFor: props.field, className: "col-fixed", style: labelStyle }, label),
59
- react_1.default.createElement(inputnumber_1.InputNumber, { id: props.field, value: fieldValue, onChange: onValueChange, disabled: readOnly, mode: "decimal", locale: "de-DE", useGrouping: useGrouping, minFractionDigits: fractionDigits, maxFractionDigits: fractionDigits, min: min, max: max, size: sizeInput, style: props.inputStyle })));
60
- };
55
+ // value zostalo undefined ak nebol vykonany ziaden if (konvertujeme null -> undefined) - InputNumber pozaduje undefined, nechce null
56
+ return value;
57
+ };
58
+ XInputDecimal.prototype.onValueChange = function (e) {
59
+ // z InputNumber prichadza e.value - typ number alebo null
60
+ this.onValueChangeBase(e.value);
61
+ };
62
+ // nedame do onChange inputu, lebo by sa nas onChange volal po kazdej zmene pismenka
63
+ // ak bude treba, mozme este dorobit metodu "onChange2", ktora sa bude volat po kazdej zmene pismenka (asi iba do XInputText)
64
+ XInputDecimal.prototype.onBlur = function (e) {
65
+ this.callOnChangeFromOnBlur();
66
+ };
67
+ XInputDecimal.prototype.render = function () {
68
+ var _a;
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
+ var sizeInput = (_a = this.props.size) !== null && _a !== void 0 ? _a : size;
71
+ // note: style overrides size (width of the input according to character count)
72
+ 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
+ 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
+ return XInputDecimal;
77
+ }(XInput_1.XInput));
61
78
  exports.XInputDecimal = XInputDecimal;
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { XFormBase } from "./XFormBase";
3
- export declare const XInputDecimalDT: (props: {
4
- form: XFormBase;
5
- entity: string;
6
- field: string;
7
- rowData: any;
8
- readOnly?: boolean | undefined;
9
- }) => JSX.Element;
2
+ import { XInputDT, XInputDTProps } from "./XInputDT";
3
+ export interface XInputDecimalDTProps extends XInputDTProps {
4
+ }
5
+ export declare class XInputDecimalDT extends XInputDT<XInputDecimalDTProps> {
6
+ constructor(props: XInputDecimalDTProps);
7
+ getValue(): number | undefined;
8
+ onValueChange(e: any): void;
9
+ onBlur(e: any): void;
10
+ render(): JSX.Element;
11
+ }
@@ -1,4 +1,30 @@
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
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
2
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
30
  };
@@ -7,46 +33,42 @@ exports.XInputDecimalDT = void 0;
7
33
  var react_1 = __importDefault(require("react"));
8
34
  var inputnumber_1 = require("primereact/inputnumber");
9
35
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
10
- var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
11
- var XInputDecimalDT = function (props) {
12
- var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPathStr(props.entity, props.field);
13
- var _a = XUtilsMetadata_1.XUtilsMetadata.getParamsForInputNumber(xField), useGrouping = _a.useGrouping, fractionDigits = _a.fractionDigits, min = _a.min, max = _a.max;
14
- // ak mame path, field je vzdy readOnly
15
- var readOnly;
16
- var posDot = props.field.indexOf(".");
17
- if (posDot !== -1) {
18
- readOnly = true;
19
- }
20
- else {
21
- readOnly = props.readOnly !== undefined ? props.readOnly : false;
36
+ var XInputDT_1 = require("./XInputDT");
37
+ var XUtils_1 = require("./XUtils");
38
+ var XInputDecimalDT = /** @class */ (function (_super) {
39
+ __extends(XInputDecimalDT, _super);
40
+ function XInputDecimalDT(props) {
41
+ var _this = _super.call(this, props) || this;
42
+ _this.onValueChange = _this.onValueChange.bind(_this);
43
+ _this.onBlur = _this.onBlur.bind(_this);
44
+ return _this;
22
45
  }
23
- var onValueChange = function (field, rowData, newValue) {
24
- // z InputNumber prichadza e.value - typ number alebo null
25
- // zmenime hodnotu v modeli (odtial sa hodnota cita)
26
- rowData[field] = newValue;
27
- // kedze "rowData" je sucastou "props.form.state.object", tak nam staci zavolat setState({object: object}), aby sa zmena prejavila
28
- props.form.onObjectDataChange();
29
- };
30
- var fieldValue = undefined;
31
- // test na undefined je tu koli insertu noveho riadku
32
- if (props.rowData !== undefined && props.rowData !== null) {
33
- var rowDataValue = XUtilsCommon_1.XUtilsCommon.getValueByPath(props.rowData, props.field);
34
- // pre istotu dame na null, null je standard
35
- //if (rowDataValue === undefined) {
36
- // rowDataValue = null;
37
- //}
38
- // TODO - konvertovat null hodnotu na "" (vo funkcii stringAsUI) je dolezite aby sa prejavila zmena na null v modeli
39
- // - otestovat ci zmena na null funguje dobre -
40
- //fieldValue = stringAsUI(rowDataValue);
46
+ XInputDecimalDT.prototype.getValue = function () {
47
+ var value = undefined;
48
+ var rowDataValue = this.getValueFromRowData();
41
49
  // tuto zatial hack, mal by prist number
42
50
  if (typeof rowDataValue === 'string') {
43
- fieldValue = parseFloat(rowDataValue);
51
+ value = parseFloat(rowDataValue);
44
52
  }
45
53
  else if (typeof rowDataValue === 'number') {
46
- fieldValue = rowDataValue;
54
+ value = rowDataValue;
47
55
  }
48
- // fieldValue zostalo undefined (konvertujeme null -> undefined) - InputNumber pozaduje undefined, nechce null
49
- }
50
- return (react_1.default.createElement(inputnumber_1.InputNumber, { id: props.field, value: fieldValue, onChange: function (e) { return onValueChange(props.field, props.rowData, e.value); }, disabled: readOnly, mode: "decimal", locale: "de-DE", useGrouping: useGrouping, minFractionDigits: fractionDigits, maxFractionDigits: fractionDigits, min: min, max: max, className: "x-input-to-resize" }));
51
- };
56
+ // value zostalo undefined ak nebol vykonany ziaden if (konvertujeme null -> undefined) - InputNumber pozaduje undefined, nechce null
57
+ return value;
58
+ };
59
+ XInputDecimalDT.prototype.onValueChange = function (e) {
60
+ // z InputNumber prichadza e.value - typ number alebo null
61
+ this.onValueChangeBase(e.value);
62
+ };
63
+ // nedame do onChange inputu, lebo by sa nas onChange volal po kazdej zmene pismenka
64
+ // ak bude treba, mozme este dorobit metodu "onChange2", ktora sa bude volat po kazdej zmene pismenka (asi iba do XInputText)
65
+ XInputDecimalDT.prototype.onBlur = function (e) {
66
+ this.callOnChangeFromOnBlur();
67
+ };
68
+ XInputDecimalDT.prototype.render = function () {
69
+ var _a = XUtilsMetadata_1.XUtilsMetadata.getParamsForInputNumber(this.xField), useGrouping = _a.useGrouping, fractionDigits = _a.fractionDigits, min = _a.min, max = _a.max;
70
+ return (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, onBlur: this.onBlur }, XUtils_1.XUtils.addClassName(XUtils_1.XUtils.createErrorProps(this.getError()), "x-input-to-resize"))));
71
+ };
72
+ return XInputDecimalDT;
73
+ }(XInputDT_1.XInputDT));
52
74
  exports.XInputDecimalDT = XInputDecimalDT;
@@ -1,11 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { XInput, XInputProps } from "./XInput";
3
- export interface XInputTextProps extends XInputProps {
3
+ export interface XInputTextProps extends XInputProps<string> {
4
4
  size?: number;
5
5
  }
6
- export declare class XInputText extends XInput<XInputTextProps> {
6
+ export declare class XInputText extends XInput<string, XInputTextProps> {
7
7
  constructor(props: XInputTextProps);
8
8
  getValue(): string;
9
9
  onValueChange(e: any): void;
10
+ onBlur(e: any): void;
10
11
  render(): JSX.Element;
11
12
  }
@@ -39,6 +39,7 @@ var XInputText = /** @class */ (function (_super) {
39
39
  function XInputText(props) {
40
40
  var _this = _super.call(this, props) || this;
41
41
  _this.onValueChange = _this.onValueChange.bind(_this);
42
+ _this.onBlur = _this.onBlur.bind(_this);
42
43
  return _this;
43
44
  }
44
45
  XInputText.prototype.getValue = function () {
@@ -50,13 +51,18 @@ var XInputText = /** @class */ (function (_super) {
50
51
  var value = (0, XUtilsConversions_1.stringFromUI)(e.target.value);
51
52
  this.onValueChangeBase(value);
52
53
  };
54
+ // nedame do onChange inputu, lebo by sa nas onChange volal po kazdej zmene pismenka
55
+ // ak bude treba, mozme este dorobit metodu "onChange2", ktora sa bude volat po kazdej zmene pismenka (asi iba do XInputText)
56
+ XInputText.prototype.onBlur = function (e) {
57
+ this.callOnChangeFromOnBlur();
58
+ };
53
59
  XInputText.prototype.render = function () {
54
60
  var _a;
55
61
  var size = (_a = this.props.size) !== null && _a !== void 0 ? _a : this.xField.length;
56
62
  // note: style overrides size (width of the input according to character count)
57
63
  return (react_1.default.createElement("div", { className: "field grid" },
58
64
  react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
59
- 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()))));
65
+ 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 }))));
60
66
  };
61
67
  return XInputText;
62
68
  }(XInput_1.XInput));
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
2
  import { XInput, XInputProps } from "./XInput";
3
- export interface XInputTextareaProps extends XInputProps {
3
+ export interface XInputTextareaProps extends XInputProps<string> {
4
4
  rows: number;
5
5
  cols?: number | "full";
6
6
  labelOnTop?: boolean;
7
7
  }
8
- export declare class XInputTextarea extends XInput<XInputTextareaProps> {
8
+ export declare class XInputTextarea extends XInput<string, XInputTextareaProps> {
9
9
  static defaultProps: {
10
10
  cols: string;
11
11
  labelOnTop: boolean;
@@ -1,5 +1,7 @@
1
1
  import { ReactChild } from 'react';
2
2
  import { SearchTableParams } from "./SearchTableParams";
3
+ import { XCustomFilter } from "../serverApi/FindParam";
4
+ import { XOnSaveOrCancelProp } from "./XFormBase";
3
5
  export interface XEditModeHandlers {
4
6
  onStart: () => void;
5
7
  onSave: () => void;
@@ -24,7 +26,10 @@ export interface XLazyDataTableProps {
24
26
  onAddRow?: () => void;
25
27
  onEdit?: (selectedRow: any) => void;
26
28
  removeRow?: ((selectedRow: any) => Promise<boolean>) | boolean;
29
+ onRemoveRow?: XOnSaveOrCancelProp;
27
30
  appButtons?: any;
31
+ customFilter?: XCustomFilter;
32
+ initSortField?: string;
28
33
  searchTableParams?: SearchTableParams;
29
34
  width?: string;
30
35
  editMode?: boolean;
@@ -128,20 +128,7 @@ var XLazyDataTable = function (props) {
128
128
  var xField = XUtilsMetadata_1.XUtilsMetadata.getXFieldByPath(xEntity, field);
129
129
  // TODO column.props.dropdownInFilter - pre "menu" by bolo fajn mat zoznam "enumov"
130
130
  var filterMatchMode = getFilterMatchMode(xField);
131
- var filterItem = void 0;
132
- if (props.filterDisplay === "menu") {
133
- // DataTableOperatorFilterMetaData: operator + filter values
134
- filterItem = {
135
- operator: api_1.FilterOperator.OR,
136
- constraints: [{ value: null, matchMode: filterMatchMode }]
137
- };
138
- }
139
- else {
140
- // props.filterDisplay === "row"
141
- // DataTableFilterMetaData: filter value
142
- filterItem = { value: null, matchMode: filterMatchMode };
143
- }
144
- initFilters[field] = filterItem;
131
+ initFilters[field] = createFilterItem(props.filterDisplay, { value: null, matchMode: filterMatchMode });
145
132
  }
146
133
  }
147
134
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -167,18 +154,40 @@ var XLazyDataTable = function (props) {
167
154
  }
168
155
  return filterMatchMode;
169
156
  };
157
+ var createFilterItem = function (filterDisplay, constraint) {
158
+ var filterItem;
159
+ if (filterDisplay === "menu") {
160
+ // DataTableOperatorFilterMetaData: operator + filter values
161
+ filterItem = {
162
+ operator: api_1.FilterOperator.OR,
163
+ constraints: [constraint]
164
+ };
165
+ }
166
+ else {
167
+ // props.filterDisplay === "row"
168
+ // DataTableFilterMetaData: filter value
169
+ filterItem = constraint;
170
+ }
171
+ return filterItem;
172
+ };
173
+ // premenne platne pre cely component (obdoba member premennych v class-e)
170
174
  var dataTableEl = (0, react_1.useRef)(null);
175
+ var customFilter = props.customFilter;
171
176
  var _a = __read((0, react_1.useState)({ rowList: [], totalRecords: 0 }), 2), value = _a[0], setValue = _a[1];
172
177
  var _b = __read((0, react_1.useState)(false), 2), loading = _b[0], setLoading = _b[1];
173
178
  var _c = __read((0, react_1.useState)(0), 2), first = _c[0], setFirst = _c[1];
174
179
  var _d = __read((0, react_1.useState)(props.paginator ? props.rows : undefined), 2), rows = _d[0], setRows = _d[1];
175
180
  var filtersInit = createInitFilters();
176
- if (props.searchTableParams !== undefined && props.searchTableParams.filter !== undefined) {
177
- // TODO - zohladnit "menu" filtrovanie
178
- filtersInit[props.searchTableParams.displayField] = { value: props.searchTableParams.filter, matchMode: "startsWith" };
181
+ if (props.searchTableParams !== undefined) {
182
+ var displayFieldFilter = props.searchTableParams.displayFieldFilter;
183
+ if (displayFieldFilter !== undefined) {
184
+ filtersInit[displayFieldFilter.field] = createFilterItem(props.filterDisplay, displayFieldFilter.constraint);
185
+ }
186
+ // ak mame props.searchTableParams.customFilter, pridame ho
187
+ customFilter = XUtils_1.XUtils.filterAnd(customFilter, props.searchTableParams.customFilter);
179
188
  }
180
189
  var _e = __read((0, react_1.useState)(filtersInit), 2), filters = _e[0], setFilters = _e[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
181
- var _f = __read((0, react_1.useState)([]), 2), multiSortMeta = _f[0], setMultiSortMeta = _f[1];
190
+ var _f = __read((0, react_1.useState)(props.initSortField ? [{ field: props.initSortField, order: 1 }] : []), 2), multiSortMeta = _f[0], setMultiSortMeta = _f[1];
182
191
  var _g = __read((0, react_1.useState)(null), 2), selectedRow = _g[0], setSelectedRow = _g[1];
183
192
  var _h = __read((0, react_1.useState)(false), 2), dataLoaded = _h[0], setDataLoaded = _h[1]; // priznak kde si zapiseme, ci uz sme nacitali data
184
193
  var _j = __read((0, react_1.useState)(false), 2), exportRowsDialogOpened = _j[0], setExportRowsDialogOpened = _j[1];
@@ -216,7 +225,7 @@ var XLazyDataTable = function (props) {
216
225
  return __generator(this, function (_a) {
217
226
  //console.log("zavolany onPage");
218
227
  setFirst(event.first);
219
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() });
228
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: event.first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() });
220
229
  return [2 /*return*/];
221
230
  });
222
231
  }); };
@@ -230,14 +239,14 @@ var XLazyDataTable = function (props) {
230
239
  //console.log("zavolany onSort - this.state.multiSortMeta = " + JSON.stringify(multiSortMeta));
231
240
  //console.log("zavolany onSort - event.multiSortMeta = " + JSON.stringify(event.multiSortMeta));
232
241
  setMultiSortMeta(event.multiSortMeta);
233
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields() });
242
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: event.multiSortMeta, entity: props.entity, fields: getFields() });
234
243
  };
235
244
  var onClickFilter = function () {
236
245
  //console.log("zavolany onClickFilter");
237
246
  loadData();
238
247
  };
239
248
  var loadData = function () {
240
- loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() });
249
+ loadDataBase({ resultType: FindParam_1.ResultType.RowCountAndPagedRows, first: first, rows: rows, filters: filters, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() });
241
250
  };
242
251
  var loadDataBase = function (findParam) { return __awaiter(void 0, void 0, void 0, function () {
243
252
  var findResult;
@@ -365,6 +374,9 @@ var XLazyDataTable = function (props) {
365
374
  case 4:
366
375
  if (reread) {
367
376
  loadData();
377
+ if (props.onRemoveRow) {
378
+ props.onRemoveRow(selectedRow, XUtils_1.OperationType.Remove);
379
+ }
368
380
  }
369
381
  return [3 /*break*/, 10];
370
382
  case 5:
@@ -384,6 +396,9 @@ var XLazyDataTable = function (props) {
384
396
  return [3 /*break*/, 9];
385
397
  case 9:
386
398
  loadData();
399
+ if (props.onRemoveRow) {
400
+ props.onRemoveRow(selectedRow, XUtils_1.OperationType.Remove);
401
+ }
387
402
  _a.label = 10;
388
403
  case 10: return [3 /*break*/, 12];
389
404
  case 11:
@@ -398,7 +413,7 @@ var XLazyDataTable = function (props) {
398
413
  return __generator(this, function (_a) {
399
414
  switch (_a.label) {
400
415
  case 0:
401
- findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
416
+ findParam = { resultType: FindParam_1.ResultType.OnlyRowCount, first: first, rows: rows, filters: filtersAfterFiltering, customFilter: customFilter, multiSortMeta: multiSortMeta, entity: props.entity, fields: getFields() };
402
417
  return [4 /*yield*/, findByFilter(findParam)];
403
418
  case 1:
404
419
  findResult = _a.sent();
@@ -706,7 +721,7 @@ var XLazyDataTable = function (props) {
706
721
  // TODO - if filter not used at all, then buttons flags should be false
707
722
  var filterMenuInFilterRow = props.filterDisplay === "row" && showFilterMenu;
708
723
  var filterButtonInHeader = props.filterDisplay === "menu";
709
- width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, filterMenuInFilterRow, undefined, headerLabel, filterButtonInHeader);
724
+ width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, filterMenuInFilterRow, undefined, headerLabel, true, filterButtonInHeader);
710
725
  }
711
726
  var headerStyle = {};
712
727
  if (width !== undefined) {
@@ -1,17 +1,19 @@
1
1
  import React from "react";
2
- import { XFormComponent, XFormComponentProps } from "./XFormComponent";
2
+ import { XFilterProp, XFormComponent, XFormComponentProps } from "./XFormComponent";
3
3
  import { XAssoc } from "../serverApi/XEntityMetadata";
4
- export interface XSearchButtonProps extends XFormComponentProps {
4
+ import { XObject } from "./XObject";
5
+ export interface XSearchButtonProps extends XFormComponentProps<XObject> {
5
6
  assocField: string;
6
7
  displayField: string;
7
8
  searchTable: any;
8
9
  assocForm?: any;
10
+ filter?: XFilterProp;
9
11
  size?: number;
10
12
  inputStyle?: React.CSSProperties;
11
13
  }
12
- export declare class XSearchButton extends XFormComponent<XSearchButtonProps> {
14
+ export declare class XSearchButton extends XFormComponent<XObject, XSearchButtonProps> {
13
15
  protected xAssoc: XAssoc;
14
- inputTextEl: any;
16
+ inputTextRef: any;
15
17
  state: {
16
18
  inputChanged: boolean;
17
19
  inputValueState: any;
@@ -78,7 +78,7 @@ var XSearchButton = /** @class */ (function (_super) {
78
78
  function XSearchButton(props) {
79
79
  var _this = _super.call(this, props) || this;
80
80
  _this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
81
- _this.inputTextEl = react_1.default.createRef();
81
+ _this.inputTextRef = react_1.default.createRef();
82
82
  // POVODNY KOD
83
83
  //this.overlayPanelEl = React.createRef();
84
84
  _this.state = {
@@ -127,20 +127,18 @@ var XSearchButton = /** @class */ (function (_super) {
127
127
  setInputValueState(e.target.value);
128
128
  };
129
129
  var onInputBlur = function (e) { return __awaiter(_this, void 0, void 0, function () {
130
- var rows;
130
+ var displayFieldFilter, customFilter, rows;
131
131
  return __generator(this, function (_a) {
132
132
  switch (_a.label) {
133
133
  case 0:
134
134
  if (!inputChanged) return [3 /*break*/, 3];
135
- if (!(e.target.value === '')) return [3 /*break*/, 1];
135
+ if (!(e.target.value === '' || e.target.value === undefined || e.target.value === null)) return [3 /*break*/, 1];
136
136
  setValueToModel(null); // prazdny retazec znamena null hodnotu
137
137
  return [3 /*break*/, 3];
138
- case 1: return [4 /*yield*/, XUtils_1.XUtils.fetchMany('findRowsForAssoc', {
139
- entity: props.form.entity,
140
- assocField: props.assocField,
141
- displayField: props.displayField,
142
- filter: e.target.value
143
- })];
138
+ case 1:
139
+ displayFieldFilter = { filter: "[".concat(props.displayField, "] LIKE :xDisplayFieldValue"), values: { "xDisplayFieldValue": "".concat(e.target.value, "%") } };
140
+ customFilter = this.getFilterBase(this.props.filter);
141
+ return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.xAssoc.entityName, XUtils_1.XUtils.filterAnd(displayFieldFilter, customFilter))];
144
142
  case 2:
145
143
  rows = _a.sent();
146
144
  if (rows.length === 0) {
@@ -164,7 +162,7 @@ var XSearchButton = /** @class */ (function (_super) {
164
162
  });
165
163
  }); };
166
164
  var setValueToModel = function (row) {
167
- _this.onValueChangeBase(row);
165
+ _this.onValueChangeBase(row, _this.props.onChange);
168
166
  setInputChanged(false);
169
167
  };
170
168
  var onClickSearch = function (e) {
@@ -198,24 +196,28 @@ var XSearchButton = /** @class */ (function (_super) {
198
196
  setDialogOpened(false);
199
197
  // ak mame v inpute neplatnu hodnotu, musime vratit kurzor na input
200
198
  if (inputChanged) {
201
- _this.inputTextEl.current.element.focus(); // neviem preco tu trebalo pridat "element", asi primereact wrapuje react element
199
+ _this.inputTextRef.current.focus();
202
200
  }
203
201
  };
204
202
  // {React.createElement(props.searchTable, {searchTableParams: {onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}, ...props.searchTableProps}, null)}
205
203
  // <BrandSearchTable searchTableParams={{onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}} qqq="fiha"/>
204
+ // takto cez metodku, mozno sa metodka vola len ked sa otvori dialog a usetrime nieco...
205
+ var createSearchTableParams = function () {
206
+ return {
207
+ onChoose: onChoose,
208
+ displayFieldFilter: (inputChanged ? { field: props.displayField, constraint: { value: inputValueState, matchMode: "startsWith" } } : undefined),
209
+ customFilter: _this.getFilterBase(_this.props.filter)
210
+ };
211
+ };
206
212
  // vypocitame inputValue
207
213
  var inputValue = computeInputValue();
208
214
  return (react_1.default.createElement("div", { className: "field grid" },
209
215
  react_1.default.createElement("label", { htmlFor: props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
210
216
  react_1.default.createElement("div", { className: "x-search-button-base" },
211
- react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: this.isReadOnly(), ref: this.inputTextEl, maxLength: xDisplayField.length, size: size, style: props.inputStyle }, this.getClassNameTooltip())),
217
+ react_1.default.createElement(inputtext_1.InputText, __assign({ id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: this.isReadOnly(), ref: this.inputTextRef, maxLength: xDisplayField.length, size: size, style: props.inputStyle }, this.getClassNameTooltip())),
212
218
  react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
213
219
  react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, {
214
- searchTableParams: {
215
- onChoose: onChoose,
216
- displayField: props.displayField,
217
- filter: (inputChanged ? inputValueState : undefined)
218
- }
220
+ searchTableParams: createSearchTableParams()
219
221
  }, props.searchTable.children))));
220
222
  };
221
223
  return XSearchButton;
@@ -83,7 +83,7 @@ var button_1 = require("primereact/button");
83
83
  var dialog_1 = require("primereact/dialog");
84
84
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
85
85
  var XSearchButtonDT = function (props) {
86
- var inputTextEl = (0, react_1.useRef)(null);
86
+ var inputTextRef = (0, react_1.useRef)(null);
87
87
  var _a = __read((0, react_1.useState)(false), 2), inputChanged = _a[0], setInputChanged = _a[1]; // priznak, ci uzivatel typovanim zmenil hodnotu v inpute
88
88
  var _b = __read((0, react_1.useState)(null), 2), inputValueState = _b[0], setInputValueState = _b[1]; // pouzivane, len ak inputChanged === true, je tu zapisana zmenena hodnota v inpute
89
89
  var _c = __read((0, react_1.useState)(false), 2), dialogOpened = _c[0], setDialogOpened = _c[1];
@@ -172,7 +172,7 @@ var XSearchButtonDT = function (props) {
172
172
  setDialogOpened(false);
173
173
  // ak mame v inpute neplatnu hodnotu, musime vratit kurzor na input
174
174
  if (inputChanged) {
175
- inputTextEl.current.element.focus(); // neviem preco tu trebalo pridat "element", asi primereact wrapuje react element
175
+ inputTextRef.current.focus();
176
176
  }
177
177
  };
178
178
  // {React.createElement(props.searchTable, {searchTableParams: {onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined)}, ...props.searchTableProps}, null)}
@@ -181,7 +181,7 @@ var XSearchButtonDT = function (props) {
181
181
  var inputValue = computeInputValue();
182
182
  return (react_1.default.createElement("div", null,
183
183
  react_1.default.createElement("div", { className: "x-search-button-base" },
184
- react_1.default.createElement(inputtext_1.InputText, { id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: readOnly, ref: inputTextEl }),
184
+ react_1.default.createElement(inputtext_1.InputText, { id: props.assocField, value: inputValue, onChange: onInputValueChange, onBlur: onInputBlur, readOnly: readOnly, ref: inputTextRef }),
185
185
  react_1.default.createElement(button_1.Button, { label: "...", onClick: onClickSearch })),
186
186
  react_1.default.createElement(dialog_1.Dialog, { visible: dialogOpened, onHide: onHide }, react_1.default.cloneElement(props.searchTable, { searchTableParams: { onChoose: onChoose, displayField: props.displayField, filter: (inputChanged ? inputValueState : undefined) } }, props.searchTable.children))));
187
187
  };
@@ -2,7 +2,8 @@ import { XToken } from "./XToken";
2
2
  import { CsvDecimalFormat, CsvSeparator, ExportType } from "../serverApi/ExportImportParam";
3
3
  import React from "react";
4
4
  import { XEnvVar } from "./XEnvVars";
5
- import { XError } from "./XErrors";
5
+ import { XError, XErrorMap } from "./XErrors";
6
+ import { XCustomFilter } from "../serverApi/FindParam";
6
7
  export declare enum OperationType {
7
8
  None = 0,
8
9
  Insert = 1,
@@ -33,6 +34,7 @@ export declare class XUtils {
33
34
  static registerAppForm(elem: any, entity: string, formId?: string): void;
34
35
  static getAppForm(entity: string, formId?: string): any;
35
36
  static fetchMany(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any[]>;
37
+ static fetchRows(entity: string, customFilter: XCustomFilter | undefined, sortField?: string): Promise<any[]>;
36
38
  static fetchOne(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
37
39
  static fetchString(path: string, value: any): Promise<string>;
38
40
  static fetch(path: string, value: any, usePublicToken?: boolean | XToken): Promise<any>;
@@ -54,10 +56,18 @@ export declare class XUtils {
54
56
  static getEnvVarValue(envVarEnum: XEnvVar): string;
55
57
  static removeRow(entity: string, row: any): Promise<void>;
56
58
  static arrayMoveElement(array: any[], position: number, offset: number): void;
59
+ static arraySort(array: any[], fieldOrStringFunction: string | ((item: any) => string)): any[];
57
60
  static isReadOnly(path: string, readOnlyInit?: boolean): boolean;
58
61
  static markNotNull(label: string): string;
59
62
  static showErrorMessage(message: string, e: unknown): void;
60
63
  static createErrorProps(error: string | undefined): {};
61
- static getXErrorMessage(xError: XError): string | undefined;
64
+ static addClassName(props: {
65
+ [key: string]: any;
66
+ }, className: string): {
67
+ [key: string]: any;
68
+ };
69
+ static getErrorMessages(xErrorMap: XErrorMap): string;
70
+ static getErrorMessage(xError: XError): string | undefined;
62
71
  static normalizeString(value: string): string;
72
+ static filterAnd(filter1: XCustomFilter | undefined, filter2: XCustomFilter | undefined): XCustomFilter | undefined;
63
73
  }