@bigbinary/neeto-molecules 4.0.43 → 4.0.45

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.
@@ -7,7 +7,6 @@ var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
7
7
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
8
8
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
9
9
  var neetoCist = require('@bigbinary/neeto-cist');
10
- var useFetchNeetoApps = require('@bigbinary/neeto-commons-frontend/react-utils/useFetchNeetoApps');
11
10
  var useHotkeys = require('@bigbinary/neeto-hotkeys');
12
11
  var Help = require('@bigbinary/neeto-icons/Help');
13
12
  var Profile = require('@bigbinary/neeto-team-members-frontend/Profile');
@@ -22,20 +21,21 @@ var Search = require('@bigbinary/neeto-icons/Search');
22
21
  var Input = require('@bigbinary/neetoui/Input');
23
22
  var Typography = require('@bigbinary/neetoui/Typography');
24
23
  var reactI18next = require('react-i18next');
25
- var injectCss = require('./inject-css-B6qYtOJe.js');
24
+ var Spinner = require('@bigbinary/neetoui/Spinner');
25
+ var reactQuery = require('@tanstack/react-query');
26
+ var axios = require('axios');
26
27
  var Neeto = require('@bigbinary/neeto-icons/typeface-logos/Neeto');
27
28
  var AppIcons = require('@bigbinary/neeto-icons/typeface-logos');
29
+ var injectCss = require('./inject-css-B6qYtOJe.js');
28
30
  var jsxRuntime = require('react/jsx-runtime');
29
31
  var i18next = require('i18next');
30
32
  var Book = require('@bigbinary/neeto-icons/Book');
31
33
  var Community = require('@bigbinary/neeto-icons/Community');
32
34
  var useBreakpoints = require('@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints');
33
35
  var ExternalLink = require('@bigbinary/neeto-icons/ExternalLink');
34
- var reactQuery = require('@tanstack/react-query');
35
- var axios = require('axios');
36
36
  var Right = require('@bigbinary/neeto-icons/Right');
37
+ var _objectDestructuringEmpty = require('@babel/runtime/helpers/objectDestructuringEmpty');
37
38
  var ProductSwitcher$1 = require('@bigbinary/neeto-icons/ProductSwitcher');
38
- var Spinner = require('@bigbinary/neetoui/Spinner');
39
39
  var useLocalStorage = require('@bigbinary/neeto-commons-frontend/react-utils/useLocalStorage');
40
40
  var Check = require('@bigbinary/neeto-icons/Check');
41
41
  var utils = require('@bigbinary/neeto-commons-frontend/utils');
