@panneau/data 3.0.168 → 3.0.173

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.
Files changed (3) hide show
  1. package/es/index.js +487 -20
  2. package/lib/index.js +1042 -571
  3. package/package.json +5 -3
package/lib/index.js CHANGED
@@ -12,9 +12,12 @@ var fetch$1 = require('@folklore/fetch');
12
12
  var pathToRegexp = require('path-to-regexp');
13
13
  var _typeof = require('@babel/runtime/helpers/typeof');
14
14
  var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
15
+ var reactQuery = require('@tanstack/react-query');
15
16
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
16
- var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
17
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
17
18
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
19
+ var isEmpty = require('lodash/isEmpty');
20
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
18
21
 
19
22
  var useData = function useData(loadData) {
20
23
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
@@ -73,547 +76,138 @@ var useData = function useData(loadData) {
73
76
  };
74
77
  var useData$1 = useData;
75
78
 
76
- var useItems = function useItems(_ref) {
77
- var _ref$getPage = _ref.getPage,
78
- getPage = _ref$getPage === void 0 ? null : _ref$getPage,
79
- _ref$getItems = _ref.getItems,
80
- getItems = _ref$getItems === void 0 ? null : _ref$getItems,
81
- _ref$page = _ref.page,
82
- page = _ref$page === void 0 ? null : _ref$page,
83
- _ref$count = _ref.count,
84
- count = _ref$count === void 0 ? 10 : _ref$count,
85
- _ref$items = _ref.items,
86
- providedItems = _ref$items === void 0 ? null : _ref$items,
87
- _ref$pages = _ref.pages,
88
- initialPages = _ref$pages === void 0 ? null : _ref$pages,
89
- _ref$getPageFromRespo = _ref.getPageFromResponse,
90
- getPageFromResponse = _ref$getPageFromRespo === void 0 ? function (_ref2) {
91
- var _ref2$pagination = _ref2.pagination,
92
- currentPage = _ref2$pagination.page,
93
- lastPage = _ref2$pagination.last_page,
94
- total = _ref2$pagination.total,
95
- perPage = _ref2$pagination.per_page,
96
- items = _ref2.data;
97
- return {
98
- page: parseInt(currentPage, 10),
99
- lastPage: parseInt(lastPage, 10),
100
- total: parseInt(total, 10),
101
- count: parseInt(perPage, 10),
102
- items: items
103
- };
104
- } : _ref$getPageFromRespo,
105
- _ref$getItemsFromResp = _ref.getItemsFromResponse,
106
- getItemsFromResponse = _ref$getItemsFromResp === void 0 ? function (data) {
107
- return data;
108
- } : _ref$getItemsFromResp,
109
- _ref$onItemsLoaded = _ref.onItemsLoaded,
110
- onItemsLoaded = _ref$onItemsLoaded === void 0 ? null : _ref$onItemsLoaded,
111
- _ref$onPageLoaded = _ref.onPageLoaded,
112
- onPageLoaded = _ref$onPageLoaded === void 0 ? null : _ref$onPageLoaded,
113
- _ref$onLoaded = _ref.onLoaded,
114
- onLoaded = _ref$onLoaded === void 0 ? null : _ref$onLoaded,
115
- _ref$onError = _ref.onError,
116
- onError = _ref$onError === void 0 ? null : _ref$onError;
117
- var isPaginated = getPage !== null || initialPages !== null;
118
- var lastState = React.useRef(null);
119
- var initialState = React.useMemo(function () {
120
- var finalInitialPages = initialPages !== null ? initialPages.map(function (it) {
121
- return getPageFromResponse(it);
122
- }) : null;
123
- return {
124
- lastPage: finalInitialPages !== null ? finalInitialPages.reduce(function (currentLastPage, _ref3) {
125
- var initialLastPage = _ref3.lastPage;
126
- return initialLastPage > currentLastPage ? initialLastPage : currentLastPage;
127
- }, -1) : -1,
128
- total: finalInitialPages !== null ? finalInitialPages[0].total : (providedItems || []).length,
129
- loaded: providedItems !== null,
130
- loading: false,
131
- pages: finalInitialPages !== null ? finalInitialPages : null,
132
- items: null
133
- };
134
- }, [initialPages, providedItems]);
135
- var _useState = React.useState(initialState),
136
- _useState2 = _slicedToArray(_useState, 2),
137
- state = _useState2[0],
138
- setState = _useState2[1];
139
- var lastPage = state.lastPage,
140
- loaded = state.loaded,
141
- loading = state.loading,
142
- stateItems = state.items,
143
- pages = state.pages,
144
- total = state.total;
145
- var items = providedItems || (isPaginated && pages !== null ? pages.reduce(function (pagesItems, _ref4) {
146
- var pageItems = _ref4.items;
147
- return pagesItems.concat(pageItems);
148
- }, []) : stateItems) || null;
149
- var updateState = function updateState(update) {
150
- return setState(_objectSpread(_objectSpread({}, state), update));
79
+ var token = '%[a-f0-9]{2}';
80
+ var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
81
+ var multiMatcher = new RegExp('(' + token + ')+', 'gi');
82
+ function decodeComponents(components, split) {
83
+ try {
84
+ // Try to decode the entire string first
85
+ return [decodeURIComponent(components.join(''))];
86
+ } catch (_unused) {
87
+ // Do nothing
88
+ }
89
+ if (components.length === 1) {
90
+ return components;
91
+ }
92
+ split = split || 1;
93
+
94
+ // Split the array in 2 parts
95
+ var left = components.slice(0, split);
96
+ var right = components.slice(split);
97
+ return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
98
+ }
99
+ function decode$1(input) {
100
+ try {
101
+ return decodeURIComponent(input);
102
+ } catch (_unused2) {
103
+ var tokens = input.match(singleMatcher) || [];
104
+ for (var i = 1; i < tokens.length; i++) {
105
+ input = decodeComponents(tokens, i).join('');
106
+ tokens = input.match(singleMatcher) || [];
107
+ }
108
+ return input;
109
+ }
110
+ }
111
+ function customDecodeURIComponent(input) {
112
+ // Keep track of all the replacements and prefill the map with the `BOM`
113
+ var replaceMap = {
114
+ '%FE%FF': "\uFFFD\uFFFD",
115
+ '%FF%FE': "\uFFFD\uFFFD"
151
116
  };
152
- var updateFromResponse = function updateFromResponse(response) {
153
- var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
154
- var reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
155
- if (error !== null) {
156
- updateState({
157
- loaded: false,
158
- loading: false
159
- });
160
- throw error;
117
+ var match = multiMatcher.exec(input);
118
+ while (match) {
119
+ try {
120
+ // Decode as big chunks as possible
121
+ replaceMap[match[0]] = decodeURIComponent(match[0]);
122
+ } catch (_unused3) {
123
+ var result = decode$1(match[0]);
124
+ if (result !== match[0]) {
125
+ replaceMap[match[0]] = result;
126
+ }
161
127
  }
162
- if (isPaginated) {
163
- var newPage = getPageFromResponse(response);
164
- var newPages = (reset ? [newPage] : [].concat(_toConsumableArray((pages || []).filter(function (it) {
165
- return it.page !== newPage.page;
166
- })), [newPage])).sort(function (a, b) {
167
- if (a === b) {
168
- return 0;
128
+ match = multiMatcher.exec(input);
129
+ }
130
+
131
+ // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
132
+ replaceMap['%C2'] = "\uFFFD";
133
+ var entries = Object.keys(replaceMap);
134
+ for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
135
+ var key = _entries[_i];
136
+ // Replace all decoded components
137
+ input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
138
+ }
139
+ return input;
140
+ }
141
+ function decodeUriComponent(encodedURI) {
142
+ if (typeof encodedURI !== 'string') {
143
+ throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + _typeof(encodedURI) + '`');
144
+ }
145
+ try {
146
+ // Try the built in decoder first
147
+ return decodeURIComponent(encodedURI);
148
+ } catch (_unused4) {
149
+ // Fallback to a more advanced decoder
150
+ return customDecodeURIComponent(encodedURI);
151
+ }
152
+ }
153
+
154
+ function splitOnFirst(string, separator) {
155
+ if (!(typeof string === 'string' && typeof separator === 'string')) {
156
+ throw new TypeError('Expected the arguments to be of type `string`');
157
+ }
158
+ if (string === '' || separator === '') {
159
+ return [];
160
+ }
161
+ var separatorIndex = string.indexOf(separator);
162
+ if (separatorIndex === -1) {
163
+ return [];
164
+ }
165
+ return [string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length)];
166
+ }
167
+
168
+ function includeKeys(object, predicate) {
169
+ var result = {};
170
+ if (Array.isArray(predicate)) {
171
+ var _iterator = _createForOfIteratorHelper(predicate),
172
+ _step;
173
+ try {
174
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
175
+ var key = _step.value;
176
+ var descriptor = Object.getOwnPropertyDescriptor(object, key);
177
+ if (descriptor !== null && descriptor !== void 0 && descriptor.enumerable) {
178
+ Object.defineProperty(result, key, descriptor);
169
179
  }
170
- return a > b ? 1 : -1;
171
- });
172
- updateState({
173
- loaded: true,
174
- loading: false,
175
- lastPage: newPage.lastPage,
176
- total: newPage.total,
177
- pages: newPages
178
- });
179
- return newPage;
180
+ }
181
+ } catch (err) {
182
+ _iterator.e(err);
183
+ } finally {
184
+ _iterator.f();
180
185
  }
181
- var newItems = _toConsumableArray(getItemsFromResponse(response));
182
- updateState({
183
- loaded: true,
184
- loading: false,
185
- items: newItems,
186
- total: newItems.length
187
- });
188
- return newItems;
189
- };
190
- var getNextPage = function getNextPage() {
191
- var allPages = lastPage !== -1 ? Array.call.apply(Array, [null].concat(_toConsumableArray(Array(lastPage)))).map(function (it, index) {
192
- return index + 1;
193
- }) : [];
194
- var remainingPages = allPages.filter(function (pageNumber) {
195
- return pages.findIndex(function (it) {
196
- return it.page === pageNumber;
197
- }) === -1;
198
- });
199
- var firstItem = remainingPages.length > 0 ? remainingPages.shift() : null;
200
- return firstItem !== null ? firstItem : null;
201
- };
202
- var loadItems = function loadItems(requestPage) {
203
- updateState({
204
- loading: true
205
- });
206
- var canceled = false;
207
- var request = isPaginated ? getPage(requestPage, count) : getItems();
208
- var promise = request.then(function (response) {
209
- return !canceled ? updateFromResponse(response) : Promise.reject();
210
- })["catch"](function (error) {
211
- return !canceled ? updateFromResponse(null, error) : Promise.reject();
212
- }).then(function (response) {
213
- if (isPaginated && onPageLoaded !== null) {
214
- onPageLoaded(response);
215
- } else if (!isPaginated && onItemsLoaded !== null) {
216
- onItemsLoaded(response);
186
+ } else {
187
+ // `Reflect.ownKeys()` is required to retrieve symbol properties
188
+ var _iterator2 = _createForOfIteratorHelper(Reflect.ownKeys(object)),
189
+ _step2;
190
+ try {
191
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
192
+ var _key = _step2.value;
193
+ var _descriptor = Object.getOwnPropertyDescriptor(object, _key);
194
+ if (_descriptor.enumerable) {
195
+ var value = object[_key];
196
+ if (predicate(_key, value, object)) {
197
+ Object.defineProperty(result, _key, _descriptor);
198
+ }
199
+ }
217
200
  }
218
- if (onLoaded !== null) {
219
- onLoaded(response);
220
- }
221
- return response;
222
- })["catch"](function (error) {
223
- if (!canceled && onError !== null) {
224
- onError(error);
225
- }
226
- });
227
- promise.cancel = function () {
228
- canceled = true;
229
- };
230
- return promise;
231
- };
232
- var loadPage = function loadPage(pageToLoad) {
233
- if (loading) {
234
- return Promise.reject();
235
- }
236
- if (pages.find(function (it) {
237
- return it.page === pageToLoad;
238
- }) !== -1) {
239
- return Promise.reject();
240
- }
241
- return loadItems(pageToLoad);
242
- };
243
- var loadNextPage = function loadNextPage() {
244
- if (loading) {
245
- return Promise.reject();
246
- }
247
- var nextPage = getNextPage();
248
- return nextPage !== null ? loadItems(nextPage) : Promise.resolve();
249
- };
250
- var reloadPage = function reloadPage() {
251
- if (loading) {
252
- return Promise.reject();
253
- }
254
- return loadItems(page);
255
- };
256
- var reload = function reload() {
257
- if (loading) {
258
- return Promise.reject();
259
- }
260
- return loadItems();
261
- };
262
- var reset = React.useCallback(function () {
263
- setState({
264
- loaded: false,
265
- loading: false,
266
- lastPage: -1,
267
- total: 0,
268
- pages: null,
269
- items: null
270
- });
271
- }, [page, setState]);
272
- var updateItem = function updateItem(newItem) {
273
- if (loading) {
274
- return;
275
- }
276
- if (isPaginated) {
277
- var currentPages = pages || [];
278
- updateState({
279
- pages: currentPages.map(function (pageData) {
280
- var pageItems = pageData.items || [];
281
- if (pageItems.findIndex(function (_ref5) {
282
- var id = _ref5.id;
283
- return id === newItem.id;
284
- }) !== -1) {
285
- return _objectSpread(_objectSpread({}, pageData), {}, {
286
- items: pageItems.map(function (it) {
287
- return it.id === newItem.id ? newItem : it;
288
- })
289
- });
290
- }
291
- return pageData;
292
- })
293
- });
294
- } else {
295
- var currentItems = items || [];
296
- updateState({
297
- items: currentItems.map(function (it) {
298
- return it.id === newItem.id ? newItem : it;
299
- })
300
- });
301
- }
302
- };
303
- React.useEffect(function () {
304
- var hadState = lastState.current !== null;
305
- lastState.current = initialState;
306
- if (hadState) {
307
- setState(initialState);
308
- }
309
- }, [initialState]);
310
- React.useEffect(function () {
311
- if (getPage === null && getItems === null || providedItems !== null) {
312
- return function () {};
313
- }
314
- var loadPromise = null;
315
- var pageToLoad = isPaginated && initialPages === null && page === null ? 1 : page;
316
- if (!isPaginated || pageToLoad !== null) {
317
- loadPromise = loadItems(pageToLoad);
201
+ } catch (err) {
202
+ _iterator2.e(err);
203
+ } finally {
204
+ _iterator2.f();
318
205
  }
319
- return function () {
320
- if (loadPromise !== null) {
321
- loadPromise.cancel();
322
- }
323
- };
324
- }, [getPage, getItems, page]);
325
- var currentPage = isPaginated && pages !== null ? pages.find(function (_ref6) {
326
- var pageNumber = _ref6.page;
327
- return parseInt(pageNumber, 10) === parseInt(page, 10);
328
- }) || null : null;
329
- return {
330
- items: items,
331
- pages: pages,
332
- pageItems: currentPage !== null ? currentPage.items : null,
333
- total: total,
334
- lastPage: lastPage,
335
- loaded: loaded,
336
- allLoaded: !isPaginated && loaded || lastPage !== -1 && isPaginated && pages.length === lastPage,
337
- loading: loading,
338
- loadNextPage: loadNextPage,
339
- loadPage: loadPage,
340
- reloadPage: reloadPage,
341
- reload: reload,
342
- reset: reset,
343
- updateItem: updateItem
344
- };
345
- };
346
- var useItems$1 = useItems;
347
-
348
- var AccountApi = /*#__PURE__*/function () {
349
- function AccountApi(api, opts) {
350
- _classCallCheck(this, AccountApi);
351
- this.api = api;
352
- this.options = _objectSpread({
353
- withCredentials: false
354
- }, opts);
355
206
  }
356
- return _createClass(AccountApi, [{
357
- key: "update",
358
- value: function update(data) {
359
- var withCredentials = this.options.withCredentials;
360
- return this.api.requestPost(this.api.route('account'), data, {
361
- withSession: !withCredentials,
362
- withCredentials: withCredentials
363
- });
364
- }
365
- }, {
366
- key: "updatePassword",
367
- value: function updatePassword(data) {
368
- var withCredentials = this.options.withCredentials;
369
- return this.api.requestPost(this.api.route('account.password'), data, {
370
- withSession: !withCredentials,
371
- withCredentials: withCredentials
372
- });
373
- }
374
- }, {
375
- key: "updateTaxes",
376
- value: function updateTaxes(data) {
377
- var withCredentials = this.options.withCredentials;
378
- return this.api.requestPost(this.api.route('account.taxes'), data, {
379
- withSession: !withCredentials,
380
- withCredentials: withCredentials
381
- });
382
- }
383
- }, {
384
- key: "delete",
385
- value: function _delete(data) {
386
- var withCredentials = this.options.withCredentials;
387
- return this.api.requestPost(this.api.route('account.delete'), data, {
388
- withSession: !withCredentials,
389
- withCredentials: withCredentials
390
- });
391
- }
392
- }]);
393
- }();
207
+ return result;
208
+ }
394
209
 
395
- var AuthApi = /*#__PURE__*/function () {
396
- function AuthApi(api, opts) {
397
- _classCallCheck(this, AuthApi);
398
- this.api = api;
399
- this.options = _objectSpread({
400
- withCredentials: true
401
- }, opts);
402
- }
403
- return _createClass(AuthApi, [{
404
- key: "check",
405
- value: function check() {
406
- var withCredentials = this.options.withCredentials;
407
- return this.api.requestGet(this.api.route('auth.check'), null, {
408
- withSession: !withCredentials,
409
- withCredentials: withCredentials
410
- });
411
- }
412
- }, {
413
- key: "login",
414
- value: function login(email, password) {
415
- var withCredentials = this.options.withCredentials;
416
- return this.api.requestPost(this.api.route('auth.login'), {
417
- email: email,
418
- password: password
419
- }, {
420
- withSession: !withCredentials,
421
- withCredentials: withCredentials
422
- });
423
- }
424
- }, {
425
- key: "register",
426
- value: function register(data) {
427
- var withCredentials = this.options.withCredentials;
428
- return this.api.requestPost(this.api.route('auth.register'), data, {
429
- withSession: !withCredentials,
430
- withCredentials: withCredentials
431
- });
432
- }
433
- }, {
434
- key: "logout",
435
- value: function logout() {
436
- var url = this.api.getFullUrl(this.api.route('auth.logout'));
437
- return fetch(url, {
438
- method: 'POST',
439
- headers: _objectSpread({}, fetch$1.getCSRFHeaders()),
440
- credentials: 'include'
441
- })["catch"](function (err) {
442
- console.log('logout err', err); // eslint-disable-line
443
- throw err;
444
- });
445
- }
446
- }, {
447
- key: "requestPassword",
448
- value: function requestPassword(email) {
449
- var withCredentials = this.options.withCredentials;
450
- return this.api.requestPost(this.api.route('auth.password.email'), {
451
- email: email
452
- }, {
453
- withSession: !withCredentials,
454
- withCredentials: withCredentials
455
- });
456
- }
457
- }, {
458
- key: "resetPassword",
459
- value: function resetPassword(data) {
460
- var withCredentials = this.options.withCredentials;
461
- return this.api.requestPost(this.api.route('auth.password.update'), data, {
462
- withSession: !withCredentials,
463
- withCredentials: withCredentials
464
- });
465
- }
466
- }]);
467
- }();
468
-
469
- ({
470
- children: PropTypes.node.isRequired,
471
- routes: PropTypes.objectOf(PropTypes.string).isRequired,
472
- basePath: PropTypes.string
473
- });
474
- var compilers = {};
475
- function generatePath(fullPath, data) {
476
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
477
- var fullUrlMatches = fullPath.match(/^(https?:\/\/)/);
478
- if (typeof compilers[fullPath] === 'undefined') {
479
- compilers[fullPath] = pathToRegexp.compile(fullPath.replace(/^(https?:\/\/)/, ''), opts);
480
- }
481
- var compiler = compilers[fullPath];
482
- return fullUrlMatches !== null ? "".concat(fullUrlMatches[1]).concat(compiler(data)) : compiler(data);
483
- }
484
-
485
- var token = '%[a-f0-9]{2}';
486
- var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
487
- var multiMatcher = new RegExp('(' + token + ')+', 'gi');
488
- function decodeComponents(components, split) {
489
- try {
490
- // Try to decode the entire string first
491
- return [decodeURIComponent(components.join(''))];
492
- } catch (_unused) {
493
- // Do nothing
494
- }
495
- if (components.length === 1) {
496
- return components;
497
- }
498
- split = split || 1;
499
-
500
- // Split the array in 2 parts
501
- var left = components.slice(0, split);
502
- var right = components.slice(split);
503
- return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
504
- }
505
- function decode$1(input) {
506
- try {
507
- return decodeURIComponent(input);
508
- } catch (_unused2) {
509
- var tokens = input.match(singleMatcher) || [];
510
- for (var i = 1; i < tokens.length; i++) {
511
- input = decodeComponents(tokens, i).join('');
512
- tokens = input.match(singleMatcher) || [];
513
- }
514
- return input;
515
- }
516
- }
517
- function customDecodeURIComponent(input) {
518
- // Keep track of all the replacements and prefill the map with the `BOM`
519
- var replaceMap = {
520
- '%FE%FF': "\uFFFD\uFFFD",
521
- '%FF%FE': "\uFFFD\uFFFD"
522
- };
523
- var match = multiMatcher.exec(input);
524
- while (match) {
525
- try {
526
- // Decode as big chunks as possible
527
- replaceMap[match[0]] = decodeURIComponent(match[0]);
528
- } catch (_unused3) {
529
- var result = decode$1(match[0]);
530
- if (result !== match[0]) {
531
- replaceMap[match[0]] = result;
532
- }
533
- }
534
- match = multiMatcher.exec(input);
535
- }
536
-
537
- // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
538
- replaceMap['%C2'] = "\uFFFD";
539
- var entries = Object.keys(replaceMap);
540
- for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
541
- var key = _entries[_i];
542
- // Replace all decoded components
543
- input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
544
- }
545
- return input;
546
- }
547
- function decodeUriComponent(encodedURI) {
548
- if (typeof encodedURI !== 'string') {
549
- throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + _typeof(encodedURI) + '`');
550
- }
551
- try {
552
- // Try the built in decoder first
553
- return decodeURIComponent(encodedURI);
554
- } catch (_unused4) {
555
- // Fallback to a more advanced decoder
556
- return customDecodeURIComponent(encodedURI);
557
- }
558
- }
559
-
560
- function splitOnFirst(string, separator) {
561
- if (!(typeof string === 'string' && typeof separator === 'string')) {
562
- throw new TypeError('Expected the arguments to be of type `string`');
563
- }
564
- if (string === '' || separator === '') {
565
- return [];
566
- }
567
- var separatorIndex = string.indexOf(separator);
568
- if (separatorIndex === -1) {
569
- return [];
570
- }
571
- return [string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length)];
572
- }
573
-
574
- function includeKeys(object, predicate) {
575
- var result = {};
576
- if (Array.isArray(predicate)) {
577
- var _iterator = _createForOfIteratorHelper(predicate),
578
- _step;
579
- try {
580
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
581
- var key = _step.value;
582
- var descriptor = Object.getOwnPropertyDescriptor(object, key);
583
- if (descriptor !== null && descriptor !== void 0 && descriptor.enumerable) {
584
- Object.defineProperty(result, key, descriptor);
585
- }
586
- }
587
- } catch (err) {
588
- _iterator.e(err);
589
- } finally {
590
- _iterator.f();
591
- }
592
- } else {
593
- // `Reflect.ownKeys()` is required to retrieve symbol properties
594
- var _iterator2 = _createForOfIteratorHelper(Reflect.ownKeys(object)),
595
- _step2;
596
- try {
597
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
598
- var _key = _step2.value;
599
- var _descriptor = Object.getOwnPropertyDescriptor(object, _key);
600
- if (_descriptor.enumerable) {
601
- var value = object[_key];
602
- if (predicate(_key, value, object)) {
603
- Object.defineProperty(result, _key, _descriptor);
604
- }
605
- }
606
- }
607
- } catch (err) {
608
- _iterator2.e(err);
609
- } finally {
610
- _iterator2.f();
611
- }
612
- }
613
- return result;
614
- }
615
-
616
- const isNullOrUndefined = value => value === null || value === undefined;
210
+ const isNullOrUndefined = value => value === null || value === undefined;
617
211
 
