@amityco/react-native-social-uikit 4.1.0 → 4.1.1-21d3e899.0
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/lib/commonjs/core/assets/icons/xml.js +43 -1
- package/lib/commonjs/core/assets/icons/xml.js.map +1 -1
- package/lib/commonjs/social/components/LoadingImage/index.js +4 -3
- package/lib/commonjs/social/components/LoadingImage/index.js.map +1 -1
- package/lib/commonjs/social/components/LoadingImage/styles.js +4 -0
- package/lib/commonjs/social/components/LoadingImage/styles.js.map +1 -1
- package/lib/commonjs/social/components/LoadingVideo/index.js +12 -6
- package/lib/commonjs/social/components/LoadingVideo/index.js.map +1 -1
- package/lib/commonjs/social/components/LoadingVideo/styles.js +4 -0
- package/lib/commonjs/social/components/LoadingVideo/styles.js.map +1 -1
- package/lib/commonjs/social/components/MediaSelector/MediaSelector.js +164 -0
- package/lib/commonjs/social/components/MediaSelector/MediaSelector.js.map +1 -0
- package/lib/commonjs/social/components/MediaSelector/index.js +13 -0
- package/lib/commonjs/social/components/MediaSelector/index.js.map +1 -0
- package/lib/commonjs/social/components/MediaSelector/styles.js +130 -0
- package/lib/commonjs/social/components/MediaSelector/styles.js.map +1 -0
- package/lib/commonjs/social/components/MediaViewer/MediaViewer.js +134 -0
- package/lib/commonjs/social/components/MediaViewer/MediaViewer.js.map +1 -0
- package/lib/commonjs/social/components/MediaViewer/index.js +13 -0
- package/lib/commonjs/social/components/MediaViewer/index.js.map +1 -0
- package/lib/commonjs/social/components/MediaViewer/styles.js +60 -0
- package/lib/commonjs/social/components/MediaViewer/styles.js.map +1 -0
- package/lib/commonjs/social/components/PostContent/index.js +75 -120
- package/lib/commonjs/social/components/PostContent/index.js.map +1 -1
- package/lib/commonjs/social/components/SelectedMediaComponent/SelectedMediaComponent.js +147 -0
- package/lib/commonjs/social/components/SelectedMediaComponent/SelectedMediaComponent.js.map +1 -0
- package/lib/commonjs/social/components/SelectedMediaComponent/index.js +13 -0
- package/lib/commonjs/social/components/SelectedMediaComponent/index.js.map +1 -0
- package/lib/commonjs/social/components/SelectedMediaComponent/styles.js +43 -0
- package/lib/commonjs/social/components/SelectedMediaComponent/styles.js.map +1 -0
- package/lib/commonjs/social/constants/index.js +11 -0
- package/lib/commonjs/social/constants/index.js.map +1 -0
- package/lib/commonjs/social/elements/PostMediaElement/PostMediaElement.js +244 -0
- package/lib/commonjs/social/elements/PostMediaElement/PostMediaElement.js.map +1 -0
- package/lib/commonjs/social/elements/PostMediaElement/index.js +13 -0
- package/lib/commonjs/social/elements/PostMediaElement/index.js.map +1 -0
- package/lib/commonjs/social/elements/PostMediaElement/styles.js +117 -0
- package/lib/commonjs/social/elements/PostMediaElement/styles.js.map +1 -0
- package/lib/commonjs/social/features/post/Composer/PostComposer.js +57 -91
- package/lib/commonjs/social/features/post/Composer/PostComposer.js.map +1 -1
- package/lib/commonjs/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.js +17 -7
- package/lib/commonjs/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.js.map +1 -1
- package/lib/commonjs/social/features/post/components/MediaAttachment/MediaAttachment.js +17 -7
- package/lib/commonjs/social/features/post/components/MediaAttachment/MediaAttachment.js.map +1 -1
- package/lib/commonjs/social/utils/getFrameRatio.js +52 -0
- package/lib/commonjs/social/utils/getFrameRatio.js.map +1 -0
- package/lib/commonjs/social/utils/getIndicatorConfig.js +59 -0
- package/lib/commonjs/social/utils/getIndicatorConfig.js.map +1 -0
- package/lib/module/core/assets/icons/xml.js +38 -0
- package/lib/module/core/assets/icons/xml.js.map +1 -1
- package/lib/module/social/components/LoadingImage/index.js +4 -3
- package/lib/module/social/components/LoadingImage/index.js.map +1 -1
- package/lib/module/social/components/LoadingImage/styles.js +4 -0
- package/lib/module/social/components/LoadingImage/styles.js.map +1 -1
- package/lib/module/social/components/LoadingVideo/index.js +13 -7
- package/lib/module/social/components/LoadingVideo/index.js.map +1 -1
- package/lib/module/social/components/LoadingVideo/styles.js +4 -0
- package/lib/module/social/components/LoadingVideo/styles.js.map +1 -1
- package/lib/module/social/components/MediaSelector/MediaSelector.js +158 -0
- package/lib/module/social/components/MediaSelector/MediaSelector.js.map +1 -0
- package/lib/module/social/components/MediaSelector/index.js +2 -0
- package/lib/module/social/components/MediaSelector/index.js.map +1 -0
- package/lib/module/social/components/MediaSelector/styles.js +123 -0
- package/lib/module/social/components/MediaSelector/styles.js.map +1 -0
- package/lib/module/social/components/MediaViewer/MediaViewer.js +127 -0
- package/lib/module/social/components/MediaViewer/MediaViewer.js.map +1 -0
- package/lib/module/social/components/MediaViewer/index.js +2 -0
- package/lib/module/social/components/MediaViewer/index.js.map +1 -0
- package/lib/module/social/components/MediaViewer/styles.js +53 -0
- package/lib/module/social/components/MediaViewer/styles.js.map +1 -0
- package/lib/module/social/components/PostContent/index.js +77 -122
- package/lib/module/social/components/PostContent/index.js.map +1 -1
- package/lib/module/social/components/SelectedMediaComponent/SelectedMediaComponent.js +141 -0
- package/lib/module/social/components/SelectedMediaComponent/SelectedMediaComponent.js.map +1 -0
- package/lib/module/social/components/SelectedMediaComponent/index.js +2 -0
- package/lib/module/social/components/SelectedMediaComponent/index.js.map +1 -0
- package/lib/module/social/components/SelectedMediaComponent/styles.js +36 -0
- package/lib/module/social/components/SelectedMediaComponent/styles.js.map +1 -0
- package/lib/module/social/constants/index.js +5 -0
- package/lib/module/social/constants/index.js.map +1 -0
- package/lib/module/social/elements/PostMediaElement/PostMediaElement.js +237 -0
- package/lib/module/social/elements/PostMediaElement/PostMediaElement.js.map +1 -0
- package/lib/module/social/elements/PostMediaElement/index.js +2 -0
- package/lib/module/social/elements/PostMediaElement/index.js.map +1 -0
- package/lib/module/social/elements/PostMediaElement/styles.js +110 -0
- package/lib/module/social/elements/PostMediaElement/styles.js.map +1 -0
- package/lib/module/social/features/post/Composer/PostComposer.js +59 -93
- package/lib/module/social/features/post/Composer/PostComposer.js.map +1 -1
- package/lib/module/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.js +17 -7
- package/lib/module/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.js.map +1 -1
- package/lib/module/social/features/post/components/MediaAttachment/MediaAttachment.js +17 -7
- package/lib/module/social/features/post/components/MediaAttachment/MediaAttachment.js.map +1 -1
- package/lib/module/social/utils/getFrameRatio.js +44 -0
- package/lib/module/social/utils/getFrameRatio.js.map +1 -0
- package/lib/module/social/utils/getIndicatorConfig.js +53 -0
- package/lib/module/social/utils/getIndicatorConfig.js.map +1 -0
- package/lib/typescript/core/assets/icons/xml.d.ts +5 -0
- package/lib/typescript/core/assets/icons/xml.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingImage/index.d.ts +2 -1
- package/lib/typescript/social/components/LoadingImage/index.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingImage/styles.d.ts +4 -0
- package/lib/typescript/social/components/LoadingImage/styles.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingVideo/index.d.ts +2 -1
- package/lib/typescript/social/components/LoadingVideo/index.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingVideo/styles.d.ts +4 -0
- package/lib/typescript/social/components/LoadingVideo/styles.d.ts.map +1 -1
- package/lib/typescript/social/components/MediaSelector/MediaSelector.d.ts +14 -0
- package/lib/typescript/social/components/MediaSelector/MediaSelector.d.ts.map +1 -0
- package/lib/typescript/social/components/MediaSelector/index.d.ts +2 -0
- package/lib/typescript/social/components/MediaSelector/index.d.ts.map +1 -0
- package/lib/typescript/social/components/MediaSelector/styles.d.ts +116 -0
- package/lib/typescript/social/components/MediaSelector/styles.d.ts.map +1 -0
- package/lib/typescript/social/components/MediaViewer/MediaViewer.d.ts +17 -0
- package/lib/typescript/social/components/MediaViewer/MediaViewer.d.ts.map +1 -0
- package/lib/typescript/social/components/MediaViewer/index.d.ts +3 -0
- package/lib/typescript/social/components/MediaViewer/index.d.ts.map +1 -0
- package/lib/typescript/social/components/MediaViewer/styles.d.ts +48 -0
- package/lib/typescript/social/components/MediaViewer/styles.d.ts.map +1 -0
- package/lib/typescript/social/components/PostContent/index.d.ts.map +1 -1
- package/lib/typescript/social/components/SelectedMediaComponent/SelectedMediaComponent.d.ts +12 -0
- package/lib/typescript/social/components/SelectedMediaComponent/SelectedMediaComponent.d.ts.map +1 -0
- package/lib/typescript/social/components/SelectedMediaComponent/index.d.ts +3 -0
- package/lib/typescript/social/components/SelectedMediaComponent/index.d.ts.map +1 -0
- package/lib/typescript/social/components/SelectedMediaComponent/styles.d.ts +25 -0
- package/lib/typescript/social/components/SelectedMediaComponent/styles.d.ts.map +1 -0
- package/lib/typescript/social/constants/index.d.ts +4 -0
- package/lib/typescript/social/constants/index.d.ts.map +1 -0
- package/lib/typescript/social/elements/PostMediaElement/PostMediaElement.d.ts +15 -0
- package/lib/typescript/social/elements/PostMediaElement/PostMediaElement.d.ts.map +1 -0
- package/lib/typescript/social/elements/PostMediaElement/index.d.ts +3 -0
- package/lib/typescript/social/elements/PostMediaElement/index.d.ts.map +1 -0
- package/lib/typescript/social/elements/PostMediaElement/styles.d.ts +88 -0
- package/lib/typescript/social/elements/PostMediaElement/styles.d.ts.map +1 -0
- package/lib/typescript/social/features/post/Composer/PostComposer.d.ts.map +1 -1
- package/lib/typescript/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.d.ts +3 -0
- package/lib/typescript/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.d.ts.map +1 -1
- package/lib/typescript/social/features/post/components/MediaAttachment/MediaAttachment.d.ts +3 -0
- package/lib/typescript/social/features/post/components/MediaAttachment/MediaAttachment.d.ts.map +1 -1
- package/lib/typescript/social/utils/getFrameRatio.d.ts +21 -0
- package/lib/typescript/social/utils/getFrameRatio.d.ts.map +1 -0
- package/lib/typescript/social/utils/getIndicatorConfig.d.ts +11 -0
- package/lib/typescript/social/utils/getIndicatorConfig.d.ts.map +1 -0
- package/package.json +5 -3
- package/src/core/assets/icons/xml.ts +46 -0
- package/src/social/components/LoadingImage/index.tsx +12 -2
- package/src/social/components/LoadingImage/styles.ts +4 -0
- package/src/social/components/LoadingVideo/index.tsx +28 -4
- package/src/social/components/LoadingVideo/styles.ts +4 -0
- package/src/social/components/MediaSelector/MediaSelector.tsx +231 -0
- package/src/social/components/MediaSelector/index.tsx +1 -0
- package/src/social/components/MediaSelector/styles.ts +124 -0
- package/src/social/components/MediaViewer/MediaViewer.tsx +168 -0
- package/src/social/components/MediaViewer/index.tsx +2 -0
- package/src/social/components/MediaViewer/styles.ts +53 -0
- package/src/social/components/PostContent/index.tsx +86 -159
- package/src/social/components/SelectedMediaComponent/SelectedMediaComponent.tsx +202 -0
- package/src/social/components/SelectedMediaComponent/index.ts +2 -0
- package/src/social/components/SelectedMediaComponent/styles.ts +38 -0
- package/src/social/constants/index.ts +4 -0
- package/src/social/elements/PostMediaElement/PostMediaElement.tsx +318 -0
- package/src/social/elements/PostMediaElement/index.tsx +5 -0
- package/src/social/elements/PostMediaElement/styles.ts +99 -0
- package/src/social/features/post/Composer/PostComposer.tsx +70 -96
- package/src/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.tsx +10 -3
- package/src/social/features/post/components/MediaAttachment/MediaAttachment.tsx +14 -3
- package/src/social/utils/getFrameRatio.ts +42 -0
- package/src/social/utils/getIndicatorConfig.ts +62 -0
package/src/social/features/post/components/DetailedMediaAttachment/DetailedMediaAttachment.tsx
CHANGED
|
@@ -18,6 +18,9 @@ type AmityDetailedMediaAttachmentComponentType = {
|
|
|
18
18
|
onPressVideo: () => void;
|
|
19
19
|
chosenMediaType?: mediaAttachment;
|
|
20
20
|
onHeightChange?: (height: number) => void;
|
|
21
|
+
/** When the 10-attachment cap is reached, the camera + gallery icons are
|
|
22
|
+
* disabled and untappable (PDT-4310 / PDT-4312). */
|
|
23
|
+
disabled?: boolean;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
const AmityDetailedMediaAttachmentComponent: FC<
|
|
@@ -28,6 +31,7 @@ const AmityDetailedMediaAttachmentComponent: FC<
|
|
|
28
31
|
onPressVideo,
|
|
29
32
|
chosenMediaType,
|
|
30
33
|
onHeightChange,
|
|
34
|
+
disabled = false,
|
|
31
35
|
}) => {
|
|
32
36
|
const pageId = PageID.post_composer_page;
|
|
33
37
|
const componentId = ComponentID.detailed_media_attachment;
|
|
@@ -91,8 +95,9 @@ const AmityDetailedMediaAttachmentComponent: FC<
|
|
|
91
95
|
<Pressable
|
|
92
96
|
testID={cameraElement.accessibilityId}
|
|
93
97
|
accessibilityLabel={cameraElement.accessibilityId}
|
|
94
|
-
style={styles.mediaAttachmentBtn}
|
|
98
|
+
style={[styles.mediaAttachmentBtn, disabled && { opacity: 0.4 }]}
|
|
95
99
|
onPress={onPressCamera}
|
|
100
|
+
disabled={disabled}
|
|
96
101
|
>
|
|
97
102
|
<View style={styles.iconContainer}>
|
|
98
103
|
<SvgXml
|
|
@@ -115,8 +120,9 @@ const AmityDetailedMediaAttachmentComponent: FC<
|
|
|
115
120
|
<Pressable
|
|
116
121
|
testID={imageElement.accessibilityId}
|
|
117
122
|
accessibilityLabel={imageElement.accessibilityId}
|
|
118
|
-
style={styles.mediaAttachmentBtn}
|
|
123
|
+
style={[styles.mediaAttachmentBtn, disabled && { opacity: 0.4 }]}
|
|
119
124
|
onPress={onPressImage}
|
|
125
|
+
disabled={disabled}
|
|
120
126
|
>
|
|
121
127
|
<View style={styles.iconContainer}>
|
|
122
128
|
<SvgXml
|
|
@@ -139,8 +145,9 @@ const AmityDetailedMediaAttachmentComponent: FC<
|
|
|
139
145
|
<Pressable
|
|
140
146
|
testID={videoElement.accessibilityId}
|
|
141
147
|
accessibilityLabel={videoElement.accessibilityId}
|
|
142
|
-
style={styles.mediaAttachmentBtn}
|
|
148
|
+
style={[styles.mediaAttachmentBtn, disabled && { opacity: 0.4 }]}
|
|
143
149
|
onPress={onPressVideo}
|
|
150
|
+
disabled={disabled}
|
|
144
151
|
>
|
|
145
152
|
<View style={styles.iconContainer}>
|
|
146
153
|
<SvgXml
|
|
@@ -17,6 +17,9 @@ type AmityMediaAttachmentComponentType = {
|
|
|
17
17
|
onPressVideo: () => void;
|
|
18
18
|
chosenMediaType?: mediaAttachment;
|
|
19
19
|
onHeightChange?: (height: number) => void;
|
|
20
|
+
/** When the 10-attachment cap is reached, the camera + gallery icons are
|
|
21
|
+
* disabled and untappable (PDT-4310 / PDT-4312). */
|
|
22
|
+
disabled?: boolean;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
const AmityMediaAttachmentComponent: FC<AmityMediaAttachmentComponentType> = ({
|
|
@@ -25,6 +28,7 @@ const AmityMediaAttachmentComponent: FC<AmityMediaAttachmentComponentType> = ({
|
|
|
25
28
|
onPressVideo,
|
|
26
29
|
chosenMediaType,
|
|
27
30
|
onHeightChange,
|
|
31
|
+
disabled = false,
|
|
28
32
|
}) => {
|
|
29
33
|
const pageId = PageID.post_composer_page;
|
|
30
34
|
const componentId = ComponentID.media_attachment;
|
|
@@ -89,8 +93,9 @@ const AmityMediaAttachmentComponent: FC<AmityMediaAttachmentComponentType> = ({
|
|
|
89
93
|
testID={cameraElement.accessibilityId}
|
|
90
94
|
accessibilityLabel={cameraElement.accessibilityId}
|
|
91
95
|
onPress={onPressCamera}
|
|
96
|
+
disabled={disabled}
|
|
92
97
|
>
|
|
93
|
-
<View style={styles.iconContainer}>
|
|
98
|
+
<View style={[styles.iconContainer, disabled && { opacity: 0.4 }]}>
|
|
94
99
|
<SvgXml
|
|
95
100
|
xml={camera()}
|
|
96
101
|
width={24}
|
|
@@ -107,8 +112,11 @@ const AmityMediaAttachmentComponent: FC<AmityMediaAttachmentComponentType> = ({
|
|
|
107
112
|
testID={imageElement.accessibilityId}
|
|
108
113
|
accessibilityLabel={imageElement.accessibilityId}
|
|
109
114
|
onPress={onPressImage}
|
|
115
|
+
disabled={disabled}
|
|
110
116
|
>
|
|
111
|
-
<View
|
|
117
|
+
<View
|
|
118
|
+
style={[styles.iconContainer, disabled && { opacity: 0.4 }]}
|
|
119
|
+
>
|
|
112
120
|
<SvgXml
|
|
113
121
|
xml={photo()}
|
|
114
122
|
width={24}
|
|
@@ -124,8 +132,11 @@ const AmityMediaAttachmentComponent: FC<AmityMediaAttachmentComponentType> = ({
|
|
|
124
132
|
testID={videoElement.accessibilityId}
|
|
125
133
|
accessibilityLabel={videoElement.accessibilityId}
|
|
126
134
|
onPress={onPressVideo}
|
|
135
|
+
disabled={disabled}
|
|
127
136
|
>
|
|
128
|
-
<View
|
|
137
|
+
<View
|
|
138
|
+
style={[styles.iconContainer, disabled && { opacity: 0.4 }]}
|
|
139
|
+
>
|
|
129
140
|
<SvgXml
|
|
130
141
|
xml={video()}
|
|
131
142
|
width={24}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type FrameRatio = '16:9' | '1:1' | '4:5';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Numeric aspect ratio (width / height) for each frame ratio.
|
|
5
|
+
* React Native's `aspectRatio` style takes a number, unlike web's CSS string.
|
|
6
|
+
*/
|
|
7
|
+
export const FRAME_RATIO_VALUE: Record<FrameRatio, number> = {
|
|
8
|
+
'16:9': 16 / 9,
|
|
9
|
+
'1:1': 1,
|
|
10
|
+
'4:5': 4 / 5,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const LANDSCAPE_THRESHOLD = 1.25;
|
|
14
|
+
const PORTRAIT_THRESHOLD = 0.8;
|
|
15
|
+
|
|
16
|
+
export const DEFAULT_FRAME_RATIO: FrameRatio = '1:1';
|
|
17
|
+
|
|
18
|
+
export function getFrameRatio(width?: number, height?: number): FrameRatio {
|
|
19
|
+
if (!width || !height || height <= 0) return DEFAULT_FRAME_RATIO;
|
|
20
|
+
|
|
21
|
+
const ratio = width / height;
|
|
22
|
+
|
|
23
|
+
if (ratio >= LANDSCAPE_THRESHOLD) return '16:9';
|
|
24
|
+
if (ratio <= PORTRAIT_THRESHOLD) return '4:5';
|
|
25
|
+
return '1:1';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Swap width/height when a video is rotated 90/270 degrees so the frame ratio
|
|
30
|
+
* reflects how the video is actually displayed. Mirrors web getVideoDisplayDims.
|
|
31
|
+
*/
|
|
32
|
+
export function getVideoDisplayDims(video?: {
|
|
33
|
+
width?: number;
|
|
34
|
+
height?: number;
|
|
35
|
+
rotation?: number;
|
|
36
|
+
}): { width?: number; height?: number } {
|
|
37
|
+
const { width, height, rotation } = video ?? {};
|
|
38
|
+
if (width == null || height == null) return { width, height };
|
|
39
|
+
if (Math.abs(rotation ?? 0) % 180 === 90)
|
|
40
|
+
return { width: height, height: width };
|
|
41
|
+
return { width, height };
|
|
42
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MAX_INDICATOR_DOTS } from '../constants';
|
|
2
|
+
|
|
3
|
+
export type IndicatorDotState = 'active' | 'inactive' | 'edge';
|
|
4
|
+
|
|
5
|
+
export type IndicatorDot = {
|
|
6
|
+
key: string;
|
|
7
|
+
state: IndicatorDotState;
|
|
8
|
+
side?: 'left' | 'right';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type IndicatorConfig = {
|
|
12
|
+
dots: IndicatorDot[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function getIndicatorConfig(
|
|
16
|
+
current: number,
|
|
17
|
+
total: number
|
|
18
|
+
): IndicatorConfig {
|
|
19
|
+
if (total <= MAX_INDICATOR_DOTS) {
|
|
20
|
+
const dots = Array.from({ length: total }, (_, page) => ({
|
|
21
|
+
key: `page-${page}`,
|
|
22
|
+
state: page === current ? ('active' as const) : ('inactive' as const),
|
|
23
|
+
}));
|
|
24
|
+
return { dots };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let windowStart: number;
|
|
28
|
+
let windowEnd: number;
|
|
29
|
+
|
|
30
|
+
if (current <= 1) {
|
|
31
|
+
windowStart = 0;
|
|
32
|
+
windowEnd = 4;
|
|
33
|
+
} else if (current >= total - 3) {
|
|
34
|
+
windowStart = total - 5;
|
|
35
|
+
windowEnd = total - 1;
|
|
36
|
+
} else {
|
|
37
|
+
windowStart = current - 1;
|
|
38
|
+
windowEnd = current + 2;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const showLeft = windowStart > 0;
|
|
42
|
+
const showRight = windowEnd < total - 1;
|
|
43
|
+
|
|
44
|
+
const dots: IndicatorDot[] = [];
|
|
45
|
+
|
|
46
|
+
if (showLeft) {
|
|
47
|
+
dots.push({ key: 'edge-left', state: 'edge', side: 'left' });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (let page = windowStart; page <= windowEnd; page += 1) {
|
|
51
|
+
dots.push({
|
|
52
|
+
key: `page-${page}`,
|
|
53
|
+
state: page === current ? 'active' : 'inactive',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (showRight) {
|
|
58
|
+
dots.push({ key: 'edge-right', state: 'edge', side: 'right' });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { dots };
|
|
62
|
+
}
|