@datawheel/bespoke 0.1.32 → 0.1.33

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.
Files changed (2) hide show
  1. package/dist/index.js +142 -93
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { Notifications, notifications } from '@mantine/notifications';
16
16
  import React, { forwardRef, useMemo, useState, useCallback, useContext, useEffect, createContext, 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, Tooltip, ActionIcon, Center, Modal, Button, SegmentedControl, Select, MultiSelect, Title, TextInput, Switch, Box, List, Menu, Anchor, MantineProvider, Divider, Burger, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Container, Loader, Alert, Collapse, Card, Space, Code, Textarea, rem, Paper, Grid, Input, Popover, Checkbox, Radio, Drawer, Overlay, SimpleGrid, Autocomplete, Tabs, Header, px, Image, FileInput, Accordion, HoverCard, CopyButton, NumberInput, Col } from '@mantine/core';
19
+ import { Stack, Text, Badge, Group, useMantineTheme, Flex, packSx, Title, Tooltip, ActionIcon, Center, Modal, Button, SegmentedControl, Select, MultiSelect, TextInput, Switch, Box, List, Menu, Anchor, MantineProvider, Divider, Burger, Navbar, ScrollArea, Avatar, AppShell, UnstyledButton, ThemeIcon, LoadingOverlay, Skeleton, Container, Loader, Alert, Collapse, Card, Space, Code, Textarea, rem, Paper, Grid, Input, Popover, Checkbox, Radio, Drawer, Overlay, SimpleGrid, Autocomplete, Tabs, Header, px, Image, FileInput, Accordion, HoverCard, CopyButton, NumberInput, 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';
@@ -2929,38 +2929,51 @@ function Viz(config) {
2929
2929
  const Visualization = vizTypes[fallbackType];
2930
2930
  const { _data, ...vizPropsConfig } = vizProps.config;
2931
2931
  const vizConfig = { locale, variables, ...vizPropsConfig, ...configOverride };
2932
- return /* @__PURE__ */ jsx(
2933
- "div",
2934
- {
2935
- style: {
2936
- display: "flex",
2937
- flex: "1 1 100%",
2938
- minHeight: 400
2939
- },
2940
- children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx("p", { children: "Error in d3plus viz config." }), children: /* @__PURE__ */ jsx(
2941
- Visualization,
2942
- {
2943
- style: { flex: 1 },
2944
- dataFormat: (resp) => {
2945
- vizProps.data && Array.isArray(vizProps.data) && vizProps.data.length > 1 && vizProps.data.some((d) => typeof d === "string");
2946
- let data;
2947
- try {
2948
- data = vizProps.dataFormat(resp);
2949
- } catch (e) {
2950
- console.log("Error in dataFormat: ", e);
2951
- data = [];
2952
- }
2953
- return data;
2954
- },
2955
- linksFormat: vizProps.linksFormat,
2956
- nodesFormat: vizProps.nodesFormat,
2957
- topojsonFormat: vizProps.topojsonFormat,
2958
- config: { ...defaultConfig_default, ...vizConfig, sectionVariables: sectionVariablesStr }
2932
+ const { title } = vizConfig;
2933
+ return /* @__PURE__ */ jsxs("div", { className: "bespoke-Viz", children: [
2934
+ title && /* @__PURE__ */ jsx(
2935
+ Title,
2936
+ {
2937
+ className: "bespoke-Viz-title",
2938
+ order: 4,
2939
+ size: "h6",
2940
+ align: "center",
2941
+ dangerouslySetInnerHTML: { __html: title }
2942
+ }
2943
+ ),
2944
+ /* @__PURE__ */ jsx(
2945
+ "div",
2946
+ {
2947
+ style: {
2948
+ display: "flex",
2949
+ flex: "1 1 100%",
2950
+ minHeight: 400
2959
2951
  },
2960
- "viz-key"
2961
- ) })
2962
- }
2963
- );
2952
+ children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx("p", { children: "Error in d3plus viz config." }), children: /* @__PURE__ */ jsx(
2953
+ Visualization,
2954
+ {
2955
+ style: { flex: 1 },
2956
+ dataFormat: (resp) => {
2957
+ vizProps.data && Array.isArray(vizProps.data) && vizProps.data.length > 1 && vizProps.data.some((d) => typeof d === "string");
2958
+ let data;
2959
+ try {
2960
+ data = vizProps.dataFormat(resp);
2961
+ } catch (e) {
2962
+ console.log("Error in dataFormat: ", e);
2963
+ data = [];
2964
+ }
2965
+ return data;
2966
+ },
2967
+ linksFormat: vizProps.linksFormat,
2968
+ nodesFormat: vizProps.nodesFormat,
2969
+ topojsonFormat: vizProps.topojsonFormat,
2970
+ config: { ...defaultConfig_default, ...vizConfig, sectionVariables: sectionVariablesStr, title: void 0 }
2971
+ },
2972
+ "viz-key"
2973
+ ) })
2974
+ }
2975
+ )
2976
+ ] });
2964
2977
  }
2965
2978
  var vizTypes;
