@inboxsdk/core 0.2.29-alpha.3 → 0.2.29-alpha.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inboxsdk/core",
3
- "version": "0.2.29-alpha.3",
3
+ "version": "0.2.29-alpha.4",
4
4
  "description": "Library for building browser extensions for Gmail",
5
5
  "main": "inboxsdk.js",
6
6
  "author": "Streak",
@@ -1 +1 @@
1
- {"version":3,"file":"add-collapsible-panel.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-collapsible-panel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,eAAe,EAAE,0BAA0B,6CAgB5C"}
1
+ {"version":3,"file":"add-collapsible-panel.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-collapsible-panel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,eAAe,EAAE,0BAA0B,6CAkB5C"}
@@ -5,8 +5,7 @@ import Logger from '../../../lib/logger';
5
5
  import { CollapsiblePanelView } from '../../../views/collapsible-panel-view';
6
6
  export async function addCollapsiblePanel(driver, panelDescriptor) {
7
7
  const injectionContainer = await waitForAppMenuParentReady();
8
- const collapsiblePanelView = new CollapsiblePanelView(driver);
9
- collapsiblePanelView.panelDescriptor = panelDescriptor;
8
+ const collapsiblePanelView = new CollapsiblePanelView(driver, panelDescriptor);
10
9
  if (!injectionContainer || !collapsiblePanelView.element)
11
10
  return;
12
11
  const appMenu = await GmailElementGetter.getAppMenuAsync();
@@ -21,6 +21,8 @@ declare const GmailElementGetter: {
21
21
  getAppMenuAsync: () => Promise<HTMLElement | undefined>;
22
22
  isAppBurgerMenuOpen(): boolean;
23
23
  getAppMenuContainer(): HTMLElement | null;
24
+ getAppMenu(): HTMLElement | null;
25
+ getAppHeader(): HTMLElement | null;
24
26
  getSeparateSectionNavItemMenuInjectionContainer(): HTMLElement | null;
25
27
  getSameSectionNavItemMenuInjectionContainer(): HTMLElement | null;
26
28
  getRowListElements(): HTMLElement[];
@@ -1 +1 @@
1
- {"version":3,"file":"gmail-element-getter.d.ts","sourceRoot":"","sources":["../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAA+B,EAC7B,mBAAmB,EACpB,MAAM,yCAAyC,CAAC;AAUjD,QAAA,MAAM,kBAAkB;yBACD,WAAW,GAAG,IAAI;uCAcJ,WAAW,GAAG,IAAI;kDAKP,WAAW,GAAG,IAAI;+CAKrB,WAAW,GAAG,IAAI;wBAIzC,WAAW,GAAG,IAAI;iCAOT,WAAW,GAAG,IAAI;gCAInB,WAAW,GAAG,SAAS,GAAG,IAAI;2CA8BnB,WAAW,GAAG,IAAI;iDAIZ,MAAM,UAAU,CAC3D,mBAAmB,EACnB,KAAK,CACN;uBAgBkB,WAAW,GAAG,IAAI;kCAIP,WAAW,GAAG,IAAI;+BAOrB,WAAW,GAAG,IAAI;0CAIP,WAAW,GAAG,IAAI;+BAI7B,WAAW,GAAG,IAAI;+CAQrC,GAAG,KACR,MAAM,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC;qBAItB,WAAW,GAAG,IAAI;+BAOR,OAAO;;;;uDAqFiB,WAAW,GAAG,IAAI;mDAItB,WAAW,GAAG,IAAI;0BAQ3C,WAAW,EAAE;0BAIb,WAAW,GAAG,IAAI;sBAItB,gBAAgB,GAAG,IAAI;qCAMR,WAAW,GAAG,IAAI;kCAIrB,WAAW,GAAG,IAAI;2BAIzB,WAAW,GAAG,IAAI;iCAWZ,WAAW,GAAG,IAAI;yBAI1B,WAAW;8BAIN,WAAW,GAAG,IAAI;sBAM1B,OAAO;mBAaV,OAAO;qBAIL,OAAO;oBAIR,OAAO;iCAIM,OAAO;gCAOR,OAAO;;qCASJ,WAAW,GAAG,IAAI;;gCAKrB,QAAQ,IAAI,CAAC;CAG1C,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"gmail-element-getter.d.ts","sourceRoot":"","sources":["../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAA+B,EAC7B,mBAAmB,EACpB,MAAM,yCAAyC,CAAC;AAmBjD,QAAA,MAAM,kBAAkB;yBACD,WAAW,GAAG,IAAI;uCAcJ,WAAW,GAAG,IAAI;kDAKP,WAAW,GAAG,IAAI;+CAKrB,WAAW,GAAG,IAAI;wBAIzC,WAAW,GAAG,IAAI;iCAOT,WAAW,GAAG,IAAI;gCAInB,WAAW,GAAG,SAAS,GAAG,IAAI;2CA8BnB,WAAW,GAAG,IAAI;iDAIZ,MAAM,UAAU,CAC3D,mBAAmB,EACnB,KAAK,CACN;uBAgBkB,WAAW,GAAG,IAAI;kCAIP,WAAW,GAAG,IAAI;+BAOrB,WAAW,GAAG,IAAI;0CAIP,WAAW,GAAG,IAAI;+BAI7B,WAAW,GAAG,IAAI;+CAQrC,GAAG,KACR,MAAM,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC;qBAItB,WAAW,GAAG,IAAI;+BAOR,OAAO;;;;;;uDAgFiB,WAAW,GAAG,IAAI;mDAItB,WAAW,GAAG,IAAI;0BAQ3C,WAAW,EAAE;0BAIb,WAAW,GAAG,IAAI;sBAItB,gBAAgB,GAAG,IAAI;qCAMR,WAAW,GAAG,IAAI;kCAIrB,WAAW,GAAG,IAAI;2BAIzB,WAAW,GAAG,IAAI;iCAWZ,WAAW,GAAG,IAAI;yBAI1B,WAAW;8BAIN,WAAW,GAAG,IAAI;sBAM1B,OAAO;mBAaV,OAAO;qBAIL,OAAO;oBAIR,OAAO;iCAIM,OAAO;gCAOR,OAAO;;qCASJ,WAAW,GAAG,IAAI;;gCAKrB,QAAQ,IAAI,CAAC;CAG1C,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -7,6 +7,14 @@ import getMainContentElementChangedStream from './gmail-element-getter/get-main-
7
7
  import isIntegratedViewGmail from './gmail-driver/isIntegratedViewGmail';
8
8
  import Logger from '../../lib/logger';
9
9
  import waitFor from '../../lib/wait-for';
10
+ /**
11
+ * The selector for the new app menu https://support.google.com/mail/answer/11555490 -- FEB 2023
12
+ */
13
+ const APP_MENU = '.aeN.WR.a6o.anZ.nH.oy8Mbf[role=navigation]';
14
+ /**
15
+ * If the APP_MENU selector is not found, NAV_MENU _might_ be present.
16
+ */
17
+ const NAV_MENU = '.aeN.WR.nH.oy8Mbf[role=navigation]';
10
18
  // TODO Figure out if these functions can and should be able to return null
11
19
  const GmailElementGetter = {
12
20
  getActiveMoreMenu() {
@@ -144,14 +152,6 @@ const GmailElementGetter = {
144
152
  getAppMenuAsync: once(async () => {
145
153
  if (!GmailElementGetter.isStandalone()) {
146
154
  await GmailElementGetter.waitForGmailModeToSettle();
147
- /**
148
- * The selector for the new app menu https://support.google.com/mail/answer/11555490 -- FEB 2023
149
- */
150
- const APP_MENU = '.aeN.WR.a6o.anZ.nH.oy8Mbf[role=navigation]';
151
- /**
152
- * If the APP_MENU selector is not found, NAV_MENU _might_ be present.
153
- */
154
- const NAV_MENU = '.aeN.WR.nH.oy8Mbf[role=navigation]';
155
155
  try {
156
156
  const element = await waitFor(() => document.querySelector(`${APP_MENU}, ${NAV_MENU}`));
157
157
  if (!document.querySelector(APP_MENU)) {
@@ -172,10 +172,12 @@ const GmailElementGetter = {
172
172
  getAppMenuContainer() {
173
173
  return document.querySelector('.aqk.aql.bkL');
174
174
  },
175
- // TODO figure out if we use it
176
- // getNavMenu() {
177
- // return document.querySelector('.aeN.WR.nH.oy8Mbf[role=navigation]');
178
- // },
175
+ getAppMenu() {
176
+ return document.querySelector(APP_MENU);
177
+ },
178
+ getAppHeader() {
179
+ return document.querySelector('.oy8Mbf.qp');
180
+ },
179
181
  getSeparateSectionNavItemMenuInjectionContainer() {
180
182
  return document.querySelector('.aeN');
181
183
  },
@@ -1 +1 @@
1
- {"version":3,"file":"gmail-app-menu-item-view.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAK9C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,YAAY,MAAgB,CAAC;AAC1C,eAAO,MAAM,cAAc,yBAAmC,CAAC;AAC/D,eAAO,MAAM,aAAa,4BAA+C,CAAC;mDAOL,kBAAkB,aAAa,CAAC;AAArG,qBAAa,oBAAqB,SAAQ,yBAA4D;;IACpG,MAAM,CAAC,UAAU;;;MAGN;IAOX,IAAI,OAAO,4BAEV;IAED,qBAAqB,CAAC,qBAAqB,EAAE,qBAAqB;IAKlE,IAAI,kBAAkB,sCAErB;gBAEW,MAAM,EAAE,WAAW;IAc/B,MAAM;IAON;;OAEG;IACH,IAAI;IAIJ;;OAEG;IACH,KAAK;CAqFN"}
1
+ {"version":3,"file":"gmail-app-menu-item-view.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAK9C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,YAAY,MAAgB,CAAC;AAC1C,eAAO,MAAM,cAAc,yBAAmC,CAAC;AAC/D,eAAO,MAAM,aAAa,4BAA+C,CAAC;mDAOL,kBAAkB,aAAa,CAAC;AAArG,qBAAa,oBAAqB,SAAQ,yBAA4D;;IACpG,MAAM,CAAC,UAAU;;;MAGN;IAOX,IAAI,OAAO,4BAEV;IAED,qBAAqB,CAAC,qBAAqB,EAAE,qBAAqB;IAKlE,IAAI,kBAAkB,sCAErB;gBAEW,MAAM,EAAE,WAAW;IAc/B,MAAM;IAON;;OAEG;IACH,IAAI;IAIJ;;OAEG;IACH,KAAK;CA4FN"}
@@ -72,7 +72,8 @@ export class GmailAppMenuItemView extends EventEmitter {
72
72
  const element = this.element;
73
73
  if (!element)
74
74
  return;
75
- element.className = cx(ELEMENT_CLASS, this.#menuItemDescriptor?.className);
75
+ const existingClassNames = Object.values(GmailAppMenuItemView.elementCss).filter((className) => element.classList.contains(className));
76
+ element.className = cx(ELEMENT_CLASS, this.#menuItemDescriptor?.className, ...existingClassNames);
76
77
  this.#updateName(element);
77
78
  this.#updateIcon(element);
78
79
  this.#updateARIA(element);
@@ -30,6 +30,10 @@ export type AppMenuItemDescriptor = {
30
30
  };
31
31
  export type AppMenuItemPanelDescriptor = {
32
32
  className?: string;
33
+ /** In the form of HTML as a string.
34
+ *
35
+ * If this option is provided, the panel defaults to loading=true. */
36
+ loadingIcon?: string;
33
37
  primaryButton?: {
34
38
  name: string;
35
39
  onClick: (e: MouseEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"app-menu.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/namespaces/app-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,KAAK,UAAU,GACX,MAAM,GACN;IACE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACR,SAAS,EAAE,UAAU,CAAC;QACtB,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,EAAE,CAAC;IACjB;;;;OAIG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;QACjC,OAAO,CAAC,EAAE;YACR,SAAS,EAAE,MAAM,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;;gBAGd,MAAM,EAAE,WAAW;IAI/B,WAAW,CAAC,kBAAkB,EAAE,qBAAqB,GAAG,eAAe;IAKjE,OAAO;CAId"}
1
+ {"version":3,"file":"app-menu.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/namespaces/app-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,KAAK,UAAU,GACX,MAAM,GACN;IACE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACR,SAAS,EAAE,UAAU,CAAC;QACtB,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,EAAE,CAAC;IACjB;;;;OAIG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;0EAEsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;QACjC,OAAO,CAAC,EAAE;YACR,SAAS,EAAE,MAAM,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;;gBAGd,MAAM,EAAE,WAAW;IAI/B,WAAW,CAAC,kBAAkB,EAAE,qBAAqB,GAAG,eAAe;IAKjE,OAAO;CAId"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-menu-item-view.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/views/app-menu-item-view.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAUzC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAK3D,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;8CAyC8D,aAAa,aAAa,CAAC;AAH3F;;GAEG;AACH,qBAAa,eAAgB,SAAQ,oBAAuD;;IAiT1F,IAAI,kBAAkB,0BAErB;gBAQW,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB;IAuDpE,mBAAmB,CAAC,eAAe,EAAE,0BAA0B;IAiC/D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB;IAMtD,MAAM;CAYP"}
1
+ {"version":3,"file":"app-menu-item-view.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/views/app-menu-item-view.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAWzC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAK3D,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;8CA0C8D,aAAa,aAAa,CAAC;AAH3F;;GAEG;AACH,qBAAa,eAAgB,SAAQ,oBAAuD;;IAqV1F,IAAI,kBAAkB,0BAErB;gBAQW,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB;IAsDpE,mBAAmB,CAAC,eAAe,EAAE,0BAA0B;IA2C/D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB;IAMtD,MAAM;CAYP"}
@@ -1,5 +1,6 @@
1
1
  import Kefir from 'kefir';
2
2
  import kefirBus from 'kefir-bus';
3
+ import cx from 'classnames';
3
4
  import EventEmitter from '../lib/safe-event-emitter';
4
5
  import { GmailAppMenuItemView, NATIVE_CLASS, INBOXSDK_CLASS, } from '../dom-driver/gmail/views/gmail-app-menu-item-view';
5
6
  import { NATIVE_CLASS as PANEL_NATIVE_CLASS, CollapsiblePanelView, } from './collapsible-panel-view';
@@ -55,10 +56,15 @@ export class AppMenuItemView extends EventEmitter {
55
56
  const button = appMenuElement?.querySelector(`.${NATIVE_CLASS}.${ACTIVE}`);
56
57
  return button;
57
58
  }
59
+ static #isPanelLess() {
60
+ const activePanel = AppMenuItemView.#getActivePanel();
61
+ return !activePanel;
62
+ }
58
63
  static #setUpRouteViewDriverStream(driver) {
59
64
  if (AppMenuItemView.#routeViewDriverStream)
60
65
  return;
61
66
  AppMenuItemView.#routeViewDriverStream = driver.getRouteViewDriverStream();
67
+ // Activate menu items on route changes. Used for deep-links, browser history navigation etc.
62
68
  AppMenuItemView.#routeViewDriverStream.onValue(async (routeView) => {
63
69
  const routeViewID = routeView.getRouteID();
64
70
  const routeType = routeView.getRouteType();
@@ -72,7 +78,10 @@ export class AppMenuItemView extends EventEmitter {
72
78
  return descriptor?.isRouteActive(routeView);
73
79
  }) ?? [];
74
80
  if (gmailView?.element) {
75
- AppMenuItemView.#menuItemChangeBus.emit(['click', gmailView.element]);
81
+ AppMenuItemView.#menuItemChangeBus.emit([
82
+ 'route-activated',
83
+ gmailView.element,
84
+ ]);
76
85
  return;
77
86
  }
78
87
  /* Handling native app menu items */
@@ -86,12 +95,15 @@ export class AppMenuItemView extends EventEmitter {
86
95
  const menuItemElement = menuItemClass &&
87
96
  document.querySelector(`.${menuItemClass}`);
88
97
  if (menuItemElement) {
89
- AppMenuItemView.#menuItemChangeBus.emit(['click', menuItemElement]);
98
+ AppMenuItemView.#menuItemChangeBus.emit([
99
+ 'route-activated',
100
+ menuItemElement,
101
+ ]);
90
102
  }
91
103
  });
92
104
  }
93
105
  static {
94
- (async () => {
106
+ (async function init() {
95
107
  const gmailAppMenu = await GmailElementGetter.getAppMenuAsync();
96
108
  if (!gmailAppMenu) {
97
109
  return;
@@ -155,6 +167,28 @@ export class AppMenuItemView extends EventEmitter {
155
167
  AppMenuItemView.#menuItemChangeStream.onValue(async (v) => {
156
168
  const [type, menuItem, mouseEvent] = v;
157
169
  const { ACTIVE, HOVER } = GmailAppMenuItemView.elementCss;
170
+ function handleActivate() {
171
+ const appMenuElement = GmailElementGetter.getAppMenuContainer();
172
+ // deactivate active panel
173
+ const activePanel = AppMenuItemView.#getActivePanel();
174
+ if (activePanel) {
175
+ activePanel.style.removeProperty('height');
176
+ activePanel.classList.remove(CollapsiblePanelView.elementCss.ACTIVE);
177
+ activePanel.classList.remove(CollapsiblePanelView.elementCss.HOVER);
178
+ }
179
+ // deactivate menu items
180
+ for (const menuItem_ of appMenuElement?.querySelectorAll(`.${NATIVE_CLASS}`) ?? []) {
181
+ menuItem_.classList.remove(ACTIVE);
182
+ menuItem_.classList.remove(HOVER);
183
+ }
184
+ // activate menu item
185
+ menuItem.classList.add(ACTIVE);
186
+ // activate panel
187
+ const panel = AppMenuItemView.#menuItemToPanelMap.get(menuItem);
188
+ if (panel) {
189
+ panel.classList.add(CollapsiblePanelView.elementCss.ACTIVE);
190
+ }
191
+ }
158
192
  switch (type) {
159
193
  case 'mouseenter': {
160
194
  const panel = AppMenuItemView.#menuItemToPanelMap.get(menuItem);
@@ -226,26 +260,19 @@ export class AppMenuItemView extends EventEmitter {
226
260
  break;
227
261
  }
228
262
  case 'click': {
229
- const appMenuElement = GmailElementGetter.getAppMenuContainer();
230
- // deactivate active panel
231
- const activePanel = AppMenuItemView.#getActivePanel();
232
- if (activePanel) {
233
- activePanel.style.removeProperty('height');
234
- activePanel.classList.remove(CollapsiblePanelView.elementCss.ACTIVE);
235
- activePanel.classList.remove(CollapsiblePanelView.elementCss.HOVER);
236
- }
237
- // deactivate menu items
238
- for (const menuItem_ of appMenuElement?.querySelectorAll(`.${NATIVE_CLASS}`) ?? []) {
239
- menuItem_.classList.remove(ACTIVE);
240
- menuItem_.classList.remove(HOVER);
241
- }
242
- // activate menu item
243
- menuItem.classList.add(ACTIVE);
244
- // activate panel
245
- const panel = AppMenuItemView.#menuItemToPanelMap.get(menuItem);
246
- if (panel) {
247
- panel.classList.add(CollapsiblePanelView.elementCss.ACTIVE);
263
+ handleActivate();
264
+ // handle panel-less mode
265
+ const isPanelLess = AppMenuItemView.#isPanelLess();
266
+ for (const panel of document.querySelectorAll(CollapsiblePanelView.elementSelectors.NATIVE) ?? []) {
267
+ panel.classList.toggle(CollapsiblePanelView.elementCss.PANEL_LESS, isPanelLess);
248
268
  }
269
+ GmailElementGetter.getAppMenu()?.classList.toggle('aTO', isPanelLess);
270
+ GmailElementGetter.getAppHeader()?.classList.toggle('aTO', isPanelLess);
271
+ break;
272
+ }
273
+ case 'route-activated': {
274
+ handleActivate();
275
+ break;
249
276
  }
250
277
  }
251
278
  });
@@ -273,7 +300,6 @@ export class AppMenuItemView extends EventEmitter {
273
300
  AppMenuItemView.#menuItemToPanelMap.set(gmailElement, undefined);
274
301
  }
275
302
  gmailView.on('destroy', () => {
276
- AppMenuItemView.#menuItemChangeBus.end();
277
303
  this.remove();
278
304
  });
279
305
  gmailView.on('click', () => {
@@ -302,7 +328,14 @@ export class AppMenuItemView extends EventEmitter {
302
328
  AppMenuItemView.#appMenuItemViews.add(this);
303
329
  }
304
330
  async addCollapsiblePanel(panelDescriptor) {
305
- const collapsiblePanel = await addCollapsiblePanel(this.#driver, panelDescriptor);
331
+ const descriptor = {
332
+ ...panelDescriptor,
333
+ className: cx(panelDescriptor.className, {
334
+ [CollapsiblePanelView.elementCss.COLLAPSED]: !GmailElementGetter.isAppBurgerMenuOpen(),
335
+ [CollapsiblePanelView.elementCss.PANEL_LESS]: AppMenuItemView.#isPanelLess(),
336
+ }),
337
+ };
338
+ const collapsiblePanel = await addCollapsiblePanel(this.#driver, descriptor);
306
339
  if (collapsiblePanel) {
307
340
  this.#gmailViewPromise.then((gmailView) => {
308
341
  const gmailElement = gmailView.element;
@@ -23,16 +23,17 @@ export declare class CollapsiblePanelView extends CollapsiblePanelView_base {
23
23
  /** A hover popover has both ACTIVE _and_ HOVER */
24
24
  readonly HOVER: "aJu";
25
25
  readonly COLLAPSED_HOVER: "bym";
26
+ readonly PANEL_LESS: "a3W";
26
27
  };
27
- get element(): HTMLElement | undefined;
28
+ get loading(): boolean;
29
+ setLoading(loading: boolean): void;
30
+ get panelDescriptor(): AppMenuItemPanelDescriptor;
28
31
  set panelDescriptor(panelDescriptor: AppMenuItemPanelDescriptor);
29
- constructor(driver: GmailDriver);
30
- /**
31
- * @internal
32
- */
33
- activate(): void;
32
+ get element(): HTMLElement;
33
+ get scrollablePaneElement(): Element | null;
34
+ constructor(driver: GmailDriver, panelDescriptor: AppMenuItemPanelDescriptor);
34
35
  remove(): void;
35
- addNavItem(navItemDescriptor: NavItemDescriptor | Kefir.Observable<NavItemDescriptor, any>): NavItemView | undefined;
36
+ addNavItem(navItemDescriptor: NavItemDescriptor | Kefir.Observable<NavItemDescriptor, any>): NavItemView;
36
37
  }
37
38
  export {};
38
39
  //# sourceMappingURL=collapsible-panel-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collapsible-panel-view.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/views/collapsible-panel-view.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAIpE,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,eAAO,MAAM,YAAY,OAAiB,CAAC;AAC3C,eAAO,MAAM,cAAc,8BAAwC,CAAC;AAQpE,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CAC/B,CAAC;mDAEmE,aAAa,aAAa,CAAC;AAAhG,qBAAa,oBAAqB,SAAQ,yBAAuD;;IAC/F,MAAM,CAAC,gBAAgB;;;MAGZ;IACX,MAAM,CAAC,UAAU;;;QAGf,kDAAkD;;;MAGzC;IAQX,IAAI,OAAO,4BAEV;IAED,IAAI,eAAe,CAAC,eAAe,EAAE,0BAA0B,EAG9D;gBAEW,MAAM,EAAE,WAAW;IAS/B;;OAEG;IACH,QAAQ;IAQR,MAAM;IAON,UAAU,CACR,iBAAiB,EACb,iBAAiB,GACjB,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC;CAkK/C"}
1
+ {"version":3,"file":"collapsible-panel-view.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/views/collapsible-panel-view.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAIpE,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,eAAO,MAAM,YAAY,OAAiB,CAAC;AAC3C,eAAO,MAAM,cAAc,8BAAwC,CAAC;AAapE,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;CAC/B,CAAC;mDAEmE,aAAa,aAAa,CAAC;AAAhG,qBAAa,oBAAqB,SAAQ,yBAAuD;;IAC/F,MAAM,CAAC,gBAAgB;;;MAGZ;IACX,MAAM,CAAC,UAAU;;;QAGf,kDAAkD;;;;MAIzC;IASX,IAAI,OAAO,YAEV;IAED,UAAU,CAAC,OAAO,EAAE,OAAO;IAS3B,IAAI,eAAe,IAIkB,0BAA0B,CAF9D;IAED,IAAI,eAAe,CAAC,eAAe,EAAE,0BAA0B,EAG9D;IAED,IAAI,OAAO,gBAEV;IAED,IAAI,qBAAqB,mBAExB;gBAGC,MAAM,EAAE,WAAW,EACnB,eAAe,EAAE,0BAA0B;IAY7C,MAAM;IAON,UAAU,CACR,iBAAiB,EACb,iBAAiB,GACjB,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC;CAsL/C"}
@@ -11,6 +11,10 @@ export const INBOXSDK_CLASS = 'inboxsdk__collapsiblePanel';
11
11
  const ELEMENT_CLASS = `${NATIVE_CLASS} ${INBOXSDK_CLASS} oy8Mbf`;
12
12
  const PRIMARY_BUTTON_ELEMENT_CLASS = 'T-I T-I-KE L3';
13
13
  const PRIMARY_BUTTON_ELEMENT_SELECTOR = '.T-I.T-I-KE.L3';
14
+ const scrollablePanelClass = 'at9';
15
+ const scrollablePanelSelector = `.${scrollablePanelClass}`;
16
+ const loadingElementClass = 'inboxsdk__collapsiblePanel_loading_container';
17
+ const loadingElementSelector = `.${loadingElementClass}`;
14
18
  const NAV_MENU_CONTAINER_ELEMENT_SELECTOR = '.at9 .n3 .TK';
15
19
  export class CollapsiblePanelView extends EventEmitter {
16
20
  static elementSelectors = {
@@ -23,6 +27,7 @@ export class CollapsiblePanelView extends EventEmitter {
23
27
  /** A hover popover has both ACTIVE _and_ HOVER */
24
28
  HOVER: 'aJu',
25
29
  COLLAPSED_HOVER: 'bym',
30
+ PANEL_LESS: 'a3W',
26
31
  };
27
32
  #panelDescriptor;
28
33
  #element;
@@ -30,42 +35,50 @@ export class CollapsiblePanelView extends EventEmitter {
30
35
  #id = Math.random().toFixed(3);
31
36
  #ARIA_LABELLED_BY_ID = Math.random().toFixed(3);
32
37
  #driver;
33
- get element() {
34
- return this.#element;
38
+ #loading;
39
+ get loading() {
40
+ return this.#loading;
41
+ }
42
+ setLoading(loading) {
43
+ const changed = this.#loading !== loading;
44
+ this.#loading = loading;
45
+ if (changed) {
46
+ this.#update();
47
+ }
48
+ }
49
+ get panelDescriptor() {
50
+ return this.#panelDescriptor;
35
51
  }
36
52
  set panelDescriptor(panelDescriptor) {
37
53
  this.#panelDescriptor = panelDescriptor;
38
54
  this.#update();
39
55
  }
40
- constructor(driver) {
56
+ get element() {
57
+ return this.#element;
58
+ }
59
+ get scrollablePaneElement() {
60
+ return this.element.querySelector(scrollablePanelSelector);
61
+ }
62
+ constructor(driver, panelDescriptor) {
41
63
  super();
42
64
  this.#driver = driver;
65
+ this.#panelDescriptor = panelDescriptor;
66
+ this.#loading = panelDescriptor.loadingIcon != null;
43
67
  this.#element = this.#setupElement();
44
68
  this.#element.addEventListener('mouseleave', (e) => {
45
69
  this.emit('blur', e);
46
70
  });
47
71
  }
48
- /**
49
- * @internal
50
- */
51
- activate() {
52
- const element = this.element;
53
- if (!element)
54
- return;
55
- element?.classList.remove(CollapsiblePanelView.elementCss.HOVER);
56
- element.classList.add(CollapsiblePanelView.elementCss.ACTIVE);
57
- }
58
72
  remove() {
59
73
  if (this.#destroyed)
60
74
  return;
61
75
  this.#destroyed = true;
62
- this.element?.remove();
76
+ this.element.remove();
63
77
  this.emit('destroy');
64
78
  }
65
79
  addNavItem(navItemDescriptor) {
66
- const element = this.element;
67
- if (!element)
68
- return;
80
+ this.setLoading(false);
81
+ const { element } = this;
69
82
  const navMenuContainerElement = querySelector(element, NAV_MENU_CONTAINER_ELEMENT_SELECTOR);
70
83
  const appId = `collapsible-panel-${this.#id}`;
71
84
  const navItemDescriptorPropertyStream = kefirCast(Kefir, navItemDescriptor).toProperty();
@@ -74,12 +87,11 @@ export class CollapsiblePanelView extends EventEmitter {
74
87
  return navItemView;
75
88
  }
76
89
  #setupElement() {
77
- const { iconUrl: themedIcons, className, name = '', } = this.#panelDescriptor?.primaryButton ?? {};
90
+ const { panelDescriptor } = this;
91
+ const { loadingIcon } = panelDescriptor;
92
+ const { iconUrl: themedIcons, className, name = '', } = panelDescriptor?.primaryButton ?? {};
78
93
  const element = document.createElement('div');
79
- const burgerMenuOpen = GmailElementGetter.isAppBurgerMenuOpen();
80
- element.className = cx(ELEMENT_CLASS, {
81
- [CollapsiblePanelView.elementCss.COLLAPSED]: !burgerMenuOpen,
82
- });
94
+ element.className = cx(ELEMENT_CLASS, this.panelDescriptor.className);
83
95
  const primaryButtonClass = cx(PRIMARY_BUTTON_ELEMENT_CLASS, className);
84
96
  let iconUrl;
85
97
  if (themedIcons) {
@@ -99,7 +111,8 @@ export class CollapsiblePanelView extends EventEmitter {
99
111
  </div>
100
112
  </div>
101
113
  </div>
102
- <div class="at9">
114
+ <div class="${scrollablePanelClass}">
115
+ <div class="${loadingElementClass}">${loadingIcon ? { __html: loadingIcon } : ''}</div>
103
116
  <div class="Ls77Lb aZ6">
104
117
  <div class="pp" style="user-select: none;">
105
118
  <div>
@@ -131,25 +144,21 @@ export class CollapsiblePanelView extends EventEmitter {
131
144
  return element;
132
145
  }
133
146
  #onPrimaryButtonClick = (e) => {
134
- this.#panelDescriptor?.primaryButton?.onClick?.(e);
147
+ this.panelDescriptor.primaryButton?.onClick?.(e);
135
148
  };
136
149
  #update() {
137
150
  const element = this.element;
138
151
  if (!element)
139
152
  return;
140
- const { ACTIVE, COLLAPSED } = CollapsiblePanelView.elementCss;
141
- const isActive = element.classList.contains(ACTIVE);
142
- const isCollapsed = element.classList.contains(COLLAPSED);
143
- element.className = cx(ELEMENT_CLASS, this.#panelDescriptor?.className, {
144
- [ACTIVE]: isActive,
145
- [COLLAPSED]: isCollapsed,
146
- });
153
+ const existingClassNames = Object.values(CollapsiblePanelView.elementCss).filter((className) => element.classList.contains(className));
154
+ element.className = cx(ELEMENT_CLASS, this.panelDescriptor.className, ...existingClassNames);
147
155
  this.#updateName(element);
148
156
  this.#updateIcon(element);
157
+ this.#updateScrollablePanelLoading(element);
149
158
  }
150
159
  #updateIcon(element) {
151
160
  const iconContainerEl = querySelector(element, PRIMARY_BUTTON_ELEMENT_SELECTOR);
152
- const { iconUrl, className } = this.#panelDescriptor?.primaryButton ?? {};
161
+ const { iconUrl, className } = this.panelDescriptor.primaryButton ?? {};
153
162
  if (iconUrl) {
154
163
  const backgroundImage = `url(${GmailElementGetter.isDarkTheme()
155
164
  ? iconUrl.darkTheme
@@ -166,6 +175,19 @@ export class CollapsiblePanelView extends EventEmitter {
166
175
  if (!buttonTextEl) {
167
176
  return;
168
177
  }
169
- buttonTextEl.textContent = this.#panelDescriptor?.primaryButton?.name ?? '';
178
+ buttonTextEl.textContent = this.panelDescriptor.primaryButton?.name ?? '';
179
+ }
180
+ #updateScrollablePanelLoading(element) {
181
+ const scrollablePanelLoadingEl = element.querySelector(loadingElementSelector);
182
+ if (!scrollablePanelLoadingEl) {
183
+ return;
184
+ }
185
+ const panelLoadingClass = `${loadingElementClass}--active`;
186
+ if (this.loading) {
187
+ scrollablePanelLoadingEl.classList.add(panelLoadingClass);
188
+ }
189
+ else {
190
+ scrollablePanelLoadingEl.classList.remove(panelLoadingClass);
191
+ }
170
192
  }
171
193
  }