@sitecore-feaas/clientside 0.0.2 → 0.0.4
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 +4 -4
- package/dist/browser/index.cjs +83 -3
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +83 -3
- package/dist/browser/react.cjs +83 -3
- package/dist/browser/react.d.ts +2 -2
- package/dist/browser/react.js +83 -3
- package/dist/browser/{webcomponent-189a307d.d.ts → webcomponent-6b45b819.d.ts} +26 -9
- package/dist/node/index.cjs +186 -14
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +186 -14
- package/dist/node/react.cjs +188 -16
- package/dist/node/react.d.ts +2 -2
- package/dist/node/react.js +188 -16
- package/dist/node/{webcomponent-189a307d.d.ts → webcomponent-6b45b819.d.ts} +26 -9
- package/examples/index.html +2 -2
- package/index.cjs +83 -3
- package/index.d.ts +2 -2
- package/index.js +83 -3
- package/package.json +7 -1
- package/react.cjs +83 -3
- package/react.d.ts +2 -2
- package/react.js +83 -3
- package/src/cloud.ts +9 -9
- package/src/dom.ts +4 -2
- package/src/react.ts +2 -2
- package/src/webcomponent.ts +212 -9
- package/test/render.ts +4 -1
- package/tsconfig.json +1 -1
- package/{webcomponent-189a307d.d.ts → webcomponent-6b45b819.d.ts} +26 -9
package/dist/node/index.cjs
CHANGED
|
@@ -834,17 +834,17 @@ function getComponentURL({
|
|
|
834
834
|
hostname = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
835
835
|
library,
|
|
836
836
|
component,
|
|
837
|
-
|
|
838
|
-
|
|
837
|
+
version,
|
|
838
|
+
revision = "published"
|
|
839
839
|
}) {
|
|
840
|
-
return `${hostname}/components/${library}/${component}/${
|
|
840
|
+
return `${hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
841
841
|
}
|
|
842
842
|
function getStylesheetURL({
|
|
843
843
|
hostname = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
844
844
|
library,
|
|
845
|
-
|
|
845
|
+
revision = "published"
|
|
846
846
|
}) {
|
|
847
|
-
return `${hostname}/styles/${library}/${
|
|
847
|
+
return `${hostname}/styles/${library}/${revision}.css`;
|
|
848
848
|
}
|
|
849
849
|
function fetchComponent(props, callback) {
|
|
850
850
|
return __async(this, null, function* () {
|
|
@@ -852,7 +852,7 @@ function fetchComponent(props, callback) {
|
|
|
852
852
|
getComponentURL(props),
|
|
853
853
|
{},
|
|
854
854
|
(response) => {
|
|
855
|
-
return response.headers.get("x-ms-meta-
|
|
855
|
+
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
856
856
|
},
|
|
857
857
|
(response) => {
|
|
858
858
|
response.text().then(callback);
|
|
@@ -959,7 +959,7 @@ function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
|
959
959
|
path,
|
|
960
960
|
json
|
|
961
961
|
});
|
|
962
|
-
if (singleValue && collection) {
|
|
962
|
+
if (singleValue && collection && Array.isArray(collection)) {
|
|
963
963
|
return collection[0];
|
|
964
964
|
} else {
|
|
965
965
|
return collection;
|
|
@@ -978,6 +978,8 @@ function setDOMAttribute(element, attribute, value, config) {
|
|
|
978
978
|
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
979
979
|
} else if (attribute == "data-path-href") {
|
|
980
980
|
target = element.querySelector("a") || element.closest("a");
|
|
981
|
+
} else if (attribute == "data-path-alt") {
|
|
982
|
+
target = element.querySelector("img, picture");
|
|
981
983
|
} else if (attribute == "data-path-hidden") {
|
|
982
984
|
value = !value ? true : null;
|
|
983
985
|
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
@@ -1169,7 +1171,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1169
1171
|
this.isFetching = false;
|
|
1170
1172
|
}
|
|
1171
1173
|
static get observedAttributes() {
|
|
1172
|
-
return ["data", "library", "component", "
|
|
1174
|
+
return ["data", "library", "component", "version", "revision", "hostname", "template"];
|
|
1173
1175
|
}
|
|
1174
1176
|
connectedCallback() {
|
|
1175
1177
|
this.connected = true;
|
|
@@ -1182,11 +1184,16 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1182
1184
|
return;
|
|
1183
1185
|
if (name == "template") {
|
|
1184
1186
|
this.template = newValue;
|
|
1187
|
+
} else if (name != "date") {
|
|
1188
|
+
this.template = null;
|
|
1185
1189
|
}
|
|
1186
1190
|
if (name == "data" && this.children.length > 0) {
|
|
1187
1191
|
this.update();
|
|
1188
1192
|
} else {
|
|
1189
|
-
this.
|
|
1193
|
+
cancelAnimationFrame(this.rendering);
|
|
1194
|
+
this.rendering = requestAnimationFrame(() => {
|
|
1195
|
+
this.render();
|
|
1196
|
+
});
|
|
1190
1197
|
}
|
|
1191
1198
|
}
|
|
1192
1199
|
update() {
|
|
@@ -1232,7 +1239,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1232
1239
|
const newProps = this.getProps();
|
|
1233
1240
|
if (this.template == null) {
|
|
1234
1241
|
if (!this.isFetching) {
|
|
1235
|
-
if (newProps.component != null && newProps.
|
|
1242
|
+
if (newProps.component != null && newProps.version != null) {
|
|
1236
1243
|
this.isFetching = true;
|
|
1237
1244
|
fetchComponent(newProps, (template) => {
|
|
1238
1245
|
this.template = template;
|
|
@@ -1240,7 +1247,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1240
1247
|
renderDOMContent(this, this.template, newProps.data);
|
|
1241
1248
|
}).catch(() => {
|
|
1242
1249
|
console.error(
|
|
1243
|
-
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.
|
|
1250
|
+
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.version}/${newProps.revision}`
|
|
1244
1251
|
);
|
|
1245
1252
|
});
|
|
1246
1253
|
}
|
|
@@ -1254,8 +1261,8 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1254
1261
|
data: this.getData(),
|
|
1255
1262
|
library: this.getAttribute("library") || void 0,
|
|
1256
1263
|
component: this.getAttribute("component") || void 0,
|
|
1257
|
-
variant: this.getAttribute("variant") || void 0,
|
|
1258
1264
|
version: this.getAttribute("version") || void 0,
|
|
1265
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1259
1266
|
hostname: this.getAttribute("hostname") || void 0
|
|
1260
1267
|
};
|
|
1261
1268
|
}
|
|
@@ -1266,7 +1273,7 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1266
1273
|
this.connected = false;
|
|
1267
1274
|
}
|
|
1268
1275
|
static get observedAttributes() {
|
|
1269
|
-
return ["library", "
|
|
1276
|
+
return ["library", "revision", "hostname"];
|
|
1270
1277
|
}
|
|
1271
1278
|
connectedCallback() {
|
|
1272
1279
|
this.connected = true;
|
|
@@ -1287,14 +1294,179 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1287
1294
|
getProps() {
|
|
1288
1295
|
return {
|
|
1289
1296
|
library: this.getAttribute("library") || void 0,
|
|
1290
|
-
|
|
1297
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1291
1298
|
hostname: this.getAttribute("hostname") || void 0
|
|
1292
1299
|
};
|
|
1293
1300
|
}
|
|
1294
1301
|
};
|
|
1302
|
+
var HTMLFeaasPickerLazy = class extends WebComponent {
|
|
1303
|
+
constructor() {
|
|
1304
|
+
super(...arguments);
|
|
1305
|
+
this.src = "https://components.sitecorecloud.io/assets/picker.js";
|
|
1306
|
+
this.onClose = () => {
|
|
1307
|
+
this.set({
|
|
1308
|
+
mode: null
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
this.onScriptLoaded = () => {
|
|
1312
|
+
this.element = document.createElement("feaas-picker");
|
|
1313
|
+
this.element.style.cssText = "border: 0; width: 100%; height: 100%; display: block";
|
|
1314
|
+
this.appendChild(this.element);
|
|
1315
|
+
this.set(this.getProps());
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
static get observedAttributes() {
|
|
1319
|
+
return ["library", "mode", "hidden", "src"];
|
|
1320
|
+
}
|
|
1321
|
+
connectedCallback() {
|
|
1322
|
+
this.loader = document.createElement("feaas-loader");
|
|
1323
|
+
this.loader.style.cssText = "position: absolute; top: 0; left: 0; right: 0;bottom: 0; ";
|
|
1324
|
+
this.appendChild(this.loader);
|
|
1325
|
+
}
|
|
1326
|
+
load() {
|
|
1327
|
+
if (!this.script) {
|
|
1328
|
+
this.script = document.createElement("script");
|
|
1329
|
+
this.script.type = "module";
|
|
1330
|
+
this.script.onload = this.onScriptLoaded;
|
|
1331
|
+
this.script.src = this.src;
|
|
1332
|
+
this.appendChild(this.script);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
getProps() {
|
|
1336
|
+
return {
|
|
1337
|
+
mode: this.getAttribute("mode"),
|
|
1338
|
+
library: this.getAttribute("library"),
|
|
1339
|
+
src: this.getAttribute("src")
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1343
|
+
this.set(this.getProps());
|
|
1344
|
+
}
|
|
1345
|
+
set(options) {
|
|
1346
|
+
Object.assign(this, options);
|
|
1347
|
+
const keys = Object.keys(this.getProps());
|
|
1348
|
+
for (var key of keys) {
|
|
1349
|
+
const value = this[key];
|
|
1350
|
+
if (value == null) {
|
|
1351
|
+
this.removeAttribute(key);
|
|
1352
|
+
this.load();
|
|
1353
|
+
} else if (this.getAttribute(key) != String(value)) {
|
|
1354
|
+
this.setAttribute(key, String(value));
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
if (this.mode) {
|
|
1358
|
+
this.removeAttribute("hidden");
|
|
1359
|
+
} else if (this.getAttribute("hidden") == null) {
|
|
1360
|
+
this.setAttribute("hidden", "hidden");
|
|
1361
|
+
}
|
|
1362
|
+
if (this.element && this.element.set) {
|
|
1363
|
+
this.element.onClose = this.onClose;
|
|
1364
|
+
this.element.set(options);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
var HTMLFeaasLoader = class extends WebComponent {
|
|
1369
|
+
static get observedAttributes() {
|
|
1370
|
+
return ["hidden"];
|
|
1371
|
+
}
|
|
1372
|
+
connectedCallback() {
|
|
1373
|
+
this.style.opacity = "1";
|
|
1374
|
+
this.style.transition = "opacity 0.2s 0.6s";
|
|
1375
|
+
this.stylesheet = document.createElement("style");
|
|
1376
|
+
this.stylesheet.textContent = `
|
|
1377
|
+
#loader {
|
|
1378
|
+
position: absolute;
|
|
1379
|
+
top: 0;
|
|
1380
|
+
left: 0;
|
|
1381
|
+
right: 0;
|
|
1382
|
+
bottom: 0;
|
|
1383
|
+
display: flex;
|
|
1384
|
+
align-items: center;
|
|
1385
|
+
justify-content: center;
|
|
1386
|
+
background: #f6f6ff;
|
|
1387
|
+
z-index: 1000;
|
|
1388
|
+
opacity: 1;
|
|
1389
|
+
transition: top 0.3s, background-color 0.7s 0.3s;
|
|
1390
|
+
}
|
|
1391
|
+
@keyframes loader-disappearance {
|
|
1392
|
+
100% {
|
|
1393
|
+
opacity: 0;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
@keyframes loader-appearance {
|
|
1397
|
+
0% {
|
|
1398
|
+
opacity: 0;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
@keyframes loader-circular-track {
|
|
1402
|
+
0% {
|
|
1403
|
+
stroke-dasharray: 1, 400;
|
|
1404
|
+
stroke-dashoffset: 0;
|
|
1405
|
+
}
|
|
1406
|
+
50% {
|
|
1407
|
+
stroke-dasharray: 400, 400;
|
|
1408
|
+
stroke-dashoffset: -100;
|
|
1409
|
+
}
|
|
1410
|
+
100% {
|
|
1411
|
+
stroke-dasharray: 400, 400;
|
|
1412
|
+
stroke-dashoffset: -260;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
@keyframes loader-circular-spinner {
|
|
1417
|
+
0% {
|
|
1418
|
+
transform: rotate(0deg);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
100% {
|
|
1422
|
+
transform: rotate(360deg);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
#loader .spinner {
|
|
1426
|
+
animation: loader-disappearance 0.6s both;
|
|
1427
|
+
width: 48px;
|
|
1428
|
+
height: 48px;
|
|
1429
|
+
}
|
|
1430
|
+
#loader .spinner {
|
|
1431
|
+
animation: loader-appearance 0.6s both;
|
|
1432
|
+
}
|
|
1433
|
+
`;
|
|
1434
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1435
|
+
this.loader = document.createElement("div");
|
|
1436
|
+
this.loader.id = "loader";
|
|
1437
|
+
this.loader.innerHTML = `
|
|
1438
|
+
<div class="spinner">
|
|
1439
|
+
<svg
|
|
1440
|
+
viewBox="0 0 100 100"
|
|
1441
|
+
style="
|
|
1442
|
+
animation: 2s linear 0s infinite normal none running loader-circular-spinner;
|
|
1443
|
+
display: block;
|
|
1444
|
+
width: 48px;
|
|
1445
|
+
height: 48px;
|
|
1446
|
+
"
|
|
1447
|
+
>
|
|
1448
|
+
<circle fill="transparent" cx="50" cy="50" r="42" stroke="rgba(0,0,0,0.1)" stroke-width="10px"></circle>
|
|
1449
|
+
<circle
|
|
1450
|
+
fill="transparent"
|
|
1451
|
+
stroke="#5548D9"
|
|
1452
|
+
cx="50"
|
|
1453
|
+
cy="50"
|
|
1454
|
+
r="42"
|
|
1455
|
+
stroke-width="10px"
|
|
1456
|
+
stroke-linecap="round"
|
|
1457
|
+
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1458
|
+
></circle>
|
|
1459
|
+
</svg>
|
|
1460
|
+
</div>`;
|
|
1461
|
+
this.shadowRoot.appendChild(this.stylesheet);
|
|
1462
|
+
this.shadowRoot.appendChild(this.loader);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1295
1465
|
if (typeof window != "undefined" && !window.customElements.get("feaas-stylesheet")) {
|
|
1296
1466
|
window.customElements.define("feaas-stylesheet", HTMLFeaasStylesheet);
|
|
1297
1467
|
window.customElements.define("feaas-component", HTMLFeaasComponent);
|
|
1468
|
+
window.customElements.define("feaas-picker-lazy", HTMLFeaasPickerLazy);
|
|
1469
|
+
window.customElements.define("feaas-loader", HTMLFeaasLoader);
|
|
1298
1470
|
}
|
|
1299
1471
|
|
|
1300
1472
|
// src/index.ts
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HTMLFeaasComponent, a as HTMLFeaasStylesheet, D as Datascopes, F as FEAASCustomizations, C as CloudStylesheet, b as FEAASComponentProps } from './webcomponent-
|
|
2
|
-
export { D as Datascopes, E as ExplicitTemplate, b as FEAASComponentProps, F as FEAASCustomizations, H as HTMLFeaasComponent, a as HTMLFeaasStylesheet, d as autoloadScripts, c as cleanCollectionBit, l as loadScript, n as normalizeCollectionScope, o as observeDOMElement, q as queryScopes, i as renderComponent, r as renderComponentElement, j as renderComponentPromise, f as renderDOMContent, e as renderDOMElement, g as renderStylesheet, h as renderStylesheetPromise, s as setDOMAttribute } from './webcomponent-
|
|
1
|
+
import { H as HTMLFeaasComponent, a as HTMLFeaasStylesheet, D as Datascopes, F as FEAASCustomizations, C as CloudStylesheet, b as FEAASComponentProps } from './webcomponent-6b45b819.js';
|
|
2
|
+
export { D as Datascopes, E as ExplicitTemplate, b as FEAASComponentProps, F as FEAASCustomizations, H as HTMLFeaasComponent, k as HTMLFeaasPickerProps, a as HTMLFeaasStylesheet, P as PickerProps, d as autoloadScripts, c as cleanCollectionBit, l as loadScript, n as normalizeCollectionScope, o as observeDOMElement, q as queryScopes, i as renderComponent, r as renderComponentElement, j as renderComponentPromise, f as renderDOMContent, e as renderDOMElement, g as renderStylesheet, h as renderStylesheetPromise, s as setDOMAttribute } from './webcomponent-6b45b819.js';
|
|
3
3
|
|
|
4
4
|
declare function fetchAndRevalidate(url: Parameters<typeof fetch>[0], options: Parameters<typeof fetch>[1], validator: (resposne: Response) => boolean, callback: (response: Response, status: 'cached' | 'valid') => void): Promise<Response>;
|
|
5
5
|
|
package/dist/node/index.js
CHANGED
|
@@ -799,17 +799,17 @@ function getComponentURL({
|
|
|
799
799
|
hostname = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
800
800
|
library,
|
|
801
801
|
component,
|
|
802
|
-
|
|
803
|
-
|
|
802
|
+
version,
|
|
803
|
+
revision = "published"
|
|
804
804
|
}) {
|
|
805
|
-
return `${hostname}/components/${library}/${component}/${
|
|
805
|
+
return `${hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
806
806
|
}
|
|
807
807
|
function getStylesheetURL({
|
|
808
808
|
hostname = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
809
809
|
library,
|
|
810
|
-
|
|
810
|
+
revision = "published"
|
|
811
811
|
}) {
|
|
812
|
-
return `${hostname}/styles/${library}/${
|
|
812
|
+
return `${hostname}/styles/${library}/${revision}.css`;
|
|
813
813
|
}
|
|
814
814
|
function fetchComponent(props, callback) {
|
|
815
815
|
return __async(this, null, function* () {
|
|
@@ -817,7 +817,7 @@ function fetchComponent(props, callback) {
|
|
|
817
817
|
getComponentURL(props),
|
|
818
818
|
{},
|
|
819
819
|
(response) => {
|
|
820
|
-
return response.headers.get("x-ms-meta-
|
|
820
|
+
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
821
821
|
},
|
|
822
822
|
(response) => {
|
|
823
823
|
response.text().then(callback);
|
|
@@ -924,7 +924,7 @@ function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
|
924
924
|
path,
|
|
925
925
|
json
|
|
926
926
|
});
|
|
927
|
-
if (singleValue && collection) {
|
|
927
|
+
if (singleValue && collection && Array.isArray(collection)) {
|
|
928
928
|
return collection[0];
|
|
929
929
|
} else {
|
|
930
930
|
return collection;
|
|
@@ -943,6 +943,8 @@ function setDOMAttribute(element, attribute, value, config) {
|
|
|
943
943
|
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
944
944
|
} else if (attribute == "data-path-href") {
|
|
945
945
|
target = element.querySelector("a") || element.closest("a");
|
|
946
|
+
} else if (attribute == "data-path-alt") {
|
|
947
|
+
target = element.querySelector("img, picture");
|
|
946
948
|
} else if (attribute == "data-path-hidden") {
|
|
947
949
|
value = !value ? true : null;
|
|
948
950
|
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
@@ -1134,7 +1136,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1134
1136
|
this.isFetching = false;
|
|
1135
1137
|
}
|
|
1136
1138
|
static get observedAttributes() {
|
|
1137
|
-
return ["data", "library", "component", "
|
|
1139
|
+
return ["data", "library", "component", "version", "revision", "hostname", "template"];
|
|
1138
1140
|
}
|
|
1139
1141
|
connectedCallback() {
|
|
1140
1142
|
this.connected = true;
|
|
@@ -1147,11 +1149,16 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1147
1149
|
return;
|
|
1148
1150
|
if (name == "template") {
|
|
1149
1151
|
this.template = newValue;
|
|
1152
|
+
} else if (name != "date") {
|
|
1153
|
+
this.template = null;
|
|
1150
1154
|
}
|
|
1151
1155
|
if (name == "data" && this.children.length > 0) {
|
|
1152
1156
|
this.update();
|
|
1153
1157
|
} else {
|
|
1154
|
-
this.
|
|
1158
|
+
cancelAnimationFrame(this.rendering);
|
|
1159
|
+
this.rendering = requestAnimationFrame(() => {
|
|
1160
|
+
this.render();
|
|
1161
|
+
});
|
|
1155
1162
|
}
|
|
1156
1163
|
}
|
|
1157
1164
|
update() {
|
|
@@ -1197,7 +1204,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1197
1204
|
const newProps = this.getProps();
|
|
1198
1205
|
if (this.template == null) {
|
|
1199
1206
|
if (!this.isFetching) {
|
|
1200
|
-
if (newProps.component != null && newProps.
|
|
1207
|
+
if (newProps.component != null && newProps.version != null) {
|
|
1201
1208
|
this.isFetching = true;
|
|
1202
1209
|
fetchComponent(newProps, (template) => {
|
|
1203
1210
|
this.template = template;
|
|
@@ -1205,7 +1212,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1205
1212
|
renderDOMContent(this, this.template, newProps.data);
|
|
1206
1213
|
}).catch(() => {
|
|
1207
1214
|
console.error(
|
|
1208
|
-
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.
|
|
1215
|
+
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.version}/${newProps.revision}`
|
|
1209
1216
|
);
|
|
1210
1217
|
});
|
|
1211
1218
|
}
|
|
@@ -1219,8 +1226,8 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1219
1226
|
data: this.getData(),
|
|
1220
1227
|
library: this.getAttribute("library") || void 0,
|
|
1221
1228
|
component: this.getAttribute("component") || void 0,
|
|
1222
|
-
variant: this.getAttribute("variant") || void 0,
|
|
1223
1229
|
version: this.getAttribute("version") || void 0,
|
|
1230
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1224
1231
|
hostname: this.getAttribute("hostname") || void 0
|
|
1225
1232
|
};
|
|
1226
1233
|
}
|
|
@@ -1231,7 +1238,7 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1231
1238
|
this.connected = false;
|
|
1232
1239
|
}
|
|
1233
1240
|
static get observedAttributes() {
|
|
1234
|
-
return ["library", "
|
|
1241
|
+
return ["library", "revision", "hostname"];
|
|
1235
1242
|
}
|
|
1236
1243
|
connectedCallback() {
|
|
1237
1244
|
this.connected = true;
|
|
@@ -1252,14 +1259,179 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1252
1259
|
getProps() {
|
|
1253
1260
|
return {
|
|
1254
1261
|
library: this.getAttribute("library") || void 0,
|
|
1255
|
-
|
|
1262
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1256
1263
|
hostname: this.getAttribute("hostname") || void 0
|
|
1257
1264
|
};
|
|
1258
1265
|
}
|
|
1259
1266
|
};
|
|
1267
|
+
var HTMLFeaasPickerLazy = class extends WebComponent {
|
|
1268
|
+
constructor() {
|
|
1269
|
+
super(...arguments);
|
|
1270
|
+
this.src = "https://components.sitecorecloud.io/assets/picker.js";
|
|
1271
|
+
this.onClose = () => {
|
|
1272
|
+
this.set({
|
|
1273
|
+
mode: null
|
|
1274
|
+
});
|
|
1275
|
+
};
|
|
1276
|
+
this.onScriptLoaded = () => {
|
|
1277
|
+
this.element = document.createElement("feaas-picker");
|
|
1278
|
+
this.element.style.cssText = "border: 0; width: 100%; height: 100%; display: block";
|
|
1279
|
+
this.appendChild(this.element);
|
|
1280
|
+
this.set(this.getProps());
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
static get observedAttributes() {
|
|
1284
|
+
return ["library", "mode", "hidden", "src"];
|
|
1285
|
+
}
|
|
1286
|
+
connectedCallback() {
|
|
1287
|
+
this.loader = document.createElement("feaas-loader");
|
|
1288
|
+
this.loader.style.cssText = "position: absolute; top: 0; left: 0; right: 0;bottom: 0; ";
|
|
1289
|
+
this.appendChild(this.loader);
|
|
1290
|
+
}
|
|
1291
|
+
load() {
|
|
1292
|
+
if (!this.script) {
|
|
1293
|
+
this.script = document.createElement("script");
|
|
1294
|
+
this.script.type = "module";
|
|
1295
|
+
this.script.onload = this.onScriptLoaded;
|
|
1296
|
+
this.script.src = this.src;
|
|
1297
|
+
this.appendChild(this.script);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
getProps() {
|
|
1301
|
+
return {
|
|
1302
|
+
mode: this.getAttribute("mode"),
|
|
1303
|
+
library: this.getAttribute("library"),
|
|
1304
|
+
src: this.getAttribute("src")
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1308
|
+
this.set(this.getProps());
|
|
1309
|
+
}
|
|
1310
|
+
set(options) {
|
|
1311
|
+
Object.assign(this, options);
|
|
1312
|
+
const keys = Object.keys(this.getProps());
|
|
1313
|
+
for (var key of keys) {
|
|
1314
|
+
const value = this[key];
|
|
1315
|
+
if (value == null) {
|
|
1316
|
+
this.removeAttribute(key);
|
|
1317
|
+
this.load();
|
|
1318
|
+
} else if (this.getAttribute(key) != String(value)) {
|
|
1319
|
+
this.setAttribute(key, String(value));
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
if (this.mode) {
|
|
1323
|
+
this.removeAttribute("hidden");
|
|
1324
|
+
} else if (this.getAttribute("hidden") == null) {
|
|
1325
|
+
this.setAttribute("hidden", "hidden");
|
|
1326
|
+
}
|
|
1327
|
+
if (this.element && this.element.set) {
|
|
1328
|
+
this.element.onClose = this.onClose;
|
|
1329
|
+
this.element.set(options);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
var HTMLFeaasLoader = class extends WebComponent {
|
|
1334
|
+
static get observedAttributes() {
|
|
1335
|
+
return ["hidden"];
|
|
1336
|
+
}
|
|
1337
|
+
connectedCallback() {
|
|
1338
|
+
this.style.opacity = "1";
|
|
1339
|
+
this.style.transition = "opacity 0.2s 0.6s";
|
|
1340
|
+
this.stylesheet = document.createElement("style");
|
|
1341
|
+
this.stylesheet.textContent = `
|
|
1342
|
+
#loader {
|
|
1343
|
+
position: absolute;
|
|
1344
|
+
top: 0;
|
|
1345
|
+
left: 0;
|
|
1346
|
+
right: 0;
|
|
1347
|
+
bottom: 0;
|
|
1348
|
+
display: flex;
|
|
1349
|
+
align-items: center;
|
|
1350
|
+
justify-content: center;
|
|
1351
|
+
background: #f6f6ff;
|
|
1352
|
+
z-index: 1000;
|
|
1353
|
+
opacity: 1;
|
|
1354
|
+
transition: top 0.3s, background-color 0.7s 0.3s;
|
|
1355
|
+
}
|
|
1356
|
+
@keyframes loader-disappearance {
|
|
1357
|
+
100% {
|
|
1358
|
+
opacity: 0;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
@keyframes loader-appearance {
|
|
1362
|
+
0% {
|
|
1363
|
+
opacity: 0;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
@keyframes loader-circular-track {
|
|
1367
|
+
0% {
|
|
1368
|
+
stroke-dasharray: 1, 400;
|
|
1369
|
+
stroke-dashoffset: 0;
|
|
1370
|
+
}
|
|
1371
|
+
50% {
|
|
1372
|
+
stroke-dasharray: 400, 400;
|
|
1373
|
+
stroke-dashoffset: -100;
|
|
1374
|
+
}
|
|
1375
|
+
100% {
|
|
1376
|
+
stroke-dasharray: 400, 400;
|
|
1377
|
+
stroke-dashoffset: -260;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
@keyframes loader-circular-spinner {
|
|
1382
|
+
0% {
|
|
1383
|
+
transform: rotate(0deg);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
100% {
|
|
1387
|
+
transform: rotate(360deg);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
#loader .spinner {
|
|
1391
|
+
animation: loader-disappearance 0.6s both;
|
|
1392
|
+
width: 48px;
|
|
1393
|
+
height: 48px;
|
|
1394
|
+
}
|
|
1395
|
+
#loader .spinner {
|
|
1396
|
+
animation: loader-appearance 0.6s both;
|
|
1397
|
+
}
|
|
1398
|
+
`;
|
|
1399
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1400
|
+
this.loader = document.createElement("div");
|
|
1401
|
+
this.loader.id = "loader";
|
|
1402
|
+
this.loader.innerHTML = `
|
|
1403
|
+
<div class="spinner">
|
|
1404
|
+
<svg
|
|
1405
|
+
viewBox="0 0 100 100"
|
|
1406
|
+
style="
|
|
1407
|
+
animation: 2s linear 0s infinite normal none running loader-circular-spinner;
|
|
1408
|
+
display: block;
|
|
1409
|
+
width: 48px;
|
|
1410
|
+
height: 48px;
|
|
1411
|
+
"
|
|
1412
|
+
>
|
|
1413
|
+
<circle fill="transparent" cx="50" cy="50" r="42" stroke="rgba(0,0,0,0.1)" stroke-width="10px"></circle>
|
|
1414
|
+
<circle
|
|
1415
|
+
fill="transparent"
|
|
1416
|
+
stroke="#5548D9"
|
|
1417
|
+
cx="50"
|
|
1418
|
+
cy="50"
|
|
1419
|
+
r="42"
|
|
1420
|
+
stroke-width="10px"
|
|
1421
|
+
stroke-linecap="round"
|
|
1422
|
+
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1423
|
+
></circle>
|
|
1424
|
+
</svg>
|
|
1425
|
+
</div>`;
|
|
1426
|
+
this.shadowRoot.appendChild(this.stylesheet);
|
|
1427
|
+
this.shadowRoot.appendChild(this.loader);
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1260
1430
|
if (typeof window != "undefined" && !window.customElements.get("feaas-stylesheet")) {
|
|
1261
1431
|
window.customElements.define("feaas-stylesheet", HTMLFeaasStylesheet);
|
|
1262
1432
|
window.customElements.define("feaas-component", HTMLFeaasComponent);
|
|
1433
|
+
window.customElements.define("feaas-picker-lazy", HTMLFeaasPickerLazy);
|
|
1434
|
+
window.customElements.define("feaas-loader", HTMLFeaasLoader);
|
|
1263
1435
|
}
|
|
1264
1436
|
|
|
1265
1437
|
// src/index.ts
|