@datawheel/bespoke 0.3.1 → 0.3.3

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
@@ -17,11 +17,11 @@ import { Notifications, notifications } from '@mantine/notifications';
17
17
  import React, { forwardRef, createContext, useState, useCallback, useRef, useEffect, useMemo, useContext, memo, Fragment as Fragment$1, createElement } from 'react';
18
18
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
19
19
  import { useDispatch, useSelector } from 'react-redux';
20
- import { Stack, Text, Badge, Group, useMantineTheme, Flex, packSx, List, Tooltip, ActionIcon, Modal, Button, SegmentedControl, Select, MultiSelect, Center, Grid, Title, Radio, NumberInput, TextInput, Switch, Image, Accordion, Input, Box, Menu, Anchor, MantineProvider, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Card, Container, Loader, Alert, Burger, Collapse, Checkbox, Space, Code, Divider, Textarea, Paper, Autocomplete, Popover, Drawer, rem, Overlay, Header, px, Tabs, FileInput, SimpleGrid, HoverCard, CopyButton, Col } from '@mantine/core';
20
+ import { Stack, Text, Badge, Group, Flex, packSx, useMantineTheme, List, Tooltip, ActionIcon, Modal, Button, SegmentedControl, Select, MultiSelect, Center, Grid, Title, Radio, NumberInput, TextInput, Switch, Image, Accordion, Input, Box, Menu, Anchor, MantineProvider, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Card, Container, Loader, Alert, Burger, Collapse, Checkbox, Space, Code, Divider, Textarea, Paper, Autocomplete, Popover, Drawer, rem, Overlay, Header, px, Tabs, FileInput, SimpleGrid, HoverCard, CopyButton, Col } from '@mantine/core';
21
21
  import { dataConcat } from 'd3plus-viz';
22
22
  import * as d3plus from 'd3plus-react';
23
23
  import Router, { useRouter } from 'next/router';
24
- import { IconDice, IconBoxMultiple, IconEyeOff, IconChevronDown, IconInfoCircle, IconRefresh, IconPhotoFilled, IconSearch, IconPlus, IconHeading, IconApi, IconPercentage, IconChartBar, IconAlignLeft, IconSelector, IconPhoto, IconAlignCenter, IconAlignRight, IconBallpen, IconDatabase, IconMathFunction, IconUsers, IconLogout, IconTrash, IconX, IconUserCircle, IconEdit, IconCircleDashed, IconServer, IconPencil, IconAlertCircle, IconCircleCheck, IconPlayerPlay, IconCircleX, IconFlag, IconFileAnalytics, IconHome, IconSettingsFilled, IconEye, IconWorldUpload, IconBraces, IconClockHour2, IconAugmentedReality, IconGitMerge, IconGripHorizontal, IconChevronLeft, IconChevronRight, IconPolaroid, IconCircleMinus, IconTable, IconCamera, IconShare, IconCirclePlus, IconLogin, IconWorld, IconLock, IconBinaryTree, IconVariable, IconArrowRightCircle, IconIndentIncrease, IconCodeDots, IconUpload, IconCodePlus, IconExternalLink, IconDownload, IconTemplate, IconCode, IconPalette, IconLink, IconClipboardCheck, IconClipboardCopy, IconSettings, IconMinimize, IconMaximize, IconRss, IconGlobe, IconLinkOff } from '@tabler/icons-react';
24
+ import { IconDice, IconBoxMultiple, IconEyeOff, IconChevronDown, IconInfoCircle, IconRefresh, IconPhotoFilled, IconFileUpload, IconSearch, IconPlus, IconHeading, IconApi, IconPercentage, IconChartBar, IconAlignLeft, IconSelector, IconPhoto, IconAlignCenter, IconAlignRight, IconBallpen, IconDatabase, IconMathFunction, IconUsers, IconLogout, IconTrash, IconX, IconUserCircle, IconEdit, IconCircleDashed, IconServer, IconPencil, IconAlertCircle, IconCircleCheck, IconPlayerPlay, IconCircleX, IconFlag, IconFileAnalytics, IconHome, IconSettingsFilled, IconEye, IconWorldUpload, IconBraces, IconClockHour2, IconAugmentedReality, IconGitMerge, IconGripHorizontal, IconChevronLeft, IconChevronRight, IconPolaroid, IconCircleMinus, IconTable, IconCamera, IconShare, IconCirclePlus, IconLogin, IconWorld, IconLock, IconBinaryTree, IconVariable, IconArrowRightCircle, IconIndentIncrease, IconCodeDots, IconUpload, IconCodePlus, IconExternalLink, IconDownload, IconTemplate, IconCode, IconPalette, IconLink, IconClipboardCheck, IconClipboardCopy, IconSettings, IconMinimize, IconMaximize, IconRss, IconGlobe, IconLinkOff } from '@tabler/icons-react';
25
25
  import { useMediaQuery, useClickOutside, useDisclosure, useDebouncedValue, useSetState, useHotkeys, useFullscreen, getHotkeyHandler } from '@mantine/hooks';
26
26
  import dynamic from 'next/dynamic';
27
27
  import Link from 'next/link';
