@michalrakus/x-react-web-lib 1.32.5 → 1.32.7
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/gulpfile.js +1 -0
- package/lib/components/XEditorBase.js +49 -1
- package/lib/components/XLazyDataTable/XLazyDataTable.d.ts +11 -0
- package/lib/components/XLazyDataTable/XLazyDataTable.js +142 -40
- package/lib/components/XLazyDataTable/XOcfDropdown.js +1 -1
- package/lib/components/XLocale.d.ts +12 -1
- package/lib/components/XUtils.d.ts +3 -0
- package/lib/components/XUtils.js +49 -0
- package/lib/components/locale/x-en.json +1 -1
- package/lib/components/useXStateSession.d.ts +2 -0
- package/lib/components/useXStateSession.js +10 -0
- package/lib/components/useXStateSessionBase.d.ts +2 -0
- package/lib/components/useXStateSessionBase.js +32 -0
- package/package.json +7 -7
- package/useXStateSession.d.ts +3 -0
- package/useXStateSession.js +5 -0
package/gulpfile.js
CHANGED
|
@@ -30,6 +30,7 @@ function generateApi(cb) {
|
|
|
30
30
|
"./lib/components/XLazyDataTable/XLazyDataTable",
|
|
31
31
|
"./lib/components/XLazyDataTable/XMultilineRenderer",
|
|
32
32
|
|
|
33
|
+
"./lib/components/useXStateSession",
|
|
33
34
|
"./lib/components/useXToken",
|
|
34
35
|
"./lib/components/XAutoComplete",
|
|
35
36
|
"./lib/components/XAutoCompleteBase",
|
|
@@ -49,11 +49,59 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
49
49
|
}
|
|
50
50
|
return ar;
|
|
51
51
|
};
|
|
52
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
53
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
|
+
};
|
|
52
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
56
|
exports.XEditorBase = void 0;
|
|
54
57
|
var react_1 = __importStar(require("react"));
|
|
55
58
|
var XUtils_1 = require("./XUtils");
|
|
56
59
|
var editor_1 = require("primereact/editor");
|
|
60
|
+
var quill_1 = __importDefault(require("quill"));
|
|
61
|
+
// bez tohto kodu size options nefunguju
|
|
62
|
+
var Size = quill_1.default.import('attributors/style/size');
|
|
63
|
+
Size.whitelist = ['10px', '12px', '14px', '16px', '18px', '24px', '32px', '48px'];
|
|
64
|
+
quill_1.default.register(Size, true);
|
|
65
|
+
var Font = quill_1.default.import('formats/font');
|
|
66
|
+
Font.whitelist = [
|
|
67
|
+
'sans-serif', 'serif', 'monospace',
|
|
68
|
+
'times-new-roman', 'comic-sans',
|
|
69
|
+
];
|
|
70
|
+
quill_1.default.register(Font, true);
|
|
71
|
+
var headerTemplate = function () {
|
|
72
|
+
// poznamka - k tomuto layout-u sa este viazu css styly umiestnene v App.css
|
|
73
|
+
var styleMarginRight = { marginRight: '0.7rem' };
|
|
74
|
+
return (react_1.default.createElement("span", { className: "ql-formats" },
|
|
75
|
+
react_1.default.createElement("select", { className: "ql-font", "aria-label": "Font" },
|
|
76
|
+
react_1.default.createElement("option", { value: "sans-serif", selected: true }, "Sans-Serif"),
|
|
77
|
+
react_1.default.createElement("option", { value: "serif" }, "Serif"),
|
|
78
|
+
react_1.default.createElement("option", { value: "monospace" }, "Monospace"),
|
|
79
|
+
react_1.default.createElement("option", { value: "times-new-roman" }, "TimesNewRoman"),
|
|
80
|
+
react_1.default.createElement("option", { value: "comic-sans" }, "Comic Sans")),
|
|
81
|
+
react_1.default.createElement("select", { className: "ql-size", "aria-label": "Font Size", style: styleMarginRight },
|
|
82
|
+
react_1.default.createElement("option", { value: "10px" }, "10"),
|
|
83
|
+
react_1.default.createElement("option", { value: "12px", selected: true }, "12"),
|
|
84
|
+
react_1.default.createElement("option", { value: "14px" }, "14"),
|
|
85
|
+
react_1.default.createElement("option", { value: "16px" }, "16"),
|
|
86
|
+
react_1.default.createElement("option", { value: "18px" }, "18"),
|
|
87
|
+
react_1.default.createElement("option", { value: "24px" }, "24"),
|
|
88
|
+
react_1.default.createElement("option", { value: "32px" }, "32"),
|
|
89
|
+
react_1.default.createElement("option", { value: "48px" }, "48")),
|
|
90
|
+
react_1.default.createElement("button", { className: "ql-bold", "aria-label": "Bold" }),
|
|
91
|
+
react_1.default.createElement("button", { className: "ql-italic", "aria-label": "Italic" }),
|
|
92
|
+
react_1.default.createElement("button", { className: "ql-underline", "aria-label": "Underline" }),
|
|
93
|
+
react_1.default.createElement("button", { className: "ql-strike", "aria-label": "Strikethrough", style: styleMarginRight }),
|
|
94
|
+
react_1.default.createElement("select", { className: "ql-color", "aria-label": "Text Color" }),
|
|
95
|
+
react_1.default.createElement("select", { className: "ql-background", "aria-label": "Background Color", style: styleMarginRight }),
|
|
96
|
+
react_1.default.createElement("select", { className: "ql-align", "aria-label": "Text Alignment", style: styleMarginRight },
|
|
97
|
+
react_1.default.createElement("option", { selected: true }),
|
|
98
|
+
react_1.default.createElement("option", { value: "center" }),
|
|
99
|
+
react_1.default.createElement("option", { value: "right" })),
|
|
100
|
+
react_1.default.createElement("button", { className: "ql-list", value: "ordered", "aria-label": "Ordered List" }),
|
|
101
|
+
react_1.default.createElement("button", { className: "ql-list", value: "bullet", "aria-label": "Bullet List" }),
|
|
102
|
+
react_1.default.createElement("button", { className: "ql-indent", value: "-1", "aria-label": "Indent to the left" }),
|
|
103
|
+
react_1.default.createElement("button", { className: "ql-indent", value: "+1", "aria-label": "Indent to the right" })));
|
|
104
|
+
};
|
|
57
105
|
// koli optimalizacii - typovany text si zapisuje do svojej stavovej premennej a onChange zavola az z onBlur
|
|
58
106
|
// pri velkych formularoch je totiz volanie zmeny stavu this.setState({object: this.state.object, errorMap: this.state.errorMap}); pomale
|
|
59
107
|
var XEditorBase = function (props) {
|
|
@@ -86,6 +134,6 @@ var XEditorBase = function (props) {
|
|
|
86
134
|
}
|
|
87
135
|
return htmlValue !== null ? htmlValue : undefined; // value v Editor nechce null, chce undefined
|
|
88
136
|
};
|
|
89
|
-
return (react_1.default.createElement(editor_1.Editor, __assign({ id: props.id, value: getValue(), onTextChange: onTextChange, onBlur: onBlur, readOnly: props.readOnly, style: props.style }, XUtils_1.XUtils.createTooltipOrErrorProps(props.error))));
|
|
137
|
+
return (react_1.default.createElement(editor_1.Editor, __assign({ id: props.id, value: getValue(), onTextChange: onTextChange, onBlur: onBlur, readOnly: props.readOnly, pt: { root: { style: props.style } } }, XUtils_1.XUtils.createTooltipOrErrorProps(props.error), { headerTemplate: headerTemplate() })));
|
|
90
138
|
};
|
|
91
139
|
exports.XEditorBase = XEditorBase;
|
|
@@ -37,8 +37,18 @@ export interface XBrowseProps {
|
|
|
37
37
|
export interface XSearchBrowseProps {
|
|
38
38
|
searchBrowseParams?: XSearchBrowseParams;
|
|
39
39
|
}
|
|
40
|
+
export declare enum XStateKeySuffix {
|
|
41
|
+
filters = "filters",
|
|
42
|
+
ftsInputValue = "fts-input-value",
|
|
43
|
+
optionalCustomFilter = "optional-custom-filter",
|
|
44
|
+
multiSortMeta = "multi-sort-meta",
|
|
45
|
+
pagingFirst = "paging-first",
|
|
46
|
+
selectedRow = "selected-row",
|
|
47
|
+
multilineSwitchValue = "multiline-switch-value"
|
|
48
|
+
}
|
|
40
49
|
export interface XLazyDataTableProps {
|
|
41
50
|
entity: string;
|
|
51
|
+
stateKey?: string;
|
|
42
52
|
label?: string;
|
|
43
53
|
dataKey?: string;
|
|
44
54
|
rowExpansionTemplate?: (row: any, options: DataTableRowExpansionTemplate) => React.ReactNode;
|
|
@@ -55,6 +65,7 @@ export interface XLazyDataTableProps {
|
|
|
55
65
|
scrollHeight: string;
|
|
56
66
|
formFooterHeight?: string;
|
|
57
67
|
shrinkWidth: boolean;
|
|
68
|
+
onResetTable?: () => void;
|
|
58
69
|
onAddRow?: () => void;
|
|
59
70
|
onEdit?: (selectedRow: any) => void;
|
|
60
71
|
removeRow?: ((selectedRow: any) => Promise<boolean>) | boolean;
|
|
@@ -106,7 +106,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
106
106
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
107
107
|
};
|
|
108
108
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
109
|
-
exports.XLazyColumn = exports.XLazyDataTable = void 0;
|
|
109
|
+
exports.XLazyColumn = exports.XLazyDataTable = exports.XStateKeySuffix = void 0;
|
|
110
110
|
var react_1 = __importStar(require("react"));
|
|
111
111
|
var datatable_1 = require("primereact/datatable");
|
|
112
112
|
var column_1 = require("primereact/column");
|
|
@@ -134,9 +134,22 @@ var XOcfDropdown_1 = require("./XOcfDropdown");
|
|
|
134
134
|
var XFieldSetBase_1 = require("../XFieldSet/XFieldSetBase");
|
|
135
135
|
var XAutoCompleteBase_1 = require("../XAutoCompleteBase");
|
|
136
136
|
var XInputTextBase_1 = require("../XInputTextBase");
|
|
137
|
+
var useXStateSession_1 = require("../useXStateSession");
|
|
138
|
+
var useXStateSessionBase_1 = require("../useXStateSessionBase");
|
|
139
|
+
var _ = __importStar(require("lodash"));
|
|
140
|
+
var XStateKeySuffix;
|
|
141
|
+
(function (XStateKeySuffix) {
|
|
142
|
+
XStateKeySuffix["filters"] = "filters";
|
|
143
|
+
XStateKeySuffix["ftsInputValue"] = "fts-input-value";
|
|
144
|
+
XStateKeySuffix["optionalCustomFilter"] = "optional-custom-filter";
|
|
145
|
+
XStateKeySuffix["multiSortMeta"] = "multi-sort-meta";
|
|
146
|
+
XStateKeySuffix["pagingFirst"] = "paging-first";
|
|
147
|
+
XStateKeySuffix["selectedRow"] = "selected-row";
|
|
148
|
+
XStateKeySuffix["multilineSwitchValue"] = "multiline-switch-value";
|
|
149
|
+
})(XStateKeySuffix = exports.XStateKeySuffix || (exports.XStateKeySuffix = {}));
|
|
137
150
|
var XLazyDataTable = function (props) {
|
|
138
151
|
var _a, _b;
|
|
139
|
-
// must be here, is used in
|
|
152
|
+
// must be here, is used in createFiltersInit()
|
|
140
153
|
var xEntity = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXEntity(props.entity);
|
|
141
154
|
var createAggregateItems = function () {
|
|
142
155
|
var e_1, _a;
|
|
@@ -160,9 +173,16 @@ var XLazyDataTable = function (props) {
|
|
|
160
173
|
}
|
|
161
174
|
return aggregateItems;
|
|
162
175
|
};
|
|
163
|
-
var
|
|
176
|
+
var overrideFilters = function (filters, filtersHigherPrio) {
|
|
177
|
+
if (filtersHigherPrio) {
|
|
178
|
+
// deep clone is needed, otherwise filter elements write into "filters" and override the values in filtersHigherPrio ("props.filters") (simple cloning "..." is not enough to create 2 instances of filter values)
|
|
179
|
+
filters = __assign(__assign({}, filters), _.cloneDeep(filtersHigherPrio)); // items from filtersHigherPrio will replace existing items in filters
|
|
180
|
+
}
|
|
181
|
+
return filters;
|
|
182
|
+
};
|
|
183
|
+
var createFiltersInit = function () {
|
|
164
184
|
var e_2, _a;
|
|
165
|
-
var
|
|
185
|
+
var filtersInit = {};
|
|
166
186
|
//let columns = dataTableEl.current.props.children; - does not work
|
|
167
187
|
var columns = props.children;
|
|
168
188
|
try {
|
|
@@ -173,7 +193,7 @@ var XLazyDataTable = function (props) {
|
|
|
173
193
|
var xField = XUtilsMetadataCommon_1.XUtilsMetadataCommon.getXFieldByPath(xEntity, field);
|
|
174
194
|
// TODO column.props.dropdownInFilter - pre "menu" by bolo fajn mat zoznam "enumov"
|
|
175
195
|
var filterMatchMode = getInitFilterMatchMode(xLazyColumn.props, xField);
|
|
176
|
-
|
|
196
|
+
filtersInit[field] = createFilterItem(props.filterDisplay, { value: null, matchMode: filterMatchMode });
|
|
177
197
|
}
|
|
178
198
|
}
|
|
179
199
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -183,7 +203,14 @@ var XLazyDataTable = function (props) {
|
|
|
183
203
|
}
|
|
184
204
|
finally { if (e_2) throw e_2.error; }
|
|
185
205
|
}
|
|
186
|
-
|
|
206
|
+
filtersInit = overrideFilters(filtersInit, props.filters);
|
|
207
|
+
if (props.searchBrowseParams !== undefined) {
|
|
208
|
+
var displayFieldFilter = props.searchBrowseParams.displayFieldFilter;
|
|
209
|
+
if (displayFieldFilter !== undefined) {
|
|
210
|
+
filtersInit[displayFieldFilter.field] = createFilterItem(props.filterDisplay, displayFieldFilter.constraint);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return filtersInit;
|
|
187
214
|
};
|
|
188
215
|
var getInitFilterMatchMode = function (xLazyColumnProps, xField) {
|
|
189
216
|
var filterMatchMode;
|
|
@@ -255,11 +282,37 @@ var XLazyDataTable = function (props) {
|
|
|
255
282
|
var createInitFtsInputValue = function () {
|
|
256
283
|
return { value: null, matchMode: "contains" };
|
|
257
284
|
};
|
|
285
|
+
/*
|
|
286
|
+
// TODO turn off/on storage
|
|
287
|
+
const saveValueIntoStorage = (stateKeySuffix: XStateKeySuffix, value: any) => {
|
|
288
|
+
XUtils.saveValueIntoStorage(`${getTableStateKey()}-${stateKeySuffix}`, value);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// TODO turn off/on storage
|
|
292
|
+
const getValueFromStorage = (stateKeySuffix: XStateKeySuffix, initValue: any): any => {
|
|
293
|
+
return XUtils.getValueFromStorage(`${getTableStateKey()}-${stateKeySuffix}`, initValue);
|
|
294
|
+
}
|
|
295
|
+
*/
|
|
296
|
+
var getStateKey = function (stateKeySuffix) {
|
|
297
|
+
var _a;
|
|
298
|
+
return "xldt-state-".concat((_a = props.stateKey) !== null && _a !== void 0 ? _a : props.entity, "-").concat(stateKeySuffix);
|
|
299
|
+
};
|
|
300
|
+
var removePagingFromStorage = function () {
|
|
301
|
+
XUtils_1.XUtils.removeValueFromStorage(getStateKey(XStateKeySuffix.pagingFirst));
|
|
302
|
+
};
|
|
258
303
|
// premenne platne pre cely component (obdoba member premennych v class-e)
|
|
259
304
|
var primeReactContext = react_1.default.useContext(api_1.PrimeReactContext); // probably does not work and deprecated PrimeReact.filterMatchModeOptions is used
|
|
260
305
|
var dataTableEl = (0, react_1.useRef)(null);
|
|
261
306
|
var customFilterItems = XUtilsCommon_1.XUtilsCommon.createCustomFilterItems(props.customFilter);
|
|
307
|
+
if (props.searchBrowseParams !== undefined) {
|
|
308
|
+
// ak mame props.searchBrowseParams.customFilterFunction, pridame filter
|
|
309
|
+
if (props.searchBrowseParams.customFilter) {
|
|
310
|
+
customFilterItems = XUtilsCommon_1.XUtilsCommon.filterAnd(customFilterItems, XUtils_1.XUtils.evalFilter(props.searchBrowseParams.customFilter));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
262
313
|
var aggregateItems = createAggregateItems();
|
|
314
|
+
// poznamka k useXStateSession - v buducnosti nahradit useXStateStorage, ktory bude mat parameter session/local/none a parameter bude riadit aky storage sa pouzije
|
|
315
|
+
// zatial vzdy ukladame do session
|
|
263
316
|
// ak mame fieldSet stlpce (stlpce ktore maju zadany fieldSetId a zobrazuju hodnoty podla fieldSet-u),
|
|
264
317
|
// tak sem nacitame mapy umoznujuce ziskanie labelov zakliknutych field-ov
|
|
265
318
|
// poznamka: uz by sa zislo mat vytvorene objekty (instancie) pre stlpce a do nich zapisovat pripadny XFieldSetMap, filter (teraz je vo "filters")
|
|
@@ -267,35 +320,34 @@ var XLazyDataTable = function (props) {
|
|
|
267
320
|
var _d = __read((0, react_1.useState)({ rowList: [], totalRecords: 0, aggregateValues: [] }), 2), value = _d[0], setValue = _d[1];
|
|
268
321
|
var _e = __read((0, react_1.useState)(undefined), 2), expandedRows = _e[0], setExpandedRows = _e[1];
|
|
269
322
|
var _f = __read((0, react_1.useState)(false), 2), loading = _f[0], setLoading = _f[1];
|
|
270
|
-
var _g = __read((0,
|
|
323
|
+
var _g = __read((0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.pagingFirst), 0), 2), first = _g[0], setFirst = _g[1];
|
|
271
324
|
var _h = __read((0, react_1.useState)(props.paginator ? props.rows : undefined), 2), rows = _h[0], setRows = _h[1];
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
filtersInit =
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (displayFieldFilter !== undefined) {
|
|
279
|
-
filtersInit[displayFieldFilter.field] = createFilterItem(props.filterDisplay, displayFieldFilter.constraint);
|
|
325
|
+
// "filters" have special initialState function different from that used in useXStateSession
|
|
326
|
+
var filtersInitialStateFunction = function () {
|
|
327
|
+
var filtersInit = XUtils_1.XUtils.getValueFromStorage(getStateKey(XStateKeySuffix.filters), null);
|
|
328
|
+
if (filtersInit != null) {
|
|
329
|
+
// we have filters from session - if we have props.filters, we always override the values from session (values from props.filters have higher priority)
|
|
330
|
+
filtersInit = overrideFilters(filtersInit, props.filters);
|
|
280
331
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
332
|
+
else {
|
|
333
|
+
// no filters in session
|
|
334
|
+
filtersInit = createFiltersInit();
|
|
284
335
|
}
|
|
285
|
-
|
|
286
|
-
|
|
336
|
+
return filtersInit;
|
|
337
|
+
};
|
|
338
|
+
var _j = __read((0, useXStateSessionBase_1.useXStateSessionBase)(getStateKey(XStateKeySuffix.filters), filtersInitialStateFunction), 2), filters = _j[0], setFilters = _j[1]; // filtrovanie na "controlled manner" (moze sa sem nainicializovat nejaka hodnota)
|
|
287
339
|
var initFtsInputValue = props.fullTextSearch ? createInitFtsInputValue() : undefined;
|
|
288
|
-
var _k = __read((0,
|
|
289
|
-
var _l = __read((0,
|
|
290
|
-
var _m = __read((_a = props.multilineSwitchValue) !== null && _a !== void 0 ? _a : (0,
|
|
291
|
-
var _o = __read((0,
|
|
292
|
-
var _p = __read((0,
|
|
340
|
+
var _k = __read((0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.ftsInputValue), initFtsInputValue), 2), ftsInputValue = _k[0], setFtsInputValue = _k[1];
|
|
341
|
+
var _l = __read((0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.optionalCustomFilter), undefined), 2), optionalCustomFilter = _l[0], setOptionalCustomFilter = _l[1];
|
|
342
|
+
var _m = __read((_a = props.multilineSwitchValue) !== null && _a !== void 0 ? _a : (0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.multilineSwitchValue), props.multilineSwitchInitValue), 2), multilineSwitchValue = _m[0], setMultilineSwitchValue = _m[1];
|
|
343
|
+
var _o = __read((0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.multiSortMeta), XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(props.sortField)), 2), multiSortMeta = _o[0], setMultiSortMeta = _o[1];
|
|
344
|
+
var _p = __read((0, useXStateSession_1.useXStateSession)(getStateKey(XStateKeySuffix.selectedRow), null), 2), selectedRow = _p[0], setSelectedRow = _p[1];
|
|
293
345
|
var _q = __read((_b = props.dataLoadedState) !== null && _b !== void 0 ? _b : (0, react_1.useState)(false), 2), dataLoaded = _q[0], setDataLoaded = _q[1]; // priznak kde si zapiseme, ci uz sme nacitali data
|
|
294
346
|
var _r = __read((0, react_1.useState)({ dialogOpened: false }), 2), exportRowsDialogState = _r[0], setExportRowsDialogState = _r[1];
|
|
295
347
|
//const [exportRowsDialogRowCount, setExportRowsDialogRowCount] = useState<number>(); // param pre dialog
|
|
296
|
-
var _s = __read((0, react_1.useState)(
|
|
297
|
-
var _t = __read((0, react_1.useState)(
|
|
298
|
-
var _u = __read((0, react_1.useState)(
|
|
348
|
+
var _s = __read((0, react_1.useState)(filters), 2), filtersAfterFiltering = _s[0], setFiltersAfterFiltering = _s[1]; // sem si odkladame stav filtra po kliknuti na button Filter (chceme exportovat presne to co vidno vyfiltrovane)
|
|
349
|
+
var _t = __read((0, react_1.useState)(ftsInputValue), 2), ftsInputValueAfterFiltering = _t[0], setFtsInputValueAfterFiltering = _t[1]; // tak isto ako filtersAfterFiltering
|
|
350
|
+
var _u = __read((0, react_1.useState)(optionalCustomFilter), 2), optionalCustomFilterAfterFiltering = _u[0], setOptionalCustomFilterAfterFiltering = _u[1]; // tak isto ako filtersAfterFiltering
|
|
299
351
|
// parameter [] zabezpeci ze sa metoda zavola len po prvom renderingu (a nie po kazdej zmene stavu (zavolani setNieco()))
|
|
300
352
|
(0, react_1.useEffect)(function () {
|
|
301
353
|
// jednoduchy sposob - nepouzivame parameter props.displayed a priznak dataLoaded
|
|
@@ -341,6 +393,7 @@ var XLazyDataTable = function (props) {
|
|
|
341
393
|
//console.log("zavolany onFilter - event.filters = " + JSON.stringify(event.filters));
|
|
342
394
|
// tymto zavolanim sa zapise znak zapisany klavesnicou do inputu filtra (ak prikaz zakomentujeme, input filtra zostane prazdny)
|
|
343
395
|
setFilters(event.filters);
|
|
396
|
+
removePagingFromStorage();
|
|
344
397
|
loadDataBaseIfAutoFilter(event.filters);
|
|
345
398
|
};
|
|
346
399
|
var onSort = function (event) {
|
|
@@ -362,16 +415,49 @@ var XLazyDataTable = function (props) {
|
|
|
362
415
|
//console.log("zavolany onClickFilter");
|
|
363
416
|
loadData();
|
|
364
417
|
};
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
418
|
+
/* povodna metoda, ktora iba vycistila filter
|
|
419
|
+
const onClickClearFilter = () => {
|
|
420
|
+
// najjednoduchsi sposob - pomeni aj pripadne nastavene matchMode hodnoty
|
|
421
|
+
let filtersInit: DataTableFilterMeta = createFiltersInit();
|
|
422
|
+
setFilters(filtersInit);
|
|
423
|
+
|
|
424
|
+
if (ftsInputValue) {
|
|
425
|
+
setFtsInputValue(createInitFtsInputValue());
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (props.optionalCustomFilters) {
|
|
429
|
+
setOptionalCustomFilter(undefined);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
*/
|
|
433
|
+
var onClickResetTable = function () {
|
|
434
|
+
// every session state variable set to init value from "props" or default value
|
|
435
|
+
// (this code corresponds to init values in useXStateSession hooks)
|
|
436
|
+
var firstLocal = 0;
|
|
437
|
+
setFirst(firstLocal);
|
|
438
|
+
var filtersLocal = createFiltersInit();
|
|
439
|
+
setFilters(filtersLocal);
|
|
440
|
+
var ftsInputValueLocal = createInitFtsInputValue();
|
|
441
|
+
setFtsInputValue(ftsInputValueLocal);
|
|
442
|
+
var optionalCustomFilterLocal = undefined;
|
|
443
|
+
setOptionalCustomFilter(optionalCustomFilterLocal);
|
|
444
|
+
setMultilineSwitchValue(props.multilineSwitchInitValue);
|
|
445
|
+
var multiSortMetaLocal = XUtilsCommon_1.XUtilsCommon.createMultiSortMeta(props.sortField);
|
|
446
|
+
setMultiSortMeta(multiSortMetaLocal);
|
|
447
|
+
setSelectedRow(null);
|
|
448
|
+
// custom operations
|
|
449
|
+
if (props.onResetTable) {
|
|
450
|
+
props.onResetTable();
|
|
451
|
+
}
|
|
452
|
+
// at least because of sort change (icon shows sorting column) we have to read data from db right now
|
|
453
|
+
var findParam = createFindParam();
|
|
454
|
+
// overwrite first, filters, ... with (potentially) new values
|
|
455
|
+
findParam.first = firstLocal;
|
|
456
|
+
findParam.filters = filtersLocal;
|
|
457
|
+
findParam.fullTextSearch = createXFullTextSearch(ftsInputValueLocal);
|
|
458
|
+
findParam.customFilterItems = createXCustomFilterItems(customFilterItems, optionalCustomFilterLocal);
|
|
459
|
+
findParam.multiSortMeta = multiSortMetaLocal;
|
|
460
|
+
loadDataBase(findParam);
|
|
375
461
|
};
|
|
376
462
|
var loadData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
463
|
return __generator(this, function (_a) {
|
|
@@ -452,6 +538,8 @@ var XLazyDataTable = function (props) {
|
|
|
452
538
|
setValue(findResult);
|
|
453
539
|
setupExpandedRows(findResult, multilineSwitchValue);
|
|
454
540
|
setLoading(false);
|
|
541
|
+
// save table state into session/local
|
|
542
|
+
//saveTableState(findParam); <- old solution, state is saved immediatelly after change of some filter field, sorting, etc.
|
|
455
543
|
// odlozime si filter hodnoty pre pripadny export - deep cloning vyzera ze netreba
|
|
456
544
|
setFiltersAfterFiltering(filters);
|
|
457
545
|
setFtsInputValueAfterFiltering(ftsInputValue ? __assign({}, ftsInputValue) : undefined);
|
|
@@ -500,6 +588,13 @@ var XLazyDataTable = function (props) {
|
|
|
500
588
|
}
|
|
501
589
|
});
|
|
502
590
|
}); };
|
|
591
|
+
/*
|
|
592
|
+
const saveTableState = (findParam: FindParam) => {
|
|
593
|
+
saveValueIntoStorage(XStateKeySuffix.filters, findParam.filters);
|
|
594
|
+
saveValueIntoStorage(XStateKeySuffix.ftsInputValue, ftsInputValue);
|
|
595
|
+
saveValueIntoStorage(XStateKeySuffix.optionalCustomFilter, optionalCustomFilter);
|
|
596
|
+
}
|
|
597
|
+
*/
|
|
503
598
|
var createXFullTextSearch = function (ftsInputValue) {
|
|
504
599
|
var xFullTextSearch = undefined; // default
|
|
505
600
|
if (ftsInputValue && ftsInputValue.value !== null) {
|
|
@@ -789,6 +884,7 @@ var XLazyDataTable = function (props) {
|
|
|
789
884
|
// neskusal som, ci treba aj toto klonovat ale pravdepodobne hej
|
|
790
885
|
var filtersCloned = __assign({}, filters);
|
|
791
886
|
setFilters(filtersCloned);
|
|
887
|
+
removePagingFromStorage();
|
|
792
888
|
loadDataBaseIfAutoFilter(filtersCloned);
|
|
793
889
|
};
|
|
794
890
|
// vseobecna specialna metodka pouzvana pri custom filtri (XLazyColumn.filterElement)
|
|
@@ -807,6 +903,9 @@ var XLazyDataTable = function (props) {
|
|
|
807
903
|
// treba klonovat, inac react nezobrazi zmenenu hodnotu
|
|
808
904
|
var filtersCloned = __assign({}, filters);
|
|
809
905
|
setFilters(filtersCloned);
|
|
906
|
+
// we had problem when page was set to e.g. 3 (more than 1), after setting some filter value that caused that only 1 page should be returned
|
|
907
|
+
// - after returning back to browse no rows were displayed (because requested page was 3) (this is quick fix)
|
|
908
|
+
removePagingFromStorage();
|
|
810
909
|
loadDataBaseIfAutoFilter(filtersCloned);
|
|
811
910
|
};
|
|
812
911
|
// vseobecna metodka - precita hodnotu z filtra (vrati napr. typ Date | null)
|
|
@@ -1256,9 +1355,12 @@ var XLazyDataTable = function (props) {
|
|
|
1256
1355
|
props.label ? react_1.default.createElement("div", { className: "x-lazy-datatable-label" }, props.label) : null,
|
|
1257
1356
|
ftsInputValue ? react_1.default.createElement(XFtsInput_1.XFtsInput, { value: ftsInputValue, onChange: function (value) { return setFtsInputValue(value); } }) : null,
|
|
1258
1357
|
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "filter", icon: isMobile ? "pi pi-search" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('filter') : undefined, onClick: onClickFilter }) : null,
|
|
1259
|
-
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "
|
|
1358
|
+
props.showFilterButtons ? react_1.default.createElement(XButton_1.XButton, { key: "resetTable", icon: isMobile ? "pi pi-ban" : undefined, label: !isMobile ? (0, XLocale_1.xLocaleOption)('resetTable') : undefined, onClick: onClickResetTable }) : null,
|
|
1260
1359
|
props.optionalCustomFilters ? react_1.default.createElement(XOcfDropdown_1.XOcfDropdown, { optionalCustomFilters: props.optionalCustomFilters, value: optionalCustomFilter, onChange: function (value) { return setOptionalCustomFilter(value); }, className: "m-1" }) : null,
|
|
1261
|
-
props.multilineSwitch ? react_1.default.createElement(XMultilineSwitch_1.XMultilineSwitch, { value: multilineSwitchValue, onChange: function (switchValue) {
|
|
1360
|
+
props.multilineSwitch ? react_1.default.createElement(XMultilineSwitch_1.XMultilineSwitch, { value: multilineSwitchValue, onChange: function (switchValue) {
|
|
1361
|
+
setMultilineSwitchValue(switchValue);
|
|
1362
|
+
setupExpandedRows(value, switchValue);
|
|
1363
|
+
}, className: "m-1" }) : null,
|
|
1262
1364
|
props.headerElementRight,
|
|
1263
1365
|
props.label && !isMobile ? react_1.default.createElement("div", { className: "x-lazy-datatable-label-right-compensation" }) : null),
|
|
1264
1366
|
react_1.default.createElement("div", { className: "flex justify-content-center" },
|
|
@@ -48,6 +48,6 @@ var XOcfDropdown = function (props) {
|
|
|
48
48
|
// polozku pridavame do kopie zoznamu, lebo inac sa nam "polozka" v props.optionalCustomFilters "mnozi"
|
|
49
49
|
var options = __spreadArray([], __read(props.optionalCustomFilters), false);
|
|
50
50
|
options.splice(0, 0, { label: "" });
|
|
51
|
-
return (react_1.default.createElement(dropdown_1.Dropdown, { options: options, optionLabel: "label", value: props.value, onChange: onChange, className: props.className }));
|
|
51
|
+
return (react_1.default.createElement(dropdown_1.Dropdown, { options: options, dataKey: "label", optionLabel: "label", value: props.value, onChange: onChange, className: props.className }));
|
|
52
52
|
};
|
|
53
53
|
exports.XOcfDropdown = XOcfDropdown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface XLocaleOptions {
|
|
2
2
|
filter?: string;
|
|
3
|
-
|
|
3
|
+
resetTable?: string;
|
|
4
4
|
addRow?: string;
|
|
5
5
|
editRow?: string;
|
|
6
6
|
removeRow?: string;
|
|
@@ -21,6 +21,17 @@ export interface XLocaleOptions {
|
|
|
21
21
|
fileUploadSizeToBig?: string;
|
|
22
22
|
fileUploadFailed?: string;
|
|
23
23
|
fileDownloadFailed?: string;
|
|
24
|
+
fieldSetSaveEditConfirm?: string;
|
|
25
|
+
fieldSetCancelEditConfirm?: string;
|
|
26
|
+
fieldSetRemoveFieldConfirm?: string;
|
|
27
|
+
runStatisticMissingDateField?: string;
|
|
28
|
+
upload?: string;
|
|
29
|
+
yes?: string;
|
|
30
|
+
no?: string;
|
|
31
|
+
dateFrom?: string;
|
|
32
|
+
dateTo?: string;
|
|
33
|
+
year?: string;
|
|
34
|
+
yearForAgeCalculation?: string;
|
|
24
35
|
}
|
|
25
36
|
export declare function xAddLocale(locale: string, xOptions: XLocaleOptions): void;
|
|
26
37
|
export declare function xLocaleOption(xOptionKey: string, options?: any[string]): any;
|
|
@@ -105,4 +105,7 @@ export declare class XUtils {
|
|
|
105
105
|
static isTableRowInserted(tableRow: any): boolean;
|
|
106
106
|
static xViewStatus(xViewStatusOrBoolean: XViewStatusOrBoolean): XViewStatus;
|
|
107
107
|
static options(valueStringList: string[]): SelectItem[];
|
|
108
|
+
static saveValueIntoStorage(key: string, value: any): void;
|
|
109
|
+
static getValueFromStorage(key: string, initValue: any): any;
|
|
110
|
+
static removeValueFromStorage(key: string): void;
|
|
108
111
|
}
|
package/lib/components/XUtils.js
CHANGED
|
@@ -700,6 +700,55 @@ var XUtils = /** @class */ (function () {
|
|
|
700
700
|
XUtils.options = function (valueStringList) {
|
|
701
701
|
return valueStringList.map(function (valueString) { return { value: valueString, label: valueString }; });
|
|
702
702
|
};
|
|
703
|
+
XUtils.saveValueIntoStorage = function (key, value) {
|
|
704
|
+
// value can be also string or null or undefined
|
|
705
|
+
// if we don't have object that can be serialised to json, we create special object
|
|
706
|
+
var valueObject;
|
|
707
|
+
if (typeof value === 'object') {
|
|
708
|
+
valueObject = value;
|
|
709
|
+
}
|
|
710
|
+
else if (value === undefined) {
|
|
711
|
+
valueObject = { _xValue: "_undefined_" };
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
// value is null or string or boolean or number or Date...
|
|
715
|
+
valueObject = { _xValue: value };
|
|
716
|
+
}
|
|
717
|
+
sessionStorage.setItem(key, XUtilsCommon_1.XUtilsCommon.objectAsJSON(valueObject));
|
|
718
|
+
};
|
|
719
|
+
XUtils.getValueFromStorage = function (key, initValue) {
|
|
720
|
+
// if the value is not found in storage, initValue is returned
|
|
721
|
+
var value;
|
|
722
|
+
var item = sessionStorage.getItem(key);
|
|
723
|
+
if (item !== null) {
|
|
724
|
+
try {
|
|
725
|
+
var valueObject = JSON.parse(item);
|
|
726
|
+
if ('_xValue' in valueObject) {
|
|
727
|
+
// we have special object with 1 value
|
|
728
|
+
value = valueObject._xValue;
|
|
729
|
+
if (value === "_undefined_") {
|
|
730
|
+
value = undefined;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
// standard object
|
|
735
|
+
value = valueObject;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
catch (e) {
|
|
739
|
+
// exception should not happen
|
|
740
|
+
console.log("XUtils.getValueFromStorage: Could not parse/process item from session. key = ".concat(key, ", item = ").concat(item, ". Error: ").concat(e));
|
|
741
|
+
value = initValue;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
value = initValue;
|
|
746
|
+
}
|
|
747
|
+
return value;
|
|
748
|
+
};
|
|
749
|
+
XUtils.removeValueFromStorage = function (key) {
|
|
750
|
+
sessionStorage.removeItem(key);
|
|
751
|
+
};
|
|
703
752
|
XUtils.dropdownEmptyOptionValue = " ";
|
|
704
753
|
XUtils.xBackendUrl = undefined;
|
|
705
754
|
// nacachovany XToken - na rozlicnych miestach potrebujeme vediet uzivatela
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useXStateSession = void 0;
|
|
4
|
+
var XUtils_1 = require("./XUtils");
|
|
5
|
+
var useXStateSessionBase_1 = require("./useXStateSessionBase");
|
|
6
|
+
// TODO - initialState sholud be value | function returning T, and the function should be called in function "initialStateFunction"
|
|
7
|
+
function useXStateSession(key, initialState) {
|
|
8
|
+
return (0, useXStateSessionBase_1.useXStateSessionBase)(key, function () { return XUtils_1.XUtils.getValueFromStorage(key, initialState); });
|
|
9
|
+
}
|
|
10
|
+
exports.useXStateSession = useXStateSession;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.useXStateSessionBase = void 0;
|
|
20
|
+
var react_1 = require("react");
|
|
21
|
+
var XUtils_1 = require("./XUtils");
|
|
22
|
+
// this base version enables to use custom version of function that computes initialState
|
|
23
|
+
// (in usual case useXStateSession shoud be used)
|
|
24
|
+
function useXStateSessionBase(key, initialStateFunction) {
|
|
25
|
+
var _a = __read((0, react_1.useState)(initialStateFunction), 2), value = _a[0], setValue = _a[1];
|
|
26
|
+
var setValueIntoSession = function (value) {
|
|
27
|
+
setValue(value);
|
|
28
|
+
XUtils_1.XUtils.saveValueIntoStorage(key, value);
|
|
29
|
+
};
|
|
30
|
+
return [value, setValueIntoSession];
|
|
31
|
+
}
|
|
32
|
+
exports.useXStateSessionBase = useXStateSessionBase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michalrakus/x-react-web-lib",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@types/jest": "^29.5.0",
|
|
31
31
|
"@types/lodash": "^4.14.202",
|
|
32
32
|
"@types/node": "^18.15.3",
|
|
33
|
-
"@types/react": "^18.
|
|
34
|
-
"@types/react-dom": "^18.
|
|
33
|
+
"@types/react": "^18.3.1",
|
|
34
|
+
"@types/react-dom": "^18.3.1",
|
|
35
35
|
"@types/react-transition-group": "^4.4.5",
|
|
36
36
|
"gulp": "^4.0.2",
|
|
37
37
|
"rimraf": "^4.4.0",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"primeflex": "^3.3.1",
|
|
42
42
|
"primeicons": "^7.0.0",
|
|
43
|
-
"primereact": "
|
|
44
|
-
"quill": "^2.0.
|
|
45
|
-
"react": "^18.
|
|
46
|
-
"react-dom": "^18.
|
|
43
|
+
"primereact": "10.9.2",
|
|
44
|
+
"quill": "^2.0.3",
|
|
45
|
+
"react": "^18.3.1",
|
|
46
|
+
"react-dom": "^18.3.1",
|
|
47
47
|
"react-transition-group": "^4.4.5"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|