2966
2979
  var init_Viz = __esm({
@@ -5606,35 +5619,50 @@ function SectionBackground() {
5606
5619
  key: member ? `bg-${member.content_id}` : `bg-${ix}`,
5607
5620
  src: member ? `/api/cms/member/image.png?member=${member.content_id}&size=splash` : ""
5608
5621
  }));
5609
- return /* @__PURE__ */ jsx(
5610
- Group,
5611
- {
5612
- className: "cms-section-bg",
5613
- grow: true,
5614
- spacing: 0,
5615
- style: {
5616
- background: "white",
5617
- position: "absolute",
5618
- width: "100%",
5619
- height: "100%",
5620
- opacity: 0.5
5621
- },
5622
- children: images.map((image) => /* @__PURE__ */ jsx(
5623
- "div",
5624
- {
5625
- className: "cms-section-member-bg",
5626
- style: {
5627
- backgroundImage: `url(${image.src})`,
5628
- backgroundSize: "cover",
5629
- backgroundPosition: "center center",
5630
- height: "100%",
5631
- width: "100%"
5632
- }
5622
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5623
+ /* @__PURE__ */ jsx(
5624
+ "div",
5625
+ {
5626
+ className: "cms-section-gradient-bg",
5627
+ style: {
5628
+ background: "white",
5629
+ position: "absolute",
5630
+ width: "100%",
5631
+ height: "100%",
5632
+ opacity: 0.33,
5633
+ zIndex: 1
5634
+ }
5635
+ }
5636
+ ),
5637
+ /* @__PURE__ */ jsx(
5638
+ Group,
5639
+ {
5640
+ className: "cms-section-bg",
5641
+ grow: true,
5642
+ spacing: 0,
5643
+ style: {
5644
+ position: "absolute",
5645
+ width: "100%",
5646
+ height: "100%",
5647
+ zIndex: 0
5633
5648
  },
5634
- image.key
5635
- ))
5636
- }
5637
- );
5649
+ children: images.map((image) => /* @__PURE__ */ jsx(
5650
+ "div",
5651
+ {
5652
+ className: "cms-section-member-bg",
5653
+ style: {
5654
+ backgroundImage: `url(${image.src})`,
5655
+ backgroundSize: "cover",
5656
+ backgroundPosition: "center center",
5657
+ height: "100%",
5658
+ width: "100%"
5659
+ }
5660
+ },
5661
+ image.key
5662
+ ))
5663
+ }
5664
+ )
5665
+ ] });
5638
5666
  }
5639
5667
 
5640
5668
  // components/options/Options.tsx
