@penn-libraries/web 0.0.6 → 0.0.8
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/dist/cjs/{index-8aad290c.js → index-4f0a0453.js} +68 -24
- package/dist/cjs/index-4f0a0453.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/pennlibs-banner_3.cjs.entry.js +60 -50
- package/dist/cjs/pennlibs-banner_3.cjs.entry.js.map +1 -1
- package/dist/cjs/web.cjs.js +3 -3
- package/dist/cjs/web.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/pennlibs-banner/pennlibs-banner.js +17 -17
- package/dist/collection/components/pennlibs-banner/pennlibs-banner.js.map +1 -1
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js +48 -48
- package/dist/collection/components/pennlibs-footer/pennlibs-footer.js.map +1 -1
- package/dist/collection/components/pennlibs-header/pennlibs-header.css +18 -6
- package/dist/collection/components/pennlibs-header/pennlibs-header.js +117 -107
- package/dist/collection/components/pennlibs-header/pennlibs-header.js.map +1 -1
- package/dist/collection/utils/utils.js +1 -1
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/collection/utils/utils.spec.js +12 -12
- package/dist/collection/utils/utils.spec.js.map +1 -1
- package/dist/esm/{index-d58d1ee0.js → index-51b7707e.js} +68 -24
- package/dist/esm/index-51b7707e.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/pennlibs-banner_3.entry.js +60 -50
- package/dist/esm/pennlibs-banner_3.entry.js.map +1 -1
- package/dist/esm/web.js +4 -4
- package/dist/esm/web.js.map +1 -1
- package/dist/types/components/pennlibs-banner/pennlibs-banner.d.ts +1 -1
- package/dist/types/components/pennlibs-footer/pennlibs-footer.d.ts +10 -10
- package/dist/types/components/pennlibs-header/pennlibs-header.d.ts +21 -20
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/web/p-41432e5b.entry.js +82 -0
- package/dist/web/p-41432e5b.entry.js.map +1 -0
- package/dist/web/{p-d9c828d7.js → p-dd3ab4f7.js} +68 -24
- package/dist/web/p-dd3ab4f7.js.map +1 -0
- package/dist/web/web.css +50 -2
- package/dist/web/web.esm.js +4 -4
- package/dist/web/web.esm.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +6 -9
- package/dist/cjs/index-8aad290c.js.map +0 -1
- package/dist/esm/index-d58d1ee0.js.map +0 -1
- package/dist/web/p-d85c4348.entry.js +0 -72
- package/dist/web/p-d85c4348.entry.js.map +0 -1
- package/dist/web/p-d9c828d7.js.map +0 -1
|
@@ -31,6 +31,13 @@ const uniqueTime = (key, measureText) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
34
|
+
/**
|
|
35
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
36
|
+
*
|
|
37
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
38
|
+
* support as of Stencil v4.
|
|
39
|
+
*/
|
|
40
|
+
const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
|
|
34
41
|
/**
|
|
35
42
|
* Default style mode id
|
|
36
43
|
*/
|
|
@@ -251,6 +258,10 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
251
258
|
}
|
|
252
259
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
253
260
|
}
|
|
261
|
+
// Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
|
|
262
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
263
|
+
styleElm.innerHTML += SLOT_FB_CSS;
|
|
264
|
+
}
|
|
254
265
|
if (appliedStyles) {
|
|
255
266
|
appliedStyles.add(scopeId);
|
|
256
267
|
}
|
|
@@ -407,7 +418,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
407
418
|
elm[memberName] = newValue;
|
|
408
419
|
}
|
|
409
420
|
}
|
|
410
|
-
catch (e) {
|
|
421
|
+
catch (e) {
|
|
422
|
+
/**
|
|
423
|
+
* in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
|
|
424
|
+
*/
|
|
425
|
+
}
|
|
411
426
|
}
|
|
412
427
|
if (newValue == null || newValue === false) {
|
|
413
428
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
@@ -426,6 +441,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
426
441
|
}
|
|
427
442
|
};
|
|
428
443
|
const parseClassListRegex = /\s/;
|
|
444
|
+
/**
|
|
445
|
+
* Parsed a string of classnames into an array
|
|
446
|
+
* @param value className string, e.g. "foo bar baz"
|
|
447
|
+
* @returns list of classes, e.g. ["foo", "bar", "baz"]
|
|
448
|
+
*/
|
|
429
449
|
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
430
450
|
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
|
431
451
|
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
|
@@ -512,6 +532,9 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
512
532
|
}
|
|
513
533
|
}
|
|
514
534
|
}
|
|
535
|
+
// This needs to always happen so we can hide nodes that are projected
|
|
536
|
+
// to another component but don't end up in a slot
|
|
537
|
+
elm['s-hn'] = hostTagName;
|
|
515
538
|
return elm;
|
|
516
539
|
};
|
|
517
540
|
/**
|
|
@@ -635,8 +658,9 @@ const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
|
635
658
|
* @param oldCh the old children of the parent node
|
|
636
659
|
* @param newVNode the new VNode which will replace the parent
|
|
637
660
|
* @param newCh the new children of the parent node
|
|
661
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
638
662
|
*/
|
|
639
|
-
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
663
|
+
const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
|
|
640
664
|
let oldStartIdx = 0;
|
|
641
665
|
let newStartIdx = 0;
|
|
642
666
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -660,25 +684,25 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
660
684
|
else if (newEndVnode == null) {
|
|
661
685
|
newEndVnode = newCh[--newEndIdx];
|
|
662
686
|
}
|
|
663
|
-
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
687
|
+
else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
|
|
664
688
|
// if the start nodes are the same then we should patch the new VNode
|
|
665
689
|
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
666
690
|
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
667
691
|
// since things are matched up in order.
|
|
668
|
-
patch(oldStartVnode, newStartVnode);
|
|
692
|
+
patch(oldStartVnode, newStartVnode, isInitialRender);
|
|
669
693
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
670
694
|
newStartVnode = newCh[++newStartIdx];
|
|
671
695
|
}
|
|
672
|
-
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
696
|
+
else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
|
|
673
697
|
// likewise, if the end nodes are the same we patch new onto old and
|
|
674
698
|
// decrement our end indices, and also likewise in this case we don't
|
|
675
699
|
// need to move any DOM Nodes.
|
|
676
|
-
patch(oldEndVnode, newEndVnode);
|
|
700
|
+
patch(oldEndVnode, newEndVnode, isInitialRender);
|
|
677
701
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
678
702
|
newEndVnode = newCh[--newEndIdx];
|
|
679
703
|
}
|
|
680
|
-
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
681
|
-
patch(oldStartVnode, newEndVnode);
|
|
704
|
+
else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
|
|
705
|
+
patch(oldStartVnode, newEndVnode, isInitialRender);
|
|
682
706
|
// We need to move the element for `oldStartVnode` into a position which
|
|
683
707
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
684
708
|
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
@@ -700,8 +724,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
700
724
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
701
725
|
newEndVnode = newCh[--newEndIdx];
|
|
702
726
|
}
|
|
703
|
-
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
704
|
-
patch(oldEndVnode, newStartVnode);
|
|
727
|
+
else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
|
|
728
|
+
patch(oldEndVnode, newStartVnode, isInitialRender);
|
|
705
729
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
706
730
|
// the same node, so since we're here we know that they are not. Thus we
|
|
707
731
|
// can move the element for `oldEndVnode` _before_ the element for
|
|
@@ -755,9 +779,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
755
779
|
*
|
|
756
780
|
* @param leftVNode the first VNode to check
|
|
757
781
|
* @param rightVNode the second VNode to check
|
|
782
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
758
783
|
* @returns whether they're equal or not
|
|
759
784
|
*/
|
|
760
|
-
const isSameVnode = (leftVNode, rightVNode) => {
|
|
785
|
+
const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
|
|
761
786
|
// compare if two vnode to see if they're "technically" the same
|
|
762
787
|
// need to have the same element tag, and same key to be the same
|
|
763
788
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
@@ -772,8 +797,9 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
772
797
|
*
|
|
773
798
|
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
774
799
|
* @param newVNode a new VNode representing an updated version of the old one
|
|
800
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
775
801
|
*/
|
|
776
|
-
const patch = (oldVNode, newVNode) => {
|
|
802
|
+
const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
777
803
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
778
804
|
const oldChildren = oldVNode.$children$;
|
|
779
805
|
const newChildren = newVNode.$children$;
|
|
@@ -796,7 +822,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
796
822
|
if (oldChildren !== null && newChildren !== null) {
|
|
797
823
|
// looks like there's child vnodes for both the old and new vnodes
|
|
798
824
|
// so we need to call `updateChildren` to reconcile them
|
|
799
|
-
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
825
|
+
updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
|
|
800
826
|
}
|
|
801
827
|
else if (newChildren !== null) {
|
|
802
828
|
// no old child vnodes, but there are new child vnodes to add
|
|
@@ -873,7 +899,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
873
899
|
scopeId = hostElm['s-sc'];
|
|
874
900
|
}
|
|
875
901
|
// synchronous patch
|
|
876
|
-
patch(oldVNode, rootVnode);
|
|
902
|
+
patch(oldVNode, rootVnode, isInitialLoad);
|
|
877
903
|
};
|
|
878
904
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
879
905
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -1163,10 +1189,10 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1163
1189
|
*/
|
|
1164
1190
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1165
1191
|
var _a;
|
|
1192
|
+
const prototype = Cstr.prototype;
|
|
1166
1193
|
if (cmpMeta.$members$) {
|
|
1167
1194
|
// It's better to have a const than two Object.entries()
|
|
1168
1195
|
const members = Object.entries(cmpMeta.$members$);
|
|
1169
|
-
const prototype = Cstr.prototype;
|
|
1170
1196
|
members.map(([memberName, [memberFlags]]) => {
|
|
1171
1197
|
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1172
1198
|
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
@@ -1189,6 +1215,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1189
1215
|
const attrNameToPropName = new Map();
|
|
1190
1216
|
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
|
1191
1217
|
plt.jmp(() => {
|
|
1218
|
+
var _a;
|
|
1192
1219
|
const propName = attrNameToPropName.get(attrName);
|
|
1193
1220
|
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1194
1221
|
// in the case where an attribute was set inline.
|
|
@@ -1244,11 +1271,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1244
1271
|
// 1. The instance is ready
|
|
1245
1272
|
// 2. The watchers are ready
|
|
1246
1273
|
// 3. The value has changed
|
|
1247
|
-
if (
|
|
1274
|
+
if (flags &&
|
|
1275
|
+
!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
|
1248
1276
|
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
|
1249
1277
|
newValue !== oldValue) {
|
|
1250
1278
|
const instance = hostRef.$lazyInstance$ ;
|
|
1251
|
-
const entry = cmpMeta.$watchers$[attrName];
|
|
1279
|
+
const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
|
|
1252
1280
|
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
|
1253
1281
|
if (instance[callbackName] != null) {
|
|
1254
1282
|
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
@@ -1438,12 +1466,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1438
1466
|
const customElements = win.customElements;
|
|
1439
1467
|
const head = doc.head;
|
|
1440
1468
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1441
|
-
const
|
|
1469
|
+
const dataStyles = /*@__PURE__*/ doc.createElement('style');
|
|
1442
1470
|
const deferredConnectedCallbacks = [];
|
|
1443
1471
|
let appLoadFallback;
|
|
1444
1472
|
let isBootstrapping = true;
|
|
1445
1473
|
Object.assign(plt, options);
|
|
1446
1474
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1475
|
+
let hasSlotRelocation = false;
|
|
1447
1476
|
lazyBundles.map((lazyBundle) => {
|
|
1448
1477
|
lazyBundle[1].map((compactMeta) => {
|
|
1449
1478
|
const cmpMeta = {
|
|
@@ -1452,6 +1481,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1452
1481
|
$members$: compactMeta[2],
|
|
1453
1482
|
$listeners$: compactMeta[3],
|
|
1454
1483
|
};
|
|
1484
|
+
// Check if we are using slots outside the shadow DOM in this component.
|
|
1485
|
+
// We'll use this information later to add styles for `slot-fb` elements
|
|
1486
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
1487
|
+
hasSlotRelocation = true;
|
|
1488
|
+
}
|
|
1455
1489
|
{
|
|
1456
1490
|
cmpMeta.$members$ = compactMeta[2];
|
|
1457
1491
|
}
|
|
@@ -1505,15 +1539,25 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1505
1539
|
}
|
|
1506
1540
|
});
|
|
1507
1541
|
});
|
|
1542
|
+
// Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
|
|
1543
|
+
if (hasSlotRelocation) {
|
|
1544
|
+
dataStyles.innerHTML += SLOT_FB_CSS;
|
|
1545
|
+
}
|
|
1546
|
+
// Add hydration styles
|
|
1508
1547
|
{
|
|
1509
|
-
|
|
1510
|
-
|
|
1548
|
+
dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
|
|
1549
|
+
}
|
|
1550
|
+
// If we have styles, add them to the DOM
|
|
1551
|
+
if (dataStyles.innerHTML.length) {
|
|
1552
|
+
dataStyles.setAttribute('data-styles', '');
|
|
1511
1553
|
// Apply CSP nonce to the style tag if it exists
|
|
1512
1554
|
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1513
1555
|
if (nonce != null) {
|
|
1514
|
-
|
|
1556
|
+
dataStyles.setAttribute('nonce', nonce);
|
|
1515
1557
|
}
|
|
1516
|
-
|
|
1558
|
+
// Insert the styles into the document head
|
|
1559
|
+
// NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
|
|
1560
|
+
head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1517
1561
|
}
|
|
1518
1562
|
// Process deferred connectedCallbacks now all components have been registered
|
|
1519
1563
|
isBootstrapping = false;
|
|
@@ -1695,9 +1739,9 @@ const flush = () => {
|
|
|
1695
1739
|
}
|
|
1696
1740
|
}
|
|
1697
1741
|
};
|
|
1698
|
-
const nextTick =
|
|
1742
|
+
const nextTick = (cb) => promiseResolve().then(cb);
|
|
1699
1743
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1700
1744
|
|
|
1701
1745
|
export { getElement as a, bootstrapLazy as b, getAssetPath as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
1702
1746
|
|
|
1703
|
-
//# sourceMappingURL=index-
|
|
1747
|
+
//# sourceMappingURL=index-51b7707e.js.map
|