@@ -71,6 +71,26 @@ function _interopNamespaceDefault(e) {
71
71
 
72
72
  var AppIcons__namespace = /*#__PURE__*/_interopNamespaceDefault(AppIcons);
73
73
 
74
+ var fetch$1 = function fetch() {
75
+ return axios.get("/api/v1/neeto_apps");
76
+ };
77
+ var neetoAppsApi = {
78
+ fetch: fetch$1
79
+ };
80
+
81
+ var QUERY_KEYS$1 = {
82
+ NEETO_APPS_LIST: "neeto-apps-list"
83
+ };
84
+
85
+ function ownKeys$5(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; }
86
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
87
+ var useFetchNeetoApps = function useFetchNeetoApps(options) {
88
+ return reactQuery.useQuery(_objectSpread$5({
89
+ queryKey: [QUERY_KEYS$1.NEETO_APPS_LIST],
90
+ queryFn: neetoAppsApi.fetch
91
+ }, options));
92
+ };
93
+
74
94
  var css$1 = ".neeto-molecules-product-switcher__wrapper{align-items:flex-start;background-color:rgb(var(--neeto-ui-white));display:flex;flex-direction:column;justify-content:flex-start;max-width:100%;overflow-y:auto;padding:24px;position:relative;transition:all .3s;width:100%}@media screen and (max-width:768px){.neeto-molecules-product-switcher__wrapper{padding:16px}}.neeto-molecules-product-switcher__grid{grid-gap:12px;display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(288px,1fr))}@media only screen and (max-width:992px){.neeto-molecules-product-switcher__grid{grid-template-columns:repeat(auto-fill,minmax(248px,1fr))}}@media only screen and (max-width:640px){.neeto-molecules-product-switcher__grid{grid-template-columns:repeat(auto-fill,minmax(100%,1fr))}}.neeto-molecules-product-switcher__header{align-items:center;display:flex;gap:32px;justify-content:space-between;margin-bottom:32px;position:relative;width:100%}@media only screen and (max-width:768px){.neeto-molecules-product-switcher__header{align-items:flex-start;flex-direction:column;gap:24px}}@media only screen and (max-width:640px){.neeto-molecules-product-switcher__header h1{font-size:24px}}@media only screen and (max-width:768px){.neeto-molecules-product-switcher_modal-container .neeto-molecules-product-switcher__header-mobile{align-items:flex-start;margin-bottom:24px}}.neeto-molecules-product-switcher_modal-container .neeto-molecules-product-switcher__wrapper{padding:0}.neeto-molecules-product-switcher__close-btn{position:absolute;right:12px;top:12px}.neeto-molecules-product-switcher__search-wrapper{flex-grow:1}@media only screen and (min-width:992px){.neeto-molecules-product-switcher__search-wrapper{flex-grow:0;width:296px}}.neeto-molecules-product-switcher__body{display:flex;flex-direction:column;font-size:var(--neeto-ui-text-sm);gap:12px;margin-bottom:24px;width:100%}.neeto-molecules-product-switcher-link{background-color:rgb(var(--neeto-ui-white));border-color:rgb(var(--neeto-ui-gray-200));border-radius:var(--neeto-ui-rounded-lg);border-style:solid;border-width:1px;cursor:pointer;display:flex;flex-direction:column;gap:16px;max-width:100%;padding:10px 8px;text-decoration:none;transition:all .3s ease-in-out;width:100%}.neeto-molecules-product-switcher-link:focus,.neeto-molecules-product-switcher-link:focus-visible{outline:none}.neeto-molecules-product-switcher-link:focus-visible{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-molecules-product-switcher-link:not(.neeto-molecules-product-switcher-link--active):hover{border-color:rgb(var(--neeto-ui-primary-500))}.neeto-molecules-product-switcher-link--active{background-color:rgb(var(--neeto-ui-primary-50));border-color:rgb(var(--neeto-ui-primary-500))}.neeto-molecules-product-switcher-link__icon-holder{flex-grow:1;flex-shrink:0}.neeto-molecules-product-switcher-link__icon-holder svg{height:36px;width:auto}.neeto-molecules-product-switcher-link__icon-holder .neeto-molecules-product-switcher-link__icon-default{height:24px}.neeto-molecules-product-switcher-link__content{flex-shrink:0}.neeto-molecules-product-switcher-link__content span{display:block}.neeto-molecules-product-switcher_modal{z-index:100000}.neeto-molecules-product-switcher_modal .neeto-ui-modal__wrapper--fullscreen{display:flex;flex-direction:column;height:100dvh!important;width:100vw!important}.neeto-molecules-product-switcher_modal .neeto-ui-modal__wrapper--fullscreen .neeto-ui-modal__header{flex-shrink:0}.neeto-molecules-product-switcher_modal .neeto-ui-modal__wrapper--fullscreen .neeto-ui-modal__body{--neeto-ui-modal-body-padding-top:24px;flex-grow:1;min-height:0;overflow-y:auto}.neeto-ui-theme--dark .neeto-molecules-product-switcher__wrapper [data-dark-mode-color=true]{fill:rgb(var(--neeto-ui-black))}.neeto-molecules-product-switcher_modal .neeto-ui-modal__wrapper--fullscreen .neeto-molecules-product-switcher__header{padding-right:56px}.neeto-molecules-product-switcher_modal .neeto-ui-modal__wrapper--fullscreen .neeto-ui-modal__close{z-index:2}";
75
95
  injectCss.n(css$1,{});
76
96
 
@@ -110,6 +130,37 @@ var ProductLink$1 = /*#__PURE__*/React.memo(ProductLink);
110
130
 
111
131
  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; }
112
132
  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; }
