@michalrakus/x-react-web-lib 1.26.0 → 1.27.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/XAutoCompleteBase.d.ts +3 -0
- package/lib/components/XAutoCompleteBase.js +6 -4
- package/lib/components/XFormHeader.d.ts +1 -0
- package/lib/components/XFormHeader.js +1 -1
- package/lib/components/XInputDecimalBase.d.ts +1 -0
- package/lib/components/XInputDecimalBase.js +1 -1
- package/lib/components/XUtils.d.ts +3 -3
- package/lib/components/XUtils.js +9 -5
- package/lib/components/XUtilsMetadata.d.ts +8 -0
- package/lib/components/XUtilsMetadata.js +10 -6
- package/package.json +2 -2
|
@@ -26,6 +26,7 @@ export interface XAutoCompleteBaseProps {
|
|
|
26
26
|
searchBrowse?: JSX.Element;
|
|
27
27
|
valueForm?: JSX.Element;
|
|
28
28
|
idField?: string;
|
|
29
|
+
addRowEnabled: boolean;
|
|
29
30
|
onAddRow?: (inputValue: string) => void;
|
|
30
31
|
insertButtonTooltip?: string;
|
|
31
32
|
updateButtonTooltip?: string;
|
|
@@ -33,6 +34,7 @@ export interface XAutoCompleteBaseProps {
|
|
|
33
34
|
minLength?: number;
|
|
34
35
|
buttonsLayout: "splitButton" | "buttons";
|
|
35
36
|
width?: string;
|
|
37
|
+
maxWidth?: string;
|
|
36
38
|
scrollHeight?: string;
|
|
37
39
|
inputClassName?: string;
|
|
38
40
|
readOnly?: boolean;
|
|
@@ -45,6 +47,7 @@ export declare class XAutoCompleteBase extends Component<XAutoCompleteBaseProps>
|
|
|
45
47
|
static defaultProps: {
|
|
46
48
|
lazyLoadMaxRows: number;
|
|
47
49
|
splitQueryValue: boolean;
|
|
50
|
+
addRowEnabled: boolean;
|
|
48
51
|
minLength: number;
|
|
49
52
|
buttonsLayout: string;
|
|
50
53
|
scrollHeight: string;
|
|
@@ -674,16 +674,17 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
674
674
|
var readOnly = (_a = this.props.readOnly) !== null && _a !== void 0 ? _a : false;
|
|
675
675
|
var buttons;
|
|
676
676
|
if (!readOnly) {
|
|
677
|
-
|
|
677
|
+
var createInsertItem = (this.props.addRowEnabled && (this.props.valueForm !== undefined || this.props.onAddRow !== undefined));
|
|
678
|
+
if (createInsertItem || this.props.valueForm || this.props.searchBrowse) {
|
|
678
679
|
// mame searchBrowse alebo CRUD operacie, potrebujeme viac buttonov alebo SplitButton
|
|
679
680
|
var buttonItems = [];
|
|
680
|
-
if (
|
|
681
|
+
if (createInsertItem) {
|
|
681
682
|
this.createInsertItem(buttonItems);
|
|
682
683
|
}
|
|
683
684
|
if (this.props.valueForm) {
|
|
684
685
|
this.createUpdateItem(buttonItems);
|
|
685
686
|
}
|
|
686
|
-
if (this.props.searchBrowse
|
|
687
|
+
if (this.props.searchBrowse) {
|
|
687
688
|
this.createSearchItem(buttonItems);
|
|
688
689
|
}
|
|
689
690
|
this.createDropdownItem(buttonItems);
|
|
@@ -726,7 +727,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
726
727
|
// Dialog pre konkretny form:
|
|
727
728
|
// <DobrovolnikForm id={this.formDialogObjectId} object={this.formDialogInitValuesForInsert} onSaveOrCancel={this.formDialogOnSaveOrCancel}/>
|
|
728
729
|
// formgroup-inline lepi SplitButton na autocomplete a zarovna jeho vysku
|
|
729
|
-
return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width } },
|
|
730
|
+
return (react_1.default.createElement("div", { className: "x-auto-complete-base", style: { width: this.props.width, maxWidth: this.props.maxWidth } },
|
|
730
731
|
react_1.default.createElement(autocomplete_1.AutoComplete, __assign({ value: inputValue, suggestions: this.state.filteredSuggestions, completeMethod: this.completeMethod, itemTemplate: this.itemTemplate, onChange: this.onChange, onSelect: this.onSelect, onBlur: this.onBlur, minLength: this.props.minLength, scrollHeight: this.props.scrollHeight, ref: this.autoCompleteRef, readOnly: readOnly, disabled: readOnly }, XUtils_1.XUtils.createTooltipOrErrorProps(error), { inputClassName: this.props.inputClassName, showEmptyMessage: true })),
|
|
731
732
|
buttons,
|
|
732
733
|
this.props.valueForm != undefined ?
|
|
@@ -742,6 +743,7 @@ var XAutoCompleteBase = /** @class */ (function (_super) {
|
|
|
742
743
|
XAutoCompleteBase.defaultProps = {
|
|
743
744
|
lazyLoadMaxRows: 10,
|
|
744
745
|
splitQueryValue: true,
|
|
746
|
+
addRowEnabled: true,
|
|
745
747
|
minLength: 1,
|
|
746
748
|
buttonsLayout: "buttons",
|
|
747
749
|
scrollHeight: '15rem' // primereact has 200px
|
|
@@ -8,7 +8,7 @@ var react_1 = __importDefault(require("react"));
|
|
|
8
8
|
var XLocale_1 = require("./XLocale");
|
|
9
9
|
var XFormHeader = function (props) {
|
|
10
10
|
var _a;
|
|
11
|
-
return (react_1.default.createElement("div", { className: "x-form-header" }, props.label + (props.appendNewRow && ((_a = props.form) === null || _a === void 0 ? void 0 : _a.isAddRow()) ? " - " + (0, XLocale_1.xLocaleOption)('newRow') : "")));
|
|
11
|
+
return (react_1.default.createElement("div", { className: "x-form-header", style: props.style }, props.label + (props.appendNewRow && ((_a = props.form) === null || _a === void 0 ? void 0 : _a.isAddRow()) ? " - " + (0, XLocale_1.xLocaleOption)('newRow') : "")));
|
|
12
12
|
};
|
|
13
13
|
exports.XFormHeader = XFormHeader;
|
|
14
14
|
exports.XFormHeader.defaultProps = {
|
|
@@ -13,6 +13,6 @@ var XInputDecimalBase = function (props) {
|
|
|
13
13
|
props.onChange(e.value);
|
|
14
14
|
};
|
|
15
15
|
// null konvertujeme na undefined (zevraj InputNumber nechce null)
|
|
16
|
-
return (react_1.default.createElement(inputnumber_1.InputNumber, { id: props.id, value: props.value !== null ? props.value : undefined, onChange: onChange, readOnly: props.readOnly, mode: "decimal", locale: "de-DE", useGrouping: props.useGrouping, minFractionDigits: props.fractionDigits, maxFractionDigits: props.fractionDigits, min: props.min, max: props.max, size: props.size, className: props.className }));
|
|
16
|
+
return (react_1.default.createElement(inputnumber_1.InputNumber, { id: props.id, value: props.value !== null ? props.value : undefined, onChange: onChange, readOnly: props.readOnly, mode: "decimal", locale: "de-DE", useGrouping: props.useGrouping, minFractionDigits: props.fractionDigits, maxFractionDigits: props.fractionDigits, min: props.min, max: props.max, size: props.size, className: props.className, inputStyle: props.inputStyle }));
|
|
17
17
|
};
|
|
18
18
|
exports.XInputDecimalBase = XInputDecimalBase;
|
|
@@ -15,9 +15,9 @@ export declare enum OperationType {
|
|
|
15
15
|
Remove = 3
|
|
16
16
|
}
|
|
17
17
|
export declare enum XViewStatus {
|
|
18
|
-
ReadWrite =
|
|
19
|
-
ReadOnly =
|
|
20
|
-
Hidden =
|
|
18
|
+
ReadWrite = "readWrite",
|
|
19
|
+
ReadOnly = "readOnly",
|
|
20
|
+
Hidden = "hidden"
|
|
21
21
|
}
|
|
22
22
|
export type XViewStatusOrBoolean = XViewStatus | boolean;
|
|
23
23
|
export interface IPostgresInterval {
|
package/lib/components/XUtils.js
CHANGED
|
@@ -99,9 +99,9 @@ var OperationType;
|
|
|
99
99
|
})(OperationType = exports.OperationType || (exports.OperationType = {}));
|
|
100
100
|
var XViewStatus;
|
|
101
101
|
(function (XViewStatus) {
|
|
102
|
-
XViewStatus[
|
|
103
|
-
XViewStatus[
|
|
104
|
-
XViewStatus[
|
|
102
|
+
XViewStatus["ReadWrite"] = "readWrite";
|
|
103
|
+
XViewStatus["ReadOnly"] = "readOnly";
|
|
104
|
+
XViewStatus["Hidden"] = "hidden";
|
|
105
105
|
})(XViewStatus = exports.XViewStatus || (exports.XViewStatus = {}));
|
|
106
106
|
var XUtils = /** @class */ (function () {
|
|
107
107
|
function XUtils() {
|
|
@@ -652,8 +652,12 @@ var XUtils = /** @class */ (function () {
|
|
|
652
652
|
XUtils.showErrorMessage = function (message, e) {
|
|
653
653
|
var msg = message + XUtilsCommon_1.XUtilsCommon.newLine;
|
|
654
654
|
if (e instanceof XResponseError_1.XResponseError) {
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
if (e.xResponseErrorBody.exceptionName === 'XAppError') {
|
|
656
|
+
// app error from backend, we show only the error message
|
|
657
|
+
msg += e.xResponseErrorBody.message;
|
|
658
|
+
}
|
|
659
|
+
else if (e.xResponseErrorBody.exceptionName === 'OptimisticLockVersionMismatchError') {
|
|
660
|
+
// better error message for optimistic locking
|
|
657
661
|
msg += "The optimistic lock failed, someone else has changed the row during the editation. Sorry, you have to cancel the editation and start the editation again.";
|
|
658
662
|
}
|
|
659
663
|
else {
|
|
@@ -12,6 +12,14 @@ export declare class XUtilsMetadata {
|
|
|
12
12
|
max?: number;
|
|
13
13
|
size?: number;
|
|
14
14
|
};
|
|
15
|
+
static getParamsForInputNumberBase(useGrouping: boolean, scale: number | undefined, precision: number | undefined, // total number of digits (before + after decimal point (scale))
|
|
16
|
+
size: number | undefined): {
|
|
17
|
+
useGrouping: boolean;
|
|
18
|
+
fractionDigits?: number;
|
|
19
|
+
min?: number;
|
|
20
|
+
max?: number;
|
|
21
|
+
size?: number;
|
|
22
|
+
};
|
|
15
23
|
static CHAR_SIZE: number;
|
|
16
24
|
static computeColumnWidth(xField: XField, betweenFilter: XBetweenFilterProp, filterMenuInFilterRow: boolean, formColumnType: string | undefined, header: string | undefined, sortableButtonInHeader: boolean, filterButtonInHeader: boolean): string | undefined;
|
|
17
25
|
static computeColumnWidthBase(charSize?: number, paddingAndOther?: number): number | undefined;
|
|
@@ -82,12 +82,12 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
82
82
|
// docasne sem, kym nemame jednotny XInputDecimal/XInputDecimalDT
|
|
83
83
|
XUtilsMetadata.getParamsForInputNumber = function (xField) {
|
|
84
84
|
var useGrouping = true;
|
|
85
|
-
var
|
|
85
|
+
var scale = undefined;
|
|
86
86
|
var precision = undefined; // total number of digits (before + after decimal point (scale))
|
|
87
87
|
var size = undefined;
|
|
88
88
|
if (xField.type === "decimal") {
|
|
89
89
|
useGrouping = true;
|
|
90
|
-
|
|
90
|
+
scale = xField.scale;
|
|
91
91
|
precision = xField.precision;
|
|
92
92
|
if (precision !== undefined) {
|
|
93
93
|
size = precision + Math.floor(precision / 3); // approximatly for 123.456.789,12
|
|
@@ -95,7 +95,7 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
95
95
|
}
|
|
96
96
|
else if (xField.type === "number") {
|
|
97
97
|
useGrouping = false;
|
|
98
|
-
|
|
98
|
+
scale = 0;
|
|
99
99
|
precision = xField.width; // number pouziva width
|
|
100
100
|
if (precision === undefined) {
|
|
101
101
|
precision = xField.precision; // nech to aj takto zafunguje...
|
|
@@ -105,14 +105,18 @@ var XUtilsMetadata = /** @class */ (function () {
|
|
|
105
105
|
else {
|
|
106
106
|
throw "XInputDecimal: field ".concat(xField.name, " has unsupported type ").concat(xField.type, ". Supported types are decimal and number.");
|
|
107
107
|
}
|
|
108
|
+
return XUtilsMetadata.getParamsForInputNumberBase(useGrouping, scale, precision, size);
|
|
109
|
+
};
|
|
110
|
+
XUtilsMetadata.getParamsForInputNumberBase = function (useGrouping, scale, precision, // total number of digits (before + after decimal point (scale))
|
|
111
|
+
size) {
|
|
108
112
|
var min = undefined;
|
|
109
113
|
var max = undefined;
|
|
110
|
-
if (precision !== undefined &&
|
|
111
|
-
var digits = precision -
|
|
114
|
+
if (precision !== undefined && scale !== undefined) {
|
|
115
|
+
var digits = precision - scale;
|
|
112
116
|
min = -(Math.pow(10, digits) - 1);
|
|
113
117
|
max = Math.pow(10, digits) - 1;
|
|
114
118
|
}
|
|
115
|
-
return { useGrouping: useGrouping, fractionDigits:
|
|
119
|
+
return { useGrouping: useGrouping, fractionDigits: scale, min: min, max: max, size: size };
|
|
116
120
|
};
|
|
117
121
|
XUtilsMetadata.computeColumnWidth = function (xField, betweenFilter, filterMenuInFilterRow, formColumnType, header, sortableButtonInHeader, filterButtonInHeader) {
|
|
118
122
|
var width;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michalrakus/x-react-web-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"primeflex": "^3.3.1",
|
|
42
42
|
"primeicons": "^7.0.0",
|
|
43
|
-
"primereact": "~10.
|
|
43
|
+
"primereact": "~10.4.0",
|
|
44
44
|
"quill": "^1.3.7",
|
|
45
45
|
"react": "^18.2.0",
|
|
46
46
|
"react-dom": "^18.2.0",
|