@hero-design/rn 8.104.1-alpha.2 → 8.104.1-alpha.3

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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +8 -0
  3. package/es/index.js +162 -118
  4. package/lib/index.js +162 -118
  5. package/package.json +1 -1
  6. package/src/components/Calendar/CalendarRange.tsx +35 -117
  7. package/src/components/Calendar/__tests__/helper.spec.ts +197 -0
  8. package/src/components/Calendar/constants.ts +9 -0
  9. package/src/components/Calendar/helpers.ts +112 -0
  10. package/src/components/Calendar/index.tsx +34 -159
  11. package/src/components/Calendar/shared/hooks/useCalendarLayout.ts +37 -0
  12. package/src/components/Calendar/types.ts +62 -0
  13. package/src/components/DatePicker/DatePickerCalendar.tsx +2 -1
  14. package/src/components/Typography/Body/StyledBody.tsx +2 -2
  15. package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
  16. package/src/components/Typography/Body/__tests__/index.spec.tsx +1 -0
  17. package/src/components/Typography/Body/index.tsx +2 -13
  18. package/src/components/Typography/Caption/StyledCaption.tsx +2 -2
  19. package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +50 -0
  20. package/src/components/Typography/Caption/__tests__/index.spec.tsx +1 -0
  21. package/src/components/Typography/Caption/index.tsx +2 -13
  22. package/src/components/Typography/Label/StyledLabel.tsx +2 -2
  23. package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +48 -0
  24. package/src/components/Typography/Label/__tests__/index.spec.tsx +1 -0
  25. package/src/components/Typography/Label/index.tsx +2 -13
  26. package/src/components/Typography/Title/StyledTitle.tsx +2 -2
  27. package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
  28. package/src/components/Typography/Title/__tests__/index.spec.tsx +1 -0
  29. package/src/components/Typography/Title/index.tsx +2 -13
  30. package/src/components/Typography/types.ts +3 -2
  31. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +1 -0
  32. package/src/theme/components/typography.ts +1 -0
  33. package/stats/8.104.0/rn-stats.html +3 -1
  34. package/types/components/Calendar/CalendarRange.d.ts +4 -16
  35. package/types/components/Calendar/constants.d.ts +4 -0
  36. package/types/components/Calendar/helpers.d.ts +14 -0
  37. package/types/components/Calendar/index.d.ts +5 -56
  38. package/types/components/Calendar/shared/hooks/useCalendarLayout.d.ts +8 -0
  39. package/types/components/Calendar/types.d.ts +58 -0
  40. package/types/components/Typography/Body/StyledBody.d.ts +2 -2
  41. package/types/components/Typography/Body/index.d.ts +2 -1
  42. package/types/components/Typography/Caption/StyledCaption.d.ts +2 -2
  43. package/types/components/Typography/Caption/index.d.ts +2 -1
  44. package/types/components/Typography/Label/StyledLabel.d.ts +2 -2
  45. package/types/components/Typography/Label/index.d.ts +2 -1
  46. package/types/components/Typography/Title/StyledTitle.d.ts +2 -2
  47. package/types/components/Typography/Title/index.d.ts +2 -1
  48. package/types/components/Typography/types.d.ts +1 -1
  49. package/types/theme/components/typography.d.ts +1 -0
@@ -1,4 +1,4 @@
1
- (node:4140) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
1
+ (node:4254) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
2
2
  (Use `node --trace-warnings ...` to show where the warning was created)
3
3
  
4
4
  src/index.ts → lib/index.js, es/index.js...
@@ -15,9 +15,9 @@ node_modules/d3-selection/src/selection/index.js -> node_modules/d3-selection/sr
15
15
     ~~~~~~~~~~~~~~~~~~~
16
16
  
17
17
  (!) [plugin node-resolve] preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.
18
- created lib/index.js, es/index.js in 1m 10.7s
18
+ created lib/index.js, es/index.js in 1m 13.8s
19
19
  
20
20
  /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_AU.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/en_CA.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/index.ts, /home/runner/work/hero-design/hero-design/packages/rn/src/locales/types.ts → ., ....
21
21
  (!) Generated empty chunks
22
22
  "locales/types" and "locales/types"
