@lazerlen/legend-calendar 1.1.1 → 1.2.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/dist/index.js CHANGED
@@ -562,9 +562,7 @@ var buildBaseStyles = (theme) => {
562
562
  return {
563
563
  active: ({
564
564
  isPressed,
565
- isHovered,
566
- isStartOfRange,
567
- isEndOfRange
565
+ isHovered
568
566
  }) => {
569
567
  const baseStyles = isPressed || isHovered ? {
570
568
  container: __spreadProps(__spreadValues({}, styles.baseContainer), {
@@ -581,18 +579,6 @@ var buildBaseStyles = (theme) => {
581
579
  color: theme.colors.content.inverse.primary
582
580
  })
583
581
  };
584
- baseStyles.container.borderRadius = 0;
585
- if (isStartOfRange) {
586
- baseStyles.container.borderTopLeftRadius = 16;
587
- baseStyles.container.borderBottomLeftRadius = 16;
588
- }
589
- if (isEndOfRange) {
590
- baseStyles.container.borderTopRightRadius = 16;
591
- baseStyles.container.borderBottomRightRadius = 16;
592
- }
593
- if (!isStartOfRange && !isEndOfRange) {
594
- baseStyles.container.borderRadius = 0;
595
- }
596
582
  return baseStyles;
597
583
  },
598
584
  disabled: () => ({
@@ -675,7 +661,7 @@ var CalendarItemDay = /* @__PURE__ */ (0, import_react4.memo)(function CalendarI
675
661
  let t5;
676
662
  if ($[5] !== baseStyles || $[6] !== height || $[7] !== metadata || $[8] !== theme) {
677
663
  t5 = (t62) => {
678
- var _a, _b, _c14, _d;
664
+ var _a, _b, _c14, _d, _e;
679
665
  const {
680
666
  pressed: isPressed,
681
667
  hovered: isHovered,
@@ -691,13 +677,50 @@ var CalendarItemDay = /* @__PURE__ */ (0, import_react4.memo)(function CalendarI
691
677
  const {
692
678
  container
693
679
  } = baseStyles[metadata.state](params);
694
- return __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, container), {
695
- height
696
- }), (_c14 = theme == null ? void 0 : theme.base) == null ? void 0 : _c14.call(theme, __spreadProps(__spreadValues({}, metadata), {
680
+ const baseThemeContainer = (_c14 = theme == null ? void 0 : theme.base) == null ? void 0 : _c14.call(theme, __spreadProps(__spreadValues({}, metadata), {
697
681
  isPressed
698
- })).container), (_d = theme == null ? void 0 : theme[metadata.state]) == null ? void 0 : _d.call(theme, __spreadProps(__spreadValues({}, metadata), {
682
+ })).container;
683
+ const stateThemeContainer = (_d = theme == null ? void 0 : theme[metadata.state]) == null ? void 0 : _d.call(theme, __spreadProps(__spreadValues({}, metadata), {
699
684
  isPressed
700
- })).container);
685
+ })).container;
686
+ const mergedContainer = __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, container), {
687
+ height
688
+ }), baseThemeContainer), stateThemeContainer);
689
+ if (metadata.state === "active") {
690
+ const hasCustomRadius = (baseThemeContainer == null ? void 0 : baseThemeContainer.borderRadius) !== void 0 || (baseThemeContainer == null ? void 0 : baseThemeContainer.borderTopLeftRadius) !== void 0 || (baseThemeContainer == null ? void 0 : baseThemeContainer.borderBottomLeftRadius) !== void 0 || (baseThemeContainer == null ? void 0 : baseThemeContainer.borderTopRightRadius) !== void 0 || (baseThemeContainer == null ? void 0 : baseThemeContainer.borderBottomRightRadius) !== void 0 || (stateThemeContainer == null ? void 0 : stateThemeContainer.borderRadius) !== void 0 || (stateThemeContainer == null ? void 0 : stateThemeContainer.borderTopLeftRadius) !== void 0 || (stateThemeContainer == null ? void 0 : stateThemeContainer.borderBottomLeftRadius) !== void 0 || (stateThemeContainer == null ? void 0 : stateThemeContainer.borderTopRightRadius) !== void 0 || (stateThemeContainer == null ? void 0 : stateThemeContainer.borderBottomRightRadius) !== void 0;
691
+ if (!hasCustomRadius) {
692
+ const defaultRadius = (_e = styles.baseContainer.borderRadius) != null ? _e : 0;
693
+ mergedContainer.borderRadius = 0;
694
+ if (metadata.isStartOfRange) {
695
+ mergedContainer.borderTopLeftRadius = defaultRadius;
696
+ mergedContainer.borderBottomLeftRadius = defaultRadius;
697
+ }
698
+ if (metadata.isEndOfRange) {
699
+ mergedContainer.borderTopRightRadius = defaultRadius;
700
+ mergedContainer.borderBottomRightRadius = defaultRadius;
701
+ }
702
+ if (!metadata.isStartOfRange && !metadata.isEndOfRange) {
703
+ mergedContainer.borderRadius = 0;
704
+ }
705
+ } else {
706
+ if (mergedContainer.borderRadius !== void 0) {
707
+ const radius = mergedContainer.borderRadius;
708
+ if (metadata.isStartOfRange && mergedContainer.borderTopLeftRadius === void 0) {
709
+ mergedContainer.borderTopLeftRadius = radius;
710
+ }
711
+ if (metadata.isStartOfRange && mergedContainer.borderBottomLeftRadius === void 0) {
712
+ mergedContainer.borderBottomLeftRadius = radius;
713
+ }
714
+ if (metadata.isEndOfRange && mergedContainer.borderTopRightRadius === void 0) {
715
+ mergedContainer.borderTopRightRadius = radius;
716
+ }
717
+ if (metadata.isEndOfRange && mergedContainer.borderBottomRightRadius === void 0) {
718
+ mergedContainer.borderBottomRightRadius = radius;
719
+ }
720
+ }
721
+ }
722
+ }
723
+ return mergedContainer;
701
724
  };
702
725
  $[5] = baseStyles;
703
726
  $[6] = height;
@@ -768,7 +791,7 @@ var CalendarItemDay = /* @__PURE__ */ (0, import_react4.memo)(function CalendarI
768
791
  return t7;
769
792
  });
