@archbee/app-widget 1.1.4 → 1.1.6

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.
Files changed (3) hide show
  1. package/index.js +59 -14
  2. package/package.json +2 -2
  3. package/types.d.ts +2 -0
package/index.js CHANGED
@@ -30,6 +30,25 @@ const $7d0ac34aa5949d25$export$15a92cf792322942 = {
30
30
  };
31
31
 
32
32
 
33
+
34
+
35
+ const $01068657cf84c1f4$export$a966859aef4647ca = ({ className: className, size: size = 24 })=>/*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("svg", {
36
+ className: className,
37
+ width: size,
38
+ height: size,
39
+ viewBox: "0 0 40 40",
40
+ fill: "none",
41
+ xmlns: "http://www.w3.org/2000/svg",
42
+ children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("path", {
43
+ d: "M25 15L15 25M15 15L25 25",
44
+ stroke: "currentColor",
45
+ strokeWidth: "1.66667",
46
+ strokeLinecap: "round",
47
+ strokeLinejoin: "round"
48
+ })
49
+ });
50
+
51
+
33
52
  const $24a1ab1d9e5e268a$export$7428da3cfb78ae6 = ({ onClose: onClose })=>{
34
53
  const eventStopPropagation = (event)=>{
35
54
  event.preventDefault();
@@ -42,6 +61,13 @@ const $24a1ab1d9e5e268a$export$7428da3cfb78ae6 = ({ onClose: onClose })=>{
42
61
  onClick: eventStopPropagation,
43
62
  className: "ab-doc-loader",
44
63
  children: [
64
+ /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
65
+ onClick: onClose,
66
+ className: "ab-doc-close",
67
+ children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)((0, $01068657cf84c1f4$export$a966859aef4647ca), {
68
+ size: 50
69
+ })
70
+ }),
45
71
  /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
46
72
  className: "ab-rounded ab-gray w-1/2 mb-4",
47
73
  style: {
@@ -130,6 +156,7 @@ const $24a1ab1d9e5e268a$export$7428da3cfb78ae6 = ({ onClose: onClose })=>{
130
156
 
131
157
 
132
158
 
159
+
133
160
  const $671c57dd09bd5436$export$e9f7c27668489a52 = ({ onClose: onClose })=>{
134
161
  const eventStopPropagation = (event)=>{
135
162
  event.preventDefault();
@@ -138,23 +165,32 @@ const $671c57dd09bd5436$export$e9f7c27668489a52 = ({ onClose: onClose })=>{
138
165
  return /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
139
166
  onClick: onClose,
140
167
  className: "ab-doc-search-container",
141
- children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
168
+ children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsxs)("div", {
142
169
  onClick: eventStopPropagation,
143
170
  className: "ab-doc-search-placeholder",
144
- children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
145
- className: "ab-rounded ab-gray",
146
- style: {
147
- ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
148
- height: "3rem",
149
- width: "96%"
150
- }
151
- })
171
+ children: [
172
+ /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
173
+ onClick: onClose,
174
+ className: "ab-doc-close",
175
+ children: /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)((0, $01068657cf84c1f4$export$a966859aef4647ca), {
176
+ size: 50
177
+ })
178
+ }),
179
+ /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)("div", {
180
+ className: "ab-rounded ab-gray",
181
+ style: {
182
+ ...(0, $7d0ac34aa5949d25$export$15a92cf792322942),
183
+ height: "3rem",
184
+ width: "96%"
185
+ }
186
+ })
187
+ ]
152
188
  })
153
189
  });
154
190
  };
155
191
 
156
192
 
157
- const $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5 = ({ spaceId: spaceId, docId: docId, screen: screen = "docs", jwt: jwt, shareableToken: shareableToken, onClose: onClose })=>{
193
+ const $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5 = ({ spaceId: spaceId, docId: docId, blockId: blockId, screen: screen = "docs", jwt: jwt, shareableToken: shareableToken, onClose: onClose })=>{
158
194
  var _iframeRef_current;
159
195
  const iframeRef = (0, $hXgUO$react.useRef)(null);
160
196
  const onIframeLoaded = ()=>{
@@ -164,12 +200,13 @@ const $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5 = ({ spaceId: spaceId, docId: do
164
200
  };
165
201
  (0, $hXgUO$react.useEffect)(()=>{
166
202
  if (!iframeRef.current) return;
167
- const url = $d0b8a7ae25f50023$var$getIframeUrl(spaceId, docId, jwt, shareableToken, screen);
203
+ const url = $d0b8a7ae25f50023$var$getIframeUrl(spaceId, docId, blockId, jwt, shareableToken, screen);
168
204
  iframeRef.current.src = url;
169
205
  }, [
170
206
  screen,
171
207
  spaceId,
172
208
  docId,
209
+ blockId,
173
210
  jwt,
174
211
  shareableToken
175
212
  ]);
@@ -201,7 +238,7 @@ const $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5 = ({ spaceId: spaceId, docId: do
201
238
  ]
202
239
  });
203
240
  };
204
- const $d0b8a7ae25f50023$var$getIframeUrl = (spaceId, docId, jwt, shareableToken, screen)=>{
241
+ const $d0b8a7ae25f50023$var$getIframeUrl = (spaceId, docId, blockId, jwt, shareableToken, screen)=>{
205
242
  let iframeUrl = `${undefined}/${spaceId}`;
206
243
  if (docId) iframeUrl = iframeUrl + `/${docId}`;
207
244
  const template = "?template=widget";
@@ -209,6 +246,7 @@ const $d0b8a7ae25f50023$var$getIframeUrl = (spaceId, docId, jwt, shareableToken,
209
246
  if (jwt) iframeUrl += `&jwt=${jwt}`;
210
247
  if (shareableToken) iframeUrl += `&shareableToken=${shareableToken}`;
211
248
  if (screen) iframeUrl += `&initialScreen=${screen}`;
249
+ if (blockId) iframeUrl = iframeUrl + `#${blockId}`;
212
250
  return iframeUrl;
213
251
  };
214
252
 
@@ -237,12 +275,14 @@ const $5ea18ff364e1e223$export$c6414d05a79532c3 = ()=>{
237
275
  const $91b786905c14e19d$export$86fbec116b87613f = ()=>{
238
276
  const [isModalOpen, setIsModalOpen] = (0, $hXgUO$react.useState)(false);
239
277
  const [docId, setDocId] = (0, $hXgUO$react.useState)();
278
+ const [blockId, setBlockId] = (0, $hXgUO$react.useState)();
240
279
  const [jwt, setJwt] = (0, $hXgUO$react.useState)();
241
280
  const [shareableToken, setShareableToken] = (0, $hXgUO$react.useState)();
242
281
  const [initialScreen, setInitialScreen] = (0, $hXgUO$react.useState)();
243
282
  const widgetActionListener = (0, $hXgUO$react.useCallback)(()=>{
244
283
  setIsModalOpen(window._archbee.widget.isOpen);
245
284
  setDocId(window._archbee.widget.docId);
285
+ setBlockId(window._archbee.widget.blockId);
246
286
  setJwt(window._archbee.widget.jwt);
247
287
  setShareableToken(window._archbee.widget.shareableToken);
248
288
  setInitialScreen(window._archbee.widget.widgetType);
@@ -277,6 +317,7 @@ const $91b786905c14e19d$export$86fbec116b87613f = ()=>{
277
317
  const closeModal = ()=>{
278
318
  window._archbee.widget.isOpen = false;
279
319
  window._archbee.widget.docId = undefined;
320
+ window._archbee.widget.blockId = undefined;
280
321
  window.dispatchEvent((0, $5ea18ff364e1e223$export$c6414d05a79532c3)());
281
322
  };
282
323
  (0, $hXgUO$react.useEffect)(()=>{
@@ -286,6 +327,7 @@ const $91b786905c14e19d$export$86fbec116b87613f = ()=>{
286
327
  id: "archbee-docs-widget-modal",
287
328
  children: isModalOpen && /*#__PURE__*/ (0, $hXgUO$reactjsxruntime.jsx)((0, $d0b8a7ae25f50023$export$a65e3ebe24ca6cb5), {
288
329
  docId: docId || "",
330
+ blockId: blockId || "",
289
331
  spaceId: window._archbee.widget.spaceId || window._archbee.widget.collectionId || "",
290
332
  jwt: jwt,
291
333
  shareableToken: shareableToken,
@@ -371,6 +413,7 @@ const $12e413341357248b$export$403ad7fb28be9f07 = (proxy)=>{
371
413
  if (event.eventType === (0, $5ea18ff364e1e223$export$e923c830cbf8e49c).showWidget) {
372
414
  window._archbee.widget.isOpen = true;
373
415
  if (event.docId) window._archbee.widget.docId = event.docId;
416
+ if (event.blockId) window._archbee.widget.blockId = event.blockId;
374
417
  if (event.widgetType) {
375
418
  const widgetType = event.docId && event.widgetType === "search" ? "docs" : event.widgetType;
376
419
  window._archbee.widget.widgetType = widgetType;
@@ -380,6 +423,7 @@ const $12e413341357248b$export$403ad7fb28be9f07 = (proxy)=>{
380
423
  if (event.eventType === (0, $5ea18ff364e1e223$export$e923c830cbf8e49c).hideWidget) {
381
424
  window._archbee.widget.isOpen = false;
382
425
  window._archbee.widget.docId = undefined;
426
+ window._archbee.widget.blockId = undefined;
383
427
  window._archbee.widget.widgetType = undefined;
384
428
  window.dispatchEvent((0, $5ea18ff364e1e223$export$c6414d05a79532c3)());
385
429
  }
@@ -430,7 +474,7 @@ const $ef43c9dfc50ce6f2$export$2d47b06a7861ac47 = (spaceId, jwt, shareableToken,
430
474
 
431
475
 
432
476
 
433
- const $3454c312fc43187e$export$d1cc455138316794 = /*#__PURE__*/ (0, $hXgUO$react.forwardRef)(({ className: className, spaceId: spaceId, jwt: jwt, shareableToken: shareableToken, docId: docId, widgetType: widgetType = "docs", loadingStrategy: loadingStrategy = "lazy", onWidgetOpen: onWidgetOpen, onWidgetClose: onWidgetClose, children: children }, ref)=>{
477
+ const $3454c312fc43187e$export$d1cc455138316794 = /*#__PURE__*/ (0, $hXgUO$react.forwardRef)(({ className: className, spaceId: spaceId, jwt: jwt, shareableToken: shareableToken, docId: docId, blockId: blockId, widgetType: widgetType = "docs", loadingStrategy: loadingStrategy = "lazy", onWidgetOpen: onWidgetOpen, onWidgetClose: onWidgetClose, children: children }, ref)=>{
434
478
  const elementRef = (0, $hXgUO$react.useRef)(null);
435
479
  const widgetInstance = (0, $hXgUO$react.useMemo)(()=>{
436
480
  if (typeof window === "undefined") return;
@@ -452,7 +496,8 @@ const $3454c312fc43187e$export$d1cc455138316794 = /*#__PURE__*/ (0, $hXgUO$react
452
496
  widgetInstance === null || widgetInstance === void 0 ? void 0 : widgetInstance.push({
453
497
  eventType: "show-widget",
454
498
  widgetType: widgetType,
455
- docId: docId
499
+ docId: docId,
500
+ blockId: blockId
456
501
  });
457
502
  onWidgetOpen === null || onWidgetOpen === void 0 ? void 0 : onWidgetOpen();
458
503
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archbee/app-widget",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "author": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "scripts": {
45
45
  "clean": "rm -rf dist build",
46
- "start": "craco start",
46
+ "start": "http-server dist/ -p 3002 -c-1",
47
47
  "build": "npm run clean && npm run build:widget && npm run build:react",
48
48
  "build:widget": "REACT_APP_SDK=true craco build && parcel build src/index.tsx --no-source-maps && mkdir -p build/v1 && cp dist/* build/v1/",
49
49
  "build:react": "./react-build.script.sh",
package/types.d.ts CHANGED
@@ -21,6 +21,7 @@ interface AbWidgetData {
21
21
  collectionId?: string;
22
22
  spaceId?: string;
23
23
  docId?: string;
24
+ blockId?: string;
24
25
  isOpen: boolean;
25
26
  selector: string;
26
27
  origin?: string;
@@ -43,6 +44,7 @@ type Props = {
43
44
  className?: string;
44
45
  shareableToken?: string;
45
46
  widgetType: ScreenType;
47
+ blockId?: string;
46
48
  user?: {
47
49
  id: string;
48
50
  email?: string;