@panneau/data 3.0.173 → 3.0.175
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/es/index.js +59 -27
- package/lib/index.js +59 -27
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -75,7 +75,7 @@ var useData$1 = useData;
|
|
|
75
75
|
|
|
76
76
|
var _excluded$3 = ["store", "url", "paginated", "query", "onQueryChange", "queryConfig", "keepData"],
|
|
77
77
|
_excluded2$1 = ["page", "count"],
|
|
78
|
-
_excluded3 = ["data", "refetch", "isLoading", "isFetched", "status", "error"];
|
|
78
|
+
_excluded3 = ["data", "refetch", "isLoading", "isFetching", "isRefetching", "isFetched", "status", "error"];
|
|
79
79
|
var useItems$2 = function useItems(_ref) {
|
|
80
80
|
var store = _ref.store,
|
|
81
81
|
url = _ref.url,
|
|
@@ -194,8 +194,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
194
194
|
_useQuery$data = _useQuery.data,
|
|
195
195
|
data = _useQuery$data === void 0 ? null : _useQuery$data,
|
|
196
196
|
reload = _useQuery.refetch,
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
isLoading = _useQuery.isLoading,
|
|
198
|
+
isFetching = _useQuery.isFetching,
|
|
199
|
+
isRefetching = _useQuery.isRefetching,
|
|
200
|
+
isFetched = _useQuery.isFetched,
|
|
199
201
|
_useQuery$status = _useQuery.status,
|
|
200
202
|
status = _useQuery$status === void 0 ? null : _useQuery$status,
|
|
201
203
|
_useQuery$error = _useQuery.error,
|
|
@@ -229,10 +231,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
229
231
|
}, [query, onQueryChange]);
|
|
230
232
|
var pages = useRef(null);
|
|
231
233
|
useEffect(function () {
|
|
232
|
-
if (
|
|
234
|
+
if (isFetched && page !== null && data !== null) {
|
|
233
235
|
pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
|
|
234
236
|
}
|
|
235
|
-
}, [
|
|
237
|
+
}, [isFetched, page, data]);
|
|
236
238
|
var finalItems = useMemo(function () {
|
|
237
239
|
if (data === null) {
|
|
238
240
|
return data;
|
|
@@ -270,6 +272,7 @@ var useItems$2 = function useItems(_ref) {
|
|
|
270
272
|
var _pages$current$k;
|
|
271
273
|
return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
|
|
272
274
|
}) : null;
|
|
275
|
+
var finalLoading = isLoading || isFetching || isRefetching;
|
|
273
276
|
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
274
277
|
items: finalItems,
|
|
275
278
|
allItems: allItems,
|
|
@@ -282,10 +285,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
282
285
|
} : null,
|
|
283
286
|
total: total,
|
|
284
287
|
lastPage: lastPage,
|
|
285
|
-
loaded:
|
|
286
|
-
allLoaded: paginated && pages.current !== null && Object.keys(pages.current).length === lastPage || !paginated &&
|
|
288
|
+
loaded: isFetched,
|
|
289
|
+
allLoaded: paginated && pages.current !== null && Object.keys(pages.current).length === lastPage || !paginated && isFetched,
|
|
287
290
|
// very basic stuff, TODO
|
|
288
|
-
loading:
|
|
291
|
+
loading: finalLoading,
|
|
289
292
|
loadNextPage: loadNextPage,
|
|
290
293
|
loadPage: loadPage,
|
|
291
294
|
reloadPage: reload,
|
|
@@ -571,7 +574,7 @@ var useItems = function useItems(_ref) {
|
|
|
571
574
|
var useItems$1 = useItems;
|
|
572
575
|
|
|
573
576
|
var _excluded$2 = ["page", "count"],
|
|
574
|
-
_excluded2 = ["data", "refetch", "isLoading", "isFetched"];
|
|
577
|
+
_excluded2 = ["data", "refetch", "isLoading", "isFetching", "isRefetching", "isFetched"];
|
|
575
578
|
var useItemsStore = function useItemsStore(store, _ref) {
|
|
576
579
|
var _ref$url = _ref.url,
|
|
577
580
|
url = _ref$url === void 0 ? null : _ref$url,
|
|
@@ -605,9 +608,6 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
605
608
|
var queryKey = useMemo(function () {
|
|
606
609
|
return paginated ? [store, page || 1, count || 12, queryWithoutPage] : [store, query];
|
|
607
610
|
}, [paginated, store, page, count, query, queryWithoutPage, getPage, getItems]);
|
|
608
|
-
|
|
609
|
-
// console.log('queryKey', queryKey, 'paginated', paginated);
|
|
610
|
-
|
|
611
611
|
var _useQuery = useQuery(_objectSpread(_objectSpread({
|
|
612
612
|
queryKey: queryKey,
|
|
613
613
|
queryFn: function queryFn(_ref3) {
|
|
@@ -642,8 +642,10 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
642
642
|
_useQuery$data = _useQuery.data,
|
|
643
643
|
data = _useQuery$data === void 0 ? null : _useQuery$data,
|
|
644
644
|
reload = _useQuery.refetch,
|
|
645
|
-
|
|
646
|
-
|
|
645
|
+
isLoading = _useQuery.isLoading,
|
|
646
|
+
isFetching = _useQuery.isFetching,
|
|
647
|
+
isRefetching = _useQuery.isRefetching,
|
|
648
|
+
isFetched = _useQuery.isFetched,
|
|
647
649
|
otherProps = _objectWithoutProperties(_useQuery, _excluded2);
|
|
648
650
|
var _ref4 = data || {},
|
|
649
651
|
_ref4$data = _ref4.data,
|
|
@@ -731,19 +733,25 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
731
733
|
|
|
732
734
|
// Keep a list of pages, useEffect wont work here because delayed
|
|
733
735
|
var pages = useRef(null);
|
|
734
|
-
if (
|
|
736
|
+
if (isFetched && page !== null && data !== null) {
|
|
735
737
|
pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
|
|
736
738
|
}
|
|
737
739
|
var allItems = pages.current !== null ? replaceUpdatedItems(Object.keys(pages.current).flatMap(function (k) {
|
|
738
740
|
var _pages$current$k;
|
|
739
741
|
return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
|
|
740
742
|
})) : finalItems;
|
|
743
|
+
var finalLoading = isLoading || isFetching || isRefetching;
|
|
744
|
+
console.log(isLoading, isFetching, isRefetching, otherProps);
|
|
741
745
|
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
746
|
+
isLoading: isLoading,
|
|
747
|
+
isFetching: isFetching,
|
|
748
|
+
isRefetching: isRefetching,
|
|
749
|
+
isFetched: isFetched,
|
|
742
750
|
items: finalItems,
|
|
743
751
|
pages: pages.current,
|
|
744
752
|
allItems: allItems,
|
|
745
|
-
loading:
|
|
746
|
-
loaded:
|
|
753
|
+
loading: finalLoading,
|
|
754
|
+
loaded: isFetched,
|
|
747
755
|
reload: reload,
|
|
748
756
|
loadPage: loadPage,
|
|
749
757
|
loadNextPage: loadNextPage,
|
|
@@ -1002,10 +1010,12 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1002
1010
|
baseUrl: opts.baseUrl ? opts.baseUrl : null,
|
|
1003
1011
|
routes: _objectSpread({
|
|
1004
1012
|
index: 'medias',
|
|
1013
|
+
trashed: 'medias/trash',
|
|
1005
1014
|
tags: 'medias/tags',
|
|
1006
1015
|
show: 'medias/:media',
|
|
1007
1016
|
store: 'medias',
|
|
1008
1017
|
update: 'medias/:media',
|
|
1018
|
+
trash: 'medias/trash/:media',
|
|
1009
1019
|
"delete": 'medias/:media'
|
|
1010
1020
|
}, opts.routes || null)
|
|
1011
1021
|
}]);
|
|
@@ -1033,6 +1043,21 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1033
1043
|
}
|
|
1034
1044
|
return this.requestGet(this.route('index'), finalQuery);
|
|
1035
1045
|
}
|
|
1046
|
+
}, {
|
|
1047
|
+
key: "getTrashed",
|
|
1048
|
+
value: function getTrashed() {
|
|
1049
|
+
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1050
|
+
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1051
|
+
var count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
1052
|
+
var finalQuery = _objectSpread({}, query);
|
|
1053
|
+
if (page !== null) {
|
|
1054
|
+
finalQuery.page = page;
|
|
1055
|
+
}
|
|
1056
|
+
if (count !== null) {
|
|
1057
|
+
finalQuery.count = count;
|
|
1058
|
+
}
|
|
1059
|
+
return this.requestGet(this.route('trashed'), finalQuery);
|
|
1060
|
+
}
|
|
1036
1061
|
}, {
|
|
1037
1062
|
key: "getTags",
|
|
1038
1063
|
value: function getTags() {
|
|
@@ -1056,6 +1081,13 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1056
1081
|
media: id
|
|
1057
1082
|
}), data);
|
|
1058
1083
|
}
|
|
1084
|
+
}, {
|
|
1085
|
+
key: "trash",
|
|
1086
|
+
value: function trash(id) {
|
|
1087
|
+
return this.requestDelete(this.route('trash', {
|
|
1088
|
+
media: id
|
|
1089
|
+
}));
|
|
1090
|
+
}
|
|
1059
1091
|
}, {
|
|
1060
1092
|
key: "delete",
|
|
1061
1093
|
value: function _delete(id) {
|
|
@@ -1339,13 +1371,19 @@ var useQueryContext = function useQueryContext() {
|
|
|
1339
1371
|
};
|
|
1340
1372
|
var propTypes$1 = {
|
|
1341
1373
|
config: PropTypes.shape({}),
|
|
1374
|
+
initialKey: PropTypes.arrayOf(PropTypes.string),
|
|
1375
|
+
initialData: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.arrayOf(PropTypes.shape({}))]),
|
|
1342
1376
|
children: PropTypes.node.isRequired
|
|
1343
1377
|
};
|
|
1344
1378
|
var defaultProps$1 = {
|
|
1345
|
-
config: null
|
|
1379
|
+
config: null,
|
|
1380
|
+
initialKey: null,
|
|
1381
|
+
initialData: null
|
|
1346
1382
|
};
|
|
1347
1383
|
var QueryProvider = function QueryProvider(_ref) {
|
|
1348
1384
|
var initialConfig = _ref.config,
|
|
1385
|
+
initialKey = _ref.initialKey,
|
|
1386
|
+
initialData = _ref.initialData,
|
|
1349
1387
|
children = _ref.children;
|
|
1350
1388
|
var queryClient = useMemo(function () {
|
|
1351
1389
|
var client = new QueryClient(_objectSpread({
|
|
@@ -1355,15 +1393,9 @@ var QueryProvider = function QueryProvider(_ref) {
|
|
|
1355
1393
|
}
|
|
1356
1394
|
}
|
|
1357
1395
|
}, initialConfig));
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
// ? queryString.parse(window.location.search, {
|
|
1362
|
-
// arrayFormat: 'bracket',
|
|
1363
|
-
// })
|
|
1364
|
-
// : null;
|
|
1365
|
-
// client.setQueryData(['pages', page.url, query], page);
|
|
1366
|
-
// }
|
|
1396
|
+
if (initialKey !== null && initialData !== null) {
|
|
1397
|
+
client.setQueryData(initialKey, initialData);
|
|
1398
|
+
}
|
|
1367
1399
|
return client;
|
|
1368
1400
|
}, [initialConfig]);
|
|
1369
1401
|
return /*#__PURE__*/React.createElement(QueryClientProvider, {
|
package/lib/index.js
CHANGED
|
@@ -739,7 +739,7 @@ var queryString = /*#__PURE__*/Object.freeze({
|
|
|
739
739
|
|
|
740
740
|
var _excluded$3 = ["store", "url", "paginated", "query", "onQueryChange", "queryConfig", "keepData"],
|
|
741
741
|
_excluded2$1 = ["page", "count"],
|
|
742
|
-
_excluded3 = ["data", "refetch", "isLoading", "isFetched", "status", "error"];
|
|
742
|
+
_excluded3 = ["data", "refetch", "isLoading", "isFetching", "isRefetching", "isFetched", "status", "error"];
|
|
743
743
|
var useItems$2 = function useItems(_ref) {
|
|
744
744
|
var store = _ref.store,
|
|
745
745
|
url = _ref.url,
|
|
@@ -858,8 +858,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
858
858
|
_useQuery$data = _useQuery.data,
|
|
859
859
|
data = _useQuery$data === void 0 ? null : _useQuery$data,
|
|
860
860
|
reload = _useQuery.refetch,
|
|
861
|
-
|
|
862
|
-
|
|
861
|
+
isLoading = _useQuery.isLoading,
|
|
862
|
+
isFetching = _useQuery.isFetching,
|
|
863
|
+
isRefetching = _useQuery.isRefetching,
|
|
864
|
+
isFetched = _useQuery.isFetched,
|
|
863
865
|
_useQuery$status = _useQuery.status,
|
|
864
866
|
status = _useQuery$status === void 0 ? null : _useQuery$status,
|
|
865
867
|
_useQuery$error = _useQuery.error,
|
|
@@ -893,10 +895,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
893
895
|
}, [query, onQueryChange]);
|
|
894
896
|
var pages = React.useRef(null);
|
|
895
897
|
React.useEffect(function () {
|
|
896
|
-
if (
|
|
898
|
+
if (isFetched && page !== null && data !== null) {
|
|
897
899
|
pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
|
|
898
900
|
}
|
|
899
|
-
}, [
|
|
901
|
+
}, [isFetched, page, data]);
|
|
900
902
|
var finalItems = React.useMemo(function () {
|
|
901
903
|
if (data === null) {
|
|
902
904
|
return data;
|
|
@@ -934,6 +936,7 @@ var useItems$2 = function useItems(_ref) {
|
|
|
934
936
|
var _pages$current$k;
|
|
935
937
|
return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
|
|
936
938
|
}) : null;
|
|
939
|
+
var finalLoading = isLoading || isFetching || isRefetching;
|
|
937
940
|
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
938
941
|
items: finalItems,
|
|
939
942
|
allItems: allItems,
|
|
@@ -946,10 +949,10 @@ var useItems$2 = function useItems(_ref) {
|
|
|
946
949
|
} : null,
|
|
947
950
|
total: total,
|
|
948
951
|
lastPage: lastPage,
|
|
949
|
-
loaded:
|
|
950
|
-
allLoaded: paginated && pages.current !== null && Object.keys(pages.current).length === lastPage || !paginated &&
|
|
952
|
+
loaded: isFetched,
|
|
953
|
+
allLoaded: paginated && pages.current !== null && Object.keys(pages.current).length === lastPage || !paginated && isFetched,
|
|
951
954
|
// very basic stuff, TODO
|
|
952
|
-
loading:
|
|
955
|
+
loading: finalLoading,
|
|
953
956
|
loadNextPage: loadNextPage,
|
|
954
957
|
loadPage: loadPage,
|
|
955
958
|
reloadPage: reload,
|
|
@@ -1235,7 +1238,7 @@ var useItems = function useItems(_ref) {
|
|
|
1235
1238
|
var useItems$1 = useItems;
|
|
1236
1239
|
|
|
1237
1240
|
var _excluded$2 = ["page", "count"],
|
|
1238
|
-
_excluded2 = ["data", "refetch", "isLoading", "isFetched"];
|
|
1241
|
+
_excluded2 = ["data", "refetch", "isLoading", "isFetching", "isRefetching", "isFetched"];
|
|
1239
1242
|
var useItemsStore = function useItemsStore(store, _ref) {
|
|
1240
1243
|
var _ref$url = _ref.url,
|
|
1241
1244
|
url = _ref$url === void 0 ? null : _ref$url,
|
|
@@ -1269,9 +1272,6 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
1269
1272
|
var queryKey = React.useMemo(function () {
|
|
1270
1273
|
return paginated ? [store, page || 1, count || 12, queryWithoutPage] : [store, query];
|
|
1271
1274
|
}, [paginated, store, page, count, query, queryWithoutPage, getPage, getItems]);
|
|
1272
|
-
|
|
1273
|
-
// console.log('queryKey', queryKey, 'paginated', paginated);
|
|
1274
|
-
|
|
1275
1275
|
var _useQuery = reactQuery.useQuery(_objectSpread(_objectSpread({
|
|
1276
1276
|
queryKey: queryKey,
|
|
1277
1277
|
queryFn: function queryFn(_ref3) {
|
|
@@ -1306,8 +1306,10 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
1306
1306
|
_useQuery$data = _useQuery.data,
|
|
1307
1307
|
data = _useQuery$data === void 0 ? null : _useQuery$data,
|
|
1308
1308
|
reload = _useQuery.refetch,
|
|
1309
|
-
|
|
1310
|
-
|
|
1309
|
+
isLoading = _useQuery.isLoading,
|
|
1310
|
+
isFetching = _useQuery.isFetching,
|
|
1311
|
+
isRefetching = _useQuery.isRefetching,
|
|
1312
|
+
isFetched = _useQuery.isFetched,
|
|
1311
1313
|
otherProps = _objectWithoutProperties(_useQuery, _excluded2);
|
|
1312
1314
|
var _ref4 = data || {},
|
|
1313
1315
|
_ref4$data = _ref4.data,
|
|
@@ -1395,19 +1397,25 @@ var useItemsStore = function useItemsStore(store, _ref) {
|
|
|
1395
1397
|
|
|
1396
1398
|
// Keep a list of pages, useEffect wont work here because delayed
|
|
1397
1399
|
var pages = React.useRef(null);
|
|
1398
|
-
if (
|
|
1400
|
+
if (isFetched && page !== null && data !== null) {
|
|
1399
1401
|
pages.current = _objectSpread(_objectSpread({}, pages.current), {}, _defineProperty({}, page, data));
|
|
1400
1402
|
}
|
|
1401
1403
|
var allItems = pages.current !== null ? replaceUpdatedItems(Object.keys(pages.current).flatMap(function (k) {
|
|
1402
1404
|
var _pages$current$k;
|
|
1403
1405
|
return (_pages$current$k = pages.current[k]) === null || _pages$current$k === void 0 ? void 0 : _pages$current$k.data;
|
|
1404
1406
|
})) : finalItems;
|
|
1407
|
+
var finalLoading = isLoading || isFetching || isRefetching;
|
|
1408
|
+
console.log(isLoading, isFetching, isRefetching, otherProps);
|
|
1405
1409
|
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
1410
|
+
isLoading: isLoading,
|
|
1411
|
+
isFetching: isFetching,
|
|
1412
|
+
isRefetching: isRefetching,
|
|
1413
|
+
isFetched: isFetched,
|
|
1406
1414
|
items: finalItems,
|
|
1407
1415
|
pages: pages.current,
|
|
1408
1416
|
allItems: allItems,
|
|
1409
|
-
loading:
|
|
1410
|
-
loaded:
|
|
1417
|
+
loading: finalLoading,
|
|
1418
|
+
loaded: isFetched,
|
|
1411
1419
|
reload: reload,
|
|
1412
1420
|
loadPage: loadPage,
|
|
1413
1421
|
loadNextPage: loadNextPage,
|
|
@@ -1682,10 +1690,12 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1682
1690
|
baseUrl: opts.baseUrl ? opts.baseUrl : null,
|
|
1683
1691
|
routes: _objectSpread({
|
|
1684
1692
|
index: 'medias',
|
|
1693
|
+
trashed: 'medias/trash',
|
|
1685
1694
|
tags: 'medias/tags',
|
|
1686
1695
|
show: 'medias/:media',
|
|
1687
1696
|
store: 'medias',
|
|
1688
1697
|
update: 'medias/:media',
|
|
1698
|
+
trash: 'medias/trash/:media',
|
|
1689
1699
|
"delete": 'medias/:media'
|
|
1690
1700
|
}, opts.routes || null)
|
|
1691
1701
|
}]);
|
|
@@ -1713,6 +1723,21 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1713
1723
|
}
|
|
1714
1724
|
return this.requestGet(this.route('index'), finalQuery);
|
|
1715
1725
|
}
|
|
1726
|
+
}, {
|
|
1727
|
+
key: "getTrashed",
|
|
1728
|
+
value: function getTrashed() {
|
|
1729
|
+
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1730
|
+
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1731
|
+
var count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
1732
|
+
var finalQuery = _objectSpread({}, query);
|
|
1733
|
+
if (page !== null) {
|
|
1734
|
+
finalQuery.page = page;
|
|
1735
|
+
}
|
|
1736
|
+
if (count !== null) {
|
|
1737
|
+
finalQuery.count = count;
|
|
1738
|
+
}
|
|
1739
|
+
return this.requestGet(this.route('trashed'), finalQuery);
|
|
1740
|
+
}
|
|
1716
1741
|
}, {
|
|
1717
1742
|
key: "getTags",
|
|
1718
1743
|
value: function getTags() {
|
|
@@ -1736,6 +1761,13 @@ var MediasApi = /*#__PURE__*/function (_Base) {
|
|
|
1736
1761
|
media: id
|
|
1737
1762
|
}), data);
|
|
1738
1763
|
}
|
|
1764
|
+
}, {
|
|
1765
|
+
key: "trash",
|
|
1766
|
+
value: function trash(id) {
|
|
1767
|
+
return this.requestDelete(this.route('trash', {
|
|
1768
|
+
media: id
|
|
1769
|
+
}));
|
|
1770
|
+
}
|
|
1739
1771
|
}, {
|
|
1740
1772
|
key: "delete",
|
|
1741
1773
|
value: function _delete(id) {
|
|
@@ -2019,13 +2051,19 @@ var useQueryContext = function useQueryContext() {
|
|
|
2019
2051
|
};
|
|
2020
2052
|
var propTypes$1 = {
|
|
2021
2053
|
config: PropTypes.shape({}),
|
|
2054
|
+
initialKey: PropTypes.arrayOf(PropTypes.string),
|
|
2055
|
+
initialData: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.arrayOf(PropTypes.shape({}))]),
|
|
2022
2056
|
children: PropTypes.node.isRequired
|
|
2023
2057
|
};
|
|
2024
2058
|
var defaultProps$1 = {
|
|
2025
|
-
config: null
|
|
2059
|
+
config: null,
|
|
2060
|
+
initialKey: null,
|
|
2061
|
+
initialData: null
|
|
2026
2062
|
};
|
|
2027
2063
|
var QueryProvider = function QueryProvider(_ref) {
|
|
2028
2064
|
var initialConfig = _ref.config,
|
|
2065
|
+
initialKey = _ref.initialKey,
|
|
2066
|
+
initialData = _ref.initialData,
|
|
2029
2067
|
children = _ref.children;
|
|
2030
2068
|
var queryClient = React.useMemo(function () {
|
|
2031
2069
|
var client = new reactQuery.QueryClient(_objectSpread({
|
|
@@ -2035,15 +2073,9 @@ var QueryProvider = function QueryProvider(_ref) {
|
|
|
2035
2073
|
}
|
|
2036
2074
|
}
|
|
2037
2075
|
}, initialConfig));
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
// ? queryString.parse(window.location.search, {
|
|
2042
|
-
// arrayFormat: 'bracket',
|
|
2043
|
-
// })
|
|
2044
|
-
// : null;
|
|
2045
|
-
// client.setQueryData(['pages', page.url, query], page);
|
|
2046
|
-
// }
|
|
2076
|
+
if (initialKey !== null && initialData !== null) {
|
|
2077
|
+
client.setQueryData(initialKey, initialData);
|
|
2078
|
+
}
|
|
2047
2079
|
return client;
|
|
2048
2080
|
}, [initialConfig]);
|
|
2049
2081
|
return /*#__PURE__*/React.createElement(reactQuery.QueryClientProvider, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/data",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.175",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@babel/runtime": "^7.12.5",
|
|
57
57
|
"@folklore/fetch": "^0.1.17",
|
|
58
58
|
"@folklore/routes": "^0.2.26",
|
|
59
|
-
"@panneau/core": "^3.0.
|
|
59
|
+
"@panneau/core": "^3.0.175",
|
|
60
60
|
"@tanstack/react-query": "^5.29.2",
|
|
61
61
|
"lodash": "^4.17.21",
|
|
62
62
|
"prop-types": "^15.7.2",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "cb8320f1041e7ced6bcf77dd6d32661950215a92"
|
|
69
69
|
}
|