@bigbinary/neeto-molecules 5.3.27 → 5.3.28

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,101 @@
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 DELETE_WORKSPACE_URL = "/auth/organization/delete";
7
+ var ENGAGE_WIDGET_TRIGGER_ID = "neetoengage-trigger";
8
+ var DEFAULT_MENU_LINK_PROPS = {
9
+ engageProps: {
10
+ id: ENGAGE_WIDGET_TRIGGER_ID,
11
+ label: t("neetoMolecules.sidebar.helpLinks.whatsNew"),
12
+ "data-testid": "help-link-engage-button"
13
+ },
14
+ keyboardShortcutProps: {
15
+ label: t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
16
+ "data-testid": "help-link-keyboard-shortcut-button"
17
+ }
18
+ };
19
+
20
+ // Theme switcher
21
+ var APP_THEME_LOCALSTORAGE_KEY = "appTheme";
22
+ var THEMES = {
23
+ LIGHT: "neeto-ui-theme--light",
24
+ DARK: "neeto-ui-theme--dark"
25
+ };
26
+ var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
27
+
28
+ // Shared source of truth for the neetoEngage changelog unread count.
29
+ //
30
+ // The widget reports the count by calling `window.Nv.onReceiveData({ unreadCount })`
31
+ // and clears it via `window.Nv.onShow()`. Both the FloatingActionMenu and the
32
+ // Sidebar surface this count, so this module installs a SINGLE set of
33
+ // `window.Nv` handlers (chaining onto any pre-existing ones) and fans the value
34
+ // out to every subscribed component. Installation happens on the first
35
+ // subscriber and is torn down only when the last one unsubscribes — so
36
+ // interleaved mount/unmount of the two surfaces can never leave a stale handler
37
+ // on the global object.
38
+
39
+ var currentCount = null;
40
+ var subscribers = new Set();
41
+ var isInstalled = false;
42
+ var previousOnReceiveData;
43
+ var previousOnShow;
44
+ var notify = function notify() {
45
+ return subscribers.forEach(function (setCount) {
46
+ return setCount(currentCount);
47
+ });
48
+ };
49
+ var install = function install() {
50
+ if (isInstalled) return;
51
+ isInstalled = true;
52
+ var existing = window.Nv || {};
53
+ previousOnReceiveData = existing.onReceiveData;
54
+ previousOnShow = existing.onShow;
55
+ window.Nv = Object.assign(existing, {
56
+ onReceiveData: function onReceiveData(data) {
57
+ var _previousOnReceiveDat;
58
+ (_previousOnReceiveDat = previousOnReceiveData) === null || _previousOnReceiveDat === void 0 || _previousOnReceiveDat(data);
59
+ // Only react to a numeric unreadCount; `0` clears the badge (a non-zero
60
+ // count would otherwise stay stale until the pane is opened).
61
+ if (typeof (data === null || data === void 0 ? void 0 : data.unreadCount) === "number") {
62
+ currentCount = data.unreadCount || null;
63
+ notify();
64
+ }
65
+ },
66
+ onShow: function onShow() {
67
+ var _previousOnShow;
68
+ (_previousOnShow = previousOnShow) === null || _previousOnShow === void 0 || _previousOnShow();
69
+ currentCount = null;
70
+ notify();
71
+ }
72
+ });
73
+ };
74
+ var uninstall = function uninstall() {
75
+ if (!isInstalled) return;
76
+ isInstalled = false;
77
+ if (window.Nv) {
78
+ window.Nv.onReceiveData = previousOnReceiveData;
79
+ window.Nv.onShow = previousOnShow;
80
+ }
81
+ currentCount = null;
82
+ };
83
+ var useWhatsNewChangesCount = function useWhatsNewChangesCount() {
84
+ var _useState = useState(currentCount),
85
+ _useState2 = _slicedToArray(_useState, 2),
86
+ changesCount = _useState2[0],
87
+ setChangesCount = _useState2[1];
88
+ useEffect(function () {
89
+ install();
90
+ subscribers.add(setChangesCount);
91
+ setChangesCount(currentCount);
92
+ return function () {
93
+ subscribers["delete"](setChangesCount);
94
+ if (subscribers.size === 0) uninstall();
95
+ };
96
+ }, []);
97
+ return changesCount;
98
+ };
99
+
100
+ export { APP_THEME_LOCALSTORAGE_KEY as A, DELETE_WORKSPACE_URL as D, ENGAGE_WIDGET_TRIGGER_ID as E, MY_ORGANIZATION_URL as M, NEETO_AUTH_BILLING_INFO_URL as N, THEMES as T, DEFAULT_MENU_LINK_PROPS as a, useWhatsNewChangesCount as u };
101
+ //# sourceMappingURL=useWhatsNewChangesCount-Cy7rXdSf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWhatsNewChangesCount-Cy7rXdSf.js","sources":["../src/components/FloatingActionMenu/constants.js","../src/components/FloatingActionMenu/hooks/useWhatsNewChangesCount.js"],"sourcesContent":["import { t } from \"i18next\";\n\nexport const MY_ORGANIZATION_URL = \"/auth/organization/edit\";\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 = {\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","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// and clears it via `window.Nv.onShow()`. 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;\nlet previousOnShow;\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 previousOnShow = existing.onShow;\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 onShow: () => {\n previousOnShow?.();\n currentCount = null;\n notify();\n },\n });\n};\n\nconst uninstall = () => {\n if (!isInstalled) return;\n isInstalled = false;\n\n if (window.Nv) {\n window.Nv.onReceiveData = previousOnReceiveData;\n window.Nv.onShow = previousOnShow;\n }\n currentCount = null;\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","DELETE_WORKSPACE_URL","ENGAGE_WIDGET_TRIGGER_ID","DEFAULT_MENU_LINK_PROPS","engageProps","id","label","t","keyboardShortcutProps","APP_THEME_LOCALSTORAGE_KEY","THEMES","LIGHT","DARK","NEETO_AUTH_BILLING_INFO_URL","currentCount","subscribers","Set","isInstalled","previousOnReceiveData","previousOnShow","notify","forEach","setCount","install","existing","window","Nv","onReceiveData","onShow","Object","assign","data","_previousOnReceiveDat","unreadCount","_previousOnShow","uninstall","useWhatsNewChangesCount","_useState","useState","_useState2","_slicedToArray","changesCount","setChangesCount","useEffect","add","size"],"mappings":";;;;AAEO,IAAMA,mBAAmB,GAAG;AAC5B,IAAMC,oBAAoB,GAAG;AAC7B,IAAMC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AAA;AAEpCI,EAAAA,SAAS,CAAC,YAAM;AACdpB,IAAAA,OAAO,EAAE;AACTR,IAAAA,WAAW,CAAC6B,GAAG,CAACF,eAAe,CAAC;IAChCA,eAAe,CAAC5B,YAAY,CAAC;AAE7B,IAAA,OAAO,YAAM;MACXC,WAAW,CAAA,QAAA,CAAO,CAAC2B,eAAe,CAAC;MACnC,IAAI3B,WAAW,CAAC8B,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-5ChErwhP.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" && {