133
+ var Content = function Content(_ref) {
134
+ var searchTerm = _ref.searchTerm;
135
+ var _useTranslation = reactI18next.useTranslation(),
136
+ t = _useTranslation.t;
137
+ var _useFetchNeetoApps = useFetchNeetoApps(),
138
+ data = _useFetchNeetoApps.data,
139
+ isLoading = _useFetchNeetoApps.isLoading;
140
+ var substring = searchTerm.replace(/ /g, "").toLowerCase();
141
+ var filteredApps = data === null || data === void 0 ? void 0 : data.neetoApps.filter(function (_ref2) {
142
+ var name = _ref2.name;
143
+ return name.toLowerCase().includes(substring);
144
+ });
145
+ if (isLoading) {
146
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
147
+ className: "flex items-center justify-center py-8",
148
+ children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
149
+ });
150
+ }
151
+ return (filteredApps === null || filteredApps === void 0 ? void 0 : filteredApps.length) > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
152
+ className: "neeto-molecules-product-switcher__grid",
153
+ children: filteredApps.map(function (app) {
154
+ return /*#__PURE__*/jsxRuntime.jsx(ProductLink$1, _objectSpread$4({}, app), app.name);
155
+ })
156
+ }) : /*#__PURE__*/jsxRuntime.jsx(Typography, {
157
+ className: "neeto-ui-text-center",
158
+ "data-cy": "no-apps-found-title",
159
+ style: "body1",
160
+ children: t("neetoMolecules.productSwitcher.noApps")
161
+ });
162
+ };
163
+
113
164
  var Menu$3 = function Menu(_ref) {
114
165
  var _ref$isMobile = _ref.isMobile,
115
166
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
@@ -119,18 +170,6 @@ var Menu$3 = function Menu(_ref) {
119
170
  _useState2 = _slicedToArray(_useState, 2),
120
171
  searchTerm = _useState2[0],
121
172
  setSearchTerm = _useState2[1];
122
- var _useFetchNeetoApps = useFetchNeetoApps({
123
- enabled: false
124
- }),
125
- data = _useFetchNeetoApps.data;
126
- var substring = searchTerm.replace(/ /g, "").toLowerCase();
127
- var filteredApps = data === null || data === void 0 ? void 0 : data.neetoApps.filter(function (_ref2) {
128
- var name = _ref2.name;
129
- return name.toLowerCase().includes(substring);
130
- });
131
- var handleSearch = function handleSearch(e) {
132
- return setSearchTerm(e.target.value);
133
- };
134
173
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
135
174
  className: "neeto-molecules-product-switcher__wrapper",
136
175
  "data-cy": "switcher-wrapper",
@@ -152,21 +191,15 @@ var Menu$3 = function Menu(_ref) {
152
191
  prefix: /*#__PURE__*/jsxRuntime.jsx(Search, {}),
153
192
  type: "search",
154
193
  value: searchTerm,
155
- onChange: handleSearch
194
+ onChange: function onChange(e) {
195
+ return setSearchTerm(e.target.value);
196
+ }
156
197
  })
157
198
  })]
158
199
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
159
200
  className: classnames("neeto-molecules-product-switcher__body", _defineProperty({}, "neeto-molecules-product-switcher__body-mobile", isMobile)),
160
- children: (filteredApps === null || filteredApps === void 0 ? void 0 : filteredApps.length) > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
161
- className: "neeto-molecules-product-switcher__grid",
162
- children: filteredApps.map(function (app) {
163
- return /*#__PURE__*/jsxRuntime.jsx(ProductLink$1, _objectSpread$4({}, app), app.name);
164
- })
165
- }) : /*#__PURE__*/jsxRuntime.jsx(Typography, {
166
- className: "neeto-ui-text-center",
167
- "data-cy": "no-apps-found-title",
168
- style: "body1",
169
- children: t("neetoMolecules.productSwitcher.noApps")
201
+ children: /*#__PURE__*/jsxRuntime.jsx(Content, {
202
+ searchTerm: searchTerm
170
203
  })
171
204
  })]
172
205
  }, "switcher-wrapper");
@@ -258,7 +291,7 @@ var THEMES = {
258
291
  };
259
292
  var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
260
293
 
261
- var _excluded$2 = ["label", "icon", "changesCount"];
294
+ var _excluded$1 = ["label", "icon", "changesCount"];
262
295
  function ownKeys$3(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; }
