@lazerlen/legend-calendar 1.3.0 → 1.4.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/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-test.log +87 -87
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +164 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/CalendarList.stories.tsx +51 -0
- package/src/components/CalendarList.tsx +41 -2
package/dist/index.mjs
CHANGED
|
@@ -1991,7 +1991,7 @@ import { jsx as _jsx10 } from "react/jsx-runtime";
|
|
|
1991
1991
|
var LegendList = LegendListBase;
|
|
1992
1992
|
var keyExtractor = (month) => month.id;
|
|
1993
1993
|
function CalendarList(t0) {
|
|
1994
|
-
const $ = _c12(
|
|
1994
|
+
const $ = _c12(49);
|
|
1995
1995
|
const _a = t0, {
|
|
1996
1996
|
ref
|
|
1997
1997
|
} = _a, props = __objRest(_a, [
|
|
@@ -1999,23 +1999,25 @@ function CalendarList(t0) {
|
|
|
1999
1999
|
]);
|
|
2000
2000
|
const _b = props, {
|
|
2001
2001
|
calendarInitialMonthId,
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2002
|
+
calendarInitialScrollToActiveRange: t1,
|
|
2003
|
+
calendarPastScrollRangeInMonths: t2,
|
|
2004
|
+
calendarFutureScrollRangeInMonths: t3,
|
|
2005
|
+
calendarFirstDayOfWeek: t4,
|
|
2005
2006
|
calendarFormatLocale,
|
|
2006
|
-
calendarSpacing:
|
|
2007
|
+
calendarSpacing: t5,
|
|
2007
2008
|
calendarRowHorizontalSpacing,
|
|
2008
|
-
calendarRowVerticalSpacing:
|
|
2009
|
-
calendarMonthHeaderHeight:
|
|
2010
|
-
calendarDayHeight:
|
|
2011
|
-
calendarWeekHeaderHeight:
|
|
2012
|
-
calendarAdditionalHeight:
|
|
2009
|
+
calendarRowVerticalSpacing: t6,
|
|
2010
|
+
calendarMonthHeaderHeight: t7,
|
|
2011
|
+
calendarDayHeight: t8,
|
|
2012
|
+
calendarWeekHeaderHeight: t9,
|
|
2013
|
+
calendarAdditionalHeight: t10,
|
|
2013
2014
|
calendarColorScheme,
|
|
2014
2015
|
theme,
|
|
2015
2016
|
onEndReached,
|
|
2016
2017
|
onStartReached
|
|
2017
2018
|
} = _b, otherProps = __objRest(_b, [
|
|
2018
2019
|
"calendarInitialMonthId",
|
|
2020
|
+
"calendarInitialScrollToActiveRange",
|
|
2019
2021
|
"calendarPastScrollRangeInMonths",
|
|
2020
2022
|
"calendarFutureScrollRangeInMonths",
|
|
2021
2023
|
"calendarFirstDayOfWeek",
|
|
@@ -2032,15 +2034,16 @@ function CalendarList(t0) {
|
|
|
2032
2034
|
"onEndReached",
|
|
2033
2035
|
"onStartReached"
|
|
2034
2036
|
]);
|
|
2035
|
-
const
|
|
2036
|
-
const
|
|
2037
|
-
const
|
|
2038
|
-
const
|
|
2039
|
-
const
|
|
2040
|
-
const
|
|
2041
|
-
const
|
|
2042
|
-
const
|
|
2043
|
-
const
|
|
2037
|
+
const calendarInitialScrollToActiveRange = t1 === void 0 ? true : t1;
|
|
2038
|
+
const calendarPastScrollRangeInMonths = t2 === void 0 ? 12 : t2;
|
|
2039
|
+
const calendarFutureScrollRangeInMonths = t3 === void 0 ? 12 : t3;
|
|
2040
|
+
const calendarFirstDayOfWeek = t4 === void 0 ? "sunday" : t4;
|
|
2041
|
+
const calendarSpacing = t5 === void 0 ? 20 : t5;
|
|
2042
|
+
const calendarRowVerticalSpacing = t6 === void 0 ? 8 : t6;
|
|
2043
|
+
const calendarMonthHeaderHeight = t7 === void 0 ? 20 : t7;
|
|
2044
|
+
const calendarDayHeight = t8 === void 0 ? 32 : t8;
|
|
2045
|
+
const calendarWeekHeaderHeight = t9 === void 0 ? calendarDayHeight : t9;
|
|
2046
|
+
const calendarAdditionalHeight = t10 === void 0 ? 0 : t10;
|
|
2044
2047
|
const _c14 = otherProps, {
|
|
2045
2048
|
calendarActiveDateRanges,
|
|
2046
2049
|
calendarDisabledDateIds,
|
|
@@ -2101,50 +2104,87 @@ function CalendarList(t0) {
|
|
|
2101
2104
|
calendarMaxDateId,
|
|
2102
2105
|
calendarMinDateId
|
|
2103
2106
|
});
|
|
2104
|
-
|
|
2107
|
+
let computedInitialScrollIndex = initialMonthIndex;
|
|
2108
|
+
if (calendarInitialScrollToActiveRange && calendarActiveDateRanges) {
|
|
2109
|
+
const firstRange = calendarActiveDateRanges[0];
|
|
2110
|
+
if (firstRange == null ? void 0 : firstRange.startId) {
|
|
2111
|
+
let t112;
|
|
2112
|
+
if ($[0] !== firstRange.startId) {
|
|
2113
|
+
const startDate = fromDateId(firstRange.startId);
|
|
2114
|
+
t112 = toDateId(startOfMonth(startDate));
|
|
2115
|
+
$[0] = firstRange.startId;
|
|
2116
|
+
$[1] = t112;
|
|
2117
|
+
} else {
|
|
2118
|
+
t112 = $[1];
|
|
2119
|
+
}
|
|
2120
|
+
const monthId = t112;
|
|
2121
|
+
let t122;
|
|
2122
|
+
if ($[2] !== monthId || $[3] !== monthList) {
|
|
2123
|
+
let t132;
|
|
2124
|
+
if ($[5] !== monthId) {
|
|
2125
|
+
t132 = (month) => month.id === monthId;
|
|
2126
|
+
$[5] = monthId;
|
|
2127
|
+
$[6] = t132;
|
|
2128
|
+
} else {
|
|
2129
|
+
t132 = $[6];
|
|
2130
|
+
}
|
|
2131
|
+
t122 = monthList.findIndex(t132);
|
|
2132
|
+
$[2] = monthId;
|
|
2133
|
+
$[3] = monthList;
|
|
2134
|
+
$[4] = t122;
|
|
2135
|
+
} else {
|
|
2136
|
+
t122 = $[4];
|
|
2137
|
+
}
|
|
2138
|
+
const monthIndex = t122;
|
|
2139
|
+
if (monthIndex !== -1) {
|
|
2140
|
+
computedInitialScrollIndex = monthIndex;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
const monthListWithCalendarProps = monthList.map((month_0) => __spreadProps(__spreadValues({}, month_0), {
|
|
2105
2145
|
calendarProps
|
|
2106
2146
|
}));
|
|
2107
|
-
let
|
|
2108
|
-
if ($[
|
|
2109
|
-
|
|
2147
|
+
let t11;
|
|
2148
|
+
if ($[7] !== appendMonths || $[8] !== calendarFutureScrollRangeInMonths || $[9] !== onEndReached) {
|
|
2149
|
+
t11 = (info) => {
|
|
2110
2150
|
appendMonths(calendarFutureScrollRangeInMonths);
|
|
2111
2151
|
onEndReached == null ? void 0 : onEndReached(info);
|
|
2112
2152
|
};
|
|
2113
|
-
$[
|
|
2114
|
-
$[
|
|
2115
|
-
$[
|
|
2116
|
-
$[
|
|
2153
|
+
$[7] = appendMonths;
|
|
2154
|
+
$[8] = calendarFutureScrollRangeInMonths;
|
|
2155
|
+
$[9] = onEndReached;
|
|
2156
|
+
$[10] = t11;
|
|
2117
2157
|
} else {
|
|
2118
|
-
|
|
2158
|
+
t11 = $[10];
|
|
2119
2159
|
}
|
|
2120
|
-
const handleOnEndReached =
|
|
2121
|
-
let
|
|
2122
|
-
if ($[
|
|
2123
|
-
|
|
2160
|
+
const handleOnEndReached = t11;
|
|
2161
|
+
let t12;
|
|
2162
|
+
if ($[11] !== calendarPastScrollRangeInMonths || $[12] !== onStartReached || $[13] !== prependMonths) {
|
|
2163
|
+
t12 = (info_0) => {
|
|
2124
2164
|
prependMonths(calendarPastScrollRangeInMonths);
|
|
2125
2165
|
onStartReached == null ? void 0 : onStartReached(info_0);
|
|
2126
2166
|
};
|
|
2127
|
-
$[
|
|
2128
|
-
$[
|
|
2129
|
-
$[
|
|
2130
|
-
$[
|
|
2167
|
+
$[11] = calendarPastScrollRangeInMonths;
|
|
2168
|
+
$[12] = onStartReached;
|
|
2169
|
+
$[13] = prependMonths;
|
|
2170
|
+
$[14] = t12;
|
|
2131
2171
|
} else {
|
|
2132
|
-
|
|
2172
|
+
t12 = $[14];
|
|
2133
2173
|
}
|
|
2134
|
-
const handleOnStartReached =
|
|
2135
|
-
let
|
|
2136
|
-
if ($[
|
|
2137
|
-
|
|
2138
|
-
const
|
|
2174
|
+
const handleOnStartReached = t12;
|
|
2175
|
+
let t13;
|
|
2176
|
+
if ($[15] !== addMissingMonths || $[16] !== calendarAdditionalHeight || $[17] !== calendarDayHeight || $[18] !== calendarMonthHeaderHeight || $[19] !== calendarRowVerticalSpacing || $[20] !== calendarSpacing || $[21] !== calendarWeekHeaderHeight || $[22] !== monthList) {
|
|
2177
|
+
t13 = (date) => {
|
|
2178
|
+
const monthId_0 = toDateId(startOfMonth(date));
|
|
2139
2179
|
let baseMonthList = monthList;
|
|
2140
|
-
let index = baseMonthList.findIndex((
|
|
2180
|
+
let index = baseMonthList.findIndex((month_1) => month_1.id === monthId_0);
|
|
2141
2181
|
if (index === -1) {
|
|
2142
|
-
baseMonthList = addMissingMonths(
|
|
2143
|
-
index = baseMonthList.findIndex((
|
|
2182
|
+
baseMonthList = addMissingMonths(monthId_0);
|
|
2183
|
+
index = baseMonthList.findIndex((month_2) => month_2.id === monthId_0);
|
|
2144
2184
|
}
|
|
2145
|
-
return baseMonthList.slice(0, index).reduce((acc,
|
|
2185
|
+
return baseMonthList.slice(0, index).reduce((acc, month_3) => {
|
|
2146
2186
|
const currentHeight = getHeightForMonth({
|
|
2147
|
-
calendarMonth:
|
|
2187
|
+
calendarMonth: month_3,
|
|
2148
2188
|
calendarSpacing,
|
|
2149
2189
|
calendarDayHeight,
|
|
2150
2190
|
calendarMonthHeaderHeight,
|
|
@@ -2155,30 +2195,30 @@ function CalendarList(t0) {
|
|
|
2155
2195
|
return acc + currentHeight;
|
|
2156
2196
|
}, 0);
|
|
2157
2197
|
};
|
|
2158
|
-
$[
|
|
2159
|
-
$[
|
|
2160
|
-
$[
|
|
2161
|
-
$[
|
|
2162
|
-
$[
|
|
2163
|
-
$[
|
|
2164
|
-
$[
|
|
2165
|
-
$[
|
|
2166
|
-
$[
|
|
2167
|
-
} else {
|
|
2168
|
-
|
|
2169
|
-
}
|
|
2170
|
-
const getScrollOffsetForMonth =
|
|
2198
|
+
$[15] = addMissingMonths;
|
|
2199
|
+
$[16] = calendarAdditionalHeight;
|
|
2200
|
+
$[17] = calendarDayHeight;
|
|
2201
|
+
$[18] = calendarMonthHeaderHeight;
|
|
2202
|
+
$[19] = calendarRowVerticalSpacing;
|
|
2203
|
+
$[20] = calendarSpacing;
|
|
2204
|
+
$[21] = calendarWeekHeaderHeight;
|
|
2205
|
+
$[22] = monthList;
|
|
2206
|
+
$[23] = t13;
|
|
2207
|
+
} else {
|
|
2208
|
+
t13 = $[23];
|
|
2209
|
+
}
|
|
2210
|
+
const getScrollOffsetForMonth = t13;
|
|
2171
2211
|
const legendListRef = useRef(null);
|
|
2172
|
-
let
|
|
2173
|
-
if ($[
|
|
2174
|
-
|
|
2175
|
-
scrollToMonth(date_0, animated,
|
|
2212
|
+
let t14;
|
|
2213
|
+
if ($[24] !== calendarDayHeight || $[25] !== calendarFirstDayOfWeek || $[26] !== calendarRowVerticalSpacing || $[27] !== calendarWeekHeaderHeight || $[28] !== getScrollOffsetForMonth) {
|
|
2214
|
+
t14 = () => ({
|
|
2215
|
+
scrollToMonth(date_0, animated, t152) {
|
|
2176
2216
|
const {
|
|
2177
|
-
additionalOffset:
|
|
2178
|
-
} =
|
|
2217
|
+
additionalOffset: t162
|
|
2218
|
+
} = t152 === void 0 ? {
|
|
2179
2219
|
additionalOffset: 0
|
|
2180
|
-
} :
|
|
2181
|
-
const additionalOffset =
|
|
2220
|
+
} : t152;
|
|
2221
|
+
const additionalOffset = t162 === void 0 ? 0 : t162;
|
|
2182
2222
|
setTimeout(() => {
|
|
2183
2223
|
var _a2;
|
|
2184
2224
|
(_a2 = legendListRef.current) == null ? void 0 : _a2.scrollToOffset({
|
|
@@ -2187,14 +2227,14 @@ function CalendarList(t0) {
|
|
|
2187
2227
|
});
|
|
2188
2228
|
}, 0);
|
|
2189
2229
|
},
|
|
2190
|
-
scrollToDate(date_1, animated_0,
|
|
2230
|
+
scrollToDate(date_1, animated_0, t172) {
|
|
2191
2231
|
var _a2;
|
|
2192
2232
|
const {
|
|
2193
|
-
additionalOffset:
|
|
2194
|
-
} =
|
|
2233
|
+
additionalOffset: t182
|
|
2234
|
+
} = t172 === void 0 ? {
|
|
2195
2235
|
additionalOffset: 0
|
|
2196
|
-
} :
|
|
2197
|
-
const additionalOffset_0 =
|
|
2236
|
+
} : t172;
|
|
2237
|
+
const additionalOffset_0 = t182 === void 0 ? 0 : t182;
|
|
2198
2238
|
const currentMonthOffset = getScrollOffsetForMonth(date_1);
|
|
2199
2239
|
const weekOfMonthIndex = getWeekOfMonth(date_1, calendarFirstDayOfWeek);
|
|
2200
2240
|
const rowHeight = calendarDayHeight + calendarRowVerticalSpacing;
|
|
@@ -2213,30 +2253,30 @@ function CalendarList(t0) {
|
|
|
2213
2253
|
});
|
|
2214
2254
|
}
|
|
2215
2255
|
});
|
|
2216
|
-
$[
|
|
2217
|
-
$[
|
|
2218
|
-
$[
|
|
2219
|
-
$[
|
|
2220
|
-
$[
|
|
2221
|
-
$[
|
|
2256
|
+
$[24] = calendarDayHeight;
|
|
2257
|
+
$[25] = calendarFirstDayOfWeek;
|
|
2258
|
+
$[26] = calendarRowVerticalSpacing;
|
|
2259
|
+
$[27] = calendarWeekHeaderHeight;
|
|
2260
|
+
$[28] = getScrollOffsetForMonth;
|
|
2261
|
+
$[29] = t14;
|
|
2222
2262
|
} else {
|
|
2223
|
-
|
|
2263
|
+
t14 = $[29];
|
|
2224
2264
|
}
|
|
2225
|
-
useImperativeHandle(ref,
|
|
2226
|
-
let
|
|
2227
|
-
if ($[
|
|
2228
|
-
|
|
2265
|
+
useImperativeHandle(ref, t14);
|
|
2266
|
+
let t15;
|
|
2267
|
+
if ($[30] !== calendarSpacing) {
|
|
2268
|
+
t15 = {
|
|
2229
2269
|
paddingBottom: calendarSpacing
|
|
2230
2270
|
};
|
|
2231
|
-
$[
|
|
2232
|
-
$[
|
|
2271
|
+
$[30] = calendarSpacing;
|
|
2272
|
+
$[31] = t15;
|
|
2233
2273
|
} else {
|
|
2234
|
-
|
|
2274
|
+
t15 = $[31];
|
|
2235
2275
|
}
|
|
2236
|
-
const calendarContainerStyle =
|
|
2237
|
-
let
|
|
2238
|
-
if ($[
|
|
2239
|
-
|
|
2276
|
+
const calendarContainerStyle = t15;
|
|
2277
|
+
let t16;
|
|
2278
|
+
if ($[32] !== calendarAdditionalHeight || $[33] !== calendarDayHeight || $[34] !== calendarMonthHeaderHeight || $[35] !== calendarRowVerticalSpacing || $[36] !== calendarSpacing || $[37] !== calendarWeekHeaderHeight) {
|
|
2279
|
+
t16 = (item) => getHeightForMonth({
|
|
2240
2280
|
calendarMonth: item,
|
|
2241
2281
|
calendarSpacing,
|
|
2242
2282
|
calendarDayHeight,
|
|
@@ -2245,23 +2285,23 @@ function CalendarList(t0) {
|
|
|
2245
2285
|
calendarWeekHeaderHeight,
|
|
2246
2286
|
calendarAdditionalHeight
|
|
2247
2287
|
});
|
|
2248
|
-
$[
|
|
2249
|
-
$[
|
|
2250
|
-
$[
|
|
2251
|
-
$[
|
|
2252
|
-
$[
|
|
2253
|
-
$[
|
|
2254
|
-
$[
|
|
2288
|
+
$[32] = calendarAdditionalHeight;
|
|
2289
|
+
$[33] = calendarDayHeight;
|
|
2290
|
+
$[34] = calendarMonthHeaderHeight;
|
|
2291
|
+
$[35] = calendarRowVerticalSpacing;
|
|
2292
|
+
$[36] = calendarSpacing;
|
|
2293
|
+
$[37] = calendarWeekHeaderHeight;
|
|
2294
|
+
$[38] = t16;
|
|
2255
2295
|
} else {
|
|
2256
|
-
|
|
2296
|
+
t16 = $[38];
|
|
2257
2297
|
}
|
|
2258
|
-
const getFixedItemSize =
|
|
2259
|
-
let
|
|
2260
|
-
if ($[
|
|
2261
|
-
|
|
2298
|
+
const getFixedItemSize = t16;
|
|
2299
|
+
let t17;
|
|
2300
|
+
if ($[39] !== calendarContainerStyle) {
|
|
2301
|
+
t17 = (t182) => {
|
|
2262
2302
|
const {
|
|
2263
2303
|
item: item_0
|
|
2264
|
-
} =
|
|
2304
|
+
} = t182;
|
|
2265
2305
|
return /* @__PURE__ */ _jsx10(View7, {
|
|
2266
2306
|
style: calendarContainerStyle,
|
|
2267
2307
|
children: /* @__PURE__ */ _jsx10(Calendar, __spreadValues({
|
|
@@ -2269,21 +2309,21 @@ function CalendarList(t0) {
|
|
|
2269
2309
|
}, item_0.calendarProps))
|
|
2270
2310
|
});
|
|
2271
2311
|
};
|
|
2272
|
-
$[
|
|
2273
|
-
$[
|
|
2312
|
+
$[39] = calendarContainerStyle;
|
|
2313
|
+
$[40] = t17;
|
|
2274
2314
|
} else {
|
|
2275
|
-
|
|
2315
|
+
t17 = $[40];
|
|
2276
2316
|
}
|
|
2277
|
-
const handleRenderItem =
|
|
2317
|
+
const handleRenderItem = t17;
|
|
2278
2318
|
const handleViewableItemsChanged = _temp;
|
|
2279
|
-
let
|
|
2280
|
-
if ($[
|
|
2281
|
-
|
|
2319
|
+
let t18;
|
|
2320
|
+
if ($[41] !== computedInitialScrollIndex || $[42] !== flatListProps || $[43] !== getFixedItemSize || $[44] !== handleOnEndReached || $[45] !== handleOnStartReached || $[46] !== handleRenderItem || $[47] !== monthListWithCalendarProps) {
|
|
2321
|
+
t18 = /* @__PURE__ */ _jsx10(LegendList, __spreadValues({
|
|
2282
2322
|
data: monthListWithCalendarProps,
|
|
2283
2323
|
drawDistance: 560,
|
|
2284
2324
|
estimatedItemSize: 273,
|
|
2285
2325
|
getFixedItemSize,
|
|
2286
|
-
initialScrollIndex:
|
|
2326
|
+
initialScrollIndex: computedInitialScrollIndex,
|
|
2287
2327
|
keyExtractor,
|
|
2288
2328
|
maintainVisibleContentPosition: true,
|
|
2289
2329
|
onEndReached: handleOnEndReached,
|
|
@@ -2295,18 +2335,18 @@ function CalendarList(t0) {
|
|
|
2295
2335
|
showsVerticalScrollIndicator: false,
|
|
2296
2336
|
style: styles8.container
|
|
2297
2337
|
}, flatListProps));
|
|
2298
|
-
$[
|
|
2299
|
-
$[
|
|
2300
|
-
$[
|
|
2301
|
-
$[
|
|
2302
|
-
$[
|
|
2303
|
-
$[
|
|
2304
|
-
$[
|
|
2305
|
-
$[
|
|
2306
|
-
} else {
|
|
2307
|
-
|
|
2308
|
-
}
|
|
2309
|
-
return
|
|
2338
|
+
$[41] = computedInitialScrollIndex;
|
|
2339
|
+
$[42] = flatListProps;
|
|
2340
|
+
$[43] = getFixedItemSize;
|
|
2341
|
+
$[44] = handleOnEndReached;
|
|
2342
|
+
$[45] = handleOnStartReached;
|
|
2343
|
+
$[46] = handleRenderItem;
|
|
2344
|
+
$[47] = monthListWithCalendarProps;
|
|
2345
|
+
$[48] = t18;
|
|
2346
|
+
} else {
|
|
2347
|
+
t18 = $[48];
|
|
2348
|
+
}
|
|
2349
|
+
return t18;
|
|
2310
2350
|
}
|
|
2311
2351
|
function _temp() {
|
|
2312
2352
|
}
|