@datawheel/bespoke 0.1.32 → 0.1.34

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 +143 -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
@@ -6348,6 +6376,7 @@ function OptionsModal(props) {
6348
6376
  return /* @__PURE__ */ jsx("div", { className: "cms-section-options-modal", children: open && /* @__PURE__ */ jsx(
6349
6377
  Modal,
6350
6378
  {
6379
+ className: "bespoke-options-modal",
6351
6380
  opened: true,
6352
6381
  onClose: () => onEnds(),
6353
6382
  size: "xl",
@@ -7021,8 +7050,8 @@ var PositionWrapper = ({ settings, styles, children, ...props }) => {
7021
7050
  var WidthWrapper = ({ settings, styles, children, ...props }) => {
7022
7051
  const { width: container } = settings;
7023
7052
  const defaultStyles = {
7024
- "center": {},
7025
- "full": {}
7053
+ "center": { zIndex: 1 },
7054
+ "full": { zIndex: 1 }
7026
7055
  };
7027
7056
  const defaultProps = {
7028
7057
  "center": { size: "lg", p: "sm", fluid: false },
@@ -7062,7 +7091,7 @@ function Section({ section }) {
7062
7091
  return b.settings.allowed === "always";
7063
7092
  }
7064
7093
  });
7065
- const columns = sectionBlocks.reduce((acc, d) => {
7094
+ const columns = sectionBlocks.filter((d) => d.type !== BLOCK_TYPES.GENERATOR).reduce((acc, d) => {
7066
7095
  if (!acc[d.blockcol]) {
7067
7096
  acc[d.blockcol] = { [d.blockrow]: d };
7068
7097
  } else {
@@ -7078,6 +7107,7 @@ function Section({ section }) {
7078
7107
  return /* @__PURE__ */ jsxs(
7079
7108
  PositionWrapper,
7080
7109
  {
7110
+ className: `bespoke-Section-${id} bespoke-Section-root `,
7081
7111
  settings: sectionSettings2,
7082
7112
  styles: sectionStyles?.root || void 0,
7083
7113
  children: [
@@ -7085,6 +7115,7 @@ function Section({ section }) {
7085
7115
  /* @__PURE__ */ jsxs(
7086
7116
  WidthWrapper,
7087
7117
  {
7118
+ className: `bespoke-Section-${id} bespoke-Section-container `,
7088
7119
  settings: sectionSettings2,
7089
7120
  styles: sectionStyles?.container,
7090
7121
  id: `section-${id}`,
@@ -7094,34 +7125,52 @@ function Section({ section }) {
7094
7125
  /* @__PURE__ */ jsx(SectionResetButton, { id: section.id }),
7095
7126
  sectionSettings2.optionsMenu && /* @__PURE__ */ jsx(Options, { sectionId: section.id })
7096
7127
  ] }),
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
- }) }) })
7128
+ /* @__PURE__ */ jsx(
7129
+ StyleWrapper,
7130
+ {
7131
+ className: `bespoke-Section-${id} bespoke-Section-container`,
7132
+ settings: sectionSettings2,
7133
+ styles: sectionStyles?.content,
7134
+ children: /* @__PURE__ */ jsx(ColumnsWrapper, { children: Object.keys(columns).sort((a, b) => orderSort(a, b, "blockcol")).map((columnIndex) => {
7135
+ const column = columns[columnIndex];
7136
+ const columnSettings = settings.columnSettings ? settings.columnSettings[columnIndex] : {};
7137
+ return /* @__PURE__ */ jsx(
7138
+ SectionColumn,
7139
+ {
7140
+ column,
7141
+ columnSettings,
7142
+ sx: { flexBasis: `${100 / colsQty}%` },
7143
+ children: Object.values(column).sort((a, b) => orderSort(a, b, "blockrow")).map((item) => {
7144
+ if (!item.id || !status[item.id].allowed && item.type !== BLOCK_TYPES.NAV)
7145
+ return null;
7146
+ const { settings: settings2, type } = blockRecords[item.id];
7147
+ const blockWidth = settings2.width && !settings2.width.stretch && settings2.width.unit ? formatters[settings2.width.unit](settings2.width.value) : settings2.display === "inline" ? "auto" : "100%";
7148
+ const blockStyles = {
7149
+ alignSelf: type === "visualization" ? "stretch" : "flex-start",
7150
+ flexGrow: 0,
7151
+ margin: "0",
7152
+ textAlign: settings2.align || blockSettings.align.defaultValue,
7153
+ width: blockWidth,
7154
+ minWidth: 300
7155
+ };
7156
+ return /* @__PURE__ */ jsx(
7157
+ Box,
7158
+ {
7159
+ className: "bespoke-Block-wrapper",
7160
+ id: `bespoke-Block-${item.id}`,
7161
+ sx: blockStyles,
7162
+ py: site_default.block.padding,
7163
+ children: /* @__PURE__ */ jsx(Block, { blockId: item.id }, item.id)
7164
+ },
7165
+ item.id
7166
+ );
7167
+ })
7168
+ },
7169
+ columnIndex
7170
+ );
7171
+ }) })
7172
+ }
7173
+ )
7125
7174
  ]
7126
7175
  }
7127
7176
  )
@@ -10601,7 +10650,6 @@ function SectionEditor({
10601
10650
  }
10602
10651
  ),
10603
10652
  /* @__PURE__ */ jsxs(Box, { pos: "relative", children: [
10604
- memberImageBg && /* @__PURE__ */ jsx(SectionBackground, {}),
10605
10653
  optionsMenu && /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", mx: 16, align: "center", gap: "xs", children: [
10606
10654
  /* @__PURE__ */ jsx(SectionResetButton, { id: section.id }),
10607
10655
  /* @__PURE__ */ jsx(Options, { sectionId: section.id })
@@ -10628,13 +10676,15 @@ function SectionEditor({
10628
10676
  ] }, `block-${item.id}`))
10629
10677
  }
10630
10678
  ),
10679
+ memberImageBg && /* @__PURE__ */ jsx(SectionBackground, {}),
10631
10680
  /* @__PURE__ */ jsxs(
10632
10681
  ColumnsWrapper,
10633
10682
  {
10634
10683
  ref: columnContainer,
10635
10684
  containerProps: {
10636
10685
  mih: !isActive || !columnsQty ? 120 : "none",
10637
- p: "md"
10686
+ p: "md",
10687
+ style: { zIndex: 1 }
10638
10688
  },
10639
10689
  children: [
10640
10690
  /* @__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.34",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {