@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/react.cjs
CHANGED
|
@@ -128,17 +128,17 @@ function getComponentURL({
|
|
|
128
128
|
hostname = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
129
129
|
library,
|
|
130
130
|
component,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
version,
|
|
132
|
+
revision = "published"
|
|
133
133
|
}) {
|
|
134
|
-
return `${hostname}/components/${library}/${component}/${
|
|
134
|
+
return `${hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
135
135
|
}
|
|
136
136
|
function getStylesheetURL({
|
|
137
137
|
hostname = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
138
138
|
library,
|
|
139
|
-
|
|
139
|
+
revision = "published"
|
|
140
140
|
}) {
|
|
141
|
-
return `${hostname}/styles/${library}/${
|
|
141
|
+
return `${hostname}/styles/${library}/${revision}.css`;
|
|
142
142
|
}
|
|
143
143
|
function fetchComponent(props, callback) {
|
|
144
144
|
return __async(this, null, function* () {
|
|
@@ -146,7 +146,7 @@ function fetchComponent(props, callback) {
|
|
|
146
146
|
getComponentURL(props),
|
|
147
147
|
{},
|
|
148
148
|
(response) => {
|
|
149
|
-
return response.headers.get("x-ms-meta-
|
|
149
|
+
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
150
150
|
},
|
|
151
151
|
(response) => {
|
|
152
152
|
response.text().then(callback);
|
|
@@ -971,7 +971,7 @@ function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
|
971
971
|
path,
|
|
972
972
|
json
|
|
973
973
|
});
|
|
974
|
-
if (singleValue && collection) {
|
|
974
|
+
if (singleValue && collection && Array.isArray(collection)) {
|
|
975
975
|
return collection[0];
|
|
976
976
|
} else {
|
|
977
977
|
return collection;
|
|
@@ -990,6 +990,8 @@ function setDOMAttribute(element, attribute, value, config) {
|
|
|
990
990
|
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
991
991
|
} else if (attribute == "data-path-href") {
|
|
992
992
|
target = element.querySelector("a") || element.closest("a");
|
|
993
|
+
} else if (attribute == "data-path-alt") {
|
|
994
|
+
target = element.querySelector("img, picture");
|
|
993
995
|
} else if (attribute == "data-path-hidden") {
|
|
994
996
|
value = !value ? true : null;
|
|
995
997
|
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
@@ -1181,7 +1183,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1181
1183
|
this.isFetching = false;
|
|
1182
1184
|
}
|
|
1183
1185
|
static get observedAttributes() {
|
|
1184
|
-
return ["data", "library", "component", "
|
|
1186
|
+
return ["data", "library", "component", "version", "revision", "hostname", "template"];
|
|
1185
1187
|
}
|
|
1186
1188
|
connectedCallback() {
|
|
1187
1189
|
this.connected = true;
|
|
@@ -1194,11 +1196,16 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1194
1196
|
return;
|
|
1195
1197
|
if (name == "template") {
|
|
1196
1198
|
this.template = newValue;
|
|
1199
|
+
} else if (name != "date") {
|
|
1200
|
+
this.template = null;
|
|
1197
1201
|
}
|
|
1198
1202
|
if (name == "data" && this.children.length > 0) {
|
|
1199
1203
|
this.update();
|
|
1200
1204
|
} else {
|
|
1201
|
-
this.
|
|
1205
|
+
cancelAnimationFrame(this.rendering);
|
|
1206
|
+
this.rendering = requestAnimationFrame(() => {
|
|
1207
|
+
this.render();
|
|
1208
|
+
});
|
|
1202
1209
|
}
|
|
1203
1210
|
}
|
|
1204
1211
|
update() {
|
|
@@ -1244,7 +1251,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1244
1251
|
const newProps = this.getProps();
|
|
1245
1252
|
if (this.template == null) {
|
|
1246
1253
|
if (!this.isFetching) {
|
|
1247
|
-
if (newProps.component != null && newProps.
|
|
1254
|
+
if (newProps.component != null && newProps.version != null) {
|
|
1248
1255
|
this.isFetching = true;
|
|
1249
1256
|
fetchComponent(newProps, (template) => {
|
|
1250
1257
|
this.template = template;
|
|
@@ -1252,7 +1259,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1252
1259
|
renderDOMContent(this, this.template, newProps.data);
|
|
1253
1260
|
}).catch(() => {
|
|
1254
1261
|
console.error(
|
|
1255
|
-
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.
|
|
1262
|
+
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.version}/${newProps.revision}`
|
|
1256
1263
|
);
|
|
1257
1264
|
});
|
|
1258
1265
|
}
|
|
@@ -1266,8 +1273,8 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1266
1273
|
data: this.getData(),
|
|
1267
1274
|
library: this.getAttribute("library") || void 0,
|
|
1268
1275
|
component: this.getAttribute("component") || void 0,
|
|
1269
|
-
variant: this.getAttribute("variant") || void 0,
|
|
1270
1276
|
version: this.getAttribute("version") || void 0,
|
|
1277
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1271
1278
|
hostname: this.getAttribute("hostname") || void 0
|
|
1272
1279
|
};
|
|
1273
1280
|
}
|
|
@@ -1278,7 +1285,7 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1278
1285
|
this.connected = false;
|
|
1279
1286
|
}
|
|
1280
1287
|
static get observedAttributes() {
|
|
1281
|
-
return ["library", "
|
|
1288
|
+
return ["library", "revision", "hostname"];
|
|
1282
1289
|
}
|
|
1283
1290
|
connectedCallback() {
|
|
1284
1291
|
this.connected = true;
|
|
@@ -1299,14 +1306,179 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1299
1306
|
getProps() {
|
|
1300
1307
|
return {
|
|
1301
1308
|
library: this.getAttribute("library") || void 0,
|
|
1302
|
-
|
|
1309
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1303
1310
|
hostname: this.getAttribute("hostname") || void 0
|
|
1304
1311
|
};
|
|
1305
1312
|
}
|
|
1306
1313
|
};
|
|
1314
|
+
var HTMLFeaasPickerLazy = class extends WebComponent {
|
|
1315
|
+
constructor() {
|
|
1316
|
+
super(...arguments);
|
|
1317
|
+
this.src = "https://components.sitecorecloud.io/assets/picker.js";
|
|
1318
|
+
this.onClose = () => {
|
|
1319
|
+
this.set({
|
|
1320
|
+
mode: null
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
this.onScriptLoaded = () => {
|
|
1324
|
+
this.element = document.createElement("feaas-picker");
|
|
1325
|
+
this.element.style.cssText = "border: 0; width: 100%; height: 100%; display: block";
|
|
1326
|
+
this.appendChild(this.element);
|
|
1327
|
+
this.set(this.getProps());
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
static get observedAttributes() {
|
|
1331
|
+
return ["library", "mode", "hidden", "src"];
|
|
1332
|
+
}
|
|
1333
|
+
connectedCallback() {
|
|
1334
|
+
this.loader = document.createElement("feaas-loader");
|
|
1335
|
+
this.loader.style.cssText = "position: absolute; top: 0; left: 0; right: 0;bottom: 0; ";
|
|
1336
|
+
this.appendChild(this.loader);
|
|
1337
|
+
}
|
|
1338
|
+
load() {
|
|
1339
|
+
if (!this.script) {
|
|
1340
|
+
this.script = document.createElement("script");
|
|
1341
|
+
this.script.type = "module";
|
|
1342
|
+
this.script.onload = this.onScriptLoaded;
|
|
1343
|
+
this.script.src = this.src;
|
|
1344
|
+
this.appendChild(this.script);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
getProps() {
|
|
1348
|
+
return {
|
|
1349
|
+
mode: this.getAttribute("mode"),
|
|
1350
|
+
library: this.getAttribute("library"),
|
|
1351
|
+
src: this.getAttribute("src")
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1355
|
+
this.set(this.getProps());
|
|
1356
|
+
}
|
|
1357
|
+
set(options) {
|
|
1358
|
+
Object.assign(this, options);
|
|
1359
|
+
const keys = Object.keys(this.getProps());
|
|
1360
|
+
for (var key of keys) {
|
|
1361
|
+
const value = this[key];
|
|
1362
|
+
if (value == null) {
|
|
1363
|
+
this.removeAttribute(key);
|
|
1364
|
+
this.load();
|
|
1365
|
+
} else if (this.getAttribute(key) != String(value)) {
|
|
1366
|
+
this.setAttribute(key, String(value));
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
if (this.mode) {
|
|
1370
|
+
this.removeAttribute("hidden");
|
|
1371
|
+
} else if (this.getAttribute("hidden") == null) {
|
|
1372
|
+
this.setAttribute("hidden", "hidden");
|
|
1373
|
+
}
|
|
1374
|
+
if (this.element && this.element.set) {
|
|
1375
|
+
this.element.onClose = this.onClose;
|
|
1376
|
+
this.element.set(options);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
var HTMLFeaasLoader = class extends WebComponent {
|
|
1381
|
+
static get observedAttributes() {
|
|
1382
|
+
return ["hidden"];
|
|
1383
|
+
}
|
|
1384
|
+
connectedCallback() {
|
|
1385
|
+
this.style.opacity = "1";
|
|
1386
|
+
this.style.transition = "opacity 0.2s 0.6s";
|
|
1387
|
+
this.stylesheet = document.createElement("style");
|
|
1388
|
+
this.stylesheet.textContent = `
|
|
1389
|
+
#loader {
|
|
1390
|
+
position: absolute;
|
|
1391
|
+
top: 0;
|
|
1392
|
+
left: 0;
|
|
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
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
@keyframes loader-appearance {
|
|
1409
|
+
0% {
|
|
1410
|
+
opacity: 0;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
@keyframes loader-circular-track {
|
|
1414
|
+
0% {
|
|
1415
|
+
stroke-dasharray: 1, 400;
|
|
1416
|
+
stroke-dashoffset: 0;
|
|
1417
|
+
}
|
|
1418
|
+
50% {
|
|
1419
|
+
stroke-dasharray: 400, 400;
|
|
1420
|
+
stroke-dashoffset: -100;
|
|
1421
|
+
}
|
|
1422
|
+
100% {
|
|
1423
|
+
stroke-dasharray: 400, 400;
|
|
1424
|
+
stroke-dashoffset: -260;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
@keyframes loader-circular-spinner {
|
|
1429
|
+
0% {
|
|
1430
|
+
transform: rotate(0deg);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
100% {
|
|
1434
|
+
transform: rotate(360deg);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
#loader .spinner {
|
|
1438
|
+
animation: loader-disappearance 0.6s both;
|
|
1439
|
+
width: 48px;
|
|
1440
|
+
height: 48px;
|
|
1441
|
+
}
|
|
1442
|
+
#loader .spinner {
|
|
1443
|
+
animation: loader-appearance 0.6s both;
|
|
1444
|
+
}
|
|
1445
|
+
`;
|
|
1446
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1447
|
+
this.loader = document.createElement("div");
|
|
1448
|
+
this.loader.id = "loader";
|
|
1449
|
+
this.loader.innerHTML = `
|
|
1450
|
+
<div class="spinner">
|
|
1451
|
+
<svg
|
|
1452
|
+
viewBox="0 0 100 100"
|
|
1453
|
+
style="
|
|
1454
|
+
animation: 2s linear 0s infinite normal none running loader-circular-spinner;
|
|
1455
|
+
display: block;
|
|
1456
|
+
width: 48px;
|
|
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);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1307
1477
|
if (typeof window != "undefined" && !window.customElements.get("feaas-stylesheet")) {
|
|
1308
1478
|
window.customElements.define("feaas-stylesheet", HTMLFeaasStylesheet);
|
|
1309
1479
|
window.customElements.define("feaas-component", HTMLFeaasComponent);
|
|
1480
|
+
window.customElements.define("feaas-picker-lazy", HTMLFeaasPickerLazy);
|
|
1481
|
+
window.customElements.define("feaas-loader", HTMLFeaasLoader);
|
|
1310
1482
|
}
|
|
1311
1483
|
|
|
1312
1484
|
// src/react.ts
|
|
@@ -1319,12 +1491,12 @@ function Component(props) {
|
|
|
1319
1491
|
if (template == null && !("template" in props)) {
|
|
1320
1492
|
fetchComponent(props, setTemplate).catch(() => {
|
|
1321
1493
|
console.error(
|
|
1322
|
-
`FEAAS: Could not fetch component: ${props.library}/${props.component}/${props.
|
|
1494
|
+
`FEAAS: Could not fetch component: ${props.library}/${props.component}/${props.version}/${props.revision}`
|
|
1323
1495
|
);
|
|
1324
1496
|
});
|
|
1325
1497
|
}
|
|
1326
1498
|
},
|
|
1327
|
-
"template" in props ? [props.template, null, null, null] : [props.library, props.component, props.
|
|
1499
|
+
"template" in props ? [props.template, null, null, null] : [props.library, props.component, props.version, props.revision, props.hostname]
|
|
1328
1500
|
);
|
|
1329
1501
|
import_react.default.useEffect(() => {
|
|
1330
1502
|
if (ref.current && template) {
|
package/dist/node/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { b as FEAASComponentProps, C as CloudStylesheet, H as HTMLFeaasComponent, a as HTMLFeaasStylesheet, D as Datascopes, F as FEAASCustomizations } from './webcomponent-
|
|
3
|
-
export { C as CloudStylesheet,
|
|
2
|
+
import { b as FEAASComponentProps, C as CloudStylesheet, H as HTMLFeaasComponent, a as HTMLFeaasStylesheet, D as Datascopes, F as FEAASCustomizations } from './webcomponent-6b45b819.js';
|
|
3
|
+
export { C as CloudStylesheet, m as CloudTemplate, 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, u as fetchComponent, v as fetchStylesheet, p as getComponentURL, t as getStylesheetURL, 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';
|
|
4
4
|
|
|
5
5
|
declare function Component(props: FEAASComponentProps): React.DetailedReactHTMLElement<{
|
|
6
6
|
ref: React.MutableRefObject<HTMLElement>;
|
package/dist/node/react.js
CHANGED
|
@@ -84,17 +84,17 @@ function getComponentURL({
|
|
|
84
84
|
hostname = "https://feaascomponentsapidev.blob.core.windows.net",
|
|
85
85
|
library,
|
|
86
86
|
component,
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
version,
|
|
88
|
+
revision = "published"
|
|
89
89
|
}) {
|
|
90
|
-
return `${hostname}/components/${library}/${component}/${
|
|
90
|
+
return `${hostname}/components/${library}/${component}/${version}/${revision}.html`;
|
|
91
91
|
}
|
|
92
92
|
function getStylesheetURL({
|
|
93
93
|
hostname = `https://feaascomponentsapidev.blob.core.windows.net`,
|
|
94
94
|
library,
|
|
95
|
-
|
|
95
|
+
revision = "published"
|
|
96
96
|
}) {
|
|
97
|
-
return `${hostname}/styles/${library}/${
|
|
97
|
+
return `${hostname}/styles/${library}/${revision}.css`;
|
|
98
98
|
}
|
|
99
99
|
function fetchComponent(props, callback) {
|
|
100
100
|
return __async(this, null, function* () {
|
|
@@ -102,7 +102,7 @@ function fetchComponent(props, callback) {
|
|
|
102
102
|
getComponentURL(props),
|
|
103
103
|
{},
|
|
104
104
|
(response) => {
|
|
105
|
-
return response.headers.get("x-ms-meta-
|
|
105
|
+
return response.headers.get("x-ms-meta-versionDeletedAt") == null;
|
|
106
106
|
},
|
|
107
107
|
(response) => {
|
|
108
108
|
response.text().then(callback);
|
|
@@ -927,7 +927,7 @@ function queryScopes(scopes, datapath, singleValue = false, json = scopes) {
|
|
|
927
927
|
path,
|
|
928
928
|
json
|
|
929
929
|
});
|
|
930
|
-
if (singleValue && collection) {
|
|
930
|
+
if (singleValue && collection && Array.isArray(collection)) {
|
|
931
931
|
return collection[0];
|
|
932
932
|
} else {
|
|
933
933
|
return collection;
|
|
@@ -946,6 +946,8 @@ function setDOMAttribute(element, attribute, value, config) {
|
|
|
946
946
|
target = element.tagName == "IMG" ? element : element.querySelector("img, video");
|
|
947
947
|
} else if (attribute == "data-path-href") {
|
|
948
948
|
target = element.querySelector("a") || element.closest("a");
|
|
949
|
+
} else if (attribute == "data-path-alt") {
|
|
950
|
+
target = element.querySelector("img, picture");
|
|
949
951
|
} else if (attribute == "data-path-hidden") {
|
|
950
952
|
value = !value ? true : null;
|
|
951
953
|
} else if (attribute == "data-path" || attribute == "data-embed-html" || attribute == "html") {
|
|
@@ -1137,7 +1139,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1137
1139
|
this.isFetching = false;
|
|
1138
1140
|
}
|
|
1139
1141
|
static get observedAttributes() {
|
|
1140
|
-
return ["data", "library", "component", "
|
|
1142
|
+
return ["data", "library", "component", "version", "revision", "hostname", "template"];
|
|
1141
1143
|
}
|
|
1142
1144
|
connectedCallback() {
|
|
1143
1145
|
this.connected = true;
|
|
@@ -1150,11 +1152,16 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1150
1152
|
return;
|
|
1151
1153
|
if (name == "template") {
|
|
1152
1154
|
this.template = newValue;
|
|
1155
|
+
} else if (name != "date") {
|
|
1156
|
+
this.template = null;
|
|
1153
1157
|
}
|
|
1154
1158
|
if (name == "data" && this.children.length > 0) {
|
|
1155
1159
|
this.update();
|
|
1156
1160
|
} else {
|
|
1157
|
-
this.
|
|
1161
|
+
cancelAnimationFrame(this.rendering);
|
|
1162
|
+
this.rendering = requestAnimationFrame(() => {
|
|
1163
|
+
this.render();
|
|
1164
|
+
});
|
|
1158
1165
|
}
|
|
1159
1166
|
}
|
|
1160
1167
|
update() {
|
|
@@ -1200,7 +1207,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1200
1207
|
const newProps = this.getProps();
|
|
1201
1208
|
if (this.template == null) {
|
|
1202
1209
|
if (!this.isFetching) {
|
|
1203
|
-
if (newProps.component != null && newProps.
|
|
1210
|
+
if (newProps.component != null && newProps.version != null) {
|
|
1204
1211
|
this.isFetching = true;
|
|
1205
1212
|
fetchComponent(newProps, (template) => {
|
|
1206
1213
|
this.template = template;
|
|
@@ -1208,7 +1215,7 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1208
1215
|
renderDOMContent(this, this.template, newProps.data);
|
|
1209
1216
|
}).catch(() => {
|
|
1210
1217
|
console.error(
|
|
1211
|
-
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.
|
|
1218
|
+
`FEAAS: Could not fetch component: ${newProps.component}/${newProps.version}/${newProps.revision}`
|
|
1212
1219
|
);
|
|
1213
1220
|
});
|
|
1214
1221
|
}
|
|
@@ -1222,8 +1229,8 @@ var HTMLFeaasComponent = class extends WebComponent {
|
|
|
1222
1229
|
data: this.getData(),
|
|
1223
1230
|
library: this.getAttribute("library") || void 0,
|
|
1224
1231
|
component: this.getAttribute("component") || void 0,
|
|
1225
|
-
variant: this.getAttribute("variant") || void 0,
|
|
1226
1232
|
version: this.getAttribute("version") || void 0,
|
|
1233
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1227
1234
|
hostname: this.getAttribute("hostname") || void 0
|
|
1228
1235
|
};
|
|
1229
1236
|
}
|
|
@@ -1234,7 +1241,7 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1234
1241
|
this.connected = false;
|
|
1235
1242
|
}
|
|
1236
1243
|
static get observedAttributes() {
|
|
1237
|
-
return ["library", "
|
|
1244
|
+
return ["library", "revision", "hostname"];
|
|
1238
1245
|
}
|
|
1239
1246
|
connectedCallback() {
|
|
1240
1247
|
this.connected = true;
|
|
@@ -1255,14 +1262,179 @@ var HTMLFeaasStylesheet = class extends WebComponent {
|
|
|
1255
1262
|
getProps() {
|
|
1256
1263
|
return {
|
|
1257
1264
|
library: this.getAttribute("library") || void 0,
|
|
1258
|
-
|
|
1265
|
+
revision: this.getAttribute("revision") || void 0,
|
|
1259
1266
|
hostname: this.getAttribute("hostname") || void 0
|
|
1260
1267
|
};
|
|
1261
1268
|
}
|
|
1262
1269
|
};
|
|
1270
|
+
var HTMLFeaasPickerLazy = class extends WebComponent {
|
|
1271
|
+
constructor() {
|
|
1272
|
+
super(...arguments);
|
|
1273
|
+
this.src = "https://components.sitecorecloud.io/assets/picker.js";
|
|
1274
|
+
this.onClose = () => {
|
|
1275
|
+
this.set({
|
|
1276
|
+
mode: null
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
this.onScriptLoaded = () => {
|
|
1280
|
+
this.element = document.createElement("feaas-picker");
|
|
1281
|
+
this.element.style.cssText = "border: 0; width: 100%; height: 100%; display: block";
|
|
1282
|
+
this.appendChild(this.element);
|
|
1283
|
+
this.set(this.getProps());
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
static get observedAttributes() {
|
|
1287
|
+
return ["library", "mode", "hidden", "src"];
|
|
1288
|
+
}
|
|
1289
|
+
connectedCallback() {
|
|
1290
|
+
this.loader = document.createElement("feaas-loader");
|
|
1291
|
+
this.loader.style.cssText = "position: absolute; top: 0; left: 0; right: 0;bottom: 0; ";
|
|
1292
|
+
this.appendChild(this.loader);
|
|
1293
|
+
}
|
|
1294
|
+
load() {
|
|
1295
|
+
if (!this.script) {
|
|
1296
|
+
this.script = document.createElement("script");
|
|
1297
|
+
this.script.type = "module";
|
|
1298
|
+
this.script.onload = this.onScriptLoaded;
|
|
1299
|
+
this.script.src = this.src;
|
|
1300
|
+
this.appendChild(this.script);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
getProps() {
|
|
1304
|
+
return {
|
|
1305
|
+
mode: this.getAttribute("mode"),
|
|
1306
|
+
library: this.getAttribute("library"),
|
|
1307
|
+
src: this.getAttribute("src")
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1311
|
+
this.set(this.getProps());
|
|
1312
|
+
}
|
|
1313
|
+
set(options) {
|
|
1314
|
+
Object.assign(this, options);
|
|
1315
|
+
const keys = Object.keys(this.getProps());
|
|
1316
|
+
for (var key of keys) {
|
|
1317
|
+
const value = this[key];
|
|
1318
|
+
if (value == null) {
|
|
1319
|
+
this.removeAttribute(key);
|
|
1320
|
+
this.load();
|
|
1321
|
+
} else if (this.getAttribute(key) != String(value)) {
|
|
1322
|
+
this.setAttribute(key, String(value));
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
if (this.mode) {
|
|
1326
|
+
this.removeAttribute("hidden");
|
|
1327
|
+
} else if (this.getAttribute("hidden") == null) {
|
|
1328
|
+
this.setAttribute("hidden", "hidden");
|
|
1329
|
+
}
|
|
1330
|
+
if (this.element && this.element.set) {
|
|
1331
|
+
this.element.onClose = this.onClose;
|
|
1332
|
+
this.element.set(options);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
var HTMLFeaasLoader = class extends WebComponent {
|
|
1337
|
+
static get observedAttributes() {
|
|
1338
|
+
return ["hidden"];
|
|
1339
|
+
}
|
|
1340
|
+
connectedCallback() {
|
|
1341
|
+
this.style.opacity = "1";
|
|
1342
|
+
this.style.transition = "opacity 0.2s 0.6s";
|
|
1343
|
+
this.stylesheet = document.createElement("style");
|
|
1344
|
+
this.stylesheet.textContent = `
|
|
1345
|
+
#loader {
|
|
1346
|
+
position: absolute;
|
|
1347
|
+
top: 0;
|
|
1348
|
+
left: 0;
|
|
1349
|
+
right: 0;
|
|
1350
|
+
bottom: 0;
|
|
1351
|
+
display: flex;
|
|
1352
|
+
align-items: center;
|
|
1353
|
+
justify-content: center;
|
|
1354
|
+
background: #f6f6ff;
|
|
1355
|
+
z-index: 1000;
|
|
1356
|
+
opacity: 1;
|
|
1357
|
+
transition: top 0.3s, background-color 0.7s 0.3s;
|
|
1358
|
+
}
|
|
1359
|
+
@keyframes loader-disappearance {
|
|
1360
|
+
100% {
|
|
1361
|
+
opacity: 0;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
@keyframes loader-appearance {
|
|
1365
|
+
0% {
|
|
1366
|
+
opacity: 0;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
@keyframes loader-circular-track {
|
|
1370
|
+
0% {
|
|
1371
|
+
stroke-dasharray: 1, 400;
|
|
1372
|
+
stroke-dashoffset: 0;
|
|
1373
|
+
}
|
|
1374
|
+
50% {
|
|
1375
|
+
stroke-dasharray: 400, 400;
|
|
1376
|
+
stroke-dashoffset: -100;
|
|
1377
|
+
}
|
|
1378
|
+
100% {
|
|
1379
|
+
stroke-dasharray: 400, 400;
|
|
1380
|
+
stroke-dashoffset: -260;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
@keyframes loader-circular-spinner {
|
|
1385
|
+
0% {
|
|
1386
|
+
transform: rotate(0deg);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
100% {
|
|
1390
|
+
transform: rotate(360deg);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
#loader .spinner {
|
|
1394
|
+
animation: loader-disappearance 0.6s both;
|
|
1395
|
+
width: 48px;
|
|
1396
|
+
height: 48px;
|
|
1397
|
+
}
|
|
1398
|
+
#loader .spinner {
|
|
1399
|
+
animation: loader-appearance 0.6s both;
|
|
1400
|
+
}
|
|
1401
|
+
`;
|
|
1402
|
+
this.root = this.attachShadow({ mode: "open" });
|
|
1403
|
+
this.loader = document.createElement("div");
|
|
1404
|
+
this.loader.id = "loader";
|
|
1405
|
+
this.loader.innerHTML = `
|
|
1406
|
+
<div class="spinner">
|
|
1407
|
+
<svg
|
|
1408
|
+
viewBox="0 0 100 100"
|
|
1409
|
+
style="
|
|
1410
|
+
animation: 2s linear 0s infinite normal none running loader-circular-spinner;
|
|
1411
|
+
display: block;
|
|
1412
|
+
width: 48px;
|
|
1413
|
+
height: 48px;
|
|
1414
|
+
"
|
|
1415
|
+
>
|
|
1416
|
+
<circle fill="transparent" cx="50" cy="50" r="42" stroke="rgba(0,0,0,0.1)" stroke-width="10px"></circle>
|
|
1417
|
+
<circle
|
|
1418
|
+
fill="transparent"
|
|
1419
|
+
stroke="#5548D9"
|
|
1420
|
+
cx="50"
|
|
1421
|
+
cy="50"
|
|
1422
|
+
r="42"
|
|
1423
|
+
stroke-width="10px"
|
|
1424
|
+
stroke-linecap="round"
|
|
1425
|
+
style="animation: 1.5s linear 0s infinite normal none running loader-circular-track"
|
|
1426
|
+
></circle>
|
|
1427
|
+
</svg>
|
|
1428
|
+
</div>`;
|
|
1429
|
+
this.shadowRoot.appendChild(this.stylesheet);
|
|
1430
|
+
this.shadowRoot.appendChild(this.loader);
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1263
1433
|
if (typeof window != "undefined" && !window.customElements.get("feaas-stylesheet")) {
|
|
1264
1434
|
window.customElements.define("feaas-stylesheet", HTMLFeaasStylesheet);
|
|
1265
1435
|
window.customElements.define("feaas-component", HTMLFeaasComponent);
|
|
1436
|
+
window.customElements.define("feaas-picker-lazy", HTMLFeaasPickerLazy);
|
|
1437
|
+
window.customElements.define("feaas-loader", HTMLFeaasLoader);
|
|
1266
1438
|
}
|
|
1267
1439
|
|
|
1268
1440
|
// src/react.ts
|
|
@@ -1275,12 +1447,12 @@ function Component(props) {
|
|
|
1275
1447
|
if (template == null && !("template" in props)) {
|
|
1276
1448
|
fetchComponent(props, setTemplate).catch(() => {
|
|
1277
1449
|
console.error(
|
|
1278
|
-
`FEAAS: Could not fetch component: ${props.library}/${props.component}/${props.
|
|
1450
|
+
`FEAAS: Could not fetch component: ${props.library}/${props.component}/${props.version}/${props.revision}`
|
|
1279
1451
|
);
|
|
1280
1452
|
});
|
|
1281
1453
|
}
|
|
1282
1454
|
},
|
|
1283
|
-
"template" in props ? [props.template, null, null, null] : [props.library, props.component, props.
|
|
1455
|
+
"template" in props ? [props.template, null, null, null] : [props.library, props.component, props.version, props.revision, props.hostname]
|
|
1284
1456
|
);
|
|
1285
1457
|
React.useEffect(() => {
|
|
1286
1458
|
if (ref.current && template) {
|