@ercioko/meblotex-api 0.2.0 → 0.2.2
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/.eslintrc +6 -0
- package/.nvmrc +1 -0
- package/.prettierrc +11 -0
- package/package.json +5 -16
- package/src/api/Api.ts +140 -0
- package/src/api/Endpoint.ts +76 -0
- package/src/api/createApi.ts +116 -0
- package/src/api/error.ts +17 -0
- package/{dist/api/index.d.ts → src/api/index.ts} +1 -0
- package/src/api/status.ts +3 -0
- package/src/api/utils/getAlert.ts +75 -0
- package/src/app_types.ts +695 -0
- package/src/components/ApiHostProvider.tsx +13 -0
- package/src/components/StatusTag.tsx +83 -0
- package/src/components/Table/DataTableWrapper.tsx +28 -0
- package/src/components/Table/FloatingActions.tsx +152 -0
- package/src/components/Table/Spinner.tsx +35 -0
- package/src/components/Table/Summary.tsx +18 -0
- package/src/components/Table/Table.tsx +474 -0
- package/src/components/Table/addIndexToObject.ts +6 -0
- package/src/components/Table/areProvidedColumnsDifferent.ts +26 -0
- package/src/components/Table/clicked.js +12 -0
- package/src/components/Table/displayActions.tsx +19 -0
- package/src/components/Table/hooks/useFetchPage.tsx +83 -0
- package/src/components/Table/hooks/useGetCellRenderer.tsx +197 -0
- package/src/components/Table/hooks/useGetColumnsWithCheckbox.tsx +34 -0
- package/src/components/Table/hooks/useGetDeleteRow.tsx +37 -0
- package/src/components/Table/hooks/useGetResizeColumn.ts +33 -0
- package/src/components/Table/hooks/useGetRowCheckbox.tsx +25 -0
- package/src/components/Table/hooks/useLoadDataSource.ts +24 -0
- package/src/components/Table/hooks/usePageSize.tsx +20 -0
- package/src/components/Table/hooks/useRenderRowActions.tsx +45 -0
- package/src/components/Table/hooks/useResizeColumns.ts +61 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/providers/OrderProvider.tsx +20 -0
- package/src/components/Table/styles.ts +208 -0
- package/src/config.ts +7 -0
- package/src/db_types.ts +220 -0
- package/src/hooks/useApi.ts +43 -0
- package/src/hooks/useEndpoint.ts +35 -0
- package/src/lib/jednostkaNazwa.ts +6 -0
- package/src/lib/typDokumentuNazwa.ts +8 -0
- package/src/utils/Query.ts +30 -0
- package/src/utils/getWZNumber.ts +13 -0
- package/src/utils/getZamowienieDokumentNumber.ts +11 -0
- package/{dist/src/utils/index.js → src/utils/index.ts} +2 -2
- package/tsconfig.json +25 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/api/Api.d.ts +0 -33
- package/dist/api/Api.js +0 -152
- package/dist/api/Endpoint.d.ts +0 -13
- package/dist/api/Endpoint.js +0 -126
- package/dist/api/createApi.d.ts +0 -52
- package/dist/api/createApi.js +0 -81
- package/dist/api/error.d.ts +0 -15
- package/dist/api/error.js +0 -18
- package/dist/api/index.js +0 -34
- package/dist/api/status.d.ts +0 -3
- package/dist/api/status.js +0 -6
- package/dist/api/utils/getAlert.d.ts +0 -6
- package/dist/api/utils/getAlert.js +0 -65
- package/dist/api/utils/index.js +0 -8
- package/dist/app_types.d.ts +0 -607
- package/dist/app_types.js +0 -75
- package/dist/components/ApiHostProvider.d.ts +0 -7
- package/dist/components/ApiHostProvider.js +0 -35
- package/dist/components/StatusTag.d.ts +0 -11
- package/dist/components/StatusTag.js +0 -86
- package/dist/components/Table/DataTableWrapper.d.ts +0 -3
- package/dist/components/Table/DataTableWrapper.js +0 -44
- package/dist/components/Table/FloatingActions.d.ts +0 -14
- package/dist/components/Table/FloatingActions.js +0 -32
- package/dist/components/Table/Spinner.d.ts +0 -2
- package/dist/components/Table/Spinner.js +0 -26
- package/dist/components/Table/Summary.js +0 -16
- package/dist/components/Table/Table.d.ts +0 -28
- package/dist/components/Table/Table.js +0 -330
- package/dist/components/Table/addIndexToObject.d.ts +0 -3
- package/dist/components/Table/addIndexToObject.js +0 -17
- package/dist/components/Table/areProvidedColumnsDifferent.d.ts +0 -2
- package/dist/components/Table/areProvidedColumnsDifferent.js +0 -16
- package/dist/components/Table/clicked.js +0 -11
- package/dist/components/Table/displayActions.js +0 -11
- package/dist/components/Table/hooks/useFetchPage.d.ts +0 -18
- package/dist/components/Table/hooks/useFetchPage.js +0 -123
- package/dist/components/Table/hooks/useGetCellRenderer.d.ts +0 -25
- package/dist/components/Table/hooks/useGetCellRenderer.js +0 -166
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +0 -5
- package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -53
- package/dist/components/Table/hooks/useGetDeleteRow.d.ts +0 -9
- package/dist/components/Table/hooks/useGetDeleteRow.js +0 -74
- package/dist/components/Table/hooks/useGetResizeColumn.d.ts +0 -8
- package/dist/components/Table/hooks/useGetResizeColumn.js +0 -28
- package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +0 -5
- package/dist/components/Table/hooks/useGetRowCheckbox.js +0 -54
- package/dist/components/Table/hooks/useLoadDataSource.d.ts +0 -10
- package/dist/components/Table/hooks/useLoadDataSource.js +0 -20
- package/dist/components/Table/hooks/usePageSize.d.ts +0 -5
- package/dist/components/Table/hooks/usePageSize.js +0 -16
- package/dist/components/Table/hooks/useRenderRowActions.d.ts +0 -6
- package/dist/components/Table/hooks/useRenderRowActions.js +0 -51
- package/dist/components/Table/hooks/useResizeColumns.d.ts +0 -9
- package/dist/components/Table/hooks/useResizeColumns.js +0 -60
- package/dist/components/Table/index.d.ts +0 -1
- package/dist/components/Table/index.js +0 -8
- package/dist/components/Table/providers/OrderProvider.d.ts +0 -9
- package/dist/components/Table/providers/OrderProvider.js +0 -17
- package/dist/components/Table/styles.d.ts +0 -6
- package/dist/components/Table/styles.js +0 -37
- package/dist/components/index.js +0 -26
- package/dist/config.d.ts +0 -6
- package/dist/config.js +0 -8
- package/dist/db_types.d.ts +0 -208
- package/dist/db_types.js +0 -2
- package/dist/hooks/index.js +0 -10
- package/dist/hooks/useApi.d.ts +0 -2
- package/dist/hooks/useApi.js +0 -42
- package/dist/hooks/useEndpoint.d.ts +0 -2
- package/dist/hooks/useEndpoint.js +0 -34
- package/dist/index.js +0 -19
- package/dist/lib/index.js +0 -18
- package/dist/lib/jednostka.d.ts +0 -6
- package/dist/lib/jednostkaNazwa.d.ts +0 -6
- package/dist/lib/jednostkaNazwa.js +0 -9
- package/dist/lib/typDokumentuNazwa.d.ts +0 -6
- package/dist/lib/typDokumentuNazwa.js +0 -11
- package/dist/lib/typ_dokument.d.ts +0 -0
- package/dist/lib/typ_dokumentu.d.ts +0 -6
- package/dist/lib/unit.d.ts +0 -0
- package/dist/src/api/Api.js +0 -316
- package/dist/src/api/Endpoint.js +0 -365
- package/dist/src/api/createApi.js +0 -50
- package/dist/src/api/error.js +0 -15
- package/dist/src/api/index.js +0 -5
- package/dist/src/api/status.js +0 -3
- package/dist/src/api/utils/getAlert.js +0 -63
- package/dist/src/api/utils/index.js +0 -1
- package/dist/src/app_types.js +0 -72
- package/dist/src/components/ApiHostProvider.js +0 -11
- package/dist/src/components/StatusTag.js +0 -153
- package/dist/src/components/Table/DataTableWrapper.js +0 -115
- package/dist/src/components/Table/FloatingActions.js +0 -60
- package/dist/src/components/Table/Spinner.js +0 -40
- package/dist/src/components/Table/Summary.js +0 -16
- package/dist/src/components/Table/Table.js +0 -498
- package/dist/src/components/Table/addIndexToObject.js +0 -57
- package/dist/src/components/Table/areProvidedColumnsDifferent.js +0 -19
- package/dist/src/components/Table/clicked.js +0 -12
- package/dist/src/components/Table/displayActions.js +0 -11
- package/dist/src/components/Table/hooks/useFetchPage.js +0 -254
- package/dist/src/components/Table/hooks/useGetCellRenderer.js +0 -231
- package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -33
- package/dist/src/components/Table/hooks/useGetDeleteRow.js +0 -181
- package/dist/src/components/Table/hooks/useGetResizeColumn.js +0 -72
- package/dist/src/components/Table/hooks/useGetRowCheckbox.js +0 -55
- package/dist/src/components/Table/hooks/useLoadDataSource.js +0 -16
- package/dist/src/components/Table/hooks/usePageSize.js +0 -15
- package/dist/src/components/Table/hooks/useRenderRowActions.js +0 -50
- package/dist/src/components/Table/hooks/useResizeColumns.js +0 -70
- package/dist/src/components/Table/index.js +0 -1
- package/dist/src/components/Table/providers/OrderProvider.js +0 -65
- package/dist/src/components/Table/styles.js +0 -66
- package/dist/src/components/index.js +0 -4
- package/dist/src/config.js +0 -6
- package/dist/src/db_types.js +0 -1
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/useApi.js +0 -84
- package/dist/src/hooks/useEndpoint.js +0 -60
- package/dist/src/index.js +0 -3
- package/dist/src/lib/index.js +0 -2
- package/dist/src/lib/jednostkaNazwa.js +0 -6
- package/dist/src/lib/typDokumentuNazwa.js +0 -16
- package/dist/src/utils/Query.js +0 -73
- package/dist/src/utils/getWZNumber.js +0 -4
- package/dist/src/utils/getZamowienieDokumentNumber.js +0 -4
- package/dist/utils/AlertContext.d.ts +0 -3
- package/dist/utils/AlertContext.js +0 -3
- package/dist/utils/Query.d.ts +0 -6
- package/dist/utils/Query.js +0 -33
- package/dist/utils/geNumber.d.ts +0 -2
- package/dist/utils/getDocNumber.d.ts +0 -2
- package/dist/utils/getWZNumber.js +0 -10
- package/dist/utils/getWzNumber.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber copy.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber.d.ts +0 -2
- package/dist/utils/getZamowienieDokumentNumber.js +0 -8
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -12
- /package/{dist/api/utils/index.d.ts → src/api/utils/index.ts} +0 -0
- /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
- /package/{dist/hooks/index.d.ts → src/hooks/index.ts} +0 -0
- /package/{dist/index.d.ts → src/index.ts} +0 -0
- /package/{dist/lib/index.d.ts → src/lib/index.ts} +0 -0
|
@@ -1,498 +0,0 @@
|
|
|
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;
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|