@datawheel/bespoke 0.5.2 → 0.5.3

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 +28 -27
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -16309,7 +16309,9 @@ function OptionsModal(props) {
16309
16309
  open,
16310
16310
  title
16311
16311
  } = props;
16312
- const [selectedTab, setSelectedTab] = useState(initialMode || "data");
16312
+ const settings = getOptionsSettings(section.settings);
16313
+ const availableTabs = useMemo(() => tabList.filter((tId) => settings[tId]), [settings]);
16314
+ const [selectedTab, setSelectedTab] = useState(initialMode || availableTabs[0] || "data");
16313
16315
  const optionsTranslations = useBespokeTranslations("options");
16314
16316
  useEffect(() => {
16315
16317
  if (initialMode !== selectedTab) {
@@ -16317,6 +16319,18 @@ function OptionsModal(props) {
16317
16319
  }
16318
16320
  }, [initialMode]);
16319
16321
  const translations = { ...DEFAULT_TRANSLATIONS5, ...optionsTranslations };
16322
+ const tabs = useMemo(() => {
16323
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
16324
+ /* @__PURE__ */ jsxs(Tabs.List, { children: [
16325
+ settings.data && /* @__PURE__ */ jsx(Tabs.Tab, { value: "data", children: translations.download_title }),
16326
+ settings.image && /* @__PURE__ */ jsx(Tabs.Tab, { value: "image", children: translations.image_title }),
16327
+ settings.share && /* @__PURE__ */ jsx(Tabs.Tab, { value: "share", children: translations.share_title })
16328
+ ] }),
16329
+ settings.data && /* @__PURE__ */ jsx(Tabs.Panel, { value: "data", children: /* @__PURE__ */ jsx(DataTab, { section }) }),
16330
+ settings.image && /* @__PURE__ */ jsx(Tabs.Panel, { value: "image", children: /* @__PURE__ */ jsx(ImageTab, { section }) }),
16331
+ settings.share && /* @__PURE__ */ jsx(Tabs.Panel, { value: "share", children: /* @__PURE__ */ jsx(ShareTab, { section }) })
16332
+ ] });
16333
+ }, [settings, section, translations]);
16320
16334
  return /* @__PURE__ */ jsx("div", { className: "cms-section-options-modal", children: open && /* @__PURE__ */ jsx(
16321
16335
  Modal,
16322
16336
  {
@@ -16325,28 +16339,19 @@ function OptionsModal(props) {
16325
16339
  onClose: () => onEnds(),
16326
16340
  size: "xl",
16327
16341
  title,
16328
- children: /* @__PURE__ */ jsxs(
16342
+ children: /* @__PURE__ */ jsx(
16329
16343
  Tabs,
16330
16344
  {
16331
16345
  onTabChange: setSelectedTab,
16332
16346
  value: selectedTab,
16333
16347
  keepMounted: false,
16334
- children: [
16335
- /* @__PURE__ */ jsxs(Tabs.List, { children: [
16336
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "data", children: translations.download_title }),
16337
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "image", children: translations.image_title }),
16338
- /* @__PURE__ */ jsx(Tabs.Tab, { value: "share", children: translations.share_title })
16339
- ] }),
16340
- /* @__PURE__ */ jsx(Tabs.Panel, { value: "data", children: /* @__PURE__ */ jsx(DataTab, { section }) }),
16341
- /* @__PURE__ */ jsx(Tabs.Panel, { value: "image", children: /* @__PURE__ */ jsx(ImageTab, { section }) }),
16342
- /* @__PURE__ */ jsx(Tabs.Panel, { value: "share", children: /* @__PURE__ */ jsx(ShareTab, { section }) })
16343
- ]
16348
+ children: tabs
16344
16349
  }
16345
16350
  )
16346
16351
  }
16347
16352
  ) });
16348
16353
  }
