@ercioko/meblotex-api 0.1.0
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/LICENSE +21 -0
- package/dist/api/Api.d.ts +31 -0
- package/dist/api/Api.js +167 -0
- package/dist/api/Endpoint.d.ts +13 -0
- package/dist/api/Endpoint.js +125 -0
- package/dist/api/createApi.d.ts +52 -0
- package/dist/api/createApi.js +81 -0
- package/dist/api/error.d.ts +15 -0
- package/dist/api/error.js +18 -0
- package/dist/api/index.d.ts +50 -0
- package/dist/api/index.js +37 -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.d.ts +1 -0
- package/dist/api/utils/index.js +8 -0
- package/dist/app_types.d.ts +608 -0
- package/dist/app_types.js +75 -0
- package/dist/components/StatusTag.d.ts +11 -0
- package/dist/components/StatusTag.js +86 -0
- package/dist/components/Table/DataTableWrapper.d.ts +2 -0
- package/dist/components/Table/DataTableWrapper.js +44 -0
- package/dist/components/Table/FloatingActions.d.ts +15 -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/Summary.js +16 -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/clicked.js +11 -0
- package/dist/components/Table/displayActions.js +11 -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 +18 -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 +9 -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 +17 -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.d.ts +3 -0
- package/dist/components/index.js +25 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +12 -0
- package/dist/db_types.d.ts +208 -0
- package/dist/db_types.js +2 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/useApi.d.ts +2 -0
- package/dist/hooks/useApi.js +40 -0
- package/dist/hooks/useEndpoint.d.ts +2 -0
- package/dist/hooks/useEndpoint.js +32 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/jednostka.d.ts +6 -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/lib/typ_dokument.d.ts +0 -0
- package/dist/lib/typ_dokumentu.d.ts +6 -0
- package/dist/lib/unit.d.ts +0 -0
- package/dist/src/api/Api.js +313 -0
- package/dist/src/api/Endpoint.js +364 -0
- package/dist/src/api/createApi.js +50 -0
- package/dist/src/api/error.js +15 -0
- package/dist/src/api/index.js +8 -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/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 +3 -0
- package/dist/src/config.js +10 -0
- package/dist/src/db_types.js +1 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/useApi.js +82 -0
- package/dist/src/hooks/useEndpoint.js +57 -0
- package/dist/src/index.js +4 -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/dist/src/utils/index.js +3 -0
- package/dist/utils/AlertContext.d.ts +3 -0
- package/dist/utils/AlertContext.js +3 -0
- package/dist/utils/Query.d.ts +6 -0
- package/dist/utils/Query.js +33 -0
- package/dist/utils/geNumber.d.ts +2 -0
- package/dist/utils/getDocNumber.d.ts +2 -0
- package/dist/utils/getWZNumber.js +10 -0
- package/dist/utils/getWzNumber.d.ts +2 -0
- package/dist/utils/getZamowienieDokumentNumber copy.d.ts +2 -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 +60 -0
|
@@ -0,0 +1,254 @@
|
|
|
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_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array(iter) {
|
|
39
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
40
|
+
}
|
|
41
|
+
function _non_iterable_spread() {
|
|
42
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
43
|
+
}
|
|
44
|
+
function _to_consumable_array(arr) {
|
|
45
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
46
|
+
}
|
|
47
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
48
|
+
if (!o) return;
|
|
49
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
50
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
51
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
52
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
53
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
54
|
+
}
|
|
55
|
+
function _ts_generator(thisArg, body) {
|
|
56
|
+
var f, y, t, g, _ = {
|
|
57
|
+
label: 0,
|
|
58
|
+
sent: function() {
|
|
59
|
+
if (t[0] & 1) throw t[1];
|
|
60
|
+
return t[1];
|
|
61
|
+
},
|
|
62
|
+
trys: [],
|
|
63
|
+
ops: []
|
|
64
|
+
};
|
|
65
|
+
return g = {
|
|
66
|
+
next: verb(0),
|
|
67
|
+
"throw": verb(1),
|
|
68
|
+
"return": verb(2)
|
|
69
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
70
|
+
return this;
|
|
71
|
+
}), g;
|
|
72
|
+
function verb(n) {
|
|
73
|
+
return function(v) {
|
|
74
|
+
return step([
|
|
75
|
+
n,
|
|
76
|
+
v
|
|
77
|
+
]);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function step(op) {
|
|
81
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
82
|
+
while(_)try {
|
|
83
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
84
|
+
if (y = 0, t) op = [
|
|
85
|
+
op[0] & 2,
|
|
86
|
+
t.value
|
|
87
|
+
];
|
|
88
|
+
switch(op[0]){
|
|
89
|
+
case 0:
|
|
90
|
+
case 1:
|
|
91
|
+
t = op;
|
|
92
|
+
break;
|
|
93
|
+
case 4:
|
|
94
|
+
_.label++;
|
|
95
|
+
return {
|
|
96
|
+
value: op[1],
|
|
97
|
+
done: false
|
|
98
|
+
};
|
|
99
|
+
case 5:
|
|
100
|
+
_.label++;
|
|
101
|
+
y = op[1];
|
|
102
|
+
op = [
|
|
103
|
+
0
|
|
104
|
+
];
|
|
105
|
+
continue;
|
|
106
|
+
case 7:
|
|
107
|
+
op = _.ops.pop();
|
|
108
|
+
_.trys.pop();
|
|
109
|
+
continue;
|
|
110
|
+
default:
|
|
111
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
112
|
+
_ = 0;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
116
|
+
_.label = op[1];
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
120
|
+
_.label = t[1];
|
|
121
|
+
t = op;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (t && _.label < t[2]) {
|
|
125
|
+
_.label = t[2];
|
|
126
|
+
_.ops.push(op);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (t[2]) _.ops.pop();
|
|
130
|
+
_.trys.pop();
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
op = body.call(thisArg, _);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
op = [
|
|
136
|
+
6,
|
|
137
|
+
e
|
|
138
|
+
];
|
|
139
|
+
y = 0;
|
|
140
|
+
} finally{
|
|
141
|
+
f = t = 0;
|
|
142
|
+
}
|
|
143
|
+
if (op[0] & 5) throw op[1];
|
|
144
|
+
return {
|
|
145
|
+
value: op[0] ? op[1] : void 0,
|
|
146
|
+
done: true
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
import { message } from 'antd';
|
|
151
|
+
import React, { useCallback } from 'react';
|
|
152
|
+
import addIndexToObject from '../addIndexToObject';
|
|
153
|
+
import { useOrder } from '../providers/OrderProvider';
|
|
154
|
+
export default function useFetchPage(param) {
|
|
155
|
+
var suspend = param.suspend, setLoading = param.setLoading, pageSize = param.pageSize, loadPage = param.loadPage, filters = param.filters, data = param.data, pinned = param.pinned, setData = param.setData, setTotal = param.setTotal;
|
|
156
|
+
var order = useOrder().order;
|
|
157
|
+
return useCallback(function() {
|
|
158
|
+
var _ref = _async_to_generator(function(page, size) {
|
|
159
|
+
var loaded, newData, e;
|
|
160
|
+
return _ts_generator(this, function(_state) {
|
|
161
|
+
switch(_state.label){
|
|
162
|
+
case 0:
|
|
163
|
+
if (typeof suspend === 'boolean' && suspend) {
|
|
164
|
+
setLoading(false);
|
|
165
|
+
return [
|
|
166
|
+
2
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
if (size === undefined) {
|
|
170
|
+
size = pageSize();
|
|
171
|
+
}
|
|
172
|
+
_state.label = 1;
|
|
173
|
+
case 1:
|
|
174
|
+
_state.trys.push([
|
|
175
|
+
1,
|
|
176
|
+
3,
|
|
177
|
+
4,
|
|
178
|
+
5
|
|
179
|
+
]);
|
|
180
|
+
setLoading(true);
|
|
181
|
+
return [
|
|
182
|
+
4,
|
|
183
|
+
loadPage(page, size, filters, order)
|
|
184
|
+
];
|
|
185
|
+
case 2:
|
|
186
|
+
loaded = _state.sent();
|
|
187
|
+
if (page !== 0) {
|
|
188
|
+
newData = _to_consumable_array(data || []).concat(_to_consumable_array(loaded.data));
|
|
189
|
+
} else {
|
|
190
|
+
newData = loaded.data || [];
|
|
191
|
+
}
|
|
192
|
+
if (Array.isArray(pinned)) {
|
|
193
|
+
pinned.forEach(function(pinnedEl, pinnedIdx) {
|
|
194
|
+
var indexes = newData.map(function(param, index) {
|
|
195
|
+
var id = param.id;
|
|
196
|
+
return {
|
|
197
|
+
id: id,
|
|
198
|
+
index: index
|
|
199
|
+
};
|
|
200
|
+
})// TODO fix
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
.filter(function(el) {
|
|
203
|
+
return el.id === pinnedEl.id;
|
|
204
|
+
}).map(function(param) {
|
|
205
|
+
var index = param.index;
|
|
206
|
+
return index;
|
|
207
|
+
});
|
|
208
|
+
indexes.forEach(function(index) {
|
|
209
|
+
if (index !== pinnedIdx) {
|
|
210
|
+
newData.splice(index, 1);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
if (!indexes.includes(pinnedIdx)) {
|
|
214
|
+
newData.unshift(pinnedEl);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
setData(newData.map(addIndexToObject));
|
|
219
|
+
setTotal(loaded.total);
|
|
220
|
+
return [
|
|
221
|
+
3,
|
|
222
|
+
5
|
|
223
|
+
];
|
|
224
|
+
case 3:
|
|
225
|
+
e = _state.sent();
|
|
226
|
+
message.error("".concat(e));
|
|
227
|
+
return [
|
|
228
|
+
3,
|
|
229
|
+
5
|
|
230
|
+
];
|
|
231
|
+
case 4:
|
|
232
|
+
setLoading(false);
|
|
233
|
+
return [
|
|
234
|
+
7
|
|
235
|
+
];
|
|
236
|
+
case 5:
|
|
237
|
+
return [
|
|
238
|
+
2
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
return function(page, size) {
|
|
244
|
+
return _ref.apply(this, arguments);
|
|
245
|
+
};
|
|
246
|
+
}(), [
|
|
247
|
+
suspend,
|
|
248
|
+
pageSize,
|
|
249
|
+
loadPage,
|
|
250
|
+
filters,
|
|
251
|
+
data,
|
|
252
|
+
order
|
|
253
|
+
]);
|
|
254
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
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_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function _iterable_to_array(iter) {
|
|
23
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
24
|
+
}
|
|
25
|
+
function _non_iterable_spread() {
|
|
26
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
27
|
+
}
|
|
28
|
+
function _object_spread(target) {
|
|
29
|
+
for(var i = 1; i < arguments.length; i++){
|
|
30
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
31
|
+
var ownKeys = Object.keys(source);
|
|
32
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
33
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
34
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
ownKeys.forEach(function(key) {
|
|
38
|
+
_define_property(target, key, source[key]);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
function ownKeys(object, enumerableOnly) {
|
|
44
|
+
var keys = Object.keys(object);
|
|
45
|
+
if (Object.getOwnPropertySymbols) {
|
|
46
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
47
|
+
if (enumerableOnly) {
|
|
48
|
+
symbols = symbols.filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
keys.push.apply(keys, symbols);
|
|
53
|
+
}
|
|
54
|
+
return keys;
|
|
55
|
+
}
|
|
56
|
+
function _object_spread_props(target, source) {
|
|
57
|
+
source = source != null ? source : {};
|
|
58
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
59
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
60
|
+
} else {
|
|
61
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
62
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
function _to_consumable_array(arr) {
|
|
68
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
69
|
+
}
|
|
70
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
71
|
+
if (!o) return;
|
|
72
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
73
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
74
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
75
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
76
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
77
|
+
}
|
|
78
|
+
import React, { useCallback } from 'react';
|
|
79
|
+
import Draggable from 'react-draggable';
|
|
80
|
+
import { useOrder } from '../providers/OrderProvider';
|
|
81
|
+
import { TableData, TableHeader } from '../styles';
|
|
82
|
+
var isKeyInRow = function(key, row) {
|
|
83
|
+
return key in row;
|
|
84
|
+
};
|
|
85
|
+
export default function useGetCellRenderer(param) {
|
|
86
|
+
var columns = param.columns, data = param.data, actions = param.actions, resizeCol = param.resizeCol, setHoveredRow = param.setHoveredRow, hoveredRow = param.hoveredRow, selected = param.selected, checked = param.checked, idKey = param.idKey;
|
|
87
|
+
var _useOrder = useOrder(), order = _useOrder.order, setOrder = _useOrder.setOrder;
|
|
88
|
+
var sortByColumn = useCallback(function(param) {
|
|
89
|
+
var orderNested = param.orderNested, key = param.key;
|
|
90
|
+
if (key === 'akcje') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (Array.isArray(orderNested)) {
|
|
94
|
+
setOrder(_to_consumable_array(orderNested).concat([
|
|
95
|
+
Array.isArray(order) && order[0] === orderNested[0] && order[1] === orderNested[1] && order[2] === 'ASC' ? 'DESC' : 'ASC'
|
|
96
|
+
]));
|
|
97
|
+
} else if (data && key in data[0]) {
|
|
98
|
+
setOrder([
|
|
99
|
+
key,
|
|
100
|
+
Array.isArray(order) && order[0] === key && order[1] === 'ASC' ? 'DESC' : 'ASC'
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
order,
|
|
105
|
+
setOrder,
|
|
106
|
+
data
|
|
107
|
+
]);
|
|
108
|
+
var getBackgroundColor = useCallback(function(rowIndex) {
|
|
109
|
+
var row = data[rowIndex - 1];
|
|
110
|
+
var dataIdKey = 'id' in row ? 'id' : idKey;
|
|
111
|
+
var hasId = typeof (row === null || row === void 0 ? void 0 : row[dataIdKey]) !== 'undefined';
|
|
112
|
+
/// TODO: fix selected types
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
var isSelectedSingle = selected === (row === null || row === void 0 ? void 0 : row[dataIdKey]) && hasId;
|
|
115
|
+
if (isSelectedSingle) {
|
|
116
|
+
return '#bae7ff';
|
|
117
|
+
}
|
|
118
|
+
if (typeof checked === 'undefined') {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (row && 'index' in row) {
|
|
122
|
+
var isSelected = checked.includes(row.index);
|
|
123
|
+
if ((actions === null || actions === void 0 ? void 0 : actions.onRowClick) && hoveredRow === rowIndex && !isSelected) {
|
|
124
|
+
return '#AAA';
|
|
125
|
+
}
|
|
126
|
+
if (isSelected) {
|
|
127
|
+
return '#bae7ff';
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}, [
|
|
132
|
+
checked,
|
|
133
|
+
actions,
|
|
134
|
+
data
|
|
135
|
+
]);
|
|
136
|
+
var handleOnClick = useCallback(function(rowIndex) {
|
|
137
|
+
return function(e) {
|
|
138
|
+
e.stopPropagation();
|
|
139
|
+
actions === null || actions === void 0 ? void 0 : actions.onRowClick(data[rowIndex - 1]);
|
|
140
|
+
};
|
|
141
|
+
}, [
|
|
142
|
+
actions,
|
|
143
|
+
data
|
|
144
|
+
]);
|
|
145
|
+
return useCallback(function(param) {
|
|
146
|
+
var columnIndex = param.columnIndex, rowIndex = param.rowIndex, rowKey = param.rowKey, style = param.style, isScrolling = param.isScrolling, isVisible = param.isVisible;
|
|
147
|
+
// const hoverRow = useCallback(
|
|
148
|
+
// (rowIndex) => () => {
|
|
149
|
+
// setHoveredRow(rowIndex);
|
|
150
|
+
// },
|
|
151
|
+
// [setHoveredRow]
|
|
152
|
+
// );
|
|
153
|
+
// const blurRow = useCallback(() => setHoveredRow(), []);
|
|
154
|
+
var colCfg = columns[columnIndex];
|
|
155
|
+
var value;
|
|
156
|
+
var row = data[rowIndex - 1];
|
|
157
|
+
if (row && isKeyInRow(colCfg.key, row)) {
|
|
158
|
+
value = rowIndex !== 0 ? row[colCfg.key] : undefined;
|
|
159
|
+
}
|
|
160
|
+
if (rowIndex === 0) {
|
|
161
|
+
return /*#__PURE__*/ React.createElement(TableHeader, {
|
|
162
|
+
key: rowKey,
|
|
163
|
+
style: _object_spread_props(_object_spread({}, style), {
|
|
164
|
+
display: 'flex',
|
|
165
|
+
alignItems: 'center'
|
|
166
|
+
}),
|
|
167
|
+
className: "td th",
|
|
168
|
+
onClick: function() {
|
|
169
|
+
return sortByColumn(colCfg);
|
|
170
|
+
}
|
|
171
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
172
|
+
className: "text-nowrap w-100".concat(colCfg.resized ? ' resized' : '')
|
|
173
|
+
}, colCfg.title), /*#__PURE__*/ React.createElement(Draggable, {
|
|
174
|
+
axis: "x",
|
|
175
|
+
defaultClassName: "DragHandle",
|
|
176
|
+
defaultClassNameDragging: "DragHandleActive",
|
|
177
|
+
onDrag: function(e, param) {
|
|
178
|
+
var deltaX = param.deltaX;
|
|
179
|
+
return resizeCol(columnIndex, deltaX);
|
|
180
|
+
},
|
|
181
|
+
position: {
|
|
182
|
+
x: 0,
|
|
183
|
+
y: undefined
|
|
184
|
+
}
|
|
185
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
186
|
+
className: "DragHandleIcon"
|
|
187
|
+
}, "⋮")));
|
|
188
|
+
}
|
|
189
|
+
var clickable = (actions === null || actions === void 0 ? void 0 : actions.onRowClick) && colCfg.key !== 'akcje';
|
|
190
|
+
var divProps = colCfg.resized ? {
|
|
191
|
+
className: 'td resized'
|
|
192
|
+
} : {
|
|
193
|
+
className: 'td'
|
|
194
|
+
};
|
|
195
|
+
var content = value;
|
|
196
|
+
if (isScrolling && colCfg.lightRender) {
|
|
197
|
+
// TODO: improve
|
|
198
|
+
// @ts-ignore
|
|
199
|
+
content = colCfg.lightRender(value, data[rowIndex - 1], rowIndex);
|
|
200
|
+
} else if (colCfg.render) {
|
|
201
|
+
// TODO: improve
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
content = colCfg.render(value, data[rowIndex - 1], rowIndex);
|
|
204
|
+
}
|
|
205
|
+
return /*#__PURE__*/ React.createElement(TableData, _object_spread_props(_object_spread({
|
|
206
|
+
// onMouseOver={hoverRow(rowIndex)} // TODO: is it useful?
|
|
207
|
+
// onMouseLeave={blurRow}
|
|
208
|
+
$align: colCfg.align,
|
|
209
|
+
role: "button",
|
|
210
|
+
key: rowKey,
|
|
211
|
+
style: _object_spread_props(_object_spread({}, style), {
|
|
212
|
+
cursor: clickable ? 'pointer' : undefined,
|
|
213
|
+
backgroundColor: getBackgroundColor(rowIndex),
|
|
214
|
+
color: (actions === null || actions === void 0 ? void 0 : actions.onRowClick) && hoveredRow === rowIndex ? 'black' : undefined
|
|
215
|
+
})
|
|
216
|
+
}, divProps), {
|
|
217
|
+
className: "tr td ".concat((rowIndex - 1) % 2 === 0 ? 'td-light' : ''),
|
|
218
|
+
onClick: clickable ? handleOnClick(rowIndex) : null
|
|
219
|
+
}), content);
|
|
220
|
+
}, [
|
|
221
|
+
columns,
|
|
222
|
+
data,
|
|
223
|
+
actions,
|
|
224
|
+
resizeCol,
|
|
225
|
+
setHoveredRow,
|
|
226
|
+
hoveredRow,
|
|
227
|
+
selected,
|
|
228
|
+
checked,
|
|
229
|
+
sortByColumn
|
|
230
|
+
]);
|
|
231
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Checkbox } from 'antd';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
export default function useGetColumnsWithCheckbox(param) {
|
|
4
|
+
var checked = param.checked, data = param.data, RowCheckbox = param.RowCheckbox;
|
|
5
|
+
return useCallback(function getColumnsWithCheckbox(updatedColumns) {
|
|
6
|
+
var checkboxColumn = getCheckboxColumn({
|
|
7
|
+
allChecked: (data === null || data === void 0 ? void 0 : data.length) === (checked === null || checked === void 0 ? void 0 : checked.length),
|
|
8
|
+
RowCheckbox: RowCheckbox
|
|
9
|
+
});
|
|
10
|
+
if (updatedColumns[0].key === 'checkbox') {
|
|
11
|
+
updatedColumns[0] = checkboxColumn;
|
|
12
|
+
} else {
|
|
13
|
+
updatedColumns.unshift(checkboxColumn);
|
|
14
|
+
}
|
|
15
|
+
return updatedColumns;
|
|
16
|
+
}, [
|
|
17
|
+
checked,
|
|
18
|
+
data,
|
|
19
|
+
RowCheckbox
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
function getCheckboxColumn(param) {
|
|
23
|
+
var allChecked = param.allChecked, RowCheckbox = param.RowCheckbox;
|
|
24
|
+
return {
|
|
25
|
+
title: /*#__PURE__*/ React.createElement(Checkbox, {
|
|
26
|
+
checked: allChecked,
|
|
27
|
+
disabled: true
|
|
28
|
+
}),
|
|
29
|
+
width: 54,
|
|
30
|
+
key: 'checkbox',
|
|
31
|
+
render: RowCheckbox
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
import { message } from 'antd';
|
|
126
|
+
import React, { useCallback } from 'react';
|
|
127
|
+
import addIndexToObject from '../addIndexToObject';
|
|
128
|
+
export default function useGetDeleteRow(param) {
|
|
129
|
+
var onDelete = param.onDelete, setData = param.setData, data = param.data, deleteMessage = param.deleteMessage;
|
|
130
|
+
return useCallback(function() {
|
|
131
|
+
var _ref = _async_to_generator(function(row) {
|
|
132
|
+
var response, e;
|
|
133
|
+
return _ts_generator(this, function(_state) {
|
|
134
|
+
switch(_state.label){
|
|
135
|
+
case 0:
|
|
136
|
+
_state.trys.push([
|
|
137
|
+
0,
|
|
138
|
+
2,
|
|
139
|
+
,
|
|
140
|
+
3
|
|
141
|
+
]);
|
|
142
|
+
return [
|
|
143
|
+
4,
|
|
144
|
+
onDelete(row)
|
|
145
|
+
];
|
|
146
|
+
case 1:
|
|
147
|
+
response = _state.sent();
|
|
148
|
+
if (!response) return [
|
|
149
|
+
2
|
|
150
|
+
];
|
|
151
|
+
deleteMessage && message.success(deleteMessage(row));
|
|
152
|
+
setData(data.filter(function(e) {
|
|
153
|
+
return JSON.stringify(e) !== JSON.stringify(row);
|
|
154
|
+
}).map(addIndexToObject));
|
|
155
|
+
return [
|
|
156
|
+
3,
|
|
157
|
+
3
|
|
158
|
+
];
|
|
159
|
+
case 2:
|
|
160
|
+
e = _state.sent();
|
|
161
|
+
message.error("Wystąpił błąd ".concat(e));
|
|
162
|
+
return [
|
|
163
|
+
3,
|
|
164
|
+
3
|
|
165
|
+
];
|
|
166
|
+
case 3:
|
|
167
|
+
return [
|
|
168
|
+
2
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return function(row) {
|
|
174
|
+
return _ref.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
}(), [
|
|
177
|
+
data,
|
|
178
|
+
onDelete,
|
|
179
|
+
setData
|
|
180
|
+
]);
|
|
181
|
+
}
|