@michalrakus/x-react-web-lib 1.30.0 → 1.31.1
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/lib/components/XFieldSet/XFieldSetBase.d.ts +1 -1
- package/lib/components/XFieldSet/XFieldSetBase.js +14 -5
- package/lib/components/XFormBase.d.ts +3 -1
- package/lib/components/XFormBase.js +10 -1
- package/lib/components/XFormComponentDT.d.ts +8 -1
- package/lib/components/XFormComponentDT.js +19 -0
- package/lib/components/XInputDT.d.ts +2 -0
- package/lib/components/XInputDate.js +0 -1
- package/lib/components/XInputTextarea.d.ts +2 -0
- package/lib/components/XInputTextarea.js +8 -1
- package/lib/components/XInputTextareaBase.d.ts +26 -13
- package/lib/components/XInputTextareaBase.js +53 -38
- package/lib/components/locale/x-en.json +1 -0
- package/lib/serverApi/XUtilsConversions.d.ts +1 -0
- package/lib/serverApi/XUtilsConversions.js +5 -1
- package/package.json +3 -3
|
@@ -73,7 +73,7 @@ export interface XFieldSetValues {
|
|
|
73
73
|
}
|
|
74
74
|
export type XFieldXFieldMetaMap = Map<string, XFieldMeta>;
|
|
75
75
|
export declare class XFieldSetBase {
|
|
76
|
-
static createXFieldXFieldMetaMap(xFieldSetMeta: XFieldSetMeta): XFieldXFieldMetaMap;
|
|
76
|
+
static createXFieldXFieldMetaMap(xFieldSetMeta: XFieldSetMeta, filterFromParent?: string): XFieldXFieldMetaMap;
|
|
77
77
|
static xFieldSetValuesAsUI(xFieldSetValues: XFieldSetValues, xFieldXFieldMetaMap: XFieldXFieldMetaMap): string;
|
|
78
78
|
private static createMapForXFieldMeta;
|
|
79
79
|
}
|
|
@@ -64,9 +64,11 @@ var XFieldSetBase = /** @class */ (function () {
|
|
|
64
64
|
function XFieldSetBase() {
|
|
65
65
|
}
|
|
66
66
|
// api metoda na vytvorenie Map instancie, ktora sluzi na rychle najdenie prislusneho XFieldMeta podla nazvu fieldu
|
|
67
|
-
|
|
67
|
+
// ak je zadany filterFromParent, tak vracia len children/subchildren/... fieldu s field = filterFromParent
|
|
68
|
+
// (filterFromParent je casto groupField)
|
|
69
|
+
XFieldSetBase.createXFieldXFieldMetaMap = function (xFieldSetMeta, filterFromParent) {
|
|
68
70
|
var xFieldXFieldMetaMap = new Map();
|
|
69
|
-
XFieldSetBase.createMapForXFieldMeta(xFieldSetMeta.xFieldMetaRoot, xFieldXFieldMetaMap);
|
|
71
|
+
XFieldSetBase.createMapForXFieldMeta(xFieldSetMeta.xFieldMetaRoot, filterFromParent, xFieldXFieldMetaMap);
|
|
70
72
|
return xFieldXFieldMetaMap;
|
|
71
73
|
};
|
|
72
74
|
// api metoda na vyrenderovanie field set atributu
|
|
@@ -111,14 +113,21 @@ var XFieldSetBase = /** @class */ (function () {
|
|
|
111
113
|
}
|
|
112
114
|
return valueUIList.join(", ");
|
|
113
115
|
};
|
|
114
|
-
XFieldSetBase.createMapForXFieldMeta = function (xFieldMeta, xFieldXFieldMetaMap) {
|
|
116
|
+
XFieldSetBase.createMapForXFieldMeta = function (xFieldMeta, filterFromParent, xFieldXFieldMetaMap) {
|
|
115
117
|
var e_2, _a;
|
|
116
|
-
|
|
118
|
+
if (filterFromParent === undefined) {
|
|
119
|
+
// no filter is used
|
|
120
|
+
xFieldXFieldMetaMap.set(xFieldMeta.field, xFieldMeta);
|
|
121
|
+
}
|
|
122
|
+
else if (filterFromParent === xFieldMeta.field) {
|
|
123
|
+
// the searched parent field has been found, all his children/subchildren/... will be added to the list (we remove the filter)
|
|
124
|
+
filterFromParent = undefined;
|
|
125
|
+
}
|
|
117
126
|
if (xFieldMeta.xFieldMetaList) {
|
|
118
127
|
try {
|
|
119
128
|
for (var _b = __values(xFieldMeta.xFieldMetaList), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
120
129
|
var insideXFieldMeta = _c.value;
|
|
121
|
-
XFieldSetBase.createMapForXFieldMeta(insideXFieldMeta, xFieldXFieldMetaMap);
|
|
130
|
+
XFieldSetBase.createMapForXFieldMeta(insideXFieldMeta, filterFromParent, xFieldXFieldMetaMap);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
124
133
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -4,6 +4,7 @@ import { OperationType } from "./XUtils";
|
|
|
4
4
|
import { XFieldOnChange, XFormComponent } from "./XFormComponent";
|
|
5
5
|
import { XTableFieldOnChange, XFormDataTable2, XRowTechData } from "./XFormDataTable2";
|
|
6
6
|
import { XErrorMap, XErrors } from "./XErrors";
|
|
7
|
+
import { XEntity } from "../serverApi/XEntityMetadata";
|
|
7
8
|
export type XOnSaveOrCancelProp = (object: XObject | null, objectChange: OperationType) => void;
|
|
8
9
|
export interface XFormProps {
|
|
9
10
|
id?: number;
|
|
@@ -17,6 +18,7 @@ export declare function Form(entity: string): <T extends new (...args: any[]) =>
|
|
|
17
18
|
} & T;
|
|
18
19
|
export declare abstract class XFormBase extends Component<XFormProps> {
|
|
19
20
|
entity?: string;
|
|
21
|
+
xEntity: XEntity | undefined;
|
|
20
22
|
fields: Set<string>;
|
|
21
23
|
state: {
|
|
22
24
|
object: XObject | null;
|
|
@@ -34,7 +36,7 @@ export declare abstract class XFormBase extends Component<XFormProps> {
|
|
|
34
36
|
getEntity(): string;
|
|
35
37
|
getXObject(): XObject;
|
|
36
38
|
getObject(): any;
|
|
37
|
-
isAddRow():
|
|
39
|
+
isAddRow(): boolean;
|
|
38
40
|
isInDialog(): boolean;
|
|
39
41
|
onFieldChange(field: string, value: any, error?: string | undefined, onChange?: XFieldOnChange, assocObjectChange?: OperationType): void;
|
|
40
42
|
onTableFieldChange(rowData: any, field: string, value: any, error?: string | undefined, onChange?: XTableFieldOnChange, assocObjectChange?: OperationType): void;
|
|
@@ -93,6 +93,7 @@ exports.XFormBase = exports.Form = void 0;
|
|
|
93
93
|
var react_1 = require("react");
|
|
94
94
|
var XUtils_1 = require("./XUtils");
|
|
95
95
|
var XUtilsCommon_1 = require("../serverApi/XUtilsCommon");
|
|
96
|
+
var XUtilsMetadataCommon_1 = require("../serverApi/XUtilsMetadataCommon");
|
|
96
97
|
// class decorator ktory nastavuje property entity (dalo by sa to nastavovat v konstruktore ale decorator je menej ukecany)
|
|
97
98
|
// ma sa pouzivat len na triedach odvodenych od XFormBase - obmedzenie som vsak nevedel nakodit
|
|
98
99
|
// property sa nastavi az po zbehnuti konstruktora
|
|
@@ -156,6 +157,7 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
156
157
|
if (this.entity === undefined) {
|
|
157
158
|
throw "XFormBase: Property entity is not defined - use decorator @Form.";
|
|
158
159
|
}
|
|
160
|
+
this.xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(this.entity);
|
|
159
161
|
if (!(this.props.id !== undefined)) return [3 /*break*/, 2];
|
|
160
162
|
return [4 /*yield*/, XUtils_1.XUtils.fetchById(this.entity, Array.from(this.fields), this.props.id)];
|
|
161
163
|
case 1:
|
|
@@ -221,7 +223,14 @@ var XFormBase = /** @class */ (function (_super) {
|
|
|
221
223
|
return this.getXObject();
|
|
222
224
|
};
|
|
223
225
|
XFormBase.prototype.isAddRow = function () {
|
|
224
|
-
|
|
226
|
+
// povodny kod
|
|
227
|
+
//return this.props.id === undefined;
|
|
228
|
+
// aby sme mohli zmenit insert na update (napr. ak po kontrole id fieldov zistime ze zaznam existuje), tak zistujeme id-cko z this.state.object
|
|
229
|
+
var isAddRow = false; // default
|
|
230
|
+
if (this.state.object && this.xEntity) {
|
|
231
|
+
isAddRow = this.state.object[this.xEntity.idField] === undefined;
|
|
232
|
+
}
|
|
233
|
+
return isAddRow;
|
|
225
234
|
};
|
|
226
235
|
// helper method
|
|
227
236
|
XFormBase.prototype.isInDialog = function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XFormBase } from "./XFormBase";
|
|
2
|
-
import { Component } from "react";
|
|
2
|
+
import React, { Component } from "react";
|
|
3
3
|
import { OperationType } from "./XUtils";
|
|
4
4
|
import { XError } from "./XErrors";
|
|
5
5
|
import { XCustomFilter } from "../serverApi/FindParam";
|
|
@@ -10,6 +10,11 @@ export interface XFormComponentDTProps {
|
|
|
10
10
|
rowData: any;
|
|
11
11
|
readOnly?: XTableFieldReadOnlyProp;
|
|
12
12
|
onChange?: XTableFieldOnChange;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
tooltip?: string;
|
|
16
|
+
desc?: string;
|
|
17
|
+
labelStyle?: React.CSSProperties;
|
|
13
18
|
}
|
|
14
19
|
export declare abstract class XFormComponentDT<P extends XFormComponentDTProps> extends Component<P> {
|
|
15
20
|
private valueChanged;
|
|
@@ -19,6 +24,8 @@ export declare abstract class XFormComponentDT<P extends XFormComponentDTProps>
|
|
|
19
24
|
onValueChangeBase(value: any, onChange?: XTableFieldOnChange, assocObjectChange?: OperationType): void;
|
|
20
25
|
abstract isNotNull(): boolean;
|
|
21
26
|
isReadOnly(): boolean;
|
|
27
|
+
getLabel(): string | undefined;
|
|
28
|
+
getLabelStyle(): React.CSSProperties;
|
|
22
29
|
validate(): {
|
|
23
30
|
field: string;
|
|
24
31
|
xError: XError;
|
|
@@ -78,6 +78,25 @@ var XFormComponentDT = /** @class */ (function (_super) {
|
|
|
78
78
|
}
|
|
79
79
|
return readOnly;
|
|
80
80
|
};
|
|
81
|
+
// *********** label support - len pre ne-DT componenty pouzivany ************
|
|
82
|
+
// ak je label undefined, label element sa nevykresli
|
|
83
|
+
XFormComponentDT.prototype.getLabel = function () {
|
|
84
|
+
var label = this.props.label;
|
|
85
|
+
if (label !== undefined) {
|
|
86
|
+
// test na readOnly je tu hlavne koli tomu aby sme nemali * pri ID atribute, ktory sa pri inserte generuje az pri zapise do DB
|
|
87
|
+
if (this.isNotNull() && !this.isReadOnly()) {
|
|
88
|
+
label = XUtils_1.XUtils.markNotNull(label);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return label;
|
|
92
|
+
};
|
|
93
|
+
XFormComponentDT.prototype.getLabelStyle = function () {
|
|
94
|
+
var _a;
|
|
95
|
+
var labelStyle = (_a = this.props.labelStyle) !== null && _a !== void 0 ? _a : {};
|
|
96
|
+
// this.props.inline nepouzivame, lebo je to asi zombie
|
|
97
|
+
XUtils_1.XUtils.addCssPropIfNotExists(labelStyle, { width: XUtils_1.XUtils.FIELD_LABEL_WIDTH });
|
|
98
|
+
return labelStyle;
|
|
99
|
+
};
|
|
81
100
|
// *********** validation support ************
|
|
82
101
|
// volane po kliknuti na Save
|
|
83
102
|
// vrati (field, XError) ak nezbehne "field validacia", ak zbehne, vrati undefined
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { XField } from "../serverApi/XEntityMetadata";
|
|
2
2
|
import { XFormComponentDT, XFormComponentDTProps } from "./XFormComponentDT";
|
|
3
|
+
import React from "react";
|
|
3
4
|
export interface XInputDTProps extends XFormComponentDTProps {
|
|
4
5
|
field: string;
|
|
6
|
+
inputStyle?: React.CSSProperties;
|
|
5
7
|
}
|
|
6
8
|
export declare abstract class XInputDT<P extends XInputDTProps> extends XFormComponentDT<P> {
|
|
7
9
|
protected xField: XField;
|
|
@@ -40,7 +40,6 @@ var XInputDate = /** @class */ (function (_super) {
|
|
|
40
40
|
};
|
|
41
41
|
XInputDate.prototype.render = function () {
|
|
42
42
|
var _a;
|
|
43
|
-
// note: style overrides size (width of the input according to character count)
|
|
44
43
|
return (react_1.default.createElement("div", { className: "field grid" },
|
|
45
44
|
react_1.default.createElement("label", { htmlFor: this.props.field, className: "col-fixed", style: this.getLabelStyle() }, this.getLabel()),
|
|
46
45
|
react_1.default.createElement(XCalendar_1.XCalendar, { id: this.props.field, value: this.getValue(), onChange: this.onValueChange, readOnly: this.isReadOnly(), error: this.getError(), scale: (_a = this.props.scale) !== null && _a !== void 0 ? _a : this.xField.scale, datetime: this.xField.type === 'datetime' })));
|
|
@@ -12,9 +12,11 @@ export declare class XInputTextarea extends XInput<string, XInputTextareaProps>
|
|
|
12
12
|
cols: string;
|
|
13
13
|
labelOnTop: boolean;
|
|
14
14
|
};
|
|
15
|
+
xInputTextareaBaseRef: any;
|
|
15
16
|
constructor(props: XInputTextareaProps);
|
|
16
17
|
getValue(): string | null;
|
|
17
18
|
onValueChange(value: string | null): void;
|
|
18
19
|
getLabelStyle(): React.CSSProperties;
|
|
20
|
+
autoResize(): void;
|
|
19
21
|
render(): React.JSX.Element;
|
|
20
22
|
}
|
|
@@ -28,6 +28,7 @@ var XInputTextarea = /** @class */ (function (_super) {
|
|
|
28
28
|
__extends(XInputTextarea, _super);
|
|
29
29
|
function XInputTextarea(props) {
|
|
30
30
|
var _this = _super.call(this, props) || this;
|
|
31
|
+
_this.xInputTextareaBaseRef = react_1.default.createRef();
|
|
31
32
|
_this.onValueChange = _this.onValueChange.bind(_this);
|
|
32
33
|
return _this;
|
|
33
34
|
}
|
|
@@ -41,6 +42,12 @@ var XInputTextarea = /** @class */ (function (_super) {
|
|
|
41
42
|
var _a;
|
|
42
43
|
return this.props.labelOnTop ? ((_a = this.props.labelStyle) !== null && _a !== void 0 ? _a : {}) : _super.prototype.getLabelStyle.call(this);
|
|
43
44
|
};
|
|
45
|
+
// api method - can be called through "ref" from parent if needed to adjust the height of the input textarea according to the (changed) content
|
|
46
|
+
XInputTextarea.prototype.autoResize = function () {
|
|
47
|
+
if (this.xInputTextareaBaseRef.current) {
|
|
48
|
+
this.xInputTextareaBaseRef.current.autoResize();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
44
51
|
XInputTextarea.prototype.render = function () {
|
|
45
52
|
var _a, _b;
|
|
46
53
|
var fieldStyle = this.props.fieldStyle;
|
|
@@ -86,7 +93,7 @@ var XInputTextarea = /** @class */ (function (_super) {
|
|
|
86
93
|
react_1.default.createElement("label", { id: labelElemId, htmlFor: this.props.field, className: !this.props.labelOnTop ? 'col-fixed' : undefined, style: labelStyle }, this.getLabel()),
|
|
87
94
|
labelTooltip ? react_1.default.createElement(tooltip_1.Tooltip, { target: "#".concat(labelElemId), content: labelTooltip }) : null,
|
|
88
95
|
this.props.form.state.object ?
|
|
89
|
-
react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { id: this.props.field, value: value, onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: inputStyle, rows: this.props.rows, cols: cols, autoResize: this.props.autoResize, error: this.getError(), tooltip: this.props.tooltip, placeholder: (_b = this.props.placeholder) !== null && _b !== void 0 ? _b : this.props.desc })
|
|
96
|
+
react_1.default.createElement(XInputTextareaBase_1.XInputTextareaBase, { ref: this.xInputTextareaBaseRef, id: this.props.field, value: value, onChange: this.onValueChange, readOnly: this.isReadOnly(), maxLength: this.xField.length, style: inputStyle, rows: this.props.rows, cols: cols, autoResize: this.props.autoResize, error: this.getError(), tooltip: this.props.tooltip, placeholder: (_b = this.props.placeholder) !== null && _b !== void 0 ? _b : this.props.desc })
|
|
90
97
|
: null));
|
|
91
98
|
};
|
|
92
99
|
XInputTextarea.defaultProps = {
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export
|
|
3
|
-
id?: string
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
export interface XInputTextareaBaseProps {
|
|
3
|
+
id?: string;
|
|
4
4
|
value: string | null;
|
|
5
5
|
onChange: (value: string | null) => void;
|
|
6
|
-
rows?: number
|
|
7
|
-
cols?: number
|
|
8
|
-
autoResize?: boolean
|
|
9
|
-
readOnly?: boolean
|
|
10
|
-
error?: string
|
|
11
|
-
style?: React.CSSProperties
|
|
12
|
-
maxLength?: number
|
|
13
|
-
tooltip?: string
|
|
14
|
-
placeholder?: string
|
|
15
|
-
}
|
|
6
|
+
rows?: number;
|
|
7
|
+
cols?: number;
|
|
8
|
+
autoResize?: boolean;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class XInputTextareaBase extends Component<XInputTextareaBaseProps> {
|
|
17
|
+
inputTextareaRef: any;
|
|
18
|
+
state: {
|
|
19
|
+
inputChanged: boolean;
|
|
20
|
+
inputValueState: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
constructor(props: XInputTextareaBaseProps);
|
|
23
|
+
onChange(e: any): void;
|
|
24
|
+
onBlur(e: React.FocusEvent<HTMLTextAreaElement>): void;
|
|
25
|
+
getInputValue(): string;
|
|
26
|
+
autoResize(): void;
|
|
27
|
+
render(): React.JSX.Element;
|
|
28
|
+
}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __assign = (this && this.__assign) || function () {
|
|
3
18
|
__assign = Object.assign || function(t) {
|
|
4
19
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -33,59 +48,59 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
48
|
__setModuleDefault(result, mod);
|
|
34
49
|
return result;
|
|
35
50
|
};
|
|
36
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
-
if (!m) return o;
|
|
39
|
-
var i = m.call(o), r, ar = [], e;
|
|
40
|
-
try {
|
|
41
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
-
}
|
|
43
|
-
catch (error) { e = { error: error }; }
|
|
44
|
-
finally {
|
|
45
|
-
try {
|
|
46
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
-
}
|
|
48
|
-
finally { if (e) throw e.error; }
|
|
49
|
-
}
|
|
50
|
-
return ar;
|
|
51
|
-
};
|
|
52
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
52
|
exports.XInputTextareaBase = void 0;
|
|
54
53
|
var react_1 = __importStar(require("react"));
|
|
55
54
|
var XUtilsConversions_1 = require("../serverApi/XUtilsConversions");
|
|
56
55
|
var XUtils_1 = require("./XUtils");
|
|
57
56
|
var inputtextarea_1 = require("primereact/inputtextarea");
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
var XInputTextareaBase = /** @class */ (function (_super) {
|
|
58
|
+
__extends(XInputTextareaBase, _super);
|
|
59
|
+
function XInputTextareaBase(props) {
|
|
60
|
+
var _this = _super.call(this, props) || this;
|
|
61
|
+
_this.inputTextareaRef = react_1.default.createRef();
|
|
62
|
+
_this.state = {
|
|
63
|
+
inputChanged: false,
|
|
64
|
+
inputValueState: undefined
|
|
65
|
+
};
|
|
66
|
+
_this.onChange = _this.onChange.bind(_this);
|
|
67
|
+
_this.onBlur = _this.onBlur.bind(_this);
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
XInputTextareaBase.prototype.onChange = function (e) {
|
|
71
|
+
this.setState({ inputChanged: true, inputValueState: e.target.value });
|
|
69
72
|
};
|
|
70
|
-
|
|
73
|
+
XInputTextareaBase.prototype.onBlur = function (e) {
|
|
71
74
|
// optimalizacia - onChange volame len ak inputChanged === true
|
|
72
|
-
if (inputChanged) {
|
|
75
|
+
if (this.state.inputChanged) {
|
|
73
76
|
var value = (0, XUtilsConversions_1.stringFromUI)(e.target.value);
|
|
74
|
-
props.onChange(value);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
this.props.onChange(value);
|
|
78
|
+
// pre poriadok nastavujeme inputValueState na undefined
|
|
79
|
+
this.setState({ inputChanged: false, inputValueState: undefined });
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
|
-
|
|
82
|
+
XInputTextareaBase.prototype.getInputValue = function () {
|
|
80
83
|
var inputValue;
|
|
81
|
-
if (inputChanged) {
|
|
82
|
-
inputValue = inputValueState;
|
|
84
|
+
if (this.state.inputChanged) {
|
|
85
|
+
inputValue = this.state.inputValueState;
|
|
83
86
|
}
|
|
84
87
|
else {
|
|
85
|
-
inputValue = (0, XUtilsConversions_1.stringAsUI)(props.value);
|
|
88
|
+
inputValue = (0, XUtilsConversions_1.stringAsUI)(this.props.value);
|
|
86
89
|
}
|
|
87
90
|
return inputValue;
|
|
88
91
|
};
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
// call this method to autoresize textarea after setting the content of XInputTextareaBase via onChange of some other attribute (e.g. onChangeClient)
|
|
93
|
+
// must be called as callback (param) of the method XFormBase.setStateXForm
|
|
94
|
+
XInputTextareaBase.prototype.autoResize = function () {
|
|
95
|
+
// code from ChatGPT
|
|
96
|
+
if (this.inputTextareaRef.current) {
|
|
97
|
+
this.inputTextareaRef.current.style.height = 'auto'; // Reset height
|
|
98
|
+
this.inputTextareaRef.current.style.height = "".concat(this.inputTextareaRef.current.scrollHeight, "px"); // Set height based on scrollHeight
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
XInputTextareaBase.prototype.render = function () {
|
|
102
|
+
return (react_1.default.createElement(inputtextarea_1.InputTextarea, __assign({ ref: this.inputTextareaRef, id: this.props.id, value: this.getInputValue(), onChange: this.onChange, onBlur: this.onBlur, readOnly: this.props.readOnly, maxLength: this.props.maxLength, style: this.props.style, rows: this.props.rows, cols: this.props.cols, autoResize: this.props.autoResize }, XUtils_1.XUtils.createTooltipOrErrorProps(this.props.error, this.props.tooltip), { placeholder: this.props.placeholder })));
|
|
103
|
+
};
|
|
104
|
+
return XInputTextareaBase;
|
|
105
|
+
}(react_1.Component));
|
|
91
106
|
exports.XInputTextareaBase = XInputTextareaBase;
|
|
@@ -16,6 +16,7 @@ export declare function dateFromModel(value: any): Date | null;
|
|
|
16
16
|
export declare function dateFromUI(valueString: string, dateScale?: XDateScale): Date | null | undefined;
|
|
17
17
|
export declare function dateAsUI(value: Date | null, dateScale?: XDateScale): string;
|
|
18
18
|
export declare function dateAsYYYY_MM_DD(date: Date): string;
|
|
19
|
+
export declare function dateAsDB(date: Date | null): string;
|
|
19
20
|
export declare function datetimeAsUI(value: Date | null): string;
|
|
20
21
|
export declare function timeFromModel(value: any): Date | null;
|
|
21
22
|
export declare function dateFormatUI(dateScale?: XDateScale): string;
|
|
@@ -27,7 +27,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
27
27
|
return ar;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.convertValueBase = exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsYYYY_MM_DD = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.XDateScale = exports.numberFromString = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
30
|
+
exports.convertValueBase = exports.convertValue = exports.convertObject = exports.AsUIType = exports.booleanAsUIText = exports.intervalAsUI = exports.intervalFromUI = exports.datetimeFormatUI = exports.dateFormatCalendar = exports.dateFormatUI = exports.timeFromModel = exports.datetimeAsUI = exports.dateAsDB = exports.dateAsYYYY_MM_DD = exports.dateAsUI = exports.dateFromUI = exports.dateFromModel = exports.XDateScale = exports.numberFromString = exports.numberFromModel = exports.numberAsUI = exports.intFromUI = exports.stringAsDB = exports.stringAsUI = exports.stringFromUI = void 0;
|
|
31
31
|
var XUtilsCommon_1 = require("./XUtilsCommon");
|
|
32
32
|
var XLocale_1 = require("../components/XLocale");
|
|
33
33
|
var XUtilsMetadataCommon_1 = require("./XUtilsMetadataCommon");
|
|
@@ -228,6 +228,10 @@ function dateAsYYYY_MM_DD(date) {
|
|
|
228
228
|
return "".concat(date.getFullYear(), "-").concat(monthStr, "-").concat(dayStr);
|
|
229
229
|
}
|
|
230
230
|
exports.dateAsYYYY_MM_DD = dateAsYYYY_MM_DD;
|
|
231
|
+
function dateAsDB(date) {
|
|
232
|
+
return date !== null ? "'".concat(dateAsYYYY_MM_DD(date), "'::DATE") : "NULL::DATE";
|
|
233
|
+
}
|
|
234
|
+
exports.dateAsDB = dateAsDB;
|
|
231
235
|
function datetimeAsUI(value) {
|
|
232
236
|
if (value !== null) {
|
|
233
237
|
return (0, XUtilsCommon_1.dateFormat)(value, datetimeFormatUI());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michalrakus/x-react-web-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"primeflex": "^3.3.1",
|
|
42
42
|
"primeicons": "^7.0.0",
|
|
43
|
-
"primereact": "~10.
|
|
44
|
-
"quill": "^
|
|
43
|
+
"primereact": "~10.8.2",
|
|
44
|
+
"quill": "^2.0.2",
|
|
45
45
|
"react": "^18.2.0",
|
|
46
46
|
"react-dom": "^18.2.0",
|
|
47
47
|
"react-transition-group": "^4.4.5"
|