@trops/dash-core 0.1.117 → 0.1.119

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.esm.js CHANGED
@@ -25,6 +25,7 @@ import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
25
25
  import _inherits from '@babel/runtime/helpers/inherits';
26
26
  import colors from 'tailwindcss/colors';
27
27
  import * as ReactDOM from 'react-dom';
28
+ import { createPortal } from 'react-dom';
28
29
  import { findIconDefinition } from '@fortawesome/fontawesome-svg-core';
29
30
  import algoliasearch from 'algoliasearch';
30
31
  import { InstantSearch, Hits } from 'react-instantsearch-hooks-web';
@@ -19170,7 +19171,8 @@ var WidgetRenderer = function WidgetRenderer(_ref) {
19170
19171
  var uuidString = getUUID(params.uuid);
19171
19172
  var widgetData = _objectSpread$m(_objectSpread$m({}, params), {}, {
19172
19173
  uuidString: uuidString,
19173
- providers: (config === null || config === void 0 ? void 0 : config.providers) || []
19174
+ providers: (config === null || config === void 0 ? void 0 : config.providers) || [],
19175
+ notifications: (config === null || config === void 0 ? void 0 : config.notifications) || []
19174
19176
  });
19175
19177
 
19176
19178
  // need to set the electron api here.
@@ -25130,6 +25132,7 @@ var ComponentManager = {
25130
25132
  events: "events" in c ? c["events"] : [],
25131
25133
  eventHandlers: "eventHandlers" in c ? c["eventHandlers"] : [],
25132
25134
  providers: "providers" in c ? c["providers"] : [],
25135
+ notifications: "notifications" in c ? c["notifications"] : [],
25133
25136
  icon: "icon" in c ? c["icon"] : null
25134
25137
  };
25135
25138
  }
