@datawheel/bespoke 0.2.0 → 0.2.2
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 +158 -109
- package/dist/server.js +394 -885
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import yn4 from 'yn';
|
|
3
2
|
import * as d3Array from 'd3-array';
|
|
4
3
|
import * as d3Collection from 'd3-collection';
|
|
5
4
|
import * as d3Format from 'd3-format';
|
|
@@ -8,15 +7,16 @@ import { formatAbbreviate } from 'd3plus-format';
|
|
|
8
7
|
import { date } from 'd3plus-axis';
|
|
9
8
|
import { assign, closest, merge, isObject } from 'd3plus-common';
|
|
10
9
|
import { strip, titleCase } from 'd3plus-text';
|
|
10
|
+
import yn3 from 'yn';
|
|
11
11
|
import toposort from 'toposort';
|
|
12
12
|
import { schema, normalize } from 'normalizr';
|
|
13
13
|
import { createSlice, configureStore } from '@reduxjs/toolkit';
|
|
14
14
|
import { HYDRATE, createWrapper } from 'next-redux-wrapper';
|
|
15
15
|
import { Notifications, notifications } from '@mantine/notifications';
|
|
16
|
-
import React, { forwardRef, useMemo, useState, useCallback, useContext, useEffect, createContext, useRef, Fragment as Fragment$1, createElement } from 'react';
|
|
16
|
+
import React, { forwardRef, useMemo, useState, useCallback, useContext, useEffect, createContext, memo, useRef, Fragment as Fragment$1, createElement } from 'react';
|
|
17
17
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
18
18
|
import { useDispatch, useSelector } from 'react-redux';
|
|
19
|
-
import { Stack, Text, Badge, Group, useMantineTheme, Flex, packSx,
|
|
19
|
+
import { Stack, Text, Badge, Group, useMantineTheme, Flex, packSx, Tooltip, ActionIcon, Modal, Button, SegmentedControl, Select, MultiSelect, Center, Grid, Card, Image, Title, Radio, NumberInput, TextInput, Switch, Box, List, Menu, Anchor, MantineProvider, Divider, Burger, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Container, Loader, Alert, Collapse, Space, Code, Textarea, rem, Paper, Input, Popover, Checkbox, Drawer, Overlay, SimpleGrid, Autocomplete, Tabs, Header, px, FileInput, Accordion, HoverCard, CopyButton, Col } from '@mantine/core';
|
|
20
20
|
import { dataConcat } from 'd3plus-viz';
|
|
21
21
|
import * as d3plus from 'd3plus-react';
|
|
22
22
|
import Router, { useRouter } from 'next/router';
|
|
@@ -473,13 +473,6 @@ var init_cms = __esm({
|
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
|
-
var getLogging_default;
|
|
477
|
-
var init_getLogging = __esm({
|
|
478
|
-
"libs/configs/getLogging.ts"() {
|
|
479
|
-
init_esm_shims();
|
|
480
|
-
getLogging_default = (env = process.env) => yn4(env.REPORTS_LOGGING);
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
476
|
|
|
484
477
|
// libs/stats.js
|
|
485
478
|
function logGamma(Z) {
|
|
@@ -745,7 +738,7 @@ var init_mortarEval = __esm({
|
|
|
745
738
|
init_esm_shims();
|
|
746
739
|
init_block();
|
|
747
740
|
init_libs();
|
|
748
|
-
verbose =
|
|
741
|
+
verbose = yn3(process.env.REPORTS_LOGGING);
|
|
749
742
|
mortarEval_default = mortarEval;
|
|
750
743
|
}
|
|
751
744
|
});
|
|
@@ -1025,12 +1018,14 @@ var init_consts = __esm({
|
|
|
1025
1018
|
function isResult(response) {
|
|
1026
1019
|
return response.ok !== void 0;
|
|
1027
1020
|
}
|
|
1021
|
+
function ApiFetchException(message) {
|
|
1022
|
+
this.message = message;
|
|
1023
|
+
this.name = "ApiFetchException";
|
|
1024
|
+
}
|
|
1028
1025
|
async function apiFetch(url, settings, readMemberFn, locale = "en") {
|
|
1029
1026
|
const start = Date.now();
|
|
1030
1027
|
let finalUrl = url;
|
|
1031
1028
|
let finalData;
|
|
1032
|
-
if (verbose2)
|
|
1033
|
-
console.log("apiFetch", url);
|
|
1034
1029
|
const parsedUrl = new URL(url);
|
|
1035
1030
|
const parsedQuery = parsedUrl.searchParams;
|
|
1036
1031
|
if (parsedQuery.has("bespoke_slugs")) {
|
|
@@ -1039,11 +1034,26 @@ async function apiFetch(url, settings, readMemberFn, locale = "en") {
|
|
|
1039
1034
|
}
|
|
1040
1035
|
const useProxy = settings && settings.useProxy && settings.useProxy === "true" ? true : false;
|
|
1041
1036
|
if (typeof window === "object" && useProxy) {
|
|
1042
|
-
const result = await urlProxy({ url: finalUrl });
|
|
1043
|
-
|
|
1037
|
+
const result = await urlProxy({ url: finalUrl, timeout: apiFetchTimeout });
|
|
1038
|
+
if (result.ok === true) {
|
|
1039
|
+
finalData = result.data;
|
|
1040
|
+
} else {
|
|
1041
|
+
throw new ApiFetchException(result?.error);
|
|
1042
|
+
}
|
|
1044
1043
|
} else {
|
|
1045
|
-
|
|
1046
|
-
|
|
1044
|
+
try {
|
|
1045
|
+
const response = await axios({
|
|
1046
|
+
url: finalUrl,
|
|
1047
|
+
timeout: apiFetchTimeout
|
|
1048
|
+
});
|
|
1049
|
+
if (response.status === 200) {
|
|
1050
|
+
finalData = response.data;
|
|
1051
|
+
} else {
|
|
1052
|
+
throw new ApiFetchException("No response");
|
|
1053
|
+
}
|
|
1054
|
+
} catch (e) {
|
|
1055
|
+
throw new ApiFetchException(e.message);
|
|
1056
|
+
}
|
|
1047
1057
|
}
|
|
1048
1058
|
if (parsedQuery.has("bespoke_slugs")) {
|
|
1049
1059
|
const slugStrings = parsedQuery.get("bespoke_slugs");
|
|
@@ -1097,6 +1107,10 @@ async function apiFetch(url, settings, readMemberFn, locale = "en") {
|
|
|
1097
1107
|
requestDuration: Date.now() - start
|
|
1098
1108
|
};
|
|
1099
1109
|
}
|
|
1110
|
+
function BlockException(message) {
|
|
1111
|
+
this.name = "BlockException";
|
|
1112
|
+
this.message = message;
|
|
1113
|
+
}
|
|
1100
1114
|
async function runSingleBlock(block, formatterFunctions, blockContext, readMemberFn) {
|
|
1101
1115
|
const { locale, variables, query } = parseBlockContext(blockContext);
|
|
1102
1116
|
const allowed = isBlockAllowed(block, blockContext, variables, formatterFunctions);
|
|
@@ -1128,18 +1142,30 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
|
|
|
1128
1142
|
block.settings,
|
|
1129
1143
|
readMemberFn,
|
|
1130
1144
|
locale
|
|
1131
|
-
).
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
})
|
|
1145
|
+
).catch(
|
|
1146
|
+
(e) => {
|
|
1147
|
+
throw new BlockException(` Excecution of ${block.type}-${block.id} in section ${block.section_id} in report ${variables.report_name} (${variables.report_id}) failed.
|
|
1148
|
+
Error fetching ${apiUrl}.
|
|
1149
|
+
Message: ${e.message}.
|
|
1150
|
+
`);
|
|
1151
|
+
}
|
|
1152
|
+
)
|
|
1140
1153
|
);
|
|
1141
1154
|
}
|
|
1142
|
-
const apiResponses = await Promise.all(apiPromisesList)
|
|
1155
|
+
const apiResponses = await Promise.all(apiPromisesList).catch((e) => {
|
|
1156
|
+
return e.message;
|
|
1157
|
+
});
|
|
1158
|
+
if (typeof apiResponses === "string") {
|
|
1159
|
+
if (apiResponses) {
|
|
1160
|
+
return {
|
|
1161
|
+
outputVariables: {},
|
|
1162
|
+
renderVariables: {},
|
|
1163
|
+
status: {
|
|
1164
|
+
error: apiResponses
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1143
1169
|
resp = apiResponses.length === 1 ? apiResponses[0].data : apiResponses.map((r) => r.data);
|
|
1144
1170
|
responseSize = apiResponses.reduce((acc, r) => acc + JSON.stringify(r.data).length / 1024, 0);
|
|
1145
1171
|
duration = Math.max(...apiResponses.map((ar) => ar.requestDuration));
|
|
@@ -1280,14 +1306,13 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
|
|
|
1280
1306
|
}
|
|
1281
1307
|
};
|
|
1282
1308
|
}
|
|
1283
|
-
var
|
|
1309
|
+
var debug, ORIGIN, swapAPI, urlProxy, apiFetchTimeout, getDependencies, isBlockAllowed, runConsumersV2, getDurationColor, getSizeColor;
|
|
1284
1310
|
var init_runConsumers = __esm({
|
|
1285
1311
|
"libs/blocks/runConsumers.ts"() {
|
|
1286
1312
|
init_esm_shims();
|
|
1287
1313
|
init_api();
|
|
1288
1314
|
init_block();
|
|
1289
1315
|
init_cms();
|
|
1290
|
-
init_getLogging();
|
|
1291
1316
|
init_runSelector();
|
|
1292
1317
|
init_selectorQueryToVariable();
|
|
1293
1318
|
init_mortarEval();
|
|
@@ -1296,8 +1321,7 @@ var init_runConsumers = __esm({
|
|
|
1296
1321
|
init_getRootBlocksForSection();
|
|
1297
1322
|
init_arrayUtils();
|
|
1298
1323
|
init_consts();
|
|
1299
|
-
|
|
1300
|
-
debug = yn4(process.env.NEXT_PUBLIC_REPORTS_DEBUG);
|
|
1324
|
+
debug = yn3(process.env.NEXT_PUBLIC_REPORTS_DEBUG);
|
|
1301
1325
|
ORIGIN = process.env.REPORTS_ORIGIN || "";
|
|
1302
1326
|
axios.interceptors.request.use((config) => ({
|
|
1303
1327
|
...config,
|
|
@@ -1314,6 +1338,7 @@ var init_runConsumers = __esm({
|
|
|
1314
1338
|
return url;
|
|
1315
1339
|
};
|
|
1316
1340
|
({ urlProxy } = apiFactory("/api/cms"));
|
|
1341
|
+
apiFetchTimeout = process.env.NEXT_PUBLIC_REPORTS_API_FETCH_TIMEOUT || 0;
|
|
1317
1342
|
getDependencies = (bid, blocks, acc = [], crawlUp = true, crawlDown = true, withinSection = true, visited = []) => {
|
|
1318
1343
|
if (visited.includes(bid))
|
|
1319
1344
|
return [];
|
|
@@ -1421,6 +1446,16 @@ var init_runConsumers = __esm({
|
|
|
1421
1446
|
},
|
|
1422
1447
|
readMemberFn
|
|
1423
1448
|
).then(({ outputVariables, status }) => {
|
|
1449
|
+
if (status.error) {
|
|
1450
|
+
if (typeof window === "undefined") {
|
|
1451
|
+
throw new Error(`Run consumers failed with message: ${status.error}`);
|
|
1452
|
+
} else {
|
|
1453
|
+
statusById[bid2] = {
|
|
1454
|
+
allowed: false,
|
|
1455
|
+
error: status.error
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1424
1459
|
if (
|
|
1425
1460
|
// store output variables for block that:
|
|
1426
1461
|
(block.consumers.length > 0 || [BLOCK_TYPES.GENERATOR, BLOCK_TYPES.RELATED].includes(block.type)) && status.allowed && Object.keys(outputVariables).length > 0
|
|
@@ -2465,17 +2500,21 @@ function recalculateVariables(resource, params) {
|
|
|
2465
2500
|
};
|
|
2466
2501
|
const section = state.records.entities.section[sid];
|
|
2467
2502
|
const readMemberFn = async (innerParams) => dispatch(readMember(innerParams));
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2503
|
+
try {
|
|
2504
|
+
const data = await runConsumersV2(
|
|
2505
|
+
blocks,
|
|
2506
|
+
section && [section],
|
|
2507
|
+
bid,
|
|
2508
|
+
formatterFunctions,
|
|
2509
|
+
blockContext,
|
|
2510
|
+
void 0,
|
|
2511
|
+
readMemberFn
|
|
2512
|
+
);
|
|
2513
|
+
const { variables, status } = data;
|
|
2514
|
+
dispatch(variablesActions.setVariableChange({ attributes, variables, status }));
|
|
2515
|
+
} catch (error) {
|
|
2516
|
+
console.log("Error in runConsumers client side: recalculateVariables", error);
|
|
2517
|
+
}
|
|
2479
2518
|
};
|
|
2480
2519
|
}
|
|
2481
2520
|
function readMetadata(filters) {
|
|
@@ -3040,51 +3079,38 @@ function Viz(config) {
|
|
|
3040
3079
|
const Visualization = vizTypes[fallbackType];
|
|
3041
3080
|
const { _data, ...vizPropsConfig } = vizProps.config;
|
|
3042
3081
|
const vizConfig = { locale, variables, ...vizPropsConfig, ...configOverride };
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
{
|
|
3066
|
-
style: { flex: 1 },
|
|
3067
|
-
dataFormat: (resp) => {
|
|
3068
|
-
vizProps.data && Array.isArray(vizProps.data) && vizProps.data.length > 1 && vizProps.data.some((d) => typeof d === "string");
|
|
3069
|
-
let data;
|
|
3070
|
-
try {
|
|
3071
|
-
data = vizProps.dataFormat(resp);
|
|
3072
|
-
} catch (e) {
|
|
3073
|
-
console.log("Error in dataFormat: ", e);
|
|
3074
|
-
data = [];
|
|
3075
|
-
}
|
|
3076
|
-
return data;
|
|
3077
|
-
},
|
|
3078
|
-
linksFormat: vizProps.linksFormat,
|
|
3079
|
-
nodesFormat: vizProps.nodesFormat,
|
|
3080
|
-
topojsonFormat: vizProps.topojsonFormat,
|
|
3081
|
-
config: { ...defaultConfig_default, ...vizConfig, sectionVariables: sectionVariablesStr, title: void 0 }
|
|
3082
|
+
return /* @__PURE__ */ jsx("div", { className: "bespoke-Viz", children: /* @__PURE__ */ jsx(
|
|
3083
|
+
"div",
|
|
3084
|
+
{
|
|
3085
|
+
style: {
|
|
3086
|
+
display: "flex",
|
|
3087
|
+
flex: "1 1 100%",
|
|
3088
|
+
minHeight: 400
|
|
3089
|
+
},
|
|
3090
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx("p", { children: "Error in d3plus viz config." }), children: /* @__PURE__ */ jsx(
|
|
3091
|
+
Visualization,
|
|
3092
|
+
{
|
|
3093
|
+
style: { flex: 1 },
|
|
3094
|
+
dataFormat: (resp) => {
|
|
3095
|
+
vizProps.data && Array.isArray(vizProps.data) && vizProps.data.length > 1 && vizProps.data.some((d) => typeof d === "string");
|
|
3096
|
+
let data;
|
|
3097
|
+
try {
|
|
3098
|
+
data = vizProps.dataFormat(resp);
|
|
3099
|
+
} catch (e) {
|
|
3100
|
+
console.log("Error in dataFormat: ", e);
|
|
3101
|
+
data = [];
|
|
3102
|
+
}
|
|
3103
|
+
return data;
|
|
3082
3104
|
},
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3105
|
+
linksFormat: vizProps.linksFormat,
|
|
3106
|
+
nodesFormat: vizProps.nodesFormat,
|
|
3107
|
+
topojsonFormat: vizProps.topojsonFormat,
|
|
3108
|
+
config: { ...defaultConfig_default, ...vizConfig, sectionVariables: sectionVariablesStr, title: void 0 }
|
|
3109
|
+
},
|
|
3110
|
+
"viz-key"
|
|
3111
|
+
) })
|
|
3112
|
+
}
|
|
3113
|
+
) });
|
|
3088
3114
|
}
|
|
3089
3115
|
var vizTypes;
|
|
3090
3116
|
var init_Viz = __esm({
|
|
@@ -3238,7 +3264,7 @@ var init_Table = __esm({
|
|
|
3238
3264
|
// components/blocks/types/renderers/Viz.tsx
|
|
3239
3265
|
var Viz_exports2 = {};
|
|
3240
3266
|
__export(Viz_exports2, {
|
|
3241
|
-
default: () =>
|
|
3267
|
+
default: () => Viz_default
|
|
3242
3268
|
});
|
|
3243
3269
|
function Viz2({
|
|
3244
3270
|
block,
|
|
@@ -3269,7 +3295,7 @@ function Viz2({
|
|
|
3269
3295
|
}
|
|
3270
3296
|
};
|
|
3271
3297
|
return d3plusPropify_default(transpiledLogic, formatterFunctions, variables, locale, block.id, {}, globals);
|
|
3272
|
-
}, [
|
|
3298
|
+
}, [content?.logic, active, variables, sectionVariables]);
|
|
3273
3299
|
useMemo(() => {
|
|
3274
3300
|
if (!active || !content?.logic)
|
|
3275
3301
|
return {};
|
|
@@ -3325,7 +3351,7 @@ function Viz2({
|
|
|
3325
3351
|
}
|
|
3326
3352
|
);
|
|
3327
3353
|
}
|
|
3328
|
-
var useAppContext, CustomVizzes, vizTypes2;
|
|
3354
|
+
var useAppContext, CustomVizzes, vizTypes2, Viz_default;
|
|
3329
3355
|
var init_Viz2 = __esm({
|
|
3330
3356
|
"components/blocks/types/renderers/Viz.tsx"() {
|
|
3331
3357
|
init_esm_shims();
|
|
@@ -3348,6 +3374,9 @@ var init_Viz2 = __esm({
|
|
|
3348
3374
|
...d3plus,
|
|
3349
3375
|
...CustomVizzes
|
|
3350
3376
|
};
|
|
3377
|
+
Viz_default = memo(Viz2, (prevProps, nextProps) => {
|
|
3378
|
+
return prevProps.block.contentByLocale.logic.content === nextProps.block.contentByLocale.logic.content && prevProps.active === nextProps.active && prevProps.locale === nextProps.locale && JSON.stringify(prevProps.variables) === JSON.stringify(nextProps.variables) && JSON.stringify(prevProps.configOverride) === JSON.stringify(nextProps.configOverride);
|
|
3379
|
+
});
|
|
3351
3380
|
}
|
|
3352
3381
|
});
|
|
3353
3382
|
|
|
@@ -7626,14 +7655,14 @@ init_esm_shims();
|
|
|
7626
7655
|
function withPageRoleAuthRequired(params) {
|
|
7627
7656
|
const { SuccessComponent, FailureComponent, options } = params;
|
|
7628
7657
|
const allowedRoles = new Set(params.allowedRoles);
|
|
7629
|
-
return withPageAuthRequired(({ user }) => {
|
|
7658
|
+
return withPageAuthRequired(({ user, ...props }) => {
|
|
7630
7659
|
return useMemo(() => {
|
|
7631
7660
|
const userRoles = user.bespoke_roles || [];
|
|
7632
7661
|
if (allowedRoles.size === 0 || userRoles.some((role) => allowedRoles.has(role))) {
|
|
7633
|
-
return /* @__PURE__ */ jsx(SuccessComponent, { user });
|
|
7662
|
+
return /* @__PURE__ */ jsx(SuccessComponent, { user, ...props });
|
|
7634
7663
|
}
|
|
7635
|
-
return /* @__PURE__ */ jsx(FailureComponent, {});
|
|
7636
|
-
}, [user]);
|
|
7664
|
+
return /* @__PURE__ */ jsx(FailureComponent, { ...props });
|
|
7665
|
+
}, [user, props]);
|
|
7637
7666
|
}, options);
|
|
7638
7667
|
}
|
|
7639
7668
|
|
|
@@ -7760,7 +7789,7 @@ function normalizeList(value) {
|
|
|
7760
7789
|
var { localeDefault: localeDefault8 } = getLocales_default();
|
|
7761
7790
|
function parseReadMemberParams(query) {
|
|
7762
7791
|
const locale = normalizeList(query.locale)[0] || localeDefault8 || "en";
|
|
7763
|
-
const all = locale === "all" ||
|
|
7792
|
+
const all = locale === "all" || yn3(query.all);
|
|
7764
7793
|
const mode = normalizeList(query.mode)[0];
|
|
7765
7794
|
const outputParam = normalizeList(query.output)[0] || "full";
|
|
7766
7795
|
const output = outputParam === "lite" ? "lite" : "full";
|
|
@@ -7839,9 +7868,9 @@ function parseSearchMemberParams(query) {
|
|
|
7839
7868
|
locale: localeIsAll ? localeDefault8 : locale,
|
|
7840
7869
|
limit: normalizeList(query.limit).map(parseFiniteNumber)[0] ?? 5,
|
|
7841
7870
|
format: formatIsNested ? "nested" : "plain",
|
|
7842
|
-
includes:
|
|
7843
|
-
visible:
|
|
7844
|
-
noImage:
|
|
7871
|
+
includes: yn3(query.includes, { default: true }),
|
|
7872
|
+
visible: yn3(query.visible, { default: true }),
|
|
7873
|
+
noImage: yn3(query.noImage, { default: false }),
|
|
7845
7874
|
variant,
|
|
7846
7875
|
dimension,
|
|
7847
7876
|
report,
|
|
@@ -9425,8 +9454,8 @@ function BlockPreview(props) {
|
|
|
9425
9454
|
const variables = useInputVariablesFlat(block.id);
|
|
9426
9455
|
const formatterFunctions = useFormatterFunctionsForLocale();
|
|
9427
9456
|
const blockContext = useBlockContext(block.id, locale);
|
|
9428
|
-
const
|
|
9429
|
-
const
|
|
9457
|
+
const blockVariables = useAppSelector((state) => state.variables.variables[block.id] || {});
|
|
9458
|
+
const blockStatus = useAppSelector((state) => state.variables.status[block.id] || {});
|
|
9430
9459
|
const blockContent = types_default[block.type].renderPreviewOnEdit && blockStateContent ? blockStateContent : getBlockContent(block, locale);
|
|
9431
9460
|
const [content, setContent] = useState(null);
|
|
9432
9461
|
const [status, setStatus2] = useState(emptyStatus);
|
|
@@ -9455,8 +9484,8 @@ function BlockPreview(props) {
|
|
|
9455
9484
|
}
|
|
9456
9485
|
if (block.type === BLOCK_TYPES.GENERATOR) {
|
|
9457
9486
|
const hasAPI = Boolean(block.contentByLocale?.logic?.content?.api);
|
|
9458
|
-
setContent({ outputVariables:
|
|
9459
|
-
setStatus2(
|
|
9487
|
+
setContent({ outputVariables: blockVariables, hasAPI });
|
|
9488
|
+
setStatus2(blockStatus);
|
|
9460
9489
|
return;
|
|
9461
9490
|
}
|
|
9462
9491
|
if (block.type === BLOCK_TYPES.SELECTOR) {
|
|
@@ -9495,6 +9524,17 @@ function BlockPreview(props) {
|
|
|
9495
9524
|
};
|
|
9496
9525
|
fetch();
|
|
9497
9526
|
}, [blockContent, variables]);
|
|
9527
|
+
useEffect(() => {
|
|
9528
|
+
if (blockStatus && blockStatus.error && blockStatus.error !== "") {
|
|
9529
|
+
notifications.show({
|
|
9530
|
+
autoClose: 1e4,
|
|
9531
|
+
color: "red",
|
|
9532
|
+
id: "block-error",
|
|
9533
|
+
message: blockStatus.error,
|
|
9534
|
+
title: `Block error ID: ${block.id}`
|
|
9535
|
+
});
|
|
9536
|
+
}
|
|
9537
|
+
}, [blockStatus.error]);
|
|
9498
9538
|
const Renderer = renderers_default[block.type];
|
|
9499
9539
|
const overlayStyle = {
|
|
9500
9540
|
width: "100%",
|
|
@@ -10198,7 +10238,7 @@ function BlockEditor({
|
|
|
10198
10238
|
monacoOptions: {
|
|
10199
10239
|
onChange: (logic) => onChangeCode(logic, locale),
|
|
10200
10240
|
value: blockContent?.logic || "",
|
|
10201
|
-
height: fullscreen ? "85vh" : "
|
|
10241
|
+
height: fullscreen ? "85vh" : "61vh",
|
|
10202
10242
|
width: "100%"
|
|
10203
10243
|
},
|
|
10204
10244
|
variables
|
|
@@ -10218,6 +10258,7 @@ function BlockEditor({
|
|
|
10218
10258
|
}
|
|
10219
10259
|
);
|
|
10220
10260
|
const isVizOrGenerator = [BLOCK_TYPES.GENERATOR, BLOCK_TYPES.VIZ].includes(blockType);
|
|
10261
|
+
const isLogicType = Object.values(BLOCK_LOGIC_TYPES).includes(blockType);
|
|
10221
10262
|
return /* @__PURE__ */ jsxs(Grid, { children: [
|
|
10222
10263
|
/* @__PURE__ */ jsxs(
|
|
10223
10264
|
Col,
|
|
@@ -10288,10 +10329,17 @@ function BlockEditor({
|
|
|
10288
10329
|
height: "100%"
|
|
10289
10330
|
},
|
|
10290
10331
|
children: [
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10332
|
+
/* @__PURE__ */ jsxs(Alert, { icon: /* @__PURE__ */ jsx(IconFlag, {}), children: [
|
|
10333
|
+
!isLogicType && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10334
|
+
"You are editing the ",
|
|
10335
|
+
/* @__PURE__ */ jsx(Code, { children: locale.toUpperCase() }),
|
|
10336
|
+
" version of the block."
|
|
10337
|
+
] }),
|
|
10338
|
+
isLogicType && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10339
|
+
"You are editing a ",
|
|
10340
|
+
/* @__PURE__ */ jsx(Code, { children: "logic" }),
|
|
10341
|
+
" type of block. You have to handle all the languages inside it."
|
|
10342
|
+
] })
|
|
10295
10343
|
] }),
|
|
10296
10344
|
/* @__PURE__ */ jsxs(
|
|
10297
10345
|
Tabs,
|
|
@@ -10734,7 +10782,8 @@ function BlockElement({
|
|
|
10734
10782
|
right: px(theme.spacing.xs) / 2,
|
|
10735
10783
|
top: px(theme.spacing.xs) / 2,
|
|
10736
10784
|
backgroundColor: theme.colors.gray[2],
|
|
10737
|
-
borderRadius: theme.radius.sm
|
|
10785
|
+
borderRadius: theme.radius.sm,
|
|
10786
|
+
zIndex: 2
|
|
10738
10787
|
},
|
|
10739
10788
|
children: [
|
|
10740
10789
|
isInput || isConsumer ? /* @__PURE__ */ jsx(ActionIcon, { children: isInput ? /* @__PURE__ */ jsx(IconLogout, { size: 20, color: theme.colors.red[5] }) : /* @__PURE__ */ jsx(IconLogin, { size: 20, color: theme.colors.green[5] }) }, "globe") : null,
|
|
@@ -13614,7 +13663,7 @@ function BespokeManager(options) {
|
|
|
13614
13663
|
locale = localeDefault4,
|
|
13615
13664
|
profilePrefix = "/profilePathManager"
|
|
13616
13665
|
} = options;
|
|
13617
|
-
const
|
|
13666
|
+
const notifications5 = {
|
|
13618
13667
|
position: "bottom-center",
|
|
13619
13668
|
...options.notifications
|
|
13620
13669
|
};
|
|
@@ -13627,7 +13676,7 @@ function BespokeManager(options) {
|
|
|
13627
13676
|
return /* @__PURE__ */ jsxs(ResourceProvider, { pathSegment, profilePrefix, children: [
|
|
13628
13677
|
/* @__PURE__ */ jsx(Head, { children: /* @__PURE__ */ jsx("title", { children: title }) }),
|
|
13629
13678
|
/* @__PURE__ */ jsxs(MantineProvider, { inherit: false, children: [
|
|
13630
|
-
/* @__PURE__ */ jsx(Notifications, { ...
|
|
13679
|
+
/* @__PURE__ */ jsx(Notifications, { ...notifications5 }),
|
|
13631
13680
|
/* @__PURE__ */ jsx(DialogProvider, { children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx("p", { children: "Client side error in Bespoke. Check the console for details." }), children: /* @__PURE__ */ jsx(BespokeManagerShell, { locale }) }) })
|
|
13632
13681
|
] })
|
|
13633
13682
|
] });
|