@michalrakus/x-react-web-lib 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/XCalendar.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ // generated by gulp
2
+
3
+ export * from './lib/components/XCalendar';
package/XCalendar.js ADDED
@@ -0,0 +1,5 @@
1
+ // generated by gulp
2
+
3
+ 'use strict';
4
+
5
+ module.exports = require('./lib/components/XCalendar.js');
@@ -0,0 +1,3 @@
1
+ // generated by gulp
2
+
3
+ export * from './lib/components/XDropdownForEntity';
@@ -0,0 +1,5 @@
1
+ // generated by gulp
2
+
3
+ 'use strict';
4
+
5
+ module.exports = require('./lib/components/XDropdownForEntity.js');
@@ -0,0 +1,3 @@
1
+ // generated by gulp
2
+
3
+ export * from './lib/components/XInputDecimalBase';
@@ -0,0 +1,5 @@
1
+ // generated by gulp
2
+
3
+ 'use strict';
4
+
5
+ module.exports = require('./lib/components/XInputDecimalBase.js');
package/gulpfile.js CHANGED
@@ -16,13 +16,15 @@ function generateApi(cb) {
16
16
  "./lib/components/useXToken",
17
17
  "./lib/components/XAutoComplete",
18
18
  "./lib/components/XAutoCompleteBase",
19
+ "./lib/components/XBrowse",
19
20
  "./lib/components/XButton",
20
21
  "./lib/components/XButtonIconNarrow",
21
22
  "./lib/components/XButtonIconSmall",
22
- "./lib/components/XBrowse",
23
+ "./lib/components/XCalendar",
23
24
  "./lib/components/XChangePasswordForm",
24
25
  "./lib/components/XCheckbox",
25
26
  "./lib/components/XDropdown",
27
+ "./lib/components/XDropdownForEntity",
26
28
  "./lib/components/XEnvVars",
27
29
  "./lib/components/XErrors",
28
30
  "./lib/components/XFieldChangeEvent",
@@ -34,6 +36,7 @@ function generateApi(cb) {
34
36
  "./lib/components/XHolders",
35
37
  "./lib/components/XInputDate",
36
38
  "./lib/components/XInputDecimal",
39
+ "./lib/components/XInputDecimalBase",
37
40
  "./lib/components/XInputText",
38
41
  "./lib/components/XInputTextarea",
39
42
  "./lib/components/XLazyDataTable",
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const XCalendar: (props: {
3
+ id?: string | undefined;
4
+ value: Date | null;
5
+ onChange: (value: Date | null) => void;
6
+ readOnly?: boolean | undefined;
7
+ datetime?: boolean | undefined;
8
+ }) => JSX.Element;
@@ -0,0 +1,27 @@
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.XCalendar = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var calendar_1 = require("primereact/calendar");
9
+ var XUtilsConversions_1 = require("./XUtilsConversions");
10
+ // wrapper for Calendar component, maybe better name would be XInputDateBase
11
+ var XCalendar = function (props) {
12
+ var _a;
13
+ var onChange = function (e) {
14
+ // z Calendar prichadza e.value - typ Date alebo null
15
+ // typ Date prichadza ak uzivatel vyplnil validny datum, null (typeof e.value vracia "object") prichadza ak uzivatel vymazal datum
16
+ // alebo je este datum nekompletny (uzivatel prave zadava datum)
17
+ // ak nastavime keepInvalid={true}, tak bude chodit nevalidny string (typeof e.value vracia "string")
18
+ //console.log(typeof e.value);
19
+ //console.log(e.value instanceof Date);
20
+ if (e.value instanceof Date || e.value === null) {
21
+ props.onChange(e.value);
22
+ }
23
+ };
24
+ var datetime = (_a = props.datetime) !== null && _a !== void 0 ? _a : false;
25
+ return (react_1.default.createElement(calendar_1.Calendar, { id: props.id, value: props.value, onChange: onChange, disabled: props.readOnly, showIcon: true, showOnFocus: false, dateFormat: (0, XUtilsConversions_1.dateFormatCalendar)(), showTime: datetime, showSeconds: datetime, inputClassName: datetime ? 'x-input-datetime' : 'x-input-date' }));
26
+ };
27
+ exports.XCalendar = XCalendar;
@@ -1,22 +1,17 @@
1
1
  /// <reference types="react" />
2
- import { XFormComponent, XFormComponentProps } from "./XFormComponent";
2
+ import { XFilterProp, XFormComponent, XFormComponentProps } from "./XFormComponent";
3
3
  import { XAssoc } from "../serverApi/XEntityMetadata";
4
4
  import { XObject } from "./XObject";
5
5
  export interface XDropdownProps extends XFormComponentProps<XObject> {
6
6
  assocField: string;
7
7
  displayField: string;
8
+ filter?: XFilterProp;
8
9
  }
9
10
  export declare class XDropdown extends XFormComponent<XObject, XDropdownProps> {
10
11
  protected xAssoc: XAssoc;
11
- state: {
12
- options: any[];
13
- };
14
12
  constructor(props: XDropdownProps);
15
13
  getField(): string;
16
14
  isNotNull(): boolean;
17
15
  getValue(): any | null;
18
- onValueChange(e: any): void;
19
- componentDidMount(): void;
20
- private findOptions;
21
16
  render(): JSX.Element;
22
17
  }
@@ -14,73 +14,21 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
- 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;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
17
  var __importDefault = (this && this.__importDefault) || function (mod) {
65
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
66
19
  };
67
20
  Object.defineProperty(exports, "__esModule", { value: true });
68
21
  exports.XDropdown = void 0;
69
22
  var react_1 = __importDefault(require("react"));
70
- var dropdown_1 = require("primereact/dropdown");
71
- var XUtils_1 = require("./XUtils");
72
23
  var XUtilsMetadata_1 = require("./XUtilsMetadata");
73
24
  var XFormComponent_1 = require("./XFormComponent");
25
+ var XDropdownForEntity_1 = require("./XDropdownForEntity");
74
26
  var XDropdown = /** @class */ (function (_super) {
75
27
  __extends(XDropdown, _super);
76
28
  function XDropdown(props) {
77
29
  var _this = _super.call(this, props) || this;
78
30
  _this.xAssoc = XUtilsMetadata_1.XUtilsMetadata.getXAssocToOne(XUtilsMetadata_1.XUtilsMetadata.getXEntity(props.form.getEntity()), props.assocField);
79
- _this.state = {
80
- options: []
81
- };
82
31
  props.form.addField(props.assocField + '.' + props.displayField);
83
- _this.onValueChange = _this.onValueChange.bind(_this);
84
32
  return _this;
85
33
  }
86
34
  XDropdown.prototype.getField = function () {
@@ -93,46 +41,16 @@ var XDropdown = /** @class */ (function (_super) {
93
41
  var assocObject = this.getValueFromObject();
94
42
  return assocObject;
95
43
  };
96
- XDropdown.prototype.onValueChange = function (e) {
97
- var newValueOrNull;
98
- // specialna null polozka nema ziadne atributy
99
- if (Object.keys(e.target.value).length === 0) {
100
- newValueOrNull = null;
101
- }
102
- else {
103
- newValueOrNull = e.target.value;
104
- }
105
- this.onValueChangeBase(newValueOrNull, this.props.onChange);
106
- };
107
- XDropdown.prototype.componentDidMount = function () {
108
- this.findOptions(this.props.form.getEntity(), this.props.assocField);
109
- };
110
- XDropdown.prototype.findOptions = function (entity, assocField) {
111
- return __awaiter(this, void 0, void 0, function () {
112
- var options;
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchMany('findRowsForAssoc', { entity: entity, assocField: assocField })];
116
- case 1:
117
- options = _a.sent();
118
- options.splice(0, 0, {}); // null polozka (nepridavat pre not null atributy)
119
- this.setState({ options: options });
120
- return [2 /*return*/];
121
- }
122
- });
123
- });
124
- };
125
44
  XDropdown.prototype.render = function () {
126
- // TODO - pridat cez generikum typ objektu v Dropdown-e (ak sa da)
127
- var options = this.state.options;
128
- // TODO - mozno by nebolo od veci pouzivat InputText ak readOnly === true (chybala by len sipka (rozbalovac)) a dalo by sa copy-paste-ovat
129
- // propertiesy na Dropdown-e: readOnly vyseduje, disabled znemoznuje vyber polozky
130
- var readOnly = this.isReadOnly();
131
- // Dropdown setuje do atributu object.assocField asociovany objekt zo zoznamu objektov ktore ziskame podla asociacie
132
- // appendTo={document.body} appenduje overlay panel na element body - eliminuje "skakanie" formularu na mobile pri kliknuti na dropdown
45
+ var _this = this;
46
+ // POZOR!
47
+ // this.getFilterBase(this.props.filter) - nefunguje dynamicky filter, lebo objekt potrebny vo funkcii this.props.filter sa nacitava az v XFormBase.componentDidMount()
48
+ // a funkcia this.props.filter sa vola skor (pri vypocitavani atributu filter)
49
+ // ani keby bola funkcia volana vo componentDidMount() tohto XDropdown, nepomohlo by to, tento componentDidMount() sa vola skor ako componentDidMount() parenta XFormBase
50
+ // planuje sa to riesit bud zavedenim cache pre options alebo vytiahnutim options na uroven XFormBase
133
51
  return (react_1.default.createElement("div", { className: "field grid" },
134
52
  react_1.default.createElement("label", { htmlFor: this.props.assocField, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
135
- react_1.default.createElement(dropdown_1.Dropdown, __assign({ appendTo: document.body, id: this.props.assocField, optionLabel: this.props.displayField, value: this.getValue(), options: options, onChange: this.onValueChange, readOnly: readOnly, disabled: readOnly }, this.getClassNameTooltip()))));
53
+ react_1.default.createElement(XDropdownForEntity_1.XDropdownForEntity, { id: this.props.assocField, entity: this.xAssoc.entityName, displayField: this.props.displayField, value: this.getValue(), onChange: function (value) { return _this.onValueChangeBase(value, _this.props.onChange); }, readOnly: this.isReadOnly(), isNotNull: this.isNotNull(), error: this.getError(), filter: this.getFilterBase(this.props.filter) })));
136
54
  };
137
55
  return XDropdown;
138
56
  }(XFormComponent_1.XFormComponent));
