@archbee/app-widget 1.1.24 → 1.1.25

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/index.js DELETED
@@ -1,599 +0,0 @@
1
- var $cD94P$reactjsxruntime = require("react/jsx-runtime");
2
- var $cD94P$react = require("react");
3
- var $cD94P$reactdom = require("react-dom");
4
- var $cD94P$reactmodal = require("react-modal");
5
-
6
-
7
- function $parcel$export(e, n, v, s) {
8
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
- }
10
-
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
-
15
- $parcel$export(module.exports, "ArchbeeAppWidget", function () { return $3454c312fc43187e$export$d1cc455138316794; });
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
- const $24928a7e91a52dac$export$82eafebb825fc23f = ({ className: className, size: size = 24 })=>{
29
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("svg", {
30
- className: className,
31
- width: size,
32
- height: size,
33
- viewBox: "0 0 24 24",
34
- fill: "none",
35
- xmlns: "http://www.w3.org/2000/svg",
36
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("path", {
37
- d: "M21 21L16.65 16.65M19 11C19 15.4183 15.4183 19 11 19C6.58172 19 3 15.4183 3 11C3 6.58172 6.58172 3 11 3C15.4183 3 19 6.58172 19 11Z",
38
- stroke: "currentColor",
39
- strokeWidth: "2",
40
- strokeLinecap: "round",
41
- strokeLinejoin: "round"
42
- })
43
- });
44
- };
45
-
46
-
47
- const $71c11890332f76f6$export$890c0998c02c05a7 = ({ isModalOpen: isModalOpen, openAskBubbleModal: openAskBubbleModal })=>{
48
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
49
- className: "ab-ask-bubble",
50
- onClick: openAskBubbleModal,
51
- style: isModalOpen ? {
52
- zIndex: 0
53
- } : {},
54
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)("div", {
55
- className: "ab-ask-bubble-wrapper",
56
- children: [
57
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
58
- className: "ab-ask-notification"
59
- }),
60
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
61
- className: "ab-ask-bubble-icon",
62
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $24928a7e91a52dac$export$82eafebb825fc23f), {})
63
- }),
64
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)("div", {
65
- className: "ab-ask-bubble-content",
66
- children: [
67
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
68
- className: "ab-ask-bubble-title",
69
- children: "Ask a question"
70
- }),
71
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
72
- className: "ab-ask-bubble-subtitle",
73
- children: "Powered by Archbee"
74
- })
75
- ]
76
- })
77
- ]
78
- })
79
- });
80
- };
81
-
82
-
83
-
84
-
85
-
86
-
87
- const $7d0ac34aa5949d25$export$15a92cf792322942 = {
88
- animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
89
- };
90
-
91
-
92
-
93
-
94
- const $01068657cf84c1f4$export$a966859aef4647ca = ({ className: className, size: size = 24 })=>/*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("svg", {
95
- className: className,
96
- width: size,
97
- height: size,
98
- viewBox: "0 0 40 40",
99
- fill: "none",
100
- xmlns: "http://www.w3.org/2000/svg",
101
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("path", {
102
- d: "M25 15L15 25M15 15L25 25",
103
- stroke: "currentColor",
104
- strokeWidth: "1.66667",
105
- strokeLinecap: "round",
106
- strokeLinejoin: "round"
107
- })
108
- });
109
-
110
-
111
- const $24a1ab1d9e5e268a$export$7428da3cfb78ae6 = ({ onClose: onClose })=>{
112
- const eventStopPropagation = (event)=>{
113
- event.preventDefault();
114
- event.stopPropagation();
115
- };
116
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
117
- onClick: onClose,
118
- className: "ab-doc-container",
119
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)("div", {
120
- onClick: eventStopPropagation,
121
- className: "ab-doc-loader",
122
- children: [
123
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
124
- onClick: onClose,
125
- className: "ab-doc-close",
126
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $01068657cf84c1f4$export$a966859aef4647ca), {
127
- size: 50
128
- })
129
- }),
130
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
131
- className: "ab-rounded ab-gray w-1/2 mb-4",
132
- style: {
133
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
134
- height: "3rem"
135
- }
136
- }),
137
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
138
- className: "ab-rounded ab-gray ab-mb-20",
139
- style: {
140
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
141
- height: "1.75rem",
142
- width: "100%"
143
- }
144
- }),
145
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
146
- className: "ab-rounded ab-gray ab-mb-20",
147
- style: {
148
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
149
- height: "1.75rem",
150
- width: "75%"
151
- }
152
- }),
153
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
154
- className: "ab-rounded ab-gray ab-mb-20",
155
- style: {
156
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
157
- height: "1.75rem",
158
- width: "75%"
159
- }
160
- }),
161
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
162
- className: "ab-rounded ab-gray ab-mb-20",
163
- style: {
164
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
165
- height: "2.5rem",
166
- width: "25%"
167
- }
168
- }),
169
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
170
- className: "ab-rounded ab-gray ab-mb-20",
171
- style: {
172
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
173
- height: "1.75rem",
174
- width: "60%"
175
- }
176
- }),
177
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
178
- className: "ab-rounded ab-gray ab-mb-20",
179
- style: {
180
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
181
- height: "1.75rem",
182
- width: "40%"
183
- }
184
- }),
185
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
186
- className: "ab-rounded ab-gray ab-mb-20",
187
- style: {
188
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
189
- height: "1.75rem",
190
- width: "100%"
191
- }
192
- }),
193
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
194
- className: "ab-rounded ab-gray ab-mb-20",
195
- style: {
196
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
197
- height: "1.75rem",
198
- width: "80%"
199
- }
200
- }),
201
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
202
- className: "ab-rounded ab-gray",
203
- style: {
204
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
205
- height: "1.75rem",
206
- width: "25%"
207
- }
208
- })
209
- ]
210
- })
211
- });
212
- };
213
-
214
-
215
-
216
-
217
-
218
-
219
- const $671c57dd09bd5436$export$e9f7c27668489a52 = ({ onClose: onClose })=>{
220
- const eventStopPropagation = (event)=>{
221
- event.preventDefault();
222
- event.stopPropagation();
223
- };
224
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
225
- onClick: onClose,
226
- className: "ab-doc-search-container",
227
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)("div", {
228
- onClick: eventStopPropagation,
229
- className: "ab-doc-search-placeholder",
230
- children: [
231
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
232
- onClick: onClose,
233
- className: "ab-doc-close",
234
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $01068657cf84c1f4$export$a966859aef4647ca), {
235
- size: 50
236
- })
237
- }),
238
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
239
- className: "ab-rounded ab-gray",
240
- style: {
241
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
242
- height: "3rem",
243
- width: "96%"
244
- }
245
- })
246
- ]
247
- })
248
- });
249
- };
250
-
251
-
252
- const $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5 = ({ spaceId: spaceId, docId: docId, blockId: blockId, screen: screen = "docs", jwt: jwt, shareableToken: shareableToken, onClose: onClose })=>{
253
- var _iframeRef_current;
254
- const iframeRef = (0, $cD94P$react.useRef)(null);
255
- const onIframeLoaded = ()=>{
256
- const elementId = screen === "docs" ? "ab-doc-placeholder-container" : "ab-search-placeholder-container";
257
- const element = document.getElementById(elementId);
258
- element === null || element === void 0 ? void 0 : element.remove();
259
- };
260
- (0, $cD94P$react.useEffect)(()=>{
261
- if (!iframeRef.current) return;
262
- const url = $d0b8a7ae25f50023$var$getIframeUrl(spaceId, docId, blockId, jwt, shareableToken, screen);
263
- iframeRef.current.src = url;
264
- }, [
265
- screen,
266
- spaceId,
267
- docId,
268
- blockId,
269
- jwt,
270
- shareableToken
271
- ]);
272
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)("div", {
273
- onClick: onClose,
274
- className: "ab-modal-container",
275
- children: [
276
- screen === "docs" && /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
277
- id: "ab-doc-placeholder-container",
278
- className: "ab-placeholder-wrapper",
279
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $24a1ab1d9e5e268a$export$7428da3cfb78ae6), {
280
- onClose: onClose
281
- })
282
- }),
283
- screen === "search" && /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
284
- id: "ab-search-placeholder-container",
285
- className: "ab-placeholder-wrapper",
286
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $671c57dd09bd5436$export$e9f7c27668489a52), {
287
- onClose: onClose
288
- })
289
- }),
290
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("iframe", {
291
- onLoad: onIframeLoaded,
292
- ref: iframeRef,
293
- title: "Archbee widget",
294
- src: (_iframeRef_current = iframeRef.current) === null || _iframeRef_current === void 0 ? void 0 : _iframeRef_current.src,
295
- className: "ab-modal-iframe"
296
- })
297
- ]
298
- });
299
- };
300
- const $d0b8a7ae25f50023$var$getIframeUrl = (spaceId, docId, blockId, jwt, shareableToken, screen)=>{
301
- let iframeUrl = `${"https://app.archbee.com/public"}/${spaceId}`;
302
- if (docId) iframeUrl = iframeUrl + `/${docId}`;
303
- const template = "?template=widget";
304
- iframeUrl += template;
305
- if (jwt) iframeUrl += `&jwt=${jwt}`;
306
- if (shareableToken) iframeUrl += `&shareableToken=${shareableToken}`;
307
- if (screen) iframeUrl += `&initialScreen=${screen}`;
308
- if (blockId) iframeUrl = iframeUrl + `#${blockId}`;
309
- return iframeUrl;
310
- };
311
-
312
-
313
- var $5ea18ff364e1e223$export$e923c830cbf8e49c;
314
- (function(EVENT_TYPE_ENUM) {
315
- EVENT_TYPE_ENUM["init"] = "init";
316
- EVENT_TYPE_ENUM["showWidget"] = "show-widget";
317
- EVENT_TYPE_ENUM["hideWidget"] = "hide-widget";
318
- })($5ea18ff364e1e223$export$e923c830cbf8e49c || ($5ea18ff364e1e223$export$e923c830cbf8e49c = {}));
319
- const $5ea18ff364e1e223$export$fddb3f5bc79c4a16 = [
320
- "init",
321
- "show-widget",
322
- "hide-widget"
323
- ];
324
- const $5ea18ff364e1e223$export$4eadcc42fc7554ad = ()=>{
325
- if (typeof window === "undefined") return;
326
- return new CustomEvent("show-widget");
327
- };
328
- const $5ea18ff364e1e223$export$c6414d05a79532c3 = ()=>{
329
- if (typeof window === "undefined") return;
330
- return new CustomEvent("hide-widget");
331
- };
332
-
333
-
334
- const $91b786905c14e19d$export$86fbec116b87613f = ()=>{
335
- const [isModalOpen, setIsModalOpen] = (0, $cD94P$react.useState)(false);
336
- const [docId, setDocId] = (0, $cD94P$react.useState)();
337
- const [blockId, setBlockId] = (0, $cD94P$react.useState)();
338
- const [jwt, setJwt] = (0, $cD94P$react.useState)();
339
- const [shareableToken, setShareableToken] = (0, $cD94P$react.useState)();
340
- const [initialScreen, setInitialScreen] = (0, $cD94P$react.useState)();
341
- const widgetActionListener = (0, $cD94P$react.useCallback)(()=>{
342
- setIsModalOpen(window._archbee.widget.isOpen);
343
- setDocId(window._archbee.widget.docId);
344
- setBlockId(window._archbee.widget.blockId);
345
- setJwt(window._archbee.widget.jwt);
346
- setShareableToken(window._archbee.widget.shareableToken);
347
- setInitialScreen(window._archbee.widget.widgetType);
348
- const widget = document.getElementsByClassName("ab-widget");
349
- if (!widget.length) return;
350
- if (window._archbee.widget.isOpen) widget[0].removeAttribute("style");
351
- else widget[0].setAttribute("style", "visibility: hidden");
352
- }, []);
353
- const onPostMessageReceived = (0, $cD94P$react.useCallback)(({ data: data })=>{
354
- if (data.source !== "archbee-widget") return;
355
- switch(data.type){
356
- case "ab-doc-close":
357
- closeModal();
358
- break;
359
- default:
360
- break;
361
- }
362
- }, []);
363
- (0, $cD94P$react.useEffect)(()=>{
364
- window.addEventListener((0, $5ea18ff364e1e223$export$e923c830cbf8e49c).showWidget, widgetActionListener);
365
- window.addEventListener((0, $5ea18ff364e1e223$export$e923c830cbf8e49c).hideWidget, widgetActionListener);
366
- window.addEventListener("message", onPostMessageReceived);
367
- return ()=>{
368
- window.removeEventListener((0, $5ea18ff364e1e223$export$e923c830cbf8e49c).showWidget, widgetActionListener);
369
- window.removeEventListener((0, $5ea18ff364e1e223$export$e923c830cbf8e49c).hideWidget, widgetActionListener);
370
- window.removeEventListener("message", onPostMessageReceived);
371
- };
372
- }, [
373
- widgetActionListener,
374
- onPostMessageReceived
375
- ]);
376
- const closeModal = ()=>{
377
- window._archbee.widget.isOpen = false;
378
- window._archbee.widget.docId = undefined;
379
- window._archbee.widget.blockId = undefined;
380
- window.dispatchEvent((0, $5ea18ff364e1e223$export$c6414d05a79532c3)());
381
- };
382
- const openAskBubbleModal = ()=>{
383
- window._archbee.widget.isOpen = true;
384
- window._archbee.widget.widgetType = "search";
385
- window.dispatchEvent((0, $5ea18ff364e1e223$export$4eadcc42fc7554ad)());
386
- };
387
- (0, $cD94P$react.useEffect)(()=>{
388
- (0, ($parcel$interopDefault($cD94P$reactmodal))).setAppElement("#archbee-docs-widget-modal");
389
- }, []);
390
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsxs)((0, $cD94P$reactjsxruntime.Fragment), {
391
- children: [
392
- window._archbee.widget.bubble === "ask" && /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $71c11890332f76f6$export$890c0998c02c05a7), {
393
- isModalOpen: isModalOpen,
394
- openAskBubbleModal: openAskBubbleModal
395
- }),
396
- /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
397
- id: "archbee-docs-widget-modal",
398
- children: isModalOpen && /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5), {
399
- docId: docId || "",
400
- blockId: blockId || "",
401
- spaceId: window._archbee.widget.spaceId || window._archbee.widget.collectionId || "",
402
- jwt: jwt,
403
- shareableToken: shareableToken,
404
- screen: initialScreen,
405
- onClose: closeModal
406
- })
407
- })
408
- ]
409
- });
410
- };
411
- var $91b786905c14e19d$export$2e2bcd8739ae039 = $91b786905c14e19d$export$86fbec116b87613f;
412
-
413
-
414
- const $a328aa60f920ce82$export$b3890eb0ae9dca99 = (cb)=>{
415
- const element = document.getElementsByClassName("ab-widget")[0];
416
- (0, ($parcel$interopDefault($cD94P$reactdom))).render(/*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, ($parcel$interopDefault($cD94P$react))).StrictMode, {
417
- children: /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)((0, $91b786905c14e19d$export$2e2bcd8739ae039), {})
418
- }), element, ()=>cb && cb(element));
419
- };
420
-
421
-
422
-
423
- const $9913b3312051bc1e$export$e41ef1391ce9e919 = (widget)=>{
424
- window._archbee.widget = {
425
- ...widget
426
- };
427
- window._archbee.widget.isOpen = false;
428
- };
429
- const $9913b3312051bc1e$export$18d0fd55b1b3892d = (widg, render)=>{
430
- if (typeof document.addEventListener !== "function") return;
431
- window._archbee.widget = {
432
- ...window._archbee.widget,
433
- ...widg
434
- };
435
- try {
436
- render(widg.onRenderFinish);
437
- } catch (err) {
438
- console.log(err);
439
- }
440
- };
441
- const $9913b3312051bc1e$export$26ae5ca175b4ec5a = ()=>{
442
- if (document.getElementsByClassName("ab-widget").length) return;
443
- const abDiv = document.createElement("div");
444
- abDiv.style.cssText = "visibility:hidden";
445
- abDiv.className = `ab-widget ab-id-${Date.now()}`;
446
- document.body.appendChild(abDiv);
447
- };
448
-
449
-
450
- const $12e413341357248b$export$5cfe1e4796fafad8 = ()=>{
451
- if (!("Proxy" in window)) {
452
- console.warn("Your browser doesn't support Proxies.");
453
- return;
454
- }
455
- const proxy = new Proxy(window._archbee.queue, {
456
- get (target, property, receiver) {
457
- return Reflect.get(target, property, receiver);
458
- },
459
- apply (target, thisArg, argumentsList) {
460
- return thisArg[target].apply(this, argumentsList);
461
- },
462
- set (target, property, value) {
463
- $12e413341357248b$export$403ad7fb28be9f07(target);
464
- return Reflect.set(target, property, value);
465
- },
466
- deleteProperty (target, property) {
467
- return Reflect.deleteProperty(target, property);
468
- }
469
- });
470
- return proxy;
471
- };
472
- const $12e413341357248b$export$403ad7fb28be9f07 = (proxy)=>{
473
- if (!proxy.length) return;
474
- proxy.forEach((event, index)=>{
475
- // keep this here for now
476
- console.log("widget event received:", event.eventType, window._archbee.widget);
477
- if (event.hasExecuted || !(0, $5ea18ff364e1e223$export$fddb3f5bc79c4a16).includes(event.eventType)) {
478
- proxy.splice(index, 1);
479
- return;
480
- }
481
- if (event.eventType === (0, $5ea18ff364e1e223$export$e923c830cbf8e49c).init) {
482
- (0, $9913b3312051bc1e$export$e41ef1391ce9e919)(event);
483
- (0, $9913b3312051bc1e$export$18d0fd55b1b3892d)(event, (0, $a328aa60f920ce82$export$b3890eb0ae9dca99));
484
- }
485
- if (event.eventType === (0, $5ea18ff364e1e223$export$e923c830cbf8e49c).showWidget) {
486
- window._archbee.widget.isOpen = true;
487
- if (event.docId) window._archbee.widget.docId = event.docId;
488
- if (event.blockId) window._archbee.widget.blockId = event.blockId;
489
- if (event.widgetType) {
490
- const widgetType = event.docId && event.widgetType === "search" ? "docs" : event.widgetType;
491
- window._archbee.widget.widgetType = widgetType;
492
- } else window._archbee.widget.widgetType = "docs";
493
- window.dispatchEvent((0, $5ea18ff364e1e223$export$4eadcc42fc7554ad)());
494
- }
495
- if (event.eventType === (0, $5ea18ff364e1e223$export$e923c830cbf8e49c).hideWidget) {
496
- window._archbee.widget.isOpen = false;
497
- window._archbee.widget.docId = undefined;
498
- window._archbee.widget.blockId = undefined;
499
- window._archbee.widget.widgetType = undefined;
500
- window.dispatchEvent((0, $5ea18ff364e1e223$export$c6414d05a79532c3)());
501
- }
502
- event.hasExecuted = true;
503
- });
504
- };
505
-
506
-
507
-
508
- const $ef43c9dfc50ce6f2$export$b66f8e2563088683 = ()=>{
509
- var _link_parentNode;
510
- const widgetcsslink = document.createElement("link");
511
- const link = document.getElementsByTagName("link")[0];
512
- widgetcsslink["rel"] = "stylesheet";
513
- widgetcsslink["href"] = `${"https://widget.archbee.com/v1"}/index.css`;
514
- if (!link) document.getElementsByTagName("head")[0].append(widgetcsslink);
515
- link === null || link === void 0 ? void 0 : (_link_parentNode = link.parentNode) === null || _link_parentNode === void 0 ? void 0 : _link_parentNode.appendChild(widgetcsslink);
516
- };
517
- const $ef43c9dfc50ce6f2$export$daaeb3f1095d12b8 = (loadingStrategy)=>{
518
- var _script_parentNode;
519
- const mainUrl = "https://widget.archbee.com/v1";
520
- let scripttag = document.createElement("script");
521
- scripttag["async"] = loadingStrategy === "lazy";
522
- scripttag["src"] = `${mainUrl}/index.js`;
523
- const script = document.getElementsByTagName("script")[0];
524
- script === null || script === void 0 ? void 0 : (_script_parentNode = script.parentNode) === null || _script_parentNode === void 0 ? void 0 : _script_parentNode.insertBefore(scripttag, script);
525
- };
526
- const $ef43c9dfc50ce6f2$export$2d47b06a7861ac47 = (spaceId, jwt, shareableToken, loadingStrategy = "lazy", bubble = "invisible")=>{
527
- if (!window._archbee) {
528
- // @ts-expect-error
529
- window._archbee = window._archbee || {
530
- queue: [],
531
- push: function(event) {
532
- window._archbee.queue.push(event);
533
- }
534
- };
535
- window._archbee.push({
536
- eventType: "init",
537
- spaceId: spaceId,
538
- jwt: jwt,
539
- shareableToken: shareableToken,
540
- bubble: bubble
541
- });
542
- $ef43c9dfc50ce6f2$export$daaeb3f1095d12b8(loadingStrategy);
543
- }
544
- return window._archbee;
545
- };
546
-
547
-
548
-
549
-
550
- const $3454c312fc43187e$export$d1cc455138316794 = /*#__PURE__*/ (0, $cD94P$react.forwardRef)(({ className: className, spaceId: spaceId, jwt: jwt, shareableToken: shareableToken, docId: docId, blockId: blockId, widgetType: widgetType = "docs", loadingStrategy: loadingStrategy = "lazy", onWidgetOpen: onWidgetOpen, onWidgetClose: onWidgetClose, bubble: bubble, children: children }, ref)=>{
551
- const elementRef = (0, $cD94P$react.useRef)(null);
552
- const widgetInstance = (0, $cD94P$react.useMemo)(()=>{
553
- if (typeof window === "undefined") return;
554
- return (0, $ef43c9dfc50ce6f2$export$2d47b06a7861ac47)(spaceId, jwt, shareableToken, loadingStrategy, bubble);
555
- }, [
556
- spaceId,
557
- jwt,
558
- shareableToken,
559
- loadingStrategy,
560
- bubble
561
- ]);
562
- (0, $cD94P$react.useImperativeHandle)(ref, ()=>{
563
- return {
564
- open: onOpenWidget,
565
- close: onCloseWidget,
566
- instance: ()=>widgetInstance
567
- };
568
- });
569
- const onOpenWidget = ()=>{
570
- widgetInstance === null || widgetInstance === void 0 ? void 0 : widgetInstance.push({
571
- eventType: "show-widget",
572
- widgetType: widgetType,
573
- docId: docId,
574
- blockId: blockId
575
- });
576
- onWidgetOpen === null || onWidgetOpen === void 0 ? void 0 : onWidgetOpen();
577
- };
578
- const onCloseWidget = ()=>{
579
- widgetInstance === null || widgetInstance === void 0 ? void 0 : widgetInstance.push({
580
- eventType: "hide-widget"
581
- });
582
- onWidgetClose === null || onWidgetClose === void 0 ? void 0 : onWidgetClose();
583
- };
584
- const onElementClicked = (event)=>{
585
- var _elementRef_current;
586
- if (typeof window !== "undefined" && ((_elementRef_current = elementRef.current) === null || _elementRef_current === void 0 ? void 0 : _elementRef_current.contains(event.target)) && !ref) {
587
- event.preventDefault();
588
- onOpenWidget();
589
- }
590
- };
591
- return /*#__PURE__*/ (0, $cD94P$reactjsxruntime.jsx)("div", {
592
- className: className !== null && className !== void 0 ? className : "",
593
- ref: elementRef,
594
- onClick: onElementClicked,
595
- children: children
596
- });
597
- });
598
-
599
-
package/types.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import React from "react";
2
- declare global {
3
- interface Window {
4
- _archbee: ArchbeeWidgetInstance;
5
- }
6
- }
7
- interface ArchbeeWidgetInstance {
8
- version: string;
9
- widget: AbWidgetData;
10
- queue: any;
11
- push: Function;
12
- }
13
- enum EVENT_TYPE_ENUM {
14
- init = "init",
15
- showWidget = "show-widget",
16
- hideWidget = "hide-widget"
17
- }
18
- type WidgetEventType = EVENT_TYPE_ENUM.init | EVENT_TYPE_ENUM.showWidget | EVENT_TYPE_ENUM.hideWidget;
19
- interface AbWidgetData {
20
- eventType: WidgetEventType;
21
- collectionId?: string;
22
- spaceId?: string;
23
- docId?: string;
24
- blockId?: string;
25
- isOpen: boolean;
26
- selector: string;
27
- origin?: string;
28
- onRenderFinish?: Function;
29
- hasExecuted: boolean;
30
- jwt?: string;
31
- shareableToken?: string;
32
- widgetType?: WidgetType;
33
- bubble?: BubbleType;
34
- }
35
- type BubbleType = 'ask' | 'invisible';
36
- type WidgetType = 'docs' | 'search';
37
- interface AbWidgetRef {
38
- open: () => void;
39
- close: () => void;
40
- instance: () => ArchbeeWidgetInstance;
41
- }
42
- type Props = {
43
- spaceId: string;
44
- docId?: string;
45
- jwt?: string;
46
- className?: string;
47
- shareableToken?: string;
48
- widgetType: WidgetType;
49
- bubble?: BubbleType;
50
- blockId?: string;
51
- user?: {
52
- id: string;
53
- email?: string;
54
- first_name?: string;
55
- last_name?: string;
56
- profile_image_url?: string;
57
- [key: string]: any;
58
- };
59
- loadingStrategy?: 'eager' | 'lazy';
60
- onWidgetOpen?: Function;
61
- onWidgetClose?: Function;
62
- };
63
- export const ArchbeeAppWidget: React.ForwardRefExoticComponent<Props & {
64
- children?: React.ReactNode;
65
- } & React.RefAttributes<AbWidgetRef>>;