@trops/dash-core 0.1.117 → 0.1.118

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/index.js CHANGED
@@ -39794,13 +39794,57 @@ var FooterPopover = function FooterPopover(_ref2) {
39794
39794
  onOpenSettings = _ref2.onOpenSettings,
39795
39795
  onSignIn = _ref2.onSignIn,
39796
39796
  onSignOut = _ref2.onSignOut;
39797
+ var buttonRef = React.useRef(null);
39798
+ var _useState = React.useState(false),
39799
+ _useState2 = _slicedToArray(_useState, 2),
39800
+ doNotDisturb = _useState2[0],
39801
+ setDoNotDisturb = _useState2[1];
39797
39802
  var displayName = authStatus === "authenticated" && authProfile ? authProfile.displayName || authProfile.username : "Account";
39803
+
39804
+ // Load initial DND state
39805
+ React.useEffect(function () {
39806
+ var _window$mainApi;
39807
+ var timeout = new Promise(function (_, reject) {
39808
+ return setTimeout(function () {
39809
+ return reject(new Error("timeout"));
39810
+ }, 2000);
39811
+ });
39812
+ var fetch = (_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 || (_window$mainApi = _window$mainApi.notifications) === null || _window$mainApi === void 0 ? void 0 : _window$mainApi.getPreferences();
39813
+ if (fetch) {
39814
+ Promise.race([fetch, timeout]).then(function (prefs) {
39815
+ if (prefs) setDoNotDisturb(prefs.doNotDisturb);
39816
+ })["catch"](function () {});
39817
+ }
39818
+ }, []);
39819
+
39820
+ // Sync when toggled from macOS menu
39821
+ React.useEffect(function () {
39822
+ var _window$mainApi2, _window$mainApi2$onDn;
39823
+ var cleanup = (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.notifications) === null || _window$mainApi2 === void 0 || (_window$mainApi2$onDn = _window$mainApi2.onDndChanged) === null || _window$mainApi2$onDn === void 0 ? void 0 : _window$mainApi2$onDn.call(_window$mainApi2, function (dnd) {
39824
+ setDoNotDisturb(dnd);
39825
+ });
39826
+ return function () {
39827
+ if (cleanup) cleanup();
39828
+ };
39829
+ }, []);
39830
+ function handleToggleDnd() {
39831
+ var _window$mainApi3;
39832
+ var newValue = !doNotDisturb;
39833
+ setDoNotDisturb(newValue);
39834
+ (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.setGlobal({
39835
+ doNotDisturb: newValue
39836
+ })) === null || _window$mainApi3 === void 0 || _window$mainApi3["catch"](function () {});
39837
+ }
39798
39838
  return /*#__PURE__*/jsxRuntime.jsx(react.Popover, {
39799
39839
  className: "relative",
39800
39840
  children: function children(_ref3) {
39801
- var close = _ref3.close;
39841
+ var _rect$left;
39842
+ var open = _ref3.open,
39843
+ close = _ref3.close;
39844
+ var rect = open && buttonRef.current ? buttonRef.current.getBoundingClientRect() : null;
39802
39845
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
39803
39846
  children: [/*#__PURE__*/jsxRuntime.jsxs(react.Popover.Button, {
39847
+ ref: buttonRef,
39804
39848
  className: "flex items-center w-full gap-2 px-3 py-2 rounded-md text-sm opacity-80 hover:opacity-100 transition-colors duration-150 cursor-pointer hover:bg-white/5 focus:outline-none",
39805
39849
  title: collapsed ? displayName : undefined,
39806
39850
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
@@ -39810,15 +39854,28 @@ var FooterPopover = function FooterPopover(_ref2) {
39810
39854
  className: "flex-1 text-left truncate",
39811
39855
  children: displayName
39812
39856
  })]
39813
- }), /*#__PURE__*/jsxRuntime.jsx(react.Transition, {
39857
+ }), /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsxRuntime.jsxs(react.Transition, {
39858
+ show: open,
39814
39859
  enter: "transition ease-out duration-100",
39815
39860
  enterFrom: "transform opacity-0 scale-95",
39816
39861
  enterTo: "transform opacity-100 scale-100",
39817
39862
  leave: "transition ease-in duration-75",
39818
39863
  leaveFrom: "transform opacity-100 scale-100",
39819
39864
  leaveTo: "transform opacity-0 scale-95",
39820
- children: /*#__PURE__*/jsxRuntime.jsx(react.Popover.Panel, {
39821
- className: "absolute bottom-full left-0 mb-2 w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl z-50",
39865
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
39866
+ className: "fixed inset-0",
39867
+ style: {
39868
+ zIndex: 9998
39869
+ },
39870
+ onClick: close
39871
+ }), /*#__PURE__*/jsxRuntime.jsx(react.Popover.Panel, {
39872
+ "static": true,
39873
+ className: "fixed w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl",
39874
+ style: {
39875
+ zIndex: 9999,
39876
+ left: (_rect$left = rect === null || rect === void 0 ? void 0 : rect.left) !== null && _rect$left !== void 0 ? _rect$left : 0,
39877
+ bottom: rect ? window.innerHeight - rect.top + 8 : 0
39878
+ },
39822
39879
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
39823
39880
  className: "p-1.5 space-y-0.5",
39824
39881
  children: [/*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
@@ -39835,6 +39892,11 @@ var FooterPopover = function FooterPopover(_ref2) {
39835
39892
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39836
39893
  close();
39837
39894
  }
39895
+ }), /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
39896
+ icon: doNotDisturb ? "bell-slash" : "bell",
39897
+ label: "Do Not Disturb",
39898
+ onClick: handleToggleDnd,
39899
+ active: doNotDisturb
39838
39900
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
39839
39901
  className: "border-t border-white/10 my-1"
39840
39902
  }), authStatus === "authenticated" ? /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
@@ -39853,8 +39915,8 @@ var FooterPopover = function FooterPopover(_ref2) {
39853
39915
  }
39854
39916
  })]
39855
39917
  })
39856
- })
39857
- })]
39918
+ })]
39919
+ }), document.body)]
39858
39920
  });
39859
39921
  }
39860
39922
  });
@@ -39862,16 +39924,21 @@ var FooterPopover = function FooterPopover(_ref2) {
39862
39924
  var PopoverItem = function PopoverItem(_ref4) {
39863
39925
  var icon = _ref4.icon,
39864
39926
  label = _ref4.label,
39865
- onClick = _ref4.onClick;
39927
+ onClick = _ref4.onClick,
39928
+ _ref4$active = _ref4.active,
39929
+ active = _ref4$active === void 0 ? false : _ref4$active;
39866
39930
  return /*#__PURE__*/jsxRuntime.jsxs("button", {
39867
39931
  type: "button",
39868
39932
  onClick: onClick,
39869
- className: "flex items-center w-full gap-2 px-3 py-2 rounded-md text-sm text-white/80 hover:text-white hover:bg-white/10 transition-colors duration-150 cursor-pointer",
39933
+ className: "flex items-center w-full gap-2 px-3 py-2 rounded-md text-sm ".concat(active ? "text-white bg-white/10" : "text-white/80 hover:text-white hover:bg-white/10", " transition-colors duration-150 cursor-pointer"),
39870
39934
  children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
39871
39935
  icon: icon,
39872
39936
  className: "h-3.5 w-3.5 flex-shrink-0"
39873
39937
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
39938
+ className: "flex-1 text-left",
39874
39939
  children: label
39940
+ }), active && /*#__PURE__*/jsxRuntime.jsx("span", {
39941
+ className: "h-1.5 w-1.5 rounded-full bg-amber-400 flex-shrink-0"
39875
39942
  })]
39876
39943
  });
39877
39944
  };