@datawheel/bespoke 0.5.5 → 0.5.7
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 +28 -26
- package/dist/server.js +5 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1267,16 +1267,18 @@ var init_selectorQueryToVariable = __esm({
|
|
|
1267
1267
|
init_cms();
|
|
1268
1268
|
selectorQueryToVariable = (id, query, config) => {
|
|
1269
1269
|
const accessor = `selector${id}id`;
|
|
1270
|
-
const
|
|
1270
|
+
const locationValue = new URLSearchParams(typeof location !== "undefined" && location?.search ? location.search : "").get(accessor);
|
|
1271
|
+
const queryValue = new URLSearchParams(query).get(accessor);
|
|
1272
|
+
const selectorValue = locationValue || queryValue;
|
|
1271
1273
|
if (config.type === SELECTOR_TYPES.MULTI) {
|
|
1272
|
-
const queryIds =
|
|
1274
|
+
const queryIds = selectorValue ? selectorValue.split(",") : config.defaultValue;
|
|
1273
1275
|
const options = config.options.filter((d2) => queryIds.includes(d2.id));
|
|
1274
1276
|
return {
|
|
1275
1277
|
[`selector${id}id`]: queryIds,
|
|
1276
1278
|
[`selector${id}label`]: (options || []).map((d2) => d2.label)
|
|
1277
1279
|
};
|
|
1278
1280
|
}
|
|
1279
|
-
const queryId =
|
|
1281
|
+
const queryId = selectorValue && config.options.find((d2) => d2.id === selectorValue) ? selectorValue : config.defaultValue;
|
|
1280
1282
|
const option = config.options.find((d2) => d2.id === queryId);
|
|
1281
1283
|
return {
|
|
1282
1284
|
[`selector${id}id`]: queryId,
|
|
@@ -18293,12 +18295,12 @@ function ReportSelector({
|
|
|
18293
18295
|
}) {
|
|
18294
18296
|
const [slugReady, setSlugReady] = useState(false);
|
|
18295
18297
|
const dispatch = useAppDispatch();
|
|
18296
|
-
const
|
|
18298
|
+
const location2 = useManagerLocation();
|
|
18297
18299
|
const resource = useContext(ResourceContext);
|
|
18298
18300
|
const dimensions = report && report.dimensions ? report.dimensions : [];
|
|
18299
18301
|
const previews = useAppSelector((state) => state.status.previews);
|
|
18300
18302
|
const currentReport = previews.map((p2) => ({ variantId: p2.variant_id, memberId: p2.content_id }));
|
|
18301
|
-
const param =
|
|
18303
|
+
const param = location2.query.preview;
|
|
18302
18304
|
const slugs = Array.isArray(param) ? param.join("!") : param || "";
|
|
18303
18305
|
const onSelect = (previewMember) => {
|
|
18304
18306
|
const newPreviews = report.dimensions.map((dId) => {
|
|
@@ -18335,7 +18337,7 @@ function ReportSelector({
|
|
|
18335
18337
|
const changeLocation = previewsAsReadMember.filter((p2) => p2.content_id).length === dimensions.length;
|
|
18336
18338
|
dispatch(actions_exports.setPreviews(previewsAsReadMember));
|
|
18337
18339
|
if (changeLocation) {
|
|
18338
|
-
|
|
18340
|
+
location2.setSearchParam("preview", nextParam);
|
|
18339
18341
|
dispatch(actions_exports.recalculateVariables(resource, {
|
|
18340
18342
|
previews: previewsAsReadMember
|
|
18341
18343
|
}));
|
|
@@ -19679,8 +19681,8 @@ function CMSHeader(props) {
|
|
|
19679
19681
|
const resource = useContext(ResourceContext);
|
|
19680
19682
|
const dispatch = useAppDispatch();
|
|
19681
19683
|
const previews = useAppSelector((state) => state.status.previews);
|
|
19682
|
-
const
|
|
19683
|
-
const reportId = Number.parseInt(
|
|
19684
|
+
const location2 = useManagerLocation();
|
|
19685
|
+
const reportId = Number.parseInt(location2.params[0]);
|
|
19684
19686
|
const reportRef = useReportRef(reportId);
|
|
19685
19687
|
const profilePrefix = useProfilePrefix();
|
|
19686
19688
|
const currentLocale = useCurrentLocale2();
|
|
@@ -19696,7 +19698,7 @@ function CMSHeader(props) {
|
|
|
19696
19698
|
const localePrefix = currentLocale === localeDefault10 ? "" : `/${currentLocale}`;
|
|
19697
19699
|
const realPath = previewPath.length ? `${localePrefix}${profilePrefix}/${previewPath.join("/")}` : "";
|
|
19698
19700
|
const onSelectLocale = (previewLocale) => {
|
|
19699
|
-
|
|
19701
|
+
location2.setSearchParam("locale", previewLocale);
|
|
19700
19702
|
dispatch(actions_exports.readMember({
|
|
19701
19703
|
mode: "content_ids",
|
|
19702
19704
|
variant: previews.map((m) => m.variant_id),
|
|
@@ -22747,8 +22749,8 @@ init_hooks();
|
|
|
22747
22749
|
init_use_entity_settings();
|
|
22748
22750
|
init_hooks3();
|
|
22749
22751
|
function ReportSettingsPanel() {
|
|
22750
|
-
const
|
|
22751
|
-
const reportId = Number.parseInt(
|
|
22752
|
+
const location2 = useManagerLocation();
|
|
22753
|
+
const reportId = Number.parseInt(location2.params[0]);
|
|
22752
22754
|
const report = useReportRef(reportId).data;
|
|
22753
22755
|
const { settings, updateSettings } = useReportSettings(reportId);
|
|
22754
22756
|
const { handlers } = useSidebar("reportEditor");
|
|
@@ -24611,7 +24613,7 @@ init_EntityDeleteButton();
|
|
|
24611
24613
|
function ReportCard(props) {
|
|
24612
24614
|
const { for: report, enabled } = props;
|
|
24613
24615
|
const theme = useMantineTheme();
|
|
24614
|
-
const
|
|
24616
|
+
const location2 = useManagerLocation();
|
|
24615
24617
|
const secondaryColor = theme.colorScheme === "dark" ? theme.colors.dark[1] : theme.colors.gray[7];
|
|
24616
24618
|
return /* @__PURE__ */ jsxs(Card, { shadow: "xs", p: "sm", w: "100%", children: [
|
|
24617
24619
|
/* @__PURE__ */ jsxs(Group, { position: "apart", children: [
|
|
@@ -24624,7 +24626,7 @@ function ReportCard(props) {
|
|
|
24624
24626
|
/* @__PURE__ */ jsx(Text, { size: "sm", style: { color: secondaryColor, lineHeight: 2 }, children: "Description of report will go here" }),
|
|
24625
24627
|
/* @__PURE__ */ jsx(Space, { w: "xs" }),
|
|
24626
24628
|
/* @__PURE__ */ jsxs(Group, { position: "apart", children: [
|
|
24627
|
-
/* @__PURE__ */ jsx(Link, { href:
|
|
24629
|
+
/* @__PURE__ */ jsx(Link, { href: location2.href("reports", report.id), passHref: true, children: /* @__PURE__ */ jsx(Button, { leftIcon: /* @__PURE__ */ jsx(IconPencil, {}), compact: true, children: "Edit" }) }),
|
|
24628
24630
|
/* @__PURE__ */ jsx(EntityDeleteButton, { type: "report", id: report.id, disabled: !enabled })
|
|
24629
24631
|
] })
|
|
24630
24632
|
] });
|
|
@@ -25486,7 +25488,7 @@ function BespokeManagerShell(props) {
|
|
|
25486
25488
|
const action = useRef(null);
|
|
25487
25489
|
const [opened, { open, close }] = useDisclosure(false);
|
|
25488
25490
|
const { user, error, isLoading } = useBespokeUser_default();
|
|
25489
|
-
const
|
|
25491
|
+
const location2 = useManagerLocation();
|
|
25490
25492
|
const buildLinks = useCallback((user2) => {
|
|
25491
25493
|
const menuLinks = [];
|
|
25492
25494
|
links.forEach((link) => {
|
|
@@ -25505,7 +25507,7 @@ function BespokeManagerShell(props) {
|
|
|
25505
25507
|
}, []);
|
|
25506
25508
|
const navbar = useMemo(() => {
|
|
25507
25509
|
const linkButtons = buildLinks(user);
|
|
25508
|
-
const expand =
|
|
25510
|
+
const expand = location2.page === "welcome" || opened;
|
|
25509
25511
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
25510
25512
|
Box,
|
|
25511
25513
|
{
|
|
@@ -25551,7 +25553,7 @@ function BespokeManagerShell(props) {
|
|
|
25551
25553
|
},
|
|
25552
25554
|
withBorder: false,
|
|
25553
25555
|
children: [
|
|
25554
|
-
/* @__PURE__ */ jsx(Navbar.Section, { style: { position: "relative" }, children: /* @__PURE__ */ jsx(BespokeLogo, { href:
|
|
25556
|
+
/* @__PURE__ */ jsx(Navbar.Section, { style: { position: "relative" }, children: /* @__PURE__ */ jsx(BespokeLogo, { href: location2.href(""), onlyIcon: !expand, version }) }),
|
|
25555
25557
|
/* @__PURE__ */ jsx(Navbar.Section, { grow: true, component: ScrollArea, children: /* @__PURE__ */ jsx(Stack, { spacing: 0, children: linkButtons }) }),
|
|
25556
25558
|
/* @__PURE__ */ jsx(Navbar.Section, { children: user && !error && !isLoading && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Stack, { px: 13, children: [
|
|
25557
25559
|
/* @__PURE__ */ jsxs(Group, { align: "flex-start", children: [
|
|
@@ -25599,34 +25601,34 @@ function BespokeManagerShell(props) {
|
|
|
25599
25601
|
)
|
|
25600
25602
|
}
|
|
25601
25603
|
) });
|
|
25602
|
-
}, [
|
|
25604
|
+
}, [location2, opened, user]);
|
|
25603
25605
|
const route = useMemo(() => {
|
|
25604
|
-
const item = links.find((page) => page.href.includes(
|
|
25605
|
-
if (
|
|
25606
|
+
const item = links.find((page) => page.href.includes(location2.page));
|
|
25607
|
+
if (location2.page === "welcome") {
|
|
25606
25608
|
return /* @__PURE__ */ jsx(HelloView, {});
|
|
25607
25609
|
}
|
|
25608
25610
|
if (user && Array.isArray(user.bespoke_roles) && user.bespoke_roles.includes(item?.roleRequired)) {
|
|
25609
|
-
if (
|
|
25611
|
+
if (location2.page === "metadata") {
|
|
25610
25612
|
return /* @__PURE__ */ jsx(MetadataEditor, {});
|
|
25611
25613
|
}
|
|
25612
|
-
if (
|
|
25614
|
+
if (location2.page === "formatters") {
|
|
25613
25615
|
return /* @__PURE__ */ jsx(FormatterEditor, {});
|
|
25614
25616
|
}
|
|
25615
|
-
if (
|
|
25616
|
-
if (
|
|
25617
|
-
const reportId = Number.parseInt(
|
|
25617
|
+
if (location2.page === "reports") {
|
|
25618
|
+
if (location2.params.length > 0) {
|
|
25619
|
+
const reportId = Number.parseInt(location2.params[0]);
|
|
25618
25620
|
return /* @__PURE__ */ jsx(BuilderEditor, { id: reportId, locale });
|
|
25619
25621
|
}
|
|
25620
25622
|
return /* @__PURE__ */ jsx(ReportPicker, {});
|
|
25621
25623
|
}
|
|
25622
|
-
if (
|
|
25624
|
+
if (location2.page === "users") {
|
|
25623
25625
|
return /* @__PURE__ */ jsx(UsersEditor, {});
|
|
25624
25626
|
}
|
|
25625
25627
|
} else {
|
|
25626
25628
|
return /* @__PURE__ */ jsx(UnauthorizeView, {});
|
|
25627
25629
|
}
|
|
25628
25630
|
return /* @__PURE__ */ jsx(NotFoundView, {});
|
|
25629
|
-
}, [
|
|
25631
|
+
}, [location2, user]);
|
|
25630
25632
|
const dispatch = useAppDispatch();
|
|
25631
25633
|
useEffect(() => {
|
|
25632
25634
|
dispatch(statusActions.setStatus({ isCMS: true }));
|
package/dist/server.js
CHANGED
|
@@ -4881,16 +4881,18 @@ function runSelector(id, logic, formatterFunctions, blockContext, replaceQuery =
|
|
|
4881
4881
|
// libs/selectors/selectorQueryToVariable.js
|
|
4882
4882
|
var selectorQueryToVariable = (id, query, config) => {
|
|
4883
4883
|
const accessor = `selector${id}id`;
|
|
4884
|
-
const
|
|
4884
|
+
const locationValue = new URLSearchParams(typeof location !== "undefined" && location?.search ? location.search : "").get(accessor);
|
|
4885
|
+
const queryValue = new URLSearchParams(query).get(accessor);
|
|
4886
|
+
const selectorValue = locationValue || queryValue;
|
|
4885
4887
|
if (config.type === SELECTOR_TYPES.MULTI) {
|
|
4886
|
-
const queryIds =
|
|
4888
|
+
const queryIds = selectorValue ? selectorValue.split(",") : config.defaultValue;
|
|
4887
4889
|
const options = config.options.filter((d2) => queryIds.includes(d2.id));
|
|
4888
4890
|
return {
|
|
4889
4891
|
[`selector${id}id`]: queryIds,
|
|
4890
4892
|
[`selector${id}label`]: (options || []).map((d2) => d2.label)
|
|
4891
4893
|
};
|
|
4892
4894
|
}
|
|
4893
|
-
const queryId =
|
|
4895
|
+
const queryId = selectorValue && config.options.find((d2) => d2.id === selectorValue) ? selectorValue : config.defaultValue;
|
|
4894
4896
|
const option = config.options.find((d2) => d2.id === queryId);
|
|
4895
4897
|
return {
|
|
4896
4898
|
[`selector${id}id`]: queryId,
|