@notabene/javascript-sdk 2.0.0-next.10 → 2.0.0-next.12

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/dist/notabene.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var d = Object.defineProperty;
2
- var c = (r, e, t) => e in r ? d(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var n = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
4
- var a = /* @__PURE__ */ ((r) => (r.COMPLETE = "complete", r.RESIZE = "resize", r.RESULT = "result", r.READY = "ready", r.INVALID = "invalid", r.MODAL = "openModal", r.ERROR = "error", r.CLOSE = "closeModal", r.CANCEL = "cancel", r))(a || {}), l = /* @__PURE__ */ ((r) => (r.UPDATE = "update", r.REQUEST_RESPONSE = "requestResponse", r))(l || {});
2
+ var c = (o, e, t) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var n = (o, e, t) => c(o, typeof e != "symbol" ? e + "" : e, t);
4
+ var a = /* @__PURE__ */ ((o) => (o.COMPLETE = "complete", o.RESIZE = "resize", o.RESULT = "result", o.READY = "ready", o.INVALID = "invalid", o.MODAL = "openModal", o.ERROR = "error", o.CLOSE = "closeModal", o.CANCEL = "cancel", o))(a || {}), l = /* @__PURE__ */ ((o) => (o.UPDATE = "update", o.REQUEST_RESPONSE = "requestResponse", o))(l || {});
5
5
  class m {
6
6
  constructor() {
7
7
  n(this, "listeners", /* @__PURE__ */ new Map());
@@ -22,8 +22,8 @@ class m {
22
22
  console.log("received message", e.data);
23
23
  const t = e.data;
24
24
  if (typeof t == "object" && t !== null && "type" in t) {
25
- const s = t.type, o = this.listeners.get(s);
26
- o && o.forEach((i) => i(t));
25
+ const s = t.type, r = this.listeners.get(s);
26
+ r && r.forEach((i) => i(t));
27
27
  }
28
28
  }
29
29
  // Method to send messages through the port
@@ -32,14 +32,17 @@ class m {
32
32
  }
33
33
  }
34
34
  class u {
35
- // private popup?: HTMLElement;
35
+ /**
36
+ * Creates an instance of EmbeddedComponent.
37
+ * @param url - The URL of the embedded component
38
+ * @param value - The initial transaction value
39
+ */
36
40
  constructor(e, t) {
37
41
  n(this, "_url");
38
42
  n(this, "_value");
39
43
  n(this, "_errors", []);
40
44
  n(this, "iframe");
41
45
  n(this, "eventManager");
42
- n(this, "ready", !1);
43
46
  n(this, "modal");
44
47
  this._url = e, this._value = t, this.eventManager = new m(), this.on(a.INVALID, (s) => {
45
48
  s.type === a.INVALID && (this._errors = s.errors, this._value = s.value);
@@ -47,57 +50,98 @@ class u {
47
50
  s.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${s.height}px`);
48
51
  });
49
52
  }
53
+ /**
54
+ * Gets the URL of the embedded component
55
+ * @returns The URL of the embedded component
56
+ */
50
57
  get url() {
51
58
  return this._url;
52
59
  }
60
+ /**
61
+ * Gets the current transaction value
62
+ * @returns The current transaction value
63
+ */
53
64
  get value() {
54
65
  return this._value;
55
66
  }
56
67
  get errors() {
57
68
  return this._errors;
58
69
  }
70
+ /**
71
+ * Opens the component URL in the current window
72
+ */
59
73
  open() {
60
74
  document.location.href = this.url;
61
75
  }
76
+ /**
77
+ * Mounts the component to a parent element
78
+ * @param parentId - The ID of the parent element
79
+ * @throws Will throw an error if the parent element is not found
80
+ */
62
81
  mount(e) {
63
82
  const t = document.querySelector(e);
64
83
  if (!t) throw new Error(`parentID ${e} not found`);
65
84
  this.embed(t);
66
85
  }
86
+ /**
87
+ * Embeds the component into a parent element
88
+ * @param parent - The parent element to embed the component into
89
+ */
67
90
  embed(e) {
68
91
  var t, s;
69
- this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", this.iframe.setAttribute("allowtransparency", "true"), this.iframe.style.backgroundColor = "transparent", e.appendChild(this.iframe), window.addEventListener("message", (o) => {
92
+ this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (r) => {
70
93
  var i, h;
71
- o.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", o.data), (h = this.eventManager) == null || h.setPort(o.ports[0]), this.ready = !0);
94
+ r.source === ((i = this.iframe) == null ? void 0 : i.contentWindow) && (console.log("received message from iframe", r.data), (h = this.eventManager) == null || h.setPort(r.ports[0]));
72
95
  }), (s = (t = this.iframe) == null ? void 0 : t.contentWindow) == null || s.focus();
73
96
  }
97
+ /**
98
+ * Sends a message to the embedded component
99
+ * @param message - The message to send
100
+ */
74
101
  send(e) {
75
102
  this.eventManager.send(e);
76
103
  }
104
+ /**
105
+ * Adds an event listener for a specific message type
106
+ * @param messageType - The type of message to listen for
107
+ * @param callback - The callback function to execute when the message is received
108
+ */
77
109
  on(e, t) {
78
110
  this.eventManager.on(e, t);
79
111
  }
112
+ /**
113
+ * Removes an event listener for a specific message type
114
+ * @param messageType - The type of message to stop listening for
115
+ * @param callback - The callback function to remove
116
+ */
80
117
  off(e, t) {
81
118
  this.eventManager.off(e, t);
82
119
  }
120
+ /**
121
+ * Updates the transaction value and sends an update message to the component
122
+ * @param value - The new transaction value
123
+ */
83
124
  update(e) {
84
125
  this._value = e, this.send({ type: l.UPDATE, value: e });
85
126
  }
127
+ /**
128
+ * Waits for the component to complete and returns the transaction response
129
+ * @returns A promise that resolves with the transaction response
130
+ */
86
131
  completion() {
87
132
  return new Promise((e, t) => {
88
- this.closeModal(), this.on(a.COMPLETE, (s) => {
133
+ this.on(a.COMPLETE, (s) => {
89
134
  e(s.response);
90
135
  }), this.on("error", (s) => {
91
136
  t(new Error(s.message));
92
137
  });
93
138
  });
94
139
  }
95
- // popup(): void {
96
- // this.popup = document.createElement('div');
97
- // this.popup.style;
98
- // }
140
+ /**
141
+ * Opens the component in a modal dialog
142
+ */
99
143
  openModal() {
100
- this.modal && this.closeModal(), this.modal = document.createElement("dialog"), document.body.appendChild(this.modal), this.embed(this.modal), this.on(a.CANCEL, () => {
144
+ return this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "transparent", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "800px", document.body.appendChild(this.modal), this.embed(this.modal), this.on(a.CANCEL, () => {
101
145
  this.closeModal();
102
146
  }), this.on(a.CLOSE, () => {
103
147
  this.closeModal();
@@ -105,23 +149,32 @@ class u {
105
149
  this.closeModal();
106
150
  }), this.modal.showModal(), this.modal.addEventListener("click", () => {
107
151
  this.closeModal();
108
- });
152
+ }), this.completion();
109
153
  }
154
+ /**
155
+ * Closes the modal dialog
156
+ *
157
+ */
110
158
  closeModal() {
111
159
  var e;
112
160
  this.modal && (console.log("closeModal"), (e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
113
161
  }
114
162
  }
115
- function f(r) {
116
- return Object.entries(r).map(([e, t]) => {
163
+ function f(o) {
164
+ return Object.entries(o).map(([e, t]) => {
117
165
  if (!(e && t)) return;
118
- const s = encodeURIComponent(e), o = encodeURIComponent(
166
+ const s = encodeURIComponent(e), r = encodeURIComponent(
119
167
  typeof t == "object" ? JSON.stringify(t) : t
120
168
  );
121
- return `${s}=${o}`;
169
+ return `${s}=${r}`;
122
170
  }).filter((e) => !!e).join("&");
123
171
  }
124
172
  class E {
173
+ /**
174
+ * Creates a new instance of the Notabene SDK
175
+ *
176
+ * @param config - Configuration options for the Notabene SDK
177
+ */
125
178
  constructor(e) {
126
179
  n(this, "nodeUrl");
127
180
  n(this, "authToken");
@@ -130,7 +183,17 @@ class E {
130
183
  n(this, "locale");
131
184
  this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
132
185
  }
133
- componentUrl(e, t, s, o) {
186
+ /**
187
+ * Generates a URL for a Notabene component
188
+ *
189
+ * @param path - The path of the component
190
+ * @param value - Transaction data
191
+ * @param configuration - Optional transaction configuration
192
+ * @param callbacks - Optional callback configuration
193
+ * @returns component URL
194
+ * @internal
195
+ */
196
+ componentUrl(e, t, s, r) {
134
197
  const i = new URL(this.uxUrl);
135
198
  i.pathname = e;
136
199
  const h = f({
@@ -138,30 +201,90 @@ class E {
138
201
  value: t,
139
202
  configuration: s
140
203
  });
141
- return i.hash = h, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), o && (o.callback && i.searchParams.set("callback_url", o.callback), o.redirectUri && i.searchParams.set("redirect_uri", o.redirectUri)), i.toString();
204
+ return i.hash = h, this.nodeUrl && i.searchParams.set("nodeUrl", this.nodeUrl), this.theme && i.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && i.searchParams.set("locale", this.locale), r && (r.callback && i.searchParams.set("callback_url", r.callback), r.redirectUri && i.searchParams.set("redirect_uri", r.redirectUri)), i.toString();
142
205
  }
143
- createComponent(e, t, s, o) {
206
+ /**
207
+ * Creates a new embedded component
208
+ *
209
+ * @param path - The path of the component
210
+ * @param value - Transaction data
211
+ * @param options - Optional transaction options
212
+ * @param callbacks - Optional callback configuration
213
+ * @returns A new EmbeddedComponent instance
214
+ * @internal
215
+ */
216
+ createComponent(e, t, s, r) {
144
217
  return new u(
145
- this.componentUrl(e, t, s, o),
218
+ this.componentUrl(e, t, s, r),
146
219
  t
147
220
  );
148
221
  }
222
+ /**
223
+ * Creates a withdrawal assist component
224
+ *
225
+ * @param value - Withdrawal transaction data
226
+ * @param options - Optional transaction options
227
+ * @param callbacks - Optional callback configuration
228
+ * @returns A new EmbeddedComponent instance for withdrawal assistance
229
+ */
149
230
  createWithdrawalAssist(e, t, s) {
150
231
  return this.createComponent("withdrawal-assist", e, t, s);
151
232
  }
233
+ /**
234
+ * Creates a deposit assist component
235
+ *
236
+ * @param value - Deposit transaction data
237
+ * @param options - Optional transaction options
238
+ * @param callbacks - Optional callback configuration
239
+ * @returns A new EmbeddedComponent instance for deposit assistance
240
+ * @alpha
241
+ */
152
242
  createDepositAssist(e, t, s) {
153
- return this.createComponent("deposit-assist", e, t, s);
243
+ return this.createComponent(
244
+ "deposit-assist",
245
+ e,
246
+ t,
247
+ s
248
+ );
154
249
  }
155
- createConnect(e, t, s) {
156
- return this.createComponent("connect", e, t, s);
250
+ /**
251
+ * Creates a connect component
252
+ *
253
+ * @param value - Connection request data
254
+ * @param options - Optional transaction options
255
+ * @param callbacks - Optional callback configuration
256
+ * @returns A new EmbeddedComponent instance for connection
257
+ */
258
+ createConnectWallet(e, t, s) {
259
+ return this.createComponent(
260
+ "connect",
261
+ e,
262
+ t,
263
+ s
264
+ );
157
265
  }
266
+ /**
267
+ * Creates a deposit request component
268
+ *
269
+ * @param value - Deposit request data
270
+ * @param options - Optional transaction options
271
+ * @param callbacks - Optional callback configuration
272
+ * @returns A new EmbeddedComponent instance for deposit requests
273
+ * @alpha
274
+ */
158
275
  createDepositRequest(e, t, s) {
159
276
  return this.createComponent("deposit-request", e, t, s);
160
277
  }
278
+ /**
279
+ * Decodes a URL fragment into an object
280
+ *
281
+ * @param fragment - The URL fragment to decode
282
+ * @returns An object containing the decoded key-value pairs
283
+ */
161
284
  decodeFragmentToObject(e) {
162
285
  return e.slice(1).split("&").reduce(
163
- (s, o) => {
164
- const [i, h] = o.split("=");
286
+ (s, r) => {
287
+ const [i, h] = r.split("=");
165
288
  return s[decodeURIComponent(i)] = decodeURIComponent(h), s;
166
289
  },
167
290
  {}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.7"
8
+ "packageVersion": "7.47.9"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "author": "Notabene <developers@notabene.id>",
11
11
  "license": "MIT",
12
- "version": "2.0.0-next.10",
12
+ "version": "2.0.0-next.12",
13
13
  "source": "src/notabene.ts",
14
14
  "main": "dist/notabene.js",
15
15
  "types": "dist/notabene.d.ts",
@@ -21,44 +21,48 @@
21
21
  "README.md"
22
22
  ],
23
23
  "scripts": {
24
+ "docs": "typedoc --options typedoc.json",
24
25
  "prepare": "husky install",
25
26
  "dev": "vite",
26
27
  "preview": "vite preview",
27
28
  "watch": "parcel watch",
28
29
  "build:dev": "yarn build && yarn dev",
29
30
  "build:clean": "rimraf dist/ ts-out",
30
- "build": "vite build && tsc && api-extractor run",
31
+ "build": "yarn lint && vite build && tsc && api-extractor run && yarn docs ",
31
32
  "lint": "eslint .",
32
33
  "test": "vitest",
33
34
  "release": "semantic-release",
34
35
  "publish": "yarn build && npm publish --tag next"
35
36
  },
36
37
  "devDependencies": {
37
- "@commitlint/cli": "^19.4.0",
38
- "@commitlint/config-conventional": "^19.2.2",
39
- "@eslint/js": "^9.7.0",
40
- "@fast-check/vitest": "^0.1.2",
41
- "@microsoft/api-extractor": "^7.47.7",
38
+ "@commitlint/cli": "^19.5.0",
39
+ "@commitlint/config-conventional": "^19.5.0",
40
+ "@eslint/js": "^9.10.0",
41
+ "@fast-check/vitest": "^0.1.3",
42
+ "@microsoft/api-extractor": "^7.47.9",
42
43
  "@semantic-release/git": "^10.0.1",
43
- "@semantic-release/gitlab": "^9.3.0",
44
- "@semantic-release/npm": "^9.0.1",
45
- "@typescript-eslint/eslint-plugin": "^8.2.0",
46
- "@typescript-eslint/parser": "^8.2.0",
47
- "eslint": "^9.9.0",
44
+ "@semantic-release/gitlab": "^9.5.1",
45
+ "@semantic-release/npm": "^9.0.2",
46
+ "@typescript-eslint/eslint-plugin": "^8.6.0",
47
+ "@typescript-eslint/parser": "^8.6.0",
48
+ "eslint": "^9.10.0",
48
49
  "eslint-config-prettier": "^9.1.0",
49
50
  "eslint-plugin-prettier": "^5.2.1",
50
- "fast-check": "^3.20.0",
51
- "globals": "^15.8.0",
51
+ "fast-check": "^3.22.0",
52
+ "globals": "^15.9.0",
52
53
  "husky": "^7.0.4",
53
- "lint-staged": "^12.3.4",
54
+ "jsdom": "^25.0.0",
55
+ "lint-staged": "^12.5.0",
54
56
  "organize-imports-cli": "^0.9.0",
55
57
  "prettier": "^3.3.3",
56
58
  "rimraf": "^6.0.1",
57
- "semantic-release": "^24.1.0",
58
- "typescript": "^5.5.4",
59
- "typescript-eslint": "^8.2.0",
60
- "vite": "^5.4.2",
61
- "vitest": "^2.0.5"
59
+ "semantic-release": "^24.1.1",
60
+ "typedoc": "^0.26.7",
61
+ "typedoc-plugin-markdown": "^4.2.7",
62
+ "typescript": "^5.6.2",
63
+ "typescript-eslint": "^8.6.0",
64
+ "vite": "^5.4.6",
65
+ "vitest": "^2.1.1"
62
66
  },
63
67
  "lint-staged": {
64
68
  "*.ts": [
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  CMType,
3
+ ComponentRequest,
3
4
  HMType,
4
5
  HostMessage,
5
- Transaction,
6
- TransactionResponse,
7
6
  ValidationError,
8
7
  } from '../types';
9
8
  import {
@@ -15,25 +14,30 @@ import {
15
14
  * An embedded Notabene component
16
15
  * @public
17
16
  */
18
- export default class EmbeddedComponent {
17
+
18
+ export default class EmbeddedComponent<V, R> {
19
19
  private _url: string;
20
- private _value: Partial<Transaction>;
20
+ private _value: V;
21
21
  private _errors: ValidationError[] = [];
22
22
 
23
23
  private iframe?: HTMLIFrameElement;
24
24
  private eventManager: MessageEventManager;
25
- private ready = false;
26
25
  private modal?: HTMLDialogElement;
27
- // private popup?: HTMLElement;
28
26
 
29
- constructor(url: string, value: Partial<Transaction>) {
27
+ /**
28
+ * Creates an instance of EmbeddedComponent.
29
+ * @param url - The URL of the embedded component
30
+ * @param value - The initial transaction value
31
+ */
32
+
33
+ constructor(url: string, value: V) {
30
34
  this._url = url;
31
35
  this._value = value;
32
36
  this.eventManager = new MessageEventManager();
33
37
  this.on(CMType.INVALID, (message) => {
34
38
  if (message.type === CMType.INVALID) {
35
39
  this._errors = message.errors;
36
- this._value = message.value as Transaction;
40
+ this._value = message.value as V;
37
41
  }
38
42
  });
39
43
  this.on(CMType.RESIZE, (message) => {
@@ -42,12 +46,20 @@ export default class EmbeddedComponent {
42
46
  }
43
47
  });
44
48
  }
49
+ /**
50
+ * Gets the URL of the embedded component
51
+ * @returns The URL of the embedded component
52
+ */
45
53
 
46
54
  public get url(): string {
47
55
  return this._url;
48
56
  }
57
+ /**
58
+ * Gets the current transaction value
59
+ * @returns The current transaction value
60
+ */
49
61
 
50
- public get value(): Partial<Transaction> {
62
+ public get value(): V {
51
63
  return this._value;
52
64
  }
53
65
 
@@ -55,25 +67,40 @@ export default class EmbeddedComponent {
55
67
  return this._errors;
56
68
  }
57
69
 
70
+ /**
71
+ * Opens the component URL in the current window
72
+ */
73
+
58
74
  public open() {
59
75
  document.location.href = this.url;
60
76
  }
61
77
 
78
+ /**
79
+ * Mounts the component to a parent element
80
+ * @param parentId - The ID of the parent element
81
+ * @throws Will throw an error if the parent element is not found
82
+ */
83
+
62
84
  mount(parentId: string) {
63
85
  const parent = document.querySelector(parentId);
64
86
  if (!parent) throw new Error(`parentID ${parentId} not found`);
65
87
  this.embed(parent);
66
88
  }
89
+ /**
90
+ * Embeds the component into a parent element
91
+ * @param parent - The parent element to embed the component into
92
+ */
67
93
 
68
94
  embed(parent: Element) {
69
95
  this.iframe = document.createElement('iframe');
70
96
  this.iframe.src = this.url;
97
+ this.iframe.allow = 'web-share';
71
98
  this.iframe.style.width = '100%';
72
99
  this.iframe.style.height = '100px';
73
100
  this.iframe.style.border = 'none';
74
101
  this.iframe.style.overflow = 'hidden';
75
- this.iframe.setAttribute('allowtransparency', 'true');
76
- this.iframe.style.backgroundColor = 'transparent';
102
+ // this.iframe.setAttribute('allowtransparency', 'true');
103
+ // this.iframe.style.backgroundColor = 'transparent';
77
104
  parent.appendChild(this.iframe);
78
105
 
79
106
  window.addEventListener('message', (event: MessageEvent) => {
@@ -82,32 +109,55 @@ export default class EmbeddedComponent {
82
109
  }
83
110
  console.log('received message from iframe', event.data);
84
111
  this.eventManager?.setPort(event.ports[0]);
85
- this.ready = true;
86
112
  });
87
113
 
88
114
  this.iframe?.contentWindow?.focus();
89
115
  }
90
116
 
117
+ /**
118
+ * Sends a message to the embedded component
119
+ * @param message - The message to send
120
+ */
91
121
  send(message: HostMessage): void {
92
122
  this.eventManager.send(message);
93
123
  }
94
124
 
125
+ /**
126
+ * Adds an event listener for a specific message type
127
+ * @param messageType - The type of message to listen for
128
+ * @param callback - The callback function to execute when the message is received
129
+ */
130
+
95
131
  on(messageType: string, callback: MessageCallback): void {
96
132
  this.eventManager.on(messageType, callback);
97
133
  }
98
134
 
135
+ /**
136
+ * Removes an event listener for a specific message type
137
+ * @param messageType - The type of message to stop listening for
138
+ * @param callback - The callback function to remove
139
+ */
140
+
99
141
  off(messageType: string, callback: MessageCallback): void {
100
142
  this.eventManager.off(messageType, callback);
101
143
  }
102
144
 
103
- update(value: Partial<Transaction>) {
145
+ /**
146
+ * Updates the transaction value and sends an update message to the component
147
+ * @param value - The new transaction value
148
+ */
149
+ update(value: V) {
104
150
  this._value = value;
105
- this.send({ type: HMType.UPDATE, value });
151
+ this.send({ type: HMType.UPDATE, value: value as ComponentRequest });
106
152
  }
107
153
 
108
- completion(): Promise<TransactionResponse> {
154
+ /**
155
+ * Waits for the component to complete and returns the transaction response
156
+ * @returns A promise that resolves with the transaction response
157
+ */
158
+
159
+ completion(): Promise<R> {
109
160
  return new Promise((resolve, reject) => {
110
- this.closeModal();
111
161
  this.on(CMType.COMPLETE, (message) => {
112
162
  resolve((message as any).response);
113
163
  });
@@ -117,44 +167,22 @@ export default class EmbeddedComponent {
117
167
  });
118
168
  }
119
169
 
120
- // popup(): void {
121
- // this.popup = document.createElement('div');
122
- // this.popup.style;
123
- // }
170
+ /**
171
+ * Opens the component in a modal dialog
172
+ */
124
173
 
125
- openModal(): void {
174
+ openModal(): Promise<R> {
126
175
  if (this.modal) {
127
176
  this.closeModal();
128
177
  }
129
178
  this.modal = document.createElement('dialog');
130
- // this.modal.style.maxWidth = '600px';
131
- // this.modal.style.border = 'none !important';
132
- // this.modal.style.background = 'transparent';
133
- // this.modal.style.flexDirection = 'column';
134
- // this.modal.style.alignItems = 'end';
135
- // const close = document.createElement('button');
136
- // close.innerText = 'X';
137
- // close.style.fontSize = '1rem';
138
- // close.style.padding = '0.25rem 0.5rem';
139
- // close.style.display = 'block';
140
- // close.style.background = 'white';
141
- // close.style.color = '#aaa';
142
- // close.style.border = '#aaa';
143
- // close.addEventListener('click', () => this.closeModal());
144
- // this.modal.appendChild(close);
145
- // this.modal.css;
146
- // this.modal.style.position = 'fixed';
147
- // this.modal.style.bottom = '0';
148
- // this.modal.style.left = '0';
149
- // this.modal.style.right = '0';
150
- // this.modal.style.top = '0';
151
- // this.modal.style.left = '0';
152
- // this.modal.style.width = '100%';
153
- // this.modal.style.height = '100%';
154
- // this.modal.style.backgroundColor = 'transparent';
155
- // this.modal.style.display = 'flex';
156
- // this.modal.style.justifyContent = 'center';
157
- // this.modal.style.alignItems = 'center';
179
+ this.modal.style.border = 'none';
180
+ this.modal.style.backgroundColor = 'transparent';
181
+ this.modal.style.maxWidth = '100vw';
182
+ this.modal.style.maxHeight = '100vh';
183
+ this.modal.style.width = '600px';
184
+ this.modal.style.height = '800px';
185
+
158
186
  document.body.appendChild(this.modal);
159
187
  this.embed(this.modal);
160
188
  this.on(CMType.CANCEL, () => {
@@ -172,9 +200,14 @@ export default class EmbeddedComponent {
172
200
  // console.log('click');
173
201
  this.closeModal();
174
202
  });
203
+ return this.completion();
175
204
  }
205
+ /**
206
+ * Closes the modal dialog
207
+ *
208
+ */
176
209
 
177
- private closeModal(): void {
210
+ closeModal(): void {
178
211
  if (this.modal) {
179
212
  console.log('closeModal');
180
213
  this.modal?.close();