@datawheel/bespoke 0.3.10 → 0.3.11
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/dist/index.js +37 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3019,7 +3019,7 @@ var init_store = __esm({
|
|
|
3019
3019
|
storeWrapper = createWrapper(storeFactory);
|
|
3020
3020
|
}
|
|
3021
3021
|
});
|
|
3022
|
-
function withFetcher(Component,
|
|
3022
|
+
function withFetcher(Component, useRef16) {
|
|
3023
3023
|
const ComponentWithFetcher = (props) => {
|
|
3024
3024
|
const {
|
|
3025
3025
|
id,
|
|
@@ -3027,7 +3027,7 @@ function withFetcher(Component, useRef15) {
|
|
|
3027
3027
|
skelWidth,
|
|
3028
3028
|
...otherProps
|
|
3029
3029
|
} = props;
|
|
3030
|
-
const ref =
|
|
3030
|
+
const ref = useRef16(id);
|
|
3031
3031
|
if (ref.isUninitialized || ref.isFetching) {
|
|
3032
3032
|
return /* @__PURE__ */ jsx(Skeleton, { width: skelWidth, height: skelHeight });
|
|
3033
3033
|
}
|
|
@@ -4739,6 +4739,40 @@ function useInitialState(pathSegmentsKey) {
|
|
|
4739
4739
|
return loading || !privateBlocks.resolved;
|
|
4740
4740
|
}
|
|
4741
4741
|
|
|
4742
|
+
// frontend/hooks/useScrollToAnchor.ts
|
|
4743
|
+
init_esm_shims();
|
|
4744
|
+
function useScrollToAnchor() {
|
|
4745
|
+
const router = useRouter();
|
|
4746
|
+
const isScrollingRef = useRef(false);
|
|
4747
|
+
const delay = 500;
|
|
4748
|
+
useEffect(() => {
|
|
4749
|
+
const scrollToAnchor = () => {
|
|
4750
|
+
const { asPath } = router;
|
|
4751
|
+
if (!isScrollingRef.current && asPath.includes("#")) {
|
|
4752
|
+
const anchorId = asPath.split("#")[1];
|
|
4753
|
+
const anchorElement = document.getElementById(anchorId);
|
|
4754
|
+
if (anchorElement) {
|
|
4755
|
+
isScrollingRef.current = true;
|
|
4756
|
+
setTimeout(() => {
|
|
4757
|
+
anchorElement.scrollIntoView({
|
|
4758
|
+
behavior: "smooth"
|
|
4759
|
+
});
|
|
4760
|
+
isScrollingRef.current = false;
|
|
4761
|
+
}, delay);
|
|
4762
|
+
}
|
|
4763
|
+
}
|
|
4764
|
+
};
|
|
4765
|
+
scrollToAnchor();
|
|
4766
|
+
const handleHashChange = () => {
|
|
4767
|
+
scrollToAnchor();
|
|
4768
|
+
};
|
|
4769
|
+
router.events.on("hashChangeComplete", handleHashChange);
|
|
4770
|
+
return () => {
|
|
4771
|
+
router.events.off("hashChangeComplete", handleHashChange);
|
|
4772
|
+
};
|
|
4773
|
+
}, [router]);
|
|
4774
|
+
}
|
|
4775
|
+
|
|
4742
4776
|
// hooks/useContentOutline.ts
|
|
4743
4777
|
init_esm_shims();
|
|
4744
4778
|
init_store2();
|
|
@@ -6593,7 +6627,6 @@ function useCurrentLocale() {
|
|
|
6593
6627
|
const { currentLocale, locales: locales4 } = useAppSelector((state) => state.status);
|
|
6594
6628
|
const paramLocale = query.locale || "";
|
|
6595
6629
|
useEffect(() => {
|
|
6596
|
-
console.log();
|
|
6597
6630
|
if (paramLocale && paramLocale !== "" && locales4.includes(paramLocale) && paramLocale !== currentLocale) {
|
|
6598
6631
|
dispatch(actions_exports.setCurrentLocale(paramLocale));
|
|
6599
6632
|
}
|
|
@@ -8918,6 +8951,7 @@ var Section_default = Section;
|
|
|
8918
8951
|
function Report() {
|
|
8919
8952
|
const sectionList = useSectionList();
|
|
8920
8953
|
const comparison = useComparison();
|
|
8954
|
+
useScrollToAnchor();
|
|
8921
8955
|
return /* @__PURE__ */ jsx(Container, { className: comparison.comparisonLoaded ? "compare" : "", p: 0, pos: "relative", fluid: true, children: sectionList.isSuccess && sectionList.data.sort(orderSort).map((section) => /* @__PURE__ */ jsx(Section_default, { section }, section.id)) });
|
|
8922
8956
|
}
|
|
8923
8957
|
var Report_default = Report;
|