@redneckz/wildless-cms-uni-blocks 0.14.76 → 0.14.78
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/bin/migration-scripts/0.14.68.js +1 -1
- package/bundle/bundle.umd.js +27 -97
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/dist/components/ContentPage/ContentPage.js +0 -2
- package/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/dist/ui-kit/BlockWrapper.js +1 -3
- package/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/lib/components/ContentPage/ContentPage.js +0 -2
- package/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/lib/ui-kit/BlockWrapper.js +1 -3
- package/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +27 -97
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/mobile/dist/components/ContentPage/ContentPage.js +0 -2
- package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js +1 -3
- package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/mobile/lib/components/ContentPage/ContentPage.js +0 -2
- package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js +1 -3
- package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
- package/mobile/src/components/ContentPage/ContentPage.tsx +0 -3
- package/mobile/src/ui-kit/BlockWrapper.tsx +2 -4
- package/package.json +1 -1
- package/src/components/BenefitsBlock/BenefitsBlock.fixture.tsx +3 -3
- package/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
- package/src/components/ContentPage/ContentPage.tsx +0 -3
- package/src/ui-kit/BlockWrapper.tsx +2 -4
- package/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/dist/services/BlockRouter/BlockIntersection.js +0 -2
- package/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/dist/services/BlockRouter/BlockRouter.js +0 -11
- package/dist/services/BlockRouter/BlockRouter.js.map +0 -1
- package/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
- package/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/dist/services/BlockRouter/findActiveBlock.js +0 -15
- package/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
- package/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/lib/services/BlockRouter/BlockIntersection.js +0 -2
- package/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/lib/services/BlockRouter/BlockRouter.js +0 -8
- package/lib/services/BlockRouter/BlockRouter.js.map +0 -1
- package/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
- package/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/lib/services/BlockRouter/findActiveBlock.js +0 -12
- package/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
- package/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/dist/services/BlockRouter/BlockIntersection.js +0 -2
- package/mobile/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/dist/services/BlockRouter/BlockRouter.js +0 -11
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +0 -1
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/mobile/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/dist/services/BlockRouter/findActiveBlock.js +0 -15
- package/mobile/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/lib/services/BlockRouter/BlockIntersection.js +0 -2
- package/mobile/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/lib/services/BlockRouter/BlockRouter.js +0 -8
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +0 -1
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/mobile/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/lib/services/BlockRouter/findActiveBlock.js +0 -12
- package/mobile/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/src/services/BlockRouter/BlockIntersection.ts +0 -3
- package/mobile/src/services/BlockRouter/BlockRouter.ts +0 -11
- package/mobile/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
- package/mobile/src/services/BlockRouter/findActiveBlock.ts +0 -20
- package/mobile/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
- package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
- package/src/services/BlockRouter/BlockIntersection.ts +0 -3
- package/src/services/BlockRouter/BlockRouter.ts +0 -11
- package/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
- package/src/services/BlockRouter/findActiveBlock.ts +0 -20
- package/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
- package/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
2
|
-
|
|
3
|
-
const normalizeAnchor = (anchor?: string) => anchor?.replace('#', '') || '';
|
|
4
|
-
|
|
5
|
-
export function trackBlock(block?: BlockDef) {
|
|
6
|
-
const hash = `#${normalizeAnchor(block?.anchor)}`;
|
|
7
|
-
|
|
8
|
-
if (globalThis.location?.hash !== hash) {
|
|
9
|
-
globalThis.history?.replaceState(globalThis.history?.state, '', hash);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EventBus } from '../../EventBus/EventBus';
|
|
2
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
|
|
4
|
-
export interface BlockIntersectionEvent {
|
|
5
|
-
block: BlockDef;
|
|
6
|
-
intersection: IntersectionObserverEntry;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface EventMap {
|
|
10
|
-
intersection: BlockIntersectionEvent;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const blockRouterEventBus = new EventBus<EventMap>();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
2
|
-
import { minBy } from '../../utils/minBy';
|
|
3
|
-
import { type BlockIntersection } from './BlockIntersection';
|
|
4
|
-
|
|
5
|
-
const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
|
|
6
|
-
const EPS = 0.01;
|
|
7
|
-
|
|
8
|
-
const topLineDelta = ([, { target }]: BlockIntersection) =>
|
|
9
|
-
Math.abs(target.getBoundingClientRect().top);
|
|
10
|
-
|
|
11
|
-
export function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined {
|
|
12
|
-
const visibleIntersections = intersections
|
|
13
|
-
.filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
|
|
14
|
-
.filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
|
|
15
|
-
|
|
16
|
-
const [activeBlock] =
|
|
17
|
-
visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
|
|
18
|
-
|
|
19
|
-
return activeBlock;
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
-
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
|
3
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
4
|
-
import { blockRouterEventBus } from './blockRouterEventBus';
|
|
5
|
-
|
|
6
|
-
export function useBlockIntersectionObserver(block?: BlockDef) {
|
|
7
|
-
const observerCallback = useCallback(
|
|
8
|
-
(entries: IntersectionObserverEntry[]) => {
|
|
9
|
-
if (!block || !entries?.length) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const intersection = entries[entries.length - 1];
|
|
14
|
-
blockRouterEventBus.fire('intersection', { block, intersection });
|
|
15
|
-
},
|
|
16
|
-
[block],
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return useIntersectionObserver(observerCallback, { sensitivity: 1 });
|
|
20
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
import { debounce } from '../../utils/debounce';
|
|
4
|
-
import { trackBlock } from './BlockRouter';
|
|
5
|
-
import { blockRouterEventBus } from './blockRouterEventBus';
|
|
6
|
-
import { findActiveBlock } from './findActiveBlock';
|
|
7
|
-
|
|
8
|
-
const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
|
|
9
|
-
|
|
10
|
-
export function useBlockRouterProvider(scrollTarget: EventTarget = globalThis) {
|
|
11
|
-
const intersectionsMapRef = useRef<Map<BlockDef, IntersectionObserverEntry>>(new Map());
|
|
12
|
-
|
|
13
|
-
useEffect(
|
|
14
|
-
() =>
|
|
15
|
-
blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
|
|
16
|
-
if (intersectionsMapRef.current) {
|
|
17
|
-
intersectionsMapRef.current.set(block, intersection);
|
|
18
|
-
}
|
|
19
|
-
}),
|
|
20
|
-
[],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const handleScroll = debounce(() => {
|
|
25
|
-
trackBlock(
|
|
26
|
-
isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined,
|
|
27
|
-
);
|
|
28
|
-
}, 100);
|
|
29
|
-
|
|
30
|
-
scrollTarget.addEventListener('scroll', handleScroll);
|
|
31
|
-
|
|
32
|
-
return () => {
|
|
33
|
-
handleScroll.dispose();
|
|
34
|
-
scrollTarget.removeEventListener('scroll', handleScroll);
|
|
35
|
-
};
|
|
36
|
-
}, [scrollTarget]);
|
|
37
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
2
|
-
|
|
3
|
-
const normalizeAnchor = (anchor?: string) => anchor?.replace('#', '') || '';
|
|
4
|
-
|
|
5
|
-
export function trackBlock(block?: BlockDef) {
|
|
6
|
-
const hash = `#${normalizeAnchor(block?.anchor)}`;
|
|
7
|
-
|
|
8
|
-
if (globalThis.location?.hash !== hash) {
|
|
9
|
-
globalThis.history?.replaceState(globalThis.history?.state, '', hash);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EventBus } from '../../EventBus/EventBus';
|
|
2
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
|
|
4
|
-
export interface BlockIntersectionEvent {
|
|
5
|
-
block: BlockDef;
|
|
6
|
-
intersection: IntersectionObserverEntry;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface EventMap {
|
|
10
|
-
intersection: BlockIntersectionEvent;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const blockRouterEventBus = new EventBus<EventMap>();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
2
|
-
import { minBy } from '../../utils/minBy';
|
|
3
|
-
import { type BlockIntersection } from './BlockIntersection';
|
|
4
|
-
|
|
5
|
-
const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
|
|
6
|
-
const EPS = 0.01;
|
|
7
|
-
|
|
8
|
-
const topLineDelta = ([, { target }]: BlockIntersection) =>
|
|
9
|
-
Math.abs(target.getBoundingClientRect().top);
|
|
10
|
-
|
|
11
|
-
export function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined {
|
|
12
|
-
const visibleIntersections = intersections
|
|
13
|
-
.filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
|
|
14
|
-
.filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
|
|
15
|
-
|
|
16
|
-
const [activeBlock] =
|
|
17
|
-
visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
|
|
18
|
-
|
|
19
|
-
return activeBlock;
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
-
import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
|
|
3
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
4
|
-
import { blockRouterEventBus } from './blockRouterEventBus';
|
|
5
|
-
|
|
6
|
-
export function useBlockIntersectionObserver(block?: BlockDef) {
|
|
7
|
-
const observerCallback = useCallback(
|
|
8
|
-
(entries: IntersectionObserverEntry[]) => {
|
|
9
|
-
if (!block || !entries?.length) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const intersection = entries[entries.length - 1];
|
|
14
|
-
blockRouterEventBus.fire('intersection', { block, intersection });
|
|
15
|
-
},
|
|
16
|
-
[block],
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return useIntersectionObserver(observerCallback, { sensitivity: 1 });
|
|
20
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
-
import { type BlockDef } from '../../model/ContentPageDef';
|
|
3
|
-
import { debounce } from '../../utils/debounce';
|
|
4
|
-
import { trackBlock } from './BlockRouter';
|
|
5
|
-
import { blockRouterEventBus } from './blockRouterEventBus';
|
|
6
|
-
import { findActiveBlock } from './findActiveBlock';
|
|
7
|
-
|
|
8
|
-
const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
|
|
9
|
-
|
|
10
|
-
export function useBlockRouterProvider(scrollTarget: EventTarget = globalThis) {
|
|
11
|
-
const intersectionsMapRef = useRef<Map<BlockDef, IntersectionObserverEntry>>(new Map());
|
|
12
|
-
|
|
13
|
-
useEffect(
|
|
14
|
-
() =>
|
|
15
|
-
blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
|
|
16
|
-
if (intersectionsMapRef.current) {
|
|
17
|
-
intersectionsMapRef.current.set(block, intersection);
|
|
18
|
-
}
|
|
19
|
-
}),
|
|
20
|
-
[],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const handleScroll = debounce(() => {
|
|
25
|
-
trackBlock(
|
|
26
|
-
isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined,
|
|
27
|
-
);
|
|
28
|
-
}, 100);
|
|
29
|
-
|
|
30
|
-
scrollTarget.addEventListener('scroll', handleScroll);
|
|
31
|
-
|
|
32
|
-
return () => {
|
|
33
|
-
handleScroll.dispose();
|
|
34
|
-
scrollTarget.removeEventListener('scroll', handleScroll);
|
|
35
|
-
};
|
|
36
|
-
}, [scrollTarget]);
|
|
37
|
-
}
|