@planningcenter/topbar 11.0.1 → 11.0.3-rc.0

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.
@@ -356,7 +356,7 @@
356
356
  fill: fill
357
357
  })));
358
358
 
359
- var styles$b = {"announcement":"announcement-pI5tM","announcement--platform":"announcement--platform-EcUn2","announcement-icon":"announcement-icon-Ov39-","announcement-content":"announcement-content-q2ad6","dismiss":"dismiss-wUAoU"};
359
+ var styles$b = {"announcement":"announcement-pI5tM","announcement--platform":"announcement--platform-EcUn2","announcement--promo":"announcement--promo-FarUk","announcement-icon":"announcement-icon-Ov39-","announcement-content":"announcement-content-q2ad6","dismiss":"dismiss-wUAoU","dismiss--promo":"dismiss--promo-7zvO4"};
360
360
 
361
361
  function AnnouncementIcon() {
362
362
  return /*#__PURE__*/React.createElement("svg", {
@@ -424,11 +424,14 @@
424
424
  render() {
425
425
  const {
426
426
  style,
427
+ variant,
427
428
  ...platformProps
428
429
  } = this.props;
430
+ const isPromo = variant === "promo";
429
431
  return /*#__PURE__*/React.createElement("div", {
430
- className: classnames(styles$b["announcement"], styles$b["announcement--platform"])
431
- }, /*#__PURE__*/React.createElement(AnnouncementIcon, null), /*#__PURE__*/React.createElement("div", {
432
+ className: classnames(styles$b["announcement"], styles$b[`announcement--${variant !== null && variant !== void 0 ? variant : "platform"}`]),
433
+ "data-announcement-variant": variant !== null && variant !== void 0 ? variant : "platform"
434
+ }, !isPromo && /*#__PURE__*/React.createElement(AnnouncementIcon, null), /*#__PURE__*/React.createElement("div", {
432
435
  className: styles$b["announcement-content"],
433
436
  style: style,
434
437
  ...platformProps
@@ -451,10 +454,12 @@
451
454
  env: this.props.env,
452
455
  initialAnnouncements: this.props.data,
453
456
  configuredFetch: this.props.configuredFetch
454
- }, (data, actions) => Boolean(data.announcements.length > 0) ? (/*#__PURE__*/React.createElement("div", null, data.announcements.map(announcement => this.props.renderItem({
455
- actions,
456
- announcement
457
- })))) : null));
457
+ }, (data, actions) => {
458
+ return data.announcements.length > 0 ? (/*#__PURE__*/React.createElement("div", null, data.announcements.map(announcement => this.props.renderItem({
459
+ actions,
460
+ announcement
461
+ })))) : null;
462
+ }));
458
463
  }
459
464
  }
