@datawheel/bespoke 0.3.10 → 0.3.12

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 CHANGED
@@ -1935,7 +1935,8 @@ var init_statusSlice = __esm({
1935
1935
  tools: true,
1936
1936
  settings: false,
1937
1937
  reportEditor: false
1938
- }
1938
+ },
1939
+ isCMS: false
1939
1940
  };
1940
1941
  statusSlice = createSlice({
1941
1942
  name: "status",
@@ -3019,7 +3020,7 @@ var init_store = __esm({
3019
3020
  storeWrapper = createWrapper(storeFactory);
3020
3021
  }
3021
3022
  });
3022
- function withFetcher(Component, useRef15) {
3023
+ function withFetcher(Component, useRef16) {
3023
3024
  const ComponentWithFetcher = (props) => {
3024
3025
  const {
3025
3026
  id,
@@ -3027,7 +3028,7 @@ function withFetcher(Component, useRef15) {
3027
3028
  skelWidth,
3028
3029
  ...otherProps
3029
3030
  } = props;
3030
- const ref = useRef15(id);
3031
+ const ref = useRef16(id);
3031
3032
  if (ref.isUninitialized || ref.isFetching) {
3032
3033
  return /* @__PURE__ */ jsx(Skeleton, { width: skelWidth, height: skelHeight });
3033
3034
  }
@@ -4739,6 +4740,40 @@ function useInitialState(pathSegmentsKey) {
4739
4740
  return loading || !privateBlocks.resolved;
4740
4741
  }
4741
4742
 
4743
+ // frontend/hooks/useScrollToAnchor.ts
4744
+ init_esm_shims();
4745
+ function useScrollToAnchor() {
4746
+ const router = useRouter();
4747
+ const isScrollingRef = useRef(false);
4748
+ const delay = 500;
4749
+ useEffect(() => {
4750
+ const scrollToAnchor = () => {
4751
+ const { asPath } = router;
4752
+ if (!isScrollingRef.current && asPath.includes("#")) {
4753
+ const anchorId = asPath.split("#")[1];
4754
+ const anchorElement = document.getElementById(anchorId);
4755
+ if (anchorElement) {
4756
+ isScrollingRef.current = true;
4757
+ setTimeout(() => {
4758
+ anchorElement.scrollIntoView({
4759
+ behavior: "smooth"
4760
+ });
4761
+ isScrollingRef.current = false;
4762
+ }, delay);
4763
+ }
4764
+ }
4765
+ };
4766
+ scrollToAnchor();
4767
+ const handleHashChange = () => {
4768
+ scrollToAnchor();
4769
+ };
4770
+ router.events.on("hashChangeComplete", handleHashChange);
4771
+ return () => {
4772
+ router.events.off("hashChangeComplete", handleHashChange);
4773
+ };
4774
+ }, [router]);
4775
+ }
4776
+
4742
4777
  // hooks/useContentOutline.ts
4743
4778
  init_esm_shims();
4744
4779
  init_store2();
@@ -6593,7 +6628,6 @@ function useCurrentLocale() {
6593
6628
  const { currentLocale, locales: locales4 } = useAppSelector((state) => state.status);
6594
6629
  const paramLocale = query.locale || "";
6595
6630
  useEffect(() => {
6596
- console.log();
6597
6631
  if (paramLocale && paramLocale !== "" && locales4.includes(paramLocale) && paramLocale !== currentLocale) {
6598
6632
  dispatch(actions_exports.setCurrentLocale(paramLocale));
6599
6633
  }
@@ -7256,10 +7290,13 @@ var guessResponse = (response) => {
7256
7290
  function DataTab(props) {
7257
7291
  const { section } = props;
7258
7292
  const readMemberFn = useReadMemberFn();
7259
- const locale = useAppSelector((state2) => state2.status.currentLocale);
7293
+ const router = useRouter();
7294
+ const isCMS = useAppSelector((state2) => state2.status.isCMS);
7295
+ const statusLocale = useAppSelector((state2) => state2.status.currentLocale);
7296
+ const routerLocale = router.locale;
7297
+ const locale = isCMS ? statusLocale : routerLocale;
7260
7298
  const PREVIEW_SIZE = 50;
7261
7299
  const formatterFunctions = useFormatterFunctionsForLocale(locale);
7262
- const router = useRouter();
7263
7300
  const optionsTranslations = useBespokeTranslations("options");
7264
7301
  const translations = { ...DEFAULT_TRANSLATIONS2, ...optionsTranslations["data_tab"] };
7265
7302
  const [sourcesOptions, setSourcesOptions] = useState([]);
@@ -8918,6 +8955,7 @@ var Section_default = Section;
8918
8955
  function Report() {
8919
8956
  const sectionList = useSectionList();
8920
8957
  const comparison = useComparison();
8958
+ useScrollToAnchor();
8921
8959
  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
8960
  }
8923
8961
  var Report_default = Report;
@@ -15746,6 +15784,8 @@ function UsersEditor() {
15746
15784
  // views/BespokeManager.tsx
15747
15785
  init_ErrorBoundary();
15748
15786
  init_envvars();
15787
+ init_statusSlice();
15788
+ init_store2();
15749
15789
  function BespokeManager(options) {
15750
15790
  const {
15751
15791
  title = "Bespoke CMS",
@@ -15935,6 +15975,10 @@ function BespokeManagerShell(props) {
15935
15975
  }
15936
15976
  return /* @__PURE__ */ jsx(NotFoundView, {});
15937
15977
  }, [location, user]);
15978
+ const dispatch = useAppDispatch();
15979
+ useEffect(() => {
15980
+ dispatch(statusActions.setStatus({ isCMS: true }));
15981
+ }, []);
15938
15982
  return /* @__PURE__ */ jsx(AppShell, { styles: {
15939
15983
  main: {
15940
15984
  background: "#f8f9fa",
package/dist/server.js CHANGED
@@ -4998,7 +4998,8 @@ var initialState = {
4998
4998
  tools: true,
4999
4999
  settings: false,
5000
5000
  reportEditor: false
5001
- }
5001
+ },
5002
+ isCMS: false
5002
5003
  };
5003
5004
  var statusSlice = createSlice({
5004
5005
  name: "status",
@@ -5750,7 +5751,9 @@ function BespokeManagerServerSideProps(options) {
5750
5751
  dispatch(readEntity("report", {
5751
5752
  id: parseReportId(ctx.query[pathSegmentsKey]),
5752
5753
  include: true
5753
- }))
5754
+ })),
5755
+ // Mark the status as CMS environment
5756
+ dispatch(statusActions.setStatus({ isCMS: true }))
5754
5757
  ]);
5755
5758
  const postResult = await postResolve(store, ctx);
5756
5759
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {