@sitecore-feaas/clientside 0.0.9 → 0.1.1
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 +5 -5
- package/dist/browser/basic.cjs +67 -0
- package/dist/browser/basic.js +67 -0
- package/dist/browser/index.cjs +68 -79
- package/dist/browser/index.js +68 -79
- package/dist/node/{react.cjs → basic.cjs} +436 -443
- package/dist/node/{react.js → basic.js} +432 -439
- package/dist/node/index.cjs +666 -291
- package/dist/node/index.js +666 -295
- package/examples/index.html +1 -1
- package/package.json +17 -17
- package/src/basic.ts +5 -0
- package/src/cloud.ts +9 -5
- package/src/components/FEAASBase.tsx +265 -0
- package/src/components/FEAASComponent.ts +98 -0
- package/src/components/FEAASContext.tsx +105 -0
- package/src/components/FEAASEditor.tsx +291 -0
- package/src/components/FEAASLoader.ts +113 -0
- package/src/components/FEAASPicker.tsx +98 -0
- package/src/components/FEAASStylesheet.ts +43 -0
- package/src/components/index.tsx +7 -0
- package/src/index.ts +4 -11
- package/test/components.js +11 -0
- package/test/components.ts +12 -0
- package/test/render.js +688 -0
- package/tsconfig.json +11 -6
- package/types/basic.d.ts +5 -0
- package/types/cloud.d.ts +18 -0
- package/types/components/FEAASBase.d.ts +70 -0
- package/types/components/FEAASComponent.d.ts +39 -0
- package/types/components/FEAASContext.d.ts +43 -0
- package/types/components/FEAASEditor.d.ts +70 -0
- package/types/components/FEAASLoader.d.ts +20 -0
- package/types/components/FEAASPicker.d.ts +61 -0
- package/types/components/FEAASStylesheet.d.ts +25 -0
- package/types/components/index.d.ts +7 -0
- package/types/dom.d.ts +29 -0
- package/types/fetch.d.ts +1 -0
- package/types/index.d.ts +4 -0
- package/types/tsbuildinfo +1 -0
- package/dist/browser/index.d.ts +0 -25
- package/dist/browser/react.cjs +0 -83
- package/dist/browser/react.d.ts +0 -36
- package/dist/browser/react.js +0 -83
- package/dist/browser/webcomponent-6b45b819.d.ts +0 -120
- package/dist/node/index.d.ts +0 -25
- package/dist/node/react.d.ts +0 -36
- package/dist/node/webcomponent-6b45b819.d.ts +0 -120
- package/index.cjs +0 -83
- package/index.d.ts +0 -25
- package/index.js +0 -83
- package/react.cjs +0 -83
- package/react.d.ts +0 -36
- package/react.js +0 -83
- package/src/react.ts +0 -66
- package/src/webcomponent.ts +0 -393
- package/webcomponent-6b45b819.d.ts +0 -120
package/dist/node/index.cjs
CHANGED
|
@@ -56,12 +56,24 @@ var __async = (__this, __arguments, generator) => {
|
|
|
56
56
|
// src/index.ts
|
|
57
57
|
var src_exports = {};
|
|
58
58
|
__export(src_exports, {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
FEAASComponent: () => FEAASComponent,
|
|
60
|
+
FEAASComponentsProps: () => FEAASComponentsProps,
|
|
61
|
+
FEAASContext: () => FEAASContext,
|
|
62
|
+
FEAASContextProps: () => FEAASContextProps,
|
|
63
|
+
FEAASEditor: () => FEAASEditor,
|
|
64
|
+
FEAASEditorProps: () => FEAASEditorProps,
|
|
65
|
+
FEAASLoader: () => FEAASLoader,
|
|
66
|
+
FEAASLoaderProps: () => FEAASLoaderProps,
|
|
67
|
+
FEAASPicker: () => FEAASPicker,
|
|
68
|
+
FEAASPickerLazy: () => FEAASPickerLazy,
|
|
69
|
+
FEAASPickerLazyProps: () => FEAASPickerLazyProps,
|
|
70
|
+
FEAASPickerProps: () => FEAASPickerProps,
|
|
71
|
+
FEAASStylesheet: () => FEAASStylesheet,
|
|
72
|
+
FEAASStylesheetProps: () => FEAASStylesheetProps,
|
|
61
73
|
autoloadScripts: () => autoloadScripts,
|
|
62
74
|
cleanCollectionBit: () => cleanCollectionBit,
|
|
63
|
-
default: () => src_default,
|
|
64
75
|
fetchAndRevalidate: () => fetchAndRevalidate,
|
|
76
|
+
getFramePosition: () => getFramePosition,
|
|
65
77
|
loadScript: () => loadScript,
|
|
66
78
|
normalizeCollectionScope: () => normalizeCollectionScope,
|
|
67
79
|
observeDOMElement: () => observeDOMElement,
|
|
@@ -77,25 +89,6 @@ __export(src_exports, {
|
|
|
77
89
|
});
|
|
78
90
|
module.exports = __toCommonJS(src_exports);
|
|
79
91
|
|
|
80
|
-
// src/dom.ts
|
|
81
|
-
var dom_exports = {};
|
|
82
|
-
__export(dom_exports, {
|
|
83
|
-
autoloadScripts: () => autoloadScripts,
|
|
84
|
-
cleanCollectionBit: () => cleanCollectionBit,
|
|
85
|
-
loadScript: () => loadScript,
|
|
86
|
-
normalizeCollectionScope: () => normalizeCollectionScope,
|
|
87
|
-
observeDOMElement: () => observeDOMElement,
|
|
88
|
-
queryScopes: () => queryScopes,
|
|
89
|
-
renderComponent: () => renderComponent,
|
|
90
|
-
renderComponentElement: () => renderComponentElement,
|
|
91
|
-
renderComponentPromise: () => renderComponentPromise,
|
|
92
|
-
renderDOMContent: () => renderDOMContent,
|
|
93
|
-
renderDOMElement: () => renderDOMElement,
|
|
94
|
-
renderStylesheet: () => renderStylesheet,
|
|
95
|
-
renderStylesheetPromise: () => renderStylesheetPromise,
|
|
96
|
-
setDOMAttribute: () => setDOMAttribute
|
|
97
|
-
});
|
|
98
|
-
|
|
99
92
|
// ../node_modules/jsonpath-plus/dist/index-browser-esm.js
|
|
100
93
|
function _typeof(obj) {
|
|
101
94
|
"@babel/helpers - typeof";
|
|
@@ -831,20 +824,22 @@ function fetchAndRevalidate(url, options, validator, callback) {
|
|
|
831
824
|
|
|
832
825
|
// src/cloud.ts
|
|
833
826
|
function getComponentURL({
|
|
834
|
-
|
|
827
|
+
cdn = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
828
|
+
hostname,
|
|
835
829
|
library,
|
|
836
830
|
component,
|
|
837
831
|
version,
|
|
838
832
|
revision = "published"
|
|
839
833
|
}) {
|
|
840
|
-
return `${hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
834
|
+
return `${cdn || hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
841
835
|
}
|
|
842
836
|
function getStylesheetURL({
|
|
843
|
-
|
|
837
|
+
cdn = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
838
|
+
hostname,
|
|
844
839
|
library,
|
|
845
840
|
revision = "published"
|
|
846
841
|
}) {
|
|
847
|
-
return `${hostname}/styles/${library}/${revision}.css`;
|
|
842
|
+
return `${cdn || hostname}/styles/${library}/${revision}.css`;
|
|
848
843
|
}
|
|
849
844
|
function fetchComponent(props, callback) {
|
|
850
845
|
return __async(this, null, function* () {
|
|
@@ -1154,59 +1149,356 @@ function renderComponentPromise(props, root) {
|
|
|
1154
1149
|
});
|
|
1155
1150
|
}
|
|
1156
1151
|
|
|
1157
|
-
// src/
|
|
1158
|
-
var
|
|
1159
|
-
__export(webcomponent_exports, {
|
|
1160
|
-
HTMLFeaasComponent: () => HTMLFeaasComponent,
|
|
1161
|
-
HTMLFeaasStylesheet: () => HTMLFeaasStylesheet
|
|
1162
|
-
});
|
|
1163
|
-
var WebComponent = typeof HTMLElement == "undefined" ? class {
|
|
1164
|
-
} : HTMLElement;
|
|
1165
|
-
var HTMLFeaasComponent = class extends WebComponent {
|
|
1152
|
+
// src/components/FEAASBase.tsx
|
|
1153
|
+
var FEAASBase = class extends HTMLElement {
|
|
1166
1154
|
constructor() {
|
|
1167
1155
|
super(...arguments);
|
|
1168
|
-
this.connected =
|
|
1169
|
-
this.
|
|
1170
|
-
this.
|
|
1171
|
-
this.
|
|
1156
|
+
this.connected = null;
|
|
1157
|
+
this.refs = {};
|
|
1158
|
+
this.descendants = [];
|
|
1159
|
+
this.onLoad = (payload) => {
|
|
1160
|
+
if (payload == null)
|
|
1161
|
+
return;
|
|
1162
|
+
this.payload = payload;
|
|
1163
|
+
this.render();
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
getProps(context) {
|
|
1167
|
+
return {};
|
|
1172
1168
|
}
|
|
1173
|
-
|
|
1174
|
-
return
|
|
1169
|
+
getRoot() {
|
|
1170
|
+
return this;
|
|
1171
|
+
}
|
|
1172
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1173
|
+
this.set();
|
|
1175
1174
|
}
|
|
1176
1175
|
connectedCallback() {
|
|
1177
|
-
|
|
1178
|
-
this.
|
|
1176
|
+
console.log("FEAAS: Connected", this);
|
|
1177
|
+
this.connected = new Event("feaasConnected", { bubbles: true, composed: true });
|
|
1178
|
+
this.dispatchEvent(this.connected);
|
|
1179
|
+
this.addEventListener("feaasConnected", this);
|
|
1180
|
+
this.addEventListener("feaasDisconnected", this);
|
|
1181
|
+
this.set();
|
|
1179
1182
|
}
|
|
1180
1183
|
disconnectedCallback() {
|
|
1184
|
+
console.log("FEAAS: Disconnected", this);
|
|
1185
|
+
this.removeEventListener("feaasConnected", this);
|
|
1186
|
+
this.removeEventListener("feaasDisconnected", this);
|
|
1187
|
+
this.dispatchEvent(new Event("feaasDisconnected", { bubbles: true, composed: true }));
|
|
1188
|
+
this.connected = null;
|
|
1189
|
+
}
|
|
1190
|
+
handleEvent(event) {
|
|
1191
|
+
switch (event.type) {
|
|
1192
|
+
case "feaasConnected":
|
|
1193
|
+
this.adoptedCallback(event);
|
|
1194
|
+
break;
|
|
1195
|
+
case "feaasDisconnected":
|
|
1196
|
+
this.orphanCallback(event);
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1181
1199
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1200
|
+
orphanCallback(event) {
|
|
1201
|
+
const target = event.composedPath()[0];
|
|
1202
|
+
const index = this.descendants.indexOf(target);
|
|
1203
|
+
if (index == -1)
|
|
1184
1204
|
return;
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1205
|
+
console.log("FEAAS: Orphaning", this, target);
|
|
1206
|
+
this.descendants.splice(index, -1);
|
|
1207
|
+
this.refs[target.getComponentName()] = null;
|
|
1208
|
+
if (target.refs.parent == this)
|
|
1209
|
+
target.refs.parent = null;
|
|
1210
|
+
if (target.refs.top == this) {
|
|
1211
|
+
target.refs.top = target.refs.parent;
|
|
1189
1212
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1213
|
+
}
|
|
1214
|
+
adoptedCallback(event) {
|
|
1215
|
+
var _a, _b;
|
|
1216
|
+
const target = event.composedPath()[0];
|
|
1217
|
+
this.descendants.push(target);
|
|
1218
|
+
console.log("FEAAS: Adopting", this, target);
|
|
1219
|
+
this.refs[target.getComponentName()] = target;
|
|
1220
|
+
target.refs.top = this;
|
|
1221
|
+
(_a = target.refs).parent || (_a.parent = this);
|
|
1222
|
+
if (target.renderReact) {
|
|
1223
|
+
for (var p = target.refs.parent; p; p = p.refs.parent) {
|
|
1224
|
+
if (p.renderReact) {
|
|
1225
|
+
(_b = target.refs).parentReact || (_b.parentReact = p);
|
|
1226
|
+
target.refs.topReact = p;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
getComponentName() {
|
|
1232
|
+
return this.tagName.replace("FEAAS-", "").toLowerCase();
|
|
1233
|
+
}
|
|
1234
|
+
isReadyToLoad() {
|
|
1235
|
+
return this.payload === void 0 && this.getAttribute("hidden") == null;
|
|
1236
|
+
}
|
|
1237
|
+
reify() {
|
|
1238
|
+
return __async(this, null, function* () {
|
|
1239
|
+
if (this.payload !== void 0) {
|
|
1195
1240
|
this.render();
|
|
1241
|
+
} else if (this.isReadyToLoad()) {
|
|
1242
|
+
this.payload = null;
|
|
1243
|
+
this.load().then(this.onLoad);
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
load() {
|
|
1248
|
+
return Promise.resolve(null);
|
|
1249
|
+
}
|
|
1250
|
+
render(nested = false) {
|
|
1251
|
+
var _a, _b, _c;
|
|
1252
|
+
console.log("FEAAS: React", this.tagName, this.payload);
|
|
1253
|
+
if (this.payload == null)
|
|
1254
|
+
return;
|
|
1255
|
+
const { React, ReactDOM } = this.payload || {};
|
|
1256
|
+
if (!React)
|
|
1257
|
+
throw new Error(`${this.tagName}: React is not present in payload`);
|
|
1258
|
+
if (!ReactDOM)
|
|
1259
|
+
throw new Error(`${this.tagName}: ReactDOM is not present in payload`);
|
|
1260
|
+
if (!this.refs.topReact && !this.forceUpdateReact) {
|
|
1261
|
+
ReactDOM.render(React.createElement(this.getReactWrapper()), this.getReactRoot());
|
|
1262
|
+
} else if (this.forceUpdateReact) {
|
|
1263
|
+
(_a = this.forceUpdateReact) == null ? void 0 : _a.call(this);
|
|
1264
|
+
} else {
|
|
1265
|
+
(_c = (_b = this.refs.topReact).forceUpdateReact) == null ? void 0 : _c.call(_b);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
invokeReactRendering() {
|
|
1269
|
+
const { React, ReactDOM } = this.payload || {};
|
|
1270
|
+
const children = this.descendants.filter((r) => {
|
|
1271
|
+
return r.refs.parentReact == this && r.payload;
|
|
1272
|
+
}).map((child, index) => {
|
|
1273
|
+
return React.createElement(this.getReactWrapper(child), {
|
|
1274
|
+
key: this.tagName + "-" + index,
|
|
1275
|
+
slot: child.getAttribute("slot")
|
|
1196
1276
|
});
|
|
1277
|
+
});
|
|
1278
|
+
return this.renderReact(__spreadProps(__spreadValues({}, this.props), { children }), this.payload);
|
|
1279
|
+
}
|
|
1280
|
+
getReactWrapper(target = this, displayName = target.tagName) {
|
|
1281
|
+
const Wrapper = target.reactWrapper || (target.reactWrapper = (props) => {
|
|
1282
|
+
if (target.renderReact) {
|
|
1283
|
+
const { React, ReactDOM } = target.payload || {};
|
|
1284
|
+
const [value, forceUpdateReact] = React.useReducer((r) => r + 1, 0);
|
|
1285
|
+
target.forceUpdateReact = forceUpdateReact;
|
|
1286
|
+
return ReactDOM.createPortal(React.Fragment({ children: target.invokeReactRendering() }), target.getReactRoot());
|
|
1287
|
+
} else {
|
|
1288
|
+
return target.render();
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
Object.assign(Wrapper, {
|
|
1292
|
+
displayName
|
|
1293
|
+
});
|
|
1294
|
+
return Wrapper;
|
|
1295
|
+
}
|
|
1296
|
+
getUID() {
|
|
1297
|
+
return this.uid || (this.uid = String(Math.random()));
|
|
1298
|
+
}
|
|
1299
|
+
getReactRoot() {
|
|
1300
|
+
return this.getRoot();
|
|
1301
|
+
}
|
|
1302
|
+
set(overrides) {
|
|
1303
|
+
this.overrides = __spreadValues(__spreadValues({}, this.overrides), overrides);
|
|
1304
|
+
this.props = __spreadValues(__spreadValues({}, this.getProps()), this.overrides);
|
|
1305
|
+
for (var property in this.props) {
|
|
1306
|
+
const value = this.props[property];
|
|
1307
|
+
if (this.props[property] == null) {
|
|
1308
|
+
this.removeAttribute(property);
|
|
1309
|
+
} else if (typeof value == "string" || typeof value == "number") {
|
|
1310
|
+
if (this.getAttribute(property) != String(value))
|
|
1311
|
+
this.setAttribute(property, String(value));
|
|
1312
|
+
}
|
|
1197
1313
|
}
|
|
1314
|
+
this.scheduleRender();
|
|
1198
1315
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1316
|
+
scheduleRender() {
|
|
1317
|
+
cancelAnimationFrame(this.nextRender);
|
|
1318
|
+
this.nextRender = requestAnimationFrame(() => {
|
|
1319
|
+
this.reify();
|
|
1320
|
+
});
|
|
1201
1321
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
this.update();
|
|
1322
|
+
formatURL(src, hostname) {
|
|
1323
|
+
if (typeof src == "string" && src.match(/\/[^\/]/)) {
|
|
1324
|
+
return hostname + src;
|
|
1206
1325
|
} else {
|
|
1207
|
-
|
|
1326
|
+
return src;
|
|
1208
1327
|
}
|
|
1209
1328
|
}
|
|
1329
|
+
getContextAttribute(name, element = this) {
|
|
1330
|
+
var _a, _b;
|
|
1331
|
+
return (_b = (_a = element.closest(`[${name}]`)) == null ? void 0 : _a.getAttribute(name)) != null ? _b : this.getAttribute(name);
|
|
1332
|
+
}
|
|
1333
|
+
static register(tagName) {
|
|
1334
|
+
if (!window.customElements.get(tagName)) {
|
|
1335
|
+
window.customElements.define(tagName, this);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
// src/components/FEAASLoader.ts
|
|
1341
|
+
function FEAASLoaderProps(element = this) {
|
|
1342
|
+
return {
|
|
1343
|
+
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
var FEAASLoader = class extends FEAASBase {
|
|
1347
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1348
|
+
if (name == "hidden") {
|
|
1349
|
+
this.style.setProperty("display", "block", "important");
|
|
1350
|
+
this.style.setProperty("transition", "opacity 0.3s", "important");
|
|
1351
|
+
if (newValue) {
|
|
1352
|
+
this.style.setProperty("opacity", "0", "important");
|
|
1353
|
+
this.style.pointerEvents = "none";
|
|
1354
|
+
} else {
|
|
1355
|
+
this.style.setProperty("opacity", "1", "important");
|
|
1356
|
+
this.style.pointerEvents = "all";
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
connectedCallback() {
|
|
1361
|
+
this.attributeChangedCallback("hidden", this.getAttribute("hidden"), this.getAttribute("hidden"));
|
|
1362
|
+
this.stylesheet = document.createElement("style");
|
|
1363
|
+
this.stylesheet.textContent = `
|
|
1364
|
+
#loader {
|
|
1365
|
+
position: absolute;
|
|
1366
|
+
top: 0;
|
|
1367
|
+
left: 0;
|
|
1368
|
+
right: 0;
|
|
1369
|
+
bottom: 0;
|
|
1370
|
+
display: flex;
|
|
1371
|
+
align-items: center;
|
|
1372
|
+
justify-content: center;
|
|
1373
|
+
background: #f6f6ff;
|
|
1374
|
+
z-index: 1000;
|
|
1375
|
+
}
|
|
1376
|
+
@keyframes loader-circular-track {
|
|
1377
|
+
0% {
|
|
1378
|
+
stroke-dasharray: 1, 400;
|
|
1379
|
+
stroke-dashoffset: 0;
|
|
1380
|
+
}
|
|
1381
|
+
50% {
|
|
1382
|
+
stroke-dasharray: 400, 400;
|
|
1383
|
+
stroke-dashoffset: -100;
|
|
1384
|
+
}
|
|
1385
|
+
100% {
|
|
1386
|
+
stroke-dasharray: 400, 400;
|
|
1387
|
+
stroke-dashoffset: -260;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
@keyframes loader-circular-spinner {
|
|
1392
|
+
0% {
|
|
1393
|
+
transform: rotate(0deg);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
100% {
|
|
1397
|
+
transform: rotate(360deg);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
#loader .spinner {
|
|
1401
|
+
width: 48px;
|
|
1402
|
+
height: 48px;
|
|
1403
|
+
}
|
|
1404
|
+
`;
|
|
1405
|
+
this.loader = document.createElement("div");
|
|
1406
|
+
this.loader.id = "loader";
|
|
1407
|
+
this.loader.innerHTML = `
|
|
1408
|
+
<div class="spinner">
|
|
1409
|
+
<svg
|
|
1410
|
+
viewBox="0 0 100 100"
|
|
1411
|
+
style="
|
|
1412
|
+
animation: 2s linear 0s infinite normal none running loader-circular-spinner;
|
|
1413
|
+
display: block;
|
|
1414
|
+
width: 48px;
|
|
1415
|
+
height: 48px;
|
|
1416
|
+
"
|
|
1417
|
+
>
|
|
1418
|
+
<circle fill="transparent" cx="50" cy="50" r="42" stroke="rgba(0,0,0,0.1)" stroke-width="10px"></circle>
|
|
1419
|
+
<circle
|
|
1420
|
+
fill="transparent"
|
|
1421
|
+
stroke="#5548D9"
|
|
1422
|
+
cx="50"
|
|
1423
|
+
cy="50"
|
|
1424
|
+
r="42"
|
|
1425
|
+
stroke-width="10px"
|
|
1426
|
+
stroke-linecap="round"
|
|
1427
|
+
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1428
|
+
></circle>
|
|
1429
|
+
</svg>
|
|
1430
|
+
</div>`;
|
|
1431
|
+
this.getRoot().appendChild(this.stylesheet);
|
|
1432
|
+
this.getRoot().appendChild(this.loader);
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
FEAASLoader.observedAttributes = ["hidden"];
|
|
1436
|
+
FEAASLoader.register("feaas-loader");
|
|
1437
|
+
|
|
1438
|
+
// src/components/FEAASStylesheet.ts
|
|
1439
|
+
function FEAASStylesheetProps(element = this) {
|
|
1440
|
+
var _a;
|
|
1441
|
+
return {
|
|
1442
|
+
library: element == null ? void 0 : element.getContextAttribute("library"),
|
|
1443
|
+
revision: (_a = element == null ? void 0 : element.getAttribute("revision")) != null ? _a : "published",
|
|
1444
|
+
cdn: element == null ? void 0 : element.getContextAttribute("cdn")
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
var FEAASStylesheet = class extends FEAASBase {
|
|
1448
|
+
getProps() {
|
|
1449
|
+
return FEAASStylesheetProps(this);
|
|
1450
|
+
}
|
|
1451
|
+
isReadyToLoad() {
|
|
1452
|
+
return this.props.library != null && this.props.revision != null && this.props.cdn != null;
|
|
1453
|
+
}
|
|
1454
|
+
load() {
|
|
1455
|
+
return __async(this, null, function* () {
|
|
1456
|
+
fetchStylesheet(this.props, this.onLoad);
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
render() {
|
|
1460
|
+
if (!this.stylesheet) {
|
|
1461
|
+
this.stylesheet = document.createElement("style");
|
|
1462
|
+
this.appendChild(this.stylesheet);
|
|
1463
|
+
}
|
|
1464
|
+
this.stylesheet.textContent = this.payload;
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
FEAASStylesheet.register("feaas-stylesheet");
|
|
1468
|
+
|
|
1469
|
+
// src/components/FEAASComponent.ts
|
|
1470
|
+
function FEAASComponentsProps(element = this) {
|
|
1471
|
+
let data;
|
|
1472
|
+
const dataValue = element.getAttribute("data");
|
|
1473
|
+
if (dataValue != null) {
|
|
1474
|
+
try {
|
|
1475
|
+
data = typeof dataValue == "string" ? JSON.parse(dataValue) : {};
|
|
1476
|
+
} catch (e) {
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
return {
|
|
1480
|
+
data: data != null ? data : {},
|
|
1481
|
+
library: element.getAttribute("library"),
|
|
1482
|
+
component: element.getAttribute("component"),
|
|
1483
|
+
version: element.getAttribute("version"),
|
|
1484
|
+
revision: element.getAttribute("revision"),
|
|
1485
|
+
hostname: element.getAttribute("hostname"),
|
|
1486
|
+
cdn: element.getContextAttribute("cdn"),
|
|
1487
|
+
template: element.getAttribute("template")
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
var FEAASComponent = class extends FEAASBase {
|
|
1491
|
+
setData(data) {
|
|
1492
|
+
this.set({ data });
|
|
1493
|
+
}
|
|
1494
|
+
getProps() {
|
|
1495
|
+
return FEAASComponentsProps(this);
|
|
1496
|
+
}
|
|
1497
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1498
|
+
this.payload = void 0;
|
|
1499
|
+
this.needsRefresh = true;
|
|
1500
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
1501
|
+
}
|
|
1210
1502
|
getOriginal() {
|
|
1211
1503
|
const scope = this.getAttribute("data-path-scope");
|
|
1212
1504
|
if (!scope)
|
|
@@ -1220,267 +1512,350 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1220
1512
|
}
|
|
1221
1513
|
return last;
|
|
1222
1514
|
}
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
if (this.data) {
|
|
1226
|
-
return this.data;
|
|
1227
|
-
}
|
|
1228
|
-
if (this.getAttribute("data")) {
|
|
1229
|
-
const dataValue = this.getAttribute("data");
|
|
1230
|
-
return typeof dataValue == "string" ? JSON.parse(dataValue) : {};
|
|
1231
|
-
}
|
|
1232
|
-
return ((_a = this.getOriginal()) == null ? void 0 : _a.getData()) || {};
|
|
1233
|
-
return {};
|
|
1515
|
+
isReadyToLoad() {
|
|
1516
|
+
return super.isReadyToLoad() && this.props.library != null && this.props.component != null && this.props.version != null;
|
|
1234
1517
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
this.isFetching = false;
|
|
1247
|
-
renderDOMContent(this, this.template, newProps.data);
|
|
1248
|
-
}).catch(() => {
|
|
1249
|
-
console.error(
|
|
1250
|
-
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.version}/${newProps.revision}`
|
|
1251
|
-
);
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1518
|
+
load() {
|
|
1519
|
+
return __async(this, null, function* () {
|
|
1520
|
+
if (this.getOriginal()) {
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
try {
|
|
1524
|
+
fetchComponent(this.props, this.onLoad);
|
|
1525
|
+
} catch (e) {
|
|
1526
|
+
console.error(
|
|
1527
|
+
`FEAAS: Could not fetch component: ${this.props.component}/${this.props.version}/${this.props.revision}`
|
|
1528
|
+
);
|
|
1254
1529
|
}
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
render() {
|
|
1533
|
+
if (Array.from(this.children).filter((c) => c.tagName != "BR").length > 0 && !this.needsRefresh) {
|
|
1534
|
+
renderDOMElement(this, this.props.data);
|
|
1255
1535
|
} else {
|
|
1256
|
-
|
|
1536
|
+
this.needsRefresh = true;
|
|
1537
|
+
if (this.getOriginal()) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
renderDOMContent(this, this.payload, this.props.data);
|
|
1257
1541
|
}
|
|
1258
1542
|
}
|
|
1259
|
-
getProps() {
|
|
1260
|
-
return {
|
|
1261
|
-
data: this.getData(),
|
|
1262
|
-
library: this.getAttribute("library") || void 0,
|
|
1263
|
-
component: this.getAttribute("component") || void 0,
|
|
1264
|
-
version: this.getAttribute("version") || void 0,
|
|
1265
|
-
revision: this.getAttribute("revision") || void 0,
|
|
1266
|
-
hostname: patchHostname(this.getAttribute("hostname") || void 0)
|
|
1267
|
-
};
|
|
1268
|
-
}
|
|
1269
1543
|
};
|
|
1270
|
-
|
|
1544
|
+
FEAASComponent.observedAttributes = ["library", "component", "version", "revision", "hostname", "cdn", "template", "data"];
|
|
1545
|
+
FEAASComponent.register("feaas-component");
|
|
1546
|
+
|
|
1547
|
+
// src/components/FEAASEditor.tsx
|
|
1548
|
+
function getFramePosition(element) {
|
|
1549
|
+
let positions = [];
|
|
1550
|
+
if (element) {
|
|
1551
|
+
let currentWindow = element.ownerDocument.defaultView;
|
|
1552
|
+
let currentParentWindow;
|
|
1553
|
+
let rect;
|
|
1554
|
+
while (currentWindow !== window.top) {
|
|
1555
|
+
currentParentWindow = currentWindow.parent;
|
|
1556
|
+
for (let idx = 0; idx < currentParentWindow.frames.length; idx++)
|
|
1557
|
+
if (currentParentWindow.frames[idx] === currentWindow) {
|
|
1558
|
+
for (let frameElement of currentParentWindow.document.getElementsByTagName("iframe")) {
|
|
1559
|
+
if (frameElement.contentWindow === currentWindow) {
|
|
1560
|
+
rect = frameElement.getBoundingClientRect();
|
|
1561
|
+
const style = frameElement.contentWindow.getComputedStyle(frameElement);
|
|
1562
|
+
positions.push({
|
|
1563
|
+
left: rect.left + parseInt(style.borderLeftWidth),
|
|
1564
|
+
top: rect.top + parseInt(style.borderTopWidth)
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
currentWindow = currentParentWindow;
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
return positions.reduce(
|
|
1574
|
+
(accumulator, currentValue) => {
|
|
1575
|
+
return {
|
|
1576
|
+
left: accumulator.left + currentValue.left,
|
|
1577
|
+
top: accumulator.top + currentValue.top
|
|
1578
|
+
};
|
|
1579
|
+
},
|
|
1580
|
+
{ left: 0, top: 0 }
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
function FEAASEditorProps(element = this) {
|
|
1584
|
+
var _a;
|
|
1585
|
+
return {
|
|
1586
|
+
context: HTMLElement,
|
|
1587
|
+
frontend: element == null ? void 0 : element.getContextAttribute("frontend"),
|
|
1588
|
+
src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/editor.js",
|
|
1589
|
+
library: element == null ? void 0 : element.getAttribute("library"),
|
|
1590
|
+
component: element == null ? void 0 : element.getAttribute("component"),
|
|
1591
|
+
version: element == null ? void 0 : element.getAttribute("version"),
|
|
1592
|
+
revision: (element == null ? void 0 : element.getAttribute("revision")) || "saved",
|
|
1593
|
+
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1594
|
+
for: element == null ? void 0 : element.getAttribute("for")
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
var FEAASEditor = class extends FEAASBase {
|
|
1271
1598
|
constructor() {
|
|
1272
1599
|
super(...arguments);
|
|
1273
|
-
this.
|
|
1600
|
+
this.framePoint = { top: 0, left: 0 };
|
|
1601
|
+
this.wrapperRect = { top: 0, left: 0, width: 0, height: 0 };
|
|
1602
|
+
this.bodyRect = { top: 0, left: 0, width: 0, height: 0 };
|
|
1603
|
+
this.getTarget = () => {
|
|
1604
|
+
return document.querySelector("iframe").contentWindow.document.getElementById(this.props.for);
|
|
1605
|
+
};
|
|
1606
|
+
this.onChromeMeasureElement = (element, rect) => {
|
|
1607
|
+
if (rect == null) {
|
|
1608
|
+
rect = element.getBoundingClientRect();
|
|
1609
|
+
}
|
|
1610
|
+
if (element.ownerDocument == document) {
|
|
1611
|
+
return {
|
|
1612
|
+
left: rect.left - this.bodyRect.left,
|
|
1613
|
+
top: rect.top - this.bodyRect.top,
|
|
1614
|
+
width: rect.width,
|
|
1615
|
+
height: rect.height
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
return {
|
|
1619
|
+
left: rect.left + this.framePoint.left - this.bodyRect.left,
|
|
1620
|
+
top: rect.top + this.framePoint.top - this.bodyRect.top,
|
|
1621
|
+
width: rect.width,
|
|
1622
|
+
height: rect.height
|
|
1623
|
+
};
|
|
1624
|
+
};
|
|
1625
|
+
this.onBeforeMeasure = (refs) => {
|
|
1626
|
+
if (refs.memoized.focusable)
|
|
1627
|
+
this.framePoint = getFramePosition(refs.memoized.focusable);
|
|
1628
|
+
this.wrapperRect = this.wrapper.getBoundingClientRect();
|
|
1629
|
+
this.bodyRect = this.wrapper.ownerDocument.body.parentElement.getBoundingClientRect();
|
|
1630
|
+
};
|
|
1631
|
+
this.onMeasure = () => {
|
|
1632
|
+
};
|
|
1633
|
+
this.onPosition = ({ focusable, root }) => {
|
|
1634
|
+
const chrome = this.wrapper.querySelector(".editor-chrome");
|
|
1635
|
+
const absolute = this.wrapper.querySelector(".ui.overlays");
|
|
1636
|
+
if (focusable) {
|
|
1637
|
+
const topbarHeight = 64;
|
|
1638
|
+
const padding = 16;
|
|
1639
|
+
chrome.style.width = focusable.width + padding * 2 + "px";
|
|
1640
|
+
chrome.style.height = focusable.height + padding * 1 + topbarHeight + "px";
|
|
1641
|
+
chrome.style.left = focusable.left - padding + "px";
|
|
1642
|
+
chrome.style.top = focusable.top - topbarHeight + "px";
|
|
1643
|
+
if (absolute) {
|
|
1644
|
+
absolute.style.left = root.left + "px";
|
|
1645
|
+
absolute.style.top = root.top + "px";
|
|
1646
|
+
}
|
|
1647
|
+
} else {
|
|
1648
|
+
chrome.style.left = "-1000px";
|
|
1649
|
+
chrome.style.top = "-1000px";
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1274
1652
|
}
|
|
1275
|
-
|
|
1276
|
-
return
|
|
1653
|
+
getProps() {
|
|
1654
|
+
return FEAASEditorProps(this);
|
|
1277
1655
|
}
|
|
1278
|
-
|
|
1279
|
-
this.
|
|
1280
|
-
|
|
1656
|
+
load() {
|
|
1657
|
+
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1658
|
+
}
|
|
1659
|
+
renderReact({ children, component: componentId, version: versionId }, {
|
|
1660
|
+
Editor,
|
|
1661
|
+
VersionStatusList,
|
|
1662
|
+
Version,
|
|
1663
|
+
EditorUIUndo,
|
|
1664
|
+
EditorUIMode,
|
|
1665
|
+
React: { useEffect, useMemo, useState },
|
|
1666
|
+
Chakra: { HStack, Box },
|
|
1667
|
+
Chrome,
|
|
1668
|
+
ReactDOM,
|
|
1669
|
+
useSDK,
|
|
1670
|
+
useSlots,
|
|
1671
|
+
useModelObserver
|
|
1672
|
+
}) {
|
|
1673
|
+
if (!this.payload)
|
|
1674
|
+
return;
|
|
1675
|
+
const { sdk } = useSDK();
|
|
1676
|
+
const [component, setComponent] = useState();
|
|
1677
|
+
const library = sdk.library;
|
|
1678
|
+
useEffect(() => {
|
|
1679
|
+
return setComponent(library.components.getItem(componentId));
|
|
1680
|
+
}, [componentId, library]);
|
|
1681
|
+
useEffect(() => {
|
|
1682
|
+
component == null ? void 0 : component.versions.fetch();
|
|
1683
|
+
}, [component]);
|
|
1684
|
+
const target = useMemo(this.getTarget, [this.props.for]);
|
|
1685
|
+
const observedVersions = useModelObserver(component == null ? void 0 : component.versions);
|
|
1686
|
+
const versions = useMemo(() => {
|
|
1687
|
+
return (observedVersions == null ? void 0 : observedVersions.filter((v) => v.id == versionId || !versionId)) || [];
|
|
1688
|
+
}, [observedVersions]);
|
|
1689
|
+
if (!component)
|
|
1690
|
+
return;
|
|
1691
|
+
return useSlots(children, ({ picker, children: children2 }) => <Box ref={(el) => this.wrapper = el}><Box className="editor-wrapper" position="absolute" left={0} top={0}><Editor sdk={sdk} library={sdk.library} component={component} versions={versions} context={{
|
|
1692
|
+
onChromeMeasure: this.onMeasure,
|
|
1693
|
+
onChromeBeforeMeasure: this.onBeforeMeasure,
|
|
1694
|
+
onChromeMeasureElement: this.onChromeMeasureElement,
|
|
1695
|
+
onChromePosition: this.onPosition
|
|
1696
|
+
}}>{({ editor, status, isArchivedDisplayed }) => ({
|
|
1697
|
+
after: children2,
|
|
1698
|
+
picker,
|
|
1699
|
+
chrome: editor && <Chrome />,
|
|
1700
|
+
children: component.reduceVersionRevisions(versions).filter((snapshot) => {
|
|
1701
|
+
var _a;
|
|
1702
|
+
return isArchivedDisplayed || !((_a = snapshot.saved || snapshot.draft) == null ? void 0 : _a.deletedAt);
|
|
1703
|
+
}).map((snapshot, index) => <Box key={snapshot.head.id} position="absolute" left={0} top={0} className="editor-chrome" p={4} boxShadow="2xl" pointerEvents="none">
|
|
1704
|
+
<Box className="borders" pointerEvents="none" left={0} width="4" top={0} bottom={0} backdropFilter="blur(2px)" background="rgb(244 244 244 / 80%)" position="absolute" />
|
|
1705
|
+
<Box className="borders" pointerEvents="none" right={0} width="4" top={0} bottom={0} backdropFilter="blur(2px)" background="rgb(244 244 244 / 80%)" position="absolute" />
|
|
1706
|
+
<Box className="borders" pointerEvents="none" top={0} height="16" left={0} right={0} backdropFilter="blur(2px)" background="rgb(244 244 244 / 80%)" position="absolute" />
|
|
1707
|
+
<Box className="borders" pointerEvents="none" bottom={0} height="4" left={0} right={0} backdropFilter="blur(2px)" background="rgb(244 244 244 / 80%)" position="absolute" />
|
|
1708
|
+
<Version version={snapshot.head} node={target}>{{
|
|
1709
|
+
left: <HStack justifyContent="space-between">
|
|
1710
|
+
<EditorUIUndo size="sm" editor={status == "ready" ? editor : null} />
|
|
1711
|
+
<EditorUIMode size="sm" />
|
|
1712
|
+
</HStack>,
|
|
1713
|
+
middle: <VersionStatusList />
|
|
1714
|
+
}}</Version>
|
|
1715
|
+
</Box>)
|
|
1716
|
+
})}</Editor></Box></Box>);
|
|
1717
|
+
}
|
|
1718
|
+
isReadyToLoad() {
|
|
1719
|
+
return this.props.component != null && this.props.version != null;
|
|
1281
1720
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1721
|
+
};
|
|
1722
|
+
FEAASEditor.register("feaas-editor");
|
|
1723
|
+
|
|
1724
|
+
// src/components/FEAASPicker.tsx
|
|
1725
|
+
function FEAASPickerProps(element = this) {
|
|
1726
|
+
var _a, _b;
|
|
1727
|
+
return {
|
|
1728
|
+
part: (element == null ? void 0 : element.getAttribute("part")) || "picker",
|
|
1729
|
+
slot: (element == null ? void 0 : element.getAttribute("part")) || "slot",
|
|
1730
|
+
mode: element == null ? void 0 : element.getAttribute("mode"),
|
|
1731
|
+
frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
|
|
1732
|
+
src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
|
|
1733
|
+
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1734
|
+
context: void 0,
|
|
1735
|
+
onClose: void 0
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
var FEAASPicker = class extends FEAASBase {
|
|
1739
|
+
getProps() {
|
|
1740
|
+
return FEAASPickerProps(this);
|
|
1285
1741
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
fetchStylesheet(props, (cssText) => {
|
|
1289
|
-
this.innerHTML = "<style>" + cssText + "</style>";
|
|
1290
|
-
}).catch((e) => {
|
|
1291
|
-
console.error(`FEAAS: Could not fetch stylesheet for library ${props.library}`);
|
|
1292
|
-
});
|
|
1742
|
+
load() {
|
|
1743
|
+
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1293
1744
|
}
|
|
1294
|
-
|
|
1295
|
-
return {
|
|
1296
|
-
library: this.getAttribute("library") || void 0,
|
|
1297
|
-
revision: this.getAttribute("revision") || void 0,
|
|
1298
|
-
hostname: patchHostname(this.getAttribute("hostname") || void 0)
|
|
1299
|
-
};
|
|
1745
|
+
renderReact({ context, mode, children }, { Picker, React, ReactDOM }) {
|
|
1746
|
+
return <Picker mode={mode || void 0} onClose={this.props.onClose} context={context}>{children}</Picker>;
|
|
1300
1747
|
}
|
|
1301
1748
|
};
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1749
|
+
FEAASPicker.register("feaas-picker");
|
|
1750
|
+
function FEAASPickerLazyProps(element = this) {
|
|
1751
|
+
var _a, _b;
|
|
1752
|
+
return {
|
|
1753
|
+
library: (element == null ? void 0 : element.getAttribute("library")) || "library",
|
|
1754
|
+
mode: element == null ? void 0 : element.getAttribute("mode"),
|
|
1755
|
+
frontend: (_a = element == null ? void 0 : element.getContextAttribute("frontend")) != null ? _a : "https://components.sitecorecloud.io",
|
|
1756
|
+
src: (_b = element == null ? void 0 : element.getAttribute("src")) != null ? _b : "/assets/picker.js",
|
|
1757
|
+
hidden: (element == null ? void 0 : element.getAttribute("hidden")) != null,
|
|
1758
|
+
context: null,
|
|
1759
|
+
getToken: null
|
|
1760
|
+
};
|
|
1308
1761
|
}
|
|
1309
|
-
var
|
|
1762
|
+
var FEAASPickerLazy = class extends FEAASBase {
|
|
1310
1763
|
constructor() {
|
|
1311
1764
|
super(...arguments);
|
|
1312
|
-
this.
|
|
1765
|
+
this.payload = null;
|
|
1313
1766
|
this.onClose = () => {
|
|
1314
|
-
this.
|
|
1315
|
-
mode: null
|
|
1316
|
-
});
|
|
1317
|
-
};
|
|
1318
|
-
this.onScriptLoaded = () => {
|
|
1319
|
-
this.element = document.createElement("feaas-picker");
|
|
1320
|
-
this.element.style.cssText = "border: 0; width: 100%; height: 100%; display: block";
|
|
1321
|
-
this.appendChild(this.element);
|
|
1322
|
-
this.set(this.getProps());
|
|
1767
|
+
this.setAttribute("hidden", "hidden");
|
|
1323
1768
|
};
|
|
1324
1769
|
}
|
|
1325
|
-
static get observedAttributes() {
|
|
1326
|
-
return ["library", "mode", "hidden", "src"];
|
|
1327
|
-
}
|
|
1328
|
-
connectedCallback() {
|
|
1329
|
-
this.loader = document.createElement("feaas-loader");
|
|
1330
|
-
this.loader.style.cssText = "position: absolute; top: 0; left: 0; right: 0;bottom: 0; ";
|
|
1331
|
-
this.appendChild(this.loader);
|
|
1332
|
-
}
|
|
1333
|
-
load() {
|
|
1334
|
-
if (!this.script) {
|
|
1335
|
-
this.script = document.createElement("script");
|
|
1336
|
-
this.script.type = "module";
|
|
1337
|
-
this.script.onload = this.onScriptLoaded;
|
|
1338
|
-
this.script.src = patchHostname(this.src);
|
|
1339
|
-
this.script.crossOrigin = "anonymous";
|
|
1340
|
-
this.appendChild(this.script);
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
1770
|
getProps() {
|
|
1344
|
-
return
|
|
1345
|
-
mode: this.getAttribute("mode"),
|
|
1346
|
-
context: this.context,
|
|
1347
|
-
library: this.getAttribute("library"),
|
|
1348
|
-
src: this.getAttribute("src")
|
|
1349
|
-
};
|
|
1771
|
+
return FEAASPickerLazyProps(this);
|
|
1350
1772
|
}
|
|
1351
|
-
|
|
1352
|
-
this.
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
}
|
|
1373
|
-
if (this.element && this.element.set) {
|
|
1374
|
-
this.element.onClose = this.onClose;
|
|
1375
|
-
this.element.getToken = this.getToken;
|
|
1376
|
-
this.element.set(options);
|
|
1377
|
-
}
|
|
1773
|
+
render() {
|
|
1774
|
+
const { frontend, library, getToken, src, mode, context } = this.props;
|
|
1775
|
+
if (this.children.length == 0)
|
|
1776
|
+
this.innerHTML = `
|
|
1777
|
+
<feaas-context src='/components/providers/ContextProvider.tsx' library='${library}'>
|
|
1778
|
+
<feaas-picker mode='${mode}'>
|
|
1779
|
+
<feaas-loader />
|
|
1780
|
+
</feaas-context>
|
|
1781
|
+
`;
|
|
1782
|
+
this.refs.context.set({
|
|
1783
|
+
frontend,
|
|
1784
|
+
library,
|
|
1785
|
+
getToken
|
|
1786
|
+
});
|
|
1787
|
+
this.refs.picker.set({
|
|
1788
|
+
frontend,
|
|
1789
|
+
context,
|
|
1790
|
+
src,
|
|
1791
|
+
mode,
|
|
1792
|
+
onClose: this.onClose
|
|
1793
|
+
});
|
|
1378
1794
|
}
|
|
1379
1795
|
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
right: 0;
|
|
1394
|
-
bottom: 0;
|
|
1395
|
-
display: flex;
|
|
1396
|
-
align-items: center;
|
|
1397
|
-
justify-content: center;
|
|
1398
|
-
background: #f6f6ff;
|
|
1399
|
-
z-index: 1000;
|
|
1400
|
-
opacity: 1;
|
|
1401
|
-
transition: top 0.3s, background-color 0.7s 0.3s;
|
|
1402
|
-
}
|
|
1403
|
-
@keyframes loader-disappearance {
|
|
1404
|
-
100% {
|
|
1405
|
-
opacity: 0;
|
|
1406
|
-
}
|
|
1796
|
+
FEAASPickerLazy.register("feaas-picker-lazy");
|
|
1797
|
+
|
|
1798
|
+
// src/components/FEAASContext.tsx
|
|
1799
|
+
function FEAASContextProps(element = this) {
|
|
1800
|
+
var _a, _b, _c, _d;
|
|
1801
|
+
return {
|
|
1802
|
+
library: element == null ? void 0 : element.getAttribute("library"),
|
|
1803
|
+
src: (_a = element == null ? void 0 : element.getAttribute("src")) != null ? _a : "/assets/context.js",
|
|
1804
|
+
frontend: (_b = element == null ? void 0 : element.getAttribute("frontend")) != null ? _b : "https://components.sitecoreclud.io",
|
|
1805
|
+
backend: (_c = element == null ? void 0 : element.getAttribute("backend")) != null ? _c : "https://components-api.sitecoreclud.io",
|
|
1806
|
+
cdn: (_d = element == null ? void 0 : element.getAttribute("cdn")) != null ? _d : "https://feaascompontsapiprod.blob.core.windows.net",
|
|
1807
|
+
getToken: null
|
|
1808
|
+
};
|
|
1407
1809
|
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1810
|
+
var FEAASContext = class extends FEAASBase {
|
|
1811
|
+
getProps() {
|
|
1812
|
+
return FEAASContextProps(this);
|
|
1411
1813
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
0% {
|
|
1415
|
-
stroke-dasharray: 1, 400;
|
|
1416
|
-
stroke-dashoffset: 0;
|
|
1814
|
+
load() {
|
|
1815
|
+
return import(this.formatURL(this.props.src, this.props.frontend));
|
|
1417
1816
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
stroke-dashoffset: -100;
|
|
1817
|
+
getTheme(theme) {
|
|
1818
|
+
return theme;
|
|
1421
1819
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
stroke-dashoffset: -260;
|
|
1820
|
+
getRoot() {
|
|
1821
|
+
return this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
1425
1822
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1823
|
+
getReactRoot() {
|
|
1824
|
+
if (!this.reactRoot) {
|
|
1825
|
+
this.reactRoot = document.createElement("div");
|
|
1826
|
+
this.getRoot().appendChild(this.reactRoot);
|
|
1827
|
+
}
|
|
1828
|
+
return this.reactRoot;
|
|
1431
1829
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1830
|
+
adoptedCallback(event) {
|
|
1831
|
+
super.adoptedCallback(event);
|
|
1832
|
+
const target = event.composedPath()[0];
|
|
1833
|
+
if (target.parentNode != this.getRoot()) {
|
|
1834
|
+
this.getRoot().appendChild(target);
|
|
1835
|
+
}
|
|
1435
1836
|
}
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
height: 48px;
|
|
1458
|
-
"
|
|
1459
|
-
>
|
|
1460
|
-
<circle fill="transparent" cx="50" cy="50" r="42" stroke="rgba(0,0,0,0.1)" stroke-width="10px"></circle>
|
|
1461
|
-
<circle
|
|
1462
|
-
fill="transparent"
|
|
1463
|
-
stroke="#5548D9"
|
|
1464
|
-
cx="50"
|
|
1465
|
-
cy="50"
|
|
1466
|
-
r="42"
|
|
1467
|
-
stroke-width="10px"
|
|
1468
|
-
stroke-linecap="round"
|
|
1469
|
-
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1470
|
-
></circle>
|
|
1471
|
-
</svg>
|
|
1472
|
-
</div>`;
|
|
1473
|
-
this.shadowRoot.appendChild(this.stylesheet);
|
|
1474
|
-
this.shadowRoot.appendChild(this.loader);
|
|
1837
|
+
renderReact({ children, library }, { AppContext, Chakra: { Button, Tooltip }, React: { useRef } }) {
|
|
1838
|
+
Tooltip.defaultProps = {
|
|
1839
|
+
hasArrow: true,
|
|
1840
|
+
placement: "top",
|
|
1841
|
+
portalProps: {
|
|
1842
|
+
containerRef: { current: this.getRoot() }
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
return <AppContext libraryId={this.props.library} container={this.getRoot()} getTheme={this.getTheme} modalProps={{
|
|
1846
|
+
portalProps: {
|
|
1847
|
+
containerRef: { current: this.getRoot() }
|
|
1848
|
+
}
|
|
1849
|
+
}} chakraProps={{
|
|
1850
|
+
cssVarsRoot: ":host",
|
|
1851
|
+
resetCSS: true,
|
|
1852
|
+
toastOptions: {
|
|
1853
|
+
portalProps: {
|
|
1854
|
+
containerRef: { current: this.getRoot() }
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}}>{children}</AppContext>;
|
|
1475
1858
|
}
|
|
1476
1859
|
};
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
window.customElements.define("feaas-component", HTMLFeaasComponent);
|
|
1480
|
-
window.customElements.define("feaas-picker-lazy", HTMLFeaasPickerLazy);
|
|
1481
|
-
if (!window.customElements.get("feaas-loader"))
|
|
1482
|
-
window.customElements.define("feaas-loader", HTMLFeaasLoader);
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
// src/index.ts
|
|
1486
|
-
var src_default = __spreadValues(__spreadValues({}, dom_exports), webcomponent_exports);
|
|
1860
|
+
FEAASContext.observedAttributes = ["library", "component", "version", "revision", "hostname", "template"];
|
|
1861
|
+
FEAASContext.register("feaas-context");
|