react-native-ui-lib 7.40.1-snapshot.6825 → 7.40.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/package.json
CHANGED
|
@@ -196,7 +196,7 @@ async function generateReleaseNotes(latestVersion,
|
|
|
196
196
|
newVersion,
|
|
197
197
|
fileNamePrefix,
|
|
198
198
|
repo,
|
|
199
|
-
|
|
199
|
+
header = '',
|
|
200
200
|
tagPrefix = '',
|
|
201
201
|
categories = []) {
|
|
202
202
|
let latestVer, newVer;
|
|
@@ -214,7 +214,6 @@ async function generateReleaseNotes(latestVersion,
|
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
rl.on('close', () => {
|
|
217
|
-
const header = getHeader(newVer);
|
|
218
217
|
console.info(`Current latest version is v${latestVer}`);
|
|
219
218
|
console.info(`Generating release notes out or PRs for v${newVer}`);
|
|
220
219
|
_generateReleaseNotes(latestVer, newVer, fileNamePrefix, repo, header, tagPrefix, categories);
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import React, { useContext, useCallback, useRef
|
|
1
|
+
import React, { useContext, useCallback, useRef } from 'react';
|
|
2
2
|
import { ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
3
|
import { runOnJS, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { FlashListPackage } from "../../optionalDependencies";
|
|
5
5
|
import { BorderRadiuses, Colors } from "../../style";
|
|
6
|
-
import { useDidUpdate } from "../../hooks";
|
|
7
6
|
import View from "../../components/view";
|
|
8
7
|
import Text from "../../components/text";
|
|
9
8
|
import { isSameDay, isSameMonth } from "./helpers/DateUtils";
|
|
10
9
|
import { UpdateSource } from "./types";
|
|
11
10
|
import CalendarContext from "./CalendarContext";
|
|
12
11
|
const FlashList = FlashListPackage?.FlashList;
|
|
12
|
+
|
|
13
|
+
// TODO: Fix initial scrolling
|
|
13
14
|
function Agenda(props) {
|
|
14
15
|
const {
|
|
15
16
|
renderEvent,
|
|
16
17
|
renderHeader,
|
|
18
|
+
itemHeight = 50,
|
|
17
19
|
onEndReached,
|
|
18
20
|
showLoader
|
|
19
21
|
} = props;
|
|
@@ -26,27 +28,18 @@ function Agenda(props) {
|
|
|
26
28
|
const flashList = useRef(null);
|
|
27
29
|
const closestSectionHeader = useSharedValue(null);
|
|
28
30
|
const scrolledByUser = useSharedValue(false);
|
|
29
|
-
const [stickyHeaderIndices, setStickyHeaderIndices] = useState([]);
|
|
30
|
-
const lastDateBeforeLoadingNewEvents = useSharedValue(selectedDate.value);
|
|
31
31
|
|
|
32
32
|
/* const keyExtractor = useCallback((item: InternalEvent) => {
|
|
33
33
|
return item.type === 'Event' ? item.id : item.header;
|
|
34
34
|
}, []); */
|
|
35
35
|
|
|
36
|
-
useDidUpdate(() => {
|
|
37
|
-
const result = findClosestDateAfter(lastDateBeforeLoadingNewEvents.value);
|
|
38
|
-
if (result?.index) {
|
|
39
|
-
setTimeout(() => scrollToIndex(result?.index, false), 200);
|
|
40
|
-
}
|
|
41
|
-
const headerIndices = data.map((e, index) => e.type === 'Header' ? index : undefined).filter(i => i !== undefined);
|
|
42
|
-
// @ts-expect-error
|
|
43
|
-
setStickyHeaderIndices(headerIndices);
|
|
44
|
-
}, [data]);
|
|
45
36
|
const _renderEvent = useCallback(eventItem => {
|
|
46
37
|
if (renderEvent) {
|
|
47
|
-
return <View style={styles.eventContainer}>
|
|
38
|
+
return <View height={itemHeight} style={styles.eventContainer}>
|
|
39
|
+
{renderEvent(eventItem)}
|
|
40
|
+
</View>;
|
|
48
41
|
}
|
|
49
|
-
return <View marginV-1 marginH-10 paddingH-10 centerV style={styles.event}>
|
|
42
|
+
return <View marginV-1 marginH-10 paddingH-10 height={itemHeight} centerV style={styles.event}>
|
|
50
43
|
<Text>
|
|
51
44
|
Item for
|
|
52
45
|
{new Date(eventItem.start).toLocaleString('en-GB', {
|
|
@@ -63,15 +56,15 @@ function Agenda(props) {
|
|
|
63
56
|
})}
|
|
64
57
|
</Text>
|
|
65
58
|
</View>;
|
|
66
|
-
}, [renderEvent]);
|
|
59
|
+
}, [renderEvent, itemHeight]);
|
|
67
60
|
const _renderHeader = useCallback(headerItem => {
|
|
68
61
|
if (renderHeader) {
|
|
69
|
-
return <View>{renderHeader(headerItem)}</View>;
|
|
62
|
+
return <View height={itemHeight}>{renderHeader(headerItem)}</View>;
|
|
70
63
|
}
|
|
71
|
-
return <View
|
|
64
|
+
return <View bottom marginB-5 marginH-20 height={itemHeight}>
|
|
72
65
|
<Text>{headerItem.header}</Text>
|
|
73
66
|
</View>;
|
|
74
|
-
}, [renderHeader]);
|
|
67
|
+
}, [renderHeader, itemHeight]);
|
|
75
68
|
const renderItem = useCallback(({
|
|
76
69
|
item
|
|
77
70
|
}) => {
|
|
@@ -123,10 +116,6 @@ function Agenda(props) {
|
|
|
123
116
|
const _isSameMonth = isSameMonth(selected, previous);
|
|
124
117
|
runOnJS(scrollToIndex)(index, _isSameMonth);
|
|
125
118
|
}
|
|
126
|
-
} else {
|
|
127
|
-
// Note: We got here because we are missing future agenda events to scroll to.
|
|
128
|
-
// therefor we should expect and new events data load
|
|
129
|
-
lastDateBeforeLoadingNewEvents.value = selectedDate.value;
|
|
130
119
|
}
|
|
131
120
|
}
|
|
132
121
|
}
|
|
@@ -159,7 +148,6 @@ function Agenda(props) {
|
|
|
159
148
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
149
|
}, []);
|
|
161
150
|
const _onEndReached = useCallback(() => {
|
|
162
|
-
lastDateBeforeLoadingNewEvents.value = selectedDate.value;
|
|
163
151
|
onEndReached?.(selectedDate.value);
|
|
164
152
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
153
|
}, [onEndReached]);
|
|
@@ -167,7 +155,7 @@ function Agenda(props) {
|
|
|
167
155
|
<FlashList ref={flashList} estimatedItemSize={52} data={data}
|
|
168
156
|
// TODO: Not sure we need key extractor in flash list
|
|
169
157
|
// keyExtractor={keyExtractor}
|
|
170
|
-
renderItem={renderItem} getItemType={getItemType}
|
|
158
|
+
renderItem={renderItem} getItemType={getItemType} onViewableItemsChanged={onViewableItemsChanged} onMomentumScrollBegin={onMomentumScrollBegin} onScrollBeginDrag={onScrollBeginDrag} initialScrollIndex={findClosestDateAfter(selectedDate.value)?.index ?? 0} onEndReached={_onEndReached} />
|
|
171
159
|
{showLoader && <View absF center style={{
|
|
172
160
|
backgroundColor: Colors.rgba(Colors.grey10, 0.2)
|
|
173
161
|
}}>
|
|
@@ -9,16 +9,6 @@ import { getDateObject, getMonthForIndex, addMonths } from "./helpers/DateUtils"
|
|
|
9
9
|
import { DayNamesFormat, UpdateSource } from "./types";
|
|
10
10
|
import CalendarContext from "./CalendarContext";
|
|
11
11
|
import WeekDaysNames from "./WeekDaysNames";
|
|
12
|
-
|
|
13
|
-
// Note: this fixes the updates on the header month title
|
|
14
|
-
Reanimated.addWhitelistedNativeProps({
|
|
15
|
-
text: true
|
|
16
|
-
});
|
|
17
|
-
const ARROWS_THROTTLE_TIME = 300;
|
|
18
|
-
const ARROWS_THROTTLE_OPTIONS = {
|
|
19
|
-
leading: true,
|
|
20
|
-
trailing: false
|
|
21
|
-
};
|
|
22
12
|
const WEEK_NUMBER_WIDTH = 32;
|
|
23
13
|
const ARROW_NEXT = require("./assets/arrowNext.png");
|
|
24
14
|
const ARROW_BACK = require("./assets/arrowBack.png");
|
|
@@ -41,10 +31,10 @@ const Header = props => {
|
|
|
41
31
|
}, []);
|
|
42
32
|
const onLeftArrowPress = useCallback(throttle(() => {
|
|
43
33
|
setDate(getNewDate(-1), UpdateSource.MONTH_ARROW);
|
|
44
|
-
},
|
|
34
|
+
}, 300), [setDate, getNewDate]);
|
|
45
35
|
const onRightArrowPress = useCallback(throttle(() => {
|
|
46
36
|
setDate(getNewDate(1), UpdateSource.MONTH_ARROW);
|
|
47
|
-
},
|
|
37
|
+
}, 300), [setDate, getNewDate]);
|
|
48
38
|
const getTitle = useCallback(date => {
|
|
49
39
|
'worklet';
|
|
50
40
|
|
|
@@ -15,11 +15,12 @@ import { useDidUpdate } from "../../hooks";
|
|
|
15
15
|
const FlashList = FlashListPackage?.FlashList;
|
|
16
16
|
const VIEWABILITY_CONFIG = {
|
|
17
17
|
itemVisiblePercentThreshold: 95,
|
|
18
|
-
minimumViewTime:
|
|
18
|
+
minimumViewTime: 200
|
|
19
19
|
};
|
|
20
|
-
const YEARS_RANGE =
|
|
20
|
+
const YEARS_RANGE = 1;
|
|
21
21
|
const PAGE_RELOAD_THRESHOLD = 3;
|
|
22
|
-
const NOW =
|
|
22
|
+
const NOW = Date.now(); // so the 'initialDate' effect won't get called since the now different on every rerender
|
|
23
|
+
|
|
23
24
|
function Calendar(props) {
|
|
24
25
|
const {
|
|
25
26
|
data,
|
|
@@ -30,20 +31,20 @@ function Calendar(props) {
|
|
|
30
31
|
staticHeader = false,
|
|
31
32
|
showExtraDays = true
|
|
32
33
|
} = props;
|
|
33
|
-
const [
|
|
34
|
+
const [items] = useState(() => generateMonthItems(initialDate, YEARS_RANGE, YEARS_RANGE));
|
|
34
35
|
const getItemIndex = useCallback(date => {
|
|
35
36
|
'worklet';
|
|
36
37
|
|
|
37
38
|
const dateObject = getDateObject(date);
|
|
38
|
-
for (let i = 0; i <
|
|
39
|
-
if (
|
|
39
|
+
for (let i = 0; i < items.length; i++) {
|
|
40
|
+
if (items[i].month === dateObject.month && items[i].year === dateObject.year) {
|
|
40
41
|
return i;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
return -1;
|
|
44
|
-
}, [
|
|
45
|
+
}, [items]);
|
|
45
46
|
const flashListRef = useRef();
|
|
46
|
-
const current = useSharedValue(
|
|
47
|
+
const current = useSharedValue(initialDate);
|
|
47
48
|
const initialMonthIndex = useRef(getItemIndex(current.value));
|
|
48
49
|
const lastUpdateSource = useSharedValue(UpdateSource.INIT);
|
|
49
50
|
const processedData = useMemo(() => addHeaders(data), [data]);
|
|
@@ -73,7 +74,7 @@ function Calendar(props) {
|
|
|
73
74
|
console.log('Update items');
|
|
74
75
|
const index = getItemIndex(current.value);
|
|
75
76
|
scrollToIndex(index);
|
|
76
|
-
}, [
|
|
77
|
+
}, [items, getItemIndex]);
|
|
77
78
|
const setHeaderHeight = useCallback(height => {
|
|
78
79
|
headerHeight.value = height;
|
|
79
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -115,21 +116,21 @@ function Calendar(props) {
|
|
|
115
116
|
// const newDate = addYears(current.value, prepend ? -1 : 1);
|
|
116
117
|
// const newItems = generateMonthItems(newDate, pastRange, futureRange);
|
|
117
118
|
// const newArray = mergeArrays(prepend, items, newItems);
|
|
118
|
-
//
|
|
119
|
+
// setItems(newArray);
|
|
119
120
|
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
|
-
}, [
|
|
121
|
+
}, [items]);
|
|
121
122
|
const shouldAddPages = useCallback(index => {
|
|
122
123
|
'worklet';
|
|
123
124
|
|
|
124
|
-
return index !== -1 && (index < PAGE_RELOAD_THRESHOLD || index >
|
|
125
|
+
return index !== -1 && (index < PAGE_RELOAD_THRESHOLD || index > items.length - PAGE_RELOAD_THRESHOLD);
|
|
125
126
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
-
}, [
|
|
127
|
+
}, [items]);
|
|
127
128
|
useAnimatedReaction(() => {
|
|
128
129
|
return current.value;
|
|
129
130
|
}, (selected, previous) => {
|
|
130
131
|
const index = getItemIndex(selected);
|
|
131
132
|
if (shouldAddPages(index)) {
|
|
132
|
-
console.log('Add new pages: ', index,
|
|
133
|
+
console.log('Add new pages: ', index, items.length);
|
|
133
134
|
runOnJS(addPages)(/* index */);
|
|
134
135
|
} else if (lastUpdateSource.value !== UpdateSource.MONTH_SCROLL) {
|
|
135
136
|
if (previous && !isSameMonth(selected, previous)) {
|
|
@@ -175,7 +176,7 @@ function Calendar(props) {
|
|
|
175
176
|
}, []);
|
|
176
177
|
return <CalendarContext.Provider value={contextValue}>
|
|
177
178
|
{staticHeader && <Header />}
|
|
178
|
-
<FlashList ref={flashListRef} estimatedItemSize={Constants.screenWidth} data={
|
|
179
|
+
<FlashList ref={flashListRef} estimatedItemSize={Constants.screenWidth} data={items} initialScrollIndex={initialMonthIndex.current} estimatedFirstItemOffset={0} renderItem={renderCalendarItem} horizontal pagingEnabled showsHorizontalScrollIndicator={false}
|
|
179
180
|
// TODO: Consider moving this shared logic with Agenda to a hook
|
|
180
181
|
onViewableItemsChanged={onViewableItemsChanged} viewabilityConfig={VIEWABILITY_CONFIG} onMomentumScrollBegin={onMomentumScrollBegin} onScrollBeginDrag={onScrollBeginDrag} />
|
|
181
182
|
{children}
|
|
@@ -113,6 +113,7 @@ export interface CalendarProps {
|
|
|
113
113
|
export interface AgendaProps {
|
|
114
114
|
renderEvent?: (event: Event) => React.ReactElement | null;
|
|
115
115
|
renderHeader?: (header: DateSectionHeader) => React.ReactElement | null;
|
|
116
|
+
itemHeight?: number;
|
|
116
117
|
showLoader?: boolean;
|
|
117
118
|
onEndReached?: (date: number) => void;
|
|
118
119
|
}
|