618
212
  // eslint-disable-next-line unicorn/prefer-code-point
619
213
  const strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
@@ -1117,31 +711,852 @@ function pick(input, filter, options) {
1117
711
  ...options,
1118
712
  };
1119
713
 
1120
- const {url, query, fragmentIdentifier} = parseUrl(input, options);
714
+ const {url, query, fragmentIdentifier} = parseUrl(input, options);
715
+
716
+ return stringifyUrl({
717
+ url,
718
+ query: includeKeys(query, filter),
719
+ fragmentIdentifier,
720
+ }, options);
721
+ }
722
+
723
+ function exclude(input, filter, options) {
724
+ const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
725
+
726
+ return pick(input, exclusionFilter, options);
727
+ }
728
+
729
+ var queryString = /*#__PURE__*/Object.freeze({
730
+ __proto__: null,
731
+ exclude: exclude,
732
+ extract: extract,
733
+ parse: parse,
734
+ parseUrl: parseUrl,
735
+ pick: pick,
736
+ stringify: stringify,
737
+ stringifyUrl: stringifyUrl
738
+ });
739
+
740
+ var _excluded$3 = ["store", "url", "paginated", "query", "onQueryChange", "queryConfig", "keepData"],
741
+ _excluded2$1 = ["page", "count"],
742
+ _excluded3 = ["data", "refetch", "isLoading", "isFetched", "status", "error"];
743
+ var useItems$2 = function useItems(_ref) {
744
+ var store = _ref.store,
745
+ url = _ref.url,
746
+ _ref$paginated = _ref.paginated,
747
+ initialPaginated = _ref$paginated === void 0 ? false : _ref$paginated,
748
+ _ref$query = _ref.query,
749
+ initialQuery = _ref$query === void 0 ? null : _ref$query,
750
+ onQueryChange = _ref.onQueryChange,
751
+ _ref$queryConfig = _ref.queryConfig,
752
+ queryConfig = _ref$queryConfig === void 0 ? null : _ref$queryConfig,
753
+ _ref$keepData = _ref.keepData,
754
+ keepData = _ref$keepData === void 0 ? true : _ref$keepData,
755
+ oldProps = _objectWithoutProperties(_ref, _excluded$3);
756
+ // Legacy
757
+ var _ref2 = oldProps || {},
758
+ _ref2$getPage = _ref2.getPage,
759
+ getPage = _ref2$getPage === void 0 ? null : _ref2$getPage,
760
+ _ref2$getItems = _ref2.getItems,
761
+ getItems = _ref2$getItems === void 0 ? null : _ref2$getItems,
762
+ _ref2$page = _ref2.page,
763
+ oldPage = _ref2$page === void 0 ? null : _ref2$page,
764
+ _ref2$count = _ref2.count,
765
+ oldCount = _ref2$count === void 0 ? null : _ref2$count,
766
+ _ref2$items = _ref2.items,
767
+ providedItems = _ref2$items === void 0 ? null : _ref2$items,
768
+ _ref2$pages = _ref2.pages,
769
+ initialPages = _ref2$pages === void 0 ? null : _ref2$pages,
770
+ _ref2$getPageFromResp = _ref2.getPageFromResponse,
771
+ getPageFromResponse = _ref2$getPageFromResp === void 0 ? function () {
772
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
773
+ _ref3$pagination = _ref3.pagination,
774
+ _ref3$pagination$page = _ref3$pagination.page,
775
+ currentPage = _ref3$pagination$page === void 0 ? null : _ref3$pagination$page,
776
+ _ref3$pagination$last = _ref3$pagination.last_page,
777
+ lastPage = _ref3$pagination$last === void 0 ? null : _ref3$pagination$last,
778
+ _ref3$pagination$tota = _ref3$pagination.total,
779
+ total = _ref3$pagination$tota === void 0 ? null : _ref3$pagination$tota,
780
+ _ref3$pagination$per_ = _ref3$pagination.per_page,
781
+ perPage = _ref3$pagination$per_ === void 0 ? null : _ref3$pagination$per_,
782
+ _ref3$data = _ref3.data,
783
+ items = _ref3$data === void 0 ? null : _ref3$data;
784
+ return {
785
+ page: parseInt(currentPage, 10),
786
+ lastPage: parseInt(lastPage, 10),
787
+ total: parseInt(total, 10),
788
+ count: parseInt(perPage, 10),
789
+ items: items
790
+ };
791
+ } : _ref2$getPageFromResp,
792
+ _ref2$getItemsFromRes = _ref2.getItemsFromResponse,
793
+ getItemsFromResponse = _ref2$getItemsFromRes === void 0 ? function (data) {
794
+ return data;
795
+ } : _ref2$getItemsFromRes,
796
+ _ref2$onItemsLoaded = _ref2.onItemsLoaded,
797
+ onItemsLoaded = _ref2$onItemsLoaded === void 0 ? null : _ref2$onItemsLoaded,
798
+ _ref2$onPageLoaded = _ref2.onPageLoaded,
799
+ onPageLoaded = _ref2$onPageLoaded === void 0 ? null : _ref2$onPageLoaded,
800
+ _ref2$onLoaded = _ref2.onLoaded,
801
+ onLoaded = _ref2$onLoaded === void 0 ? null : _ref2$onLoaded,
802
+ _ref2$onError = _ref2.onError,
803
+ onError = _ref2$onError === void 0 ? null : _ref2$onError;
804
+ var paginated = React.useMemo(function () {
805
+ return getPage !== null || initialPages !== null || initialPaginated;
806
+ }, [getPage, initialPages, initialPaginated]);
807
+ var query = React.useMemo(function () {
808
+ // Backwards compatible
809
+ if (oldPage !== null || oldCount !== null) {
810
+ return _objectSpread({
811
+ page: oldPage,
812
+ count: oldCount
813
+ }, initialQuery);
814
+ }
815
+ return initialQuery;
816
+ }, [initialQuery]);
817
+ var _ref4 = query || {},
818
+ _ref4$page = _ref4.page,
819
+ page = _ref4$page === void 0 ? null : _ref4$page,
820
+ _ref4$count = _ref4.count,
821
+ count = _ref4$count === void 0 ? null : _ref4$count,
822
+ queryWithoutPageAndCount = _objectWithoutProperties(_ref4, _excluded2$1);
823
+ var queryKey = React.useMemo(function () {
824
+ return paginated && getPage !== null ? [store, page, count || 10, queryWithoutPageAndCount] : [store, query];
825
+ }, [paginated, page, count, queryWithoutPageAndCount]);
826
+ var _useQuery = reactQuery.useQuery(_objectSpread(_objectSpread(_objectSpread({
827
+ queryKey: queryKey,
828
+ queryFn: function queryFn(_ref5) {
829
+ var key = _ref5.queryKey;
830
+ if (paginated && getPage !== null) {
831
+ var _key = _slicedToArray(key, 4),
832
+ _key$ = _key[1],
833
+ p = _key$ === void 0 ? null : _key$,
834
+ _key$2 = _key[2],
835
+ c = _key$2 === void 0 ? null : _key$2,
836
+ _key$3 = _key[3],
837
+ _q = _key$3 === void 0 ? null : _key$3;
838
+ return getPage(p, c, _q);
839
+ }
840
+ if (!paginated && getItems !== null) {
841
+ var _key2 = _slicedToArray(key, 2),
842
+ _key2$ = _key2[1],
843
+ _q2 = _key2$ === void 0 ? null : _key2$;
844
+ return getItems(_q2);
845
+ }
846
+ var _key3 = _slicedToArray(key, 2),
847
+ _key3$ = _key3[1],
848
+ q = _key3$ === void 0 ? null : _key3$;
849
+ return fetch$1.getJSON("".concat(url).concat(!isEmpty(q) ? "?".concat(queryString.stringify(q, {
850
+ arrayFormat: 'bracket'
851
+ })) : ''));
852
+ }
853
+ }, keepData ? {
854
+ placeholderData: reactQuery.keepPreviousData
855
+ } : null), providedItems !== null ? {
856
+ initialData: providedItems
857
+ } : null), queryConfig)),
858
+ _useQuery$data = _useQuery.data,
859
+ data = _useQuery$data === void 0 ? null : _useQuery$data,
860
+ reload = _useQuery.refetch,
861
+ loading = _useQuery.isLoading,
862
+ loaded = _useQuery.isFetched,
863
+ _useQuery$status = _useQuery.status,
864
+ status = _useQuery$status === void 0 ? null : _useQuery$status,
865
+ _useQuery$error = _useQuery.error,
866
+ error = _useQuery$error === void 0 ? null : _useQuery$error,
867
+ otherProps = _objectWithoutProperties(_useQuery, _excluded3);
868
+ var _ref6 = data || {},
869
+ _ref6$data = _ref6.data,
870
+ items = _ref6$data === void 0 ? [] : _ref6$data,
871
+ _ref6$pagination = _ref6.pagination,
872
+ pagination = _ref6$pagination === void 0 ? null : _ref6$pagination;
873
+ var _ref7 = pagination || {},
874
+ _ref7$page = _ref7.page,
875
+ currentPage = _ref7$page === void 0 ? null : _ref7$page,
876
+ _ref7$last_page = _ref7.last_page,
877
+ lastPage = _ref7$last_page === void 0 ? null : _ref7$last_page,
878
+ _ref7$total = _ref7.total,
879
+ total = _ref7$total === void 0 ? null : _ref7$total;
880
+ var loadNextPage = React.useCallback(function () {
881
+ if (onQueryChange !== null && paginated && page !== null && page < lastPage) {
882
+ onQueryChange(_objectSpread(_objectSpread({}, query), {}, {
883
+ page: page + 1
884
+ }));
885
+ }
886
+ }, [paginated, pagination, page]);
887
+ var loadPage = React.useCallback(function (newPage) {
888
+ if (onQueryChange !== null && newPage !== null) {
889
+ onQueryChange(_objectSpread(_objectSpread({}, query), {}, {
890
+ page: newPage
891
+ }));
892
+ }
893
+ }, [query, onQueryChange]);
894
+ var pages = React.useRef(null);
895
+ React.useEffect(function () {
896
+ if (loaded && page !== null && data !== null) {
897
+ pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
898
+ }
899
+ }, [loaded, page, data]);
900
+ var finalItems = React.useMemo(function () {
901
+ if (data === null) {
902
+ return data;
903
+ }
904
+ if (paginated) {
905
+ if (getPageFromResponse !== null) {
906
+ return items;
907
+ }
908
+ return items;
909
+ }
910
+ if (getItemsFromResponse !== null) {
911
+ return getItemsFromResponse(data);
912
+ }
913
+ return data;
914
+ }, [items, data, paginated, getPageFromResponse, getItemsFromResponse]);
915
+
916
+ // Pseudo-events for compatibility
917
+ React.useEffect(function () {
918
+ if (status === 'success') {
919
+ if (onPageLoaded !== null && paginated) {
920
+ onItemsLoaded(data);
921
+ }
922
+ if (onItemsLoaded !== null && !paginated) {
923
+ onItemsLoaded(data);
924
+ }
925
+ if (onLoaded !== null) {
926
+ onLoaded(data);
927
+ }
928
+ }
929
+ if (status === 'error' && onError !== null) {
930
+ onError(error);
931
+ }
932
+ }, [status]);
933
+ var allItems = pages.current !== null ? Object.keys(pages.current).flatMap(function (k) {
934
+ var _pages$current$k;
935
+ return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
936
+ }) : null;
937
+ return _objectSpread(_objectSpread({}, otherProps), {}, {
938
+ items: finalItems,
939
+ allItems: allItems,
940
+ pages: pages.current,
941
+ pageItems: paginated ? finalItems : null,
942
+ pagination: paginated ? {
943
+ page: currentPage,
944
+ lastPage: lastPage,
945
+ total: total
946
+ } : null,
947
+ total: total,
948
+ lastPage: lastPage,
949
+ loaded: loaded,
950
+ allLoaded: paginated && pages.current !== null && Object.keys(pages.current).length === lastPage || !paginated && loaded,
951
+ // very basic stuff, TODO
952
+ loading: loading,
953
+ loadNextPage: loadNextPage,
954
+ loadPage: loadPage,
955
+ reloadPage: reload,
956
+ reload: reload,
957
+ reset: reload,
958
+ updateItem: null,
959
+ status: status,
960
+ error: error
961
+ });
962
+ };
963
+ var useItems$3 = useItems$2;
964
+
965
+ var useItems = function useItems(_ref) {
966
+ var _ref$getPage = _ref.getPage,
967
+ getPage = _ref$getPage === void 0 ? null : _ref$getPage,
968
+ _ref$getItems = _ref.getItems,
969
+ getItems = _ref$getItems === void 0 ? null : _ref$getItems,
970
+ _ref$page = _ref.page,
971
+ page = _ref$page === void 0 ? null : _ref$page,
972
+ _ref$count = _ref.count,
973
+ count = _ref$count === void 0 ? 10 : _ref$count,
974
+ _ref$items = _ref.items,
975
+ providedItems = _ref$items === void 0 ? null : _ref$items,
976
+ _ref$pages = _ref.pages,
977
+ initialPages = _ref$pages === void 0 ? null : _ref$pages,
978
+ _ref$getPageFromRespo = _ref.getPageFromResponse,
979
+ getPageFromResponse = _ref$getPageFromRespo === void 0 ? function (_ref2) {
980
+ var _ref2$pagination = _ref2.pagination,
981
+ currentPage = _ref2$pagination.page,
982
+ lastPage = _ref2$pagination.last_page,
983
+ total = _ref2$pagination.total,
984
+ perPage = _ref2$pagination.per_page,
985
+ items = _ref2.data;
986
+ return {
987
+ page: parseInt(currentPage, 10),
988
+ lastPage: parseInt(lastPage, 10),
989
+ total: parseInt(total, 10),
990
+ count: parseInt(perPage, 10),
991
+ items: items
992
+ };
993
+ } : _ref$getPageFromRespo,
994
+ _ref$getItemsFromResp = _ref.getItemsFromResponse,
995
+ getItemsFromResponse = _ref$getItemsFromResp === void 0 ? function (data) {
996
+ return data;
997
+ } : _ref$getItemsFromResp,
998
+ _ref$onItemsLoaded = _ref.onItemsLoaded,
999
+ onItemsLoaded = _ref$onItemsLoaded === void 0 ? null : _ref$onItemsLoaded,
1000
+ _ref$onPageLoaded = _ref.onPageLoaded,
1001
+ onPageLoaded = _ref$onPageLoaded === void 0 ? null : _ref$onPageLoaded,
1002
+ _ref$onLoaded = _ref.onLoaded,
1003
+ onLoaded = _ref$onLoaded === void 0 ? null : _ref$onLoaded,
1004
+ _ref$onError = _ref.onError,
1005
+ onError = _ref$onError === void 0 ? null : _ref$onError;
1006
+ var isPaginated = getPage !== null || initialPages !== null;
1007
+ var lastState = React.useRef(null);
1008
+ var initialState = React.useMemo(function () {
1009
+ var finalInitialPages = initialPages !== null ? initialPages.map(function (it) {
1010
+ return getPageFromResponse(it);
1011
+ }) : null;
1012
+ return {
1013
+ lastPage: finalInitialPages !== null ? finalInitialPages.reduce(function (currentLastPage, _ref3) {
1014
+ var initialLastPage = _ref3.lastPage;
1015
+ return initialLastPage > currentLastPage ? initialLastPage : currentLastPage;
1016
+ }, -1) : -1,
1017
+ total: finalInitialPages !== null ? finalInitialPages[0].total : (providedItems || []).length,
1018
+ loaded: providedItems !== null,
1019
+ loading: false,
1020
+ pages: finalInitialPages !== null ? finalInitialPages : null,
1021
+ items: null
1022
+ };
1023
+ }, [initialPages, providedItems]);
1024
+ var _useState = React.useState(initialState),
1025
+ _useState2 = _slicedToArray(_useState, 2),
1026
+ state = _useState2[0],
1027
+ setState = _useState2[1];
1028
+ var lastPage = state.lastPage,
1029
+ loaded = state.loaded,
1030
+ loading = state.loading,
1031
+ stateItems = state.items,
1032
+ pages = state.pages,
1033
+ total = state.total;
1034
+ var items = providedItems || (isPaginated && pages !== null ? pages.reduce(function (pagesItems, _ref4) {
1035
+ var pageItems = _ref4.items;
1036
+ return pagesItems.concat(pageItems);
1037
+ }, []) : stateItems) || null;
1038
+ var updateState = function updateState(update) {
1039
+ return setState(_objectSpread(_objectSpread({}, state), update));
1040
+ };
1041
+ var updateFromResponse = function updateFromResponse(response) {
1042
+ var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1043
+ var reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1044
+ if (error !== null) {
1045
+ updateState({
1046
+ loaded: false,
1047
+ loading: false
1048
+ });
1049
+ throw error;
1050
+ }
1051
+ if (isPaginated) {
1052
+ var newPage = getPageFromResponse(response);
1053
+ var newPages = (reset ? [newPage] : [].concat(_toConsumableArray((pages || []).filter(function (it) {
1054
+ return it.page !== newPage.page;
1055
+ })), [newPage])).sort(function (a, b) {
1056
+ if (a === b) {
1057
+ return 0;
1058
+ }
1059
+ return a > b ? 1 : -1;
1060
+ });
1061
+ updateState({
1062
+ loaded: true,
1063
+ loading: false,
1064
+ lastPage: newPage.lastPage,
1065
+ total: newPage.total,
1066
+ pages: newPages
1067
+ });
1068
+ return newPage;
1069
+ }
1070
+ var newItems = _toConsumableArray(getItemsFromResponse(response));
1071
+ updateState({
1072
+ loaded: true,
1073
+ loading: false,
1074
+ items: newItems,
1075
+ total: newItems.length
1076
+ });
1077
+ return newItems;
1078
+ };
1079
+ var getNextPage = function getNextPage() {
1080
+ var allPages = lastPage !== -1 ? Array.call.apply(Array, [null].concat(_toConsumableArray(Array(lastPage)))).map(function (it, index) {
1081
+ return index + 1;
1082
+ }) : [];
1083
+ var remainingPages = allPages.filter(function (pageNumber) {
1084
+ return pages.findIndex(function (it) {
1085
+ return it.page === pageNumber;
1086
+ }) === -1;
1087
+ });
1088
+ var firstItem = remainingPages.length > 0 ? remainingPages.shift() : null;
1089
+ return firstItem !== null ? firstItem : null;
1090
+ };
1091
+ var loadItems = function loadItems(requestPage) {
1092
+ updateState({
1093
+ loading: true
1094
+ });
1095
+ var canceled = false;
1096
+ var request = isPaginated ? getPage(requestPage, count) : getItems();
1097
+ var promise = request.then(function (response) {
1098
+ return !canceled ? updateFromResponse(response) : Promise.reject();
1099
+ })["catch"](function (error) {
1100
+ return !canceled ? updateFromResponse(null, error) : Promise.reject();
1101
+ }).then(function (response) {
1102
+ if (isPaginated && onPageLoaded !== null) {
1103
+ onPageLoaded(response);
1104
+ } else if (!isPaginated && onItemsLoaded !== null) {
1105
+ onItemsLoaded(response);
1106
+ }
1107
+ if (onLoaded !== null) {
1108
+ onLoaded(response);
1109
+ }
1110
+ return response;
1111
+ })["catch"](function (error) {
1112
+ if (!canceled && onError !== null) {
1113
+ onError(error);
1114
+ }
1115
+ });
1116
+ promise.cancel = function () {
1117
+ canceled = true;
1118
+ };
1119
+ return promise;
1120
+ };
1121
+ var loadPage = function loadPage(pageToLoad) {
1122
+ if (loading) {
1123
+ return Promise.reject();
1124
+ }
1125
+ if (pages.find(function (it) {
1126
+ return it.page === pageToLoad;
1127
+ }) !== -1) {
1128
+ return Promise.reject();
1129
+ }
1130
+ return loadItems(pageToLoad);
1131
+ };
1132
+ var loadNextPage = function loadNextPage() {
1133
+ if (loading) {
1134
+ return Promise.reject();
1135
+ }
1136
+ var nextPage = getNextPage();
1137
+ return nextPage !== null ? loadItems(nextPage) : Promise.resolve();
1138
+ };
1139
+ var reloadPage = function reloadPage() {
1140
+ if (loading) {
1141
+ return Promise.reject();
1142
+ }
1143
+ return loadItems(page);
1144
+ };
1145
+ var reload = function reload() {
1146
+ if (loading) {
1147
+ return Promise.reject();
1148
+ }
1149
+ return loadItems();
1150
+ };
1151
+ var reset = React.useCallback(function () {
1152
+ setState({
1153
+ loaded: false,
1154
+ loading: false,
1155
+ lastPage: -1,
1156
+ total: 0,
1157
+ pages: null,
1158
+ items: null
1159
+ });
1160
+ }, [page, setState]);
1161
+ var updateItem = function updateItem(newItem) {
1162
+ if (loading) {
1163
+ return;
1164
+ }
1165
+ if (isPaginated) {
1166
+ var currentPages = pages || [];
1167
+ updateState({
1168
+ pages: currentPages.map(function (pageData) {
1169
+ var pageItems = pageData.items || [];
1170
+ if (pageItems.findIndex(function (_ref5) {
1171
+ var id = _ref5.id;
1172
+ return id === newItem.id;
1173
+ }) !== -1) {
1174
+ return _objectSpread(_objectSpread({}, pageData), {}, {
1175
+ items: pageItems.map(function (it) {
1176
+ return it.id === newItem.id ? newItem : it;
1177
+ })
1178
+ });
1179
+ }
1180
+ return pageData;
1181
+ })
1182
+ });
1183
+ } else {
1184
+ var currentItems = items || [];
1185
+ updateState({
1186
+ items: currentItems.map(function (it) {
1187
+ return it.id === newItem.id ? newItem : it;
1188
+ })
1189
+ });
1190
+ }
1191
+ };
1192
+ React.useEffect(function () {
1193
+ var hadState = lastState.current !== null;
1194
+ lastState.current = initialState;
1195
+ if (hadState) {
1196
+ setState(initialState);
1197
+ }
1198
+ }, [initialState]);
1199
+ React.useEffect(function () {
1200
+ if (getPage === null && getItems === null || providedItems !== null) {
1201
+ return function () {};
1202
+ }
1203
+ var loadPromise = null;
1204
+ var pageToLoad = isPaginated && initialPages === null && page === null ? 1 : page;
1205
+ if (!isPaginated || pageToLoad !== null) {
1206
+ loadPromise = loadItems(pageToLoad);
1207
+ }
1208
+ return function () {
1209
+ if (loadPromise !== null) {
1210
+ loadPromise.cancel();
1211
+ }
1212
+ };
1213
+ }, [getPage, getItems, page]);
1214
+ var currentPage = isPaginated && pages !== null ? pages.find(function (_ref6) {
1215
+ var pageNumber = _ref6.page;
1216
+ return parseInt(pageNumber, 10) === parseInt(page, 10);
1217
+ }) || null : null;
1218
+ return {
1219
+ items: items,
1220
+ pages: pages,
1221
+ pageItems: currentPage !== null ? currentPage.items : null,
1222
+ total: total,
1223
+ lastPage: lastPage,
1224
+ loaded: loaded,
1225
+ allLoaded: !isPaginated && loaded || lastPage !== -1 && isPaginated && pages.length === lastPage,
1226
+ loading: loading,
1227
+ loadNextPage: loadNextPage,
1228
+ loadPage: loadPage,
1229
+ reloadPage: reloadPage,
1230
+ reload: reload,
1231
+ reset: reset,
1232
+ updateItem: updateItem
1233
+ };
1234
+ };
1235
+ var useItems$1 = useItems;
1236
+
1237
+ var _excluded$2 = ["page", "count"],
1238
+ _excluded2 = ["data", "refetch", "isLoading", "isFetched"];
1239
+ var useItemsStore = function useItemsStore(store, _ref) {
1240
+ var _ref$url = _ref.url,
1241
+ url = _ref$url === void 0 ? null : _ref$url,
1242
+ _ref$getPage = _ref.getPage,
1243
+ getPage = _ref$getPage === void 0 ? null : _ref$getPage,
1244
+ _ref$getItems = _ref.getItems,
1245
+ getItems = _ref$getItems === void 0 ? null : _ref$getItems,
1246
+ _ref$getPageFromRespo = _ref.getPageFromResponse,
1247
+ getPageFromResponse = _ref$getPageFromRespo === void 0 ? null : _ref$getPageFromRespo,
1248
+ _ref$getItemsFromResp = _ref.getItemsFromResponse,
1249
+ getItemsFromResponse = _ref$getItemsFromResp === void 0 ? null : _ref$getItemsFromResp,
1250
+ _ref$page = _ref.page,
1251
+ initialPage = _ref$page === void 0 ? null : _ref$page,
1252
+ _ref$count = _ref.count,
1253
+ initialCount = _ref$count === void 0 ? null : _ref$count,
1254
+ _ref$query = _ref.query,
1255
+ query = _ref$query === void 0 ? null : _ref$query,
1256
+ _ref$onQueryChange = _ref.onQueryChange,
1257
+ onQueryChange = _ref$onQueryChange === void 0 ? null : _ref$onQueryChange,
1258
+ _ref$queryConfig = _ref.queryConfig,
1259
+ queryConfig = _ref$queryConfig === void 0 ? null : _ref$queryConfig,
1260
+ _ref$keepData = _ref.keepData,
1261
+ keepData = _ref$keepData === void 0 ? true : _ref$keepData;
1262
+ var _ref2 = query || {},
1263
+ _ref2$page = _ref2.page,
1264
+ page = _ref2$page === void 0 ? initialPage : _ref2$page,
1265
+ _ref2$count = _ref2.count,
1266
+ count = _ref2$count === void 0 ? initialCount : _ref2$count,
1267
+ queryWithoutPage = _objectWithoutProperties(_ref2, _excluded$2);
1268
+ var paginated = page !== null;
1269
+ var queryKey = React.useMemo(function () {
1270
+ return paginated ? [store, page || 1, count || 12, queryWithoutPage] : [store, query];
1271
+ }, [paginated, store, page, count, query, queryWithoutPage, getPage, getItems]);
1272
+
1273
+ // console.log('queryKey', queryKey, 'paginated', paginated);
1274
+
1275
+ var _useQuery = reactQuery.useQuery(_objectSpread(_objectSpread({
1276
+ queryKey: queryKey,
1277
+ queryFn: function queryFn(_ref3) {
1278
+ var _ref3$queryKey = _ref3.queryKey,
1279
+ key = _ref3$queryKey === void 0 ? null : _ref3$queryKey;
1280
+ if (paginated && getPage !== null) {
1281
+ var _key = _slicedToArray(key, 4),
1282
+ _key$ = _key[1],
1283
+ p = _key$ === void 0 ? null : _key$,
1284
+ _key$2 = _key[2],
1285
+ c = _key$2 === void 0 ? null : _key$2,
1286
+ _key$3 = _key[3],
1287
+ _q = _key$3 === void 0 ? null : _key$3;
1288
+ return getPage(p, c, _q);
1289
+ }
1290
+ if (!paginated && getItems !== null) {
1291
+ var _key2 = _slicedToArray(key, 2),
1292
+ _key2$ = _key2[1],
1293
+ _q2 = _key2$ === void 0 ? null : _key2$;
1294
+ return getItems(_q2);
1295
+ }
1296
+ var _key3 = _slicedToArray(key, 2),
1297
+ _key3$ = _key3[1],
1298
+ q = _key3$ === void 0 ? null : _key3$;
1299
+ return fetch$1.getJSON("".concat(url).concat(!isEmpty(q) ? "?".concat(queryString.stringify(q, {
1300
+ arrayFormat: 'bracket'
1301
+ })) : ''));
1302
+ }
1303
+ }, keepData ? {
1304
+ placeholderData: reactQuery.keepPreviousData
1305
+ } : null), queryConfig)),
1306
+ _useQuery$data = _useQuery.data,
1307
+ data = _useQuery$data === void 0 ? null : _useQuery$data,
1308
+ reload = _useQuery.refetch,
1309
+ loading = _useQuery.isLoading,
1310
+ loaded = _useQuery.isFetched,
1311
+ otherProps = _objectWithoutProperties(_useQuery, _excluded2);
1312
+ var _ref4 = data || {},
1313
+ _ref4$data = _ref4.data,
1314
+ items = _ref4$data === void 0 ? [] : _ref4$data,
1315
+ _ref4$pagination = _ref4.pagination,
1316
+ pagination = _ref4$pagination === void 0 ? null : _ref4$pagination,
1317
+ _ref4$metadata = _ref4.metadata,
1318
+ metadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
1319
+ var _ref5 = pagination || metadata || {},
1320
+ _ref5$page = _ref5.page,
1321
+ currentPage = _ref5$page === void 0 ? null : _ref5$page,
1322
+ _ref5$last_page = _ref5.last_page,
1323
+ lastPage = _ref5$last_page === void 0 ? 0 : _ref5$last_page,
1324
+ _ref5$total = _ref5.total,
1325
+ total = _ref5$total === void 0 ? null : _ref5$total;
1326
+ var loadNextPage = React.useCallback(function () {
1327
+ if (onQueryChange !== null && paginated && page !== null && page < lastPage) {
1328
+ onQueryChange(_objectSpread(_objectSpread({}, query), {}, {
1329
+ page: page + 1
1330
+ }));
1331
+ }
1332
+ }, [paginated, pagination, page]);
1333
+ var loadPage = React.useCallback(function (newPage) {
1334
+ if (onQueryChange !== null && newPage !== null) {
1335
+ onQueryChange(_objectSpread(_objectSpread({}, query), {}, {
1336
+ page: newPage
1337
+ }));
1338
+ }
1339
+ }, [query, onQueryChange]);
1121
1340
 
1122
- return stringifyUrl({
1123
- url,
1124
- query: includeKeys(query, filter),
1125
- fragmentIdentifier,
1126
- }, options);
1127
- }
1341
+ // Keep a list of updated items
1342
+ var _useState = React.useState([]),
1343
+ _useState2 = _slicedToArray(_useState, 2),
1344
+ updatedItems = _useState2[0],
1345
+ setUpdatedItems = _useState2[1];
1346
+ var updateItem = React.useCallback(function (item) {
1347
+ var _ref6 = item || {},
1348
+ _ref6$id = _ref6.id,
1349
+ itemId = _ref6$id === void 0 ? null : _ref6$id;
1350
+ if (itemId !== null) {
1351
+ setUpdatedItems([].concat(_toConsumableArray((items || []).filter(function () {
1352
+ var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1353
+ _ref7$id = _ref7.id,
1354
+ id = _ref7$id === void 0 ? null : _ref7$id;
1355
+ return id !== itemId;
1356
+ })), [item]));
1357
+ }
1358
+ }, [items, updatedItems, setUpdatedItems]);
1359
+ var replaceUpdatedItems = React.useCallback(function (currentItems) {
1360
+ if (currentItems === null || updatedItems === null || updatedItems.length === 0) {
1361
+ return currentItems;
1362
+ }
1363
+ return (currentItems || []).map(function (item) {
1364
+ var _ref8 = item || {},
1365
+ _ref8$id = _ref8.id,
1366
+ itemId = _ref8$id === void 0 ? null : _ref8$id;
1367
+ var updated = (updatedItems || []).find(function () {
1368
+ var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1369
+ _ref9$id = _ref9.id,
1370
+ id = _ref9$id === void 0 ? null : _ref9$id;
1371
+ return id === itemId;
1372
+ }) || null;
1373
+ if (updated !== null) {
1374
+ return updated;
1375
+ }
1376
+ return item;
1377
+ }, []);
1378
+ }, [updatedItems]);
1379
+ var partialItems = React.useMemo(function () {
1380
+ if (data === null) {
1381
+ return data;
1382
+ }
1383
+ if (paginated) {
1384
+ if (getPageFromResponse !== null) {
1385
+ return getPageFromResponse(items);
1386
+ }
1387
+ return items;
1388
+ }
1389
+ if (getItemsFromResponse !== null) {
1390
+ return getItemsFromResponse(data);
1391
+ }
1392
+ return data;
1393
+ }, [items, data, paginated, getPageFromResponse, getItemsFromResponse, updatedItems]);
1394
+ var finalItems = replaceUpdatedItems(partialItems);
1395
+
1396
+ // Keep a list of pages, useEffect wont work here because delayed
1397
+ var pages = React.useRef(null);
1398
+ if (loaded && page !== null && data !== null) {
1399
+ pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
1400
+ }
1401
+ var allItems = pages.current !== null ? replaceUpdatedItems(Object.keys(pages.current).flatMap(function (k) {
1402
+ var _pages$current$k;
1403
+ return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
1404
+ })) : finalItems;
1405
+ return _objectSpread(_objectSpread({}, otherProps), {}, {
1406
+ items: finalItems,
1407
+ pages: pages.current,
1408
+ allItems: allItems,
1409
+ loading: loading,
1410
+ loaded: loaded,
1411
+ reload: reload,
1412
+ loadPage: loadPage,
1413
+ loadNextPage: loadNextPage,
1414
+ updateItem: updateItem,
1415
+ pagination: paginated ? {
1416
+ page: currentPage,
1417
+ lastPage: lastPage,
1418
+ total: total
1419
+ } : null
1420
+ });
1421
+ };
1422
+ var useItemsStore$1 = useItemsStore;
1128
1423
 