16349
- var DEFAULT_TRANSLATIONS5;
16354
+ var DEFAULT_TRANSLATIONS5, tabList;
16350
16355
  var init_OptionsModal = __esm({
16351
16356
  "components/options/OptionsModal.tsx"() {
16352
16357
  init_esm_shims();
@@ -16354,20 +16359,23 @@ var init_OptionsModal = __esm({
16354
16359
  init_ImageTab();
16355
16360
  init_ShareTab();
16356
16361
  init_TranslationsProvider();
16362
+ init_section2();
16357
16363
  DEFAULT_TRANSLATIONS5 = {
16358
16364
  download_title: "Download Data",
16359
16365
  image_title: "Save Image",
16360
16366
  share_title: "Share Link"
16361
16367
  };
16368
+ tabList = ["data", "image", "share"];
16362
16369
  }
16363
16370
  });
16364
16371
  function Options(props) {
16365
- const { sectionId, disabled = false, optionsSettings } = props;
16372
+ const { sectionId, disabled = false } = props;
16366
16373
  const [opened, setOpened] = useState(false);
16367
16374
  const [mode, setMode] = useState("data");
16368
16375
  const sectionRef = useSectionRef(sectionId);
16369
16376
  const optionsTranslations = useBespokeTranslations("options");
16370
16377
  const translations = { ...DEFAULT_TRANSLATIONS5, ...optionsTranslations };
16378
+ const settings = getOptionsSettings(sectionRef.isSuccess ? sectionRef.data.settings : {});
16371
16379
  const onClickOption = (mode2) => {
16372
16380
  setMode(mode2);
16373
16381
  setOpened(true);
@@ -16377,7 +16385,7 @@ function Options(props) {
16377
16385
  };
16378
16386
  return /* @__PURE__ */ jsxs("div", { className: "cms-section-options", children: [
16379
16387
  /* @__PURE__ */ jsxs(Button.Group, { children: [
16380
- optionsSettings.data && /* @__PURE__ */ jsx(
16388
+ settings.data && /* @__PURE__ */ jsx(
16381
16389
  Button,
16382
16390
  {
16383
16391
  variant: "default",
@@ -16389,7 +16397,7 @@ function Options(props) {
16389
16397
  children: /* @__PURE__ */ jsx(IconTable, { size: 16 })
16390
16398
  }
16391
16399
  ),
16392
- optionsSettings.image && /* @__PURE__ */ jsx(
16400
+ settings.image && /* @__PURE__ */ jsx(
16393
16401
  Button,
16394
16402
  {
16395
16403
  variant: "default",
@@ -16401,7 +16409,7 @@ function Options(props) {
16401
16409
  children: /* @__PURE__ */ jsx(IconCamera, { size: 16 })
16402
16410
  }
16403
16411
  ),
16404
- optionsSettings.share && /* @__PURE__ */ jsx(
16412
+ settings.share && /* @__PURE__ */ jsx(
16405
16413
  Button,
16406
16414
  {
16407
16415
  variant: "default",
@@ -16431,6 +16439,7 @@ var init_Options = __esm({
16431
16439
  init_OptionsModal();
16432
16440
  init_store2();
16433
16441
  init_TranslationsProvider();
16442
+ init_section2();
16434
16443
  }
16435
16444
  });
16436
16445
 
@@ -17154,14 +17163,7 @@ function SectionWrapper({
17154
17163
  children: [
17155
17164
  !print && /* @__PURE__ */ jsxs(Group, { position: "right", mb: "xs", children: [
17156
17165
  /* @__PURE__ */ jsx(SectionResetButton, { id }),
17157
- sectionSettings2.optionsMenu && /* @__PURE__ */ jsx(
17158
- Options,
17159
- {
17160
- sectionId: id,
17161
- disabled: false,
17162
- optionsSettings: getOptionsSettings(sectionSettings2)
17163
- }
17164
- )
17166
+ sectionSettings2.optionsMenu && /* @__PURE__ */ jsx(Options, { sectionId: id, disabled: false })
17165
17167
  ] }),
17166
17168
  /* @__PURE__ */ jsxs(
17167
17169
  StyleWrapper,
@@ -21471,7 +21473,6 @@ init_cms();
21471
21473
  init_getBlockContent();
21472
21474
  init_Options();
21473
21475
  init_SectionMenu();
21474
- init_section2();
21475
21476
  function SectionHeader({
21476
21477
  active,
21477
21478
  isDragging,
@@ -21514,7 +21515,7 @@ function SectionHeader({
21514
21515
  /* @__PURE__ */ jsxs(Group, { children: [
21515
21516
  sectionSettings2.optionsMenu && /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", mx: 16, align: "center", gap: "xs", children: [
21516
21517
  /* @__PURE__ */ jsx(SectionResetButton, { id: section.id }),
21517
- /* @__PURE__ */ jsx(Options, { sectionId: section.id, disabled: !active, optionsSettings: getOptionsSettings(sectionSettings2) })
21518
+ /* @__PURE__ */ jsx(Options, { sectionId: section.id, disabled: !active })
21518
21519
  ] }),
21519
21520
  /* @__PURE__ */ jsx(SectionMenu_default, { sectionId: id, onActivate })
21520
21521
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {
@@ -141,4 +141,4 @@
141
141
  "peerDependencies": {
142
142
  "next": "^14.2.3"
143
143
  }
144
- }
144
+ }