@redneckz/wildless-cms-uni-blocks 0.8.10 → 0.8.12
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/bundle/bundle.umd.js +79 -93
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/bundle/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/bundle/utils/adjustHref.d.ts +3 -0
- package/bundle/utils/dirname.d.ts +1 -0
- package/bundle/utils/url.d.ts +2 -2
- package/dist/ProjectSettings.js +3 -4
- package/dist/ProjectSettings.js.map +1 -1
- package/dist/hooks/useLink.js +4 -16
- package/dist/hooks/useLink.js.map +1 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/dist/services/BlockRouter/BlockRouter.js +6 -9
- package/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.js +2 -10
- package/dist/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/dist/setup-fixture.js +3 -4
- package/dist/setup-fixture.js.map +1 -1
- package/dist/ui-kit/BlockWrapper.js +3 -2
- package/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/dist/ui-kit/Icon/Icon.js +5 -1
- package/dist/ui-kit/Icon/Icon.js.map +1 -1
- package/dist/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/dist/ui-kit/Img/ImgAsPicture.js +18 -21
- package/dist/ui-kit/Img/ImgAsPicture.js.map +1 -1
- package/dist/utils/adjustHref.d.ts +3 -0
- package/dist/utils/adjustHref.js +14 -0
- package/dist/utils/adjustHref.js.map +1 -0
- package/dist/utils/dirname.d.ts +1 -0
- package/dist/utils/dirname.js +5 -0
- package/dist/utils/dirname.js.map +1 -0
- package/dist/utils/url.d.ts +2 -2
- package/dist/utils/url.js +1 -1
- package/dist/utils/url.js.map +1 -1
- package/dist/wlc.json +0 -1
- package/lib/ProjectSettings.js +3 -4
- package/lib/ProjectSettings.js.map +1 -1
- package/lib/hooks/useLink.js +5 -17
- package/lib/hooks/useLink.js.map +1 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/lib/services/BlockRouter/BlockRouter.js +5 -7
- package/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.js +2 -10
- package/lib/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/lib/setup-fixture.js +3 -4
- package/lib/setup-fixture.js.map +1 -1
- package/lib/ui-kit/BlockWrapper.js +3 -2
- package/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/lib/ui-kit/Icon/Icon.js +5 -1
- package/lib/ui-kit/Icon/Icon.js.map +1 -1
- package/lib/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/lib/ui-kit/Img/ImgAsPicture.js +17 -19
- package/lib/ui-kit/Img/ImgAsPicture.js.map +1 -1
- package/lib/utils/adjustHref.d.ts +3 -0
- package/lib/utils/adjustHref.js +11 -0
- package/lib/utils/adjustHref.js.map +1 -0
- package/lib/utils/dirname.d.ts +1 -0
- package/lib/utils/dirname.js +2 -0
- package/lib/utils/dirname.js.map +1 -0
- package/lib/utils/url.d.ts +2 -2
- package/lib/utils/url.js +1 -1
- package/lib/utils/url.js.map +1 -1
- package/lib/wlc.json +0 -1
- package/mobile/bundle/bundle.umd.js +79 -93
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/mobile/bundle/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/mobile/bundle/utils/adjustHref.d.ts +3 -0
- package/mobile/bundle/utils/dirname.d.ts +1 -0
- package/mobile/bundle/utils/url.d.ts +2 -2
- package/mobile/dist/ProjectSettings.js +3 -4
- package/mobile/dist/ProjectSettings.js.map +1 -1
- package/mobile/dist/hooks/useLink.js +4 -16
- package/mobile/dist/hooks/useLink.js.map +1 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/mobile/dist/services/BlockRouter/BlockRouter.js +6 -9
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +2 -10
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/mobile/dist/setup-fixture.js +3 -4
- package/mobile/dist/setup-fixture.js.map +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js +3 -2
- package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/dist/ui-kit/Icon/Icon.js +5 -1
- package/mobile/dist/ui-kit/Icon/Icon.js.map +1 -1
- package/mobile/dist/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/mobile/dist/ui-kit/Img/ImgAsPicture.js +18 -21
- package/mobile/dist/ui-kit/Img/ImgAsPicture.js.map +1 -1
- package/mobile/dist/utils/adjustHref.d.ts +3 -0
- package/mobile/dist/utils/adjustHref.js +14 -0
- package/mobile/dist/utils/adjustHref.js.map +1 -0
- package/mobile/dist/utils/dirname.d.ts +1 -0
- package/mobile/dist/utils/dirname.js +5 -0
- package/mobile/dist/utils/dirname.js.map +1 -0
- package/mobile/dist/utils/url.d.ts +2 -2
- package/mobile/dist/utils/url.js +1 -1
- package/mobile/dist/utils/url.js.map +1 -1
- package/mobile/dist/wlc.json +0 -1
- package/mobile/lib/ProjectSettings.js +3 -4
- package/mobile/lib/ProjectSettings.js.map +1 -1
- package/mobile/lib/hooks/useLink.js +5 -17
- package/mobile/lib/hooks/useLink.js.map +1 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +1 -3
- package/mobile/lib/services/BlockRouter/BlockRouter.js +5 -7
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +1 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +2 -10
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +1 -1
- package/mobile/lib/setup-fixture.js +3 -4
- package/mobile/lib/setup-fixture.js.map +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js +3 -2
- package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/lib/ui-kit/Icon/Icon.js +5 -1
- package/mobile/lib/ui-kit/Icon/Icon.js.map +1 -1
- package/mobile/lib/ui-kit/Img/ImgAsPicture.d.ts +0 -2
- package/mobile/lib/ui-kit/Img/ImgAsPicture.js +17 -19
- package/mobile/lib/ui-kit/Img/ImgAsPicture.js.map +1 -1
- package/mobile/lib/utils/adjustHref.d.ts +3 -0
- package/mobile/lib/utils/adjustHref.js +11 -0
- package/mobile/lib/utils/adjustHref.js.map +1 -0
- package/mobile/lib/utils/dirname.d.ts +1 -0
- package/mobile/lib/utils/dirname.js +2 -0
- package/mobile/lib/utils/dirname.js.map +1 -0
- package/mobile/lib/utils/url.d.ts +2 -2
- package/mobile/lib/utils/url.js +1 -1
- package/mobile/lib/utils/url.js.map +1 -1
- package/mobile/lib/wlc.json +0 -1
- package/mobile/src/ProjectSettings.ts +4 -4
- package/mobile/src/hooks/useLink.ts +5 -18
- package/mobile/src/services/BlockRouter/BlockRouter.ts +5 -8
- package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +4 -10
- package/mobile/src/setup-fixture.ts +5 -4
- package/mobile/src/ui-kit/BlockWrapper.tsx +3 -2
- package/mobile/src/ui-kit/Icon/Icon.tsx +5 -1
- package/mobile/src/ui-kit/Img/ImgAsPicture.tsx +23 -28
- package/mobile/src/utils/adjustHref.ts +17 -0
- package/mobile/src/utils/dirname.ts +1 -0
- package/mobile/src/utils/url.ts +2 -3
- package/mobile/src/wlc.json +0 -1
- package/package.json +1 -1
- package/src/ProjectSettings.ts +4 -4
- package/src/hooks/useLink.ts +5 -18
- package/src/services/BlockRouter/BlockRouter.ts +5 -8
- package/src/services/BlockRouter/useBlockRouterProvider.ts +4 -10
- package/src/setup-fixture.ts +5 -4
- package/src/ui-kit/BlockWrapper.tsx +3 -2
- package/src/ui-kit/Icon/Icon.tsx +5 -1
- package/src/ui-kit/Img/ImgAsPicture.tsx +23 -28
- package/src/utils/adjustHref.ts +17 -0
- package/src/utils/dirname.ts +1 -0
- package/src/utils/url.ts +2 -3
- package/src/wlc.json +0 -1
package/bundle/bundle.umd.js
CHANGED
|
@@ -81,12 +81,10 @@
|
|
|
81
81
|
return this._.FOOTER;
|
|
82
82
|
}
|
|
83
83
|
get CDN() {
|
|
84
|
-
return this._.CDN;
|
|
84
|
+
return appendSlash(this._.CDN);
|
|
85
85
|
}
|
|
86
86
|
get BASE_PATH() {
|
|
87
|
-
return this._.BASE_PATH
|
|
88
|
-
? `${this._.BASE_PATH}/`
|
|
89
|
-
: this._.BASE_PATH;
|
|
87
|
+
return appendSlash(this._.BASE_PATH);
|
|
90
88
|
}
|
|
91
89
|
get YANDEX_MAP_API_KEY() {
|
|
92
90
|
return this._.YANDEX_MAP_API_KEY;
|
|
@@ -95,6 +93,7 @@
|
|
|
95
93
|
return this._.YANDEX_METRIKA_ID;
|
|
96
94
|
}
|
|
97
95
|
})();
|
|
96
|
+
const appendSlash = (url) => (url && !url.endsWith('/') ? `${url}/` : url);
|
|
98
97
|
|
|
99
98
|
const AUTH_PREFIX = 'guest';
|
|
100
99
|
const STORAGE_KEY = 'likesToken';
|
|
@@ -369,8 +368,9 @@
|
|
|
369
368
|
const [isVisible, setVisible] = useState(true);
|
|
370
369
|
useEffect(() => defaultEventBus.subscribe('tab', (event) => {
|
|
371
370
|
if (event.type === 'group') {
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
setVisible(!block?.labels?.length ||
|
|
372
|
+
!event.label ||
|
|
373
|
+
Boolean(block?.labels?.includes(event.label)));
|
|
374
374
|
}
|
|
375
375
|
else {
|
|
376
376
|
setVisible(true);
|
|
@@ -419,6 +419,49 @@
|
|
|
419
419
|
return (jsx("div", { ref: containerRef, className: `transition-max-h duration-300 overflow-hidden ${containerRef.current || !isUnfolded ? 'max-h-0' : ''} ${className}`, children: children }));
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
+
function useRouter() {
|
|
423
|
+
return useRouter._impl();
|
|
424
|
+
}
|
|
425
|
+
useRouter._impl = () => ({
|
|
426
|
+
href: globalThis.location?.href || '/',
|
|
427
|
+
pathname: globalThis.location?.pathname || '/',
|
|
428
|
+
query: {},
|
|
429
|
+
push: () => {
|
|
430
|
+
// Do nothing
|
|
431
|
+
},
|
|
432
|
+
replace: () => {
|
|
433
|
+
// Do nothing
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
useRouter.setup = (impl) => {
|
|
437
|
+
useRouter._impl = impl;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const dirname = (path) => path?.split('/').slice(0, -1).join('/');
|
|
441
|
+
|
|
442
|
+
const isURL = (href) => Boolean(href?.includes(':'));
|
|
443
|
+
const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
444
|
+
const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
445
|
+
const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
446
|
+
const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
447
|
+
|
|
448
|
+
var url = /*#__PURE__*/Object.freeze({
|
|
449
|
+
__proto__: null,
|
|
450
|
+
isURL: isURL,
|
|
451
|
+
isLocalURL: isLocalURL,
|
|
452
|
+
isHash: isHash,
|
|
453
|
+
withoutQuery: withoutQuery,
|
|
454
|
+
joinPath: joinPath
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const adjustHref = (router) => (href) => {
|
|
458
|
+
if (!href || isURL(href) || (projectSettings.CDN && href.startsWith(projectSettings.CDN))) {
|
|
459
|
+
return href;
|
|
460
|
+
}
|
|
461
|
+
const isRelativeToBase = href.startsWith('/');
|
|
462
|
+
return joinPath(projectSettings.BASE_PATH, isRelativeToBase ? '/' : dirname(router.pathname), href);
|
|
463
|
+
};
|
|
464
|
+
|
|
422
465
|
const svgUseStyleMap = {
|
|
423
466
|
normal: '',
|
|
424
467
|
color: 'text-primary-main',
|
|
@@ -426,7 +469,8 @@
|
|
|
426
469
|
white: 'text-black',
|
|
427
470
|
};
|
|
428
471
|
const Icon = JSX(({ className = '', imageClassName = '', name = '', alt = `Иконка ${name}`, title = alt, iconVersion = 'color', asSVG, ...imgProps }) => {
|
|
429
|
-
const
|
|
472
|
+
const router = useRouter();
|
|
473
|
+
const href = adjustHref(router)(joinPath(projectSettings.CDN, '/icons', `${name}.svg`));
|
|
430
474
|
if (asSVG && iconVersion !== 'normal') {
|
|
431
475
|
return (jsx(Background, { className: className, children: jsxs("svg", { className: style(getSvgSize(imgProps.width), svgUseStyleMap[iconVersion], iconVersion === 'white' ? 'invert' : '', imageClassName), ...imgProps, "aria-hidden": "true", children: [title ? jsx("title", { children: title }) : null, alt ? jsx("desc", { children: alt }) : null, jsx("use", { href: `${href}#icon`, xlinkHref: `${href}#icon` })] }) }));
|
|
432
476
|
}
|
|
@@ -435,22 +479,18 @@
|
|
|
435
479
|
const getSvgSize = (width) => (width ? '' : 'w-full h-full');
|
|
436
480
|
const Background = JSX(({ className, children }) => className ? jsx("div", { className: className, children: children }) : children);
|
|
437
481
|
|
|
438
|
-
const sourcesComparator = (a, b) =>
|
|
439
|
-
if (a.media && b.media) {
|
|
440
|
-
return a.media - b.media;
|
|
441
|
-
}
|
|
442
|
-
return 0;
|
|
443
|
-
};
|
|
482
|
+
const sourcesComparator = (a, b) => a?.media && b?.media ? a.media - b.media : 0;
|
|
444
483
|
const ImgAsPicture = JSX(({ className = '', image, imageClassName = '', isMobile = false, pathPrefix }) => {
|
|
445
|
-
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
484
|
+
const router = useRouter();
|
|
448
485
|
const pictureStyles = isMobile ? 'flex' : 'flex-none';
|
|
449
486
|
return (jsxs("picture", { className: `${pictureStyles} ${className}`, children: [image?.sources?.length
|
|
450
487
|
? image.sources
|
|
488
|
+
.filter((_) => _?.src)
|
|
451
489
|
.sort(sourcesComparator)
|
|
452
|
-
.map(({ src, format, media }, index) => (jsx("source", { srcSet:
|
|
453
|
-
: null,
|
|
490
|
+
.map(({ src, format, media }, index) => (jsx("source", { srcSet: adjustSrcset(router, pathPrefix)(src), type: formatToMimeType(format), media: media ? `(max-width: ${media}px)` : '', ...image.size }, `${index}_${src}`)))
|
|
491
|
+
: null, image?.src
|
|
492
|
+
? renderImg({ ...image, src: adjustSrcset(router, pathPrefix)(image.src) }, imageClassName, isMobile)
|
|
493
|
+
: null] }));
|
|
454
494
|
});
|
|
455
495
|
const renderImg = (image, imageClassName = '', isMobile = false) => {
|
|
456
496
|
const style = {
|
|
@@ -462,15 +502,14 @@
|
|
|
462
502
|
const imgStyle = isMobile ? 'm-auto' : 'm-0';
|
|
463
503
|
return (jsx("img", { src: image.src, className: `${imgStyle} ${imageClassName}`, alt: alt, title: title, style: style, ...image.size }));
|
|
464
504
|
};
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
.map((src) =>
|
|
505
|
+
const adjustSrcset = (router, pathPrefix) => (srcset) => srcset
|
|
506
|
+
?.split(/\s*,\s*/)
|
|
507
|
+
.map((src) => src.trim())
|
|
508
|
+
.filter(Boolean)
|
|
509
|
+
.map((src) => (isURL(src) ? src : joinPath(pathPrefix, src)))
|
|
510
|
+
.map(adjustHref(router))
|
|
470
511
|
.join(', ');
|
|
471
|
-
|
|
472
|
-
return format ? `image/${String(format)}` : undefined;
|
|
473
|
-
}
|
|
512
|
+
const formatToMimeType = (format) => format ? `image/${String(format)}` : undefined;
|
|
474
513
|
|
|
475
514
|
const ImgInner = JSX(({ className = '', image, imageClassName = '', isMobile, pathPrefix, ...iconProps }) => {
|
|
476
515
|
if (!image?.src && !image?.icon) {
|
|
@@ -614,31 +653,6 @@
|
|
|
614
653
|
},
|
|
615
654
|
];
|
|
616
655
|
|
|
617
|
-
const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
|
|
618
|
-
function gotoBlock(router, anchor) {
|
|
619
|
-
router.replace(`#${normalizeAnchor(anchor)}`);
|
|
620
|
-
}
|
|
621
|
-
function trackBlock(router, block) {
|
|
622
|
-
router.replace(`#${normalizeAnchor(block?.anchor)}`, undefined, {
|
|
623
|
-
scroll: false,
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
const isURL = (href) => Boolean(href?.includes('//'));
|
|
628
|
-
const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
629
|
-
const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
630
|
-
const withoutQuery = (href) => (href || '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
631
|
-
const joinPath = (...path) => path.filter(Boolean).join('/').replace(/\/+/g, '/');
|
|
632
|
-
|
|
633
|
-
var url = /*#__PURE__*/Object.freeze({
|
|
634
|
-
__proto__: null,
|
|
635
|
-
isURL: isURL,
|
|
636
|
-
isLocalURL: isLocalURL,
|
|
637
|
-
isHash: isHash,
|
|
638
|
-
withoutQuery: withoutQuery,
|
|
639
|
-
joinPath: joinPath
|
|
640
|
-
});
|
|
641
|
-
|
|
642
656
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
643
657
|
const handlerDecorator = (handler, targetContent) => {
|
|
644
658
|
return handlerDecorator._impl(handler, targetContent);
|
|
@@ -648,53 +662,24 @@
|
|
|
648
662
|
handlerDecorator._impl = impl;
|
|
649
663
|
};
|
|
650
664
|
|
|
651
|
-
function useRouter() {
|
|
652
|
-
return useRouter._impl();
|
|
653
|
-
}
|
|
654
|
-
useRouter._impl = () => ({
|
|
655
|
-
href: globalThis.location?.href || '/',
|
|
656
|
-
pathname: globalThis.location?.pathname || '/',
|
|
657
|
-
query: {},
|
|
658
|
-
push: () => {
|
|
659
|
-
// Do nothing
|
|
660
|
-
},
|
|
661
|
-
replace: () => {
|
|
662
|
-
// Do nothing
|
|
663
|
-
},
|
|
664
|
-
});
|
|
665
|
-
useRouter.setup = (impl) => {
|
|
666
|
-
useRouter._impl = impl;
|
|
667
|
-
};
|
|
668
|
-
|
|
669
665
|
function useLink(isRemote) {
|
|
670
666
|
const router = useRouter();
|
|
671
667
|
return (props) => ({
|
|
672
668
|
...props,
|
|
673
|
-
href: adjustHref(props.href),
|
|
669
|
+
href: isRemote ? props.href : adjustHref(router)(props.href),
|
|
674
670
|
'aria-label': props.text,
|
|
675
671
|
onClick: handlerDecorator(handleHref(props), props),
|
|
676
672
|
});
|
|
677
|
-
function adjustHref(href) {
|
|
678
|
-
const isRelativeToBase = !isRemote && href?.startsWith('/');
|
|
679
|
-
return projectSettings.BASE_PATH && href && isRelativeToBase
|
|
680
|
-
? joinPath(projectSettings.BASE_PATH, href)
|
|
681
|
-
: href;
|
|
682
|
-
}
|
|
683
673
|
function handleHref({ href, target, onClick }) {
|
|
684
674
|
return (ev) => {
|
|
685
675
|
onClick && onClick(ev);
|
|
686
|
-
if (isRemote || !isLocalURL(href, target)) {
|
|
676
|
+
if (!href || isRemote || !isLocalURL(href, target)) {
|
|
687
677
|
// Default routing
|
|
688
678
|
return;
|
|
689
679
|
}
|
|
690
680
|
// Client routing
|
|
691
681
|
ev?.preventDefault();
|
|
692
|
-
|
|
693
|
-
gotoBlock(router, href);
|
|
694
|
-
}
|
|
695
|
-
else if (href) {
|
|
696
|
-
router.push(href);
|
|
697
|
-
}
|
|
682
|
+
router.push(href);
|
|
698
683
|
};
|
|
699
684
|
}
|
|
700
685
|
}
|
|
@@ -4449,6 +4434,14 @@
|
|
|
4449
4434
|
return debouncedCallback;
|
|
4450
4435
|
};
|
|
4451
4436
|
|
|
4437
|
+
const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
|
|
4438
|
+
function trackBlock(block) {
|
|
4439
|
+
const hash = `#${normalizeAnchor(block?.anchor)}`;
|
|
4440
|
+
if (globalThis.location?.hash !== hash) {
|
|
4441
|
+
globalThis.history?.replaceState(globalThis.history?.state, '', hash);
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
4444
|
+
|
|
4452
4445
|
const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
|
|
4453
4446
|
const EPS = 0.01;
|
|
4454
4447
|
const topLineDelta = ([, { target }]) => Math.abs(target.getBoundingClientRect().top);
|
|
@@ -4462,7 +4455,6 @@
|
|
|
4462
4455
|
|
|
4463
4456
|
const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
|
|
4464
4457
|
function useBlockRouterProvider(scrollTarget = globalThis) {
|
|
4465
|
-
const router = useRouter();
|
|
4466
4458
|
const intersectionsMapRef = useRef(new Map());
|
|
4467
4459
|
useEffect(() => blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
|
|
4468
4460
|
if (intersectionsMapRef.current) {
|
|
@@ -4471,20 +4463,14 @@
|
|
|
4471
4463
|
}), []);
|
|
4472
4464
|
useEffect(() => {
|
|
4473
4465
|
const handleScroll = debounce(() => {
|
|
4474
|
-
|
|
4475
|
-
const activeBlock = findActiveBlock([...(intersectionsMapRef.current || [])]);
|
|
4476
|
-
trackBlock(router, activeBlock);
|
|
4477
|
-
}
|
|
4478
|
-
else {
|
|
4479
|
-
trackBlock(router);
|
|
4480
|
-
}
|
|
4466
|
+
trackBlock(isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined);
|
|
4481
4467
|
}, 100);
|
|
4482
4468
|
scrollTarget.addEventListener('scroll', handleScroll);
|
|
4483
4469
|
return () => {
|
|
4484
4470
|
handleScroll.dispose();
|
|
4485
4471
|
scrollTarget.removeEventListener('scroll', handleScroll);
|
|
4486
4472
|
};
|
|
4487
|
-
}, [
|
|
4473
|
+
}, [scrollTarget]);
|
|
4488
4474
|
}
|
|
4489
4475
|
|
|
4490
4476
|
const api = LikeAPI();
|
|
@@ -4555,7 +4541,7 @@
|
|
|
4555
4541
|
return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
|
|
4556
4542
|
}
|
|
4557
4543
|
|
|
4558
|
-
const packageVersion = "0.8.
|
|
4544
|
+
const packageVersion = "0.8.12";
|
|
4559
4545
|
|
|
4560
4546
|
exports.Blocks = Blocks;
|
|
4561
4547
|
exports.ContentPage = ContentPage;
|