@@ -1930,6 +1930,9 @@ var init_statusSlice = __esm({
1930
1930
  setPreviews(state, action) {
1931
1931
  state.previews = action.payload;
1932
1932
  },
1933
+ setCurrentLocale(state, action) {
1934
+ state.currentLocale = action.payload;
1935
+ },
1933
1936
  setSectionState(state, action) {
1934
1937
  state.sectionState = { ...state.sectionState, ...action.payload };
1935
1938
  },
@@ -2091,6 +2094,10 @@ var init_recordsSlice = __esm({
2091
2094
  } else if (req.type === "dimension") {
2092
2095
  const item = req.data;
2093
2096
  state.entities.report[item.report_id].dimensions.push(item.id);
2097
+ state.entities.report[item.report_id].dimensions = recalculateOrder(
2098
+ nextEntities.report[item.report_id].dimensions,
2099
+ nextEntities.dimension
2100
+ );
2094
2101
  } else if (req.type === "variant") {
2095
2102
  const item = req.data;
2096
2103
  state.entities.dimension[item.dimension_id].variants.push(item.id);
@@ -2497,6 +2504,7 @@ __export(actions_exports, {
2497
2504
  searchRegenerate: () => searchRegenerate,
2498
2505
  searchRole: () => searchRole,
2499
2506
  searchUser: () => searchUser,
2507
+ setCurrentLocale: () => setCurrentLocale,
2500
2508
  setPreviews: () => setPreviews,
2501
2509
  setQueryParam: () => setQueryParam,
2502
2510
  setSectionState: () => setSectionState,
@@ -2715,7 +2723,7 @@ function revalidateReport(params) {
2715
2723
  return result.data;
2716
2724
  };
2717
2725
  }
2718
- var setStatus, setPreviews, setSectionState, resetSectionState;
2726
+ var setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale;
2719
2727
  var init_actions = __esm({
2720
2728
  "store/actions.ts"() {
2721
2729
  init_esm_shims();
@@ -2727,7 +2735,7 @@ var init_actions = __esm({
2727
2735
  init_variablesSlice();
2728
2736
  init_recordsSlice();
2729
2737
  init_recordsActions();
2730
- ({ setStatus, setPreviews, setSectionState, resetSectionState } = statusActions);
2738
+ ({ setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale } = statusActions);
2731
2739
  }
2732
2740
  });
2733
2741
  function ResourceProvider(props) {
@@ -2994,7 +3002,7 @@ var init_store = __esm({
2994
3002
  storeWrapper = createWrapper(storeFactory);
2995
3003
  }
2996
3004
  });
2997
- function withFetcher(Component, useRef13) {
3005
+ function withFetcher(Component, useRef14) {
2998
3006
  const ComponentWithFetcher = (props) => {
2999
3007
  const {
3000
3008
  id,
@@ -3002,7 +3010,7 @@ function withFetcher(Component, useRef13) {
3002
3010
  skelWidth,
3003
3011
  ...otherProps
3004
3012
  } = props;
3005
- const ref = useRef13(id);
3013
+ const ref = useRef14(id);
3006
3014
  if (ref.isUninitialized || ref.isFetching) {
3007
3015
  return /* @__PURE__ */ jsx(Skeleton, { width: skelWidth, height: skelHeight });
3008
3016
  }
@@ -3099,38 +3107,6 @@ var init_d3plusPropify = __esm({
3099
3107
  d3plusPropify_default = propify;
3100
3108
  }
3101
3109
  });
3102
-
3103
- // libs/viz/defaultConfig.ts
3104
- var defaultConfig_default;
3105
- var init_defaultConfig = __esm({
3106
- "libs/viz/defaultConfig.ts"() {
3107
- init_esm_shims();
3108
- defaultConfig_default = {
3109
- loadingHTML: `<div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">
3110
- <svg class="cp-viz-spinner" width="60px" height="60px" viewBox="0 0 317 317" xmlns="http://www.w3.org/2000/svg">
3111
- <path class="outer" d="M16.43 157.072c0 34.797 12.578 66.644 33.428 91.277l-11.144 11.141c-23.673-27.496-37.992-63.283-37.992-102.418 0-39.133 14.319-74.921 37.992-102.423l11.144 11.144c-20.85 24.63-33.428 56.481-33.428 91.279z"/>
3112
- <path class="outer" d="M157.793 15.708c34.798 0 66.648 12.58 91.28 33.427l11.143-11.144c-27.502-23.676-63.29-37.991-102.423-37.991-39.132 0-74.919 14.315-102.422 37.991l11.148 11.144c24.627-20.847 56.477-33.427 91.274-33.427"/>
3113
- <path class="outer" d="M299.159 157.072c0 34.797-12.578 66.644-33.43 91.277l11.145 11.141c23.674-27.496 37.992-63.283 37.992-102.418 0-39.133-14.318-74.921-37.992-102.423l-11.145 11.144c20.852 24.63 33.43 56.481 33.43 91.279"/>
3114
- <path class="outer" d="M157.793 298.432c-34.797 0-66.647-12.574-91.274-33.424l-11.148 11.138c27.503 23.682 63.29 37.997 102.422 37.997 39.133 0 74.921-14.315 102.423-37.997l-11.143-11.138c-24.632 20.85-56.482 33.424-91.28 33.424"/>
3115
- <path class="middle" d="M226.59 61.474l-7.889 13.659c24.997 18.61 41.184 48.382 41.184 81.94 0 33.555-16.187 63.329-41.184 81.936l7.889 13.664c29.674-21.394 49.004-56.23 49.004-95.6 0-39.373-19.33-74.21-49.004-95.599"/>
3116
- <path class="middle" d="M157.793 259.169c-52.398 0-95.553-39.485-101.399-90.317h-15.814c5.912 59.524 56.131 106.018 117.213 106.018 17.26 0 33.633-3.742 48.404-10.406l-7.893-13.672c-12.425 5.38-26.114 8.377-40.511 8.377"/>
3117
- <path class="middle" d="M157.793 54.976c14.397 0 28.086 2.993 40.511 8.371l7.893-13.667c-14.771-6.669-31.144-10.412-48.404-10.412-61.082 0-111.301 46.493-117.213 106.021h15.814c5.846-50.831 49.001-90.313 101.399-90.313"/>
3118
- <path class="inner" d="M95.371 164.193c-3.476-30.475 15.471-58.324 43.723-67.097l-1.804-15.842c-36.899 9.931-61.986 45.602-57.524 84.719 4.461 39.115 36.934 68.219 75.122 69.584l-1.806-15.838c-29.504-2.186-54.235-25.054-57.711-55.526"/>
3119
- <path class="inner" d="M162.504 94.425c29.508 2.185 54.235 25.053 57.711 55.529 3.476 30.469-15.466 58.319-43.724 67.096l1.806 15.834c36.898-9.927 61.986-45.598 57.525-84.712-4.461-39.117-36.936-68.223-75.125-69.588l1.807 15.841z"/>
3120
- </svg>
3121
- <strong>Loading</strong>
3122
- <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;">
3123
- <a style="color: inherit;" href="https://www.datawheel.us/" target="_blank">
3124
- Built by Datawheel
3125
- </a>
3126
- </sub>
3127
- </div>`,
3128
- noDataHTML: `<div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">
3129
- <strong>No Data Available</strong>
3130
- </div>`
3131
- };
3132
- }
3133
- });
3134
3110
  var ErrorBoundary;
3135
3111
  var init_ErrorBoundary = __esm({
3136
3112
  "views/ErrorBoundary.tsx"() {
@@ -3223,7 +3199,7 @@ function Viz(config) {
3223
3199
  linksFormat: vizProps.linksFormat,
3224
3200
  nodesFormat: vizProps.nodesFormat,
3225
3201
  topojsonFormat: vizProps.topojsonFormat,
3226
- config: { ...defaultConfig_default, ...vizConfig, sectionVariables: sectionVariablesStr }
3202
+ config: { ...vizConfig, sectionVariables: sectionVariablesStr }
3227
3203
  },
3228
3204
  "viz-key"
3229
3205
  ) })
@@ -3238,7 +3214,6 @@ var init_Viz = __esm({
3238
3214
  init_d3plusPropify();
3239
3215
  init_varSwapRecursive();
3240
3216
  init_hooks();
3241
- init_defaultConfig();
3242
3217
  init_hooks();
3243
3218
  init_ErrorBoundary();
3244
3219
  vizTypes = {
@@ -3462,7 +3437,7 @@ function Viz2({
3462
3437
  linksFormat: vizProps.linksFormat,
3463
3438
  nodesFormat: vizProps.nodesFormat,
3464
3439
  topojsonFormat: vizProps.topojsonFormat,
3465
- config: { ...defaultConfig_default, ...vizConfig }
3440
+ config: { ...vizConfig }
3466
3441
  },
3467
3442
  "viz-key"
3468
3443
  ) })
@@ -3475,7 +3450,6 @@ var init_Viz2 = __esm({
3475
3450
  init_esm_shims();
3476
3451
  init_varSwapRecursive();
3477
3452
  init_mortarEval();
3478
- init_defaultConfig();
3479
3453
  init_Graphic();
3480
3454
  init_HTML();
3481
3455
  init_Table();
@@ -4266,11 +4240,12 @@ function TitleIcon({
4266
4240
  }) {
4267
4241
  const [srcSVG, setSrcSVG] = useState(void 0);
4268
4242
  const iconPath = iconType === "custom" ? icon : `/api/cms/read/icons/${iconType}/icon.svg?name=${icon}`;
4243
+ const isSVG = /^.*\.svg*$/.test(iconPath);
4269
4244
  useEffect(() => {
4270
- if (iconType === "custom" || icon.length) {
4245
+ if (iconType === "custom" || isSVG) {
4271
4246
  axios.get(iconPath, { responseType: "text" }).then((resp) => resp.data).then(setSrcSVG).catch(() => void 0);
4272
4247
  }
4273
- }, [icon, iconType, iconPath]);
4248
+ }, [iconType, isSVG, iconPath]);
4274
4249
  const ready = Boolean(srcSVG);
4275
4250
  return /* @__PURE__ */ jsx(Fragment, { children: iconType !== "none" && icon && icon !== "" && ready && /* @__PURE__ */ jsx(
4276
4251
  ThemeIcon,
@@ -4280,8 +4255,8 @@ function TitleIcon({
4280
4255
  radius: iconRadius,
4281
4256
  size: iconSize,
4282
4257
  p: parseInt(iconPadding),
4283
- dangerouslySetInnerHTML: srcSVG ? { __html: srcSVG } : void 0,
4284
- children: null
4258
+ dangerouslySetInnerHTML: srcSVG && isSVG ? { __html: srcSVG } : void 0,
4259
+ children: !isSVG ? /* @__PURE__ */ jsx(Image, { src: iconPath, alt: "Title Icon" }) : null
4285
4260
  }
4286
4261
  ) });
4287
4262
  }
@@ -4541,7 +4516,7 @@ function TitleView({
4541
4516
  const comparison = useComparison();
4542
4517
  const previews = useAppSelector((state) => state.status.previews);
4543
4518
  const previewNames = asComparison ? comparison.status.previews : previews;
4544
- previewNames.map((p) => p.name).join(" | ");
4519
+ const memberName = previewNames.map((p) => p.name).join(" | ");
4545
4520
  const titleElement = /* @__PURE__ */ jsxs(Group, { children: [
4546
4521
  /* @__PURE__ */ jsx(
4547
4522
  TitleIcon,
@@ -4573,7 +4548,7 @@ function TitleView({
4573
4548
  tooltip && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Tooltip, { label: tooltipHTML, withArrow: true, withinPortal: true, children: /* @__PURE__ */ jsx(ActionIcon, { children: /* @__PURE__ */ jsx(IconInfoCircle, {}) }) }) }, "tooltip"),
4574
4549
  /* @__PURE__ */ jsxs("div", { children: [
4575
4550
  finalElement,
4576
- displayName && /* @__PURE__ */ jsx(Text, { className: "bespoke-comparison-title", children: reportName })
4551
+ displayName && /* @__PURE__ */ jsx(Text, { className: "bespoke-comparison-title", children: memberName })
4577
4552
  ] })
4578
4553
  ]
4579
4554
  }
@@ -4969,7 +4944,7 @@ var DesktopNav = ({ contentOutline, showIcons }) => {
4969
4944
  listStyleType: "none"
4970
4945
  }),
4971
4946
  children: contentOutline?.map(
4972
- (node) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsxs(Menu, { trigger: "hover", openDelay: 100, closeDelay: 400, children: [
4947
+ (node) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsxs(Menu, { trigger: "hover", openDelay: 100, closeDelay: 200, children: [
4973
4948
  /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(Anchor, { href: `#bespoke-title-${node.id}`, children: /* @__PURE__ */ jsxs(Group, { spacing: "sm", children: [
4974
4949
  showIcons && /* @__PURE__ */ jsx(TitleIcon, { ...node.iconProps, iconSize: "sm" }),
4975
4950
  /* @__PURE__ */ jsx(Text, { dangerouslySetInnerHTML: { __html: node.label } })
@@ -5770,6 +5745,7 @@ function TitleUI({ onChange, simpleState }) {
5770
5745
  const [iconSize, setIconSize] = useState(simpleState?.iconSize ?? "md");
5771
5746
  const [iconRadius, setIconRadius] = useState(simpleState?.iconRadius ?? "md");
5772
5747
  const [iconPadding, setIconPadding] = useState(simpleState?.iconPadding ?? "1");
5748
+ const inputPathRef = useRef(null);
5773
5749
  const isNoneOrCustom = [TITLE_ICON_TYPES.none.value, TITLE_ICON_TYPES.custom.value].includes(iconType);
5774
5750
  const IconItem = useMemo(() => forwardRef(
5775
5751
  ({ value, ...others }, ref) => {
@@ -5897,17 +5873,31 @@ function TitleUI({ onChange, simpleState }) {
5897
5873
  )
5898
5874
  }
5899
5875
  ),
5900
- iconType === TITLE_ICON_TYPES.custom.value && /* @__PURE__ */ jsx(
5901
- TextInput,
5902
- {
5903
- placeholder: "e.g '/image{{id1}}.png' or 'http://site/image.png'",
5904
- label: "Enter an icon path",
5905
- required: true,
5906
- value: icon,
5907
- description: "Add an absolute or a relative path url",
5908
- onChange: (e) => setIcon(e.currentTarget.value)
5909
- }
5910
- ),
5876
+ iconType === TITLE_ICON_TYPES.custom.value && /* @__PURE__ */ jsxs(Flex, { align: "flex-end", children: [
5877
+ /* @__PURE__ */ jsx(
5878
+ TextInput,
5879
+ {
5880
+ ref: inputPathRef,
5881
+ placeholder: "e.g '/image{{id1}}.png' or 'http://site/image.png'",
5882
+ label: "Enter an icon path",
5883
+ required: true,
5884
+ defaultValue: icon,
5885
+ description: "Add an absolute or a relative path url",
5886
+ onBlur: (e) => setIcon(e.currentTarget.value),
5887
+ sx: { flexGrow: 1 }
5888
+ }
5889
+ ),
5890
+ /* @__PURE__ */ jsx(
5891
+ ActionIcon,
5892
+ {
5893
+ maw: 36,
5894
+ size: 36,
5895
+ onClick: () => inputPathRef ? setIcon(inputPathRef.current.value) : void 0,
5896
+ sx: { flexGrow: 0 },
5897
+ children: /* @__PURE__ */ jsx(IconFileUpload, {})
5898
+ }
5899
+ )
5900
+ ] }),
5911
5901
  iconType !== TITLE_ICON_TYPES.none.value && /* @__PURE__ */ jsxs(Fragment, { children: [
5912
5902
  /* @__PURE__ */ jsx(
5913
5903
  Select,
@@ -6532,6 +6522,26 @@ function stringifyPreview(member) {
6532
6522
  const variant = "variant_slug" in member ? member.variant_slug : member.variant.slug;
6533
6523
  return `${variant}/${member.slug}`;
6534
6524
  }
6525
+
6526
+ // hooks/useCurrentLocale.ts
6527
+ init_esm_shims();
6528
+ init_store2();
6529
+ function useCurrentLocale() {
6530
+ const dispatch = useAppDispatch();
6531
+ const { router, setSearchParam } = useManagerLocation();
6532
+ const { asPath } = router;
6533
+ const [, search] = asPath.split("?");
6534
+ const query = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') : {};
6535
+ const { currentLocale, locales: locales4 } = useAppSelector((state) => state.status);
6536
+ const paramLocale = query.locale || "";
6537
+ useEffect(() => {
6538
+ console.log();
6539
+ if (paramLocale && paramLocale !== "" && locales4.includes(paramLocale) && paramLocale !== currentLocale) {
6540
+ dispatch(actions_exports.setCurrentLocale(paramLocale));
6541
+ }
6542
+ }, [paramLocale]);
6543
+ return currentLocale;
6544
+ }
6535
6545
  function NavPreview({ headings, settings }) {
6536
6546
  const { min = "1", max = "6", icons = "yes" } = settings;
6537
6547
  const contentOutline = useContentOutline(parseInt(min, 10), parseInt(max, 10), headings);
@@ -6785,7 +6795,7 @@ function Block({ blockId, active = true, asComparison = false }) {
6785
6795
  asComparison && comparison.active ? comparison?.variables.attributes : void 0
6786
6796
  );
6787
6797
  const blockContent = getBlockContent(block, locale);
6788
- const formatterFunctions = useFormatterFunctionsForLocale();
6798
+ const formatterFunctions = useFormatterFunctionsForLocale(locale);
6789
6799
  const blockContext = {
6790
6800
  variables,
6791
6801
  query,
@@ -7920,6 +7930,10 @@ var EditButton = ({ sectionId, onActivate }) => {
7920
7930
  const { activeEntity } = useActiveEntity();
7921
7931
  const { handlers } = useSidebar("settings");
7922
7932
  const active = activeEntity.type === "section" && activeEntity.id === sectionId;
7933
+ const openAndActivate = () => {
7934
+ onActivate();
7935
+ handlers.open();
7936
+ };
7923
7937
  return active ? /* @__PURE__ */ jsx(
7924
7938
  Button,
7925
7939
  {
@@ -7931,7 +7945,7 @@ var EditButton = ({ sectionId, onActivate }) => {
7931
7945
  compact: true,
7932
7946
  children: "Edit"
7933
7947
  }
7934
- ) : /* @__PURE__ */ jsx(ActionIcon, { variant: "transparent", onClick: onActivate, children: /* @__PURE__ */ jsx(IconPencil, { size: 18 }) });
7948
+ ) : /* @__PURE__ */ jsx(ActionIcon, { variant: "transparent", onClick: openAndActivate, children: /* @__PURE__ */ jsx(IconPencil, { size: 18 }) });
7935
7949
  };
7936
7950
  function SectionMenu({ sectionId, onActivate }) {
7937
7951
  return /* @__PURE__ */ jsxs(Group, { spacing: 0, children: [
@@ -7947,6 +7961,32 @@ init_cms();
7947
7961
  // components/sections/SectionColumns.tsx
7948
7962
  init_esm_shims();
7949
7963
  init_store2();
7964
+
7965
+ // components/builder/hooks/use-entity-settings.ts
7966
+ init_esm_shims();
7967
+ init_store2();
7968
+ function useEntitySettingsFactory(entityType, entityId) {
7969
+ const entity = useAppSelector((store) => entityId ? store.records.entities[entityType][entityId] : null);
7970
+ const storeSettings = entity?.settings;
7971
+ const [settingsState, setSettingsState] = useSetState(entity?.settings || {});
7972
+ const dispatch = useAppDispatch();
7973
+ const handleChange = useCallback((field, value) => {
7974
+ if (entity) {
7975
+ setSettingsState({ [field]: value });
7976
+ dispatch(actions_exports.updateEntity(entityType, {
7977
+ id: entity.id,
7978
+ settings: { ...entity.settings, [field]: value }
7979
+ }));
7980
+ }
7981
+ }, [dispatch, entity]);
7982
+ useEffect(() => {
7983
+ if (storeSettings)
7984
+ setSettingsState(storeSettings);
7985
+ }, [storeSettings, setSettingsState]);
7986
+ return { settings: settingsState, updateSettings: handleChange };
7987
+ }
7988
+ var useSectionSettings = (sectionId) => useEntitySettingsFactory("section", sectionId);
7989
+ var useReportSettings = (reportId) => useEntitySettingsFactory("report", reportId);
7950
7990
  function SectionColumnsWrapper({
7951
7991
  children,
7952
7992
  containerProps
@@ -7967,11 +8007,11 @@ function SectionColumnsWrapper({
7967
8007
  );
7968
8008
  }
7969
8009
  var SectionColumn = React.forwardRef(
7970
- function SectionColumn2({ children, column, columnSettings = {}, sx = {}, ...rest }, ref) {
8010
+ function SectionColumn2({ children, column, basis, columnSettings = {}, sx = {}, ...rest }, ref) {
7971
8011
  const hasInline = Object.values(column).some((item) => item.settings?.display === "inline");
7972
- const width = columnSettings?.width;
7973
- const theme = useMantineTheme();
7974
- const mediumScreen = useMediaQuery(`(max-width: ${theme.breakpoints.md})`);
8012
+ const width = columnSettings?.width ? `${columnSettings.width}px` : basis;
8013
+ const maxWidth = columnSettings?.width ? `${columnSettings?.width}px` : "100&";
8014
+ const computedMaxWidth = columnSettings?.full ? "100%" : maxWidth;
7975
8015
  return /* @__PURE__ */ jsx(
7976
8016
  Flex,
7977
8017
  {
@@ -7980,11 +8020,18 @@ var SectionColumn = React.forwardRef(
7980
8020
  align: "flex-start",
7981
8021
  direction: hasInline ? "row" : "column",
7982
8022
  wrap: hasInline ? "wrap" : "nowrap",
7983
- maw: width && !mediumScreen ? `${width}px` : "none",
7984
- miw: mediumScreen ? 300 : 400,
8023
+ maw: { base: "100%", md: computedMaxWidth },
8024
+ miw: { base: "none", md: 300 },
7985
8025
  p: 0,
7986
8026
  pos: "relative",
7987
- sx: [{ flexGrow: 1, flexShrink: 1 }, ...packSx(sx)],
8027
+ sx: [
8028
+ {
8029
+ flexGrow: 1,
8030
+ flexShrink: columnSettings?.full ? 0 : 1,
8031
+ flexBasis: columnSettings?.full ? "100%" : width
8032
+ },
8033
+ ...packSx(sx)
8034
+ ],
7988
8035
  ...rest,
7989
8036
  children
7990
8037
  }
@@ -7994,24 +8041,22 @@ var SectionColumn = React.forwardRef(
7994
8041
  var ResizeColumnInput = ({ sectionId, columnIndex }) => {
7995
8042
  const dispatch = useAppDispatch();
7996
8043
  const section = useSectionRef(sectionId).data;
8044
+ const { settings, updateSettings } = useSectionSettings(sectionId);
7997
8045
  if (!section)
7998
8046
  return null;
7999
- const { columnSettings = {} } = section.settings;
8047
+ const { columnSettings = {} } = settings;
8000
8048
  const { width = void 0 } = columnSettings[columnIndex] ? columnSettings[columnIndex] : {};
8001
8049
  const handleChange = (e) => {
8002
8050
  if (section) {
8003
- dispatch(actions_exports.updateEntity("section", {
8004
- id: sectionId,
8005
- settings: {
8006
- ...section.settings,
8007
- columnSettings: {
8008
- ...columnSettings,
8009
- [columnIndex]: {
8010
- width: parseInt(e.target.value, 10)
8011
- }
8051
+ updateSettings(
8052
+ "columnSettings",
8053
+ {
8054
+ ...columnSettings,
8055
+ [columnIndex]: {
8056
+ width: parseInt(e.target.value, 10)
8012
8057
  }
8013
8058
  }
8014
- }));
8059
+ );
8015
8060
  }
8016
8061
  };
8017
8062
  const handleReset = () => {
@@ -8030,34 +8075,51 @@ var ResizeColumnInput = ({ sectionId, columnIndex }) => {
8030
8075
  }));
8031
8076
  }
8032
8077
  };
8033
- return /* @__PURE__ */ jsx(
8034
- Box,
8078
+ const handleFullWidthChange = (event) => {
8079
+ updateSettings("columnSettings", {
8080
+ ...columnSettings,
8081
+ [columnIndex]: {
8082
+ ...columnSettings[columnIndex] || {},
8083
+ full: event.currentTarget.checked
8084
+ }
8085
+ });
8086
+ };
8087
+ return /* @__PURE__ */ jsxs(
8088
+ Group,
8035
8089
  {
8036
8090
  className: "bespoke-resize-col",
8037
8091
  pos: "absolute",
8038
8092
  top: -12,
8039
8093
  left: "50%",
8040
8094
  sx: {
8095
+ borderRadius: "4px",
8041
8096
  transform: "translate(-50%, 0%)",
8042
8097
  zIndex: 20
8043
8098
  },
8044
- p: "sm",
8045
- maw: 110,
8046
- children: /* @__PURE__ */ jsx(
8047
- Input,
8048
- {
8049
- placeholder: "auto",
8050
- w: "fit-content",
8051
- miw: "none",
8052
- variant: "filled",
8053
- type: "number",
8054
- value: width || "auto",
8055
- onChange: handleChange,
8056
- size: "xs",
8057
- p: 0,
8058
- rightSection: /* @__PURE__ */ jsx(IconX, { onClick: handleReset, size: 8 })
8059
- }
8060
- )
8099
+ py: 0,
8100
+ px: "xs",
8101
+ maw: 180,
8102
+ bg: "white",
8103
+ noWrap: true,
8104
+ children: [
8105
+ /* @__PURE__ */ jsx(Checkbox, { label: "100%", size: "xs", onChange: handleFullWidthChange, checked: columnSettings[columnIndex]?.full }),
8106
+ /* @__PURE__ */ jsx(
8107
+ Input,
8108
+ {
8109
+ placeholder: "auto",
8110
+ w: "fit-content",
8111
+ miw: "none",
8112
+ variant: "filled",
8113
+ type: "number",
8114
+ value: width || "auto",
8115
+ maw: 110,
8116
+ onChange: handleChange,
8117
+ size: "xs",
8118
+ p: 0,
8119
+ rightSection: /* @__PURE__ */ jsx(IconX, { onClick: handleReset, size: 8 })
8120
+ }
8121
+ )
8122
+ ]
8061
8123
  }
8062
8124
  );
8063
8125
  };
@@ -8565,8 +8627,8 @@ function Section({ section }) {
8565
8627
  const blocks = sectionBlocks.reduce((blocks2, block) => ({ ...blocks2, [block.id]: block }), {});
8566
8628
  console.log("blocks", blocks);
8567
8629
  sectionColumns = [
8568
- /* @__PURE__ */ jsx(SectionColumn, { column: blocks, sx: { flexBasis: "50%" }, children: getBlockRenderers(Object.values(sectionBlocks)) }, "original"),
8569
- /* @__PURE__ */ jsx(SectionColumn, { column: blocks, sx: { flexBasis: "50%" }, children: getBlockRenderers(Object.values(sectionBlocks), true) }, "comparison")
8630
+ /* @__PURE__ */ jsx(SectionColumn, { column: blocks, basis: "50%", children: getBlockRenderers(Object.values(sectionBlocks)) }, "original"),
8631
+ /* @__PURE__ */ jsx(SectionColumn, { column: blocks, basis: "50%", children: getBlockRenderers(Object.values(sectionBlocks), true) }, "comparison")
8570
8632
  // TODO: maybe add more comparisons?
8571
8633
  ];
8572
8634
  } else {
@@ -8583,7 +8645,7 @@ function Section({ section }) {
8583
8645
  {
8584
8646
  column,
8585
8647
  columnSettings,
8586
- sx: { flexBasis: `${100 / colsQty}%`, flexShrink: 1 },
8648
+ basis: `calc(${100 / colsQty}% - (10px * ${colsQty}))`,
8587
8649
  children: columnBlocks.map((item) => {
8588
8650
  if (!item.id || !status[item.id]?.allowed && item.type !== BLOCK_TYPES.NAV)
8589
8651
  return null;
@@ -8600,7 +8662,7 @@ function Section({ section }) {
8600
8662
  return /* @__PURE__ */ jsx(
8601
8663
  Box,
8602
8664
  {
8603
- className: "bespoke-Block-wrapper",
8665
+ className: `bespoke-Block-wrapper bespoke-${item.type}-wrapper`,
8604
8666
  id: `bespoke-Block-${item.id}`,
8605
8667
  sx: blockStyles,
8606
8668
  py: site_default.block.padding,
@@ -8627,7 +8689,7 @@ function Section({ section }) {
8627
8689
  {
8628
8690
  containerProps: {
8629
8691
  gap: sectionSettings2.columnGutter || "md",
8630
- wrap: { base: "wrap", md: "nowrap" },
8692
+ wrap: comparison.active ? "nowrap" : "wrap",
8631
8693
  sx: { zIndex: 20 }
8632
8694
  },
8633
8695
  children: sectionColumns
@@ -9918,7 +9980,7 @@ function DimensionAutocomplete({ id, locale, onSelect, initialSelection = void 0
9918
9980
  onChange: onChangeVariant
9919
9981
  }
9920
9982
  ),
9921
- currentMember && !searchMode && /* @__PURE__ */ jsx("div", { style: { maxWidth: 200 }, children: /* @__PURE__ */ jsx(
9983
+ currentMember && !searchMode && /* @__PURE__ */ jsx("div", { style: { maxWidth: 100 }, children: /* @__PURE__ */ jsx(
9922
9984
  Badge,
9923
9985
  {
9924
9986
  variant: "filled",
@@ -9978,7 +10040,6 @@ function HeaderLayout(props) {
9978
10040
  }
9979
10041
 
9980
10042
  // components/builder/CMSHeader.tsx
9981
- init_statusSlice();
9982
10043
  init_hooks();
9983
10044
  function CMSHeader(props) {
9984
10045
  const { report: currentReport } = props;
@@ -9991,7 +10052,7 @@ function CMSHeader(props) {
9991
10052
  const reportId = Number.parseInt(location.params[0]);
9992
10053
  const reportRef = useReportRef(reportId);
9993
10054
  const profilePrefix = useProfilePrefix();
9994
- const currentLocale = useAppSelector((state) => state.status.currentLocale);
10055
+ const currentLocale = useCurrentLocale();
9995
10056
  const localeDefault10 = useAppSelector((state) => state.status.localeDefault);
9996
10057
  const localeOptions = useAppSelector(selectLocaleOptions);
9997
10058
  const previewsFromState = useAppSelector((state) => state.status.previews);
@@ -10005,13 +10066,12 @@ function CMSHeader(props) {
10005
10066
  const showPreviewSelector = useMemo(() => {
10006
10067
  return dimensions.length > 0;
10007
10068
  }, [dimensions]);
10008
- const [previewMembers, setPreviewMembers] = useState([]);
10009
10069
  const [initialFavorites, setInitialFavorites] = useState([]);
10010
- const previewPath = previewsFromState.reduce((acc, member) => {
10070
+ const previewPath = previewsFromState.filter((member) => member.variant_slug).reduce((acc, member) => {
10011
10071
  return acc.concat([member.variant_slug, member.slug]);
10012
10072
  }, []);
10013
10073
  const localePrefix = currentLocale === localeDefault10 ? "" : `/${currentLocale}`;
10014
- const realPath = `${localePrefix}${profilePrefix}/${previewPath.join("/")}`;
10074
+ const realPath = previewPath.length ? `${localePrefix}${profilePrefix}/${previewPath.join("/")}` : "";
10015
10075
  const onSelectPreview = (previewMember) => {
10016
10076
  const newPreviews = currentReport.dimensions.map((dId) => {
10017
10077
  let member;
@@ -10019,7 +10079,7 @@ function CMSHeader(props) {
10019
10079
  if (previewMember.dimension_id === dId) {
10020
10080
  member = previewMember;
10021
10081
  } else {
10022
- const anotherMember = previewMembers.find((m) => m ? m.dimension_id === dId : false);
10082
+ const anotherMember = previewsFromState.find((m) => m ? m.dimension_id === dId : false);
10023
10083
  if (anotherMember) {
10024
10084
  member = anotherMember;
10025
10085
  }
@@ -10027,7 +10087,22 @@ function CMSHeader(props) {
10027
10087
  }
10028
10088
  return member;
10029
10089
  });
10030
- setPreviewMembers(newPreviews);
10090
+ dispatch(actions_exports.recalculateVariables(resource, {
10091
+ previews: newPreviews.filter((preview) => preview).map((preview) => ({
10092
+ ...preview,
10093
+ report_name: preview.report?.name || preview.report_name,
10094
+ report_id: preview.report?.id || preview.report_id,
10095
+ dimension_id: preview.dimension?.id || preview.dimension_id,
10096
+ dimension_name: preview.dimension?.name || preview.dimension_name,
10097
+ variant_id: preview.variant?.id || preview.variant_id,
10098
+ variant_name: preview.variant?.name || preview.variant_name,
10099
+ variant_slug: preview.variant?.slug || preview.variant_slug
10100
+ }))
10101
+ }));
10102
+ };
10103
+ const onSelectLocale = (previewLocale) => {
10104
+ location.setSearchParam("locale", previewLocale);
10105
+ dispatch(actions_exports.recalculateVariables(resource, { previews: [] }));
10031
10106
  };
10032
10107
  const maybeRevalidateUrl = useCallback(async () => {
10033
10108
  try {
@@ -10059,20 +10134,15 @@ function CMSHeader(props) {
10059
10134
  }
10060
10135
  }, [realPath]);
10061
10136
  useEffect(() => {
10062
- setPreviewMembers([]);
10137
+ dispatch(actions_exports.recalculateVariables(resource, {
10138
+ previews: []
10139
+ }));
10063
10140
  }, [dimensions]);
10064
10141
  useEffect(() => {
10065
10142
  if (previewsFromState && previewsFromState.length > 0) {
10066
10143
  setInitialFavorites(previewsFromState.map((ps) => ({ variantId: ps.variant_id, contentId: ps.content_id })));
10067
10144
  }
10068
10145
  }, [previewsFromState]);
10069
- useEffect(() => {
10070
- if (previewMembers.length > 0) {
10071
- dispatch(actions_exports.recalculateVariables(resource, {
10072
- previews: previewMembers
10073
- }));
10074
- }
10075
- }, [previewMembers]);
10076
10146
  useEffect(() => {
10077
10147
  if (castedUser) {
10078
10148
  if (castedUser.bespoke_app_metadata && castedUser.bespoke_app_metadata.reports && Array.isArray(castedUser.bespoke_app_metadata.reports)) {
@@ -10082,12 +10152,12 @@ function CMSHeader(props) {
10082
10152
  }
10083
10153
  }
10084
10154
  }
10085
- }, [castedUser, id, previewMembers]);
10155
+ }, [castedUser, id, previewsFromState]);
10086
10156
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10087
10157
  /* @__PURE__ */ jsx(
10088
10158
  HeaderLayout,
10089
10159
  {
10090
- center: /* @__PURE__ */ jsxs(Group, { spacing: "xs", children: [
10160
+ center: /* @__PURE__ */ jsxs(Group, { spacing: 4, children: [
10091
10161
  /* @__PURE__ */ jsx(
10092
10162
  ActionIcon,
10093
10163
  {
@@ -10103,13 +10173,11 @@ function CMSHeader(props) {
10103
10173
  /* @__PURE__ */ jsx(
10104
10174
  Select,
10105
10175
  {
10106
- style: { width: 60 },
10176
+ w: 60,
10107
10177
  size: "xs",
10108
10178
  data: localeOptions,
10109
10179
  value: currentLocale,
10110
- onChange: (value) => dispatch(
10111
- statusActions.setStatus({ currentLocale: value || localeDefault10, previews: [] })
10112
- )
10180
+ onChange: onSelectLocale
10113
10181
  }
10114
10182
  ),
10115
10183
  showPreviewSelector && dimensions.map((dId, ix) => /* @__PURE__ */ jsx(
@@ -10133,6 +10201,7 @@ function CMSHeader(props) {
10133
10201
  bg: "#E9ECEF",
10134
10202
  title: "Open report in new tab",
10135
10203
  color: "dark",
10204
+ disabled: !realPath,
10136
10205
  children: /* @__PURE__ */ jsx(IconEye, { size: 20 })
10137
10206
  }
10138
10207
  ) }),
@@ -11777,32 +11846,6 @@ function SectionHeader({
11777
11846
  // components/sections/Section.tsx
11778
11847
  init_cms();
11779
11848
  init_hooks();
11780
-
11781
- // components/builder/hooks/use-entity-settings.ts
11782
- init_esm_shims();
11783
- init_store2();
11784
- function useEntitySettingsFactory(entityType, entityId) {
11785
- const entity = useAppSelector((store) => entityId ? store.records.entities[entityType][entityId] : null);
11786
- const storeSettings = entity?.settings;
11787
- const [settingsState, setSettingsState] = useSetState(entity?.settings || {});
11788
- const dispatch = useAppDispatch();
11789
- const handleChange = useCallback((field, value) => {
11790
- if (entity) {
11791
- setSettingsState({ [field]: value });
11792
- dispatch(actions_exports.updateEntity(entityType, {
11793
- id: entity.id,
11794
- settings: { ...entity.settings, [field]: value }
11795
- }));
11796
- }
11797
- }, [dispatch, entity]);
11798
- useEffect(() => {
11799
- if (storeSettings)
11800
- setSettingsState(storeSettings);
11801
- }, [storeSettings, setSettingsState]);
11802
- return { settings: settingsState, updateSettings: handleChange };
11803
- }
11804
- var useSectionSettings = (sectionId) => useEntitySettingsFactory("section", sectionId);
11805
- var useReportSettings = (reportId) => useEntitySettingsFactory("report", reportId);
11806
11849
  var blockTypes = Object.values(BLOCK_TYPES);
11807
11850
  var CreateBlockButton = ({ columns, columnIndex, section }) => {
11808
11851
  const dispatch = useAppDispatch();
@@ -12054,7 +12097,7 @@ function SectionEditor({
12054
12097
  p: section.settings.margin || "md",
12055
12098
  style: { zIndex: 2 },
12056
12099
  gap: section.settings.columnGutter || "md",
12057
- wrap: { base: "wrap", md: "nowrap" }
12100
+ wrap: "wrap"
12058
12101
  },
12059
12102
  children: /* @__PURE__ */ jsxs(DragDropContext, { onDragEnd, onDragStart, children: [
12060
12103
  orderedCols.map((columnIndex) => {
@@ -12065,9 +12108,9 @@ function SectionEditor({
12065
12108
  column: columns[columnIndex],
12066
12109
  columnSettings: columnSettings[columnIndex],
12067
12110
  ref: provided.innerRef,
12111
+ basis: `calc(${100 / columnsQty}% - (10px * ${columnsQty}))`,
12068
12112
  sx: {
12069
12113
  // extra styles for columns on editor
12070
- flexBasis: `${100 / columnsQty}%`,
12071
12114
  background: snapshot.isDraggingOver ? theme.colors[theme.primaryColor][0] : "inherit",
12072
12115
  border: "1px solid transparent",
12073
12116
  "& .bespoke-resize-col": {
@@ -12315,15 +12358,23 @@ var SectionItem = forwardRef(
12315
12358
  style: { flexShrink: 0 }
12316
12359
  }
12317
12360
  ),
12318
- edit ? /* @__PURE__ */ jsx(NameEditor, { section, onEnd: saveAndClose }) : /* @__PURE__ */ jsx(
12319
- Text,
12320
- {
12321
- size: "sm",
12322
- c: sectionColor,
12323
- sx: { whiteSpace: "nowrap", textOverflow: "ellipsis", overflow: "hidden" },
12324
- children: name
12325
- }
12326
- )
12361
+ edit ? /* @__PURE__ */ jsx(NameEditor, { section, onEnd: saveAndClose }) : /* @__PURE__ */ jsxs(Group, { spacing: 4, align: "flex-end", children: [
12362
+ /* @__PURE__ */ jsxs(Text, { size: "sm", fw: 500, color: "gray.5", span: true, children: [
12363
+ section.id,
12364
+ " -"
12365
+ ] }),
12366
+ /* @__PURE__ */ jsx(
12367
+ Text,
12368
+ {
12369
+ size: "sm",
12370
+ c: sectionColor,
12371
+ maw: 220,
12372
+ sx: { whiteSpace: "nowrap", textOverflow: "ellipsis", overflow: "hidden" },
12373
+ span: true,
12374
+ children: name
12375
+ }
12376
+ )
12377
+ ] })
12327
12378
  ] }),
12328
12379
  /* @__PURE__ */ jsxs(Group, { spacing: "xs", children: [
12329
12380
  section.settings.hidden && /* @__PURE__ */ jsx(IconEyeOff, { size: "0.8rem", color: theme.colors["red"][3] }),
@@ -13068,7 +13119,6 @@ function InteractiveReport(props) {
13068
13119
  const maybeActivate = useCallback((sectionId) => {
13069
13120
  const onActivate = () => {
13070
13121
  selectEntity({ type: "section", id: sectionId });
13071
- settingsSidebar.handlers.open();
13072
13122
  dispatch(recalculateVariables(resource, { sid: sectionId }));
13073
13123
  };
13074
13124
  if (previews.length < report.dimensions.length) {
@@ -13132,7 +13182,9 @@ function InteractiveReport(props) {
13132
13182
  ]
13133
13183
  }
13134
13184
  ), [sectionOrder, activeEntity.id, maybeActivate]);
13135
- const scrollContainerWidth = 50 + (toolsSidebar.opened ? 350 : 50) + (settingsSidebar.opened ? 350 : 50);
13185
+ const settingsVisible = Boolean(activeEntity.id);
13186
+ const settingsWidthPlaceholder = settingsVisible ? 50 : 0;
13187
+ const scrollContainerWidth = 50 + (toolsSidebar.opened ? 350 : 50) + (settingsSidebar.opened ? 350 : settingsWidthPlaceholder);
13136
13188
  return /* @__PURE__ */ jsxs(Flex, { h: "100vh", children: [
13137
13189
  /* @__PURE__ */ jsx(ToolsSidebar, { scrollContainer: mainContainer }),
13138
13190
  /* @__PURE__ */ jsxs(Box, { sx: { flexGrow: 1 }, pos: "relative", children: [
@@ -13143,6 +13195,11 @@ function InteractiveReport(props) {
13143
13195
  w: `calc(100vw - ${scrollContainerWidth}px)`,
13144
13196
  viewportRef: mainContainer,
13145
13197
  h: "calc(100vh - 50px)",
13198
+ styles: {
13199
+ scrollbar: {
13200
+ zIndex: 9999
13201
+ }
13202
+ },
13146
13203
  offsetScrollbars: true,
13147
13204
  children: /* @__PURE__ */ jsxs(Stack, { styles: { backgroundColor: theme.colors.gray[2] }, spacing: 0, children: [
13148
13205
  /* @__PURE__ */ jsxs(Alert, { icon: /* @__PURE__ */ jsx(IconFlag, {}), children: [
package/dist/server.js CHANGED
@@ -1548,20 +1548,26 @@ function readMemberFactory(db) {
1548
1548
  });
1549
1549
  whereClause.content_id = entities.map((item) => item.content_id);
1550
1550
  } else if (mode === "slugs") {
1551
- const entities = await Search.findAll({
1551
+ const queries = params.slugs.map((item) => Search.findAll({
1552
1552
  attributes: ["content_id"],
1553
1553
  where: {
1554
- slug: params.slugs.map((item) => item.memberSlug)
1554
+ slug: item.memberSlug
1555
1555
  },
1556
1556
  include: {
1557
1557
  association: "variant",
1558
1558
  attributes: ["id", "name", "slug"],
1559
1559
  required: true,
1560
1560
  where: {
1561
- slug: params.slugs.map((item) => item.variantSlug)
1561
+ slug: item.variantSlug
1562
1562
  }
1563
1563
  }
1564
- });
1564
+ }));
1565
+ const entities = await Promise.all(queries).then((results) => results.reduce(
1566
+ (acc, items) => {
1567
+ return acc.concat(items);
1568
+ },
1569
+ []
1570
+ ));
1565
1571
  whereClause.content_id = entities.map((item) => item.content_id);
1566
1572
  } else if (mode === "related") {
1567
1573
  const levelWhereClause = () => {
@@ -2015,7 +2021,8 @@ var blockQuery = {
2015
2021
  var dimensionQuery = {
2016
2022
  include: [
2017
2023
  { association: "variants", separate: true }
2018
- ]
2024
+ ],
2025
+ order: [["ordering", "ASC"]]
2019
2026
  };
2020
2027
  var sectionQuery = {
2021
2028
  include: [
@@ -2226,7 +2233,13 @@ function dbReportFactory(db) {
2226
2233
  include,
2227
2234
  locales: locales9 = reportLocales
2228
2235
  } = {}) {
2229
- const idList = id == null ? [] : [].concat(id);
2236
+ const allIdsList = id == null ? [] : [].concat(id);
2237
+ const idList = allIdsList.reduce((uniques, currentValue) => {
2238
+ if (!uniques.includes(currentValue)) {
2239
+ uniques.push(currentValue);
2240
+ }
2241
+ return uniques;
2242
+ }, []);
2230
2243
  const entities = await Report.findAll({
2231
2244
  where: idList.length > 0 ? { id: idList } : void 0,
2232
2245
  include: include ? reportQuery.include : void 0
@@ -3872,6 +3885,7 @@ __export(actions_exports, {
3872
3885
  searchRegenerate: () => searchRegenerate,
3873
3886
  searchRole: () => searchRole,
3874
3887
  searchUser: () => searchUser,
3888
+ setCurrentLocale: () => setCurrentLocale,
3875
3889
  setPreviews: () => setPreviews,
3876
3890
  setQueryParam: () => setQueryParam,
3877
3891
  setSectionState: () => setSectionState,
@@ -4949,6 +4963,9 @@ var statusSlice = createSlice({
4949
4963
  setPreviews(state, action) {
4950
4964
  state.previews = action.payload;
4951
4965
  },
4966
+ setCurrentLocale(state, action) {
4967
+ state.currentLocale = action.payload;
4968
+ },
4952
4969
  setSectionState(state, action) {
4953
4970
  state.sectionState = { ...state.sectionState, ...action.payload };
4954
4971
  },
@@ -5080,6 +5097,10 @@ var recordsSlice = createSlice({
5080
5097
  } else if (req.type === "dimension") {
5081
5098
  const item = req.data;
5082
5099
  state.entities.report[item.report_id].dimensions.push(item.id);
5100
+ state.entities.report[item.report_id].dimensions = recalculateOrder(
5101
+ nextEntities.report[item.report_id].dimensions,
5102
+ nextEntities.dimension
5103
+ );
5083
5104
  } else if (req.type === "variant") {
5084
5105
  const item = req.data;
5085
5106
  state.entities.dimension[item.dimension_id].variants.push(item.id);
@@ -5434,7 +5455,7 @@ function keyMakerDelete(entity, params) {
5434
5455
  }
5435
5456
 
5436
5457
  // store/actions.ts
5437
- var { setStatus, setPreviews, setSectionState, resetSectionState } = statusActions;
5458
+ var { setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale } = statusActions;
5438
5459
  function variantValidateSlug(dimension, slug) {
5439
5460
  return async (_, __, api) => {
5440
5461
  const result = await api.validateVariantSlug({ dimension, slug });
@@ -5805,7 +5826,7 @@ function BespokeRendererStaticProps(options) {
5805
5826
  ]);
5806
5827
  const state = store.getState();
5807
5828
  const formatterList = selectFormatterList(state);
5808
- const formatters = funcifyFormattersByLocale(formatterList, localeDefault9);
5829
+ const formatters = funcifyFormattersByLocale(formatterList, locale);
5809
5830
  const sectionList = selectSectionList(state);
5810
5831
  const blockRecords = selectBlockRecords(state);
5811
5832
  const publicBlockRecords = { ...blockRecords };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {