@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.js
CHANGED
|
@@ -2023,7 +2023,7 @@ var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
|
2023
2023
|
var LegendList = import_react_native9.LegendList;
|
|
2024
2024
|
var keyExtractor = (month) => month.id;
|
|
2025
2025
|
function CalendarList(t0) {
|
|
2026
|
-
const $ = (0, import_compiler_runtime12.c)(
|
|
2026
|
+
const $ = (0, import_compiler_runtime12.c)(49);
|
|
2027
2027
|
const _a = t0, {
|
|
2028
2028
|
ref
|
|
2029
2029
|
} = _a, props = __objRest(_a, [
|
|
@@ -2031,23 +2031,25 @@ function CalendarList(t0) {
|
|
|
2031
2031
|
]);
|
|
2032
2032
|
const _b = props, {
|
|
2033
2033
|
calendarInitialMonthId,
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2034
|
+
calendarInitialScrollToActiveRange: t1,
|
|
2035
|
+
calendarPastScrollRangeInMonths: t2,
|
|
2036
|
+
calendarFutureScrollRangeInMonths: t3,
|
|
2037
|
+
calendarFirstDayOfWeek: t4,
|
|
2037
2038
|
calendarFormatLocale,
|
|
2038
|
-
calendarSpacing:
|
|
2039
|
+
calendarSpacing: t5,
|
|
2039
2040
|
calendarRowHorizontalSpacing,
|
|
2040
|
-
calendarRowVerticalSpacing:
|
|
2041
|
-
calendarMonthHeaderHeight:
|
|
2042
|
-
calendarDayHeight:
|
|
2043
|
-
calendarWeekHeaderHeight:
|
|
2044
|
-
calendarAdditionalHeight:
|
|
2041
|
+
calendarRowVerticalSpacing: t6,
|
|
2042
|
+
calendarMonthHeaderHeight: t7,
|
|
2043
|
+
calendarDayHeight: t8,
|
|
2044
|
+
calendarWeekHeaderHeight: t9,
|
|
2045
|
+
calendarAdditionalHeight: t10,
|
|
2045
2046
|
calendarColorScheme,
|
|
2046
2047
|
theme,
|
|
2047
2048
|
onEndReached,
|
|
2048
2049
|
onStartReached
|
|
2049
2050
|
} = _b, otherProps = __objRest(_b, [
|
|
2050
2051
|
"calendarInitialMonthId",
|
|
2052
|
+
"calendarInitialScrollToActiveRange",
|
|
2051
2053
|
"calendarPastScrollRangeInMonths",
|
|
2052
2054
|
"calendarFutureScrollRangeInMonths",
|
|
2053
2055
|
"calendarFirstDayOfWeek",
|
|
@@ -2064,15 +2066,16 @@ function CalendarList(t0) {
|
|
|
2064
2066
|
"onEndReached",
|
|
2065
2067
|
"onStartReached"
|
|
2066
2068
|
]);
|
|
2067
|
-
const
|
|
2068
|
-
const
|
|
2069
|
-
const
|
|
2070
|
-
const
|
|
2071
|
-
const
|
|
2072
|
-
const
|
|
2073
|
-
const
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2069
|
+
const calendarInitialScrollToActiveRange = t1 === void 0 ? true : t1;
|
|
2070
|
+
const calendarPastScrollRangeInMonths = t2 === void 0 ? 12 : t2;
|
|
2071
|
+
const calendarFutureScrollRangeInMonths = t3 === void 0 ? 12 : t3;
|
|
2072
|
+
const calendarFirstDayOfWeek = t4 === void 0 ? "sunday" : t4;
|
|
2073
|
+
const calendarSpacing = t5 === void 0 ? 20 : t5;
|
|
2074
|
+
const calendarRowVerticalSpacing = t6 === void 0 ? 8 : t6;
|
|
2075
|
+
const calendarMonthHeaderHeight = t7 === void 0 ? 20 : t7;
|
|
2076
|
+
const calendarDayHeight = t8 === void 0 ? 32 : t8;
|
|
2077
|
+
const calendarWeekHeaderHeight = t9 === void 0 ? calendarDayHeight : t9;
|
|
2078
|
+
const calendarAdditionalHeight = t10 === void 0 ? 0 : t10;
|
|
2076
2079
|
const _c14 = otherProps, {
|
|
2077
2080
|
calendarActiveDateRanges,
|
|
2078
2081
|
calendarDisabledDateIds,
|
|
@@ -2133,50 +2136,87 @@ function CalendarList(t0) {
|
|
|
2133
2136
|
calendarMaxDateId,
|
|
2134
2137
|
calendarMinDateId
|
|
2135
2138
|
});
|
|
2136
|
-
|
|
2139
|
+
let computedInitialScrollIndex = initialMonthIndex;
|
|
2140
|
+
if (calendarInitialScrollToActiveRange && calendarActiveDateRanges) {
|
|
2141
|
+
const firstRange = calendarActiveDateRanges[0];
|
|
2142
|
+
if (firstRange == null ? void 0 : firstRange.startId) {
|
|
2143
|
+
let t112;
|
|
2144
|
+
if ($[0] !== firstRange.startId) {
|
|
2145
|
+
const startDate = fromDateId(firstRange.startId);
|
|
2146
|
+
t112 = toDateId(startOfMonth(startDate));
|
|
2147
|
+
$[0] = firstRange.startId;
|
|
2148
|
+
$[1] = t112;
|
|
2149
|
+
} else {
|
|
2150
|
+
t112 = $[1];
|
|
2151
|
+
}
|
|
2152
|
+
const monthId = t112;
|
|
2153
|
+
let t122;
|
|
2154
|
+
if ($[2] !== monthId || $[3] !== monthList) {
|
|
2155
|
+
let t132;
|
|
2156
|
+
if ($[5] !== monthId) {
|
|
2157
|
+
t132 = (month) => month.id === monthId;
|
|
2158
|
+
$[5] = monthId;
|
|
2159
|
+
$[6] = t132;
|
|
2160
|
+
} else {
|
|
2161
|
+
t132 = $[6];
|
|
2162
|
+
}
|
|
2163
|
+
t122 = monthList.findIndex(t132);
|
|
2164
|
+
$[2] = monthId;
|
|
2165
|
+
$[3] = monthList;
|
|
2166
|
+
$[4] = t122;
|
|
2167
|
+
} else {
|
|
2168
|
+
t122 = $[4];
|
|
2169
|
+
}
|
|
2170
|
+
const monthIndex = t122;
|
|
2171
|
+
if (monthIndex !== -1) {
|
|
2172
|
+
computedInitialScrollIndex = monthIndex;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
const monthListWithCalendarProps = monthList.map((month_0) => __spreadProps(__spreadValues({}, month_0), {
|
|
2137
2177
|
calendarProps
|
|
2138
2178
|
}));
|
|
2139
|
-
let
|
|
2140
|
-
if ($[
|
|
2141
|
-
|
|
2179
|
+
let t11;
|
|
2180
|
+
if ($[7] !== appendMonths || $[8] !== calendarFutureScrollRangeInMonths || $[9] !== onEndReached) {
|
|
2181
|
+
t11 = (info) => {
|
|
2142
2182
|
appendMonths(calendarFutureScrollRangeInMonths);
|
|
2143
2183
|
onEndReached == null ? void 0 : onEndReached(info);
|
|
2144
2184
|
};
|
|
2145
|
-
$[
|
|
2146
|
-
$[
|
|
2147
|
-
$[
|
|
2148
|
-
$[
|
|
2185
|
+
$[7] = appendMonths;
|
|
2186
|
+
$[8] = calendarFutureScrollRangeInMonths;
|
|
2187
|
+
$[9] = onEndReached;
|
|
2188
|
+
$[10] = t11;
|
|
2149
2189
|
} else {
|
|
2150
|
-
|
|
2190
|
+
t11 = $[10];
|
|
2151
2191
|
}
|
|
2152
|
-
const handleOnEndReached =
|
|
2153
|
-
let
|
|
2154
|
-
if ($[
|
|
2155
|
-
|
|
2192
|
+
const handleOnEndReached = t11;
|
|
2193
|
+
let t12;
|
|
2194
|
+
if ($[11] !== calendarPastScrollRangeInMonths || $[12] !== onStartReached || $[13] !== prependMonths) {
|
|
2195
|
+
t12 = (info_0) => {
|
|
2156
2196
|
prependMonths(calendarPastScrollRangeInMonths);
|
|
2157
2197
|
onStartReached == null ? void 0 : onStartReached(info_0);
|
|
2158
2198
|
};
|
|
2159
|
-
$[
|
|
2160
|
-
$[
|
|
2161
|
-
$[
|
|
2162
|
-
$[
|
|
2199
|
+
$[11] = calendarPastScrollRangeInMonths;
|
|
2200
|
+
$[12] = onStartReached;
|
|
2201
|
+
$[13] = prependMonths;
|
|
2202
|
+
$[14] = t12;
|
|
2163
2203
|
} else {
|
|
2164
|
-
|
|
2204
|
+
t12 = $[14];
|
|
2165
2205
|
}
|
|
2166
|
-
const handleOnStartReached =
|
|
2167
|
-
let
|
|
2168
|
-
if ($[
|
|
2169
|
-
|
|
2170
|
-
const
|
|
2206
|
+
const handleOnStartReached = t12;
|
|
2207
|
+
let t13;
|
|
2208
|
+
if ($[15] !== addMissingMonths || $[16] !== calendarAdditionalHeight || $[17] !== calendarDayHeight || $[18] !== calendarMonthHeaderHeight || $[19] !== calendarRowVerticalSpacing || $[20] !== calendarSpacing || $[21] !== calendarWeekHeaderHeight || $[22] !== monthList) {
|
|
2209
|
+
t13 = (date) => {
|
|
2210
|
+
const monthId_0 = toDateId(startOfMonth(date));
|
|
2171
2211
|
let baseMonthList = monthList;
|
|
2172
|
-
let index = baseMonthList.findIndex((
|
|
2212
|
+
let index = baseMonthList.findIndex((month_1) => month_1.id === monthId_0);
|
|
2173
2213
|
if (index === -1) {
|
|
2174
|
-
baseMonthList = addMissingMonths(
|
|
2175
|
-
index = baseMonthList.findIndex((
|
|
2214
|
+
baseMonthList = addMissingMonths(monthId_0);
|
|
2215
|
+
index = baseMonthList.findIndex((month_2) => month_2.id === monthId_0);
|
|
2176
2216
|
}
|
|
2177
|
-
return baseMonthList.slice(0, index).reduce((acc,
|
|
2217
|
+
return baseMonthList.slice(0, index).reduce((acc, month_3) => {
|
|
2178
2218
|
const currentHeight = getHeightForMonth({
|
|
2179
|
-
calendarMonth:
|
|
2219
|
+
calendarMonth: month_3,
|
|
2180
2220
|
calendarSpacing,
|
|
2181
2221
|
calendarDayHeight,
|
|
2182
2222
|
calendarMonthHeaderHeight,
|
|
@@ -2187,30 +2227,30 @@ function CalendarList(t0) {
|
|
|
2187
2227
|
return acc + currentHeight;
|
|
2188
2228
|
}, 0);
|
|
2189
2229
|
};
|
|
2190
|
-
$[
|
|
2191
|
-
$[
|
|
2192
|
-
$[
|
|
2193
|
-
$[
|
|
2194
|
-
$[
|
|
2195
|
-
$[
|
|
2196
|
-
$[
|
|
2197
|
-
$[
|
|
2198
|
-
$[
|
|
2199
|
-
} else {
|
|
2200
|
-
|
|
2201
|
-
}
|
|
2202
|
-
const getScrollOffsetForMonth =
|
|
2230
|
+
$[15] = addMissingMonths;
|
|
2231
|
+
$[16] = calendarAdditionalHeight;
|
|
2232
|
+
$[17] = calendarDayHeight;
|
|
2233
|
+
$[18] = calendarMonthHeaderHeight;
|
|
2234
|
+
$[19] = calendarRowVerticalSpacing;
|
|
2235
|
+
$[20] = calendarSpacing;
|
|
2236
|
+
$[21] = calendarWeekHeaderHeight;
|
|
2237
|
+
$[22] = monthList;
|
|
2238
|
+
$[23] = t13;
|
|
2239
|
+
} else {
|
|
2240
|
+
t13 = $[23];
|
|
2241
|
+
}
|
|
2242
|
+
const getScrollOffsetForMonth = t13;
|
|
2203
2243
|
const legendListRef = (0, import_react11.useRef)(null);
|
|
2204
|
-
let
|
|
2205
|
-
if ($[
|
|
2206
|
-
|
|
2207
|
-
scrollToMonth(date_0, animated,
|
|
2244
|
+
let t14;
|
|
2245
|
+
if ($[24] !== calendarDayHeight || $[25] !== calendarFirstDayOfWeek || $[26] !== calendarRowVerticalSpacing || $[27] !== calendarWeekHeaderHeight || $[28] !== getScrollOffsetForMonth) {
|
|
2246
|
+
t14 = () => ({
|
|
2247
|
+
scrollToMonth(date_0, animated, t152) {
|
|
2208
2248
|
const {
|
|
2209
|
-
additionalOffset:
|
|
2210
|
-
} =
|
|
2249
|
+
additionalOffset: t162
|
|
2250
|
+
} = t152 === void 0 ? {
|
|
2211
2251
|
additionalOffset: 0
|
|
2212
|
-
} :
|
|
2213
|
-
const additionalOffset =
|
|
2252
|
+
} : t152;
|
|
2253
|
+
const additionalOffset = t162 === void 0 ? 0 : t162;
|
|
2214
2254
|
setTimeout(() => {
|
|
2215
2255
|
var _a2;
|
|
2216
2256
|
(_a2 = legendListRef.current) == null ? void 0 : _a2.scrollToOffset({
|
|
@@ -2219,14 +2259,14 @@ function CalendarList(t0) {
|
|
|
2219
2259
|
});
|
|
2220
2260
|
}, 0);
|
|
2221
2261
|
},
|
|
2222
|
-
scrollToDate(date_1, animated_0,
|
|
2262
|
+
scrollToDate(date_1, animated_0, t172) {
|
|
2223
2263
|
var _a2;
|
|
2224
2264
|
const {
|
|
2225
|
-
additionalOffset:
|
|
2226
|
-
} =
|
|
2265
|
+
additionalOffset: t182
|
|
2266
|
+
} = t172 === void 0 ? {
|
|
2227
2267
|
additionalOffset: 0
|
|
2228
|
-
} :
|
|
2229
|
-
const additionalOffset_0 =
|
|
2268
|
+
} : t172;
|
|
2269
|
+
const additionalOffset_0 = t182 === void 0 ? 0 : t182;
|
|
2230
2270
|
const currentMonthOffset = getScrollOffsetForMonth(date_1);
|
|
2231
2271
|
const weekOfMonthIndex = getWeekOfMonth(date_1, calendarFirstDayOfWeek);
|
|
2232
2272
|
const rowHeight = calendarDayHeight + calendarRowVerticalSpacing;
|
|
@@ -2245,30 +2285,30 @@ function CalendarList(t0) {
|
|
|
2245
2285
|
});
|
|
2246
2286
|
}
|
|
2247
2287
|
});
|
|
2248
|
-
$[
|
|
2249
|
-
$[
|
|
2250
|
-
$[
|
|
2251
|
-
$[
|
|
2252
|
-
$[
|
|
2253
|
-
$[
|
|
2288
|
+
$[24] = calendarDayHeight;
|
|
2289
|
+
$[25] = calendarFirstDayOfWeek;
|
|
2290
|
+
$[26] = calendarRowVerticalSpacing;
|
|
2291
|
+
$[27] = calendarWeekHeaderHeight;
|
|
2292
|
+
$[28] = getScrollOffsetForMonth;
|
|
2293
|
+
$[29] = t14;
|
|
2254
2294
|
} else {
|
|
2255
|
-
|
|
2295
|
+
t14 = $[29];
|
|
2256
2296
|
}
|
|
2257
|
-
(0, import_react11.useImperativeHandle)(ref,
|
|
2258
|
-
let
|
|
2259
|
-
if ($[
|
|
2260
|
-
|
|
2297
|
+
(0, import_react11.useImperativeHandle)(ref, t14);
|
|
2298
|
+
let t15;
|
|
2299
|
+
if ($[30] !== calendarSpacing) {
|
|
2300
|
+
t15 = {
|
|
2261
2301
|
paddingBottom: calendarSpacing
|
|
2262
2302
|
};
|
|
2263
|
-
$[
|
|
2264
|
-
$[
|
|
2303
|
+
$[30] = calendarSpacing;
|
|
2304
|
+
$[31] = t15;
|
|
2265
2305
|
} else {
|
|
2266
|
-
|
|
2306
|
+
t15 = $[31];
|
|
2267
2307
|
}
|
|
2268
|
-
const calendarContainerStyle =
|
|
2269
|
-
let
|
|
2270
|
-
if ($[
|
|
2271
|
-
|
|
2308
|
+
const calendarContainerStyle = t15;
|
|
2309
|
+
let t16;
|
|
2310
|
+
if ($[32] !== calendarAdditionalHeight || $[33] !== calendarDayHeight || $[34] !== calendarMonthHeaderHeight || $[35] !== calendarRowVerticalSpacing || $[36] !== calendarSpacing || $[37] !== calendarWeekHeaderHeight) {
|
|
2311
|
+
t16 = (item) => getHeightForMonth({
|
|
2272
2312
|
calendarMonth: item,
|
|
2273
2313
|
calendarSpacing,
|
|
2274
2314
|
calendarDayHeight,
|
|
@@ -2277,23 +2317,23 @@ function CalendarList(t0) {
|
|
|
2277
2317
|
calendarWeekHeaderHeight,
|
|
2278
2318
|
calendarAdditionalHeight
|
|
2279
2319
|
});
|
|
2280
|
-
$[
|
|
2281
|
-
$[
|
|
2282
|
-
$[
|
|
2283
|
-
$[
|
|
2284
|
-
$[
|
|
2285
|
-
$[
|
|
2286
|
-
$[
|
|
2320
|
+
$[32] = calendarAdditionalHeight;
|
|
2321
|
+
$[33] = calendarDayHeight;
|
|
2322
|
+
$[34] = calendarMonthHeaderHeight;
|
|
2323
|
+
$[35] = calendarRowVerticalSpacing;
|
|
2324
|
+
$[36] = calendarSpacing;
|
|
2325
|
+
$[37] = calendarWeekHeaderHeight;
|
|
2326
|
+
$[38] = t16;
|
|
2287
2327
|
} else {
|
|
2288
|
-
|
|
2328
|
+
t16 = $[38];
|
|
2289
2329
|
}
|
|
2290
|
-
const getFixedItemSize =
|
|
2291
|
-
let
|
|
2292
|
-
if ($[
|
|
2293
|
-
|
|
2330
|
+
const getFixedItemSize = t16;
|
|
2331
|
+
let t17;
|
|
2332
|
+
if ($[39] !== calendarContainerStyle) {
|
|
2333
|
+
t17 = (t182) => {
|
|
2294
2334
|
const {
|
|
2295
2335
|
item: item_0
|
|
2296
|
-
} =
|
|
2336
|
+
} = t182;
|
|
2297
2337
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, {
|
|
2298
2338
|
style: calendarContainerStyle,
|
|
2299
2339
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Calendar, __spreadValues({
|
|
@@ -2301,21 +2341,21 @@ function CalendarList(t0) {
|
|
|
2301
2341
|
}, item_0.calendarProps))
|
|
2302
2342
|
});
|
|
2303
2343
|
};
|
|
2304
|
-
$[
|
|
2305
|
-
$[
|
|
2344
|
+
$[39] = calendarContainerStyle;
|
|
2345
|
+
$[40] = t17;
|
|
2306
2346
|
} else {
|
|
2307
|
-
|
|
2347
|
+
t17 = $[40];
|
|
2308
2348
|
}
|
|
2309
|
-
const handleRenderItem =
|
|
2349
|
+
const handleRenderItem = t17;
|
|
2310
2350
|
const handleViewableItemsChanged = _temp;
|
|
2311
|
-
let
|
|
2312
|
-
if ($[
|
|
2313
|
-
|
|
2351
|
+
let t18;
|
|
2352
|
+
if ($[41] !== computedInitialScrollIndex || $[42] !== flatListProps || $[43] !== getFixedItemSize || $[44] !== handleOnEndReached || $[45] !== handleOnStartReached || $[46] !== handleRenderItem || $[47] !== monthListWithCalendarProps) {
|
|
2353
|
+
t18 = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LegendList, __spreadValues({
|
|
2314
2354
|
data: monthListWithCalendarProps,
|
|
2315
2355
|
drawDistance: 560,
|
|
2316
2356
|
estimatedItemSize: 273,
|
|
2317
2357
|
getFixedItemSize,
|
|
2318
|
-
initialScrollIndex:
|
|
2358
|
+
initialScrollIndex: computedInitialScrollIndex,
|
|
2319
2359
|
keyExtractor,
|
|
2320
2360
|
maintainVisibleContentPosition: true,
|
|
2321
2361
|
onEndReached: handleOnEndReached,
|
|
@@ -2327,18 +2367,18 @@ function CalendarList(t0) {
|
|
|
2327
2367
|
showsVerticalScrollIndicator: false,
|
|
2328
2368
|
style: styles8.container
|
|
2329
2369
|
}, flatListProps));
|
|
2330
|
-
$[
|
|
2331
|
-
$[
|
|
2332
|
-
$[
|
|
2333
|
-
$[
|
|
2334
|
-
$[
|
|
2335
|
-
$[
|
|
2336
|
-
$[
|
|
2337
|
-
$[
|
|
2338
|
-
} else {
|
|
2339
|
-
|
|
2340
|
-
}
|
|
2341
|
-
return
|
|
2370
|
+
$[41] = computedInitialScrollIndex;
|
|
2371
|
+
$[42] = flatListProps;
|
|
2372
|
+
$[43] = getFixedItemSize;
|
|
2373
|
+
$[44] = handleOnEndReached;
|
|
2374
|
+
$[45] = handleOnStartReached;
|
|
2375
|
+
$[46] = handleRenderItem;
|
|
2376
|
+
$[47] = monthListWithCalendarProps;
|
|
2377
|
+
$[48] = t18;
|
|
2378
|
+
} else {
|
|
2379
|
+
t18 = $[48];
|
|
2380
|
+
}
|
|
2381
|
+
return t18;
|
|
2342
2382
|
}
|
|
2343
2383
|
function _temp() {
|
|
2344
2384
|
}
|