23
- created ., . in 19.7s
23
+ created ., . in 21.7s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.104.1-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3497](https://github.com/Thinkei/hero-design/pull/3497) [`e92d1dab57316441e7b5054debe823328e1a1083`](https://github.com/Thinkei/hero-design/commit/e92d1dab57316441e7b5054debe823328e1a1083) Thanks [@luanlai2201](https://github.com/luanlai2201)! - [Font] replace playful font to Saiga
8
+
9
+ - [#4123](https://github.com/Thinkei/hero-design/pull/4123) [`ecc5905dec81783858f57595a0af4306ff3b0b89`](https://github.com/Thinkei/hero-design/commit/ecc5905dec81783858f57595a0af4306ff3b0b89) Thanks [@truongnguyen-eh](https://github.com/truongnguyen-eh)! - [ANG-3740] Resolve conflict between alpha and master-react-18
10
+
3
11
  ## 8.104.1-alpha.2
4
12
 
5
13
  ### Patch Changes
package/es/index.js CHANGED
@@ -7066,7 +7066,8 @@ var getTypographyTheme = function getTypographyTheme(theme) {
7066
7066
  inverted: theme.colors.onDarkGlobalSurface,
7067
7067
  archived: theme.colors.onArchivedSurface,
7068
7068
  disabled: theme.colors.disabledOnDefaultGlobalSurface,
7069
- muted: theme.colors.mutedOnDefaultGlobalSurface
7069
+ muted: theme.colors.mutedOnDefaultGlobalSurface,
7070
+ inactive: theme.colors.inactiveOnDefaultGlobalSurface
7070
7071
  };
7071
7072
  var fontSizes = {
7072
7073
  xsmall: theme.fontSizes.xsmall,
@@ -13463,6 +13464,14 @@ var CalendarRowItem = function CalendarRowItem(_ref) {
13463
13464
  }) : null));
13464
13465
  };
13465
13466
 
