@bigbinary/neeto-molecules 5.3.27 → 5.3.29

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.
@@ -0,0 +1,105 @@
1
+ import { t } from 'i18next';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import { useState, useEffect } from 'react';
4
+
5
+ var MY_ORGANIZATION_URL = "/auth/organization/edit";
6
+ var BILLING_URL = "/auth/admin_billing";
7
+ var DELETE_WORKSPACE_URL = "/auth/organization/delete";
8
+ var ENGAGE_WIDGET_TRIGGER_ID = "neetoengage-trigger";
9
+ var DEFAULT_MENU_LINK_PROPS = {
10
+ engageProps: {
11
+ id: ENGAGE_WIDGET_TRIGGER_ID,
12
+ label: t("neetoMolecules.sidebar.helpLinks.whatsNew"),
13
+ "data-testid": "help-link-engage-button"
14
+ },
15
+ keyboardShortcutProps: {
16
+ label: t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
17
+ "data-testid": "help-link-keyboard-shortcut-button"
18
+ }
19
+ };
20
+
21
+ // Theme switcher
22
+ var APP_THEME_LOCALSTORAGE_KEY = "appTheme";
23
+ var THEMES = {
24
+ LIGHT: "light",
25
+ DARK: "dark"
26
+ };
27
+
28
+ // Legacy neetoUI theme classes — kept until full migration is complete.
29
+ var LEGACY_THEMES = {
30
+ LIGHT: "neeto-ui-theme--light",
31
+ DARK: "neeto-ui-theme--dark"
32
+ };
33
+ var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
34
+ var MENU_ITEM_CLASSES = "gap-2.5 px-2.5 py-2 font-medium [&>[data-slot=menu-item-prefix]>svg]:!size-[18px] [&>[data-slot=menu-item-suffix]>svg]:!size-[18px]";
35
+ var THEME_BUTTON_BASE = "relative z-10 flex items-center justify-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none";
36
+ var THEME_ICON_BASE = "transition-transform duration-300 ease-out";
37
+
38
+ // Shared source of truth for the neetoEngage changelog unread count.
39
+ //
40
+ // The widget reports the count by calling `window.Nv.onReceiveData({ unreadCount })`
41
+ // whenever it changes (on load and each time entries are marked read). Opening
42
+ // the widget doesn't clear it: the count only drops as entries are read. Both the FloatingActionMenu and the
43
+ // Sidebar surface this count, so this module installs a SINGLE set of
44
+ // `window.Nv` handlers (chaining onto any pre-existing ones) and fans the value
45
+ // out to every subscribed component. Installation happens on the first
46
+ // subscriber and is torn down only when the last one unsubscribes — so
47
+ // interleaved mount/unmount of the two surfaces can never leave a stale handler
48
+ // on the global object.
49
+
50
+ var currentCount = null;
51
+ var subscribers = new Set();
52
+ var isInstalled = false;
53
+ var previousOnReceiveData;
54
+ var notify = function notify() {
55
+ return subscribers.forEach(function (setCount) {
56
+ return setCount(currentCount);
57
+ });
58
+ };
59
+ var install = function install() {
60
+ if (isInstalled) return;
61
+ isInstalled = true;
62
+ var existing = window.Nv || {};
63
+ previousOnReceiveData = existing.onReceiveData;
64
+ window.Nv = Object.assign(existing, {
65
+ onReceiveData: function onReceiveData(data) {
66
+ var _previousOnReceiveDat;
67
+ (_previousOnReceiveDat = previousOnReceiveData) === null || _previousOnReceiveDat === void 0 || _previousOnReceiveDat(data);
68
+ // Only react to a numeric unreadCount; `0` clears the badge (a non-zero
69
+ // count would otherwise stay stale until the pane is opened).
70
+ if (typeof (data === null || data === void 0 ? void 0 : data.unreadCount) === "number") {
71
+ currentCount = data.unreadCount || null;
72
+ notify();
73
+ }
74
+ }
75
+ });
76
+ };
77
+ var uninstall = function uninstall() {
78
+ if (!isInstalled) return;
79
+ isInstalled = false;
80
+ if (window.Nv) {
81
+ window.Nv.onReceiveData = previousOnReceiveData;
82
+ }
83
+ // currentCount is kept: the widget only reports it on page load and after a
84
+ // "Mark as read", so a surface that remounts (e.g. after navigating to a page
85
+ // without a sidebar and back) would otherwise lose it until a full reload.
86
+ };
87
+ var useWhatsNewChangesCount = function useWhatsNewChangesCount() {
88
+ var _useState = useState(currentCount),
89
+ _useState2 = _slicedToArray(_useState, 2),
90
+ changesCount = _useState2[0],
91
+ setChangesCount = _useState2[1];
92
+ useEffect(function () {
93
+ install();
94
+ subscribers.add(setChangesCount);
95
+ setChangesCount(currentCount);
96
+ return function () {
97
+ subscribers["delete"](setChangesCount);
98
+ if (subscribers.size === 0) uninstall();
99
+ };
100
+ }, []);
101
+ return changesCount;
102
+ };
103
+
104
+ export { APP_THEME_LOCALSTORAGE_KEY as A, BILLING_URL as B, DELETE_WORKSPACE_URL as D, ENGAGE_WIDGET_TRIGGER_ID as E, LEGACY_THEMES as L, MENU_ITEM_CLASSES as M, NEETO_AUTH_BILLING_INFO_URL as N, THEMES as T, THEME_ICON_BASE as a, THEME_BUTTON_BASE as b, MY_ORGANIZATION_URL as c, DEFAULT_MENU_LINK_PROPS as d, useWhatsNewChangesCount as u };
105
+ //# sourceMappingURL=useWhatsNewChangesCount-DLIMw7dA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWhatsNewChangesCount-DLIMw7dA.js","sources":["../src/v2/components/FloatingActionMenu/constants.js","../src/v2/components/FloatingActionMenu/hooks/useWhatsNewChangesCount.js"],"sourcesContent":["import { t } from \"i18next\";\n\nexport const MY_ORGANIZATION_URL = \"/auth/organization/edit\";\nexport const BILLING_URL = \"/auth/admin_billing\";\nexport const DELETE_WORKSPACE_URL = \"/auth/organization/delete\";\nexport const ENGAGE_WIDGET_TRIGGER_ID = \"neetoengage-trigger\";\n\nexport const DEFAULT_MENU_LINK_PROPS = {\n engageProps: {\n id: ENGAGE_WIDGET_TRIGGER_ID,\n label: t(\"neetoMolecules.sidebar.helpLinks.whatsNew\"),\n \"data-testid\": \"help-link-engage-button\",\n },\n keyboardShortcutProps: {\n label: t(\"neetoMolecules.sidebar.helpLinks.keyboardShortcuts\"),\n \"data-testid\": \"help-link-keyboard-shortcut-button\",\n },\n};\n\n// Theme switcher\nexport const APP_THEME_LOCALSTORAGE_KEY = \"appTheme\";\n\nexport const THEMES = { LIGHT: \"light\", DARK: \"dark\" };\n\n// Legacy neetoUI theme classes — kept until full migration is complete.\nexport const LEGACY_THEMES = {\n LIGHT: \"neeto-ui-theme--light\",\n DARK: \"neeto-ui-theme--dark\",\n};\n\nexport const NEETO_AUTH_BILLING_INFO_URL =\n \"/neeto_sso/api/v1/subscription/billing\";\n\nexport const MENU_ITEM_CLASSES =\n \"gap-2.5 px-2.5 py-2 font-medium [&>[data-slot=menu-item-prefix]>svg]:!size-[18px] [&>[data-slot=menu-item-suffix]>svg]:!size-[18px]\";\n\nexport const THEME_BUTTON_BASE =\n \"relative z-10 flex items-center justify-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none\";\n\nexport const THEME_ICON_BASE = \"transition-transform duration-300 ease-out\";\n","import { useEffect, useState } from \"react\";\n\n// Shared source of truth for the neetoEngage changelog unread count.\n//\n// The widget reports the count by calling `window.Nv.onReceiveData({ unreadCount })`\n// whenever it changes (on load and each time entries are marked read). Opening\n// the widget doesn't clear it: the count only drops as entries are read. Both the FloatingActionMenu and the\n// Sidebar surface this count, so this module installs a SINGLE set of\n// `window.Nv` handlers (chaining onto any pre-existing ones) and fans the value\n// out to every subscribed component. Installation happens on the first\n// subscriber and is torn down only when the last one unsubscribes — so\n// interleaved mount/unmount of the two surfaces can never leave a stale handler\n// on the global object.\n\nlet currentCount = null;\nconst subscribers = new Set();\nlet isInstalled = false;\nlet previousOnReceiveData;\n\nconst notify = () => subscribers.forEach(setCount => setCount(currentCount));\n\nconst install = () => {\n if (isInstalled) return;\n isInstalled = true;\n\n const existing = window.Nv || {};\n previousOnReceiveData = existing.onReceiveData;\n\n window.Nv = Object.assign(existing, {\n onReceiveData: data => {\n previousOnReceiveData?.(data);\n // Only react to a numeric unreadCount; `0` clears the badge (a non-zero\n // count would otherwise stay stale until the pane is opened).\n if (typeof data?.unreadCount === \"number\") {\n currentCount = data.unreadCount || null;\n notify();\n }\n },\n });\n};\n\nconst uninstall = () => {\n if (!isInstalled) return;\n isInstalled = false;\n\n if (window.Nv) {\n window.Nv.onReceiveData = previousOnReceiveData;\n }\n // currentCount is kept: the widget only reports it on page load and after a\n // \"Mark as read\", so a surface that remounts (e.g. after navigating to a page\n // without a sidebar and back) would otherwise lose it until a full reload.\n};\n\nconst useWhatsNewChangesCount = () => {\n const [changesCount, setChangesCount] = useState(currentCount);\n\n useEffect(() => {\n install();\n subscribers.add(setChangesCount);\n setChangesCount(currentCount);\n\n return () => {\n subscribers.delete(setChangesCount);\n if (subscribers.size === 0) uninstall();\n };\n }, []);\n\n return changesCount;\n};\n\nexport default useWhatsNewChangesCount;\n"],"names":["MY_ORGANIZATION_URL","BILLING_URL","DELETE_WORKSPACE_URL","ENGAGE_WIDGET_TRIGGER_ID","DEFAULT_MENU_LINK_PROPS","engageProps","id","label","t","keyboardShortcutProps","APP_THEME_LOCALSTORAGE_KEY","THEMES","LIGHT","DARK","LEGACY_THEMES","NEETO_AUTH_BILLING_INFO_URL","MENU_ITEM_CLASSES","THEME_BUTTON_BASE","THEME_ICON_BASE","currentCount","subscribers","Set","isInstalled","previousOnReceiveData","notify","forEach","setCount","install","existing","window","Nv","onReceiveData","Object","assign","data","_previousOnReceiveDat","unreadCount","uninstall","useWhatsNewChangesCount","_useState","useState","_useState2","_slicedToArray","changesCount","setChangesCount","useEffect","add","size"],"mappings":";;;;AAEO,IAAMA,mBAAmB,GAAG;AAC5B,IAAMC,WAAW,GAAG;AACpB,IAAMC,oBAAoB,GAAG;AAC7B,IAAMC,wBAAwB,GAAG;AAEjC,IAAMC,uBAAuB,GAAG;AACrCC,EAAAA,WAAW,EAAE;AACXC,IAAAA,EAAE,EAAEH,wBAAwB;AAC5BI,IAAAA,KAAK,EAAEC,CAAC,CAAC,2CAA2C,CAAC;AACrD,IAAA,aAAa,EAAE;GAChB;AACDC,EAAAA,qBAAqB,EAAE;AACrBF,IAAAA,KAAK,EAAEC,CAAC,CAAC,oDAAoD,CAAC;AAC9D,IAAA,aAAa,EAAE;AACjB;AACF;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A,IAAJA,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJA,IAAI,CAAEE,WAAW,CAAA,KAAK,QAAQ,EAAE;AACzCjB,QAAAA,YAAY,GAAGe,IAAI,CAACE,WAAW,IAAI,IAAI;AACvCZ,QAAAA,MAAM,EAAE;AACV,MAAA;AACF,IAAA;AACF,GAAC,CAAC;AACJ,CAAC;AAED,IAAMa,SAAS,GAAG,SAAZA,SAASA,GAAS;EACtB,IAAI,CAACf,WAAW,EAAE;AAClBA,EAAAA,WAAW,GAAG,KAAK;EAEnB,IAAIO,MAAM,CAACC,EAAE,EAAE;AACbD,IAAAA,MAAM,CAACC,EAAE,CAACC,aAAa,GAAGR,qBAAqB;AACjD,EAAA;AACA;AACA;AACA;AACF,CAAC;AAED,IAAMe,uBAAuB,GAAG,SAA1BA,uBAAuBA,GAAS;AACpC,EAAA,IAAAC,SAAA,GAAwCC,QAAQ,CAACrB,YAAY,CAAC;IAAAsB,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAvDI,IAAAA,YAAY,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,eAAe,GAAAH,UAAA,CAAA,CAAA,CAAA;AAEpCI,EAAAA,SAAS,CAAC,YAAM;AACdlB,IAAAA,OAAO,EAAE;AACTP,IAAAA,WAAW,CAAC0B,GAAG,CAACF,eAAe,CAAC;IAChCA,eAAe,CAACzB,YAAY,CAAC;AAE7B,IAAA,OAAO,YAAM;MACXC,WAAW,CAAA,QAAA,CAAO,CAACwB,eAAe,CAAC;MACnC,IAAIxB,WAAW,CAAC2B,IAAI,KAAK,CAAC,EAAEV,SAAS,EAAE;IACzC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;AAEN,EAAA,OAAOM,YAAY;AACrB;;;;"}
@@ -23,12 +23,13 @@ import axios from 'axios';
23
23
  import { S as Search } from '../search-H0uYy0W-.js';
