@redneckz/wildless-cms-uni-blocks 0.6.49 → 0.7.1
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/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +71 -19
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/bundle/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/bundle/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/bundle/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/bundle/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/bundle/icons/IconName.d.ts +4 -2
- package/bundle/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/bundle/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/bundle/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/bundle/utils/style.d.ts +1 -0
- package/cosmos-static/icons/ArrowRightIcon.svg +1 -1
- package/cosmos-static/icons/ArrowTopRightIcon.svg +1 -0
- package/dist/components/Blocks.js +2 -0
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/CarouselCard/CarouselCard.js +2 -2
- package/dist/components/CarouselCard/CarouselCard.js.map +1 -1
- package/dist/components/CarouselProgramsCard/CarouselProgramsCard.js +1 -1
- package/dist/components/CarouselProgramsCard/CarouselProgramsCard.js.map +1 -1
- package/dist/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -9
- package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/dist/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/dist/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlock.js +14 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlock.js.map +1 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.js +2 -0
- package/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.js.map +1 -0
- package/dist/icons/IconName.d.ts +4 -2
- package/dist/icons/IconName.js +2 -0
- package/dist/icons/IconName.js.map +1 -1
- package/dist/ui-kit/BlockWrapper.js +1 -1
- package/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/dist/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/dist/ui-kit/SwipeListControl/SwipeListContainer.js +8 -5
- package/dist/ui-kit/SwipeListControl/SwipeListContainer.js.map +1 -1
- package/dist/ui-kit/SwipeListControl/SwipeListControl.js +3 -2
- package/dist/ui-kit/SwipeListControl/SwipeListControl.js.map +1 -1
- package/dist/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/dist/ui-kit/SwipeListControl/SwipeListControlDots.js +12 -3
- package/dist/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
- package/dist/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/dist/utils/style.d.ts +1 -0
- package/dist/utils/style.js +5 -0
- package/dist/utils/style.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/Blocks.js +2 -0
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/CarouselCard/CarouselCard.js +2 -2
- package/lib/components/CarouselCard/CarouselCard.js.map +1 -1
- package/lib/components/CarouselProgramsCard/CarouselProgramsCard.js +1 -1
- package/lib/components/CarouselProgramsCard/CarouselProgramsCard.js.map +1 -1
- package/lib/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -9
- package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/lib/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/lib/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlock.fixture.d.ts +5 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlock.js +12 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlock.js.map +1 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.js +2 -0
- package/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.js.map +1 -0
- package/lib/icons/IconName.d.ts +4 -2
- package/lib/icons/IconName.js +2 -0
- package/lib/icons/IconName.js.map +1 -1
- package/lib/ui-kit/BlockWrapper.js +1 -1
- package/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/lib/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/lib/ui-kit/SwipeListControl/SwipeListContainer.js +8 -5
- package/lib/ui-kit/SwipeListControl/SwipeListContainer.js.map +1 -1
- package/lib/ui-kit/SwipeListControl/SwipeListControl.fixture.mobile.d.ts +1 -0
- package/lib/ui-kit/SwipeListControl/SwipeListControl.js +3 -2
- package/lib/ui-kit/SwipeListControl/SwipeListControl.js.map +1 -1
- package/lib/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/lib/ui-kit/SwipeListControl/SwipeListControlDots.js +12 -3
- package/lib/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
- package/lib/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/lib/utils/style.d.ts +1 -0
- package/lib/utils/style.js +2 -0
- package/lib/utils/style.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +25 -12
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/mobile/bundle/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/mobile/bundle/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/mobile/bundle/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/mobile/bundle/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/mobile/bundle/icons/IconName.d.ts +4 -2
- package/mobile/bundle/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/mobile/bundle/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/mobile/bundle/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/mobile/bundle/utils/style.d.ts +1 -0
- package/mobile/dist/components/CarouselCard/CarouselCard.js +2 -2
- package/mobile/dist/components/CarouselCard/CarouselCard.js.map +1 -1
- package/mobile/dist/components/CarouselProgramsCard/CarouselProgramsCard.js +1 -1
- package/mobile/dist/components/CarouselProgramsCard/CarouselProgramsCard.js.map +1 -1
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -9
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/mobile/dist/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlock.js +14 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlock.js.map +1 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.js +2 -0
- package/mobile/dist/components/SwipeListControlBlock/SwipeListControlBlockContent.js.map +1 -0
- package/mobile/dist/icons/IconName.d.ts +4 -2
- package/mobile/dist/icons/IconName.js +2 -0
- package/mobile/dist/icons/IconName.js.map +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListContainer.js +8 -5
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListContainer.js.map +1 -1
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControl.js +3 -2
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControl.js.map +1 -1
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlDots.js +12 -3
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
- package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/mobile/dist/utils/style.d.ts +1 -0
- package/mobile/dist/utils/style.js +5 -0
- package/mobile/dist/utils/style.js.map +1 -0
- package/mobile/lib/components/CarouselCard/CarouselCard.js +2 -2
- package/mobile/lib/components/CarouselCard/CarouselCard.js.map +1 -1
- package/mobile/lib/components/CarouselProgramsCard/CarouselProgramsCard.js +1 -1
- package/mobile/lib/components/CarouselProgramsCard/CarouselProgramsCard.js.map +1 -1
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.d.ts +1 -1
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -9
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCardContent.d.ts +1 -1
- package/mobile/lib/components/LinkDocs/LinkDocsContent.d.ts +4 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlock.d.ts +6 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlock.js +12 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlock.js.map +1 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.d.ts +5 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.js +2 -0
- package/mobile/lib/components/SwipeListControlBlock/SwipeListControlBlockContent.js.map +1 -0
- package/mobile/lib/icons/IconName.d.ts +4 -2
- package/mobile/lib/icons/IconName.js +2 -0
- package/mobile/lib/icons/IconName.js.map +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListContainer.d.ts +2 -1
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListContainer.js +8 -5
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListContainer.js.map +1 -1
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControl.js +3 -2
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControl.js.map +1 -1
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlDots.d.ts +2 -0
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlDots.js +12 -3
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
- package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlProps.d.ts +7 -0
- package/mobile/lib/utils/style.d.ts +1 -0
- package/mobile/lib/utils/style.js +2 -0
- package/mobile/lib/utils/style.js.map +1 -0
- package/mobile/src/common.css +11 -0
- package/mobile/src/components/Carousel/Carousel.ui.json +8 -0
- package/mobile/src/components/CarouselCard/CarouselCard.tsx +11 -5
- package/mobile/src/components/CarouselProgramsCard/CarouselProgramsCard.tsx +1 -1
- package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.example.json +11 -3
- package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +29 -17
- package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCardContent.ts +1 -1
- package/mobile/src/components/LinkDocs/LinkDocsContent.ts +4 -0
- package/mobile/src/components/SwipeListControlBlock/SwipeListControlBlock.example.json +18 -0
- package/mobile/src/components/SwipeListControlBlock/SwipeListControlBlock.tsx +23 -0
- package/mobile/src/components/SwipeListControlBlock/SwipeListControlBlock.ui.json +1 -0
- package/mobile/src/components/SwipeListControlBlock/SwipeListControlBlockContent.ts +6 -0
- package/mobile/src/icons/ArrowRightIcon.svg +1 -1
- package/mobile/src/icons/ArrowTopRightIcon.svg +1 -0
- package/mobile/src/icons/IconName.ts +4 -4
- package/mobile/src/ui-kit/BlockWrapper.tsx +1 -1
- package/mobile/src/ui-kit/SwipeListControl/SwipeListContainer.tsx +19 -10
- package/mobile/src/ui-kit/SwipeListControl/SwipeListControl.tsx +6 -2
- package/mobile/src/ui-kit/SwipeListControl/SwipeListControlDots.tsx +20 -4
- package/mobile/src/ui-kit/SwipeListControl/SwipeListControlProps.ts +8 -0
- package/mobile/src/utils/style.ts +2 -0
- package/package.json +2 -2
- package/src/common.css +11 -0
- package/src/components/Blocks.ts +2 -0
- package/src/components/Carousel/Carousel.ui.json +8 -0
- package/src/components/CarouselCard/CarouselCard.tsx +11 -5
- package/src/components/CarouselProgramsCard/CarouselProgramsCard.tsx +1 -1
- package/src/components/CarouselTariffsCard/CarouselTariffsCard.example.json +11 -3
- package/src/components/CarouselTariffsCard/CarouselTariffsCard.fixture.tsx +3 -3
- package/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +29 -17
- package/src/components/CarouselTariffsCard/CarouselTariffsCardContent.ts +1 -1
- package/src/components/LinkDocs/LinkDocsContent.ts +4 -0
- package/src/components/SwipeListControlBlock/SwipeListControlBlock.example.json +18 -0
- package/src/components/SwipeListControlBlock/SwipeListControlBlock.fixture.tsx +27 -0
- package/src/components/SwipeListControlBlock/SwipeListControlBlock.tsx +23 -0
- package/src/components/SwipeListControlBlock/SwipeListControlBlock.ui.json +1 -0
- package/src/components/SwipeListControlBlock/SwipeListControlBlockContent.ts +6 -0
- package/src/icons/ArrowRightIcon.svg +1 -1
- package/src/icons/ArrowTopRightIcon.svg +1 -0
- package/src/icons/IconName.ts +333 -6
- package/src/ui-kit/BlockWrapper.tsx +1 -1
- package/src/ui-kit/SwipeListControl/SwipeListContainer.tsx +19 -10
- package/src/ui-kit/SwipeListControl/SwipeListControl.fixture.mobile.tsx +6 -1
- package/src/ui-kit/SwipeListControl/SwipeListControl.tsx +6 -2
- package/src/ui-kit/SwipeListControl/SwipeListControlDots.tsx +20 -4
- package/src/ui-kit/SwipeListControl/SwipeListControlProps.ts +8 -0
- package/src/utils/style.ts +2 -0
|
@@ -2,7 +2,8 @@ import { JSX } from '@redneckz/uni-jsx';
|
|
|
2
2
|
import { useCallback, useRef } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import type { IntersectionObserverOptions } from '../../hooks/useIntersectionObserver';
|
|
4
4
|
import { mapChildren } from '../../utils/mapChildren';
|
|
5
|
-
import
|
|
5
|
+
import { style } from '../../utils/style';
|
|
6
|
+
import type { SwipeContainerProps, SwipeListControlType } from './SwipeListControlProps';
|
|
6
7
|
import { SwipeListItem } from './SwipeListItem';
|
|
7
8
|
|
|
8
9
|
type ItemsVisibilityList = Array<IntersectionObserverEntry | undefined>;
|
|
@@ -20,6 +21,7 @@ interface SwipeListContainerProps extends SwipeContainerProps {
|
|
|
20
21
|
snapAlign?: 'snap-start' | 'snap-center' | 'snap-end';
|
|
21
22
|
onVisibleItemsChange?: (itemsVisibilityList: ItemsVisibilityList) => void;
|
|
22
23
|
onVisibleIndicesChange?: (indices: number[]) => void;
|
|
24
|
+
listType?: SwipeListControlType;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const childStyleMap = ['min-w-[100%]', 'min-w-[50%]', 'min-w-[33.33%]', 'min-w-[25%]'];
|
|
@@ -32,6 +34,7 @@ export const SwipeListContainer = JSX<SwipeListContainerProps>(
|
|
|
32
34
|
visibleItemCount = 0,
|
|
33
35
|
gap = 0,
|
|
34
36
|
padding = 0,
|
|
37
|
+
listType = 'horizontal-list',
|
|
35
38
|
snapAlign = 'snap-center',
|
|
36
39
|
children,
|
|
37
40
|
onVisibleItemsChange,
|
|
@@ -54,25 +57,31 @@ export const SwipeListContainer = JSX<SwipeListContainerProps>(
|
|
|
54
57
|
},
|
|
55
58
|
[onVisibleItemsChange, onVisibleIndicesChange],
|
|
56
59
|
);
|
|
60
|
+
|
|
57
61
|
const additionPadding = visibleItemCount > 0 ? gap * Number(visibleItemCount) - 1 : 0;
|
|
58
62
|
|
|
63
|
+
const isHorizontalList = listType === 'horizontal-list';
|
|
64
|
+
const containerStyle = {
|
|
65
|
+
...(isHorizontalList ? getContainerStyle(padding, additionPadding) : {}),
|
|
66
|
+
gap: `${gap}px`,
|
|
67
|
+
};
|
|
68
|
+
|
|
59
69
|
return (
|
|
60
70
|
<div
|
|
61
|
-
className={
|
|
62
|
-
style={
|
|
63
|
-
...getContainerStyle(padding, additionPadding),
|
|
64
|
-
gap: `${gap}px`,
|
|
65
|
-
}}
|
|
71
|
+
className={style('box-border overflow-auto no-scrollbar', listType, className)}
|
|
72
|
+
style={containerStyle}
|
|
66
73
|
role="list"
|
|
67
74
|
ref={containerRef}
|
|
68
75
|
>
|
|
69
76
|
{mapChildren((child, idx) => (
|
|
70
77
|
<SwipeListItem
|
|
71
78
|
key={String(idx)}
|
|
72
|
-
className={
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
className={style(
|
|
80
|
+
snapAlign,
|
|
81
|
+
visibleItemCount ? childStyleMap[visibleItemCount - 1] : '',
|
|
82
|
+
listType === 'vertical-list' ? 'h-full' : '',
|
|
83
|
+
)}
|
|
84
|
+
style={isHorizontalList ? getContainerStyle(padding / 4) : {}}
|
|
76
85
|
activeIndex={activeIndex}
|
|
77
86
|
idx={idx}
|
|
78
87
|
observerOptions={observerOptions}
|
|
@@ -3,7 +3,7 @@ import '../../setup-fixture';
|
|
|
3
3
|
import { SwipeListControl } from './SwipeListControl';
|
|
4
4
|
|
|
5
5
|
const renderElement = (_: any, i: number): VNode => (
|
|
6
|
-
<div key={String(i)} className="border border-gray rounded-md text-center h-
|
|
6
|
+
<div key={String(i)} className="border border-gray rounded-md text-center h-full">
|
|
7
7
|
{`Element #${i}`}
|
|
8
8
|
</div>
|
|
9
9
|
);
|
|
@@ -45,4 +45,9 @@ export default {
|
|
|
45
45
|
<SwipeListControl>string content</SwipeListControl>
|
|
46
46
|
</div>
|
|
47
47
|
),
|
|
48
|
+
vertical: (
|
|
49
|
+
<div className="px-4 py-5 bg-white h-80">
|
|
50
|
+
<SwipeListControl listType="vertical-list">{generateChildren(3)}</SwipeListControl>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
48
53
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { style } from '../../utils/style';
|
|
2
3
|
import { SwipeListContainer } from './SwipeListContainer';
|
|
3
4
|
import { SwipeListControlDots } from './SwipeListControlDots';
|
|
4
5
|
import type { SwipeListControlProps } from './SwipeListControlProps';
|
|
@@ -15,12 +16,13 @@ const DEFAULT_PADDING = 16;
|
|
|
15
16
|
|
|
16
17
|
export const SwipeListControl = JSX<SwipeListControlProps>(
|
|
17
18
|
({
|
|
18
|
-
className,
|
|
19
|
+
className = '',
|
|
19
20
|
gap = DEFAULT_GAP,
|
|
20
21
|
padding = DEFAULT_PADDING,
|
|
21
22
|
showDots = true,
|
|
22
23
|
children,
|
|
23
24
|
onVisibleIndicesChange,
|
|
25
|
+
listType = 'horizontal-list',
|
|
24
26
|
}) => {
|
|
25
27
|
const itemCount = Array.isArray(children) ? children.length : 0;
|
|
26
28
|
|
|
@@ -31,7 +33,7 @@ export const SwipeListControl = JSX<SwipeListControlProps>(
|
|
|
31
33
|
const [activeIndex] = scroll.visibleIndicesRange;
|
|
32
34
|
|
|
33
35
|
return (
|
|
34
|
-
<div className={className}>
|
|
36
|
+
<div className={style(className, listType === 'vertical-list' ? 'relative h-full' : '')}>
|
|
35
37
|
<SwipeListContainer
|
|
36
38
|
containerRef={containerRef}
|
|
37
39
|
activeIndex={activeIndex}
|
|
@@ -39,6 +41,7 @@ export const SwipeListControl = JSX<SwipeListControlProps>(
|
|
|
39
41
|
gap={gap}
|
|
40
42
|
padding={padding}
|
|
41
43
|
onVisibleIndicesChange={scroll.handleVisibleIndicesChange}
|
|
44
|
+
listType={listType}
|
|
42
45
|
>
|
|
43
46
|
{children}
|
|
44
47
|
</SwipeListContainer>
|
|
@@ -47,6 +50,7 @@ export const SwipeListControl = JSX<SwipeListControlProps>(
|
|
|
47
50
|
containerRef={containerRef}
|
|
48
51
|
activeIndex={activeIndex}
|
|
49
52
|
dotCount={itemCount}
|
|
53
|
+
listType={listType}
|
|
50
54
|
/>
|
|
51
55
|
) : null}
|
|
52
56
|
</div>
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { SwipeListControlType } from './SwipeListControlProps';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const containerStyles: Record<SwipeListControlType, string> = {
|
|
5
|
+
'horizontal-list': 'mx-auto mt-5 w-fit',
|
|
6
|
+
'vertical-list': 'absolute flex-col justify-center h-full top-0 left-4',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const activeDotStyles: Record<SwipeListControlType, string> = {
|
|
10
|
+
'horizontal-list': 'w-6',
|
|
11
|
+
'vertical-list': 'h-6',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const dotStyle = 'cursor-pointer bg-primary-main rounded-full transition-width duration-300';
|
|
15
|
+
|
|
16
|
+
const inactiveDotStyle = 'w-2 h-2 opacity-30';
|
|
4
17
|
|
|
5
18
|
interface SwipeListControlDotsProps {
|
|
6
19
|
containerRef?: { current: HTMLDivElement | null };
|
|
7
20
|
activeIndex?: number;
|
|
8
21
|
dotCount?: number;
|
|
22
|
+
listType?: SwipeListControlType;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
export const SwipeListControlDots = JSX<SwipeListControlDotsProps>(
|
|
12
|
-
({ containerRef, activeIndex, dotCount = 0 }) => {
|
|
26
|
+
({ containerRef, activeIndex, dotCount = 0, listType = 'horizontal-list' }) => {
|
|
13
27
|
const handleClick = (idx: number) => {
|
|
14
28
|
if (idx !== activeIndex && containerRef?.current) {
|
|
15
29
|
containerRef.current.children[idx]?.scrollIntoView({
|
|
@@ -20,11 +34,13 @@ export const SwipeListControlDots = JSX<SwipeListControlDotsProps>(
|
|
|
20
34
|
};
|
|
21
35
|
|
|
22
36
|
return dotCount ? (
|
|
23
|
-
<div className=
|
|
37
|
+
<div className={`flex gap-2 ${containerStyles[listType]}`}>
|
|
24
38
|
{new Array(dotCount).fill(null).map((_, idx: number) => (
|
|
25
39
|
<div
|
|
26
40
|
key={String(idx)}
|
|
27
|
-
className={`${dotStyle} ${
|
|
41
|
+
className={`${dotStyle} ${
|
|
42
|
+
idx === activeIndex ? activeDotStyles[listType] : inactiveDotStyle
|
|
43
|
+
}`}
|
|
28
44
|
role="button"
|
|
29
45
|
aria-hidden
|
|
30
46
|
onClick={() => handleClick(idx)}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title Вид
|
|
3
|
+
* @enumNames ["Горизонтальный", "Вертикальный"]
|
|
4
|
+
*/
|
|
5
|
+
export type SwipeListControlType = 'horizontal-list' | 'vertical-list';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* @title Контейнер
|
|
3
9
|
*/
|
|
@@ -15,5 +21,7 @@ export interface SwipeListControlProps extends SwipeContainerProps {
|
|
|
15
21
|
className?: string;
|
|
16
22
|
/** @title Точки-индикаторы */
|
|
17
23
|
showDots?: boolean;
|
|
24
|
+
/** @hidden */
|
|
18
25
|
onVisibleIndicesChange?: (indices: number[]) => void;
|
|
26
|
+
listType?: SwipeListControlType;
|
|
19
27
|
}
|