@forge/bridge 2.1.2 → 2.2.0-next.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @forge/bridge
2
2
 
3
+ ## 2.2.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6fe60823: Ability to disable close on escape and overlay click for modals
8
+
9
+ ## 2.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 7c11b22: Improve error message for when the Custom UI bridge is not available
14
+
15
+ ## 2.1.3-next.0
16
+
17
+ ### Patch Changes
18
+
19
+ - 7c11b22: Improve error message for when the Custom UI bridge is not available
20
+
3
21
  ## 2.1.2
4
22
 
5
23
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAAO,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAE/D,CAAC"}
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,QAAO,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAS/D,CAAC"}
package/out/bridge.js CHANGED
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCallBridge = void 0;
4
+ const errors_1 = require("./errors");
5
+ function isBridgeAvailable(bridge) {
6
+ return !!(bridge === null || bridge === void 0 ? void 0 : bridge.callBridge);
7
+ }
4
8
  exports.getCallBridge = () => {
9
+ if (!isBridgeAvailable(window.__bridge)) {
10
+ throw new errors_1.BridgeAPIError(`
11
+ Unable to establish a connection with the Custom UI bridge.
12
+ If you are trying to run your app locally, Forge apps only work in the context of Atlassian products. Refer to https://go.atlassian.com/forge-tunneling-with-custom-ui for how to tunnel when using a local development server.
13
+ `);
14
+ }
5
15
  return window.__bridge.callBridge;
6
16
  };
@@ -3,12 +3,16 @@ export interface ModalOptions {
3
3
  onClose?: (payload: any) => any;
4
4
  size?: string;
5
5
  context?: any;
6
+ closeOnEscape?: boolean;
7
+ closeOnOverlayClick?: boolean;
6
8
  }
7
9
  export declare class Modal {
8
10
  resource: string | null;
9
11
  onClose: NonNullable<ModalOptions['onClose']>;
10
12
  size: string;
11
13
  context: any;
14
+ closeOnEscape: boolean;
15
+ closeOnOverlayClick: boolean;
12
16
  constructor(opts?: ModalOptions);
13
17
  open(): Promise<void>;
14
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAKD,qBAAa,KAAK;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;gBACD,IAAI,CAAC,EAAE,YAAY;IAOzB,IAAI;CAgBX"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/modal/modal.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAKD,qBAAa,KAAK;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;gBACjB,IAAI,CAAC,EAAE,YAAY;IASzB,IAAI;CAkBX"}
@@ -8,10 +8,13 @@ const callBridge = bridge_1.getCallBridge();
8
8
  const noop = () => { };
9
9
  class Modal {
10
10
  constructor(opts) {
11
+ var _a, _b;
11
12
  this.resource = (opts === null || opts === void 0 ? void 0 : opts.resource) || null;
12
13
  this.onClose = (opts === null || opts === void 0 ? void 0 : opts.onClose) || noop;
13
14
  this.size = (opts === null || opts === void 0 ? void 0 : opts.size) || 'medium';
14
15
  this.context = (opts === null || opts === void 0 ? void 0 : opts.context) || {};
16
+ this.closeOnEscape = (_a = opts === null || opts === void 0 ? void 0 : opts.closeOnEscape) !== null && _a !== void 0 ? _a : true;
17
+ this.closeOnOverlayClick = (_b = opts === null || opts === void 0 ? void 0 : opts.closeOnOverlayClick) !== null && _b !== void 0 ? _b : true;
15
18
  }
16
19
  open() {
17
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -20,7 +23,9 @@ class Modal {
20
23
  resource: this.resource,
21
24
  onClose: this.onClose,
22
25
  size: this.size,
23
- context: this.context
26
+ context: this.context,
27
+ closeOnEscape: this.closeOnEscape,
28
+ closeOnOverlayClick: this.closeOnOverlayClick
24
29
  });
25
30
  if (success === false) {
26
31
  throw new errors_1.BridgeAPIError('Unable to open modal.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bridge",
3
- "version": "2.1.2",
3
+ "version": "2.2.0-next.0",
4
4
  "description": "Forge bridge API for custom UI apps",
5
5
  "author": "Atlassian",
6
6
  "license": "UNLICENSED",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "history": "4.10.1",
19
- "jest-date-mock": "^1.0.8",
20
- "isomorphic-fetch": "^3.0.0"
19
+ "isomorphic-fetch": "^3.0.0",
20
+ "jest-date-mock": "^1.0.8"
21
21
  }
22
22
  }