@planningcenter/topbar 11.0.1 → 11.0.2
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/topbar.js +75 -20
- package/dist/topbar.js.map +1 -1
- package/dist/topbar.modern.js +76 -21
- package/dist/topbar.modern.js.map +1 -1
- package/dist/topbar.module.js +76 -21
- package/dist/topbar.module.js.map +1 -1
- package/dist/topbar.umd.js +75 -20
- package/dist/topbar.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/topbar.js
CHANGED
|
@@ -699,6 +699,13 @@ const useJoltEffect = (channelSubscription, eventName, callback) => {
|
|
|
699
699
|
};
|
|
700
700
|
|
|
701
701
|
const capitalize = s => s.charAt(0).toUpperCase() + s.slice(1);
|
|
702
|
+
const RESOLVED_COLOR_MODE_ATTRIBUTE = "data-resolved-color-mode";
|
|
703
|
+
function resolveColorMode(colorMode) {
|
|
704
|
+
if (colorMode === "system") {
|
|
705
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
706
|
+
}
|
|
707
|
+
return colorMode;
|
|
708
|
+
}
|
|
702
709
|
const debounce = (func, wait) => {
|
|
703
710
|
let timeout;
|
|
704
711
|
return function (...args) {
|
|
@@ -779,6 +786,58 @@ const useNotificationsHasUnread = ({
|
|
|
779
786
|
return storedValue;
|
|
780
787
|
};
|
|
781
788
|
|
|
789
|
+
function useMediaQuery(query) {
|
|
790
|
+
const getMatches = query => {
|
|
791
|
+
// Prevents SSR issues
|
|
792
|
+
if (typeof window !== "undefined") {
|
|
793
|
+
return window.matchMedia(query).matches;
|
|
794
|
+
}
|
|
795
|
+
return false;
|
|
796
|
+
};
|
|
797
|
+
const [matches, setMatches] = React.useState(getMatches(query));
|
|
798
|
+
function handleChange() {
|
|
799
|
+
setMatches(getMatches(query));
|
|
800
|
+
}
|
|
801
|
+
React.useEffect(() => {
|
|
802
|
+
const matchMedia = window.matchMedia(query);
|
|
803
|
+
// Triggered at the first client-side load and if query changes
|
|
804
|
+
handleChange();
|
|
805
|
+
// Listen matchMedia
|
|
806
|
+
if (matchMedia.addListener) {
|
|
807
|
+
matchMedia.addListener(handleChange);
|
|
808
|
+
} else {
|
|
809
|
+
matchMedia.addEventListener("change", handleChange);
|
|
810
|
+
}
|
|
811
|
+
return () => {
|
|
812
|
+
if (matchMedia.removeListener) {
|
|
813
|
+
matchMedia.removeListener(handleChange);
|
|
814
|
+
} else {
|
|
815
|
+
matchMedia.removeEventListener("change", handleChange);
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
}, [query]);
|
|
819
|
+
return matches;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function createStore(initialState) {
|
|
823
|
+
let currentState = initialState;
|
|
824
|
+
const listeners = new Set();
|
|
825
|
+
return {
|
|
826
|
+
getState: () => currentState,
|
|
827
|
+
setState: newState => {
|
|
828
|
+
currentState = newState;
|
|
829
|
+
listeners.forEach(listener => listener(currentState));
|
|
830
|
+
},
|
|
831
|
+
subscribe: listener => {
|
|
832
|
+
listeners.add(listener);
|
|
833
|
+
return () => listeners.delete(listener);
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
const store$1 = createStore({});
|
|
838
|
+
|
|
839
|
+
const useStore = (selector = state => state) => shim.useSyncExternalStore(store$1.subscribe, () => selector(store$1.getState()));
|
|
840
|
+
|
|
782
841
|
const useTopbarAPI = ({
|
|
783
842
|
configuredFetch,
|
|
784
843
|
env
|
|
@@ -805,23 +864,6 @@ const useTopbarAPI = ({
|
|
|
805
864
|
return resp;
|
|
806
865
|
};
|
|
807
866
|
|
|
808
|
-
function createStore(initialState) {
|
|
809
|
-
let currentState = initialState;
|
|
810
|
-
const listeners = new Set();
|
|
811
|
-
return {
|
|
812
|
-
getState: () => currentState,
|
|
813
|
-
setState: newState => {
|
|
814
|
-
currentState = newState;
|
|
815
|
-
listeners.forEach(listener => listener(currentState));
|
|
816
|
-
},
|
|
817
|
-
subscribe: listener => {
|
|
818
|
-
listeners.add(listener);
|
|
819
|
-
return () => listeners.delete(listener);
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
const store$1 = createStore({});
|
|
824
|
-
|
|
825
867
|
const AppsProvider = ({
|
|
826
868
|
configuredFetch = defaultFetch,
|
|
827
869
|
enableJoltLogging,
|
|
@@ -841,6 +883,10 @@ const AppsProvider = ({
|
|
|
841
883
|
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;
|
|
842
884
|
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);
|
|
843
885
|
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;
|
|
886
|
+
const {
|
|
887
|
+
colorMode: currentColorMode
|
|
888
|
+
} = useStore();
|
|
889
|
+
const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
|
|
844
890
|
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;
|
|
845
891
|
const notificationsEnabled = !window.notificationsDisabled;
|
|
846
892
|
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";
|
|
@@ -892,6 +938,16 @@ const AppsProvider = ({
|
|
|
892
938
|
enabled: true,
|
|
893
939
|
joltChannel: notificationsJoltChannel
|
|
894
940
|
});
|
|
941
|
+
React.useLayoutEffect(() => {
|
|
942
|
+
if (colorMode) {
|
|
943
|
+
document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, resolveColorMode(colorMode));
|
|
944
|
+
}
|
|
945
|
+
}, [colorMode]);
|
|
946
|
+
React.useEffect(() => {
|
|
947
|
+
if (currentColorMode === "system") {
|
|
948
|
+
document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, prefersDark ? "dark" : "light");
|
|
949
|
+
}
|
|
950
|
+
}, [currentColorMode, prefersDark]);
|
|
895
951
|
React.useEffect(() => {
|
|
896
952
|
const state = store$1.getState();
|
|
897
953
|
store$1.setState({
|
|
@@ -2060,8 +2116,6 @@ const useSetCurrentRouteInfo = ({
|
|
|
2060
2116
|
}, [routes, app]);
|
|
2061
2117
|
};
|
|
2062
2118
|
|
|
2063
|
-
const useStore = (selector = state => state) => shim.useSyncExternalStore(store$1.subscribe, () => selector(store$1.getState()));
|
|
2064
|
-
|
|
2065
2119
|
const useUpdateStore = () => React.useCallback(updates => {
|
|
2066
2120
|
const currentState = store$1.getState();
|
|
2067
2121
|
store$1.setState({
|
|
@@ -2969,6 +3023,7 @@ function ColorModeSwitcher() {
|
|
|
2969
3023
|
colorMode
|
|
2970
3024
|
});
|
|
2971
3025
|
document.documentElement.setAttribute("data-color-mode", colorMode);
|
|
3026
|
+
document.documentElement.setAttribute(RESOLVED_COLOR_MODE_ATTRIBUTE, resolveColorMode(colorMode));
|
|
2972
3027
|
updateColorMode(colorMode);
|
|
2973
3028
|
}
|
|
2974
3029
|
}), /*#__PURE__*/React.createElement(ColorModeIcon, {
|
|
@@ -4403,7 +4458,7 @@ function Toolbar({
|
|
|
4403
4458
|
document.body.style.overflow = "hidden";
|
|
4404
4459
|
window.scrollTo(0, 0);
|
|
4405
4460
|
} else {
|
|
4406
|
-
document.body.style.overflow = "
|
|
4461
|
+
document.body.style.overflow = "";
|
|
4407
4462
|
}
|
|
4408
4463
|
}, [open]);
|
|
4409
4464
|
// Listen for external close requests from store
|