@websolutespa/bom-mixer-hooks 1.8.3 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @websolutespa/bom-mixer-hooks
2
2
 
3
+ ## 1.8.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: usePageLoading, shallow routes do not fire loading state
8
+
3
9
  ## 1.8.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -396,6 +396,9 @@ declare function PageProvider({ children, page }: {
396
396
  page: IPage;
397
397
  }): react_jsx_runtime.JSX.Element;
398
398
 
399
+ type IPageRouteOptions = {
400
+ shallow: boolean;
401
+ };
399
402
  type IPageRoute = {
400
403
  pathname: string;
401
404
  query: Record<string, string>;
@@ -571,4 +574,4 @@ type WindowSize = {
571
574
  };
572
575
  declare function useWindowSize(): WindowSize;
573
576
 
574
- export { BodyScrollOptions, ClickOutGetContainer, CurrentStateType, ElementStackItem, ExtraProvider, Filter, FilterMode, FilterParams, FilterValues, GeoLocationSensorState, IExtra, IFilter, IFilterOption, IGeolocationPositionError, ILabelContext, ILayoutContext, ILazyModulesContext, IPageContext, IPageRoute, IPaginationInfo, IParams, IParamsEncoded, IParamsQs, IUseSearchParamsEncodedResult, IUseSearchParamsQsResult, IUseSearchParamsResult, IUseSearchParamsValueResult, KeyCode, KeyMod, KeyboardOptions, KeyboardResult, LabelProvider, LabelService, LayoutProvider, LazyModulesProvider, PageProvider, SSRState, SizeResult, SizeType, Sorting, UIReducer, UIValue, UseFiltersResultType, UseKeyboard, UseKeyboardHandler, createElementWithId, createGenericContext, detectIsBrowser, filtersToParams, getCurrentPosition, getFilteredItems, getFilters, getOwnerPaddingRight, getOwnerScrollbarWidth, getPagedItems, getPaginationInfo, getRealSize, getSearchParams, getSearchParamsEncoded, getSearchParamsQs, getUID, hasGeolocation, isElement, isPaginationInfo, localCollectionDelete, localCollectionFetch, localCollectionGet, localCollectionPatch, localCollectionPost, localCollectionPut, parseLabel, parseParams, pushSearchParams, pushSearchParamsEncoded, pushSearchParamsEncodedSilently, pushSearchParamsQs, pushSearchParamsQsSilently, pushSearchParamsSilently, replaceSearchParams, replaceSearchParamsEncoded, replaceSearchParamsEncodedSilently, replaceSearchParamsQs, replaceSearchParamsQsSilently, replaceSearchParamsSilently, scrollToRelativeY, scrollToSelector, scrollToY, setFilters, updateSearchParams, updateSearchParamsEncoded, updateSearchParamsQs, useApi, useApiDelete, useApiFetch, useApiGet, useApiPatch, useApiPost, useApiPut, useBodyScroll, useBreakpoint, useClickAnyWhere, useClickOut, useCollectionApi, useCollectionApiDelete, useCollectionApiGet, useCollectionApiPatch, useCollectionApiPost, useCollectionApiPut, useCurrency, useCurrentState, useDateTimeFormat, useDebounce, useDebounceCallback, useDebugChangedProps, useDomObserver, useDrawer, useElementSize, useEventListener, useExtra, useFilters, useGeolocation, useIdle, useInfiniteLoader, useIntersectionObserver, useIsomorphicLayoutEffect, useKeyboard, useLabel, useLayout, useLazyModules, useModal, useMounted, useNumber, usePage, usePageLoading, usePagination, usePortal, usePrevious, useRealSize, useResize, useSSR, useScroll, useScrollTo, useScrolled, useSearchParams, useSearchParamsEncoded, useSearchParamsQs, useSearchParamsValue, useSorting, useSyncedRef, useUI, useUnit, useUnmountEffect, useWindowSize };
577
+ export { BodyScrollOptions, ClickOutGetContainer, CurrentStateType, ElementStackItem, ExtraProvider, Filter, FilterMode, FilterParams, FilterValues, GeoLocationSensorState, IExtra, IFilter, IFilterOption, IGeolocationPositionError, ILabelContext, ILayoutContext, ILazyModulesContext, IPageContext, IPageRoute, IPageRouteOptions, IPaginationInfo, IParams, IParamsEncoded, IParamsQs, IUseSearchParamsEncodedResult, IUseSearchParamsQsResult, IUseSearchParamsResult, IUseSearchParamsValueResult, KeyCode, KeyMod, KeyboardOptions, KeyboardResult, LabelProvider, LabelService, LayoutProvider, LazyModulesProvider, PageProvider, SSRState, SizeResult, SizeType, Sorting, UIReducer, UIValue, UseFiltersResultType, UseKeyboard, UseKeyboardHandler, createElementWithId, createGenericContext, detectIsBrowser, filtersToParams, getCurrentPosition, getFilteredItems, getFilters, getOwnerPaddingRight, getOwnerScrollbarWidth, getPagedItems, getPaginationInfo, getRealSize, getSearchParams, getSearchParamsEncoded, getSearchParamsQs, getUID, hasGeolocation, isElement, isPaginationInfo, localCollectionDelete, localCollectionFetch, localCollectionGet, localCollectionPatch, localCollectionPost, localCollectionPut, parseLabel, parseParams, pushSearchParams, pushSearchParamsEncoded, pushSearchParamsEncodedSilently, pushSearchParamsQs, pushSearchParamsQsSilently, pushSearchParamsSilently, replaceSearchParams, replaceSearchParamsEncoded, replaceSearchParamsEncodedSilently, replaceSearchParamsQs, replaceSearchParamsQsSilently, replaceSearchParamsSilently, scrollToRelativeY, scrollToSelector, scrollToY, setFilters, updateSearchParams, updateSearchParamsEncoded, updateSearchParamsQs, useApi, useApiDelete, useApiFetch, useApiGet, useApiPatch, useApiPost, useApiPut, useBodyScroll, useBreakpoint, useClickAnyWhere, useClickOut, useCollectionApi, useCollectionApiDelete, useCollectionApiGet, useCollectionApiPatch, useCollectionApiPost, useCollectionApiPut, useCurrency, useCurrentState, useDateTimeFormat, useDebounce, useDebounceCallback, useDebugChangedProps, useDomObserver, useDrawer, useElementSize, useEventListener, useExtra, useFilters, useGeolocation, useIdle, useInfiniteLoader, useIntersectionObserver, useIsomorphicLayoutEffect, useKeyboard, useLabel, useLayout, useLazyModules, useModal, useMounted, useNumber, usePage, usePageLoading, usePagination, usePortal, usePrevious, useRealSize, useResize, useSSR, useScroll, useScrollTo, useScrolled, useSearchParams, useSearchParamsEncoded, useSearchParamsQs, useSearchParamsValue, useSorting, useSyncedRef, useUI, useUnit, useUnmountEffect, useWindowSize };
package/dist/index.js CHANGED
@@ -1420,22 +1420,31 @@ function usePageLoading(options = { loading: false }) {
1420
1420
  const [previousPageRoute, setPreviousPageRoute] = (0, import_react25.useState)();
1421
1421
  (0, import_react25.useEffect)(() => {
1422
1422
  let previousRoute;
1423
- const onRouteChangeStart = () => {
1423
+ const onRouteChangeStart = (route, options2) => {
1424
1424
  const pageRoute2 = previousRoute ? getPageRoute(previousRoute) : void 0;
1425
- setLoading(true);
1426
- setPreviousPageRoute(pageRoute2);
1427
1425
  setError();
1426
+ setPreviousPageRoute(pageRoute2);
1427
+ if (options2 == null ? void 0 : options2.shallow) {
1428
+ return;
1429
+ }
1430
+ setLoading(true);
1428
1431
  };
1429
- const onRouteChangeComplete = (route) => {
1432
+ const onRouteChangeComplete = (route, options2) => {
1430
1433
  const pageRoute2 = getPageRoute(route);
1431
1434
  setPageRoute(pageRoute2);
1432
1435
  previousRoute = route;
1436
+ if (options2 == null ? void 0 : options2.shallow) {
1437
+ return;
1438
+ }
1433
1439
  setLoading(false);
1434
1440
  };
1435
- const onRouteChangeError = (error2) => {
1441
+ const onRouteChangeError = (error2, route, options2) => {
1436
1442
  console.log("usePageLoading.onRouteChangeError", error2);
1437
- setLoading(false);
1438
1443
  setError(error2);
1444
+ if (options2 == null ? void 0 : options2.shallow) {
1445
+ return;
1446
+ }
1447
+ setLoading(false);
1439
1448
  };
1440
1449
  import_router.Router.events.on("routeChangeStart", onRouteChangeStart);
1441
1450
  import_router.Router.events.on("routeChangeComplete", onRouteChangeComplete);
package/dist/index.mjs CHANGED
@@ -1280,22 +1280,31 @@ function usePageLoading(options = { loading: false }) {
1280
1280
  const [previousPageRoute, setPreviousPageRoute] = useState14();
1281
1281
  useEffect19(() => {
1282
1282
  let previousRoute;
1283
- const onRouteChangeStart = () => {
1283
+ const onRouteChangeStart = (route, options2) => {
1284
1284
  const pageRoute2 = previousRoute ? getPageRoute(previousRoute) : void 0;
1285
- setLoading(true);
1286
- setPreviousPageRoute(pageRoute2);
1287
1285
  setError();
1286
+ setPreviousPageRoute(pageRoute2);
1287
+ if (options2 == null ? void 0 : options2.shallow) {
1288
+ return;
1289
+ }
1290
+ setLoading(true);
1288
1291
  };
1289
- const onRouteChangeComplete = (route) => {
1292
+ const onRouteChangeComplete = (route, options2) => {
1290
1293
  const pageRoute2 = getPageRoute(route);
1291
1294
  setPageRoute(pageRoute2);
1292
1295
  previousRoute = route;
1296
+ if (options2 == null ? void 0 : options2.shallow) {
1297
+ return;
1298
+ }
1293
1299
  setLoading(false);
1294
1300
  };
1295
- const onRouteChangeError = (error2) => {
1301
+ const onRouteChangeError = (error2, route, options2) => {
1296
1302
  console.log("usePageLoading.onRouteChangeError", error2);
1297
- setLoading(false);
1298
1303
  setError(error2);
1304
+ if (options2 == null ? void 0 : options2.shallow) {
1305
+ return;
1306
+ }
1307
+ setLoading(false);
1299
1308
  };
1300
1309
  Router.events.on("routeChangeStart", onRouteChangeStart);
1301
1310
  Router.events.on("routeChangeComplete", onRouteChangeComplete);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-mixer-hooks",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "Mixer Hooks module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -1,6 +1,10 @@
1
1
  import { Router } from 'next/router';
2
2
  import { useEffect, useState } from 'react';
3
3
 
4
+ export type IPageRouteOptions = {
5
+ shallow: boolean;
6
+ };
7
+
4
8
  export type IPageRoute = {
5
9
  pathname: string;
6
10
  query: Record<string, string>;
@@ -31,24 +35,36 @@ export function usePageLoading(options: { loading: boolean } = { loading: false
31
35
 
32
36
  useEffect(() => {
33
37
  let previousRoute: string | undefined;
34
- const onRouteChangeStart = () => {
38
+ const onRouteChangeStart = (route: string, options: IPageRouteOptions) => {
35
39
  const pageRoute = previousRoute ? getPageRoute(previousRoute) : undefined;
36
40
  // console.log('usePageLoading.onRouteChangeStart', pageRoute, previousRoute);
37
- setLoading(true);
38
- setPreviousPageRoute(pageRoute);
39
41
  setError();
42
+ setPreviousPageRoute(pageRoute);
43
+ // shallow routes do not fire loading state
44
+ if (options?.shallow) {
45
+ return;
46
+ }
47
+ setLoading(true);
40
48
  };
41
- const onRouteChangeComplete = (route: string) => {
49
+ const onRouteChangeComplete = (route: string, options: IPageRouteOptions) => {
42
50
  const pageRoute = getPageRoute(route);
43
51
  // console.log('usePageLoading.onRouteChangeComplete', pageRoute);
44
52
  setPageRoute(pageRoute);
45
53
  previousRoute = route;
54
+ // shallow routes do not fire loading state
55
+ if (options?.shallow) {
56
+ return;
57
+ }
46
58
  setLoading(false);
47
59
  };
48
- const onRouteChangeError = (error: Error) => {
60
+ const onRouteChangeError = (error: Error, route: string, options: IPageRouteOptions) => {
49
61
  console.log('usePageLoading.onRouteChangeError', error);
50
- setLoading(false);
51
62
  setError(error);
63
+ // shallow routes do not fire loading state
64
+ if (options?.shallow) {
65
+ return;
66
+ }
67
+ setLoading(false);
52
68
  };
53
69
  Router.events.on('routeChangeStart', onRouteChangeStart);
54
70
  Router.events.on('routeChangeComplete', onRouteChangeComplete);