24
24
  import { g as getNeetoUrl, a as getProductBillingUrl } from '../urls-DC61u0b2.js';
25
25
  import useBreakpoints from '@bigbinary/neeto-commons-frontend/v2/react-utils/useBreakpoints';
26
- import { t } from 'i18next';
26
+ import { M as MENU_ITEM_CLASSES, D as DELETE_WORKSPACE_URL, A as APP_THEME_LOCALSTORAGE_KEY, T as THEMES, L as LEGACY_THEMES, a as THEME_ICON_BASE, b as THEME_BUTTON_BASE, c as MY_ORGANIZATION_URL, B as BILLING_URL, N as NEETO_AUTH_BILLING_INFO_URL, u as useWhatsNewChangesCount, d as DEFAULT_MENU_LINK_PROPS } from '../useWhatsNewChangesCount-DLIMw7dA.js';
27
27
  import { c as createLucideIcon } from '../createLucideIcon--oLqczpc.js';
28
28
  import { C as CircleQuestionMark } from '../circle-question-mark-B807GLZf.js';
29
29
  import { C as ChevronRight } from '../chevron-right-CEsVcNLw.js';
30
30
  import { U as User } from '../user-Dhw9zdMR.js';
31
31
  import useLocalStorage from '@bigbinary/neeto-commons-frontend/v2/react-utils/useLocalStorage';
