@bigbinary/neeto-molecules 5.10.0-beta1 → 5.10.0-beta2

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.
Files changed (65) hide show
  1. package/dist/{Chevron-Dp-3nhLf.js → Chevron-Cx18bD7P.js} +4 -2
  2. package/dist/Chevron-Cx18bD7P.js.map +1 -0
  3. package/dist/ConfigurePageSidebar.js +1 -1
  4. package/dist/{ConfigureView-BT0WxcF4.js → ConfigureView-CA-v13ng.js} +4 -2
  5. package/dist/ConfigureView-CA-v13ng.js.map +1 -0
  6. package/dist/MadeWith.js +2 -2
  7. package/dist/Sidebar.js +1 -1
  8. package/dist/cjs/{Chevron-Drw6ou3f.js → Chevron-DrNdaalo.js} +4 -2
  9. package/dist/cjs/Chevron-DrNdaalo.js.map +1 -0
  10. package/dist/cjs/ConfigurePageSidebar.js +1 -1
  11. package/dist/cjs/{ConfigureView-BU16GgF_.js → ConfigureView-Ckcj7MLm.js} +4 -2
  12. package/dist/cjs/ConfigureView-Ckcj7MLm.js.map +1 -0
  13. package/dist/cjs/MadeWith.js +3 -3
  14. package/dist/cjs/Sidebar.js +1 -1
  15. package/dist/cjs/lock-f3r8WHga.js +20 -0
  16. package/dist/cjs/lock-f3r8WHga.js.map +1 -0
  17. package/dist/cjs/useWhatsNewChangesCount-CAxjl3n7.js +599 -0
  18. package/dist/cjs/useWhatsNewChangesCount-CAxjl3n7.js.map +1 -0
  19. package/dist/cjs/v2/ConfigurePageSidebar.js +1 -1
  20. package/dist/cjs/v2/DocumentEditor.js +60 -11
  21. package/dist/cjs/v2/DocumentEditor.js.map +1 -1
  22. package/dist/cjs/v2/EmailForm.js +3 -2
  23. package/dist/cjs/v2/EmailForm.js.map +1 -1
  24. package/dist/cjs/v2/EmailPreview.js +5 -4
  25. package/dist/cjs/v2/EmailPreview.js.map +1 -1
  26. package/dist/cjs/v2/ErrorPage.js +3 -16
  27. package/dist/cjs/v2/ErrorPage.js.map +1 -1
  28. package/dist/cjs/v2/FloatingActionMenu.js +69 -358
  29. package/dist/cjs/v2/FloatingActionMenu.js.map +1 -1
  30. package/dist/cjs/v2/MadeWith.js +3 -3
  31. package/dist/cjs/v2/ShareViaLink.js +1 -0
  32. package/dist/cjs/v2/ShareViaLink.js.map +1 -1
  33. package/dist/cjs/v2/Sidebar.js +130 -9
  34. package/dist/cjs/v2/Sidebar.js.map +1 -1
  35. package/dist/lock-BFUDkBSb.js +18 -0
  36. package/dist/lock-BFUDkBSb.js.map +1 -0
  37. package/dist/useWhatsNewChangesCount-Do5jWaPy.js +562 -0
  38. package/dist/useWhatsNewChangesCount-Do5jWaPy.js.map +1 -0
  39. package/dist/v2/ConfigurePageSidebar.js +1 -1
  40. package/dist/v2/DocumentEditor.js +61 -12
  41. package/dist/v2/DocumentEditor.js.map +1 -1
  42. package/dist/v2/EmailForm.js +3 -2
  43. package/dist/v2/EmailForm.js.map +1 -1
  44. package/dist/v2/EmailPreview.js +5 -4
  45. package/dist/v2/EmailPreview.js.map +1 -1
  46. package/dist/v2/ErrorPage.js +2 -15
  47. package/dist/v2/ErrorPage.js.map +1 -1
  48. package/dist/v2/FloatingActionMenu.js +73 -343
  49. package/dist/v2/FloatingActionMenu.js.map +1 -1
  50. package/dist/v2/MadeWith.js +2 -2
  51. package/dist/v2/ShareViaLink.js +1 -0
  52. package/dist/v2/ShareViaLink.js.map +1 -1
  53. package/dist/v2/Sidebar.js +132 -11
  54. package/dist/v2/Sidebar.js.map +1 -1
  55. package/package.json +1 -1
  56. package/src/translations/en.json +4 -0
  57. package/types/v2/Sidebar.d.ts +2 -0
  58. package/dist/Chevron-Dp-3nhLf.js.map +0 -1
  59. package/dist/ConfigureView-BT0WxcF4.js.map +0 -1
  60. package/dist/cjs/Chevron-Drw6ou3f.js.map +0 -1
  61. package/dist/cjs/ConfigureView-BU16GgF_.js.map +0 -1
  62. package/dist/cjs/useWhatsNewChangesCount-BVkLLk7f.js +0 -121
  63. package/dist/cjs/useWhatsNewChangesCount-BVkLLk7f.js.map +0 -1
  64. package/dist/useWhatsNewChangesCount-CQxhUCpt.js +0 -106
  65. package/dist/useWhatsNewChangesCount-CQxhUCpt.js.map +0 -1