1129
- function exclude(input, filter, options) {
1130
- const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
1424
+ var AccountApi = /*#__PURE__*/function () {
1425
+ function AccountApi(api, opts) {
1426
+ _classCallCheck(this, AccountApi);
1427
+ this.api = api;
1428
+ this.options = _objectSpread({
1429
+ withCredentials: false
1430
+ }, opts);
1431
+ }
1432
+ return _createClass(AccountApi, [{
1433
+ key: "update",
1434
+ value: function update(data) {
1435
+ var withCredentials = this.options.withCredentials;
1436
+ return this.api.requestPost(this.api.route('account'), data, {
1437
+ withSession: !withCredentials,
1438
+ withCredentials: withCredentials
1439
+ });
1440
+ }
1441
+ }, {
1442
+ key: "updatePassword",
1443
+ value: function updatePassword(data) {
1444
+ var withCredentials = this.options.withCredentials;
1445
+ return this.api.requestPost(this.api.route('account.password'), data, {
1446
+ withSession: !withCredentials,
1447
+ withCredentials: withCredentials
1448
+ });
1449
+ }
1450
+ }, {
1451
+ key: "updateTaxes",
1452
+ value: function updateTaxes(data) {
1453
+ var withCredentials = this.options.withCredentials;
1454
+ return this.api.requestPost(this.api.route('account.taxes'), data, {
1455
+ withSession: !withCredentials,
1456
+ withCredentials: withCredentials
1457
+ });
1458
+ }
1459
+ }, {
1460
+ key: "delete",
1461
+ value: function _delete(data) {
1462
+ var withCredentials = this.options.withCredentials;
1463
+ return this.api.requestPost(this.api.route('account.delete'), data, {
1464
+ withSession: !withCredentials,
1465
+ withCredentials: withCredentials
1466
+ });
1467
+ }
1468
+ }]);
1469
+ }();
1131
1470
 
1132
- return pick(input, exclusionFilter, options);
1133
- }
1471
+ var AuthApi = /*#__PURE__*/function () {
1472
+ function AuthApi(api, opts) {
1473
+ _classCallCheck(this, AuthApi);
1474
+ this.api = api;
1475
+ this.options = _objectSpread({
1476
+ withCredentials: true
1477
+ }, opts);
1478
+ }
1479
+ return _createClass(AuthApi, [{
1480
+ key: "check",
1481
+ value: function check() {
1482
+ var withCredentials = this.options.withCredentials;
1483
+ return this.api.requestGet(this.api.route('auth.check'), null, {
1484
+ withSession: !withCredentials,
1485
+ withCredentials: withCredentials
1486
+ });
1487
+ }
1488
+ }, {
1489
+ key: "login",
1490
+ value: function login(email, password) {
1491
+ var withCredentials = this.options.withCredentials;
1492
+ return this.api.requestPost(this.api.route('auth.login'), {
1493
+ email: email,
1494
+ password: password
1495
+ }, {
1496
+ withSession: !withCredentials,
1497
+ withCredentials: withCredentials
1498
+ });
1499
+ }
1500
+ }, {
1501
+ key: "register",
1502
+ value: function register(data) {
1503
+ var withCredentials = this.options.withCredentials;
1504
+ return this.api.requestPost(this.api.route('auth.register'), data, {
1505
+ withSession: !withCredentials,
1506
+ withCredentials: withCredentials
1507
+ });
1508
+ }
1509
+ }, {
1510
+ key: "logout",
1511
+ value: function logout() {
1512
+ var url = this.api.getFullUrl(this.api.route('auth.logout'));
1513
+ return fetch(url, {
1514
+ method: 'POST',
1515
+ headers: _objectSpread({}, fetch$1.getCSRFHeaders()),
1516
+ credentials: 'include'
1517
+ })["catch"](function (err) {
1518
+ console.log('logout err', err); // eslint-disable-line
1519
+ throw err;
1520
+ });
1521
+ }
1522
+ }, {
1523
+ key: "requestPassword",
1524
+ value: function requestPassword(email) {
1525
+ var withCredentials = this.options.withCredentials;
1526
+ return this.api.requestPost(this.api.route('auth.password.email'), {
1527
+ email: email
1528
+ }, {
1529
+ withSession: !withCredentials,
1530
+ withCredentials: withCredentials
1531
+ });
1532
+ }
1533
+ }, {
1534
+ key: "resetPassword",
1535
+ value: function resetPassword(data) {
1536
+ var withCredentials = this.options.withCredentials;
1537
+ return this.api.requestPost(this.api.route('auth.password.update'), data, {
1538
+ withSession: !withCredentials,
1539
+ withCredentials: withCredentials
1540
+ });
1541
+ }
1542
+ }]);
1543
+ }();
1134
1544
 