32
+ import { t } from 'i18next';
32
33
  import { getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/v2/utils';
33
34
  import { resetAuthTokens } from '@bigbinary/neeto-commons-frontend/v2/utils/axios';
34
35
  import { removeFromLocalStorage } from '@bigbinary/neeto-commons-frontend/v2/utils/general';
@@ -552,39 +553,6 @@ var Modal = withT(function (_ref) {
552
553
  });
553
554
  });
554
555
 
555
- var MY_ORGANIZATION_URL = "/auth/organization/edit";
556
- var BILLING_URL = "/auth/admin_billing";
557
- var DELETE_WORKSPACE_URL = "/auth/organization/delete";
558
- var ENGAGE_WIDGET_TRIGGER_ID = "neetoengage-trigger";
559
- var DEFAULT_MENU_LINK_PROPS = {
560
- engageProps: {
561
- id: ENGAGE_WIDGET_TRIGGER_ID,
562
- label: t("neetoMolecules.sidebar.helpLinks.whatsNew"),
563
- "data-testid": "help-link-engage-button"
564
- },
565
- keyboardShortcutProps: {
566
- label: t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
567
- "data-testid": "help-link-keyboard-shortcut-button"
568
- }
569
- };
570
-
571
- // Theme switcher
572
- var APP_THEME_LOCALSTORAGE_KEY = "appTheme";
573
- var THEMES = {
574
- LIGHT: "light",
575
- DARK: "dark"
576
- };
577
-
578
- // Legacy neetoUI theme classes — kept until full migration is complete.
579
- var LEGACY_THEMES = {
580
- LIGHT: "neeto-ui-theme--light",
581
- DARK: "neeto-ui-theme--dark"
582
- };
583
- var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
584
- var MENU_ITEM_CLASSES = "gap-2.5 px-2.5 py-2 font-medium [&>[data-slot=menu-item-prefix]>svg]:!size-[18px] [&>[data-slot=menu-item-suffix]>svg]:!size-[18px]";
585
- var THEME_BUTTON_BASE = "relative z-10 flex items-center justify-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none";
586
- var THEME_ICON_BASE = "transition-transform duration-300 ease-out";
587
-
588
556
  var _excluded$2 = ["className"];