@@ -39775,13 +39778,57 @@ var FooterPopover = function FooterPopover(_ref2) {
39775
39778
  onOpenSettings = _ref2.onOpenSettings,
39776
39779
  onSignIn = _ref2.onSignIn,
39777
39780
  onSignOut = _ref2.onSignOut;
39781
+ var buttonRef = useRef(null);
39782
+ var _useState = useState(false),
39783
+ _useState2 = _slicedToArray(_useState, 2),
39784
+ doNotDisturb = _useState2[0],
39785
+ setDoNotDisturb = _useState2[1];
39778
39786
  var displayName = authStatus === "authenticated" && authProfile ? authProfile.displayName || authProfile.username : "Account";
39787
+
39788
+ // Load initial DND state
39789
+ useEffect(function () {
39790
+ var _window$mainApi;
39791
+ var timeout = new Promise(function (_, reject) {
39792
+ return setTimeout(function () {
39793
+ return reject(new Error("timeout"));
39794
+ }, 2000);
39795
+ });
39796
+ 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();
39797
+ if (fetch) {
39798
+ Promise.race([fetch, timeout]).then(function (prefs) {
39799
+ if (prefs) setDoNotDisturb(prefs.doNotDisturb);
39800
+ })["catch"](function () {});
39801
+ }
39802
+ }, []);
39803
+
39804
+ // Sync when toggled from macOS menu
39805
+ useEffect(function () {
39806
+ var _window$mainApi2, _window$mainApi2$onDn;
39807
+ 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) {
39808
+ setDoNotDisturb(dnd);
39809
+ });
39810
+ return function () {
39811
+ if (cleanup) cleanup();
39812
+ };
39813
+ }, []);
39814
+ function handleToggleDnd() {
39815
+ var _window$mainApi3;
39816
+ var newValue = !doNotDisturb;
39817
+ setDoNotDisturb(newValue);
39818
+ (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.setGlobal({
39819
+ doNotDisturb: newValue
39820
+ })) === null || _window$mainApi3 === void 0 || _window$mainApi3["catch"](function () {});
39821
+ }
39779
39822
  return /*#__PURE__*/jsx(Popover, {
39780
39823
  className: "relative",
39781
39824
  children: function children(_ref3) {
39782
- var close = _ref3.close;
39825
+ var _rect$left;
39826
+ var open = _ref3.open,
39827
+ close = _ref3.close;
39828
+ var rect = open && buttonRef.current ? buttonRef.current.getBoundingClientRect() : null;
39783
39829
  return /*#__PURE__*/jsxs(Fragment, {
39784
39830
  children: [/*#__PURE__*/jsxs(Popover.Button, {
39831
+ ref: buttonRef,
39785
39832
  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",
39786
39833
  title: collapsed ? displayName : undefined,
39787
39834
  children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
@@ -39791,15 +39838,28 @@ var FooterPopover = function FooterPopover(_ref2) {
39791
39838
  className: "flex-1 text-left truncate",
39792
39839
  children: displayName
39793
39840
  })]
39794
- }), /*#__PURE__*/jsx(Transition, {
39841
+ }), /*#__PURE__*/createPortal(/*#__PURE__*/jsxs(Transition, {
39842
+ show: open,
39795
39843
  enter: "transition ease-out duration-100",
39796
39844
  enterFrom: "transform opacity-0 scale-95",
39797
39845
  enterTo: "transform opacity-100 scale-100",
39798
39846
  leave: "transition ease-in duration-75",
39799
39847
  leaveFrom: "transform opacity-100 scale-100",
39800
39848
  leaveTo: "transform opacity-0 scale-95",
39801
- children: /*#__PURE__*/jsx(Popover.Panel, {
39802
- className: "absolute bottom-full left-0 mb-2 w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl z-50",
39849
+ children: [/*#__PURE__*/jsx("div", {
39850
+ className: "fixed inset-0",
39851
+ style: {
39852
+ zIndex: 9998
39853
+ },
39854
+ onClick: close
39855
+ }), /*#__PURE__*/jsx(Popover.Panel, {
39856
+ "static": true,
39857
+ className: "fixed w-52 rounded-lg border border-white/10 bg-neutral-900 shadow-xl",
39858
+ style: {
39859
+ zIndex: 9999,
39860
+ left: (_rect$left = rect === null || rect === void 0 ? void 0 : rect.left) !== null && _rect$left !== void 0 ? _rect$left : 0,
39861
+ bottom: rect ? window.innerHeight - rect.top + 8 : 0
39862
+ },
39803
39863
  children: /*#__PURE__*/jsxs("div", {
39804
39864
  className: "p-1.5 space-y-0.5",
39805
39865
  children: [/*#__PURE__*/jsx(PopoverItem, {
@@ -39816,6 +39876,11 @@ var FooterPopover = function FooterPopover(_ref2) {
39816
39876
  changeThemeVariant(themeVariant === "dark" ? "light" : "dark");
39817
39877
  close();
39818
39878
  }
39879
+ }), /*#__PURE__*/jsx(PopoverItem, {
39880
+ icon: doNotDisturb ? "bell-slash" : "bell",
39881
+ label: "Do Not Disturb",
39882
+ onClick: handleToggleDnd,
39883
+ active: doNotDisturb
39819
39884
  }), /*#__PURE__*/jsx("div", {
39820
39885
  className: "border-t border-white/10 my-1"
39821
39886
  }), authStatus === "authenticated" ? /*#__PURE__*/jsx(PopoverItem, {
@@ -39834,8 +39899,8 @@ var FooterPopover = function FooterPopover(_ref2) {
39834
39899
  }
39835
39900
  })]
39836
39901
  })
39837
- })
39838
- })]
39902
+ })]
39903
+ }), document.body)]
39839
39904
  });
39840
39905
  }
39841
39906
  });
@@ -39843,16 +39908,21 @@ var FooterPopover = function FooterPopover(_ref2) {
39843
39908
  var PopoverItem = function PopoverItem(_ref4) {
39844
39909
  var icon = _ref4.icon,
39845
39910
  label = _ref4.label,
39846
- onClick = _ref4.onClick;
39911
+ onClick = _ref4.onClick,
39912
+ _ref4$active = _ref4.active,
39913
+ active = _ref4$active === void 0 ? false : _ref4$active;
39847
39914
  return /*#__PURE__*/jsxs("button", {
39848
39915
  type: "button",
39849
39916
  onClick: onClick,
39850
- 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",
39917
+ 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"),
39851
39918
  children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
39852
39919
  icon: icon,
39853
39920
  className: "h-3.5 w-3.5 flex-shrink-0"
39854
39921
  }), /*#__PURE__*/jsx("span", {
39922
+ className: "flex-1 text-left",
39855
39923
  children: label
39924
+ }), active && /*#__PURE__*/jsx("span", {
39925
+ className: "h-1.5 w-1.5 rounded-full bg-amber-400 flex-shrink-0"
39856
39926
  })]
39857
39927
  });
39858
39928
  };