@@ -0,0 +1,599 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var useHotkeys = require('@bigbinary/neeto-hotkeys');
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
+ var neetoAtoms = require('@bigbinary/neeto-atoms');
8
+ var reactI18next = require('react-i18next');
9
+ var neetoCist = require('@bigbinary/neeto-cist');
10
+ var ramda = require('ramda');
11
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
12
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
13
+ var reactQuery = require('@tanstack/react-query');
14
+ var initializers = require('@bigbinary/neeto-commons-frontend/v2/initializers');
15
+ var axios = require('axios');
16
+ var classnames = require('classnames');
17
+ var Neeto = require('@bigbinary/neeto-icons/logos/Neeto');
18
+ var Logos = require('@bigbinary/neeto-icons/logos');
19
+ var jsxRuntime = require('react/jsx-runtime');
20
+ var lock$1 = require('./lock-f3r8WHga.js');
21
+ var search = require('./search-DoXqXFel.js');
22
+ var x = require('./x-B2CPkf_D.js');
23
+ var createLucideIcon = require('./createLucideIcon-BbuuRL2u.js');
24
+ var i18next = require('i18next');
25
+
26
+ function _interopNamespaceDefault(e) {
27
+ var n = Object.create(null);
28
+ if (e) {
29
+ Object.keys(e).forEach(function (k) {
30
+ if (k !== 'default') {
31
+ var d = Object.getOwnPropertyDescriptor(e, k);
32
+ Object.defineProperty(n, k, d.get ? d : {
33
+ enumerable: true,
34
+ get: function () { return e[k]; }
35
+ });
36
+ }
37
+ });
38
+ }
39
+ n.default = e;
40
+ return Object.freeze(n);
41
+ }
42
+
43
+ var Logos__namespace = /*#__PURE__*/_interopNamespaceDefault(Logos);
44
+
45
+ /**
46
+ * @license lucide-react v1.24.0 - ISC
47
+ *
48
+ * This source code is licensed under the ISC license.
49
+ * See the LICENSE file in the root directory of this source tree.
50
+ */
51
+
52
+
53
+ const __iconNode = [
54
+ ["path", { d: "m13.5 8.5-5 5", key: "1cs55j" }],
55
+ ["path", { d: "m8.5 8.5 5 5", key: "a8mexj" }],
56
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
57
+ ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
58
+ ];
59
+ const SearchX = createLucideIcon.createLucideIcon("search-x", __iconNode);
60
+
61
+ var QUERY_KEYS = {
62
+ NEETO_APPS_LIST: "neeto-apps-list"
63
+ };
64
+ var SPECIAL_APP_NAMES = {
65
+ bugwatch: "BugWatch"
66
+ };
67
+
68
+ // How long the "no access" notice stays before auto-dismissing (ms).
69
+ var NO_ACCESS_NOTICE_DURATION = 10000;
70
+
71
+ // Decides which switcher ctrl/⌘+u opens when more than one is mounted (the
72
+ // sidebar switcher vs the floating action menu one). Higher wins, so the
73
+ // sidebar is preferred and the FAM acts as the fallback.
74
+ var HOTKEY_PRIORITY = {
75
+ SIDEBAR: 2,
76
+ FLOATING_ACTION_MENU: 1
77
+ };
78
+
79
+ // The global shortcut that opens the product switcher, and its options.
80
+ var PRODUCT_SWITCHER_HOTKEYS = ["ctrl+u", "command+u"];
81
+ var PRODUCT_SWITCHER_HOTKEY_OPTIONS = {
82
+ mode: "global"
83
+ };
84
+
85
+ // The hotkey keys/options are stable module-level constants so neetohotkeys
86
+ // doesn't rebind on every render — two switchers binding the same shortcut
87
+ // would otherwise clobber each other.
88
+
89
+ // Registry of the currently mounted switchers; each entry exposes its open()
90
+ // and a priority. The shortcut always opens the highest-priority one, so it
91
+ // works whether the sidebar switcher, the FAM switcher, or both are present,
92
+ // and never opens two. open() is idempotent (sets open to true), so it's safe
93
+ // even if more than one binding fires for the same keypress.
94
+ var switchers = new Set();
95
+ var openPrimarySwitcher = function openPrimarySwitcher() {
96
+ var _top;
97
+ var top = null;
98
+ switchers.forEach(function (current) {
99
+ if (!top || current.priority > top.priority) top = current;
100
+ });
101
+ (_top = top) === null || _top === void 0 || _top.open();
102
+ };
103
+ var useProductSwitcherHotkey = function useProductSwitcherHotkey(setIsOpen, priority) {
104
+ var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
105
+ var entryRef = React.useRef({});
106
+ entryRef.current.priority = priority;
107
+ entryRef.current.open = function () {
108
+ return setIsOpen(true);
109
+ };
110
+
111
+ // One stable handler per instance so bindings stay independent across the
112
+ // sidebar and FAM switchers (hotkeys-js keeps a distinct binding for each).
113
+ var handlerRef = React.useRef(function () {
114
+ return openPrimarySwitcher();
115
+ });
116
+ React.useEffect(function () {
117
+ if (!enabled) return undefined;
118
+ var entry = entryRef.current;
119
+ switchers.add(entry);
120
+ return function () {
121
+ switchers["delete"](entry);
122
+ };
123
+ }, [enabled]);
124
+ useHotkeys(PRODUCT_SWITCHER_HOTKEYS, handlerRef.current, PRODUCT_SWITCHER_HOTKEY_OPTIONS);
125
+ };
126
+
127
+ // Mirrors the grid layout `grid-cols-2 sm:grid-cols-3` (sm breakpoint = 640px),
128
+ // so ArrowUp/ArrowDown move by the correct number of columns.
129
+ var getColumnsPerRow = function getColumnsPerRow() {
130
+ return window.innerWidth < 640 ? 2 : 3;
131
+ };
132
+ var useKeyboardNavigation = function useKeyboardNavigation() {
133
+ var filteredApps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
134
+ var onSelect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
135
+ var _useState = React.useState(0),
136
+ _useState2 = _slicedToArray(_useState, 2),
137
+ highlightedIndex = _useState2[0],
138
+ setHighlightedIndex = _useState2[1];
139
+ var scrollContainerRef = React.useRef(null);
140
+ React.useEffect(function () {
141
+ return setHighlightedIndex(0);
142
+ }, [filteredApps]);
143
+ React.useEffect(function () {
144
+ if (!scrollContainerRef.current || ramda.isEmpty(filteredApps)) return;
145
+ var container = scrollContainerRef.current;
146
+ var highlightedElement = container.querySelector("[data-highlighted-index=\"".concat(highlightedIndex, "\"]"));
147
+ if (!highlightedElement) return;
148
+ var containerRect = container.getBoundingClientRect();
149
+ var elRect = highlightedElement.getBoundingClientRect();
150
+ if (elRect.top < containerRect.top) {
151
+ container.scrollTop += elRect.top - containerRect.top;
152
+ } else if (elRect.bottom > containerRect.bottom) {
153
+ container.scrollTop += elRect.bottom - containerRect.bottom;
154
+ }
155
+ }, [highlightedIndex, filteredApps]);
156
+ var navigationHandlers = {
157
+ left: function left(prev) {
158
+ return prev === 0 ? filteredApps.length - 1 : prev - 1;
159
+ },
160
+ right: function right(prev) {
161
+ return prev === filteredApps.length - 1 ? 0 : prev + 1;
162
+ },
163
+ up: function up(prev) {
164
+ var columnsPerRow = getColumnsPerRow();
165
+ var newIndex = prev - columnsPerRow;
166
+ if (newIndex >= 0) return newIndex;
167
+ var currentCol = prev % columnsPerRow;
168
+ var lastIndex = filteredApps.length - 1;
169
+ return lastIndex - (lastIndex - currentCol) % columnsPerRow;
170
+ },
171
+ down: function down(prev) {
172
+ var columnsPerRow = getColumnsPerRow();
173
+ var newIndex = prev + columnsPerRow;
174
+ if (newIndex < filteredApps.length) return newIndex;
175
+ return prev % columnsPerRow;
176
+ }
177
+ };
178
+ var handleOpenHighlightedApp = function handleOpenHighlightedApp() {
179
+ var app = filteredApps[highlightedIndex];
180
+ // Delegate to the caller, which decides whether to navigate (has access)
181
+ // or surface the "no access" notice (locked product).
182
+ if (app) onSelect(app);
183
+ };
184
+ var keyActions = {
185
+ Enter: handleOpenHighlightedApp,
186
+ ArrowLeft: function ArrowLeft() {
187
+ return setHighlightedIndex(navigationHandlers["left"]);
188
+ },
189
+ ArrowRight: function ArrowRight() {
190
+ return setHighlightedIndex(navigationHandlers["right"]);
191
+ },
192
+ ArrowUp: function ArrowUp() {
193
+ return setHighlightedIndex(navigationHandlers["up"]);
194
+ },
195
+ ArrowDown: function ArrowDown() {
196
+ return setHighlightedIndex(navigationHandlers["down"]);
197
+ }
198
+ };
199
+ var handleKeyDown = function handleKeyDown(e) {
200
+ var action = keyActions[e.key];
201
+ if (!action) return;
202
+ e.preventDefault();
203
+ e.stopPropagation();
204
+ if (neetoCist.isNotEmpty(filteredApps)) action(e);
205
+ };
206
+ return {
207
+ highlightedIndex: highlightedIndex,
208
+ handleKeyDown: handleKeyDown,
209
+ scrollContainerRef: scrollContainerRef
210
+ };
211
+ };
212
+
213
+ var fetch = function fetch() {
214
+ return axios.get("/api/v1/neeto_apps");
215
+ };
216
+ var neetoAppsApi = {
217
+ fetch: fetch
218
+ };
219
+
220
+ var _excluded$1 = ["neetoApps", "lockedApps"];
221
+ function ownKeys$2(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; }
222
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
223
+ var lock = function lock(app) {
224
+ var _globalProps$appName;
225
+ return (_globalProps$appName = initializers.globalProps.appName) !== null && _globalProps$appName !== void 0 && _globalProps$appName.includes(app.name) ? ramda.assoc("url", window.location.origin, app) : ramda.assoc("hasAccess", false, app);
226
+ };
227
+ var mergeLockedApps = function mergeLockedApps(_ref) {
228
+ var _ref$neetoApps = _ref.neetoApps,
229
+ neetoApps = _ref$neetoApps === void 0 ? [] : _ref$neetoApps,
230
+ _ref$lockedApps = _ref.lockedApps,
231
+ lockedApps = _ref$lockedApps === void 0 ? [] : _ref$lockedApps,
232
+ data = _objectWithoutProperties(_ref, _excluded$1);
233
+ return _objectSpread$2(_objectSpread$2({}, data), {}, {
234
+ neetoApps: [].concat(_toConsumableArray(neetoApps), _toConsumableArray(lockedApps.map(lock)))
235
+ });
236
+ };
237
+ var useFetchNeetoApps = function useFetchNeetoApps(options) {
238
+ return reactQuery.useQuery(_objectSpread$2({
239
+ queryKey: [QUERY_KEYS.NEETO_APPS_LIST],
240
+ queryFn: neetoAppsApi.fetch,
241
+ staleTime: 5 * 60 * 1000,
242
+ select: mergeLockedApps
243
+ }, options));
244
+ };
245
+
246
+ var _excluded = ["name", "description", "url", "hasAccess", "isHighlighted", "onNavigate", "onLockedClick"];
247
+ function ownKeys$1(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; }
248
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
249
+ var ProductCard$1 = function ProductCard(_ref) {
250
+ var _ref2, _globalProps$appName;
251
+ var name = _ref.name,
252
+ description = _ref.description,
253
+ url = _ref.url,
254
+ hasAccess = _ref.hasAccess,
255
+ _ref$isHighlighted = _ref.isHighlighted,
256
+ isHighlighted = _ref$isHighlighted === void 0 ? false : _ref$isHighlighted,
257
+ onNavigate = _ref.onNavigate,
258
+ onLockedClick = _ref.onLockedClick,
259
+ otherProps = _objectWithoutProperties(_ref, _excluded);
260
+ var normalizedName = (name || "").toLowerCase();
261
+ var specialCase = SPECIAL_APP_NAMES[normalizedName];
262
+ var safeName = name || "";
263
+ var logoKey = "Neeto".concat(safeName.charAt(0).toUpperCase()).concat(safeName.slice(1).toLowerCase());
264
+ var Logo = (_ref2 = specialCase ? Logos__namespace["Neeto".concat(specialCase)] : Logos__namespace[logoKey]) !== null && _ref2 !== void 0 ? _ref2 : Neeto;
265
+ var isCurrentApp = initializers.globalProps === null || initializers.globalProps === void 0 || (_globalProps$appName = initializers.globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.includes(name);
266
+ // A product that is part of the suite but the user has no access to is shown
267
+ // locked. When the backend omits `hasAccess`, the card stays navigable.
268
+ var isLocked = hasAccess === false;
269
+ var body = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
270
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
271
+ className: classnames("flex size-14 shrink-0 items-center justify-center rounded-xl transition-colors [&>svg]:size-9", {
272
+ "bg-background shadow-sm": isCurrentApp,
273
+ "bg-muted": !isCurrentApp,
274
+ "opacity-45": isLocked
275
+ }),
276
+ children: /*#__PURE__*/jsxRuntime.jsx(Logo, {})
277
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
278
+ className: classnames("flex flex-col gap-0.5 text-center", {
279
+ "opacity-45": isLocked
280
+ }),
281
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
282
+ lineClamp: 1,
283
+ variant: "body2",
284
+ weight: "semibold",
285
+ children: name
286
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
287
+ color: "muted",
288
+ lineClamp: 1,
289
+ variant: "caption",
290
+ children: description
291
+ })]
292
+ }), isCurrentApp && /*#__PURE__*/jsxRuntime.jsx("span", {
293
+ className: "bg-primary ring-primary/20 absolute end-3 top-3 size-2 rounded-full ring-4"
294
+ }), isLocked && /*#__PURE__*/jsxRuntime.jsx("span", {
295
+ className: "border-border bg-background text-muted-foreground absolute end-3 top-3 flex size-4.5 items-center justify-center rounded-full border",
296
+ children: /*#__PURE__*/jsxRuntime.jsx(lock$1.Lock, {
297
+ size: 10
298
+ })
299
+ })]
300
+ });
301
+ if (isLocked) {
302
+ return /*#__PURE__*/jsxRuntime.jsx("button", _objectSpread$1(_objectSpread$1({
303
+ "data-testid": "".concat(normalizedName, "-app-card"),
304
+ type: "button",
305
+ className: classnames("focus-visible:ring-ring relative flex h-32 w-36 cursor-pointer flex-col items-center gap-3 rounded-2xl border p-3 transition-colors outline-none focus-visible:ring-2", {
306
+ "hover:border-border hover:bg-muted/40 border-transparent": !isHighlighted,
307
+ "border-border bg-accent": isHighlighted
308
+ }),
309
+ onClick: function onClick() {
310
+ return onLockedClick === null || onLockedClick === void 0 ? void 0 : onLockedClick(name);
311
+ }
312
+ }, otherProps), {}, {
313
+ children: body
314
+ }));
315
+ }
316
+ return /*#__PURE__*/jsxRuntime.jsx("a", _objectSpread$1(_objectSpread$1({
317
+ "data-testid": "".concat(normalizedName, "-app-card"),
318
+ href: url,
319
+ rel: "noreferrer",
320
+ target: "_blank",
321
+ className: classnames("focus-visible:ring-ring relative flex h-32 w-36 flex-col items-center gap-3 rounded-2xl border p-3 no-underline transition-colors outline-none focus-visible:ring-2", {
322
+ "border-border": isCurrentApp || isHighlighted,
323
+ "hover:border-border hover:bg-muted/40 border-transparent": !isCurrentApp && !isHighlighted,
324
+ "bg-muted/40": isCurrentApp && !isHighlighted,
325
+ "bg-accent": isHighlighted
326
+ }),
327
+ onClick: onNavigate
328
+ }, otherProps), {}, {
329
+ children: body
330
+ }));
331
+ };
332
+ var ProductCard = /*#__PURE__*/React.memo(ProductCard$1);
333
+
334
+ function ownKeys(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; }
335
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
336
+ var Panel = function Panel(_ref) {
337
+ var onNavigate = _ref.onNavigate,
338
+ _ref$autoFocusSearch = _ref.autoFocusSearch,
339
+ autoFocusSearch = _ref$autoFocusSearch === void 0 ? true : _ref$autoFocusSearch;
340
+ var _useTranslation = reactI18next.useTranslation(),
341
+ t = _useTranslation.t;
342
+ var _useState = React.useState(""),
343
+ _useState2 = _slicedToArray(_useState, 2),
344
+ searchTerm = _useState2[0],
345
+ setSearchTerm = _useState2[1];
346
+ var _useState3 = React.useState(null),
347
+ _useState4 = _slicedToArray(_useState3, 2),
348
+ lockedAppName = _useState4[0],
349
+ setLockedAppName = _useState4[1];
350
+ var _useFetchNeetoApps = useFetchNeetoApps(),
351
+ data = _useFetchNeetoApps.data,
352
+ isLoading = _useFetchNeetoApps.isLoading;
353
+ var substring = searchTerm.replace(/ /g, "").toLowerCase();
354
+ var filteredApps = React.useMemo(function () {
355
+ var _data$neetoApps;
356
+ if (!data) return [];
357
+ return data === null || data === void 0 || (_data$neetoApps = data.neetoApps) === null || _data$neetoApps === void 0 ? void 0 : _data$neetoApps.filter(function (_ref2) {
358
+ var name = _ref2.name;
359
+ var nameLower = name.toLowerCase();
360
+ var isNeetoPrefixMatch = substring.length <= 4 && "neeto".startsWith(substring);
361
+ if (isNeetoPrefixMatch) return true;
362
+ var productName = substring.startsWith("neeto") ? substring.replace("neeto", "") : substring;
363
+ return nameLower.includes(productName);
364
+ });
365
+ }, [data, substring]);
366
+ var handleSelect = function handleSelect(app) {
367
+ if (!app) return;
368
+ if (app.hasAccess === false) {
369
+ setLockedAppName(app.name);
370
+ return;
371
+ }
372
+ if (app.url) window.open(app.url, "_blank", "noopener,noreferrer");
373
+ onNavigate();
374
+ };
375
+ var _useKeyboardNavigatio = useKeyboardNavigation(filteredApps, handleSelect),
376
+ highlightedIndex = _useKeyboardNavigatio.highlightedIndex,
377
+ handleKeyDown = _useKeyboardNavigatio.handleKeyDown,
378
+ scrollContainerRef = _useKeyboardNavigatio.scrollContainerRef;
379
+
380
+ // The host app's i18next lowercases interpolated values, which would render
381
+ // the product name as "neetoplanner". Interpolate a case-invariant sentinel
382
+ // and splice the correctly-cased name back in as plain text instead.
383
+ var _t$split = t("neetoMolecules.productSwitcher.noAccess", {
384
+ product: ""
385
+ }).split(""),
386
+ _t$split2 = _slicedToArray(_t$split, 2),
387
+ noAccessBefore = _t$split2[0],
388
+ _t$split2$ = _t$split2[1],
389
+ noAccessAfter = _t$split2$ === void 0 ? "" : _t$split2$;
390
+ React.useEffect(function () {
391
+ if (!lockedAppName) return undefined;
392
+ var timer = setTimeout(function () {
393
+ return setLockedAppName(null);
394
+ }, NO_ACCESS_NOTICE_DURATION);
395
+ return function () {
396
+ return clearTimeout(timer);
397
+ };
398
+ }, [lockedAppName]);
399
+ var renderBody = function renderBody() {
400
+ if (isLoading) {
401
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
402
+ className: "flex h-40 items-center justify-center",
403
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {
404
+ "data-testid": "neeto-ui-spinner"
405
+ })
406
+ });
407
+ }
408
+ if (!(filteredApps !== null && filteredApps !== void 0 && filteredApps.length)) {
409
+ return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Empty, {
410
+ "data-testid": "no-apps-found-title",
411
+ description: t("neetoMolecules.productSwitcher.noApps"),
412
+ icon: SearchX
413
+ });
414
+ }
415
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
416
+ className: "grid grid-cols-2 justify-items-start gap-2 sm:grid-cols-3",
417
+ children: filteredApps.map(function (app, index) {
418
+ return /*#__PURE__*/jsxRuntime.jsx(ProductCard, _objectSpread(_objectSpread({}, _objectSpread(_objectSpread({}, app), {}, {
419
+ onNavigate: onNavigate
420
+ })), {}, {
421
+ "data-highlighted-index": index,
422
+ isHighlighted: index === highlightedIndex,
423
+ onLockedClick: setLockedAppName
424
+ }), app.name);
425
+ })
426
+ });
427
+ };
428
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
429
+ className: "flex h-full w-full flex-col",
430
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
431
+ className: "border-border flex shrink-0 flex-col gap-3 border-b p-4 sm:flex-row sm:items-center sm:justify-between",
432
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
433
+ as: "h2",
434
+ variant: "h5",
435
+ weight: "semibold",
436
+ children: t("neetoMolecules.productSwitcher.allProducts")
437
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
438
+ className: "w-full sm:w-48",
439
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
440
+ autoFocus: autoFocusSearch,
441
+ "data-testid": "sidebar-product-switcher-search",
442
+ placeholder: t("neetoMolecules.productSwitcher.search"),
443
+ prefix: /*#__PURE__*/jsxRuntime.jsx(search.Search, {}),
444
+ type: "search",
445
+ value: searchTerm,
446
+ onChange: function onChange(e) {
447
+ return setSearchTerm(e.target.value);
448
+ },
449
+ onKeyDown: handleKeyDown
450
+ })
451
+ })]
452
+ }), lockedAppName && /*#__PURE__*/jsxRuntime.jsx("div", {
453
+ className: "shrink-0 px-4 pt-4",
454
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Callout, {
455
+ "data-testid": "sidebar-product-switcher-no-access",
456
+ icon: lock$1.Lock,
457
+ variant: "warning",
458
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
459
+ className: "flex items-start justify-between gap-3",
460
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
461
+ children: [noAccessBefore, "Neeto", lockedAppName, noAccessAfter]
462
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
463
+ "aria-label": t("neetoMolecules.productSwitcher.closeNotice"),
464
+ className: "-me-1 -mt-1 shrink-0",
465
+ icon: x.X,
466
+ size: "icon-xs",
467
+ variant: "ghost",
468
+ onClick: function onClick() {
469
+ return setLockedAppName(null);
470
+ }
471
+ })]
472
+ })
473
+ })
474
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
475
+ className: "min-h-0 flex-1 overflow-y-auto p-4",
476
+ ref: scrollContainerRef,
477
+ children: renderBody()
478
+ })]
479
+ });
480
+ };
481
+
482
+ var MY_ORGANIZATION_URL = "/auth/organization/edit";
483
+ var BILLING_URL = "/auth/admin_billing";
484
+ var DELETE_WORKSPACE_URL = "/auth/organization/delete";
485
+ var ENGAGE_WIDGET_TRIGGER_ID = "neetoengage-trigger";
486
+ var DEFAULT_MENU_LINK_PROPS = {
487
+ engageProps: {
488
+ id: ENGAGE_WIDGET_TRIGGER_ID,
489
+ label: i18next.t("neetoMolecules.sidebar.helpLinks.whatsNew"),
490
+ "data-testid": "help-link-engage-button"
491
+ },
492
+ keyboardShortcutProps: {
493
+ label: i18next.t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
494
+ "data-testid": "help-link-keyboard-shortcut-button"
495
+ }
496
+ };
497
+
498
+ // Theme switcher
499
+ var APP_THEME_LOCALSTORAGE_KEY = "appTheme";
500
+ var THEMES = {
501
+ LIGHT: "light",
502
+ DARK: "dark"
503
+ };
504
+
505
+ // Legacy neetoUI theme classes — kept until full migration is complete.
506
+ var LEGACY_THEMES = {
507
+ LIGHT: "neeto-ui-theme--light",
508
+ DARK: "neeto-ui-theme--dark"
509
+ };
510
+ var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
511
+ 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]";
512
+ 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";
513
+ var THEME_ICON_BASE = "transition-transform duration-300 ease-out";
514
+ var SLOWNESS_DESCRIPTION_MAX_LENGTH = 2000;
515
+
516
+ // Shared source of truth for the neetoEngage changelog unread count.
517
+ //
518
+ // The widget reports the count by calling `window.Nv.onReceiveData({ unreadCount })`
519
+ // whenever it changes (on load and each time entries are marked read). Opening
520
+ // the widget doesn't clear it: the count only drops as entries are read. Both the FloatingActionMenu and the
521
+ // Sidebar surface this count, so this module installs a SINGLE set of
522
+ // `window.Nv` handlers (chaining onto any pre-existing ones) and fans the value
523
+ // out to every subscribed component. Installation happens on the first
524
+ // subscriber and is torn down only when the last one unsubscribes — so
525
+ // interleaved mount/unmount of the two surfaces can never leave a stale handler
526
+ // on the global object.
527
+
528
+ var currentCount = null;
529
+ var subscribers = new Set();
530
+ var isInstalled = false;
531
+ var previousOnReceiveData;
532
+ var notify = function notify() {
533
+ return subscribers.forEach(function (setCount) {
534
+ return setCount(currentCount);
535
+ });
536
+ };
537
+ var install = function install() {
538
+ if (isInstalled) return;
539
+ isInstalled = true;
540
+ var existing = window.Nv || {};
541
+ previousOnReceiveData = existing.onReceiveData;
542
+ window.Nv = Object.assign(existing, {
543
+ onReceiveData: function onReceiveData(data) {
544
+ var _previousOnReceiveDat;
545
+ (_previousOnReceiveDat = previousOnReceiveData) === null || _previousOnReceiveDat === void 0 || _previousOnReceiveDat(data);
546
+ // Only react to a numeric unreadCount; `0` clears the badge (a non-zero
547
+ // count would otherwise stay stale until the pane is opened).
548
+ if (typeof (data === null || data === void 0 ? void 0 : data.unreadCount) === "number") {
549
+ currentCount = data.unreadCount || null;
550
+ notify();
551
+ }
552
+ }
553
+ });
554
+ };
555
+ var uninstall = function uninstall() {
556
+ if (!isInstalled) return;
557
+ isInstalled = false;
558
+ if (window.Nv) {
559
+ window.Nv.onReceiveData = previousOnReceiveData;
560
+ }
561
+ // currentCount is kept: the widget only reports it on page load and after a
562
+ // "Mark as read", so a surface that remounts (e.g. after navigating to a page
563
+ // without a sidebar and back) would otherwise lose it until a full reload.
564
+ };
565
+ var useWhatsNewChangesCount = function useWhatsNewChangesCount() {
566
+ var _useState = React.useState(currentCount),
567
+ _useState2 = _slicedToArray(_useState, 2),
568
+ changesCount = _useState2[0],
569
+ setChangesCount = _useState2[1];
570
+ React.useEffect(function () {
571
+ install();
572
+ subscribers.add(setChangesCount);
573
+ setChangesCount(currentCount);
574
+ return function () {
575
+ subscribers["delete"](setChangesCount);
576
+ if (subscribers.size === 0) uninstall();
577
+ };
578
+ }, []);
579
+ return changesCount;
580
+ };
581
+
582
+ exports.APP_THEME_LOCALSTORAGE_KEY = APP_THEME_LOCALSTORAGE_KEY;
583
+ exports.BILLING_URL = BILLING_URL;
584
+ exports.DEFAULT_MENU_LINK_PROPS = DEFAULT_MENU_LINK_PROPS;
585
+ exports.DELETE_WORKSPACE_URL = DELETE_WORKSPACE_URL;
586
+ exports.ENGAGE_WIDGET_TRIGGER_ID = ENGAGE_WIDGET_TRIGGER_ID;
587
+ exports.HOTKEY_PRIORITY = HOTKEY_PRIORITY;
588
+ exports.LEGACY_THEMES = LEGACY_THEMES;
589
+ exports.MENU_ITEM_CLASSES = MENU_ITEM_CLASSES;
590
+ exports.MY_ORGANIZATION_URL = MY_ORGANIZATION_URL;
591
+ exports.NEETO_AUTH_BILLING_INFO_URL = NEETO_AUTH_BILLING_INFO_URL;
592
+ exports.Panel = Panel;
593
+ exports.SLOWNESS_DESCRIPTION_MAX_LENGTH = SLOWNESS_DESCRIPTION_MAX_LENGTH;
594
+ exports.THEMES = THEMES;
595
+ exports.THEME_BUTTON_BASE = THEME_BUTTON_BASE;
596
+ exports.THEME_ICON_BASE = THEME_ICON_BASE;
597
+ exports.useProductSwitcherHotkey = useProductSwitcherHotkey;
598
+ exports.useWhatsNewChangesCount = useWhatsNewChangesCount;
599
+ //# sourceMappingURL=useWhatsNewChangesCount-CAxjl3n7.js.map