589
557
  function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
590
558
  function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -1441,10 +1409,7 @@ var ProfileButton = function ProfileButton(_ref) {
1441
1409
  _useState6 = _slicedToArray(_useState5, 2),
1442
1410
  isMenuOpen = _useState6[0],
1443
1411
  setIsMenuOpen = _useState6[1];
1444
- var _useState7 = useState(null),
1445
- _useState8 = _slicedToArray(_useState7, 2),
1446
- changesCount = _useState8[0],
1447
- setChangesCount = _useState8[1];
1412
+ var changesCount = useWhatsNewChangesCount();
1448
1413
  var _KeyboardShortcuts$us = KeyboardShortcuts.usePaneState(),
1449
1414
  _KeyboardShortcuts$us2 = _slicedToArray(_KeyboardShortcuts$us, 2),
1450
1415
  setIsOpen = _KeyboardShortcuts$us2[1];
@@ -1454,18 +1419,6 @@ var ProfileButton = function ProfileButton(_ref) {
1454
1419
  mode: "global"
1455
1420
  });
1456
1421
  var profileInfo = getProfileInfo(profileInfoOverrides, isConsumer);
1457
- useEffect(function () {
1458
- var Nv = {
1459
- onReceiveData: function onReceiveData(data) {
1460
- if (!data.unreadCount) return;
1461
- setChangesCount(data.unreadCount);
1462
- },
1463
- onShow: function onShow() {
1464
- setChangesCount(null);
1465
- }
1466
- };
1467
- window.Nv = window.Nv ? Object.assign(window.Nv, Nv) : Nv;
1468
- }, []);
1469
1422
  var newBottomLinks = [].concat(_toConsumableArray(getDefaultBottomLinks(profileInfo.isAuthenticated, isConsumer)), _toConsumableArray(bottomLinks));
1470
1423
  var defaultLinks = Object.keys(DEFAULT_MENU_LINK_PROPS).map(function (key) {
1471
1424
  return _objectSpread$1(_objectSpread$1(_objectSpread$1({}, DEFAULT_MENU_LINK_PROPS[key]), key === "keyboardShortcutProps" && {