@datawheel/bespoke 0.3.2 → 0.3.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/dist/index.js +231 -164
- package/dist/server.js +38 -7
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { date } from 'd3plus-axis';
|
|
|
8
8
|
import { assign, closest, merge, isObject } from 'd3plus-common';
|
|
9
9
|
import { strip, titleCase } from 'd3plus-text';
|
|
10
10
|
import yn3 from 'yn';
|
|
11
|
+
import axiosRetry from 'axios-retry';
|
|
11
12
|
import toposort from 'toposort';
|
|
12
13
|
import getConfig from 'next/config';
|
|
13
14
|
import { schema, normalize } from 'normalizr';
|
|
@@ -17,11 +18,11 @@ import { Notifications, notifications } from '@mantine/notifications';
|
|
|
17
18
|
import React, { forwardRef, createContext, useState, useCallback, useRef, useEffect, useMemo, useContext, memo, Fragment as Fragment$1, createElement } from 'react';
|
|
18
19
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
19
20
|
import { useDispatch, useSelector } from 'react-redux';
|
|
20
|
-
import { Stack, Text, Badge, Group,
|
|
21
|
+
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
22
|
import { dataConcat } from 'd3plus-viz';
|
|
22
23
|
import * as d3plus from 'd3plus-react';
|
|
23
24
|
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';
|
|
25
|
+
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
26
|
import { useMediaQuery, useClickOutside, useDisclosure, useDebouncedValue, useSetState, useHotkeys, useFullscreen, getHotkeyHandler } from '@mantine/hooks';
|
|
26
27
|
import dynamic from 'next/dynamic';
|
|
27
28
|
import Link from 'next/link';
|
|
@@ -1366,6 +1367,15 @@ var init_runConsumers = __esm({
|
|
|
1366
1367
|
init_consts();
|
|
1367
1368
|
debug = yn3(process.env.NEXT_PUBLIC_REPORTS_DEBUG);
|
|
1368
1369
|
ORIGIN = process.env.REPORTS_ORIGIN || "";
|
|
1370
|
+
axiosRetry(axios, {
|
|
1371
|
+
retries: 3,
|
|
1372
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
1373
|
+
onRetry: (retryCount, error, requestConfig) => {
|
|
1374
|
+
console.log("Generator request failed. Retrying... Count: ", retryCount);
|
|
1375
|
+
console.log("URL: ", requestConfig.url);
|
|
1376
|
+
console.log(error.message);
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1369
1379
|
axios.interceptors.request.use((config) => ({
|
|
1370
1380
|
...config,
|
|
1371
1381
|
requestStart: Date.now()
|
|
@@ -1930,6 +1940,9 @@ var init_statusSlice = __esm({
|
|
|
1930
1940
|
setPreviews(state, action) {
|
|
1931
1941
|
state.previews = action.payload;
|
|
1932
1942
|
},
|
|
1943
|
+
setCurrentLocale(state, action) {
|
|
1944
|
+
state.currentLocale = action.payload;
|
|
1945
|
+
},
|
|
1933
1946
|
setSectionState(state, action) {
|
|
1934
1947
|
state.sectionState = { ...state.sectionState, ...action.payload };
|
|
1935
1948
|
},
|
|
@@ -2091,6 +2104,10 @@ var init_recordsSlice = __esm({
|
|
|
2091
2104
|
} else if (req.type === "dimension") {
|
|
2092
2105
|
const item = req.data;
|
|
2093
2106
|
state.entities.report[item.report_id].dimensions.push(item.id);
|
|
2107
|
+
state.entities.report[item.report_id].dimensions = recalculateOrder(
|
|
2108
|
+
nextEntities.report[item.report_id].dimensions,
|
|
2109
|
+
nextEntities.dimension
|
|
2110
|
+
);
|
|
2094
2111
|
} else if (req.type === "variant") {
|
|
2095
2112
|
const item = req.data;
|
|
2096
2113
|
state.entities.dimension[item.dimension_id].variants.push(item.id);
|
|
@@ -2497,6 +2514,7 @@ __export(actions_exports, {
|
|
|
2497
2514
|
searchRegenerate: () => searchRegenerate,
|
|
2498
2515
|
searchRole: () => searchRole,
|
|
2499
2516
|
searchUser: () => searchUser,
|
|
2517
|
+
setCurrentLocale: () => setCurrentLocale,
|
|
2500
2518
|
setPreviews: () => setPreviews,
|
|
2501
2519
|
setQueryParam: () => setQueryParam,
|
|
2502
2520
|
setSectionState: () => setSectionState,
|
|
@@ -2715,7 +2733,7 @@ function revalidateReport(params) {
|
|
|
2715
2733
|
return result.data;
|
|
2716
2734
|
};
|
|
2717
2735
|
}
|
|
2718
|
-
var setStatus, setPreviews, setSectionState, resetSectionState;
|
|
2736
|
+
var setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale;
|
|
2719
2737
|
var init_actions = __esm({
|
|
2720
2738
|
"store/actions.ts"() {
|
|
2721
2739
|
init_esm_shims();
|
|
@@ -2727,7 +2745,7 @@ var init_actions = __esm({
|
|
|
2727
2745
|
init_variablesSlice();
|
|
2728
2746
|
init_recordsSlice();
|
|
2729
2747
|
init_recordsActions();
|
|
2730
|
-
({ setStatus, setPreviews, setSectionState, resetSectionState } = statusActions);
|
|
2748
|
+
({ setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale } = statusActions);
|
|
2731
2749
|
}
|
|
2732
2750
|
});
|
|
2733
2751
|
function ResourceProvider(props) {
|
|
@@ -2994,7 +3012,7 @@ var init_store = __esm({
|
|
|
2994
3012
|
storeWrapper = createWrapper(storeFactory);
|
|
2995
3013
|
}
|
|
2996
3014
|
});
|
|
2997
|
-
function withFetcher(Component,
|
|
3015
|
+
function withFetcher(Component, useRef14) {
|
|
2998
3016
|
const ComponentWithFetcher = (props) => {
|
|
2999
3017
|
const {
|
|
3000
3018
|
id,
|
|
@@ -3002,7 +3020,7 @@ function withFetcher(Component, useRef13) {
|
|
|
3002
3020
|
skelWidth,
|
|
3003
3021
|
...otherProps
|
|
3004
3022
|
} = props;
|
|
3005
|
-
const ref =
|
|
3023
|
+
const ref = useRef14(id);
|
|
3006
3024
|
if (ref.isUninitialized || ref.isFetching) {
|
|
3007
3025
|
return /* @__PURE__ */ jsx(Skeleton, { width: skelWidth, height: skelHeight });
|
|
3008
3026
|
}
|
|
@@ -3099,38 +3117,6 @@ var init_d3plusPropify = __esm({
|
|
|
3099
3117
|
d3plusPropify_default = propify;
|
|
3100
3118
|
}
|
|
3101
3119
|
});
|
|
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
3120
|
var ErrorBoundary;
|
|
3135
3121
|
var init_ErrorBoundary = __esm({
|
|
3136
3122
|
"views/ErrorBoundary.tsx"() {
|
|
@@ -3223,7 +3209,7 @@ function Viz(config) {
|
|
|
3223
3209
|
linksFormat: vizProps.linksFormat,
|
|
3224
3210
|
nodesFormat: vizProps.nodesFormat,
|
|
3225
3211
|
topojsonFormat: vizProps.topojsonFormat,
|
|
3226
|
-
config: { ...
|
|
3212
|
+
config: { ...vizConfig, sectionVariables: sectionVariablesStr }
|
|
3227
3213
|
},
|
|
3228
3214
|
"viz-key"
|
|
3229
3215
|
) })
|
|
@@ -3238,7 +3224,6 @@ var init_Viz = __esm({
|
|
|
3238
3224
|
init_d3plusPropify();
|
|
3239
3225
|
init_varSwapRecursive();
|
|
3240
3226
|
init_hooks();
|
|
3241
|
-
init_defaultConfig();
|
|
3242
3227
|
init_hooks();
|
|
3243
3228
|
init_ErrorBoundary();
|
|
3244
3229
|
vizTypes = {
|
|
@@ -3462,7 +3447,7 @@ function Viz2({
|
|
|
3462
3447
|
linksFormat: vizProps.linksFormat,
|
|
3463
3448
|
nodesFormat: vizProps.nodesFormat,
|
|
3464
3449
|
topojsonFormat: vizProps.topojsonFormat,
|
|
3465
|
-
config: { ...
|
|
3450
|
+
config: { ...vizConfig }
|
|
3466
3451
|
},
|
|
3467
3452
|
"viz-key"
|
|
3468
3453
|
) })
|
|
@@ -3475,7 +3460,6 @@ var init_Viz2 = __esm({
|
|
|
3475
3460
|
init_esm_shims();
|
|
3476
3461
|
init_varSwapRecursive();
|
|
3477
3462
|
init_mortarEval();
|
|
3478
|
-
init_defaultConfig();
|
|
3479
3463
|
init_Graphic();
|
|
3480
3464
|
init_HTML();
|
|
3481
3465
|
init_Table();
|
|
@@ -4266,11 +4250,12 @@ function TitleIcon({
|
|
|
4266
4250
|
}) {
|
|
4267
4251
|
const [srcSVG, setSrcSVG] = useState(void 0);
|
|
4268
4252
|
const iconPath = iconType === "custom" ? icon : `/api/cms/read/icons/${iconType}/icon.svg?name=${icon}`;
|
|
4253
|
+
const isSVG = /^.*\.svg*$/.test(iconPath);
|
|
4269
4254
|
useEffect(() => {
|
|
4270
|
-
if (iconType === "custom" ||
|
|
4255
|
+
if (iconType === "custom" || isSVG) {
|
|
4271
4256
|
axios.get(iconPath, { responseType: "text" }).then((resp) => resp.data).then(setSrcSVG).catch(() => void 0);
|
|
4272
4257
|
}
|
|
4273
|
-
}, [
|
|
4258
|
+
}, [iconType, isSVG, iconPath]);
|
|
4274
4259
|
const ready = Boolean(srcSVG);
|
|
4275
4260
|
return /* @__PURE__ */ jsx(Fragment, { children: iconType !== "none" && icon && icon !== "" && ready && /* @__PURE__ */ jsx(
|
|
4276
4261
|
ThemeIcon,
|
|
@@ -4280,8 +4265,8 @@ function TitleIcon({
|
|
|
4280
4265
|
radius: iconRadius,
|
|
4281
4266
|
size: iconSize,
|
|
4282
4267
|
p: parseInt(iconPadding),
|
|
4283
|
-
dangerouslySetInnerHTML: srcSVG ? { __html: srcSVG } : void 0,
|
|
4284
|
-
children: null
|
|
4268
|
+
dangerouslySetInnerHTML: srcSVG && isSVG ? { __html: srcSVG } : void 0,
|
|
4269
|
+
children: !isSVG ? /* @__PURE__ */ jsx(Image, { src: iconPath, alt: "Title Icon" }) : null
|
|
4285
4270
|
}
|
|
4286
4271
|
) });
|
|
4287
4272
|
}
|
|
@@ -4541,7 +4526,7 @@ function TitleView({
|
|
|
4541
4526
|
const comparison = useComparison();
|
|
4542
4527
|
const previews = useAppSelector((state) => state.status.previews);
|
|
4543
4528
|
const previewNames = asComparison ? comparison.status.previews : previews;
|
|
4544
|
-
previewNames.map((p) => p.name).join(" | ");
|
|
4529
|
+
const memberName = previewNames.map((p) => p.name).join(" | ");
|
|
4545
4530
|
const titleElement = /* @__PURE__ */ jsxs(Group, { children: [
|
|
4546
4531
|
/* @__PURE__ */ jsx(
|
|
4547
4532
|
TitleIcon,
|
|
@@ -4573,7 +4558,7 @@ function TitleView({
|
|
|
4573
4558
|
tooltip && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Tooltip, { label: tooltipHTML, withArrow: true, withinPortal: true, children: /* @__PURE__ */ jsx(ActionIcon, { children: /* @__PURE__ */ jsx(IconInfoCircle, {}) }) }) }, "tooltip"),
|
|
4574
4559
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
4575
4560
|
finalElement,
|
|
4576
|
-
displayName && /* @__PURE__ */ jsx(Text, { className: "bespoke-comparison-title", children:
|
|
4561
|
+
displayName && /* @__PURE__ */ jsx(Text, { className: "bespoke-comparison-title", children: memberName })
|
|
4577
4562
|
] })
|
|
4578
4563
|
]
|
|
4579
4564
|
}
|
|
@@ -4969,7 +4954,7 @@ var DesktopNav = ({ contentOutline, showIcons }) => {
|
|
|
4969
4954
|
listStyleType: "none"
|
|
4970
4955
|
}),
|
|
4971
4956
|
children: contentOutline?.map(
|
|
4972
|
-
(node) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsxs(Menu, { trigger: "hover", openDelay: 100, closeDelay:
|
|
4957
|
+
(node) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsxs(Menu, { trigger: "hover", openDelay: 100, closeDelay: 200, children: [
|
|
4973
4958
|
/* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(Anchor, { href: `#bespoke-title-${node.id}`, children: /* @__PURE__ */ jsxs(Group, { spacing: "sm", children: [
|
|
4974
4959
|
showIcons && /* @__PURE__ */ jsx(TitleIcon, { ...node.iconProps, iconSize: "sm" }),
|
|
4975
4960
|
/* @__PURE__ */ jsx(Text, { dangerouslySetInnerHTML: { __html: node.label } })
|
|
@@ -5770,6 +5755,7 @@ function TitleUI({ onChange, simpleState }) {
|
|
|
5770
5755
|
const [iconSize, setIconSize] = useState(simpleState?.iconSize ?? "md");
|
|
5771
5756
|
const [iconRadius, setIconRadius] = useState(simpleState?.iconRadius ?? "md");
|
|
5772
5757
|
const [iconPadding, setIconPadding] = useState(simpleState?.iconPadding ?? "1");
|
|
5758
|
+
const inputPathRef = useRef(null);
|
|
5773
5759
|
const isNoneOrCustom = [TITLE_ICON_TYPES.none.value, TITLE_ICON_TYPES.custom.value].includes(iconType);
|
|
5774
5760
|
const IconItem = useMemo(() => forwardRef(
|
|
5775
5761
|
({ value, ...others }, ref) => {
|
|
@@ -5897,17 +5883,31 @@ function TitleUI({ onChange, simpleState }) {
|
|
|
5897
5883
|
)
|
|
5898
5884
|
}
|
|
5899
5885
|
),
|
|
5900
|
-
iconType === TITLE_ICON_TYPES.custom.value && /* @__PURE__ */
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5886
|
+
iconType === TITLE_ICON_TYPES.custom.value && /* @__PURE__ */ jsxs(Flex, { align: "flex-end", children: [
|
|
5887
|
+
/* @__PURE__ */ jsx(
|
|
5888
|
+
TextInput,
|
|
5889
|
+
{
|
|
5890
|
+
ref: inputPathRef,
|
|
5891
|
+
placeholder: "e.g '/image{{id1}}.png' or 'http://site/image.png'",
|
|
5892
|
+
label: "Enter an icon path",
|
|
5893
|
+
required: true,
|
|
5894
|
+
defaultValue: icon,
|
|
5895
|
+
description: "Add an absolute or a relative path url",
|
|
5896
|
+
onBlur: (e) => setIcon(e.currentTarget.value),
|
|
5897
|
+
sx: { flexGrow: 1 }
|
|
5898
|
+
}
|
|
5899
|
+
),
|
|
5900
|
+
/* @__PURE__ */ jsx(
|
|
5901
|
+
ActionIcon,
|
|
5902
|
+
{
|
|
5903
|
+
maw: 36,
|
|
5904
|
+
size: 36,
|
|
5905
|
+
onClick: () => inputPathRef ? setIcon(inputPathRef.current.value) : void 0,
|
|
5906
|
+
sx: { flexGrow: 0 },
|
|
5907
|
+
children: /* @__PURE__ */ jsx(IconFileUpload, {})
|
|
5908
|
+
}
|
|
5909
|
+
)
|
|
5910
|
+
] }),
|
|
5911
5911
|
iconType !== TITLE_ICON_TYPES.none.value && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5912
5912
|
/* @__PURE__ */ jsx(
|
|
5913
5913
|
Select,
|
|
@@ -6532,6 +6532,26 @@ function stringifyPreview(member) {
|
|
|
6532
6532
|
const variant = "variant_slug" in member ? member.variant_slug : member.variant.slug;
|
|
6533
6533
|
return `${variant}/${member.slug}`;
|
|
6534
6534
|
}
|
|
6535
|
+
|
|
6536
|
+
// hooks/useCurrentLocale.ts
|
|
6537
|
+
init_esm_shims();
|
|
6538
|
+
init_store2();
|
|
6539
|
+
function useCurrentLocale() {
|
|
6540
|
+
const dispatch = useAppDispatch();
|
|
6541
|
+
const { router, setSearchParam } = useManagerLocation();
|
|
6542
|
+
const { asPath } = router;
|
|
6543
|
+
const [, search] = asPath.split("?");
|
|
6544
|
+
const query = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') : {};
|
|
6545
|
+
const { currentLocale, locales: locales4 } = useAppSelector((state) => state.status);
|
|
6546
|
+
const paramLocale = query.locale || "";
|
|
6547
|
+
useEffect(() => {
|
|
6548
|
+
console.log();
|
|
6549
|
+
if (paramLocale && paramLocale !== "" && locales4.includes(paramLocale) && paramLocale !== currentLocale) {
|
|
6550
|
+
dispatch(actions_exports.setCurrentLocale(paramLocale));
|
|
6551
|
+
}
|
|
6552
|
+
}, [paramLocale]);
|
|
6553
|
+
return currentLocale;
|
|
6554
|
+
}
|
|
6535
6555
|
function NavPreview({ headings, settings }) {
|
|
6536
6556
|
const { min = "1", max = "6", icons = "yes" } = settings;
|
|
6537
6557
|
const contentOutline = useContentOutline(parseInt(min, 10), parseInt(max, 10), headings);
|
|
@@ -7920,6 +7940,10 @@ var EditButton = ({ sectionId, onActivate }) => {
|
|
|
7920
7940
|
const { activeEntity } = useActiveEntity();
|
|
7921
7941
|
const { handlers } = useSidebar("settings");
|
|
7922
7942
|
const active = activeEntity.type === "section" && activeEntity.id === sectionId;
|
|
7943
|
+
const openAndActivate = () => {
|
|
7944
|
+
onActivate();
|
|
7945
|
+
handlers.open();
|
|
7946
|
+
};
|
|
7923
7947
|
return active ? /* @__PURE__ */ jsx(
|
|
7924
7948
|
Button,
|
|
7925
7949
|
{
|
|
@@ -7931,7 +7955,7 @@ var EditButton = ({ sectionId, onActivate }) => {
|
|
|
7931
7955
|
compact: true,
|
|
7932
7956
|
children: "Edit"
|
|
7933
7957
|
}
|
|
7934
|
-
) : /* @__PURE__ */ jsx(ActionIcon, { variant: "transparent", onClick:
|
|
7958
|
+
) : /* @__PURE__ */ jsx(ActionIcon, { variant: "transparent", onClick: openAndActivate, children: /* @__PURE__ */ jsx(IconPencil, { size: 18 }) });
|
|
7935
7959
|
};
|
|
7936
7960
|
function SectionMenu({ sectionId, onActivate }) {
|
|
7937
7961
|
return /* @__PURE__ */ jsxs(Group, { spacing: 0, children: [
|
|
@@ -7947,6 +7971,32 @@ init_cms();
|
|
|
7947
7971
|
// components/sections/SectionColumns.tsx
|
|
7948
7972
|
init_esm_shims();
|
|
7949
7973
|
init_store2();
|
|
7974
|
+
|
|
7975
|
+
// components/builder/hooks/use-entity-settings.ts
|
|
7976
|
+
init_esm_shims();
|
|
7977
|
+
init_store2();
|
|
7978
|
+
function useEntitySettingsFactory(entityType, entityId) {
|
|
7979
|
+
const entity = useAppSelector((store) => entityId ? store.records.entities[entityType][entityId] : null);
|
|
7980
|
+
const storeSettings = entity?.settings;
|
|
7981
|
+
const [settingsState, setSettingsState] = useSetState(entity?.settings || {});
|
|
7982
|
+
const dispatch = useAppDispatch();
|
|
7983
|
+
const handleChange = useCallback((field, value) => {
|
|
7984
|
+
if (entity) {
|
|
7985
|
+
setSettingsState({ [field]: value });
|
|
7986
|
+
dispatch(actions_exports.updateEntity(entityType, {
|
|
7987
|
+
id: entity.id,
|
|
7988
|
+
settings: { ...entity.settings, [field]: value }
|
|
7989
|
+
}));
|
|
7990
|
+
}
|
|
7991
|
+
}, [dispatch, entity]);
|
|
7992
|
+
useEffect(() => {
|
|
7993
|
+
if (storeSettings)
|
|
7994
|
+
setSettingsState(storeSettings);
|
|
7995
|
+
}, [storeSettings, setSettingsState]);
|
|
7996
|
+
return { settings: settingsState, updateSettings: handleChange };
|
|
7997
|
+
}
|
|
7998
|
+
var useSectionSettings = (sectionId) => useEntitySettingsFactory("section", sectionId);
|
|
7999
|
+
var useReportSettings = (reportId) => useEntitySettingsFactory("report", reportId);
|
|
7950
8000
|
function SectionColumnsWrapper({
|
|
7951
8001
|
children,
|
|
7952
8002
|
containerProps
|
|
@@ -7967,11 +8017,11 @@ function SectionColumnsWrapper({
|
|
|
7967
8017
|
);
|
|
7968
8018
|
}
|
|
7969
8019
|
var SectionColumn = React.forwardRef(
|
|
7970
|
-
function SectionColumn2({ children, column, columnSettings = {}, sx = {}, ...rest }, ref) {
|
|
8020
|
+
function SectionColumn2({ children, column, basis, columnSettings = {}, sx = {}, ...rest }, ref) {
|
|
7971
8021
|
const hasInline = Object.values(column).some((item) => item.settings?.display === "inline");
|
|
7972
|
-
const width = columnSettings?.width;
|
|
7973
|
-
const
|
|
7974
|
-
const
|
|
8022
|
+
const width = columnSettings?.width ? `${columnSettings.width}px` : basis;
|
|
8023
|
+
const maxWidth = columnSettings?.width ? `${columnSettings?.width}px` : "100&";
|
|
8024
|
+
const computedMaxWidth = columnSettings?.full ? "100%" : maxWidth;
|
|
7975
8025
|
return /* @__PURE__ */ jsx(
|
|
7976
8026
|
Flex,
|
|
7977
8027
|
{
|
|
@@ -7980,11 +8030,18 @@ var SectionColumn = React.forwardRef(
|
|
|
7980
8030
|
align: "flex-start",
|
|
7981
8031
|
direction: hasInline ? "row" : "column",
|
|
7982
8032
|
wrap: hasInline ? "wrap" : "nowrap",
|
|
7983
|
-
maw:
|
|
7984
|
-
miw:
|
|
8033
|
+
maw: { base: "100%", md: computedMaxWidth },
|
|
8034
|
+
miw: { base: "none", md: 300 },
|
|
7985
8035
|
p: 0,
|
|
7986
8036
|
pos: "relative",
|
|
7987
|
-
sx: [
|
|
8037
|
+
sx: [
|
|
8038
|
+
{
|
|
8039
|
+
flexGrow: 1,
|
|
8040
|
+
flexShrink: columnSettings?.full ? 0 : 1,
|
|
8041
|
+
flexBasis: columnSettings?.full ? "100%" : width
|
|
8042
|
+
},
|
|
8043
|
+
...packSx(sx)
|
|
8044
|
+
],
|
|
7988
8045
|
...rest,
|
|
7989
8046
|
children
|
|
7990
8047
|
}
|
|
@@ -7994,24 +8051,22 @@ var SectionColumn = React.forwardRef(
|
|
|
7994
8051
|
var ResizeColumnInput = ({ sectionId, columnIndex }) => {
|
|
7995
8052
|
const dispatch = useAppDispatch();
|
|
7996
8053
|
const section = useSectionRef(sectionId).data;
|
|
8054
|
+
const { settings, updateSettings } = useSectionSettings(sectionId);
|
|
7997
8055
|
if (!section)
|
|
7998
8056
|
return null;
|
|
7999
|
-
const { columnSettings = {} } =
|
|
8057
|
+
const { columnSettings = {} } = settings;
|
|
8000
8058
|
const { width = void 0 } = columnSettings[columnIndex] ? columnSettings[columnIndex] : {};
|
|
8001
8059
|
const handleChange = (e) => {
|
|
8002
8060
|
if (section) {
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
...
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
[columnIndex]: {
|
|
8010
|
-
width: parseInt(e.target.value, 10)
|
|
8011
|
-
}
|
|
8061
|
+
updateSettings(
|
|
8062
|
+
"columnSettings",
|
|
8063
|
+
{
|
|
8064
|
+
...columnSettings,
|
|
8065
|
+
[columnIndex]: {
|
|
8066
|
+
width: parseInt(e.target.value, 10)
|
|
8012
8067
|
}
|
|
8013
8068
|
}
|
|
8014
|
-
|
|
8069
|
+
);
|
|
8015
8070
|
}
|
|
8016
8071
|
};
|
|
8017
8072
|
const handleReset = () => {
|
|
@@ -8030,34 +8085,51 @@ var ResizeColumnInput = ({ sectionId, columnIndex }) => {
|
|
|
8030
8085
|
}));
|
|
8031
8086
|
}
|
|
8032
8087
|
};
|
|
8033
|
-
|
|
8034
|
-
|
|
8088
|
+
const handleFullWidthChange = (event) => {
|
|
8089
|
+
updateSettings("columnSettings", {
|
|
8090
|
+
...columnSettings,
|
|
8091
|
+
[columnIndex]: {
|
|
8092
|
+
...columnSettings[columnIndex] || {},
|
|
8093
|
+
full: event.currentTarget.checked
|
|
8094
|
+
}
|
|
8095
|
+
});
|
|
8096
|
+
};
|
|
8097
|
+
return /* @__PURE__ */ jsxs(
|
|
8098
|
+
Group,
|
|
8035
8099
|
{
|
|
8036
8100
|
className: "bespoke-resize-col",
|
|
8037
8101
|
pos: "absolute",
|
|
8038
8102
|
top: -12,
|
|
8039
8103
|
left: "50%",
|
|
8040
8104
|
sx: {
|
|
8105
|
+
borderRadius: "4px",
|
|
8041
8106
|
transform: "translate(-50%, 0%)",
|
|
8042
8107
|
zIndex: 20
|
|
8043
8108
|
},
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8109
|
+
py: 0,
|
|
8110
|
+
px: "xs",
|
|
8111
|
+
maw: 180,
|
|
8112
|
+
bg: "white",
|
|
8113
|
+
noWrap: true,
|
|
8114
|
+
children: [
|
|
8115
|
+
/* @__PURE__ */ jsx(Checkbox, { label: "100%", size: "xs", onChange: handleFullWidthChange, checked: columnSettings[columnIndex]?.full }),
|
|
8116
|
+
/* @__PURE__ */ jsx(
|
|
8117
|
+
Input,
|
|
8118
|
+
{
|
|
8119
|
+
placeholder: "auto",
|
|
8120
|
+
w: "fit-content",
|
|
8121
|
+
miw: "none",
|
|
8122
|
+
variant: "filled",
|
|
8123
|
+
type: "number",
|
|
8124
|
+
value: width || "auto",
|
|
8125
|
+
maw: 110,
|
|
8126
|
+
onChange: handleChange,
|
|
8127
|
+
size: "xs",
|
|
8128
|
+
p: 0,
|
|
8129
|
+
rightSection: /* @__PURE__ */ jsx(IconX, { onClick: handleReset, size: 8 })
|
|
8130
|
+
}
|
|
8131
|
+
)
|
|
8132
|
+
]
|
|
8061
8133
|
}
|
|
8062
8134
|
);
|
|
8063
8135
|
};
|
|
@@ -8565,8 +8637,8 @@ function Section({ section }) {
|
|
|
8565
8637
|
const blocks = sectionBlocks.reduce((blocks2, block) => ({ ...blocks2, [block.id]: block }), {});
|
|
8566
8638
|
console.log("blocks", blocks);
|
|
8567
8639
|
sectionColumns = [
|
|
8568
|
-
/* @__PURE__ */ jsx(SectionColumn, { column: blocks,
|
|
8569
|
-
/* @__PURE__ */ jsx(SectionColumn, { column: blocks,
|
|
8640
|
+
/* @__PURE__ */ jsx(SectionColumn, { column: blocks, basis: "50%", children: getBlockRenderers(Object.values(sectionBlocks)) }, "original"),
|
|
8641
|
+
/* @__PURE__ */ jsx(SectionColumn, { column: blocks, basis: "50%", children: getBlockRenderers(Object.values(sectionBlocks), true) }, "comparison")
|
|
8570
8642
|
// TODO: maybe add more comparisons?
|
|
8571
8643
|
];
|
|
8572
8644
|
} else {
|
|
@@ -8583,7 +8655,7 @@ function Section({ section }) {
|
|
|
8583
8655
|
{
|
|
8584
8656
|
column,
|
|
8585
8657
|
columnSettings,
|
|
8586
|
-
|
|
8658
|
+
basis: `calc(${100 / colsQty}% - (10px * ${colsQty}))`,
|
|
8587
8659
|
children: columnBlocks.map((item) => {
|
|
8588
8660
|
if (!item.id || !status[item.id]?.allowed && item.type !== BLOCK_TYPES.NAV)
|
|
8589
8661
|
return null;
|
|
@@ -8600,7 +8672,7 @@ function Section({ section }) {
|
|
|
8600
8672
|
return /* @__PURE__ */ jsx(
|
|
8601
8673
|
Box,
|
|
8602
8674
|
{
|
|
8603
|
-
className:
|
|
8675
|
+
className: `bespoke-Block-wrapper bespoke-${item.type}-wrapper`,
|
|
8604
8676
|
id: `bespoke-Block-${item.id}`,
|
|
8605
8677
|
sx: blockStyles,
|
|
8606
8678
|
py: site_default.block.padding,
|
|
@@ -8627,7 +8699,7 @@ function Section({ section }) {
|
|
|
8627
8699
|
{
|
|
8628
8700
|
containerProps: {
|
|
8629
8701
|
gap: sectionSettings2.columnGutter || "md",
|
|
8630
|
-
wrap:
|
|
8702
|
+
wrap: comparison.active ? "nowrap" : "wrap",
|
|
8631
8703
|
sx: { zIndex: 20 }
|
|
8632
8704
|
},
|
|
8633
8705
|
children: sectionColumns
|
|
@@ -9918,7 +9990,7 @@ function DimensionAutocomplete({ id, locale, onSelect, initialSelection = void 0
|
|
|
9918
9990
|
onChange: onChangeVariant
|
|
9919
9991
|
}
|
|
9920
9992
|
),
|
|
9921
|
-
currentMember && !searchMode && /* @__PURE__ */ jsx("div", { style: { maxWidth:
|
|
9993
|
+
currentMember && !searchMode && /* @__PURE__ */ jsx("div", { style: { maxWidth: 100 }, children: /* @__PURE__ */ jsx(
|
|
9922
9994
|
Badge,
|
|
9923
9995
|
{
|
|
9924
9996
|
variant: "filled",
|
|
@@ -9978,7 +10050,6 @@ function HeaderLayout(props) {
|
|
|
9978
10050
|
}
|
|
9979
10051
|
|
|
9980
10052
|
// components/builder/CMSHeader.tsx
|
|
9981
|
-
init_statusSlice();
|
|
9982
10053
|
init_hooks();
|
|
9983
10054
|
function CMSHeader(props) {
|
|
9984
10055
|
const { report: currentReport } = props;
|
|
@@ -9991,7 +10062,7 @@ function CMSHeader(props) {
|
|
|
9991
10062
|
const reportId = Number.parseInt(location.params[0]);
|
|
9992
10063
|
const reportRef = useReportRef(reportId);
|
|
9993
10064
|
const profilePrefix = useProfilePrefix();
|
|
9994
|
-
const currentLocale =
|
|
10065
|
+
const currentLocale = useCurrentLocale();
|
|
9995
10066
|
const localeDefault10 = useAppSelector((state) => state.status.localeDefault);
|
|
9996
10067
|
const localeOptions = useAppSelector(selectLocaleOptions);
|
|
9997
10068
|
const previewsFromState = useAppSelector((state) => state.status.previews);
|
|
@@ -10005,13 +10076,12 @@ function CMSHeader(props) {
|
|
|
10005
10076
|
const showPreviewSelector = useMemo(() => {
|
|
10006
10077
|
return dimensions.length > 0;
|
|
10007
10078
|
}, [dimensions]);
|
|
10008
|
-
const [previewMembers, setPreviewMembers] = useState([]);
|
|
10009
10079
|
const [initialFavorites, setInitialFavorites] = useState([]);
|
|
10010
|
-
const previewPath = previewsFromState.reduce((acc, member) => {
|
|
10080
|
+
const previewPath = previewsFromState.filter((member) => member.variant_slug).reduce((acc, member) => {
|
|
10011
10081
|
return acc.concat([member.variant_slug, member.slug]);
|
|
10012
10082
|
}, []);
|
|
10013
10083
|
const localePrefix = currentLocale === localeDefault10 ? "" : `/${currentLocale}`;
|
|
10014
|
-
const realPath = `${localePrefix}${profilePrefix}/${previewPath.join("/")}
|
|
10084
|
+
const realPath = previewPath.length ? `${localePrefix}${profilePrefix}/${previewPath.join("/")}` : "";
|
|
10015
10085
|
const onSelectPreview = (previewMember) => {
|
|
10016
10086
|
const newPreviews = currentReport.dimensions.map((dId) => {
|
|
10017
10087
|
let member;
|
|
@@ -10019,7 +10089,7 @@ function CMSHeader(props) {
|
|
|
10019
10089
|
if (previewMember.dimension_id === dId) {
|
|
10020
10090
|
member = previewMember;
|
|
10021
10091
|
} else {
|
|
10022
|
-
const anotherMember =
|
|
10092
|
+
const anotherMember = previewsFromState.find((m) => m ? m.dimension_id === dId : false);
|
|
10023
10093
|
if (anotherMember) {
|
|
10024
10094
|
member = anotherMember;
|
|
10025
10095
|
}
|
|
@@ -10027,7 +10097,22 @@ function CMSHeader(props) {
|
|
|
10027
10097
|
}
|
|
10028
10098
|
return member;
|
|
10029
10099
|
});
|
|
10030
|
-
|
|
10100
|
+
dispatch(actions_exports.recalculateVariables(resource, {
|
|
10101
|
+
previews: newPreviews.filter((preview) => preview).map((preview) => ({
|
|
10102
|
+
...preview,
|
|
10103
|
+
report_name: preview.report?.name || preview.report_name,
|
|
10104
|
+
report_id: preview.report?.id || preview.report_id,
|
|
10105
|
+
dimension_id: preview.dimension?.id || preview.dimension_id,
|
|
10106
|
+
dimension_name: preview.dimension?.name || preview.dimension_name,
|
|
10107
|
+
variant_id: preview.variant?.id || preview.variant_id,
|
|
10108
|
+
variant_name: preview.variant?.name || preview.variant_name,
|
|
10109
|
+
variant_slug: preview.variant?.slug || preview.variant_slug
|
|
10110
|
+
}))
|
|
10111
|
+
}));
|
|
10112
|
+
};
|
|
10113
|
+
const onSelectLocale = (previewLocale) => {
|
|
10114
|
+
location.setSearchParam("locale", previewLocale);
|
|
10115
|
+
dispatch(actions_exports.recalculateVariables(resource, { previews: [] }));
|
|
10031
10116
|
};
|
|
10032
10117
|
const maybeRevalidateUrl = useCallback(async () => {
|
|
10033
10118
|
try {
|
|
@@ -10059,20 +10144,15 @@ function CMSHeader(props) {
|
|
|
10059
10144
|
}
|
|
10060
10145
|
}, [realPath]);
|
|
10061
10146
|
useEffect(() => {
|
|
10062
|
-
|
|
10147
|
+
dispatch(actions_exports.recalculateVariables(resource, {
|
|
10148
|
+
previews: []
|
|
10149
|
+
}));
|
|
10063
10150
|
}, [dimensions]);
|
|
10064
10151
|
useEffect(() => {
|
|
10065
10152
|
if (previewsFromState && previewsFromState.length > 0) {
|
|
10066
10153
|
setInitialFavorites(previewsFromState.map((ps) => ({ variantId: ps.variant_id, contentId: ps.content_id })));
|
|
10067
10154
|
}
|
|
10068
10155
|
}, [previewsFromState]);
|
|
10069
|
-
useEffect(() => {
|
|
10070
|
-
if (previewMembers.length > 0) {
|
|
10071
|
-
dispatch(actions_exports.recalculateVariables(resource, {
|
|
10072
|
-
previews: previewMembers
|
|
10073
|
-
}));
|
|
10074
|
-
}
|
|
10075
|
-
}, [previewMembers]);
|
|
10076
10156
|
useEffect(() => {
|
|
10077
10157
|
if (castedUser) {
|
|
10078
10158
|
if (castedUser.bespoke_app_metadata && castedUser.bespoke_app_metadata.reports && Array.isArray(castedUser.bespoke_app_metadata.reports)) {
|
|
@@ -10082,12 +10162,12 @@ function CMSHeader(props) {
|
|
|
10082
10162
|
}
|
|
10083
10163
|
}
|
|
10084
10164
|
}
|
|
10085
|
-
}, [castedUser, id,
|
|
10165
|
+
}, [castedUser, id, previewsFromState]);
|
|
10086
10166
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10087
10167
|
/* @__PURE__ */ jsx(
|
|
10088
10168
|
HeaderLayout,
|
|
10089
10169
|
{
|
|
10090
|
-
center: /* @__PURE__ */ jsxs(Group, { spacing:
|
|
10170
|
+
center: /* @__PURE__ */ jsxs(Group, { spacing: 4, children: [
|
|
10091
10171
|
/* @__PURE__ */ jsx(
|
|
10092
10172
|
ActionIcon,
|
|
10093
10173
|
{
|
|
@@ -10103,13 +10183,11 @@ function CMSHeader(props) {
|
|
|
10103
10183
|
/* @__PURE__ */ jsx(
|
|
10104
10184
|
Select,
|
|
10105
10185
|
{
|
|
10106
|
-
|
|
10186
|
+
w: 60,
|
|
10107
10187
|
size: "xs",
|
|
10108
10188
|
data: localeOptions,
|
|
10109
10189
|
value: currentLocale,
|
|
10110
|
-
onChange:
|
|
10111
|
-
statusActions.setStatus({ currentLocale: value || localeDefault10, previews: [] })
|
|
10112
|
-
)
|
|
10190
|
+
onChange: onSelectLocale
|
|
10113
10191
|
}
|
|
10114
10192
|
),
|
|
10115
10193
|
showPreviewSelector && dimensions.map((dId, ix) => /* @__PURE__ */ jsx(
|
|
@@ -10133,6 +10211,7 @@ function CMSHeader(props) {
|
|
|
10133
10211
|
bg: "#E9ECEF",
|
|
10134
10212
|
title: "Open report in new tab",
|
|
10135
10213
|
color: "dark",
|
|
10214
|
+
disabled: !realPath,
|
|
10136
10215
|
children: /* @__PURE__ */ jsx(IconEye, { size: 20 })
|
|
10137
10216
|
}
|
|
10138
10217
|
) }),
|
|
@@ -11777,32 +11856,6 @@ function SectionHeader({
|
|
|
11777
11856
|
// components/sections/Section.tsx
|
|
11778
11857
|
init_cms();
|
|
11779
11858
|
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
11859
|
var blockTypes = Object.values(BLOCK_TYPES);
|
|
11807
11860
|
var CreateBlockButton = ({ columns, columnIndex, section }) => {
|
|
11808
11861
|
const dispatch = useAppDispatch();
|
|
@@ -12054,7 +12107,7 @@ function SectionEditor({
|
|
|
12054
12107
|
p: section.settings.margin || "md",
|
|
12055
12108
|
style: { zIndex: 2 },
|
|
12056
12109
|
gap: section.settings.columnGutter || "md",
|
|
12057
|
-
wrap:
|
|
12110
|
+
wrap: "wrap"
|
|
12058
12111
|
},
|
|
12059
12112
|
children: /* @__PURE__ */ jsxs(DragDropContext, { onDragEnd, onDragStart, children: [
|
|
12060
12113
|
orderedCols.map((columnIndex) => {
|
|
@@ -12065,9 +12118,9 @@ function SectionEditor({
|
|
|
12065
12118
|
column: columns[columnIndex],
|
|
12066
12119
|
columnSettings: columnSettings[columnIndex],
|
|
12067
12120
|
ref: provided.innerRef,
|
|
12121
|
+
basis: `calc(${100 / columnsQty}% - (10px * ${columnsQty}))`,
|
|
12068
12122
|
sx: {
|
|
12069
12123
|
// extra styles for columns on editor
|
|
12070
|
-
flexBasis: `${100 / columnsQty}%`,
|
|
12071
12124
|
background: snapshot.isDraggingOver ? theme.colors[theme.primaryColor][0] : "inherit",
|
|
12072
12125
|
border: "1px solid transparent",
|
|
12073
12126
|
"& .bespoke-resize-col": {
|
|
@@ -12315,15 +12368,23 @@ var SectionItem = forwardRef(
|
|
|
12315
12368
|
style: { flexShrink: 0 }
|
|
12316
12369
|
}
|
|
12317
12370
|
),
|
|
12318
|
-
edit ? /* @__PURE__ */ jsx(NameEditor, { section, onEnd: saveAndClose }) : /* @__PURE__ */
|
|
12319
|
-
Text,
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12371
|
+
edit ? /* @__PURE__ */ jsx(NameEditor, { section, onEnd: saveAndClose }) : /* @__PURE__ */ jsxs(Group, { spacing: 4, align: "flex-end", children: [
|
|
12372
|
+
/* @__PURE__ */ jsxs(Text, { size: "sm", fw: 500, color: "gray.5", span: true, children: [
|
|
12373
|
+
section.id,
|
|
12374
|
+
" -"
|
|
12375
|
+
] }),
|
|
12376
|
+
/* @__PURE__ */ jsx(
|
|
12377
|
+
Text,
|
|
12378
|
+
{
|
|
12379
|
+
size: "sm",
|
|
12380
|
+
c: sectionColor,
|
|
12381
|
+
maw: 220,
|
|
12382
|
+
sx: { whiteSpace: "nowrap", textOverflow: "ellipsis", overflow: "hidden" },
|
|
12383
|
+
span: true,
|
|
12384
|
+
children: name
|
|
12385
|
+
}
|
|
12386
|
+
)
|
|
12387
|
+
] })
|
|
12327
12388
|
] }),
|
|
12328
12389
|
/* @__PURE__ */ jsxs(Group, { spacing: "xs", children: [
|
|
12329
12390
|
section.settings.hidden && /* @__PURE__ */ jsx(IconEyeOff, { size: "0.8rem", color: theme.colors["red"][3] }),
|
|
@@ -13068,7 +13129,6 @@ function InteractiveReport(props) {
|
|
|
13068
13129
|
const maybeActivate = useCallback((sectionId) => {
|
|
13069
13130
|
const onActivate = () => {
|
|
13070
13131
|
selectEntity({ type: "section", id: sectionId });
|
|
13071
|
-
settingsSidebar.handlers.open();
|
|
13072
13132
|
dispatch(recalculateVariables(resource, { sid: sectionId }));
|
|
13073
13133
|
};
|
|
13074
13134
|
if (previews.length < report.dimensions.length) {
|
|
@@ -13132,7 +13192,9 @@ function InteractiveReport(props) {
|
|
|
13132
13192
|
]
|
|
13133
13193
|
}
|
|
13134
13194
|
), [sectionOrder, activeEntity.id, maybeActivate]);
|
|
13135
|
-
const
|
|
13195
|
+
const settingsVisible = Boolean(activeEntity.id);
|
|
13196
|
+
const settingsWidthPlaceholder = settingsVisible ? 50 : 0;
|
|
13197
|
+
const scrollContainerWidth = 50 + (toolsSidebar.opened ? 350 : 50) + (settingsSidebar.opened ? 350 : settingsWidthPlaceholder);
|
|
13136
13198
|
return /* @__PURE__ */ jsxs(Flex, { h: "100vh", children: [
|
|
13137
13199
|
/* @__PURE__ */ jsx(ToolsSidebar, { scrollContainer: mainContainer }),
|
|
13138
13200
|
/* @__PURE__ */ jsxs(Box, { sx: { flexGrow: 1 }, pos: "relative", children: [
|
|
@@ -13143,6 +13205,11 @@ function InteractiveReport(props) {
|
|
|
13143
13205
|
w: `calc(100vw - ${scrollContainerWidth}px)`,
|
|
13144
13206
|
viewportRef: mainContainer,
|
|
13145
13207
|
h: "calc(100vh - 50px)",
|
|
13208
|
+
styles: {
|
|
13209
|
+
scrollbar: {
|
|
13210
|
+
zIndex: 9999
|
|
13211
|
+
}
|
|
13212
|
+
},
|
|
13146
13213
|
offsetScrollbars: true,
|
|
13147
13214
|
children: /* @__PURE__ */ jsxs(Stack, { styles: { backgroundColor: theme.colors.gray[2] }, spacing: 0, children: [
|
|
13148
13215
|
/* @__PURE__ */ jsxs(Alert, { icon: /* @__PURE__ */ jsx(IconFlag, {}), children: [
|
package/dist/server.js
CHANGED
|
@@ -26,6 +26,7 @@ import * as allIcons from '@tabler/icons-react';
|
|
|
26
26
|
import NextCors from 'nextjs-cors';
|
|
27
27
|
import formidable from 'formidable';
|
|
28
28
|
import DomParser from 'dom-parser';
|
|
29
|
+
import axiosRetry from 'axios-retry';
|
|
29
30
|
import toposort from 'toposort';
|
|
30
31
|
import getConfig from 'next/config';
|
|
31
32
|
import { schema, normalize } from 'normalizr';
|
|
@@ -1548,20 +1549,26 @@ function readMemberFactory(db) {
|
|
|
1548
1549
|
});
|
|
1549
1550
|
whereClause.content_id = entities.map((item) => item.content_id);
|
|
1550
1551
|
} else if (mode === "slugs") {
|
|
1551
|
-
const
|
|
1552
|
+
const queries = params.slugs.map((item) => Search.findAll({
|
|
1552
1553
|
attributes: ["content_id"],
|
|
1553
1554
|
where: {
|
|
1554
|
-
slug:
|
|
1555
|
+
slug: item.memberSlug
|
|
1555
1556
|
},
|
|
1556
1557
|
include: {
|
|
1557
1558
|
association: "variant",
|
|
1558
1559
|
attributes: ["id", "name", "slug"],
|
|
1559
1560
|
required: true,
|
|
1560
1561
|
where: {
|
|
1561
|
-
slug:
|
|
1562
|
+
slug: item.variantSlug
|
|
1562
1563
|
}
|
|
1563
1564
|
}
|
|
1564
|
-
});
|
|
1565
|
+
}));
|
|
1566
|
+
const entities = await Promise.all(queries).then((results) => results.reduce(
|
|
1567
|
+
(acc, items) => {
|
|
1568
|
+
return acc.concat(items);
|
|
1569
|
+
},
|
|
1570
|
+
[]
|
|
1571
|
+
));
|
|
1565
1572
|
whereClause.content_id = entities.map((item) => item.content_id);
|
|
1566
1573
|
} else if (mode === "related") {
|
|
1567
1574
|
const levelWhereClause = () => {
|
|
@@ -2015,7 +2022,8 @@ var blockQuery = {
|
|
|
2015
2022
|
var dimensionQuery = {
|
|
2016
2023
|
include: [
|
|
2017
2024
|
{ association: "variants", separate: true }
|
|
2018
|
-
]
|
|
2025
|
+
],
|
|
2026
|
+
order: [["ordering", "ASC"]]
|
|
2019
2027
|
};
|
|
2020
2028
|
var sectionQuery = {
|
|
2021
2029
|
include: [
|
|
@@ -2226,7 +2234,13 @@ function dbReportFactory(db) {
|
|
|
2226
2234
|
include,
|
|
2227
2235
|
locales: locales9 = reportLocales
|
|
2228
2236
|
} = {}) {
|
|
2229
|
-
const
|
|
2237
|
+
const allIdsList = id == null ? [] : [].concat(id);
|
|
2238
|
+
const idList = allIdsList.reduce((uniques, currentValue) => {
|
|
2239
|
+
if (!uniques.includes(currentValue)) {
|
|
2240
|
+
uniques.push(currentValue);
|
|
2241
|
+
}
|
|
2242
|
+
return uniques;
|
|
2243
|
+
}, []);
|
|
2230
2244
|
const entities = await Report.findAll({
|
|
2231
2245
|
where: idList.length > 0 ? { id: idList } : void 0,
|
|
2232
2246
|
include: include ? reportQuery.include : void 0
|
|
@@ -3872,6 +3886,7 @@ __export(actions_exports, {
|
|
|
3872
3886
|
searchRegenerate: () => searchRegenerate,
|
|
3873
3887
|
searchRole: () => searchRole,
|
|
3874
3888
|
searchUser: () => searchUser,
|
|
3889
|
+
setCurrentLocale: () => setCurrentLocale,
|
|
3875
3890
|
setPreviews: () => setPreviews,
|
|
3876
3891
|
setQueryParam: () => setQueryParam,
|
|
3877
3892
|
setSectionState: () => setSectionState,
|
|
@@ -4261,6 +4276,15 @@ var getRootBlocksForSection_default = getRootBlocksForSection;
|
|
|
4261
4276
|
var apiSeparator = "|||";
|
|
4262
4277
|
var debug = yn2(process.env.NEXT_PUBLIC_REPORTS_DEBUG);
|
|
4263
4278
|
var ORIGIN = process.env.REPORTS_ORIGIN || "";
|
|
4279
|
+
axiosRetry(axios5, {
|
|
4280
|
+
retries: 3,
|
|
4281
|
+
retryDelay: axiosRetry.exponentialDelay,
|
|
4282
|
+
onRetry: (retryCount, error, requestConfig) => {
|
|
4283
|
+
console.log("Generator request failed. Retrying... Count: ", retryCount);
|
|
4284
|
+
console.log("URL: ", requestConfig.url);
|
|
4285
|
+
console.log(error.message);
|
|
4286
|
+
}
|
|
4287
|
+
});
|
|
4264
4288
|
axios5.interceptors.request.use((config) => ({
|
|
4265
4289
|
...config,
|
|
4266
4290
|
requestStart: Date.now()
|
|
@@ -4949,6 +4973,9 @@ var statusSlice = createSlice({
|
|
|
4949
4973
|
setPreviews(state, action) {
|
|
4950
4974
|
state.previews = action.payload;
|
|
4951
4975
|
},
|
|
4976
|
+
setCurrentLocale(state, action) {
|
|
4977
|
+
state.currentLocale = action.payload;
|
|
4978
|
+
},
|
|
4952
4979
|
setSectionState(state, action) {
|
|
4953
4980
|
state.sectionState = { ...state.sectionState, ...action.payload };
|
|
4954
4981
|
},
|
|
@@ -5080,6 +5107,10 @@ var recordsSlice = createSlice({
|
|
|
5080
5107
|
} else if (req.type === "dimension") {
|
|
5081
5108
|
const item = req.data;
|
|
5082
5109
|
state.entities.report[item.report_id].dimensions.push(item.id);
|
|
5110
|
+
state.entities.report[item.report_id].dimensions = recalculateOrder(
|
|
5111
|
+
nextEntities.report[item.report_id].dimensions,
|
|
5112
|
+
nextEntities.dimension
|
|
5113
|
+
);
|
|
5083
5114
|
} else if (req.type === "variant") {
|
|
5084
5115
|
const item = req.data;
|
|
5085
5116
|
state.entities.dimension[item.dimension_id].variants.push(item.id);
|
|
@@ -5434,7 +5465,7 @@ function keyMakerDelete(entity, params) {
|
|
|
5434
5465
|
}
|
|
5435
5466
|
|
|
5436
5467
|
// store/actions.ts
|
|
5437
|
-
var { setStatus, setPreviews, setSectionState, resetSectionState } = statusActions;
|
|
5468
|
+
var { setStatus, setPreviews, setSectionState, resetSectionState, setCurrentLocale } = statusActions;
|
|
5438
5469
|
function variantValidateSlug(dimension, slug) {
|
|
5439
5470
|
return async (_, __, api) => {
|
|
5440
5471
|
const result = await api.validateVariantSlug({ dimension, slug });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datawheel/bespoke",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Content management system for creating automated data reports",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@tinymce/tinymce-react": "^4.2.0",
|
|
57
57
|
"auth0": "^3.3",
|
|
58
58
|
"axios": "^0.26.1",
|
|
59
|
+
"axios-retry": "^3.8.0",
|
|
59
60
|
"base58": "^2.0.1",
|
|
60
61
|
"buble": "^0.20.0",
|
|
61
62
|
"comment-parser": "^1.3.1",
|