770
793
  var CalendarItemDayContainer = /* @__PURE__ */ (0, import_react4.memo)(function CalendarItemDayContainer2(t0) {
771
- const $ = (0, import_compiler_runtime3.c)(16);
794
+ const $ = (0, import_compiler_runtime3.c)(21);
772
795
  const {
773
796
  children,
774
797
  isStartOfWeek,
@@ -779,27 +802,44 @@ var CalendarItemDayContainer = /* @__PURE__ */ (0, import_react4.memo)(function
779
802
  metadata
780
803
  } = t0;
781
804
  const baseTheme = useTheme();
782
- const t1 = isStartOfWeek ? 0 : daySpacing;
783
- const t2 = theme == null ? void 0 : theme.spacer;
805
+ let t1;
806
+ if ($[0] !== metadata || $[1] !== theme) {
807
+ t1 = typeof (theme == null ? void 0 : theme.spacer) === "function" && metadata ? theme.spacer(metadata) : theme == null ? void 0 : theme.spacer;
808
+ $[0] = metadata;
809
+ $[1] = theme;
810
+ $[2] = t1;
811
+ } else {
812
+ t1 = $[2];
813
+ }
814
+ const spacerTheme = t1;
815
+ const t2 = isStartOfWeek ? 0 : daySpacing;
784
816
  let t3;
785
- if ($[0] !== dayHeight || $[1] !== t1 || $[2] !== t2) {
786
- t3 = __spreadValues({
817
+ if ($[3] !== spacerTheme) {
818
+ t3 = spacerTheme != null ? spacerTheme : {};
819
+ $[3] = spacerTheme;
820
+ $[4] = t3;
821
+ } else {
822
+ t3 = $[4];
823
+ }
824
+ let t4;
825
+ if ($[5] !== dayHeight || $[6] !== t2 || $[7] !== t3) {
826
+ t4 = __spreadValues({
787
827
  position: "relative",
788
- marginLeft: t1,
828
+ marginLeft: t2,
789
829
  flex: 1,
790
830
  height: dayHeight
791
- }, t2);
792
- $[0] = dayHeight;
793
- $[1] = t1;
794
- $[2] = t2;
795
- $[3] = t3;
831
+ }, t3);
832
+ $[5] = dayHeight;
833
+ $[6] = t2;
834
+ $[7] = t3;
835
+ $[8] = t4;
796
836
  } else {
797
- t3 = $[3];
837
+ t4 = $[8];
798
838
  }
799
- const spacerStyles = t3;
800
- let t4;
801
- if ($[4] !== baseTheme || $[5] !== daySpacing || $[6] !== metadata || $[7] !== shouldShowActiveDayFiller || $[8] !== theme) {
802
- t4 = !shouldShowActiveDayFiller ? null : __spreadValues({
839
+ const spacerStyles = t4;
840
+ let t5;
841
+ if ($[9] !== baseTheme || $[10] !== daySpacing || $[11] !== metadata || $[12] !== shouldShowActiveDayFiller || $[13] !== theme) {
842
+ t5 = !shouldShowActiveDayFiller ? null : __spreadValues({
803
843
  position: "absolute",
804
844
  top: 0,
805
845
  bottom: 0,
@@ -807,40 +847,40 @@ var CalendarItemDayContainer = /* @__PURE__ */ (0, import_react4.memo)(function
807
847
  width: daySpacing + 2,
808
848
  backgroundColor: baseTheme.colors.background.inverse.primary
809
849
  }, typeof (theme == null ? void 0 : theme.activeDayFiller) === "function" && !!metadata ? theme.activeDayFiller(metadata) : theme == null ? void 0 : theme.activeDayFiller);
810
- $[4] = baseTheme;
811
- $[5] = daySpacing;
812
- $[6] = metadata;
813
- $[7] = shouldShowActiveDayFiller;
814
- $[8] = theme;
815
- $[9] = t4;
850
+ $[9] = baseTheme;
851
+ $[10] = daySpacing;
852
+ $[11] = metadata;
853
+ $[12] = shouldShowActiveDayFiller;
854
+ $[13] = theme;
855
+ $[14] = t5;
816
856
  } else {
817
- t4 = $[9];
857
+ t5 = $[14];
818
858
  }
819
- const activeDayFiller = t4;
820
- let t5;
821
- if ($[10] !== activeDayFiller) {
822
- t5 = activeDayFiller ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, {
859
+ const activeDayFiller = t5;
860
+ let t6;
861
+ if ($[15] !== activeDayFiller) {
862
+ t6 = activeDayFiller ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, {
823
863
  style: activeDayFiller
824
864
  }) : null;
825
- $[10] = activeDayFiller;
826
- $[11] = t5;
865
+ $[15] = activeDayFiller;
866
+ $[16] = t6;
827
867
  } else {
828
- t5 = $[11];
868
+ t6 = $[16];
829
869
  }
830
- let t6;
831
- if ($[12] !== children || $[13] !== spacerStyles || $[14] !== t5) {
832
- t6 = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, {
870
+ let t7;
871
+ if ($[17] !== children || $[18] !== spacerStyles || $[19] !== t6) {
872
+ t7 = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, {
833
873
  style: spacerStyles,
834
- children: [t5, children]
874
+ children: [t6, children]
835
875
  });
836
- $[12] = children;
837
- $[13] = spacerStyles;
838
- $[14] = t5;
839
- $[15] = t6;
876
+ $[17] = children;
877
+ $[18] = spacerStyles;
878
+ $[19] = t6;
879
+ $[20] = t7;
840
880
  } else {
841
- t6 = $[15];
881
+ t7 = $[20];
842
882
  }
843
- return t6;
883
+ return t7;
844
884
  });
845
885
  var CalendarItemDayWithContainer = /* @__PURE__ */ (0, import_react4.memo)(function CalendarItemDayWithContainer2(t0) {
846
886
  const $ = (0, import_compiler_runtime3.c)(14);
@@ -1946,8 +1986,8 @@ var getHeightForMonth = ({
1946
1986
  var import_jsx_runtime10 = require("react/jsx-runtime");
1947
1987
  var LegendList = import_react_native9.LegendList;
1948
1988
  var keyExtractor = (month) => month.id;
1949
- var CalendarList = /* @__PURE__ */ (0, import_react11.memo)(function CalendarList2(t0) {
1950
- const $ = (0, import_compiler_runtime12.c)(32);
1989
+ function CalendarList(t0) {
1990
+ const $ = (0, import_compiler_runtime12.c)(42);
1951
1991
  const _a = t0, {
1952
1992
  ref
1953
1993
  } = _a, props = __objRest(_a, [
@@ -2143,14 +2183,14 @@ var CalendarList = /* @__PURE__ */ (0, import_react11.memo)(function CalendarLis
2143
2183
  });
2144
2184
  }, 0);
2145
2185
  },
2146
- scrollToDate(date_1, animated_0, t16) {
2186
+ scrollToDate(date_1, animated_0, t162) {
2147
2187
  var _a2;
2148
2188
  const {
2149
- additionalOffset: t17
2150
- } = t16 === void 0 ? {
2189
+ additionalOffset: t172
2190
+ } = t162 === void 0 ? {
2151
2191
  additionalOffset: 0
2152
- } : t16;
2153
- const additionalOffset_0 = t17 === void 0 ? 0 : t17;
2192
+ } : t162;
2193
+ const additionalOffset_0 = t172 === void 0 ? 0 : t172;
2154
2194
  const currentMonthOffset = getScrollOffsetForMonth(date_1);
2155
2195
  const weekOfMonthIndex = getWeekOfMonth(date_1, calendarFirstDayOfWeek);
2156
2196
  const rowHeight = calendarDayHeight + calendarRowVerticalSpacing;
@@ -2181,54 +2221,91 @@ var CalendarList = /* @__PURE__ */ (0, import_react11.memo)(function CalendarLis
2181
2221
  (0, import_react11.useImperativeHandle)(ref, t13);
2182
2222
  let t14;
2183
2223
  if ($[23] !== calendarSpacing) {
2184
- const calendarContainerStyle = {
2224
+ t14 = {
2185
2225
  paddingBottom: calendarSpacing
2186
2226
  };
2187
- t14 = (t152) => {
2227
+ $[23] = calendarSpacing;
2228
+ $[24] = t14;
2229
+ } else {
2230
+ t14 = $[24];
2231
+ }
2232
+ const calendarContainerStyle = t14;
2233
+ let t15;
2234
+ if ($[25] !== calendarAdditionalHeight || $[26] !== calendarDayHeight || $[27] !== calendarMonthHeaderHeight || $[28] !== calendarRowVerticalSpacing || $[29] !== calendarSpacing || $[30] !== calendarWeekHeaderHeight) {
2235
+ t15 = (item) => getHeightForMonth({
2236
+ calendarMonth: item,
2237
+ calendarSpacing,
2238
+ calendarDayHeight,
2239
+ calendarMonthHeaderHeight,
2240
+ calendarRowVerticalSpacing,
2241
+ calendarWeekHeaderHeight,
2242
+ calendarAdditionalHeight
2243
+ });
2244
+ $[25] = calendarAdditionalHeight;
2245
+ $[26] = calendarDayHeight;
2246
+ $[27] = calendarMonthHeaderHeight;
2247
+ $[28] = calendarRowVerticalSpacing;
2248
+ $[29] = calendarSpacing;
2249
+ $[30] = calendarWeekHeaderHeight;
2250
+ $[31] = t15;
2251
+ } else {
2252
+ t15 = $[31];
2253
+ }
2254
+ const getFixedItemSize = t15;
2255
+ let t16;
2256
+ if ($[32] !== calendarContainerStyle) {
2257
+ t16 = (t172) => {
2188
2258
  const {
2189
- item
2190
- } = t152;
2259
+ item: item_0
2260
+ } = t172;
2191
2261
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native10.View, {
2192
2262
  style: calendarContainerStyle,
2193
2263
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Calendar, __spreadValues({
2194
- calendarMonthId: item.id
2195
- }, item.calendarProps))
2264
+ calendarMonthId: item_0.id
2265
+ }, item_0.calendarProps))
2196
2266
  });
2197
2267
  };
2198
- $[23] = calendarSpacing;
2199
- $[24] = t14;
2268
+ $[32] = calendarContainerStyle;
2269
+ $[33] = t16;
2200
2270
  } else {
2201
- t14 = $[24];
2271
+ t16 = $[33];
2202
2272
  }
2203
- const handleRenderItem = t14;
2204
- let t15;
2205
- if ($[25] !== flatListProps || $[26] !== handleOnEndReached || $[27] !== handleOnStartReached || $[28] !== handleRenderItem || $[29] !== initialMonthIndex || $[30] !== monthListWithCalendarProps) {
2206
- t15 = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LegendList, __spreadValues({
2273
+ const handleRenderItem = t16;
2274
+ const handleViewableItemsChanged = _temp;
2275
+ let t17;
2276
+ if ($[34] !== flatListProps || $[35] !== getFixedItemSize || $[36] !== handleOnEndReached || $[37] !== handleOnStartReached || $[38] !== handleRenderItem || $[39] !== initialMonthIndex || $[40] !== monthListWithCalendarProps) {
2277
+ t17 = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LegendList, __spreadValues({
2207
2278
  data: monthListWithCalendarProps,
2279
+ drawDistance: 560,
2208
2280
  estimatedItemSize: 273,
2281
+ getFixedItemSize,
2209
2282
  initialScrollIndex: initialMonthIndex,
2210
2283
  keyExtractor,
2211
2284
  maintainVisibleContentPosition: true,
2212
2285
  onEndReached: handleOnEndReached,
2213
2286
  onStartReached: handleOnStartReached,
2287
+ onViewableItemsChanged: handleViewableItemsChanged,
2214
2288
  recycleItems: true,
2215
2289
  ref: legendListRef,
2216
2290
  renderItem: handleRenderItem,
2217
2291
  showsVerticalScrollIndicator: false,
2218
2292
  style: styles8.container
2219
2293
  }, flatListProps));
2220
- $[25] = flatListProps;
2221
- $[26] = handleOnEndReached;
2222
- $[27] = handleOnStartReached;
2223
- $[28] = handleRenderItem;
2224
- $[29] = initialMonthIndex;
2225
- $[30] = monthListWithCalendarProps;
2226
- $[31] = t15;
2294
+ $[34] = flatListProps;
2295
+ $[35] = getFixedItemSize;
2296
+ $[36] = handleOnEndReached;
2297
+ $[37] = handleOnStartReached;
2298
+ $[38] = handleRenderItem;
2299
+ $[39] = initialMonthIndex;
2300
+ $[40] = monthListWithCalendarProps;
2301
+ $[41] = t17;
2227
2302
  } else {
2228
- t15 = $[31];
2303
+ t17 = $[41];
2229
2304
  }
2230
- return t15;
2231
- });
2305
+ return t17;
2306
+ }
2307
+ function _temp() {
2308
+ }
2232
2309
  var styles8 = import_react_native10.StyleSheet.create({
2233
2310
  container: {
2234
2311
  flex: 1