13467
+ var DAYS_OF_WEEK = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
13468
+ // Sunday first column => 0
13469
+ // Sunday last column => 1
13470
+ var WEEK_INDEX_OFFSET = 1;
13471
+ var SUNDAY_INDEX = 6;
13472
+ // Always render 7 rows x 6 items for consistent layout
13473
+ var TOTAL_DATES_ITEMS = 7 * 6;
13474
+
13466
13475
  var initArray = function initArray(length, func) {
13467
13476
  return Array.from(Array(length)).map(function (_, index) {
13468
13477
  return func(index);
@@ -13535,6 +13544,73 @@ var setStartOrEndDate = function setStartOrEndDate(_ref2) {
13535
13544
  endDate: undefined
13536
13545
  };
13537
13546
  };
13547
+ var shouldUseMonthPicker = function shouldUseMonthPicker(onMonthChange) {
13548
+ return onMonthChange !== noop$2;
13549
+ };
13550
+ var getCalendarDate = function getCalendarDate(_ref3) {
13551
+ var visibleDate = _ref3.visibleDate,
13552
+ _ref3$markedDates = _ref3.markedDates,
13553
+ markedDates = _ref3$markedDates === void 0 ? [] : _ref3$markedDates,
13554
+ minDate = _ref3.minDate,
13555
+ maxDate = _ref3.maxDate;
13556
+ var currentMonth = visibleDate.getMonth();
13557
+ var currentYear = visibleDate.getFullYear();
13558
+ var parsedMaskedDate = markedDates.reduce(function (current, markedDate) {
13559
+ return _objectSpread2(_objectSpread2({}, current), {}, _defineProperty({}, markedDate.toDateString(), true));
13560
+ }, {});
13561
+ var firstDateOfMonth = new Date(currentYear, currentMonth, 1);
13562
+ var lastDateOfMonth = new Date(currentYear, currentMonth + 1, 0);
13563
+ var lastDateOfPreviousMonth = new Date(currentYear, currentMonth, 0);
13564
+ // Index of day in week is shifted by 1 due to Sunday is the last column
13565
+ var firstDayWeekIndexOfMonth = firstDateOfMonth.getDay() === 0 ? SUNDAY_INDEX : firstDateOfMonth.getDay() - WEEK_INDEX_OFFSET;
13566
+ var lastDayIndexOfCurrentMonth = lastDateOfMonth.getDate();
13567
+ var lastDayIndexOfPreviousMonth = lastDateOfPreviousMonth.getDate();
13568
+ var daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, function (index) {
13569
+ var reversedIndex = firstDayWeekIndexOfMonth - index - 1;
13570
+ var count = lastDayIndexOfPreviousMonth - reversedIndex;
13571
+ return getValidDate(new Date(currentYear, currentMonth - 1, count), minDate, maxDate);
13572
+ });
13573
+ var daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, function (index) {
13574
+ return getValidDate(new Date(currentYear, currentMonth, index + 1), minDate, maxDate);
13575
+ });
13576
+ var daysOfNextMonth = initArray(TOTAL_DATES_ITEMS - (daysOfPreviousMonth.length + daysOfCurrentMonth.length), function (index) {
13577
+ return getValidDate(new Date(currentYear, currentMonth + 1, index + 1), minDate, maxDate);
13578
+ });
13579
+ return {
13580
+ firstDateOfMonth: firstDateOfMonth,
13581
+ lastDateOfMonth: lastDateOfMonth,
13582
+ parsedMaskedDate: parsedMaskedDate,
13583
+ daysOfPreviousMonth: daysOfPreviousMonth,
13584
+ daysOfCurrentMonth: daysOfCurrentMonth,
13585
+ daysOfNextMonth: daysOfNextMonth
13586
+ };
13587
+ };
13588
+ var getCalendarButtonState = function getCalendarButtonState(_ref4) {
13589
+ var visibleDate = _ref4.visibleDate,
13590
+ markedDates = _ref4.markedDates,
13591
+ minDate = _ref4.minDate,
13592
+ maxDate = _ref4.maxDate;
13593
+ var _getCalendarDate = getCalendarDate({
13594
+ visibleDate: visibleDate,
13595
+ markedDates: markedDates,
13596
+ minDate: minDate,
13597
+ maxDate: maxDate
13598
+ }),
13599
+ daysOfPreviousMonth = _getCalendarDate.daysOfPreviousMonth,
13600
+ daysOfNextMonth = _getCalendarDate.daysOfNextMonth,
13601
+ firstDateOfMonth = _getCalendarDate.firstDateOfMonth,
13602
+ lastDateOfMonth = _getCalendarDate.lastDateOfMonth;
13603
+ var disablePrevButton = minDate === undefined ? false : !daysOfPreviousMonth.some(function (date) {
13604
+ return date !== undefined;
13605
+ }) && minDate >= firstDateOfMonth;
13606
+ var disableNextButton = maxDate === undefined ? false : !daysOfNextMonth.some(function (date) {
13607
+ return date !== undefined;
13608
+ }) || maxDate <= lastDateOfMonth;
13609
+ return {
13610
+ disablePrevButton: disablePrevButton,
13611
+ disableNextButton: disableNextButton
13612
+ };
13613
+ };
13538
13614
 
13539
13615
  var SelectedDate = function SelectedDate(_ref) {
13540
13616
  var date = _ref.date,
@@ -13570,13 +13646,36 @@ var SelectedDate = function SelectedDate(_ref) {
13570
13646
  }) : null));
13571
13647
  };
13572
13648
 
