@net7/boilerplate-muruca 5.5.18 → 5.5.20
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/esm2022/lib/data-sources/facets/facet-map.ds.mjs +17 -10
- package/esm2022/lib/data-sources/parallel-text-viewer.ds.mjs +28 -29
- package/fesm2022/net7-boilerplate-muruca.mjs +43 -37
- package/fesm2022/net7-boilerplate-muruca.mjs.map +1 -1
- package/lib/data-sources/facets/facet-map.ds.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2745,35 +2745,48 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2745
2745
|
// Attacca al primo caricamento
|
|
2746
2746
|
document.addEventListener('pb-end-update', attachListeners);
|
|
2747
2747
|
setTimeout(attachListeners, 500);
|
|
2748
|
-
// Cross-highlight per termini multi-@ana: quando un pb-highlight con key
|
|
2749
|
-
//
|
|
2750
|
-
// per ogni token individuale ("vox2", "vox3") così i termini correlati si evidenziano.
|
|
2748
|
+
// Cross-highlight per termini multi-@ana: quando un pb-highlight con doppia key emette pb-highlight-on
|
|
2749
|
+
// ri-emette pb-highlight-on per ogni token individuale così i termini correlati si evidenziano.
|
|
2751
2750
|
document.addEventListener('pb-highlight-on', (ev) => {
|
|
2752
2751
|
const key = ev.detail?.id;
|
|
2753
2752
|
const channel = ev.detail?.key;
|
|
2754
|
-
if (key
|
|
2753
|
+
if (!key || !channel)
|
|
2754
|
+
return;
|
|
2755
|
+
// Chiave composita (multi-@ana "vox2_vox3", ancore paired "v1a1_v1a2"): spezza e ri-emetti per ogni token su highlight-channel.
|
|
2756
|
+
if (key.includes('_')) {
|
|
2755
2757
|
key.split('_').forEach((token) => {
|
|
2756
2758
|
document.dispatchEvent(new CustomEvent('pb-highlight-on', {
|
|
2757
2759
|
detail: { key: channel, id: token, source: ev.detail.source },
|
|
2758
2760
|
}));
|
|
2759
2761
|
});
|
|
2762
|
+
return;
|
|
2760
2763
|
}
|
|
2764
|
+
if (ev.detail?.source === 'paired-anchor')
|
|
2765
|
+
return;
|
|
2766
|
+
// Token singolo: se corrisponde a un'ancora paired ri-emette con l'id composito del popup per attivarne l'highlight.
|
|
2767
|
+
document.querySelectorAll('[id$="-view"]').forEach((view) => {
|
|
2768
|
+
if (!view.shadowRoot)
|
|
2769
|
+
return;
|
|
2770
|
+
const popup = view.shadowRoot.querySelector(`.tei-app[data-from="${key}"]`)
|
|
2771
|
+
|| view.shadowRoot.querySelector(`.tei-app[data-to="${key}"]`);
|
|
2772
|
+
if (popup && popup.id) {
|
|
2773
|
+
document.dispatchEvent(new CustomEvent('pb-highlight-on', {
|
|
2774
|
+
detail: { key: channel, id: popup.id, source: 'paired-anchor' },
|
|
2775
|
+
}));
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2761
2778
|
});
|
|
2762
2779
|
}
|
|
2763
2780
|
onClick(payload) {
|
|
2764
|
-
// console.log('🔵 onClick chiamato!', payload);
|
|
2765
2781
|
let target = null;
|
|
2766
2782
|
const clickPath = payload.path || payload.composedPath();
|
|
2767
|
-
// console.log('🔵 clickPath:', clickPath);
|
|
2768
2783
|
// chiusura apparato con tasto
|
|
2769
2784
|
const closeButton = clickPath.find((el) => el.className
|
|
2770
2785
|
&& typeof el.className === 'string'
|
|
2771
2786
|
&& el.className.includes('close_app'));
|
|
2772
2787
|
if (closeButton) {
|
|
2773
|
-
// console.log('Click rilevato sul bottone di chiusura:', closeButton);
|
|
2774
2788
|
const parentAppItem = closeButton.closest('.tei-app');
|
|
2775
2789
|
if (parentAppItem && parentAppItem.style) {
|
|
2776
|
-
// console.log('Chiusura dell\'elemento tei-app');
|
|
2777
2790
|
parentAppItem.style.display = 'none';
|
|
2778
2791
|
parentAppItem.style.transform = '';
|
|
2779
2792
|
this.resetHighlights();
|
|
@@ -2792,10 +2805,8 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2792
2805
|
&& typeof el.className === 'string'
|
|
2793
2806
|
&& el.className.includes('close_note'));
|
|
2794
2807
|
if (closeNoteButton) {
|
|
2795
|
-
// console.log('Click rilevato sul bottone di chiusura nota:', closeNoteButton);
|
|
2796
2808
|
const parentNoteItem = closeNoteButton.closest('.note-item');
|
|
2797
2809
|
if (parentNoteItem && parentNoteItem.style) {
|
|
2798
|
-
// console.log('Chiusura dell\'elemento note-item');
|
|
2799
2810
|
parentNoteItem.style.display = 'none';
|
|
2800
2811
|
parentNoteItem.style.transform = '';
|
|
2801
2812
|
this.resetHighlights();
|
|
@@ -2824,12 +2835,16 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2824
2835
|
return;
|
|
2825
2836
|
}
|
|
2826
2837
|
if (view.shadowRoot) {
|
|
2827
|
-
|
|
2838
|
+
// Cerca prima per id esatto; se non trovato, cerca popup per ancora apertura (data-from)
|
|
2839
|
+
// o ancora di chiusura (data-to)
|
|
2840
|
+
const found = view.shadowRoot.querySelector(`[id="${appId}"]`)
|
|
2841
|
+
|| view.shadowRoot.querySelector(`.tei-app[data-from="${appId}"]`)
|
|
2842
|
+
|| view.shadowRoot.querySelector(`.tei-app[data-to="${appId}"]`);
|
|
2828
2843
|
if (found) {
|
|
2829
2844
|
if (!anchorElement) {
|
|
2830
2845
|
anchorElement = found;
|
|
2831
2846
|
}
|
|
2832
|
-
const appElement = found.closest('.tei-app');
|
|
2847
|
+
const appElement = found.closest('.tei-app') || (found.classList.contains('tei-app') ? found : null);
|
|
2833
2848
|
if (appElement && !teiAppElement) {
|
|
2834
2849
|
teiAppElement = appElement;
|
|
2835
2850
|
}
|
|
@@ -2842,18 +2857,6 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2842
2857
|
const nestedCits = target.querySelectorAll('span.quote');
|
|
2843
2858
|
const isOuterCit = nestedCits.length > 0;
|
|
2844
2859
|
const segElements = target.querySelectorAll('.seg-outer-inner');
|
|
2845
|
-
// console.log('[seg-outer-inner] click su:', target.getAttribute('key'), '| isOuterCit:', isOuterCit, '| seg trovati:', segElements.length, '| panel isVisible:', isVisible);
|
|
2846
|
-
// console.log(' nestedCits keys:', Array.from(nestedCits).map((el) => el.getAttribute('key')));
|
|
2847
|
-
// segElements.forEach((el, i) => {
|
|
2848
|
-
// console.log(` seg[${i}] backgroundColor attuale: "${(el as HTMLElement).style.backgroundColor}"`);
|
|
2849
|
-
// let node = (el as HTMLElement).parentElement;
|
|
2850
|
-
// const chain = [];
|
|
2851
|
-
// while (node && chain.length < 6) {
|
|
2852
|
-
// chain.push(`${node.tagName}${node.className ? '.' + node.className.replace(/\s+/g, '.') : ''}${node.getAttribute('key') ? '[key=' + node.getAttribute('key').substring(0, 20) + ']' : ''}`);
|
|
2853
|
-
// node = node.parentElement;
|
|
2854
|
-
// }
|
|
2855
|
-
// console.log(` seg[${i}] ancestors:`, chain.join(' > '));
|
|
2856
|
-
// });
|
|
2857
2860
|
if (isVisible) {
|
|
2858
2861
|
teiAppElement.style.display = 'none';
|
|
2859
2862
|
teiAppElement.style.transform = '';
|
|
@@ -2862,7 +2865,6 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2862
2865
|
// Pannello esterno chiuso: ripristina il background dei seg annidati
|
|
2863
2866
|
segElements.forEach((el) => {
|
|
2864
2867
|
el.style.backgroundColor = '';
|
|
2865
|
-
// console.log(' [outer CLOSE] seg backgroundColor → ""');
|
|
2866
2868
|
});
|
|
2867
2869
|
}
|
|
2868
2870
|
}
|
|
@@ -2880,7 +2882,6 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2880
2882
|
requestAnimationFrame(() => {
|
|
2881
2883
|
segElements.forEach((el) => {
|
|
2882
2884
|
el.style.backgroundColor = 'white';
|
|
2883
|
-
// console.log(' [outer OPEN rAF] seg backgroundColor → "white"');
|
|
2884
2885
|
});
|
|
2885
2886
|
});
|
|
2886
2887
|
}
|
|
@@ -2889,7 +2890,6 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2889
2890
|
requestAnimationFrame(() => {
|
|
2890
2891
|
segElements.forEach((el) => {
|
|
2891
2892
|
el.style.backgroundColor = '';
|
|
2892
|
-
// console.log(' [inner OPEN rAF] seg backgroundColor → ""');
|
|
2893
2893
|
});
|
|
2894
2894
|
});
|
|
2895
2895
|
}
|
|
@@ -2901,7 +2901,6 @@ class MrParallelTextViewerDS extends DataSource {
|
|
|
2901
2901
|
}
|
|
2902
2902
|
else if (target && target.getAttribute('type') === 'note_line') {
|
|
2903
2903
|
const noteId = target.getAttribute('key');
|
|
2904
|
-
// console.log('noteId', noteId);
|
|
2905
2904
|
const clickedElementPosition = target.getBoundingClientRect().top;
|
|
2906
2905
|
const apparatusView = document.querySelector('.n7-text-viewer #apparato-view');
|
|
2907
2906
|
const anchorElement = apparatusView
|
|
@@ -7457,12 +7456,11 @@ class FacetMapDS extends DataSource {
|
|
|
7457
7456
|
};
|
|
7458
7457
|
this.getValue = () => this.value;
|
|
7459
7458
|
}
|
|
7460
|
-
|
|
7459
|
+
linksToMarkers(links) {
|
|
7461
7460
|
const markers = [];
|
|
7462
7461
|
links
|
|
7463
7462
|
.filter((d) => d.args?.lat && d.args?.lon)
|
|
7464
7463
|
.forEach((d) => {
|
|
7465
|
-
// if a link has more than one corresponding marker
|
|
7466
7464
|
if (Array.isArray(d.args.lat)) {
|
|
7467
7465
|
d.args.lat.forEach((element, i) => {
|
|
7468
7466
|
markers.push({
|
|
@@ -7476,7 +7474,6 @@ class FacetMapDS extends DataSource {
|
|
|
7476
7474
|
});
|
|
7477
7475
|
}
|
|
7478
7476
|
else {
|
|
7479
|
-
// if a link has only one marker
|
|
7480
7477
|
markers.push({
|
|
7481
7478
|
coords: [+d.args.lat, +d.args.lon],
|
|
7482
7479
|
template: d.text,
|
|
@@ -7487,6 +7484,10 @@ class FacetMapDS extends DataSource {
|
|
|
7487
7484
|
});
|
|
7488
7485
|
}
|
|
7489
7486
|
});
|
|
7487
|
+
return markers;
|
|
7488
|
+
}
|
|
7489
|
+
transform({ links }) {
|
|
7490
|
+
const markers = this.linksToMarkers(links);
|
|
7490
7491
|
const mapConfig = this.options?.libOptions;
|
|
7491
7492
|
return {
|
|
7492
7493
|
containerId: 'map-canvas',
|
|
@@ -7589,12 +7590,17 @@ class FacetMapDS extends DataSource {
|
|
|
7589
7590
|
}));
|
|
7590
7591
|
// update marker icons
|
|
7591
7592
|
if (this.markerLayer) {
|
|
7592
|
-
this.
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7593
|
+
if (this.options.libOptions?.hideUnavailablePin) {
|
|
7594
|
+
this.buildMarkers(this.linksToMarkers(links));
|
|
7595
|
+
}
|
|
7596
|
+
else {
|
|
7597
|
+
this.markerLayer.eachLayer((marker) => {
|
|
7598
|
+
const { id } = marker;
|
|
7599
|
+
const counter = links.find(({ payload }) => payload === id)?.counter || 0;
|
|
7600
|
+
marker.getPopup()._source.setIcon(this.getIcon(id, counter))
|
|
7601
|
+
.setZIndexOffset(this.getZindex(id, counter));
|
|
7602
|
+
});
|
|
7603
|
+
}
|
|
7598
7604
|
}
|
|
7599
7605
|
// ---
|
|
7600
7606
|
this.update({
|