460
465
  PlatformAnnouncements.defaultProps = {
@@ -462,33 +467,39 @@
462
467
  renderItem: ({
463
468
  announcement,
464
469
  actions
465
- }) => (/*#__PURE__*/React.createElement(DissmissibleAnnouncement, {
470
+ }) => (/*#__PURE__*/React.createElement(DismissibleAnnouncement, {
466
471
  key: announcement.id,
467
472
  html: announcement.data.html,
473
+ variant: announcement.data.style,
468
474
  onClick: () => actions.dismissAnnouncements(announcement.id)
469
475
  }))
470
476
  };
471
477
  function StyledDismissButton$1({
478
+ variant,
472
479
  ...props
473
480
  }) {
481
+ const isPromo = variant === "promo";
474
482
  return /*#__PURE__*/React.createElement("button", {
475
483
  type: "button",
476
- className: styles$b.dismiss,
484
+ className: classnames(styles$b.dismiss, isPromo && styles$b["dismiss--promo"]),
477
485
  ...props
478
486
  }, /*#__PURE__*/React.createElement(X, {
479
- fill: "white",
487
+ fill: isPromo ? "currentColor" : "white",
480
488
  style: {
481
489
  height: 20,
482
490
  width: 20
483
491
  }
484
492
  }));
485
493
  }
486
- function DissmissibleAnnouncement(props) {
487
- return /*#__PURE__*/React.createElement(StyledAnnouncement$1, null, /*#__PURE__*/React.createElement("span", {
494
+ function DismissibleAnnouncement(props) {
495
+ return /*#__PURE__*/React.createElement(StyledAnnouncement$1, {
496
+ variant: props.variant
497
+ }, /*#__PURE__*/React.createElement("span", {
488
498
  dangerouslySetInnerHTML: {
489
499
  __html: props.html
490
500
  }
491
501
  }), /*#__PURE__*/React.createElement(StyledDismissButton$1, {
502
+ variant: props.variant,
492
503
  onClick: props.onClick
493
504
  }));
494
505
  }
@@ -685,7 +696,47 @@
685
696
  }, [channelSubscription, callback]);
686
697
  };
687
698
 
699
+ function useMediaQuery(query) {
700
+ const getMatches = query => {
701
+ // Prevents SSR issues
702
+ if (typeof window !== "undefined") {
703
+ return window.matchMedia(query).matches;
704
+ }
705
+ return false;
706
+ };
707
+ const [matches, setMatches] = React.useState(getMatches(query));
708
+ function handleChange() {
709
+ setMatches(getMatches(query));
710
+ }
711
+ React.useEffect(() => {
712
+ const matchMedia = window.matchMedia(query);
713
+ // Triggered at the first client-side load and if query changes
714
+ handleChange();
715
+ // Listen matchMedia
716
+ if (matchMedia.addListener) {
717
+ matchMedia.addListener(handleChange);
718
+ } else {
719
+ matchMedia.addEventListener("change", handleChange);
720
+ }
721
+ return () => {
722
+ if (matchMedia.removeListener) {
723
+ matchMedia.removeListener(handleChange);
724
+ } else {
725
+ matchMedia.removeEventListener("change", handleChange);
726
+ }
727
+ };
728
+ }, [query]);
729
+ return matches;
730
+ }
731
+
688
732
  const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1);
733
+ const RESOLVED_COLOR_MODE_ATTRIBUTE = "data-resolved-color-mode";
734
+ function resolveColorMode(colorMode) {
735
+ if (colorMode === "system") {
736
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
737
+ }
738
+ return colorMode;
739
+ }
689
740
  const debounce = (func, wait) => {
690
741
  let timeout;
691
742
  return function (...args) {
@@ -766,6 +817,25 @@
766
817
  return storedValue;
767
818
  };
768
819
 
820
+ function createStore(initialState) {
821
+ let currentState = initialState;
822
+ const listeners = new Set();
823
+ return {
824
+ getState: () => currentState,
825
+ setState: newState => {
826
+ currentState = newState;
827
+ listeners.forEach(listener => listener(currentState));
828
+ },
829
+ subscribe: listener => {
830
+ listeners.add(listener);
831
+ return () => listeners.delete(listener);
832
+ }
833
+ };
834
+ }
835
+ const store$1 = createStore({});
836
+
837
+ const useStore = (selector = state => state) => shim.useSyncExternalStore(store$1.subscribe, () => selector(store$1.getState()));
838
+
769
839
  const useTopbarAPI = ({
770
840
  configuredFetch,
771
841
  env
@@ -792,23 +862,6 @@
792
862
  return resp;
793
863
  };
794
864
 
795
- function createStore(initialState) {
796
- let currentState = initialState;
797
- const listeners = new Set();
798
- return {
799
- getState: () => currentState,
800
- setState: newState => {
801
- currentState = newState;
802
- listeners.forEach(listener => listener(currentState));
803
- },
804
- subscribe: listener => {
805
- listeners.add(listener);
806
- return () => listeners.delete(listener);
807
- }
808
- };
809
- }
810
- const store$1 = createStore({});
811
-
812
865
  const AppsProvider = ({
813
866
  configuredFetch = defaultFetch,
814
867
  enableJoltLogging,
@@ -828,6 +881,10 @@
828
881
  const hasConnectedPeople = (_b = (_a = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.has_connected_people;
829
882
  const mfaConfigured = !!((_d = (_c = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _c === void 0 ? void 0 : _c.attributes) === null || _d === void 0 ? void 0 : _d.mfa_configured);
830
883
  const colorMode = (_f = (_e = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _e === void 0 ? void 0 : _e.attributes) === null || _f === void 0 ? void 0 : _f.color_mode;
884
+ const {
885
+ colorMode: currentColorMode
886
+ } = useStore();
887
+ const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
831
888
  const name = (_h = (_g = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _g === void 0 ? void 0 : _g.attributes) === null || _h === void 0 ? void 0 : _h.name;
832
889
  const notificationsEnabled = !window.notificationsDisabled;
833
890
  const organizationTimeZone = ((_k = (_j = topbarResponse === null || topbarResponse === void 0 ? void 0 : topbarResponse.data) === null || _j === void 0 ? void 0 : _j.attributes) === null || _k === void 0 ? void 0 : _k.org_time_zone) || "America/Los_Angeles";
@@ -879,6 +936,16 @@
879
936
  enabled: true,
880
937
  joltChannel: notificationsJoltChannel
881
938
  });
939
+ React.useLayoutEffect(() => {
940
+ if (colorMode) {
941
+ document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, resolveColorMode(colorMode));
942
+ }
943
+ }, [colorMode]);
944
+ React.useEffect(() => {
945
+ if (currentColorMode === "system") {
946
+ document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, prefersDark ? "dark" : "light");
947
+ }
948
+ }, [currentColorMode, prefersDark]);
882
949
  React.useEffect(() => {
883
950
  const state = store$1.getState();
884
951
  store$1.setState({
@@ -2047,8 +2114,6 @@
2047
2114
  }, [routes, app]);
2048
2115
  };
2049
2116
 
2050
- const useStore = (selector = state => state) => shim.useSyncExternalStore(store$1.subscribe, () => selector(store$1.getState()));
2051
-
2052
2117
  const useUpdateStore = () => React.useCallback(updates => {
2053
2118
  const currentState = store$1.getState();
2054
2119
  store$1.setState({
@@ -2414,7 +2479,7 @@
2414
2479
  width: 24,
2415
2480
  xmlns: "http://www.w3.org/2000/svg"
2416
2481
  }, /*#__PURE__*/React.createElement(Accounts$1, {
2417
- color: "var(--t-icon-color-secondary",
2482
+ color: "var(--t-icon-color-secondary)",
2418
2483
  key: "key2"
2419
2484
  })), /*#__PURE__*/React.createElement("span", null, "Account settings"));
2420
2485
  }
@@ -2662,8 +2727,8 @@
2662
2727
  function onHashChange() {
2663
2728
  updateFragment(location.hash);
2664
2729
  }
2665
- window.addEventListener('hashchange', onHashChange);
2666
- return () => window.removeEventListener('hashchange', onHashChange);
2730
+ window.addEventListener("hashchange", onHashChange);
2731
+ return () => window.removeEventListener("hashchange", onHashChange);
2667
2732
  }, [updateFragment]);
2668
2733
  return [value, updateFragment];
2669
2734
  }
@@ -2677,9 +2742,9 @@
2677
2742
  }, [updateFragment]);
2678
2743
  const route = React.useMemo(() => {
2679
2744
  if (toolbarFragment) {
2680
- const [tool, ...rest] = toolbarFragment.split('/');
2745
+ const [tool, ...rest] = toolbarFragment.split("/");
2681
2746
  return {
2682
- path: rest.join('/'),
2747
+ path: rest.join("/"),
2683
2748
  tool
2684
2749
  };
2685
2750
  } else {
@@ -2956,6 +3021,7 @@
2956
3021
  colorMode
2957
3022
  });
2958
3023
  document.documentElement.setAttribute("data-color-mode", colorMode);
3024
+ document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, resolveColorMode(colorMode));
2959
3025
  updateColorMode(colorMode);
2960
3026
  }
2961
3027
  }), /*#__PURE__*/React.createElement(ColorModeIcon, {
@@ -4212,11 +4278,11 @@
4212
4278
  return iframeSrc;
4213
4279
  }
4214
4280
  function encodeQueryString(path) {
4215
- const [pathPart, queryPart] = path.split('?', 2);
4281
+ const [pathPart, queryPart] = path.split("?", 2);
4216
4282
  return queryPart ? `${pathPart}?${encodeURIComponent(queryPart)}` : pathPart;
4217
4283
  }
4218
4284
  function decodeQueryString(path) {
4219
- const [pathPart, queryPart] = path.split('?', 2);
4285
+ const [pathPart, queryPart] = path.split("?", 2);
4220
4286
  return queryPart ? `${pathPart}?${decodeURIComponent(queryPart)}` : pathPart;
4221
4287
  }
4222
4288
 
@@ -4390,7 +4456,7 @@
4390
4456
  document.body.style.overflow = "hidden";
4391
4457
  window.scrollTo(0, 0);
4392
4458
  } else {
4393
- document.body.style.overflow = "auto";
4459
+ document.body.style.overflow = "";
4394
4460
  }
4395
4461
  }, [open]);
4396
4462
  // Listen for external close requests from store