@penn-libraries/web 0.0.7 → 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 +2 -13
- 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
|
@@ -53,6 +53,13 @@ const uniqueTime = (key, measureText) => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
56
|
+
/**
|
|
57
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
58
|
+
*
|
|
59
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
60
|
+
* support as of Stencil v4.
|
|
61
|
+
*/
|
|
62
|
+
const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
|
|
56
63
|
/**
|
|
57
64
|
* Default style mode id
|
|
58
65
|
*/
|
|
@@ -273,6 +280,10 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
273
280
|
}
|
|
274
281
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
275
282
|
}
|
|
283
|
+
// Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
|
|
284
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
285
|
+
styleElm.innerHTML += SLOT_FB_CSS;
|
|
286
|
+
}
|
|
276
287
|
if (appliedStyles) {
|
|
277
288
|
appliedStyles.add(scopeId);
|
|
278
289
|
}
|
|
@@ -429,7 +440,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
429
440
|
elm[memberName] = newValue;
|
|
430
441
|
}
|
|
431
442
|
}
|
|
432
|
-
catch (e) {
|
|
443
|
+
catch (e) {
|
|
444
|
+
/**
|
|
445
|
+
* in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
|
|
446
|
+
*/
|
|
447
|
+
}
|
|
433
448
|
}
|
|
434
449
|
if (newValue == null || newValue === false) {
|
|
435
450
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
@@ -448,6 +463,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
448
463
|
}
|
|
449
464
|
};
|
|
450
465
|
const parseClassListRegex = /\s/;
|
|
466
|
+
/**
|
|
467
|
+
* Parsed a string of classnames into an array
|
|
468
|
+
* @param value className string, e.g. "foo bar baz"
|
|
469
|
+
* @returns list of classes, e.g. ["foo", "bar", "baz"]
|
|
470
|
+
*/
|
|
451
471
|
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
452
472
|
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
|
453
473
|
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
|
@@ -534,6 +554,9 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
534
554
|
}
|
|
535
555
|
}
|
|
536
556
|
}
|
|
557
|
+
// This needs to always happen so we can hide nodes that are projected
|
|
558
|
+
// to another component but don't end up in a slot
|
|
559
|
+
elm['s-hn'] = hostTagName;
|
|
537
560
|
return elm;
|
|
538
561
|
};
|
|
539
562
|
/**
|
|
@@ -657,8 +680,9 @@ const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
|
657
680
|
* @param oldCh the old children of the parent node
|
|
658
681
|
* @param newVNode the new VNode which will replace the parent
|
|
659
682
|
* @param newCh the new children of the parent node
|
|
683
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
660
684
|
*/
|
|
661
|
-
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
685
|
+
const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
|
|
662
686
|
let oldStartIdx = 0;
|
|
663
687
|
let newStartIdx = 0;
|
|
664
688
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -682,25 +706,25 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
682
706
|
else if (newEndVnode == null) {
|
|
683
707
|
newEndVnode = newCh[--newEndIdx];
|
|
684
708
|
}
|
|
685
|
-
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
709
|
+
else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
|
|
686
710
|
// if the start nodes are the same then we should patch the new VNode
|
|
687
711
|
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
688
712
|
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
689
713
|
// since things are matched up in order.
|
|
690
|
-
patch(oldStartVnode, newStartVnode);
|
|
714
|
+
patch(oldStartVnode, newStartVnode, isInitialRender);
|
|
691
715
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
692
716
|
newStartVnode = newCh[++newStartIdx];
|
|
693
717
|
}
|
|
694
|
-
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
718
|
+
else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
|
|
695
719
|
// likewise, if the end nodes are the same we patch new onto old and
|
|
696
720
|
// decrement our end indices, and also likewise in this case we don't
|
|
697
721
|
// need to move any DOM Nodes.
|
|
698
|
-
patch(oldEndVnode, newEndVnode);
|
|
722
|
+
patch(oldEndVnode, newEndVnode, isInitialRender);
|
|
699
723
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
700
724
|
newEndVnode = newCh[--newEndIdx];
|
|
701
725
|
}
|
|
702
|
-
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
703
|
-
patch(oldStartVnode, newEndVnode);
|
|
726
|
+
else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
|
|
727
|
+
patch(oldStartVnode, newEndVnode, isInitialRender);
|
|
704
728
|
// We need to move the element for `oldStartVnode` into a position which
|
|
705
729
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
706
730
|
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
@@ -722,8 +746,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
722
746
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
723
747
|
newEndVnode = newCh[--newEndIdx];
|
|
724
748
|
}
|
|
725
|
-
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
726
|
-
patch(oldEndVnode, newStartVnode);
|
|
749
|
+
else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
|
|
750
|
+
patch(oldEndVnode, newStartVnode, isInitialRender);
|
|
727
751
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
728
752
|
// the same node, so since we're here we know that they are not. Thus we
|
|
729
753
|
// can move the element for `oldEndVnode` _before_ the element for
|
|
@@ -777,9 +801,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
777
801
|
*
|
|
778
802
|
* @param leftVNode the first VNode to check
|
|
779
803
|
* @param rightVNode the second VNode to check
|
|
804
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
780
805
|
* @returns whether they're equal or not
|
|
781
806
|
*/
|
|
782
|
-
const isSameVnode = (leftVNode, rightVNode) => {
|
|
807
|
+
const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
|
|
783
808
|
// compare if two vnode to see if they're "technically" the same
|
|
784
809
|
// need to have the same element tag, and same key to be the same
|
|
785
810
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
@@ -794,8 +819,9 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
794
819
|
*
|
|
795
820
|
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
796
821
|
* @param newVNode a new VNode representing an updated version of the old one
|
|
822
|
+
* @param isInitialRender whether or not this is the first render of the vdom
|
|
797
823
|
*/
|
|
798
|
-
const patch = (oldVNode, newVNode) => {
|
|
824
|
+
const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
799
825
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
800
826
|
const oldChildren = oldVNode.$children$;
|
|
801
827
|
const newChildren = newVNode.$children$;
|
|
@@ -818,7 +844,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
818
844
|
if (oldChildren !== null && newChildren !== null) {
|
|
819
845
|
// looks like there's child vnodes for both the old and new vnodes
|
|
820
846
|
// so we need to call `updateChildren` to reconcile them
|
|
821
|
-
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
847
|
+
updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
|
|
822
848
|
}
|
|
823
849
|
else if (newChildren !== null) {
|
|
824
850
|
// no old child vnodes, but there are new child vnodes to add
|
|
@@ -895,7 +921,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
895
921
|
scopeId = hostElm['s-sc'];
|
|
896
922
|
}
|
|
897
923
|
// synchronous patch
|
|
898
|
-
patch(oldVNode, rootVnode);
|
|
924
|
+
patch(oldVNode, rootVnode, isInitialLoad);
|
|
899
925
|
};
|
|
900
926
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
901
927
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -1185,10 +1211,10 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1185
1211
|
*/
|
|
1186
1212
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1187
1213
|
var _a;
|
|
1214
|
+
const prototype = Cstr.prototype;
|
|
1188
1215
|
if (cmpMeta.$members$) {
|
|
1189
1216
|
// It's better to have a const than two Object.entries()
|
|
1190
1217
|
const members = Object.entries(cmpMeta.$members$);
|
|
1191
|
-
const prototype = Cstr.prototype;
|
|
1192
1218
|
members.map(([memberName, [memberFlags]]) => {
|
|
1193
1219
|
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1194
1220
|
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
@@ -1211,6 +1237,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1211
1237
|
const attrNameToPropName = new Map();
|
|
1212
1238
|
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
|
1213
1239
|
plt.jmp(() => {
|
|
1240
|
+
var _a;
|
|
1214
1241
|
const propName = attrNameToPropName.get(attrName);
|
|
1215
1242
|
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1216
1243
|
// in the case where an attribute was set inline.
|
|
@@ -1266,11 +1293,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1266
1293
|
// 1. The instance is ready
|
|
1267
1294
|
// 2. The watchers are ready
|
|
1268
1295
|
// 3. The value has changed
|
|
1269
|
-
if (
|
|
1296
|
+
if (flags &&
|
|
1297
|
+
!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
|
1270
1298
|
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
|
1271
1299
|
newValue !== oldValue) {
|
|
1272
1300
|
const instance = hostRef.$lazyInstance$ ;
|
|
1273
|
-
const entry = cmpMeta.$watchers$[attrName];
|
|
1301
|
+
const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
|
|
1274
1302
|
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
|
1275
1303
|
if (instance[callbackName] != null) {
|
|
1276
1304
|
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
@@ -1460,12 +1488,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1460
1488
|
const customElements = win.customElements;
|
|
1461
1489
|
const head = doc.head;
|
|
1462
1490
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1463
|
-
const
|
|
1491
|
+
const dataStyles = /*@__PURE__*/ doc.createElement('style');
|
|
1464
1492
|
const deferredConnectedCallbacks = [];
|
|
1465
1493
|
let appLoadFallback;
|
|
1466
1494
|
let isBootstrapping = true;
|
|
1467
1495
|
Object.assign(plt, options);
|
|
1468
1496
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1497
|
+
let hasSlotRelocation = false;
|
|
1469
1498
|
lazyBundles.map((lazyBundle) => {
|
|
1470
1499
|
lazyBundle[1].map((compactMeta) => {
|
|
1471
1500
|
const cmpMeta = {
|
|
@@ -1474,6 +1503,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1474
1503
|
$members$: compactMeta[2],
|
|
1475
1504
|
$listeners$: compactMeta[3],
|
|
1476
1505
|
};
|
|
1506
|
+
// Check if we are using slots outside the shadow DOM in this component.
|
|
1507
|
+
// We'll use this information later to add styles for `slot-fb` elements
|
|
1508
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
1509
|
+
hasSlotRelocation = true;
|
|
1510
|
+
}
|
|
1477
1511
|
{
|
|
1478
1512
|
cmpMeta.$members$ = compactMeta[2];
|
|
1479
1513
|
}
|
|
@@ -1527,15 +1561,25 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1527
1561
|
}
|
|
1528
1562
|
});
|
|
1529
1563
|
});
|
|
1564
|
+
// Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
|
|
1565
|
+
if (hasSlotRelocation) {
|
|
1566
|
+
dataStyles.innerHTML += SLOT_FB_CSS;
|
|
1567
|
+
}
|
|
1568
|
+
// Add hydration styles
|
|
1530
1569
|
{
|
|
1531
|
-
|
|
1532
|
-
|
|
1570
|
+
dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
|
|
1571
|
+
}
|
|
1572
|
+
// If we have styles, add them to the DOM
|
|
1573
|
+
if (dataStyles.innerHTML.length) {
|
|
1574
|
+
dataStyles.setAttribute('data-styles', '');
|
|
1533
1575
|
// Apply CSP nonce to the style tag if it exists
|
|
1534
1576
|
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1535
1577
|
if (nonce != null) {
|
|
1536
|
-
|
|
1578
|
+
dataStyles.setAttribute('nonce', nonce);
|
|
1537
1579
|
}
|
|
1538
|
-
|
|
1580
|
+
// Insert the styles into the document head
|
|
1581
|
+
// NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
|
|
1582
|
+
head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1539
1583
|
}
|
|
1540
1584
|
// Process deferred connectedCallbacks now all components have been registered
|
|
1541
1585
|
isBootstrapping = false;
|
|
@@ -1717,7 +1761,7 @@ const flush = () => {
|
|
|
1717
1761
|
}
|
|
1718
1762
|
}
|
|
1719
1763
|
};
|
|
1720
|
-
const nextTick =
|
|
1764
|
+
const nextTick = (cb) => promiseResolve().then(cb);
|
|
1721
1765
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1722
1766
|
|
|
1723
1767
|
exports.bootstrapLazy = bootstrapLazy;
|
|
@@ -1728,4 +1772,4 @@ exports.promiseResolve = promiseResolve;
|
|
|
1728
1772
|
exports.registerInstance = registerInstance;
|
|
1729
1773
|
exports.setNonce = setNonce;
|
|
1730
1774
|
|
|
1731
|
-
//# sourceMappingURL=index-
|
|
1775
|
+
//# sourceMappingURL=index-4f0a0453.js.map
|