@@ -80,28 +80,29 @@ var react_1 = __importStar(require("react"));
80
80
  var XUtils_1 = require("./XUtils");
81
81
  var dropdown_1 = require("primereact/dropdown");
82
82
  var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
83
+ var XUtilsMetadata_1 = require("./XUtilsMetadata");
83
84
  // pouzivany vo filtri v XLazyDataTable aj v XFormDataTable2
84
85
  var XDropdownDTFilter = function (props) {
85
86
  var _a = __read((0, react_1.useState)([]), 2), options = _a[0], setOptions = _a[1];
86
- // TODO - upravit tak aby zvladol aj path dlzky 3 a viac
87
87
  var fieldList = XUtilsCommon_1.XUtilsCommon.getFieldListForPath(props.path);
88
88
  if (fieldList.length < 2) {
89
- throw "XDropdownDTFilter: prop path (".concat(props.path, ") must have at least 2 fields");
89
+ throw "XDropdownDTFilter: prop path (".concat(props.path, ") must have at least 2 items");
90
90
  }
91
- var assocField = fieldList[0];
92
91
  var displayField = fieldList[fieldList.length - 1];
93
92
  // parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
94
93
  (0, react_1.useEffect)(function () {
95
- findOptions(props.entity, assocField, displayField);
94
+ findOptions(props.entity, props.path, displayField);
96
95
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
97
96
  var onValueChange = function (e) {
98
97
  props.onValueChange(props.path, e.target.value);
99
98
  };
100
- var findOptions = function (entity, assocField, displayField) { return __awaiter(void 0, void 0, void 0, function () {
101
- var options, emptyOption;
99
+ var findOptions = function (entity, path, displayField) { return __awaiter(void 0, void 0, void 0, function () {
100
+ var xAssoc, options, emptyOption;
102
101
  return __generator(this, function (_a) {
103
102
  switch (_a.label) {
104
- case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchMany('findRowsForAssoc', { entity: entity, assocField: assocField })];
103
+ case 0:
104
+ xAssoc = XUtilsMetadata_1.XUtilsMetadata.getLastXAssocByPath(XUtilsMetadata_1.XUtilsMetadata.getXEntity(entity), path);
105
+ return [4 /*yield*/, XUtils_1.XUtils.fetchRows(xAssoc.entityName, undefined, displayField)];
105
106
  case 1:
106
107
  options = _a.sent();
107
108
  emptyOption = {};
@@ -0,0 +1,24 @@
1
+ import { Component } from "react";
2
+ import { DropdownChangeEvent } from "primereact/dropdown";
3
+ import { XCustomFilter } from "../serverApi/FindParam";
4
+ export interface XDropdownForEntityProps {
5
+ id?: string;
6
+ entity: string;
7
+ displayField: string;
8
+ value: any | null;
9
+ onChange: (value: any | null) => void;
10
+ readOnly?: boolean;
11
+ isNotNull?: boolean;
12
+ error?: string;
13
+ filter?: XCustomFilter;
14
+ }
15
+ export declare class XDropdownForEntity extends Component<XDropdownForEntityProps> {
16
+ state: {
17
+ options: any[];
18
+ };
19
+ constructor(props: XDropdownForEntityProps);
20
+ componentDidMount(): void;
21
+ loadOptions(): Promise<void>;
22
+ onChange(e: DropdownChangeEvent): void;
23
+ render(): JSX.Element;
24
+ }
@@ -0,0 +1,148 @@
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
+ };
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = 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);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
41
+ }) : function(o, v) {
42
+ o["default"] = v;
43
+ });
44
+ var __importStar = (this && this.__importStar) || function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53
+ return new (P || (P = Promise))(function (resolve, reject) {
54
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
58
+ });
59
+ };
60
+ var __generator = (this && this.__generator) || function (thisArg, body) {
61
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
62
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
+ function verb(n) { return function (v) { return step([n, v]); }; }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
+ 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;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+ switch (op[0]) {
70
+ case 0: case 1: t = op; break;
71
+ case 4: _.label++; return { value: op[1], done: false };
72
+ case 5: _.label++; y = op[1]; op = [0]; continue;
73
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
+ default:
75
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
+ if (t[2]) _.ops.pop();
80
+ _.trys.pop(); continue;
81
+ }
82
+ op = body.call(thisArg, _);
83
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
+ }
86
+ };
87
+ Object.defineProperty(exports, "__esModule", { value: true });
88
+ exports.XDropdownForEntity = void 0;
89
+ var react_1 = __importStar(require("react"));
90
+ var dropdown_1 = require("primereact/dropdown");
91
+ var XUtils_1 = require("./XUtils");
92
+ // vseobecny Dropdown ktoreho parametrom je entity, zobrazuje zaznamy danej entity, po selectnuti vracia zaznam danej entity
93
+ // ambicia je pouzivat ho vsade - vo formulari, vo filtroch, vo form tabulke, priamo aplikacnym programmerom
94
+ // dalo by sa vyclenit este XDropdownBase, ktory by dostaval ako parameter options (bol by nezavisly od DB), zatial ho nerobime,
95
+ // pravdepodobnost potreby XDropdownBase je nizka
96
+ // do buducna sa planuje pouzit cache pre options (plnila by sa pri otvoreni XFormBase*) - dolezite je to hlavne pre dropdowny vo form tabulke (a tiez pre dynamicky filter vo formulari - objekt sa nacita neskor ako options)
97
+ // tiez by bolo fajn podporovat dynamicky filter (vo formulari) - to by ale trebalo vytiahnut options do state formulara
98
+ // otazka je ci nepouzivat vsade len XAutoComplete a upustit od XDropdown
99
+ var XDropdownForEntity = /** @class */ (function (_super) {
100
+ __extends(XDropdownForEntity, _super);
101
+ function XDropdownForEntity(props) {
102
+ var _this = _super.call(this, props) || this;
103
+ _this.state = {
104
+ options: []
105
+ };
106
+ _this.onChange = _this.onChange.bind(_this);
107
+ return _this;
108
+ }
109
+ XDropdownForEntity.prototype.componentDidMount = function () {
110
+ this.loadOptions();
111
+ };
112
+ XDropdownForEntity.prototype.loadOptions = function () {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var options;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0: return [4 /*yield*/, XUtils_1.XUtils.fetchRows(this.props.entity, this.props.filter, this.props.displayField)];
118
+ case 1:
119
+ options = _a.sent();
120
+ if (this.props.isNotNull === undefined || !this.props.isNotNull) {
121
+ // pridame prazdnu polozku
122
+ options.splice(0, 0, {}); // null polozka
123
+ }
124
+ this.setState({ options: options });
125
+ return [2 /*return*/];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ XDropdownForEntity.prototype.onChange = function (e) {
131
+ var value;
132
+ // specialna null polozka nema ziadne atributy
133
+ if (Object.keys(e.value).length === 0) {
134
+ value = null;
135
+ }
136
+ else {
137
+ value = e.value;
138
+ }
139
+ this.props.onChange(value);
140
+ };
141
+ XDropdownForEntity.prototype.render = function () {
142
+ // TODO - mozno by nebolo od veci pouzivat InputText ak readOnly === true (chybala by len sipka (rozbalovac)) a dalo by sa copy-paste-ovat
143
+ // propertiesy na Dropdown-e: readOnly vyseduje, disabled znemoznuje vyber polozky
144
+ return (react_1.default.createElement(dropdown_1.Dropdown, __assign({ id: this.props.id, options: this.state.options, optionLabel: this.props.displayField, value: this.props.value, onChange: this.onChange, readOnly: this.props.readOnly, disabled: this.props.readOnly }, XUtils_1.XUtils.createErrorProps(this.props.error))));
145
+ };
146
+ return XDropdownForEntity;
147
+ }(react_1.Component));
148
+ exports.XDropdownForEntity = XDropdownForEntity;
@@ -84,9 +84,10 @@ var XFieldSelector = function (props) {
84
84
  }
85
85
  finally { if (e_1) throw e_1.error; }
86
86
  }
87
+ var assocToOneList = XUtilsMetadata_1.XUtilsMetadata.getXAssocList(xEntity, ["many-to-one", "one-to-one"]);
87
88
  try {
88
- for (var _c = __values(Object.entries(xEntity.assocToOneMap)), _d = _c.next(); !_d.done; _d = _c.next()) {
89
- var _e = __read(_d.value, 2), key = _e[0], xAssoc = _e[1];
89
+ for (var assocToOneList_1 = __values(assocToOneList), assocToOneList_1_1 = assocToOneList_1.next(); !assocToOneList_1_1.done; assocToOneList_1_1 = assocToOneList_1.next()) {
90
+ var xAssoc = assocToOneList_1_1.value;
90
91
  var itemKey = keyPrefix + xAssoc.name;
91
92
  treeNodeList.push({
92
93
  key: itemKey,
@@ -99,7 +100,7 @@ var XFieldSelector = function (props) {
99
100
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
100
101
  finally {
101
102
  try {
102
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
103
+ if (assocToOneList_1_1 && !assocToOneList_1_1.done && (_b = assocToOneList_1.return)) _b.call(assocToOneList_1);
103
104
  }
104
105
  finally { if (e_2) throw e_2.error; }
105
106
  }
@@ -30,6 +30,9 @@ export declare abstract class XFormComponent<T, P extends XFormComponentProps<T>
30
30
  } | undefined;
31
31
  validateOnChange(value: any): string | undefined;
32
32
  validateNotNull(value: any): string | undefined;
33
+ /**
34
+ * @deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props (asi ako v XAutoComplete)
35
+ */
33
36
  getClassNameTooltip(): {};
34
37
  getError(): string | undefined;
35
38
  callOnChangeFromOnBlur(): void;
@@ -130,7 +130,9 @@ var XFormComponent = /** @class */ (function (_super) {
130
130
  }
131
131
  return undefined;
132
132
  };
133
- // deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props (asi ako v XAutoComplete)
133
+ /**
134
+ * @deprecated - nie je to pekne riesenie - do komponentu treba posielat error message (string) a nie props (asi ako v XAutoComplete)
135
+ */
134
136
  XFormComponent.prototype.getClassNameTooltip = function () {
135
137
  var error = this.getError();
136
138
  return error ? {
@@ -588,7 +588,7 @@ var XFormDataTable2 = /** @class */ (function (_super) {
588
588
  var filterMenuInFilterRow = thisLocal.props.filterDisplay === "row" && showFilterMenu;
589
589
  var sortableButtonInHeader = thisLocal.props.sortable;
590
590
  var filterButtonInHeader = thisLocal.props.filterDisplay === "menu";
591
- width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, filterMenuInFilterRow, childColumnProps.type, header, sortableButtonInHeader, filterButtonInHeader);
591
+ width = XUtilsMetadata_1.XUtilsMetadata.computeColumnWidth(xField, undefined, filterMenuInFilterRow, childColumnProps.type, header, sortableButtonInHeader, filterButtonInHeader);
592
592
  }
593
593
  var headerStyle = {};
594
594
  if (width !== undefined) {
@@ -1,9 +1,13 @@
1
- import { XFormBase } from "./XFormBase";
2
- import React from "react";
3
- export declare const XInputDate: (props: {
4
- form: XFormBase;
1
+ /// <reference types="react" />
2
+ import { XFormComponentProps } from "./XFormComponent";
3
+ import { XInput } from "./XInput";
4
+ export interface XInputDateProps extends XFormComponentProps<number> {
5
5
  field: string;
6
- label?: string | undefined;
7
- readOnly?: boolean | undefined;
8
- labelStyle?: React.CSSProperties | undefined;
9
- }) => JSX.Element;
6
+ }
7
+ export declare class XInputDate extends XInput<Date, XInputDateProps> {
8
+ constructor(props: XInputDateProps);
9
+ getValue(): Date | null;
10
+ onValueChange(value: Date | null): void;
11
+ onBlur(e: any): void;
12
+ render(): JSX.Element;
13
+ }