@ercioko/meblotex-api 0.2.2 → 0.2.4
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/dist/api/Api.d.ts +33 -0
- package/dist/api/Api.js +152 -0
- package/dist/api/Endpoint.d.ts +13 -0
- package/dist/api/Endpoint.js +126 -0
- package/dist/api/createApi.d.ts +53 -0
- package/dist/api/createApi.js +82 -0
- package/dist/api/error.d.ts +15 -0
- package/dist/api/error.js +18 -0
- package/{src/api/index.ts → dist/api/index.d.ts} +0 -1
- package/dist/api/index.js +34 -0
- package/dist/api/status.d.ts +3 -0
- package/dist/api/status.js +6 -0
- package/dist/api/utils/getAlert.d.ts +6 -0
- package/dist/api/utils/getAlert.js +65 -0
- package/dist/api/utils/index.js +8 -0
- package/dist/app_types.d.ts +607 -0
- package/dist/app_types.js +75 -0
- package/dist/components/ApiHostProvider.d.ts +7 -0
- package/dist/components/ApiHostProvider.js +35 -0
- package/dist/components/StatusTag.d.ts +11 -0
- package/dist/components/StatusTag.js +86 -0
- package/dist/components/Table/DataTableWrapper.d.ts +3 -0
- package/dist/components/Table/DataTableWrapper.js +44 -0
- package/dist/components/Table/FloatingActions.d.ts +14 -0
- package/dist/components/Table/FloatingActions.js +32 -0
- package/dist/components/Table/Spinner.d.ts +2 -0
- package/dist/components/Table/Spinner.js +26 -0
- package/dist/components/Table/Table.d.ts +28 -0
- package/dist/components/Table/Table.js +330 -0
- package/dist/components/Table/addIndexToObject.d.ts +3 -0
- package/dist/components/Table/addIndexToObject.js +17 -0
- package/dist/components/Table/areProvidedColumnsDifferent.d.ts +2 -0
- package/dist/components/Table/areProvidedColumnsDifferent.js +16 -0
- package/dist/components/Table/hooks/useFetchPage.d.ts +18 -0
- package/dist/components/Table/hooks/useFetchPage.js +123 -0
- package/dist/components/Table/hooks/useGetCellRenderer.d.ts +25 -0
- package/dist/components/Table/hooks/useGetCellRenderer.js +166 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +53 -0
- package/dist/components/Table/hooks/useGetDeleteRow.d.ts +9 -0
- package/dist/components/Table/hooks/useGetDeleteRow.js +74 -0
- package/dist/components/Table/hooks/useGetResizeColumn.d.ts +8 -0
- package/dist/components/Table/hooks/useGetResizeColumn.js +28 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +5 -0
- package/dist/components/Table/hooks/useGetRowCheckbox.js +54 -0
- package/dist/components/Table/hooks/useLoadDataSource.d.ts +10 -0
- package/dist/components/Table/hooks/useLoadDataSource.js +20 -0
- package/dist/components/Table/hooks/usePageSize.d.ts +5 -0
- package/dist/components/Table/hooks/usePageSize.js +16 -0
- package/dist/components/Table/hooks/useRenderRowActions.d.ts +6 -0
- package/dist/components/Table/hooks/useRenderRowActions.js +51 -0
- package/dist/components/Table/hooks/useResizeColumns.d.ts +9 -0
- package/dist/components/Table/hooks/useResizeColumns.js +60 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +8 -0
- package/dist/components/Table/providers/OrderProvider.d.ts +9 -0
- package/dist/components/Table/providers/OrderProvider.js +17 -0
- package/dist/components/Table/styles.d.ts +6 -0
- package/dist/components/Table/styles.js +37 -0
- package/dist/components/index.js +26 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +8 -0
- package/dist/db_types.d.ts +208 -0
- package/dist/db_types.js +2 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/useApi.d.ts +2 -0
- package/dist/hooks/useApi.js +42 -0
- package/dist/hooks/useEndpoint.d.ts +2 -0
- package/dist/hooks/useEndpoint.js +34 -0
- package/dist/index.js +19 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/jednostkaNazwa.d.ts +6 -0
- package/dist/lib/jednostkaNazwa.js +9 -0
- package/dist/lib/typDokumentuNazwa.d.ts +6 -0
- package/dist/lib/typDokumentuNazwa.js +11 -0
- package/dist/src/api/Api.js +316 -0
- package/dist/src/api/Endpoint.js +365 -0
- package/dist/src/api/createApi.js +51 -0
- package/dist/src/api/error.js +15 -0
- package/dist/src/api/index.js +5 -0
- package/dist/src/api/status.js +3 -0
- package/dist/src/api/utils/getAlert.js +63 -0
- package/dist/src/api/utils/index.js +1 -0
- package/dist/src/app_types.js +72 -0
- package/dist/src/components/ApiHostProvider.js +11 -0
- package/dist/src/components/StatusTag.js +153 -0
- package/dist/src/components/Table/DataTableWrapper.js +115 -0
- package/dist/src/components/Table/FloatingActions.js +60 -0
- package/dist/src/components/Table/Spinner.js +40 -0
- package/dist/src/components/Table/Summary.js +16 -0
- package/dist/src/components/Table/Table.js +498 -0
- package/dist/src/components/Table/addIndexToObject.js +57 -0
- package/dist/src/components/Table/areProvidedColumnsDifferent.js +19 -0
- package/dist/src/components/Table/clicked.js +12 -0
- package/dist/src/components/Table/displayActions.js +11 -0
- package/dist/src/components/Table/hooks/useFetchPage.js +254 -0
- package/dist/src/components/Table/hooks/useGetCellRenderer.js +231 -0
- package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +33 -0
- package/dist/src/components/Table/hooks/useGetDeleteRow.js +181 -0
- package/dist/src/components/Table/hooks/useGetResizeColumn.js +72 -0
- package/dist/src/components/Table/hooks/useGetRowCheckbox.js +55 -0
- package/dist/src/components/Table/hooks/useLoadDataSource.js +16 -0
- package/dist/src/components/Table/hooks/usePageSize.js +15 -0
- package/dist/src/components/Table/hooks/useRenderRowActions.js +50 -0
- package/dist/src/components/Table/hooks/useResizeColumns.js +70 -0
- package/dist/src/components/Table/index.js +1 -0
- package/dist/src/components/Table/providers/OrderProvider.js +65 -0
- package/dist/src/components/Table/styles.js +66 -0
- package/dist/src/components/index.js +4 -0
- package/dist/src/config.js +6 -0
- package/dist/src/db_types.js +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/useApi.js +84 -0
- package/dist/src/hooks/useEndpoint.js +60 -0
- package/dist/src/index.js +3 -0
- package/dist/src/lib/index.js +2 -0
- package/dist/src/lib/jednostkaNazwa.js +6 -0
- package/dist/src/lib/typDokumentuNazwa.js +16 -0
- package/dist/src/utils/Query.js +73 -0
- package/dist/src/utils/getWZNumber.js +4 -0
- package/dist/src/utils/getZamowienieDokumentNumber.js +4 -0
- package/{src/utils/index.ts → dist/src/utils/index.js} +2 -2
- package/dist/utils/Query.d.ts +6 -0
- package/dist/utils/Query.js +33 -0
- package/dist/utils/getWZNumber.d.ts +2 -0
- package/dist/utils/getWZNumber.js +10 -0
- package/dist/utils/getZamowienieDokumentNumber.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber.js +8 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +12 -0
- package/package.json +3 -2
- package/.eslintrc +0 -6
- package/.nvmrc +0 -1
- package/.prettierrc +0 -11
- package/src/api/Api.ts +0 -140
- package/src/api/Endpoint.ts +0 -76
- package/src/api/createApi.ts +0 -116
- package/src/api/error.ts +0 -17
- package/src/api/status.ts +0 -3
- package/src/api/utils/getAlert.ts +0 -75
- package/src/app_types.ts +0 -695
- package/src/components/ApiHostProvider.tsx +0 -13
- package/src/components/StatusTag.tsx +0 -83
- package/src/components/Table/DataTableWrapper.tsx +0 -28
- package/src/components/Table/FloatingActions.tsx +0 -152
- package/src/components/Table/Spinner.tsx +0 -35
- package/src/components/Table/Summary.tsx +0 -18
- package/src/components/Table/Table.tsx +0 -474
- package/src/components/Table/addIndexToObject.ts +0 -6
- package/src/components/Table/areProvidedColumnsDifferent.ts +0 -26
- package/src/components/Table/clicked.js +0 -12
- package/src/components/Table/displayActions.tsx +0 -19
- package/src/components/Table/hooks/useFetchPage.tsx +0 -83
- package/src/components/Table/hooks/useGetCellRenderer.tsx +0 -197
- package/src/components/Table/hooks/useGetColumnsWithCheckbox.tsx +0 -34
- package/src/components/Table/hooks/useGetDeleteRow.tsx +0 -37
- package/src/components/Table/hooks/useGetResizeColumn.ts +0 -33
- package/src/components/Table/hooks/useGetRowCheckbox.tsx +0 -25
- package/src/components/Table/hooks/useLoadDataSource.ts +0 -24
- package/src/components/Table/hooks/usePageSize.tsx +0 -20
- package/src/components/Table/hooks/useRenderRowActions.tsx +0 -45
- package/src/components/Table/hooks/useResizeColumns.ts +0 -61
- package/src/components/Table/index.ts +0 -1
- package/src/components/Table/providers/OrderProvider.tsx +0 -20
- package/src/components/Table/styles.ts +0 -208
- package/src/config.ts +0 -7
- package/src/db_types.ts +0 -220
- package/src/hooks/useApi.ts +0 -43
- package/src/hooks/useEndpoint.ts +0 -35
- package/src/lib/jednostkaNazwa.ts +0 -6
- package/src/lib/typDokumentuNazwa.ts +0 -8
- package/src/utils/Query.ts +0 -30
- package/src/utils/getWZNumber.ts +0 -13
- package/src/utils/getZamowienieDokumentNumber.ts +0 -11
- package/tsconfig.json +0 -25
- package/tsconfig.tsbuildinfo +0 -1
- /package/{src/api/utils/index.ts → dist/api/utils/index.d.ts} +0 -0
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/hooks/index.ts → dist/hooks/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/lib/index.ts → dist/lib/index.d.ts} +0 -0
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
function _iterable_to_array(iter) {
|
|
26
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
27
|
+
}
|
|
28
|
+
function _iterable_to_array_limit(arr, i) {
|
|
29
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
|
+
if (_i == null) return;
|
|
31
|
+
var _arr = [];
|
|
32
|
+
var _n = true;
|
|
33
|
+
var _d = false;
|
|
34
|
+
var _s, _e;
|
|
35
|
+
try {
|
|
36
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
37
|
+
_arr.push(_s.value);
|
|
38
|
+
if (i && _arr.length === i) break;
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
_d = true;
|
|
42
|
+
_e = err;
|
|
43
|
+
} finally{
|
|
44
|
+
try {
|
|
45
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
46
|
+
} finally{
|
|
47
|
+
if (_d) throw _e;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return _arr;
|
|
51
|
+
}
|
|
52
|
+
function _non_iterable_rest() {
|
|
53
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
+
}
|
|
55
|
+
function _non_iterable_spread() {
|
|
56
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
+
}
|
|
58
|
+
function _object_spread(target) {
|
|
59
|
+
for(var i = 1; i < arguments.length; i++){
|
|
60
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
61
|
+
var ownKeys = Object.keys(source);
|
|
62
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
63
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
ownKeys.forEach(function(key) {
|
|
68
|
+
_define_property(target, key, source[key]);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return target;
|
|
72
|
+
}
|
|
73
|
+
function ownKeys(object, enumerableOnly) {
|
|
74
|
+
var keys = Object.keys(object);
|
|
75
|
+
if (Object.getOwnPropertySymbols) {
|
|
76
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
77
|
+
if (enumerableOnly) {
|
|
78
|
+
symbols = symbols.filter(function(sym) {
|
|
79
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
keys.push.apply(keys, symbols);
|
|
83
|
+
}
|
|
84
|
+
return keys;
|
|
85
|
+
}
|
|
86
|
+
function _object_spread_props(target, source) {
|
|
87
|
+
source = source != null ? source : {};
|
|
88
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
89
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
90
|
+
} else {
|
|
91
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
92
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
97
|
+
function _sliced_to_array(arr, i) {
|
|
98
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
|
+
}
|
|
100
|
+
function _to_consumable_array(arr) {
|
|
101
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
102
|
+
}
|
|
103
|
+
function _type_of(obj) {
|
|
104
|
+
"@swc/helpers - typeof";
|
|
105
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
106
|
+
}
|
|
107
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
108
|
+
if (!o) return;
|
|
109
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
110
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
111
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
112
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
113
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
114
|
+
}
|
|
115
|
+
import { Spin, Empty } from 'antd';
|
|
116
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
117
|
+
import { useSelector } from 'react-redux';
|
|
118
|
+
import { MultiGrid } from 'react-virtualized';
|
|
119
|
+
import config from '../../config';
|
|
120
|
+
import Spinner from './Spinner';
|
|
121
|
+
import useGetRowCheckbox from './hooks/useGetRowCheckbox';
|
|
122
|
+
import useGetCellRenderer from './hooks/useGetCellRenderer';
|
|
123
|
+
import useGetResizeColumn from './hooks/useGetResizeColumn';
|
|
124
|
+
import useRenderRowActions from './hooks/useRenderRowActions';
|
|
125
|
+
import addIndexToObject from './addIndexToObject';
|
|
126
|
+
import useGetColumnsWithCheckbox from './hooks/useGetColumnsWithCheckbox';
|
|
127
|
+
import useDeleteRow from './hooks/useGetDeleteRow';
|
|
128
|
+
import useResizeColumns from './hooks/useResizeColumns';
|
|
129
|
+
import useLoadDataSource from './hooks/useLoadDataSource';
|
|
130
|
+
import areProvidedColumnsDifferent from './areProvidedColumnsDifferent';
|
|
131
|
+
import useFetchPage from './hooks/useFetchPage';
|
|
132
|
+
import FloatingActions from './FloatingActions';
|
|
133
|
+
import DataTableWrapper from './DataTableWrapper';
|
|
134
|
+
import { DataTable, StyledTable } from './styles';
|
|
135
|
+
import { usePageSize } from './hooks/usePageSize';
|
|
136
|
+
import { OrderProvider, useOrder } from './providers/OrderProvider';
|
|
137
|
+
var ROW_SIZE = config.ROW_SIZE, ROW_SIZE_MOBILE = config.ROW_SIZE_MOBILE, MOBILE_BREAKPOINT = config.MOBILE_BREAKPOINT;
|
|
138
|
+
var getSearchBarCollapsed = function(s) {
|
|
139
|
+
return s.searchBarCollapsed;
|
|
140
|
+
};
|
|
141
|
+
export var MARGIN_FOR_SPINNER = 55;
|
|
142
|
+
function BaseTable(param) {
|
|
143
|
+
var style = param.style, providedColumns = param.columns, filters = param.filters, actions = param.actions, loadPage = param.loadPage, onDelete = param.onDelete, added = param.added, dataSource = param.dataSource, withCheckbox = param.withCheckbox, checked = param.checked, setChecked = param.setChecked, selected = param.selected, _param_loadingDataSource = param.loadingDataSource, loadingDataSource = _param_loadingDataSource === void 0 ? false : _param_loadingDataSource, floatingActions = param.floatingActions, suspend = param.suspend, pinned = param.pinned, _param_useData = param.useData, useData = _param_useData === void 0 ? useState : _param_useData, responsive = param.responsive, deleteMessage = param.deleteMessage, idKey = param.idKey;
|
|
144
|
+
var _main_current, _main_current1;
|
|
145
|
+
var order = useOrder().order;
|
|
146
|
+
var _useState = _sliced_to_array(useState(ROW_SIZE), 2), rowSize = _useState[0], setRowSize = _useState[1];
|
|
147
|
+
var main = useRef(null);
|
|
148
|
+
var table = useRef(null);
|
|
149
|
+
var grid = useRef(null);
|
|
150
|
+
var _useState1 = _sliced_to_array(useState(((_main_current = main.current) === null || _main_current === void 0 ? void 0 : _main_current.offsetWidth) || 0), 2), listWidth = _useState1[0], setListWidth = _useState1[1];
|
|
151
|
+
var _useState2 = _sliced_to_array(useState((((_main_current1 = main.current) === null || _main_current1 === void 0 ? void 0 : _main_current1.offsetHeight) || 0) - rowSize), 2), listHeight = _useState2[0], setListHeight = _useState2[1];
|
|
152
|
+
var _useState3 = _sliced_to_array(useState(), 2), hoveredRow = _useState3[0], setHoveredRow = _useState3[1]; // TODO: is it used anywhere?
|
|
153
|
+
var _useData = _sliced_to_array(useData((dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(addIndexToObject)) || undefined), 2), data = _useData[0], setData = _useData[1];
|
|
154
|
+
var _useState4 = _sliced_to_array(useState(), 2), total = _useState4[0], setTotal = _useState4[1];
|
|
155
|
+
var _useState5 = _sliced_to_array(useState(providedColumns), 2), columns = _useState5[0], setColumns = _useState5[1];
|
|
156
|
+
var _useState6 = _sliced_to_array(useState(false), 2), loading = _useState6[0], setLoading = _useState6[1];
|
|
157
|
+
var _useState7 = _sliced_to_array(useState(), 2), actionsFor = _useState7[0], setActionsFor = _useState7[1];
|
|
158
|
+
var _useState8 = _sliced_to_array(useState({
|
|
159
|
+
top: -20,
|
|
160
|
+
width: 0,
|
|
161
|
+
transition: ''
|
|
162
|
+
}), 2), actionsDimensions = _useState8[0], setActionsDimensions = _useState8[1];
|
|
163
|
+
var collapsed = useSelector(getSearchBarCollapsed);
|
|
164
|
+
var menuCollapsed = useSelector(function(state) {
|
|
165
|
+
return state.menuCollapsed;
|
|
166
|
+
});
|
|
167
|
+
useEffect(function() {
|
|
168
|
+
setLoading(loadingDataSource);
|
|
169
|
+
}, [
|
|
170
|
+
loadingDataSource
|
|
171
|
+
]);
|
|
172
|
+
var deleteRow = useDeleteRow({
|
|
173
|
+
deleteMessage: deleteMessage,
|
|
174
|
+
onDelete: onDelete,
|
|
175
|
+
setData: setData,
|
|
176
|
+
data: data
|
|
177
|
+
});
|
|
178
|
+
var resizeCol = useGetResizeColumn({
|
|
179
|
+
columns: columns,
|
|
180
|
+
setColumns: setColumns
|
|
181
|
+
});
|
|
182
|
+
var CellRenderer = useGetCellRenderer({
|
|
183
|
+
idKey: idKey,
|
|
184
|
+
columns: columns,
|
|
185
|
+
// TODO: improve
|
|
186
|
+
data: data,
|
|
187
|
+
actions: actions,
|
|
188
|
+
resizeCol: resizeCol,
|
|
189
|
+
setHoveredRow: setHoveredRow,
|
|
190
|
+
hoveredRow: hoveredRow,
|
|
191
|
+
selected: (typeof selected === "undefined" ? "undefined" : _type_of(selected)) === 'object' ? selected === null || selected === void 0 ? void 0 : selected.id : selected,
|
|
192
|
+
checked: checked
|
|
193
|
+
});
|
|
194
|
+
var RowActions = useRenderRowActions({
|
|
195
|
+
data: data,
|
|
196
|
+
actions: actions,
|
|
197
|
+
deleteRow: deleteRow
|
|
198
|
+
});
|
|
199
|
+
var getColumnsWithActions = useCallback(function(updatedColumns) {
|
|
200
|
+
var newUpdatedColumns = _to_consumable_array(updatedColumns);
|
|
201
|
+
if (newUpdatedColumns[newUpdatedColumns.length - 1].key === 'akcje') {
|
|
202
|
+
newUpdatedColumns[newUpdatedColumns.length - 1] = _object_spread_props(_object_spread({}, newUpdatedColumns[newUpdatedColumns.length - 1]), {
|
|
203
|
+
render: RowActions
|
|
204
|
+
});
|
|
205
|
+
} else if (actions.width) {
|
|
206
|
+
newUpdatedColumns.push({
|
|
207
|
+
title: 'Akcja',
|
|
208
|
+
width: actions.width,
|
|
209
|
+
key: 'akcje',
|
|
210
|
+
render: RowActions
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return newUpdatedColumns;
|
|
214
|
+
}, [
|
|
215
|
+
RowActions,
|
|
216
|
+
actions
|
|
217
|
+
]);
|
|
218
|
+
var RowCheckbox = useGetRowCheckbox({
|
|
219
|
+
checked: checked,
|
|
220
|
+
setChecked: setChecked
|
|
221
|
+
});
|
|
222
|
+
var getColumnsWithCheckbox = useGetColumnsWithCheckbox({
|
|
223
|
+
data: data,
|
|
224
|
+
checked: checked,
|
|
225
|
+
RowCheckbox: RowCheckbox
|
|
226
|
+
});
|
|
227
|
+
var addCheckboxAndActions = useCallback(function() {
|
|
228
|
+
var updatedColumns = _to_consumable_array(columns);
|
|
229
|
+
if (withCheckbox) {
|
|
230
|
+
updatedColumns = getColumnsWithCheckbox(updatedColumns);
|
|
231
|
+
}
|
|
232
|
+
if (!floatingActions && actions && actions.width) {
|
|
233
|
+
updatedColumns = getColumnsWithActions(updatedColumns);
|
|
234
|
+
}
|
|
235
|
+
if (withCheckbox || !floatingActions && actions && actions.width) {
|
|
236
|
+
// if (JSON.stringify(updatedColumns) !== JSON.stringify(columns)) {
|
|
237
|
+
setColumns(updatedColumns);
|
|
238
|
+
// }
|
|
239
|
+
}
|
|
240
|
+
}, [
|
|
241
|
+
getColumnsWithCheckbox,
|
|
242
|
+
getColumnsWithActions,
|
|
243
|
+
// columns,
|
|
244
|
+
withCheckbox,
|
|
245
|
+
actions,
|
|
246
|
+
floatingActions
|
|
247
|
+
]);
|
|
248
|
+
useEffect(function() {
|
|
249
|
+
addCheckboxAndActions();
|
|
250
|
+
}, [
|
|
251
|
+
addCheckboxAndActions,
|
|
252
|
+
checked,
|
|
253
|
+
data
|
|
254
|
+
]);
|
|
255
|
+
var resizeColumns = useResizeColumns({
|
|
256
|
+
providedColumns: providedColumns,
|
|
257
|
+
columns: columns,
|
|
258
|
+
main: main,
|
|
259
|
+
floatingActions: floatingActions,
|
|
260
|
+
actions: actions,
|
|
261
|
+
setColumns: setColumns,
|
|
262
|
+
grid: grid
|
|
263
|
+
});
|
|
264
|
+
useEffect(function() {
|
|
265
|
+
resizeColumns();
|
|
266
|
+
}, [
|
|
267
|
+
resizeColumns,
|
|
268
|
+
columns,
|
|
269
|
+
collapsed,
|
|
270
|
+
menuCollapsed,
|
|
271
|
+
listWidth,
|
|
272
|
+
listHeight
|
|
273
|
+
]);
|
|
274
|
+
useEffect(function() {
|
|
275
|
+
var _main_current;
|
|
276
|
+
setListHeight(((_main_current = main.current) === null || _main_current === void 0 ? void 0 : _main_current.offsetHeight) || 0 - rowSize);
|
|
277
|
+
}, [
|
|
278
|
+
collapsed
|
|
279
|
+
]);
|
|
280
|
+
var pageSize = usePageSize({
|
|
281
|
+
mainRef: main,
|
|
282
|
+
rowSize: rowSize
|
|
283
|
+
});
|
|
284
|
+
var handleResize = useCallback(function() {
|
|
285
|
+
if (main.current) {
|
|
286
|
+
if (responsive) {
|
|
287
|
+
setRowSize(main.current.offsetWidth < MOBILE_BREAKPOINT ? ROW_SIZE_MOBILE : ROW_SIZE);
|
|
288
|
+
}
|
|
289
|
+
setListWidth(main.current.offsetWidth);
|
|
290
|
+
setListHeight(main.current.offsetHeight - rowSize);
|
|
291
|
+
}
|
|
292
|
+
}, [
|
|
293
|
+
main
|
|
294
|
+
]);
|
|
295
|
+
useEffect(function() {
|
|
296
|
+
handleResize();
|
|
297
|
+
}, [
|
|
298
|
+
handleResize,
|
|
299
|
+
menuCollapsed
|
|
300
|
+
]);
|
|
301
|
+
useEffect(function() {
|
|
302
|
+
if (main.current) {
|
|
303
|
+
if (responsive) {
|
|
304
|
+
setRowSize(main.current.offsetWidth < MOBILE_BREAKPOINT ? ROW_SIZE_MOBILE : ROW_SIZE);
|
|
305
|
+
}
|
|
306
|
+
setListWidth(main.current.offsetWidth);
|
|
307
|
+
setListHeight(main.current.offsetHeight - rowSize);
|
|
308
|
+
}
|
|
309
|
+
window.removeEventListener('resize', handleResize);
|
|
310
|
+
window.addEventListener('resize', handleResize);
|
|
311
|
+
return function() {
|
|
312
|
+
return window.removeEventListener('resize', handleResize);
|
|
313
|
+
};
|
|
314
|
+
}, [
|
|
315
|
+
handleResize
|
|
316
|
+
]);
|
|
317
|
+
useEffect(function() {
|
|
318
|
+
if (areProvidedColumnsDifferent(providedColumns, columns)) {
|
|
319
|
+
setColumns(providedColumns);
|
|
320
|
+
}
|
|
321
|
+
}, [
|
|
322
|
+
providedColumns,
|
|
323
|
+
columns
|
|
324
|
+
]);
|
|
325
|
+
var floatingButtons = useMemo(function() {
|
|
326
|
+
if (actions) {
|
|
327
|
+
return _to_consumable_array(actions.floatingOnly || []).concat(_to_consumable_array(actions.buttons || []));
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}, [
|
|
331
|
+
actions
|
|
332
|
+
]);
|
|
333
|
+
var fetchPage = useFetchPage({
|
|
334
|
+
suspend: suspend,
|
|
335
|
+
setLoading: setLoading,
|
|
336
|
+
pageSize: pageSize,
|
|
337
|
+
loadPage: loadPage,
|
|
338
|
+
filters: filters,
|
|
339
|
+
// TODO: improve
|
|
340
|
+
data: data,
|
|
341
|
+
pinned: pinned,
|
|
342
|
+
setData: setData,
|
|
343
|
+
setTotal: setTotal
|
|
344
|
+
});
|
|
345
|
+
useLoadDataSource({
|
|
346
|
+
filters: filters,
|
|
347
|
+
added: added,
|
|
348
|
+
data: data,
|
|
349
|
+
dataSource: dataSource,
|
|
350
|
+
setData: setData,
|
|
351
|
+
fetchPage: fetchPage,
|
|
352
|
+
pageSize: pageSize,
|
|
353
|
+
loadPage: loadPage
|
|
354
|
+
});
|
|
355
|
+
var hide = useCallback(function(e) {
|
|
356
|
+
if (!actionsFor) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (e) {
|
|
360
|
+
e.stopPropagation();
|
|
361
|
+
}
|
|
362
|
+
setActionsFor(undefined);
|
|
363
|
+
setActionsDimensions(_object_spread_props(_object_spread({}, actionsDimensions), {
|
|
364
|
+
width: 0,
|
|
365
|
+
transition: ''
|
|
366
|
+
}));
|
|
367
|
+
}, [
|
|
368
|
+
actionsFor,
|
|
369
|
+
actionsDimensions
|
|
370
|
+
]);
|
|
371
|
+
var scrolled = useCallback(function(param) {
|
|
372
|
+
var scrollTop = param.scrollTop, clientHeight = param.clientHeight;
|
|
373
|
+
if (actionsFor) {
|
|
374
|
+
hide();
|
|
375
|
+
}
|
|
376
|
+
if (dataSource !== undefined || loading || data.length === total) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
var page = Math.ceil((data.length - ((pinned === null || pinned === void 0 ? void 0 : pinned.length) || 0)) / pageSize());
|
|
380
|
+
if (scrollTop < clientHeight * (page - 1)) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
fetchPage(page);
|
|
384
|
+
}, [
|
|
385
|
+
fetchPage,
|
|
386
|
+
actionsFor,
|
|
387
|
+
dataSource,
|
|
388
|
+
data,
|
|
389
|
+
loading,
|
|
390
|
+
total,
|
|
391
|
+
pageSize,
|
|
392
|
+
hide,
|
|
393
|
+
pinned === null || pinned === void 0 ? void 0 : pinned.length
|
|
394
|
+
]);
|
|
395
|
+
useEffect(function() {
|
|
396
|
+
if (loadPage !== undefined) {
|
|
397
|
+
fetchPage(0);
|
|
398
|
+
}
|
|
399
|
+
}, [
|
|
400
|
+
order
|
|
401
|
+
]);
|
|
402
|
+
useEffect(function() {
|
|
403
|
+
window.addEventListener('click', hide);
|
|
404
|
+
return function() {
|
|
405
|
+
return window.removeEventListener('click', hide);
|
|
406
|
+
};
|
|
407
|
+
}, [
|
|
408
|
+
hide,
|
|
409
|
+
actionsFor,
|
|
410
|
+
actionsDimensions
|
|
411
|
+
]);
|
|
412
|
+
var actionHover = useCallback(function() {
|
|
413
|
+
if (Array.isArray(floatingButtons)) {
|
|
414
|
+
setActionsDimensions(_object_spread_props(_object_spread({}, actionsDimensions), {
|
|
415
|
+
width: floatingButtons.length * 24 + (floatingButtons.length - 1) * 28 + (actions.delete ? 53 : 0) + 98 + (actions.additionalWidth || 0),
|
|
416
|
+
transition: 'width 150ms ease-in-out'
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
}, [
|
|
420
|
+
actionsDimensions,
|
|
421
|
+
floatingButtons,
|
|
422
|
+
actions
|
|
423
|
+
]);
|
|
424
|
+
var actionLeave = useCallback(function() {
|
|
425
|
+
if (Array.isArray(floatingButtons) && actionsFor) {
|
|
426
|
+
setActionsDimensions(_object_spread_props(_object_spread({}, actionsDimensions), {
|
|
427
|
+
width: floatingButtons.length * 24 + (floatingButtons.length - 1) * 28 + (actions.delete ? 53 : 0) + 74
|
|
428
|
+
}));
|
|
429
|
+
}
|
|
430
|
+
}, [
|
|
431
|
+
actionsFor,
|
|
432
|
+
actionsDimensions,
|
|
433
|
+
floatingButtons,
|
|
434
|
+
actions
|
|
435
|
+
]);
|
|
436
|
+
var isVisibleCellRenderer = useCallback(function(param) {
|
|
437
|
+
var columnIndex = param.columnIndex, key = param.key, rowIndex = param.rowIndex, cellStyle = param.style, isVisible = param.isVisible, isScrolling = param.isScrolling;
|
|
438
|
+
if (isVisible) {
|
|
439
|
+
return /*#__PURE__*/ React.createElement(CellRenderer, {
|
|
440
|
+
isVisible: isVisible,
|
|
441
|
+
columnIndex: columnIndex,
|
|
442
|
+
key: key,
|
|
443
|
+
rowKey: key,
|
|
444
|
+
rowIndex: rowIndex,
|
|
445
|
+
isScrolling: isScrolling,
|
|
446
|
+
style: cellStyle
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return null;
|
|
450
|
+
}, [
|
|
451
|
+
CellRenderer
|
|
452
|
+
]);
|
|
453
|
+
return /*#__PURE__*/ React.createElement(DataTable, {
|
|
454
|
+
style: style,
|
|
455
|
+
className: "data-table",
|
|
456
|
+
ref: main
|
|
457
|
+
}, ((actions === null || actions === void 0 ? void 0 : actions.both) || floatingActions) && actions ? /*#__PURE__*/ React.createElement(FloatingActions, {
|
|
458
|
+
actionsDimensions: actionsDimensions,
|
|
459
|
+
actionsFor: actionsFor,
|
|
460
|
+
floatingButtons: floatingButtons,
|
|
461
|
+
actionHover: actionHover,
|
|
462
|
+
actionLeave: actionLeave,
|
|
463
|
+
hide: hide,
|
|
464
|
+
actions: actions
|
|
465
|
+
}) : undefined, /*#__PURE__*/ React.createElement(DataTableWrapper, null, /*#__PURE__*/ React.createElement(StyledTable, {
|
|
466
|
+
className: "table",
|
|
467
|
+
ref: table
|
|
468
|
+
}, data && /*#__PURE__*/ React.createElement(MultiGrid, {
|
|
469
|
+
cellRenderer: isVisibleCellRenderer,
|
|
470
|
+
height: listHeight,
|
|
471
|
+
width: listWidth,
|
|
472
|
+
columnWidth: function(param) {
|
|
473
|
+
var index = param.index;
|
|
474
|
+
return columns[index].width;
|
|
475
|
+
},
|
|
476
|
+
rowHeight: rowSize,
|
|
477
|
+
fixedRowCount: 1,
|
|
478
|
+
columnCount: columns.length,
|
|
479
|
+
rowCount: data.length + 1,
|
|
480
|
+
overscanRowCount: 22,
|
|
481
|
+
styleBottomLeftGrid: {
|
|
482
|
+
outline: 'none'
|
|
483
|
+
},
|
|
484
|
+
styleBottomRightGrid: {
|
|
485
|
+
outline: 'none'
|
|
486
|
+
},
|
|
487
|
+
onScroll: scrolled,
|
|
488
|
+
ref: grid
|
|
489
|
+
})), data && loading ? /*#__PURE__*/ React.createElement(Spinner, null) : undefined), !data ? /*#__PURE__*/ React.createElement("div", {
|
|
490
|
+
className: "data-table-no-data"
|
|
491
|
+
}, loading ? /*#__PURE__*/ React.createElement(Spin, null) : /*#__PURE__*/ React.createElement(Empty, {
|
|
492
|
+
description: "Brak danych"
|
|
493
|
+
})) : undefined);
|
|
494
|
+
}
|
|
495
|
+
function Table(props) {
|
|
496
|
+
return /*#__PURE__*/ React.createElement(OrderProvider, null, /*#__PURE__*/ React.createElement(BaseTable, props));
|
|
497
|
+
}
|
|
498
|
+
export default Table;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
export default function addIndexToObject(e, i) {
|
|
54
|
+
return _object_spread_props(_object_spread({}, e), {
|
|
55
|
+
index: i + 1
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function areProvidedColumnsDifferent(providedColumns, currentColumns) {
|
|
2
|
+
var providedKeys = providedColumns.map(function(c) {
|
|
3
|
+
return String(c.key).toLowerCase();
|
|
4
|
+
});
|
|
5
|
+
var currentKeys = currentColumns.map(function(c) {
|
|
6
|
+
return String(c.key).toLowerCase();
|
|
7
|
+
});
|
|
8
|
+
var currentHasActions = currentKeys.includes('akcje');
|
|
9
|
+
var providedHasActions = providedKeys.includes('akcje');
|
|
10
|
+
var currentHasCheckbox = currentKeys.includes('checkbox');
|
|
11
|
+
var providedHasCheckbox = providedKeys.includes('checkbox');
|
|
12
|
+
var providedKeysWithAdditional = providedKeys.concat(currentHasActions && !providedHasActions ? [
|
|
13
|
+
'akcje'
|
|
14
|
+
] : []);
|
|
15
|
+
if (currentHasCheckbox && !providedHasCheckbox) {
|
|
16
|
+
providedKeysWithAdditional.unshift('checkbox');
|
|
17
|
+
}
|
|
18
|
+
return JSON.stringify(providedKeysWithAdditional) !== JSON.stringify(currentKeys);
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { displayActions } from './displayActions';
|
|
2
|
+
var clicked = function(e, row, type) {
|
|
3
|
+
if (type === 0) {
|
|
4
|
+
// Left-click
|
|
5
|
+
if (actionsFor) hide();
|
|
6
|
+
else if (withCheckbox) onChecked(row, checked.indexOf(row) === -1);
|
|
7
|
+
} else if (type === 1) {
|
|
8
|
+
var _actions;
|
|
9
|
+
// Right-click
|
|
10
|
+
if (((_actions = actions) === null || _actions === void 0 ? void 0 : _actions.both) || floatingActions) displayActions(e, row);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// TODO: remove?
|
|
2
|
+
import { ROW_SIZE } from './index';
|
|
3
|
+
export default function displayActions(e, row) {
|
|
4
|
+
if (actionsFor) e.stopPropagation();
|
|
5
|
+
setActionsFor(row);
|
|
6
|
+
setActionsDimensions({
|
|
7
|
+
top: (data ? (ROW_SIZE + 1) * data.indexOf(row) - 50 : -50) - wrapper.current.scrollTop,
|
|
8
|
+
width: floatingButtons.length * 24 + (floatingButtons.length - 1) * 28 + (actions.delete ? 53 : 0) + 74,
|
|
9
|
+
transition: actionsFor ? 'top 150ms ease-in-out' : undefined
|
|
10
|
+
});
|
|
11
|
+
}
|