13573
- var DAYS_OF_WEEK$1 = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
13574
- // Sunday first column => 0
13575
- // Sunday last column => 1
13576
- var WEEK_INDEX_OFFSET$1 = 1;
13577
- var SUNDAY_INDEX$1 = 6;
13578
- // Always render 7 rows x 6 items for consistent layout
13579
- var TOTAL_DATES_ITEMS$1 = 7 * 6;
13649
+ var useCalendarLayout = function useCalendarLayout() {
13650
+ var theme = useTheme();
13651
+ var _useState = useState(0),
13652
+ _useState2 = _slicedToArray(_useState, 2),
13653
+ contentHeight = _useState2[0],
13654
+ setContentHeight = _useState2[1];
13655
+ var calendarItemHeight = contentHeight - theme.__hd__.calendar.space.iosPickerMarginVertical * 2;
13656
+ var _useState3 = useState(0),
13657
+ _useState4 = _slicedToArray(_useState3, 2),
13658
+ contentWidth = _useState4[0],
13659
+ setContentWidth = _useState4[1];
13660
+ var calendarItemWidth = useMemo(function () {
13661
+ return contentWidth > 0 ? Math.floor((contentWidth - theme.__hd__.calendar.space.cellPadding) / 7) : undefined;
13662
+ }, [contentWidth, theme]);
13663
+ var onLayout = useCallback(function (e) {
13664
+ var _e$nativeEvent$layout = e.nativeEvent.layout,
13665
+ width = _e$nativeEvent$layout.width,
13666
+ height = _e$nativeEvent$layout.height;
13667
+ setContentHeight(height);
13668
+ setContentWidth(width);
13669
+ }, []);
13670
+ return {
13671
+ onLayout: onLayout,
13672
+ contentHeight: contentHeight,
13673
+ calendarItemHeight: calendarItemHeight,
13674
+ contentWidth: contentWidth,
13675
+ calendarItemWidth: calendarItemWidth
13676
+ };
13677
+ };
13678
+
13580
13679
  var CalendarRange = function CalendarRange(_ref) {
13581
13680
  var value = _ref.value,
13582
13681
  visibleDate = _ref.visibleDate,
@@ -13599,52 +13698,35 @@ var CalendarRange = function CalendarRange(_ref) {
13599
13698
  monthPickerConfirmLabel = _ref.monthPickerConfirmLabel,
13600
13699
  monthPickerCancelLabel = _ref.monthPickerCancelLabel;
13601
13700
  var theme = useTheme();
13602
- var currentMonth = visibleDate.getMonth();
13603
- var currentYear = visibleDate.getFullYear();
13604
- var now = new Date();
13605
- var parsedMaskedDate = markedDates.reduce(function (current, markedDate) {
13606
- return _objectSpread2(_objectSpread2({}, current), {}, _defineProperty({}, markedDate.toDateString(), true));
13607
- }, {});
13608
13701
  var _useState = useState(false),
13609
13702
  _useState2 = _slicedToArray(_useState, 2),
13610
13703
  monthPickerVisible = _useState2[0],
13611
13704
  setMonthPickerVisible = _useState2[1];
13612
- var _useState3 = useState(0),
13613
- _useState4 = _slicedToArray(_useState3, 2),
13614
- contentHeight = _useState4[0],
13615
- setContentHeight = _useState4[1];
13616
- var _useState5 = useState(0),
13617
- _useState6 = _slicedToArray(_useState5, 2),
13618
- contentWidth = _useState6[0],
13619
- setContentWidth = _useState6[1];
13620
- var calendarItemWidth = useMemo(function () {
13621
- return contentWidth > 0 ? Math.floor((contentWidth - theme.__hd__.calendar.space.cellPadding) / 7) : undefined;
13622
- }, [contentWidth, theme]);
13623
- var useMonthPicker = onMonthChange !== noop$2;
13624
- var firstDateOfMonth = new Date(currentYear, currentMonth, 1);
13625
- var lastDateOfMonth = new Date(currentYear, currentMonth + 1, 0);
13626
- var lastDateOfPreviousMonth = new Date(currentYear, currentMonth, 0);
13627
- // Index of day in week is shifted by 1 due to Sunday is the last column
13628
- var firstDayWeekIndexOfMonth = firstDateOfMonth.getDay() === 0 ? SUNDAY_INDEX$1 : firstDateOfMonth.getDay() - WEEK_INDEX_OFFSET$1;
13629
- var lastDayIndexOfCurrentMonth = lastDateOfMonth.getDate();
13630
- var lastDayIndexOfPreviousMonth = lastDateOfPreviousMonth.getDate();
13631
- var daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, function (index) {
13632
- var reversedIndex = firstDayWeekIndexOfMonth - index - 1;
13633
- var count = lastDayIndexOfPreviousMonth - reversedIndex;
13634
- return getValidDate(new Date(currentYear, currentMonth - 1, count), minDate, maxDate);
13635
- });
13636
- var daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, function (index) {
13637
- return getValidDate(new Date(currentYear, currentMonth, index + 1), minDate, maxDate);
13638
- });
13639
- var daysOfNextMonth = initArray(TOTAL_DATES_ITEMS$1 - (daysOfPreviousMonth.length + daysOfCurrentMonth.length), function (index) {
13640
- return getValidDate(new Date(currentYear, currentMonth + 1, index + 1), minDate, maxDate);
13641
- });
13642
- var disablePrevButton = minDate === undefined ? false : !daysOfPreviousMonth.some(function (date) {
13643
- return date !== undefined;
13644
- }) && minDate >= firstDateOfMonth;
13645
- var disableNextButton = maxDate === undefined ? false : !daysOfNextMonth.some(function (date) {
13646
- return date !== undefined;
13647
- }) || maxDate <= lastDateOfMonth;
13705
+ var _useCalendarLayout = useCalendarLayout(),
13706
+ onLayout = _useCalendarLayout.onLayout,
13707
+ contentHeight = _useCalendarLayout.contentHeight,
13708
+ contentWidth = _useCalendarLayout.contentWidth,
13709
+ calendarItemWidth = _useCalendarLayout.calendarItemWidth;
13710
+ var _getCalendarDate = getCalendarDate({
13711
+ visibleDate: visibleDate,
13712
+ markedDates: markedDates,
13713
+ minDate: minDate,
13714
+ maxDate: maxDate,
13715
+ onMonthChange: onMonthChange
13716
+ }),
13717
+ parsedMaskedDate = _getCalendarDate.parsedMaskedDate,
13718
+ daysOfPreviousMonth = _getCalendarDate.daysOfPreviousMonth,
13719
+ daysOfCurrentMonth = _getCalendarDate.daysOfCurrentMonth,
13720
+ daysOfNextMonth = _getCalendarDate.daysOfNextMonth;
13721
+ var _getCalendarButtonSta = getCalendarButtonState({
13722
+ visibleDate: visibleDate,
13723
+ minDate: minDate,
13724
+ maxDate: maxDate
13725
+ }),
13726
+ disablePrevButton = _getCalendarButtonSta.disablePrevButton,
13727
+ disableNextButton = _getCalendarButtonSta.disableNextButton;
13728
+ var shouldShowMonthPicker = shouldUseMonthPicker(onMonthChange);
13729
+ var now = new Date();
13648
13730
  var onDateChange = function onDateChange(date) {
13649
13731
  var newDateRange = setStartOrEndDate({
13650
13732
  date: date,
@@ -13692,17 +13774,10 @@ var CalendarRange = function CalendarRange(_ref) {
13692
13774
  textIntent: isCurrentMonth ? undefined : 'subdued'
13693
13775
  });
13694
13776
  };
13695
- var onLayout = function onLayout(e) {
13696
- var _e$nativeEvent$layout = e.nativeEvent.layout,
13697
- width = _e$nativeEvent$layout.width,
13698
- height = _e$nativeEvent$layout.height;
13699
- setContentHeight(height);
13700
- setContentWidth(width);
13701
- };
13702
13777
  return /*#__PURE__*/React__default.createElement(StyledContainer$7, {
13703
13778
  testID: testID
13704
13779
  }, /*#__PURE__*/React__default.createElement(StyledCalendarHeader, null, /*#__PURE__*/React__default.createElement(ContentNavigator, {
13705
- value: !useMonthPicker ? formatTime('MMMM yyyy', visibleDate) : /*#__PURE__*/React__default.createElement(TouchableOpacity, {
13780
+ value: !shouldShowMonthPicker ? formatTime('MMMM yyyy', visibleDate) : /*#__PURE__*/React__default.createElement(TouchableOpacity, {
13706
13781
  testID: "calendar-month-picker",
13707
13782
  onPress: function onPress() {
13708
13783
  onToggleMonthPicker === null || onToggleMonthPicker === void 0 || onToggleMonthPicker(!monthPickerVisible);
@@ -13724,7 +13799,7 @@ var CalendarRange = function CalendarRange(_ref) {
13724
13799
  }))),
13725
13800
  onPreviousPress: onPreviousPress,
13726
13801
  onNextPress: onNextPress,
13727
- onPress: useMonthPicker ? undefined : onTitlePress,
13802
+ onPress: shouldShowMonthPicker ? undefined : onTitlePress,
13728
13803
  previousDisabled: disablePrevButton,
13729
13804
  nextDisabled: disableNextButton,
13730
13805
  fontSize: "large"
@@ -13744,7 +13819,7 @@ var CalendarRange = function CalendarRange(_ref) {
13744
13819
  }
13745
13820
  })) : /*#__PURE__*/React__default.createElement(Box, {
13746
13821
  onLayout: onLayout
13747
- }, /*#__PURE__*/React__default.createElement(StyledCalendarRow, null, DAYS_OF_WEEK$1.map(function (day) {
13822
+ }, /*#__PURE__*/React__default.createElement(StyledCalendarRow, null, DAYS_OF_WEEK.map(function (day) {
13748
13823
  return /*#__PURE__*/React__default.createElement(StyledCalendarRowItem, {
13749
13824
  key: day
13750
13825
  }, /*#__PURE__*/React__default.createElement(StyledCalendarDayNameCell, {
@@ -13784,13 +13859,6 @@ var CalendarRange = function CalendarRange(_ref) {
13784
13859
  })));
13785
13860
  };
13786
13861
 
13787
- var DAYS_OF_WEEK = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
13788
- // Sunday first column => 0
13789
- // Sunday last column => 1
13790
- var WEEK_INDEX_OFFSET = 1;
13791
- var SUNDAY_INDEX = 6;
13792
- // Always render 7 rows x 6 items for consistent layout
13793
- var TOTAL_DATES_ITEMS = 7 * 6;
13794
13862
  var Calendar = function Calendar(_ref) {
13795
13863
  var value = _ref.value,
13796
13864
  visibleDate = _ref.visibleDate,
@@ -13813,63 +13881,39 @@ var Calendar = function Calendar(_ref) {
13813
13881
  monthPickerConfirmLabel = _ref.monthPickerConfirmLabel,
13814
13882
  monthPickerCancelLabel = _ref.monthPickerCancelLabel;
13815
13883
  var theme = useTheme();
13816
- var currentMonth = visibleDate.getMonth();
13817
- var currentYear = visibleDate.getFullYear();
13818
- var now = new Date();
13819
- var parsedMaskedDate = markedDates.reduce(function (current, markedDate) {
13820
- return _objectSpread2(_objectSpread2({}, current), {}, _defineProperty({}, markedDate.toDateString(), true));
13821
- }, {});
13884
+ var _useCalendarLayout = useCalendarLayout(),
13885
+ onLayout = _useCalendarLayout.onLayout,
13886
+ contentHeight = _useCalendarLayout.contentHeight,
13887
+ contentWidth = _useCalendarLayout.contentWidth,
13888
+ calendarItemWidth = _useCalendarLayout.calendarItemWidth;
13889
+ var _getCalendarDate = getCalendarDate({
13890
+ visibleDate: visibleDate,
13891
+ markedDates: markedDates,
13892
+ minDate: minDate,
13893
+ maxDate: maxDate,
13894
+ onMonthChange: onMonthChange
13895
+ }),
13896
+ parsedMaskedDate = _getCalendarDate.parsedMaskedDate,
13897
+ daysOfPreviousMonth = _getCalendarDate.daysOfPreviousMonth,
13898
+ daysOfCurrentMonth = _getCalendarDate.daysOfCurrentMonth,
13899
+ daysOfNextMonth = _getCalendarDate.daysOfNextMonth;
13900
+ var _getCalendarButtonSta = getCalendarButtonState({
13901
+ visibleDate: visibleDate,
13902
+ minDate: minDate,
13903
+ maxDate: maxDate
13904
+ }),
13905
+ disablePrevButton = _getCalendarButtonSta.disablePrevButton,
13906
+ disableNextButton = _getCalendarButtonSta.disableNextButton;
13907
+ var shouldShowMonthPicker = shouldUseMonthPicker(onMonthChange);
13822
13908
  var _useState = useState(false),
13823
13909
  _useState2 = _slicedToArray(_useState, 2),
13824
13910
  monthPickerVisible = _useState2[0],
13825
13911
  setMonthPickerVisible = _useState2[1];
13826
- var _useState3 = useState(0),
13827
- _useState4 = _slicedToArray(_useState3, 2),
13828
- contentHeight = _useState4[0],
13829
- setContentHeight = _useState4[1];
13830
- var _useState5 = useState(0),
13831
- _useState6 = _slicedToArray(_useState5, 2),
13832
- contentWidth = _useState6[0],
13833
- setContentWidth = _useState6[1];
13834
- var calendarItemWidth = useMemo(function () {
13835
- return contentWidth > 0 ? Math.floor((contentWidth - theme.__hd__.calendar.space.cellPadding) / 7) : undefined;
13836
- }, [contentWidth, theme]);
13837
- var useMonthPicker = onMonthChange !== noop$2;
13838
- var firstDateOfMonth = new Date(currentYear, currentMonth, 1);
13839
- var lastDateOfMonth = new Date(currentYear, currentMonth + 1, 0);
13840
- var lastDateOfPreviousMonth = new Date(currentYear, currentMonth, 0);
13841
- // Index of day in week is shifted by 1 due to Sunday is the last column
13842
- var firstDayWeekIndexOfMonth = firstDateOfMonth.getDay() === 0 ? SUNDAY_INDEX : firstDateOfMonth.getDay() - WEEK_INDEX_OFFSET;
13843
- var lastDayIndexOfCurrentMonth = lastDateOfMonth.getDate();
13844
- var lastDayIndexOfPreviousMonth = lastDateOfPreviousMonth.getDate();
13845
- var daysOfPreviousMonth = initArray(firstDayWeekIndexOfMonth, function (index) {
13846
- var reversedIndex = firstDayWeekIndexOfMonth - index - 1;
13847
- var count = lastDayIndexOfPreviousMonth - reversedIndex;
13848
- return getValidDate(new Date(currentYear, currentMonth - 1, count), minDate, maxDate);
13849
- });
13850
- var daysOfCurrentMonth = initArray(lastDayIndexOfCurrentMonth, function (index) {
13851
- return getValidDate(new Date(currentYear, currentMonth, index + 1), minDate, maxDate);
13852
- });
13853
- var daysOfNextMonth = initArray(TOTAL_DATES_ITEMS - (daysOfPreviousMonth.length + daysOfCurrentMonth.length), function (index) {
13854
- return getValidDate(new Date(currentYear, currentMonth + 1, index + 1), minDate, maxDate);
13855
- });
13856
- var disablePrevButton = minDate === undefined ? false : !daysOfPreviousMonth.some(function (date) {
13857
- return date !== undefined;
13858
- }) && minDate >= firstDateOfMonth;
13859
- var disableNextButton = maxDate === undefined ? false : !daysOfNextMonth.some(function (date) {
13860
- return date !== undefined;
13861
- }) || maxDate <= lastDateOfMonth;
13862
- var onLayout = function onLayout(e) {
13863
- var _e$nativeEvent$layout = e.nativeEvent.layout,
13864
- width = _e$nativeEvent$layout.width,
13865
- height = _e$nativeEvent$layout.height;
13866
- setContentHeight(height);
13867
- setContentWidth(width);
13868
- };
13912
+ var now = new Date();
13869
13913
  return /*#__PURE__*/React__default.createElement(StyledContainer$7, {
13870
13914
  testID: testID
13871
13915
  }, /*#__PURE__*/React__default.createElement(StyledCalendarHeader, null, /*#__PURE__*/React__default.createElement(ContentNavigator, {
13872
- value: !useMonthPicker ? formatTime('MMMM yyyy', visibleDate) : /*#__PURE__*/React__default.createElement(TouchableOpacity, {
13916
+ value: !shouldShowMonthPicker ? formatTime('MMMM yyyy', visibleDate) : /*#__PURE__*/React__default.createElement(TouchableOpacity, {
13873
13917
  testID: "calendar-month-picker",
13874
13918
  onPress: function onPress() {
13875
13919
  onToggleMonthPicker === null || onToggleMonthPicker === void 0 || onToggleMonthPicker(!monthPickerVisible);
@@ -13891,7 +13935,7 @@ var Calendar = function Calendar(_ref) {
13891
13935
  }))),
13892
13936
  onPreviousPress: onPreviousPress,
13893
13937
  onNextPress: onNextPress,
13894
- onPress: useMonthPicker ? undefined : onTitlePress,
13938
+ onPress: shouldShowMonthPicker ? undefined : onTitlePress,
13895
13939
  previousDisabled: disablePrevButton,
13896
13940
  nextDisabled: disableNextButton,
13897
13941
  fontSize: "large"