263
296
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
264
297
  var LinkSection = function LinkSection(_ref) {
@@ -270,7 +303,7 @@ var LinkSection = function LinkSection(_ref) {
270
303
  var label = _ref2.label,
271
304
  Icon = _ref2.icon,
272
305
  changesCount = _ref2.changesCount,
273
- otherProps = _objectWithoutProperties(_ref2, _excluded$2);
306
+ otherProps = _objectWithoutProperties(_ref2, _excluded$1);
274
307
  return /*#__PURE__*/jsxRuntime.jsxs(MenuItem.Button, _objectSpread$3(_objectSpread$3({
275
308
  className: "neeto-molecules-menu-sublist__item-btn",
276
309
  "data-cy": "floating-action-menu-link-section",
@@ -388,24 +421,20 @@ var OrganizationSwitcher = function OrganizationSwitcher() {
388
421
  });
389
422
  };
390
423
 
391
- var _excluded$1 = ["isLoading", "onMouseEnter"];
392
424
  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; }
393
425
  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; }
394
426
  var MenuButton$1 = function MenuButton(_ref) {
395
- var isLoading = _ref.isLoading,
396
- onMouseEnter = _ref.onMouseEnter,
397
- otherProps = _objectWithoutProperties(_ref, _excluded$1);
427
+ var otherProps = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
398
428
  var _useTranslation = reactI18next.useTranslation(),
399
429
  t = _useTranslation.t;
400
430
  var MenuItem = Dropdown$1.MenuItem;
401
431
  return /*#__PURE__*/jsxRuntime.jsxs(MenuItem.Button, _objectSpread$2(_objectSpread$2({
402
- onMouseEnter: onMouseEnter,
403
432
  className: "neeto-molecules-menu-sublist__item-btn",
404
433
  "data-cy": "product-switcher-button",
405
434
  "data-testid": "product-switcher-button",
406
435
  label: t("neetoMolecules.sidebar.productSwitcher"),
407
436
  style: "text",
408
- suffix: isLoading ? /*#__PURE__*/jsxRuntime.jsx(Spinner, {}) : /*#__PURE__*/jsxRuntime.jsx(Right, {
437
+ suffix: /*#__PURE__*/jsxRuntime.jsx(Right, {
409
438
  size: 18
410
439
  })
411
440
  }, otherProps), {}, {
@@ -418,26 +447,12 @@ var MenuButton$1 = function MenuButton(_ref) {
418
447
  var Menu$1 = Dropdown$1.Menu,
419
448
  MenuItem$2 = Dropdown$1.MenuItem;
420
449
  var Dropdown = function Dropdown() {
421
- var _useFetchNeetoApps = useFetchNeetoApps(),
422
- data = _useFetchNeetoApps.data,
423
- isLoading = _useFetchNeetoApps.isLoading,
424
- isStale = _useFetchNeetoApps.isStale,
425
- refetchNeetoApps = _useFetchNeetoApps.refetch;
426
- var onMouseEnter = function onMouseEnter() {
427
- if (!isStale) return;
428
- refetchNeetoApps();
429
- };
430
450
  return /*#__PURE__*/jsxRuntime.jsx(Dropdown$1, {
431
451
  appendTo: "parent",
432
452
  className: "neeto-molecules-product-switcher-menu-popup-wrapper",
433
453
  closeOnSelect: false,
434
- customTarget: /*#__PURE__*/jsxRuntime.jsx(MenuButton$1, {
435
- isLoading: isLoading,
436
- onMouseEnter: onMouseEnter
437
- }),
438
- disabled: !data || isLoading,
454
+ customTarget: /*#__PURE__*/jsxRuntime.jsx(MenuButton$1, {}),
439
455
  interactiveDebounce: 30,
440
- isOpen: !data ? false : undefined,
441
456
  offset: [0, 5],
442
457
  position: "right",
443
458
  trigger: "all",
@@ -727,6 +742,7 @@ var ProfileMenu = function ProfileMenu(_ref) {
727
742
  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; }
728
743
  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; }
729
744
  var ProfileButton = function ProfileButton(_ref) {
745
+ var _globalProps$user;
730
746
  var profileInfoOverrides = _ref.profileInfoOverrides,
731
747
  showProductSwitcher = _ref.showProductSwitcher,
732
748
  bottomLinks = _ref.bottomLinks,
@@ -750,10 +766,6 @@ var ProfileButton = function ProfileButton(_ref) {
750
766
  var _Profile$usePaneState = Profile.usePaneState(),
751
767
  _Profile$usePaneState2 = _slicedToArray(_Profile$usePaneState, 2),
752
768
  setIsProfilePaneOpen = _Profile$usePaneState2[1];
753
- var _useFetchNeetoApps = useFetchNeetoApps(),
754
- data = _useFetchNeetoApps.data,
755
- refetch = _useFetchNeetoApps.refetch,
756
- isStale = _useFetchNeetoApps.isStale;
757
769
  useHotkeys(["ctrl+e", "command+e"], function () {
758
770
  return setIsModalOpen(ramda.not);
759
771
  }, {
@@ -772,11 +784,7 @@ var ProfileButton = function ProfileButton(_ref) {
772
784
  };
773
785
  window.Nv = window.Nv ? Object.assign(window.Nv, Nv) : Nv;
774
786
  }, []);
775
- React.useEffect(function () {
776
- if (!isStale) return;
777
- refetch();
778
- }, [isStale]);
779
- var newTopLinks = globalProps.appName.toLowerCase() !== "neetoauth" ? [].concat(_toConsumableArray(getDefaultTopLinks(data === null || data === void 0 ? void 0 : data.isOwner, setIsProfilePaneOpen, profileInfo.isAuthenticated)), _toConsumableArray(topLinks)) : topLinks;
787
+ var newTopLinks = globalProps.appName.toLowerCase() !== "neetoauth" ? [].concat(_toConsumableArray(getDefaultTopLinks((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.isOwner, setIsProfilePaneOpen, profileInfo.isAuthenticated)), _toConsumableArray(topLinks)) : topLinks;
780
788
  var newBottomLinks = [].concat(_toConsumableArray(getDefaultBottomLinks(profileInfo.isAuthenticated, isConsumer)), _toConsumableArray(bottomLinks));
781
789
  var helpLinks = Object.keys(DEFAULT_HELP_LINK_PROPS).map(function (key) {
782
790
  return _objectSpread$1({}, DEFAULT_HELP_LINK_PROPS[key]);