1135
- var queryString = /*#__PURE__*/Object.freeze({
1136
- __proto__: null,
1137
- exclude: exclude,
1138
- extract: extract,
1139
- parse: parse,
1140
- parseUrl: parseUrl,
1141
- pick: pick,
1142
- stringify: stringify,
1143
- stringifyUrl: stringifyUrl
1545
+ ({
1546
+ children: PropTypes.node.isRequired,
1547
+ routes: PropTypes.objectOf(PropTypes.string).isRequired,
1548
+ basePath: PropTypes.string
1144
1549
  });
1550
+ var compilers = {};
1551
+ function generatePath(fullPath, data) {
1552
+ var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1553
+ var fullUrlMatches = fullPath.match(/^(https?:\/\/)/);
1554
+ if (typeof compilers[fullPath] === 'undefined') {
1555
+ compilers[fullPath] = pathToRegexp.compile(fullPath.replace(/^(https?:\/\/)/, ''), opts);
1556
+ }
1557
+ var compiler = compilers[fullPath];
1558
+ return fullUrlMatches !== null ? "".concat(fullUrlMatches[1]).concat(compiler(data)) : compiler(data);
1559
+ }
1145
1560
 
1146
1561
  var Base = /*#__PURE__*/function () {
1147
1562
  function Base() {
@@ -1361,7 +1776,7 @@ var ResourcesApi = /*#__PURE__*/function () {
1361
1776
  value: function get(resource) {
1362
1777
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1363
1778
  var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1364
- var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
1779
+ var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 12;
1365
1780
  var finalQuery = _objectSpread({}, query);
1366
1781
  if (page !== null) {
1367
1782
  finalQuery.page = page;
@@ -1427,13 +1842,13 @@ var ApiContext = /*#__PURE__*/React.createContext(null);
1427
1842
  var useApi = function useApi() {
1428
1843
  return React.useContext(ApiContext);
1429
1844
  };
1430
- var propTypes$1 = {
1845
+ var propTypes$2 = {
1431
1846
  api: PropTypes.instanceOf(Api$1),
1432
1847
  baseUrl: PropTypes.string,
1433
1848
  onUnauthorized: PropTypes.func,
1434
1849
  children: PropTypes.node.isRequired
1435
1850
  };
1436
- var defaultProps$1 = {
1851
+ var defaultProps$2 = {
1437
1852
  api: null,
1438
1853
  onUnauthorized: null,
1439
1854
  baseUrl: undefined
@@ -1456,8 +1871,8 @@ var ApiProvider = function ApiProvider(_ref) {
1456
1871
  value: api
1457
1872
  }, children);
1458
1873
  };
1459
- ApiProvider.propTypes = propTypes$1;
1460
- ApiProvider.defaultProps = defaultProps$1;
1874
+ ApiProvider.propTypes = propTypes$2;
1875
+ ApiProvider.defaultProps = defaultProps$2;
1461
1876
 
1462
1877
  var useResourceDestroy = function useResourceDestroy(resource) {
1463
1878
  var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -1498,7 +1913,7 @@ var useResourceItem = function useResourceItem(resource, id, opts) {
1498
1913
  };
1499
1914
  var useResourceItem$1 = useResourceItem;
1500
1915
 
1501
- var _excluded = ["items", "pageItems"];
1916
+ var _excluded = ["items"];
1502
1917
  var useResourceItems = function useResourceItems(resource) {
1503
1918
  var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1504
1919
  var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
@@ -1510,7 +1925,7 @@ var useResourceItems = function useResourceItems(resource) {
1510
1925
  id = _ref$id === void 0 ? null : _ref$id;
1511
1926
  var lastResourceRef = React.useRef(id);
1512
1927
  var resourceChanging = lastResourceRef.current !== id;
1513
- var getItems = React.useCallback(function () {
1928
+ var getPage = React.useCallback(function () {
1514
1929
  var requestedPage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1515
1930
  return api.resources.get(resource, query, requestedPage, count).then(function (response) {
1516
1931
  var _ref2 = resource || {},
@@ -1524,18 +1939,30 @@ var useResourceItems = function useResourceItems(resource) {
1524
1939
  throw err;
1525
1940
  });
1526
1941
  }, [api, resource, query, count]);
1527
- var _useItems = useItems$1(_objectSpread({
1528
- getPage: page !== null ? getItems : null,
1942
+ var getItems = React.useCallback(function () {
1943
+ return api.resources.get(resource, query, null, null).then(function (response) {
1944
+ var _ref4 = resource || {},
1945
+ resourceId = _ref4.id;
1946
+ lastResourceRef.current = resourceId;
1947
+ return response;
1948
+ })["catch"](function (err) {
1949
+ var _ref5 = resource || {},
1950
+ resourceId = _ref5.id;
1951
+ lastResourceRef.current = resourceId;
1952
+ throw err;
1953
+ });
1954
+ }, [api, resource, query, count]);
1955
+ var _useItemsStore = useItemsStore$1(id, _objectSpread({
1956
+ getPage: page !== null ? getPage : null,
1529
1957
  getItems: page === null ? getItems : null,
1530
- page: page
1958
+ query: query,
1959
+ page: page,
1960
+ count: count
1531
1961
  }, opts)),
1532
- items = _useItems.items,
1533
- pageItems = _useItems.pageItems,
1534
- request = _objectWithoutProperties(_useItems, _excluded);
1535
- var finalItems = page !== null ? pageItems : items;
1962
+ items = _useItemsStore.items,
1963
+ request = _objectWithoutProperties(_useItemsStore, _excluded);
1536
1964
  return _objectSpread({
1537
- items: resourceChanging ? null : finalItems,
1538
- allItems: items
1965
+ items: resourceChanging ? null : items
1539
1966
  }, request);
1540
1967
  };
1541
1968
  var useResourceItems$1 = useResourceItems;
@@ -1586,6 +2013,46 @@ var useResourceUpdate = function useResourceUpdate(resource, id) {
1586
2013
  };
1587
2014
  var useResourceUpdate$1 = useResourceUpdate;
1588
2015
 
2016
+ var QueryContext = /*#__PURE__*/React.createContext(null);
2017
+ var useQueryContext = function useQueryContext() {
2018
+ return React.useContext(QueryContext);
2019
+ };
2020
+ var propTypes$1 = {
2021
+ config: PropTypes.shape({}),
2022
+ children: PropTypes.node.isRequired
2023
+ };
2024
+ var defaultProps$1 = {
2025
+ config: null
2026
+ };
2027
+ var QueryProvider = function QueryProvider(_ref) {
2028
+ var initialConfig = _ref.config,
2029
+ children = _ref.children;
2030
+ var queryClient = React.useMemo(function () {
2031
+ var client = new reactQuery.QueryClient(_objectSpread({
2032
+ defaultOptions: {
2033
+ queries: {
2034
+ staleTime: Infinity
2035
+ }
2036
+ }
2037
+ }, initialConfig));
2038
+ // if (page !== null) {
2039
+ // const query =
2040
+ // window && !isEmpty(window.location.search)
2041
+ // ? queryString.parse(window.location.search, {
2042
+ // arrayFormat: 'bracket',
2043
+ // })
2044
+ // : null;
2045
+ // client.setQueryData(['pages', page.url, query], page);
2046
+ // }
2047
+ return client;
2048
+ }, [initialConfig]);
2049
+ return /*#__PURE__*/React.createElement(reactQuery.QueryClientProvider, {
2050
+ client: queryClient
2051
+ }, children);
2052
+ };
2053
+ QueryProvider.propTypes = propTypes$1;
2054
+ QueryProvider.defaultProps = defaultProps$1;
2055
+
1589
2056
  /* eslint-disable react/jsx-props-no-spreading */
1590
2057
  var propTypes = {
1591
2058
  api: PropTypes.instanceOf(Api$1),
@@ -1614,9 +2081,13 @@ exports.Api = Api$1;
1614
2081
  exports.ApiProvider = ApiProvider;
1615
2082
  exports.BaseApi = Base$1;
1616
2083
  exports.DataProvider = DataProvider$1;
2084
+ exports.QueryProvider = QueryProvider;
1617
2085
  exports.useApi = useApi;
1618
2086
  exports.useData = useData$1;
1619
- exports.useItems = useItems$1;
2087
+ exports.useItems = useItems$3;
2088
+ exports.useItemsLegacy = useItems$1;
2089
+ exports.useItemsStore = useItemsStore$1;
2090
+ exports.useQueryContext = useQueryContext;
1620
2091
  exports.useResourceDestroy = useResourceDestroy$1;
1621
2092
  exports.useResourceItem = useResourceItem$1;
1622
2093
  exports.useResourceItems = useResourceItems$1;