@archbee/app-widget 1.1.25 → 1.1.26
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/README.md +1 -0
- package/index.esm.js +212 -166
- package/package.json +1 -1
- package/src/lib/main.d.ts +13 -20
- package/src/lib/scripts/initScripts.d.ts +1 -1
- package/src/lib/scripts/render.d.ts +1 -1
- package/src/lib/types.d.ts +2 -2
package/README.md
CHANGED
|
@@ -106,6 +106,7 @@ ReactDOM.render(<App />, appElement);
|
|
|
106
106
|
| `widgetType` | `docs \| search` | `optional` | Default value is `docs`. This opens the widget with the desired behaviour. ` docs`` type will open the widget with the default behaviour, `search` will open a search widget bar that shows a search bar with AI support (if included in your subscription) |
|
|
107
107
|
| `bubble` | `ask \| invisible` | `optional` | Default value is `invisible`. This prop will display an ask bubble in the bottom-right of your screen. Whenever someone clicks on it, the search widget will open. |
|
|
108
108
|
| `loadingStrategy` | `eager \| lazy` | `optional` | Default value is `lazy`. While `lazy` loading delays the initialization of a resource, `eager` loading initializes or loads the widget as soon as the code is executed. |
|
|
109
|
+
| `anchor` | `string` | `optional` | You can provide your `class`, `id` or `path` to a DOM element where you would like the widget to anchor and instantiate. The container provided should have `position: relative` as the widget will be displayed based on the first relative parent found. |
|
|
109
110
|
| `onWidgetOpen` | `void` | `optional` | Callback that is called after widget opens. |
|
|
110
111
|
| `onWidgetClose` | `void` | `optional` | Callback that is called after widget closes. |
|
|
111
112
|
|
package/index.esm.js
CHANGED
|
@@ -2,47 +2,6 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import React, { forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
|
|
5
|
-
const initScripts = () => {
|
|
6
|
-
var _a;
|
|
7
|
-
const widgetcsslink = document.createElement('link');
|
|
8
|
-
const link = document.getElementsByTagName('link')[0];
|
|
9
|
-
const mainurl = "https://widget.archbee.com/v1";
|
|
10
|
-
widgetcsslink['rel'] = 'stylesheet';
|
|
11
|
-
widgetcsslink['href'] = `${mainurl}/main.css`;
|
|
12
|
-
if (!link) {
|
|
13
|
-
document.getElementsByTagName('head')[0].append(widgetcsslink);
|
|
14
|
-
}
|
|
15
|
-
(_a = link === null || link === void 0 ? void 0 : link.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(widgetcsslink);
|
|
16
|
-
};
|
|
17
|
-
const initJsScripts = loadingStrategy => {
|
|
18
|
-
var _a;
|
|
19
|
-
const mainUrl = "https://widget.archbee.com/v1";
|
|
20
|
-
let scripttag = document.createElement('script');
|
|
21
|
-
scripttag['async'] = loadingStrategy === 'lazy';
|
|
22
|
-
scripttag['src'] = `${mainUrl}/main.js`;
|
|
23
|
-
const script = document.getElementsByTagName('script')[0];
|
|
24
|
-
(_a = script === null || script === void 0 ? void 0 : script.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(scripttag, script);
|
|
25
|
-
};
|
|
26
|
-
const createArchbeeWidget = (spaceId, jwt, shareableToken, loadingStrategy = 'lazy', bubble = 'invisible') => {
|
|
27
|
-
if (!window._archbee) {
|
|
28
|
-
window._archbee = window._archbee || {
|
|
29
|
-
queue: [],
|
|
30
|
-
push: function (event) {
|
|
31
|
-
window._archbee.queue.push(event);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
window._archbee.push({
|
|
35
|
-
eventType: 'init',
|
|
36
|
-
spaceId,
|
|
37
|
-
jwt,
|
|
38
|
-
shareableToken,
|
|
39
|
-
bubble
|
|
40
|
-
});
|
|
41
|
-
initJsScripts(loadingStrategy);
|
|
42
|
-
}
|
|
43
|
-
return window._archbee;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
47
6
|
|
|
48
7
|
var check = function (it) {
|
|
@@ -1050,15 +1009,166 @@ var _export = function (options, source) {
|
|
|
1050
1009
|
}
|
|
1051
1010
|
};
|
|
1052
1011
|
|
|
1012
|
+
var internalObjectKeys = objectKeysInternal;
|
|
1013
|
+
var enumBugKeys$1 = enumBugKeys$3;
|
|
1014
|
+
|
|
1015
|
+
// `Object.keys` method
|
|
1016
|
+
// https://tc39.es/ecma262/#sec-object.keys
|
|
1017
|
+
// eslint-disable-next-line es/no-object-keys -- safe
|
|
1018
|
+
var objectKeys$2 = Object.keys || function keys(O) {
|
|
1019
|
+
return internalObjectKeys(O, enumBugKeys$1);
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1022
|
+
var DESCRIPTORS$1 = descriptors;
|
|
1023
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
1024
|
+
var call$1 = functionCall;
|
|
1025
|
+
var fails$3 = fails$c;
|
|
1026
|
+
var objectKeys$1 = objectKeys$2;
|
|
1027
|
+
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
|
1028
|
+
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
1029
|
+
var toObject$1 = toObject$3;
|
|
1030
|
+
var IndexedObject = indexedObject;
|
|
1031
|
+
|
|
1032
|
+
// eslint-disable-next-line es/no-object-assign -- safe
|
|
1033
|
+
var $assign = Object.assign;
|
|
1034
|
+
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
1035
|
+
var defineProperty$1 = Object.defineProperty;
|
|
1036
|
+
var concat = uncurryThis$1([].concat);
|
|
1037
|
+
|
|
1038
|
+
// `Object.assign` method
|
|
1039
|
+
// https://tc39.es/ecma262/#sec-object.assign
|
|
1040
|
+
var objectAssign = !$assign || fails$3(function () {
|
|
1041
|
+
// should have correct order of operations (Edge bug)
|
|
1042
|
+
if (DESCRIPTORS$1 && $assign({ b: 1 }, $assign(defineProperty$1({}, 'a', {
|
|
1043
|
+
enumerable: true,
|
|
1044
|
+
get: function () {
|
|
1045
|
+
defineProperty$1(this, 'b', {
|
|
1046
|
+
value: 3,
|
|
1047
|
+
enumerable: false
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}), { b: 2 })).b !== 1) return true;
|
|
1051
|
+
// should work with symbols and should have deterministic property order (V8 bug)
|
|
1052
|
+
var A = {};
|
|
1053
|
+
var B = {};
|
|
1054
|
+
// eslint-disable-next-line es/no-symbol -- safe
|
|
1055
|
+
var symbol = Symbol('assign detection');
|
|
1056
|
+
var alphabet = 'abcdefghijklmnopqrst';
|
|
1057
|
+
A[symbol] = 7;
|
|
1058
|
+
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
|
1059
|
+
return $assign({}, A)[symbol] !== 7 || objectKeys$1($assign({}, B)).join('') !== alphabet;
|
|
1060
|
+
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
|
|
1061
|
+
var T = toObject$1(target);
|
|
1062
|
+
var argumentsLength = arguments.length;
|
|
1063
|
+
var index = 1;
|
|
1064
|
+
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
1065
|
+
var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
|
1066
|
+
while (argumentsLength > index) {
|
|
1067
|
+
var S = IndexedObject(arguments[index++]);
|
|
1068
|
+
var keys = getOwnPropertySymbols ? concat(objectKeys$1(S), getOwnPropertySymbols(S)) : objectKeys$1(S);
|
|
1069
|
+
var length = keys.length;
|
|
1070
|
+
var j = 0;
|
|
1071
|
+
var key;
|
|
1072
|
+
while (length > j) {
|
|
1073
|
+
key = keys[j++];
|
|
1074
|
+
if (!DESCRIPTORS$1 || call$1(propertyIsEnumerable, S, key)) T[key] = S[key];
|
|
1075
|
+
}
|
|
1076
|
+
} return T;
|
|
1077
|
+
} : $assign;
|
|
1078
|
+
|
|
1079
|
+
var $$3 = _export;
|
|
1080
|
+
var assign = objectAssign;
|
|
1081
|
+
|
|
1082
|
+
// `Object.assign` method
|
|
1083
|
+
// https://tc39.es/ecma262/#sec-object.assign
|
|
1084
|
+
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1085
|
+
$$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
|
|
1086
|
+
assign: assign
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
/******************************************************************************
|
|
1090
|
+
Copyright (c) Microsoft Corporation.
|
|
1091
|
+
|
|
1092
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1093
|
+
purpose with or without fee is hereby granted.
|
|
1094
|
+
|
|
1095
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1096
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1097
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1098
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1099
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1100
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1101
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1102
|
+
***************************************************************************** */
|
|
1103
|
+
|
|
1104
|
+
function __rest(s, e) {
|
|
1105
|
+
var t = {};
|
|
1106
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1107
|
+
t[p] = s[p];
|
|
1108
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1109
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1110
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1111
|
+
t[p[i]] = s[p[i]];
|
|
1112
|
+
}
|
|
1113
|
+
return t;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1117
|
+
var e = new Error(message);
|
|
1118
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
const initScripts = () => {
|
|
1122
|
+
var _a;
|
|
1123
|
+
const widgetcsslink = document.createElement('link');
|
|
1124
|
+
const link = document.getElementsByTagName('link')[0];
|
|
1125
|
+
const mainurl = "https://widget.archbee.com/v1";
|
|
1126
|
+
widgetcsslink['rel'] = 'stylesheet';
|
|
1127
|
+
widgetcsslink['href'] = `${mainurl}/main.css`;
|
|
1128
|
+
if (!link) {
|
|
1129
|
+
document.getElementsByTagName('head')[0].append(widgetcsslink);
|
|
1130
|
+
}
|
|
1131
|
+
(_a = link === null || link === void 0 ? void 0 : link.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(widgetcsslink);
|
|
1132
|
+
};
|
|
1133
|
+
const initJsScripts = loadingStrategy => {
|
|
1134
|
+
var _a;
|
|
1135
|
+
const mainUrl = "https://widget.archbee.com/v1";
|
|
1136
|
+
let scripttag = document.createElement('script');
|
|
1137
|
+
scripttag['async'] = loadingStrategy === 'lazy';
|
|
1138
|
+
scripttag['src'] = `${mainUrl}/main.js`;
|
|
1139
|
+
const script = document.getElementsByTagName('script')[0];
|
|
1140
|
+
(_a = script === null || script === void 0 ? void 0 : script.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(scripttag, script);
|
|
1141
|
+
};
|
|
1142
|
+
const createArchbeeWidget = (spaceId, jwt, shareableToken, loadingStrategy = 'lazy', bubble = 'invisible', anchor) => {
|
|
1143
|
+
if (!window._archbee) {
|
|
1144
|
+
window._archbee = window._archbee || {
|
|
1145
|
+
queue: [],
|
|
1146
|
+
push: function (event) {
|
|
1147
|
+
window._archbee.queue.push(event);
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
window._archbee.push({
|
|
1151
|
+
eventType: 'init',
|
|
1152
|
+
spaceId,
|
|
1153
|
+
jwt,
|
|
1154
|
+
shareableToken,
|
|
1155
|
+
bubble,
|
|
1156
|
+
anchor
|
|
1157
|
+
});
|
|
1158
|
+
initJsScripts(loadingStrategy);
|
|
1159
|
+
}
|
|
1160
|
+
return window._archbee;
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1053
1163
|
var hasOwn$1 = hasOwnProperty_1;
|
|
1054
1164
|
|
|
1055
1165
|
var isDataDescriptor$1 = function (descriptor) {
|
|
1056
1166
|
return descriptor !== undefined && (hasOwn$1(descriptor, 'value') || hasOwn$1(descriptor, 'writable'));
|
|
1057
1167
|
};
|
|
1058
1168
|
|
|
1059
|
-
var fails$
|
|
1169
|
+
var fails$2 = fails$c;
|
|
1060
1170
|
|
|
1061
|
-
var correctPrototypeGetter = !fails$
|
|
1171
|
+
var correctPrototypeGetter = !fails$2(function () {
|
|
1062
1172
|
function F() { /* empty */ }
|
|
1063
1173
|
F.prototype.constructor = null;
|
|
1064
1174
|
// eslint-disable-next-line es/no-object-getprototypeof -- required for testing
|
|
@@ -1067,7 +1177,7 @@ var correctPrototypeGetter = !fails$3(function () {
|
|
|
1067
1177
|
|
|
1068
1178
|
var hasOwn = hasOwnProperty_1;
|
|
1069
1179
|
var isCallable$1 = isCallable$c;
|
|
1070
|
-
var toObject
|
|
1180
|
+
var toObject = toObject$3;
|
|
1071
1181
|
var sharedKey$1 = sharedKey$3;
|
|
1072
1182
|
var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
|
|
1073
1183
|
|
|
@@ -1079,7 +1189,7 @@ var ObjectPrototype = $Object$1.prototype;
|
|
|
1079
1189
|
// https://tc39.es/ecma262/#sec-object.getprototypeof
|
|
1080
1190
|
// eslint-disable-next-line es/no-object-getprototypeof -- safe
|
|
1081
1191
|
var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf : function (O) {
|
|
1082
|
-
var object = toObject
|
|
1192
|
+
var object = toObject(O);
|
|
1083
1193
|
if (hasOwn(object, IE_PROTO$1)) return object[IE_PROTO$1];
|
|
1084
1194
|
var constructor = object.constructor;
|
|
1085
1195
|
if (isCallable$1(constructor) && object instanceof constructor) {
|
|
@@ -1087,12 +1197,12 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf :
|
|
|
1087
1197
|
} return object instanceof $Object$1 ? ObjectPrototype : null;
|
|
1088
1198
|
};
|
|
1089
1199
|
|
|
1090
|
-
var $$
|
|
1091
|
-
var call
|
|
1200
|
+
var $$2 = _export;
|
|
1201
|
+
var call = functionCall;
|
|
1092
1202
|
var anObject$2 = anObject$5;
|
|
1093
1203
|
var isObject$1 = isObject$7;
|
|
1094
1204
|
var isDataDescriptor = isDataDescriptor$1;
|
|
1095
|
-
var fails$
|
|
1205
|
+
var fails$1 = fails$c;
|
|
1096
1206
|
var definePropertyModule$1 = objectDefineProperty;
|
|
1097
1207
|
var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
|
|
1098
1208
|
var getPrototypeOf = objectGetPrototypeOf;
|
|
@@ -1120,49 +1230,39 @@ function set(target, propertyKey, V /* , receiver */) {
|
|
|
1120
1230
|
} else {
|
|
1121
1231
|
setter = ownDescriptor.set;
|
|
1122
1232
|
if (setter === undefined) return false;
|
|
1123
|
-
call
|
|
1233
|
+
call(setter, receiver, V);
|
|
1124
1234
|
} return true;
|
|
1125
1235
|
}
|
|
1126
1236
|
|
|
1127
1237
|
// MS Edge 17-18 Reflect.set allows setting the property to object
|
|
1128
1238
|
// with non-writable property on the prototype
|
|
1129
|
-
var MS_EDGE_BUG = fails$
|
|
1239
|
+
var MS_EDGE_BUG = fails$1(function () {
|
|
1130
1240
|
var Constructor = function () { /* empty */ };
|
|
1131
1241
|
var object = definePropertyModule$1.f(new Constructor(), 'a', { configurable: true });
|
|
1132
1242
|
// eslint-disable-next-line es/no-reflect -- required for testing
|
|
1133
1243
|
return Reflect.set(Constructor.prototype, 'a', 1, object) !== false;
|
|
1134
1244
|
});
|
|
1135
1245
|
|
|
1136
|
-
$$
|
|
1246
|
+
$$2({ target: 'Reflect', stat: true, forced: MS_EDGE_BUG }, {
|
|
1137
1247
|
set: set
|
|
1138
1248
|
});
|
|
1139
1249
|
|
|
1140
1250
|
var objectDefineProperties = {};
|
|
1141
1251
|
|
|
1142
|
-
var
|
|
1143
|
-
var enumBugKeys$1 = enumBugKeys$3;
|
|
1144
|
-
|
|
1145
|
-
// `Object.keys` method
|
|
1146
|
-
// https://tc39.es/ecma262/#sec-object.keys
|
|
1147
|
-
// eslint-disable-next-line es/no-object-keys -- safe
|
|
1148
|
-
var objectKeys$2 = Object.keys || function keys(O) {
|
|
1149
|
-
return internalObjectKeys(O, enumBugKeys$1);
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
var DESCRIPTORS$1 = descriptors;
|
|
1252
|
+
var DESCRIPTORS = descriptors;
|
|
1153
1253
|
var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
|
|
1154
1254
|
var definePropertyModule = objectDefineProperty;
|
|
1155
1255
|
var anObject$1 = anObject$5;
|
|
1156
1256
|
var toIndexedObject = toIndexedObject$4;
|
|
1157
|
-
var objectKeys
|
|
1257
|
+
var objectKeys = objectKeys$2;
|
|
1158
1258
|
|
|
1159
1259
|
// `Object.defineProperties` method
|
|
1160
1260
|
// https://tc39.es/ecma262/#sec-object.defineproperties
|
|
1161
1261
|
// eslint-disable-next-line es/no-object-defineproperties -- safe
|
|
1162
|
-
objectDefineProperties.f = DESCRIPTORS
|
|
1262
|
+
objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
1163
1263
|
anObject$1(O);
|
|
1164
1264
|
var props = toIndexedObject(Properties);
|
|
1165
|
-
var keys = objectKeys
|
|
1265
|
+
var keys = objectKeys(Properties);
|
|
1166
1266
|
var length = keys.length;
|
|
1167
1267
|
var index = 0;
|
|
1168
1268
|
var key;
|
|
@@ -1260,7 +1360,7 @@ var objectCreate = Object.create || function create(O, Properties) {
|
|
|
1260
1360
|
|
|
1261
1361
|
var wellKnownSymbol$4 = wellKnownSymbol$6;
|
|
1262
1362
|
var create = objectCreate;
|
|
1263
|
-
var defineProperty
|
|
1363
|
+
var defineProperty = objectDefineProperty.f;
|
|
1264
1364
|
|
|
1265
1365
|
var UNSCOPABLES = wellKnownSymbol$4('unscopables');
|
|
1266
1366
|
var ArrayPrototype = Array.prototype;
|
|
@@ -1268,7 +1368,7 @@ var ArrayPrototype = Array.prototype;
|
|
|
1268
1368
|
// Array.prototype[@@unscopables]
|
|
1269
1369
|
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
1270
1370
|
if (ArrayPrototype[UNSCOPABLES] === undefined) {
|
|
1271
|
-
defineProperty
|
|
1371
|
+
defineProperty(ArrayPrototype, UNSCOPABLES, {
|
|
1272
1372
|
configurable: true,
|
|
1273
1373
|
value: create(null)
|
|
1274
1374
|
});
|
|
@@ -1279,20 +1379,20 @@ var addToUnscopables$1 = function (key) {
|
|
|
1279
1379
|
ArrayPrototype[UNSCOPABLES][key] = true;
|
|
1280
1380
|
};
|
|
1281
1381
|
|
|
1282
|
-
var $$
|
|
1382
|
+
var $$1 = _export;
|
|
1283
1383
|
var $includes = arrayIncludes.includes;
|
|
1284
|
-
var fails
|
|
1384
|
+
var fails = fails$c;
|
|
1285
1385
|
var addToUnscopables = addToUnscopables$1;
|
|
1286
1386
|
|
|
1287
1387
|
// FF99+ bug
|
|
1288
|
-
var BROKEN_ON_SPARSE = fails
|
|
1388
|
+
var BROKEN_ON_SPARSE = fails(function () {
|
|
1289
1389
|
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
1290
1390
|
return !Array(1).includes();
|
|
1291
1391
|
});
|
|
1292
1392
|
|
|
1293
1393
|
// `Array.prototype.includes` method
|
|
1294
1394
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
1295
|
-
$$
|
|
1395
|
+
$$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
1296
1396
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
1297
1397
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
1298
1398
|
}
|
|
@@ -1388,18 +1488,18 @@ var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
|
1388
1488
|
} return false;
|
|
1389
1489
|
};
|
|
1390
1490
|
|
|
1391
|
-
var
|
|
1392
|
-
var uncurryThis
|
|
1491
|
+
var $ = _export;
|
|
1492
|
+
var uncurryThis = functionUncurryThis;
|
|
1393
1493
|
var notARegExp = notARegexp;
|
|
1394
1494
|
var requireObjectCoercible = requireObjectCoercible$3;
|
|
1395
1495
|
var toString = toString$1;
|
|
1396
1496
|
var correctIsRegExpLogic = correctIsRegexpLogic;
|
|
1397
1497
|
|
|
1398
|
-
var stringIndexOf = uncurryThis
|
|
1498
|
+
var stringIndexOf = uncurryThis(''.indexOf);
|
|
1399
1499
|
|
|
1400
1500
|
// `String.prototype.includes` method
|
|
1401
1501
|
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
1402
|
-
|
|
1502
|
+
$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
|
|
1403
1503
|
includes: function includes(searchString /* , position = 0 */) {
|
|
1404
1504
|
return !!~stringIndexOf(
|
|
1405
1505
|
toString(requireObjectCoercible(this)),
|
|
@@ -1425,101 +1525,43 @@ const hideWidgetEvent = () => {
|
|
|
1425
1525
|
return new CustomEvent(EVENT_TYPE_ENUM.hideWidget);
|
|
1426
1526
|
};
|
|
1427
1527
|
|
|
1428
|
-
const render = (component, cb) => {
|
|
1528
|
+
const render = (component, createContainer, cb) => {
|
|
1529
|
+
createContainer();
|
|
1429
1530
|
const element = document.getElementsByClassName('ab-widget')[0];
|
|
1430
1531
|
ReactDOM.render(jsx(React.StrictMode, {
|
|
1431
1532
|
children: component
|
|
1432
1533
|
}), element, () => cb && cb(element));
|
|
1433
1534
|
};
|
|
1434
1535
|
|
|
1435
|
-
var DESCRIPTORS = descriptors;
|
|
1436
|
-
var uncurryThis = functionUncurryThis;
|
|
1437
|
-
var call = functionCall;
|
|
1438
|
-
var fails = fails$c;
|
|
1439
|
-
var objectKeys = objectKeys$2;
|
|
1440
|
-
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
|
1441
|
-
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
1442
|
-
var toObject = toObject$3;
|
|
1443
|
-
var IndexedObject = indexedObject;
|
|
1444
|
-
|
|
1445
|
-
// eslint-disable-next-line es/no-object-assign -- safe
|
|
1446
|
-
var $assign = Object.assign;
|
|
1447
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
1448
|
-
var defineProperty = Object.defineProperty;
|
|
1449
|
-
var concat = uncurryThis([].concat);
|
|
1450
|
-
|
|
1451
|
-
// `Object.assign` method
|
|
1452
|
-
// https://tc39.es/ecma262/#sec-object.assign
|
|
1453
|
-
var objectAssign = !$assign || fails(function () {
|
|
1454
|
-
// should have correct order of operations (Edge bug)
|
|
1455
|
-
if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
|
|
1456
|
-
enumerable: true,
|
|
1457
|
-
get: function () {
|
|
1458
|
-
defineProperty(this, 'b', {
|
|
1459
|
-
value: 3,
|
|
1460
|
-
enumerable: false
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
}), { b: 2 })).b !== 1) return true;
|
|
1464
|
-
// should work with symbols and should have deterministic property order (V8 bug)
|
|
1465
|
-
var A = {};
|
|
1466
|
-
var B = {};
|
|
1467
|
-
// eslint-disable-next-line es/no-symbol -- safe
|
|
1468
|
-
var symbol = Symbol('assign detection');
|
|
1469
|
-
var alphabet = 'abcdefghijklmnopqrst';
|
|
1470
|
-
A[symbol] = 7;
|
|
1471
|
-
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
|
1472
|
-
return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
|
|
1473
|
-
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
|
|
1474
|
-
var T = toObject(target);
|
|
1475
|
-
var argumentsLength = arguments.length;
|
|
1476
|
-
var index = 1;
|
|
1477
|
-
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
1478
|
-
var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
|
1479
|
-
while (argumentsLength > index) {
|
|
1480
|
-
var S = IndexedObject(arguments[index++]);
|
|
1481
|
-
var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
|
|
1482
|
-
var length = keys.length;
|
|
1483
|
-
var j = 0;
|
|
1484
|
-
var key;
|
|
1485
|
-
while (length > j) {
|
|
1486
|
-
key = keys[j++];
|
|
1487
|
-
if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
|
|
1488
|
-
}
|
|
1489
|
-
} return T;
|
|
1490
|
-
} : $assign;
|
|
1491
|
-
|
|
1492
|
-
var $ = _export;
|
|
1493
|
-
var assign = objectAssign;
|
|
1494
|
-
|
|
1495
|
-
// `Object.assign` method
|
|
1496
|
-
// https://tc39.es/ecma262/#sec-object.assign
|
|
1497
|
-
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1498
|
-
$({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
|
|
1499
|
-
assign: assign
|
|
1500
|
-
});
|
|
1501
|
-
|
|
1502
1536
|
const setWidget = widget => {
|
|
1503
1537
|
window._archbee.widget = Object.assign({}, widget);
|
|
1504
1538
|
window._archbee.widget.isOpen = false;
|
|
1505
1539
|
};
|
|
1506
1540
|
const loadWidget = (widg, render) => {
|
|
1541
|
+
var _a;
|
|
1507
1542
|
if (typeof document.addEventListener !== 'function') {
|
|
1508
1543
|
return;
|
|
1509
1544
|
}
|
|
1510
|
-
window._archbee.widget = Object.assign(Object.assign({}, window._archbee.widget), widg);
|
|
1545
|
+
window._archbee.widget = Object.assign(Object.assign({}, (_a = window._archbee) === null || _a === void 0 ? void 0 : _a.widget), widg);
|
|
1511
1546
|
try {
|
|
1512
|
-
render(widg.onRenderFinish);
|
|
1547
|
+
render(createContainer, widg.onRenderFinish);
|
|
1513
1548
|
} catch (err) {
|
|
1514
1549
|
console.log(err);
|
|
1515
1550
|
}
|
|
1516
1551
|
};
|
|
1517
1552
|
const createContainer = () => {
|
|
1553
|
+
var _a, _b, _c, _d;
|
|
1518
1554
|
if (document.getElementsByClassName('ab-widget').length) return;
|
|
1519
1555
|
const abDiv = document.createElement('div');
|
|
1520
1556
|
abDiv.style.cssText = 'visibility:hidden';
|
|
1521
1557
|
abDiv.className = `ab-widget ab-id-${Date.now()}`;
|
|
1522
|
-
|
|
1558
|
+
if (!((_b = (_a = window._archbee) === null || _a === void 0 ? void 0 : _a.widget) === null || _b === void 0 ? void 0 : _b.anchor)) {
|
|
1559
|
+
document.body.appendChild(abDiv);
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const anchor = document.querySelector((_d = (_c = window._archbee) === null || _c === void 0 ? void 0 : _c.widget) === null || _d === void 0 ? void 0 : _d.anchor);
|
|
1563
|
+
if (!anchor) return;
|
|
1564
|
+
anchor.appendChild(abDiv);
|
|
1523
1565
|
};
|
|
1524
1566
|
|
|
1525
1567
|
const registerProxy = component => {
|
|
@@ -1584,25 +1626,28 @@ const iterateProxy = (proxy, component) => {
|
|
|
1584
1626
|
});
|
|
1585
1627
|
};
|
|
1586
1628
|
|
|
1587
|
-
const ArchbeeAppWidget = /*#__PURE__*/forwardRef(({
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1629
|
+
const ArchbeeAppWidget = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1630
|
+
var {
|
|
1631
|
+
className,
|
|
1632
|
+
spaceId,
|
|
1633
|
+
jwt,
|
|
1634
|
+
shareableToken,
|
|
1635
|
+
docId,
|
|
1636
|
+
blockId,
|
|
1637
|
+
widgetType = 'docs',
|
|
1638
|
+
loadingStrategy = 'lazy',
|
|
1639
|
+
onWidgetOpen,
|
|
1640
|
+
onWidgetClose,
|
|
1641
|
+
bubble,
|
|
1642
|
+
anchor,
|
|
1643
|
+
children
|
|
1644
|
+
} = _a,
|
|
1645
|
+
rest = __rest(_a, ["className", "spaceId", "jwt", "shareableToken", "docId", "blockId", "widgetType", "loadingStrategy", "onWidgetOpen", "onWidgetClose", "bubble", "anchor", "children"]);
|
|
1601
1646
|
const elementRef = useRef(null);
|
|
1602
1647
|
const widgetInstance = useMemo(() => {
|
|
1603
1648
|
if (typeof window === 'undefined') return;
|
|
1604
|
-
return createArchbeeWidget(spaceId, jwt, shareableToken,
|
|
1605
|
-
}, [spaceId, jwt, shareableToken,
|
|
1649
|
+
return createArchbeeWidget(spaceId, jwt, shareableToken, loadingStrategy, bubble, anchor);
|
|
1650
|
+
}, [spaceId, jwt, shareableToken, loadingStrategy, bubble]);
|
|
1606
1651
|
useImperativeHandle(ref, () => {
|
|
1607
1652
|
return {
|
|
1608
1653
|
open: onOpenWidget,
|
|
@@ -1613,7 +1658,7 @@ const ArchbeeAppWidget = /*#__PURE__*/forwardRef(({
|
|
|
1613
1658
|
const onOpenWidget = () => {
|
|
1614
1659
|
widgetInstance === null || widgetInstance === void 0 ? void 0 : widgetInstance.push({
|
|
1615
1660
|
eventType: 'show-widget',
|
|
1616
|
-
widgetType
|
|
1661
|
+
widgetType,
|
|
1617
1662
|
docId,
|
|
1618
1663
|
blockId
|
|
1619
1664
|
});
|
|
@@ -1632,12 +1677,13 @@ const ArchbeeAppWidget = /*#__PURE__*/forwardRef(({
|
|
|
1632
1677
|
onOpenWidget();
|
|
1633
1678
|
}
|
|
1634
1679
|
};
|
|
1635
|
-
return jsx("div", {
|
|
1680
|
+
return jsx("div", Object.assign({
|
|
1636
1681
|
className: className !== null && className !== void 0 ? className : '',
|
|
1637
1682
|
ref: elementRef,
|
|
1638
|
-
onClick: onElementClicked
|
|
1683
|
+
onClick: onElementClicked
|
|
1684
|
+
}, rest, {
|
|
1639
1685
|
children: children
|
|
1640
|
-
});
|
|
1686
|
+
}));
|
|
1641
1687
|
});
|
|
1642
1688
|
|
|
1643
1689
|
export { ArchbeeAppWidget, EVENT_TYPE_ENUM, EVENT_TYPE_LIST, createArchbeeWidget, createContainer, hideWidgetEvent, initJsScripts, initScripts, iterateProxy, loadWidget, registerProxy, render, setWidget, showWidgetEvent };
|
package/package.json
CHANGED
package/src/lib/main.d.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { AbWidgetData, AbWidgetRef } from './types';
|
|
3
|
+
type CommonWidgetData = Omit<AbWidgetData, 'spaceId' | 'isOpen' | 'eventType' | 'collectionId' | 'onRenderFinish' | 'hasExecuted'>;
|
|
4
|
+
export declare const ArchbeeAppWidget: import("react").ForwardRefExoticComponent<{
|
|
3
5
|
spaceId: string;
|
|
4
|
-
docId?: string;
|
|
5
|
-
jwt?: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
shareableToken?: string;
|
|
8
|
-
widgetType: WidgetType;
|
|
9
|
-
bubble?: BubbleType;
|
|
10
|
-
blockId?: string;
|
|
11
6
|
user?: {
|
|
12
|
-
id: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
first_name?: string;
|
|
15
|
-
last_name?: string;
|
|
16
|
-
profile_image_url?: string;
|
|
17
7
|
[key: string]: any;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
id: string;
|
|
9
|
+
email?: string | undefined;
|
|
10
|
+
first_name?: string | undefined;
|
|
11
|
+
last_name?: string | undefined;
|
|
12
|
+
profile_image_url?: string | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
onWidgetOpen?: Function | undefined;
|
|
15
|
+
onWidgetClose?: Function | undefined;
|
|
16
|
+
} & CommonWidgetData & HTMLAttributes<HTMLDivElement> & {
|
|
24
17
|
children?: import("react").ReactNode;
|
|
25
18
|
} & import("react").RefAttributes<AbWidgetRef>>;
|
|
26
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BubbleType, LoadingStrategy } from '../types';
|
|
2
2
|
export declare const initScripts: () => void;
|
|
3
3
|
export declare const initJsScripts: (loadingStrategy: LoadingStrategy) => void;
|
|
4
|
-
export declare const createArchbeeWidget: (spaceId: string, jwt?: string, shareableToken?: string, loadingStrategy?: LoadingStrategy, bubble?: BubbleType) => any;
|
|
4
|
+
export declare const createArchbeeWidget: (spaceId: string, jwt?: string, shareableToken?: string, loadingStrategy?: LoadingStrategy, bubble?: BubbleType, anchor?: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const render: (component: JSX.Element, cb?: Function) => void;
|
|
1
|
+
export declare const render: (component: JSX.Element, createContainer: Function, cb?: Function) => void;
|
package/src/lib/types.d.ts
CHANGED
|
@@ -18,14 +18,14 @@ export interface AbWidgetData {
|
|
|
18
18
|
docId?: string;
|
|
19
19
|
blockId?: string;
|
|
20
20
|
isOpen: boolean;
|
|
21
|
-
selector: string;
|
|
22
|
-
origin?: string;
|
|
23
21
|
onRenderFinish?: Function;
|
|
24
22
|
hasExecuted: boolean;
|
|
25
23
|
jwt?: string;
|
|
26
24
|
shareableToken?: string;
|
|
27
25
|
widgetType?: WidgetType;
|
|
28
26
|
bubble?: BubbleType;
|
|
27
|
+
anchor?: string;
|
|
28
|
+
loadingStrategy?: LoadingStrategy;
|
|
29
29
|
}
|
|
30
30
|
type AbWidgetActionType = 'ab-doc-open' | 'ab-doc-close';
|
|
31
31
|
export interface AbWidgetAction {
|