@@ -7021,8 +7049,8 @@ var PositionWrapper = ({ settings, styles, children, ...props }) => {
7021
7049
  var WidthWrapper = ({ settings, styles, children, ...props }) => {
7022
7050
  const { width: container } = settings;
7023
7051
  const defaultStyles = {
7024
- "center": {},
7025
- "full": {}
7052
+ "center": { zIndex: 1 },
7053
+ "full": { zIndex: 1 }
7026
7054
  };
7027
7055
  const defaultProps = {
7028
7056
  "center": { size: "lg", p: "sm", fluid: false },
@@ -7062,7 +7090,7 @@ function Section({ section }) {
7062
7090
  return b.settings.allowed === "always";
7063
7091
  }
7064
7092
  });
7065
- const columns = sectionBlocks.reduce((acc, d) => {
7093
+ const columns = sectionBlocks.filter((d) => d.type !== BLOCK_TYPES.GENERATOR).reduce((acc, d) => {
7066
7094
  if (!acc[d.blockcol]) {
7067
7095
  acc[d.blockcol] = { [d.blockrow]: d };
7068
7096
  } else {
@@ -7078,6 +7106,7 @@ function Section({ section }) {
7078
7106
  return /* @__PURE__ */ jsxs(
7079
7107
  PositionWrapper,
7080
7108
  {
7109
+ className: `bespoke-Section-${id} bespoke-Section-root `,
7081
7110
  settings: sectionSettings2,
7082
7111
  styles: sectionStyles?.root || void 0,
7083
7112
  children: [
@@ -7085,6 +7114,7 @@ function Section({ section }) {
7085
7114
  /* @__PURE__ */ jsxs(
7086
7115
  WidthWrapper,
7087
7116
  {
7117
+ className: `bespoke-Section-${id} bespoke-Section-container `,
7088
7118
  settings: sectionSettings2,
7089
7119
  styles: sectionStyles?.container,
7090
7120
  id: `section-${id}`,
@@ -7094,34 +7124,52 @@ function Section({ section }) {
7094
7124
  /* @__PURE__ */ jsx(SectionResetButton, { id: section.id }),
7095
7125
  sectionSettings2.optionsMenu && /* @__PURE__ */ jsx(Options, { sectionId: section.id })
7096
7126
  ] }),
7097
- /* @__PURE__ */ jsx(StyleWrapper, { className: "bespoke-section-content", settings: sectionSettings2, styles: sectionStyles?.content, children: /* @__PURE__ */ jsx(ColumnsWrapper, { children: Object.keys(columns).sort((a, b) => orderSort(a, b, "blockcol")).map((columnIndex) => {
7098
- const column = columns[columnIndex];
7099
- const columnSettings = settings.columnSettings ? settings.columnSettings[columnIndex] : {};
7100
- return /* @__PURE__ */ jsx(
7101
- SectionColumn,
7102
- {
7103
- column,
7104
- columnSettings,
7105
- sx: { flexBasis: `${100 / colsQty}%` },
7106
- children: Object.values(column).sort((a, b) => orderSort(a, b, "blockrow")).map((item) => {
7107
- if (!item.id)
7108
- return null;
7109
- const { settings: settings2, type } = blockRecords[item.id];
7110
- const blockWidth = settings2.width && !settings2.width.stretch && settings2.width.unit ? formatters[settings2.width.unit](settings2.width.value) : settings2.display === "inline" ? "auto" : "100%";
7111
- const blockStyles = {
7112
- alignSelf: type === "visualization" ? "stretch" : "flex-start",
7113
- flexGrow: 0,
7114
- margin: "0",
7115
- textAlign: settings2.align || blockSettings.align.defaultValue,
7116
- width: blockWidth,
7117
- minWidth: 300
7118
- };
7119
- return /* @__PURE__ */ jsx(Box, { sx: blockStyles, py: site_default.block.padding, children: /* @__PURE__ */ jsx(Block, { blockId: item.id }, item.id) }, item.id);
7120
- })
7121
- },
7122
- columnIndex
7123
- );
7124
- }) }) })
7127
+ /* @__PURE__ */ jsx(
7128
+ StyleWrapper,
7129
+ {
7130
+ className: `bespoke-Section-${id} bespoke-Section-container`,
7131
+ settings: sectionSettings2,
7132
+ styles: sectionStyles?.content,
7133
+ children: /* @__PURE__ */ jsx(ColumnsWrapper, { children: Object.keys(columns).sort((a, b) => orderSort(a, b, "blockcol")).map((columnIndex) => {
7134
+ const column = columns[columnIndex];
7135
+ const columnSettings = settings.columnSettings ? settings.columnSettings[columnIndex] : {};
7136
+ return /* @__PURE__ */ jsx(
7137
+ SectionColumn,
7138
+ {
7139
+ column,
7140
+ columnSettings,
7141
+ sx: { flexBasis: `${100 / colsQty}%` },
7142
+ children: Object.values(column).sort((a, b) => orderSort(a, b, "blockrow")).map((item) => {
7143
+ if (!item.id || !status[item.id].allowed)
7144
+ return null;
7145
+ const { settings: settings2, type } = blockRecords[item.id];
7146
+ const blockWidth = settings2.width && !settings2.width.stretch && settings2.width.unit ? formatters[settings2.width.unit](settings2.width.value) : settings2.display === "inline" ? "auto" : "100%";
7147
+ const blockStyles = {
7148
+ alignSelf: type === "visualization" ? "stretch" : "flex-start",
7149
+ flexGrow: 0,
7150
+ margin: "0",
7151
+ textAlign: settings2.align || blockSettings.align.defaultValue,
7152
+ width: blockWidth,
7153
+ minWidth: 300
7154
+ };
7155
+ return /* @__PURE__ */ jsx(
7156
+ Box,
7157
+ {
7158
+ className: "bespoke-Block-wrapper",
7159
+ id: `bespoke-Block-${item.id}`,
7160
+ sx: blockStyles,
7161
+ py: site_default.block.padding,
7162
+ children: /* @__PURE__ */ jsx(Block, { blockId: item.id }, item.id)
7163
+ },
7164
+ item.id
7165
+ );
7166
+ })
7167
+ },
7168
+ columnIndex
7169
+ );
7170
+ }) })
7171
+ }
7172
+ )
7125
7173
  ]
7126
7174
  }
7127
7175
  )
@@ -10601,7 +10649,6 @@ function SectionEditor({
10601
10649
  }
10602
10650
  ),
10603
10651
  /* @__PURE__ */ jsxs(Box, { pos: "relative", children: [
10604
- memberImageBg && /* @__PURE__ */ jsx(SectionBackground, {}),
10605
10652
  optionsMenu && /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", mx: 16, align: "center", gap: "xs", children: [
10606
10653
  /* @__PURE__ */ jsx(SectionResetButton, { id: section.id }),
10607
10654
  /* @__PURE__ */ jsx(Options, { sectionId: section.id })
@@ -10628,13 +10675,15 @@ function SectionEditor({
10628
10675
  ] }, `block-${item.id}`))
10629
10676
  }
10630
10677
  ),
10678
+ memberImageBg && /* @__PURE__ */ jsx(SectionBackground, {}),
10631
10679
  /* @__PURE__ */ jsxs(
10632
10680
  ColumnsWrapper,
10633
10681
  {
10634
10682
  ref: columnContainer,
10635
10683
  containerProps: {
10636
10684
  mih: !isActive || !columnsQty ? 120 : "none",
10637
- p: "md"
10685
+ p: "md",
10686
+ style: { zIndex: 1 }
10638
10687
  },
10639
10688
  children: [
10640
10689
  /* @__PURE__ */ jsxs(DragDropContext, { onDragEnd, onDragStart, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {