impact-ui 4.0.1-alpha.2 → 4.0.1-alpha.21

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 (192) hide show
  1. package/dist/_virtual/North.js +4 -0
  2. package/dist/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/_virtual/index13.js +2 -2
  4. package/dist/_virtual/index14.js +2 -2
  5. package/dist/_virtual/index15.js +2 -2
  6. package/dist/_virtual/index16.js +2 -2
  7. package/dist/components/AccordionModern/index.js +5 -10
  8. package/dist/components/BottomSheet/index.d.ts.map +1 -1
  9. package/dist/components/BottomSheet/index.js +5 -4
  10. package/dist/components/Chart/index.d.ts.map +1 -1
  11. package/dist/components/Chart/index.js +5 -7
  12. package/dist/components/Chatbot/constant.d.ts.map +1 -1
  13. package/dist/components/Chatbot/constant.js +8 -2
  14. package/dist/components/Chatbot/index.d.ts.map +1 -1
  15. package/dist/components/Chatbot/index.js +24 -15
  16. package/dist/components/Chatbot/newChatComponent.js +1 -1
  17. package/dist/components/Checkbox/Default.js +1 -1
  18. package/dist/components/CommentsPanel/CommentsContext.js +5 -9
  19. package/dist/components/CommentsPanel/CommentsPanel.impl.d.ts.map +1 -1
  20. package/dist/components/CommentsPanel/CommentsPanel.impl.js +8 -12
  21. package/dist/components/DatePicker/index.d.ts.map +1 -1
  22. package/dist/components/DatePicker/index.js +1 -1
  23. package/dist/components/DateRangePicker/dateRangePickerCustom.d.ts +1 -5
  24. package/dist/components/DateRangePicker/dateRangePickerCustom.d.ts.map +1 -1
  25. package/dist/components/DateRangePicker/dateRangePickerCustom.js +1 -4
  26. package/dist/components/DateRangePicker/dateRangePickerDropdown.d.ts +1 -44
  27. package/dist/components/DateRangePicker/dateRangePickerDropdown.d.ts.map +1 -1
  28. package/dist/components/DateRangePicker/dateRangePickerDropdown.js +204 -166
  29. package/dist/components/DateRangePicker/dateRangePickerFooter.d.ts +1 -11
  30. package/dist/components/DateRangePicker/dateRangePickerFooter.d.ts.map +1 -1
  31. package/dist/components/DateRangePicker/dateRangePickerFooter.js +1 -1
  32. package/dist/components/DateRangePicker/dateRangePickerInput.d.ts +1 -30
  33. package/dist/components/DateRangePicker/dateRangePickerInput.d.ts.map +1 -1
  34. package/dist/components/DateRangePicker/dateRangePickerInput.js +225 -180
  35. package/dist/components/DateRangePicker/index.d.ts +2 -6
  36. package/dist/components/DateRangePicker/index.d.ts.map +1 -1
  37. package/dist/components/DateRangePicker/index.js +158 -164
  38. package/dist/components/DateRangePicker/showMonthYearSelect.d.ts +1 -12
  39. package/dist/components/DateRangePicker/showMonthYearSelect.d.ts.map +1 -1
  40. package/dist/components/DateRangePicker/showMonthYearSelect.js +37 -51
  41. package/dist/components/DateRangePicker/utils.d.ts +13 -39
  42. package/dist/components/DateRangePicker/utils.d.ts.map +1 -1
  43. package/dist/components/DateRangePicker/utils.js +25 -30
  44. package/dist/components/FileUpload/index.d.ts.map +1 -1
  45. package/dist/components/FileUpload/index.js +4 -2
  46. package/dist/components/FiltersStrip/AppliedFilters.d.ts.map +1 -1
  47. package/dist/components/FiltersStrip/AppliedFilters.js +6 -6
  48. package/dist/components/Header/index.js +1 -1
  49. package/dist/components/KeyboardShortCuts/Keycombo.d.ts +3 -1
  50. package/dist/components/KeyboardShortCuts/Keycombo.d.ts.map +1 -1
  51. package/dist/components/KeyboardShortCuts/Keycombo.js +11 -1
  52. package/dist/components/KeyboardShortCuts/ShortcutLandingPage.d.ts.map +1 -1
  53. package/dist/components/KeyboardShortCuts/ShortcutLandingPage.js +38 -12
  54. package/dist/components/KeyboardShortCuts/ShortcutModal.d.ts.map +1 -1
  55. package/dist/components/KeyboardShortCuts/ShortcutModal.js +100 -43
  56. package/dist/components/KeyboardShortCuts/allSetBox.js +1 -1
  57. package/dist/components/KeyboardShortCuts/index.js +1 -1
  58. package/dist/components/KeyboardShortCuts/tutorial.d.ts.map +1 -1
  59. package/dist/components/KeyboardShortCuts/tutorial.js +9 -6
  60. package/dist/components/Loader/index.js +1 -1
  61. package/dist/components/Menu/MenuHeaderInfo.d.ts.map +1 -1
  62. package/dist/components/Menu/MenuHeaderInfo.js +4 -7
  63. package/dist/components/Modal/Modal.types.d.ts +12 -1
  64. package/dist/components/Modal/Modal.types.d.ts.map +1 -1
  65. package/dist/components/Modal/index.js +2 -2
  66. package/dist/components/Notification/Notification.types.d.ts +4 -0
  67. package/dist/components/Notification/Notification.types.d.ts.map +1 -1
  68. package/dist/components/Notification/NotificationBody/NotificationList/NotificationChipsList.d.ts.map +1 -1
  69. package/dist/components/Notification/NotificationBody/NotificationList/NotificationChipsList.js +2 -1
  70. package/dist/components/Notification/NotificationBody/NotificationList/NotificationList.d.ts.map +1 -1
  71. package/dist/components/Notification/NotificationBody/NotificationList/NotificationList.js +9 -4
  72. package/dist/components/Notification/NotificationBody/NotificationList/NotificationListItem.d.ts.map +1 -1
  73. package/dist/components/Notification/NotificationBody/NotificationList/NotificationListItem.js +169 -47
  74. package/dist/components/Notification/index.js +1 -1
  75. package/dist/components/Notification/mockData.d.ts.map +1 -1
  76. package/dist/components/Select/Select.types.d.ts +4 -6
  77. package/dist/components/Select/Select.types.d.ts.map +1 -1
  78. package/dist/components/Select/customGroupHeading.d.ts.map +1 -1
  79. package/dist/components/Select/customGroupHeading.js +9 -3
  80. package/dist/components/Select/dropdown.d.ts.map +1 -1
  81. package/dist/components/Select/dropdown.js +1 -1
  82. package/dist/components/Select/hooks/useMenuPosition.d.ts +1 -1
  83. package/dist/components/Select/hooks/useMenuPosition.d.ts.map +1 -1
  84. package/dist/components/Select/hooks/useMenuPosition.js +25 -39
  85. package/dist/components/Select/hooks/useScrollIntoView.d.ts +2 -1
  86. package/dist/components/Select/hooks/useScrollIntoView.d.ts.map +1 -1
  87. package/dist/components/Select/hooks/useScrollIntoView.js +4 -2
  88. package/dist/components/Select/index.d.ts.map +1 -1
  89. package/dist/components/Select/index.js +6 -13
  90. package/dist/components/Select/menuList.d.ts.map +1 -1
  91. package/dist/components/Select/menuList.js +19 -19
  92. package/dist/components/Slider/index.d.ts +1 -1
  93. package/dist/components/Slider/index.d.ts.map +1 -1
  94. package/dist/components/Slider/index.js +2 -8
  95. package/dist/components/Table/AdvanceSortModal.d.ts.map +1 -1
  96. package/dist/components/Table/AdvanceSortModal.js +3 -5
  97. package/dist/components/Table/AgGridHeader.d.ts.map +1 -1
  98. package/dist/components/Table/AgGridHeader.js +27 -10
  99. package/dist/components/Table/CommentsPortal.d.ts.map +1 -1
  100. package/dist/components/Table/CommentsPortal.js +6 -10
  101. package/dist/components/Table/NewAdvanceSearchModal/NewAdvanceSearchModal.d.ts.map +1 -1
  102. package/dist/components/Table/NewAdvanceSearchModal/NewAdvanceSearchModal.js +5 -1
  103. package/dist/components/Table/NewAdvanceSearchModal/NewAdvanceSearchModalItem.d.ts.map +1 -1
  104. package/dist/components/Table/NewAdvanceSearchModal/NewAdvanceSearchModalItem.js +6 -1
  105. package/dist/components/Table/NoComments.d.ts.map +1 -1
  106. package/dist/components/Table/NoComments.js +2 -3
  107. package/dist/components/Table/index.d.ts +1 -2
  108. package/dist/components/Table/index.d.ts.map +1 -1
  109. package/dist/components/Table/index.js +156 -112
  110. package/dist/components/Table/tableFunctions.d.ts.map +1 -1
  111. package/dist/components/Table/tableFunctions.js +176 -104
  112. package/dist/components/Table/tableHeader.d.ts +2 -1
  113. package/dist/components/Table/tableHeader.d.ts.map +1 -1
  114. package/dist/components/Table/tableHeader.js +2 -0
  115. package/dist/components/Table/tableMoreOptions.d.ts +2 -1
  116. package/dist/components/Table/tableMoreOptions.d.ts.map +1 -1
  117. package/dist/components/Table/tableMoreOptions.js +2 -1
  118. package/dist/components/Table/tableSettings.d.ts +2 -1
  119. package/dist/components/Table/tableSettings.d.ts.map +1 -1
  120. package/dist/components/Table/tableSettings.js +2 -0
  121. package/dist/components/Table/withCommentIcon.d.ts.map +1 -1
  122. package/dist/components/Table/withCommentIcon.js +2 -3
  123. package/dist/components/TableChat/EmptyContainer.js +1 -1
  124. package/dist/components/TableChat/TableChatSidePanel.d.ts.map +1 -1
  125. package/dist/components/TableChat/TableChatSidePanel.js +18 -22
  126. package/dist/components/TableChat/components/TableChatLeftSection/AddChatContainer/AddChatContainer.d.ts +1 -2
  127. package/dist/components/TableChat/components/TableChatLeftSection/AddChatContainer/AddChatContainer.d.ts.map +1 -1
  128. package/dist/components/TableChat/components/TableChatLeftSection/AddChatContainer/AddChatContainer.js +15 -18
  129. package/dist/components/TableChat/components/TableChatLeftSection/ChatChannelItem.d.ts +1 -3
  130. package/dist/components/TableChat/components/TableChatLeftSection/ChatChannelItem.d.ts.map +1 -1
  131. package/dist/components/TableChat/components/TableChatLeftSection/ChatChannelItem.js +26 -22
  132. package/dist/components/TableChat/components/TableChatLeftSection/ChatChannelList.d.ts.map +1 -1
  133. package/dist/components/TableChat/components/TableChatLeftSection/ChatChannelList.js +4 -52
  134. package/dist/components/TableChat/components/TableChatLeftSection/TableChatChannelHeader.d.ts +1 -3
  135. package/dist/components/TableChat/components/TableChatLeftSection/TableChatChannelHeader.d.ts.map +1 -1
  136. package/dist/components/TableChat/components/TableChatLeftSection/TableChatChannelHeader.js +2 -7
  137. package/dist/components/TableChat/components/TableChatRightSection/AvatarGroup/AvatarGroup.js +1 -1
  138. package/dist/components/TableChat/components/TableChatRightSection/ChatDefaultMessageType/ChatDefaultMessageType.d.ts +1 -2
  139. package/dist/components/TableChat/components/TableChatRightSection/ChatDefaultMessageType/ChatDefaultMessageType.d.ts.map +1 -1
  140. package/dist/components/TableChat/components/TableChatRightSection/ChatDefaultMessageType/ChatDefaultMessageType.js +17 -17
  141. package/dist/components/TableChat/components/TableChatRightSection/{ChatEditedMessageType/ChatEditedMessageType.d.ts → ChatEditedMessageType /ChatEditedMessageType.d.ts } +0 -1
  142. package/dist/components/TableChat/components/TableChatRightSection/ChatEditedMessageType /ChatEditedMessageType.d.ts.map +1 -0
  143. package/dist/components/TableChat/components/TableChatRightSection/{ChatEditedMessageType/ChatEditedMessageType.js → ChatEditedMessageType /ChatEditedMessageType.js } +2 -4
  144. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeader.d.ts +1 -2
  145. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeader.d.ts.map +1 -1
  146. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeader.js +7 -8
  147. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeaderAction.d.ts.map +1 -1
  148. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeaderAction.js +4 -8
  149. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeaderInfo.d.ts +1 -1
  150. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeaderInfo.d.ts.map +1 -1
  151. package/dist/components/TableChat/components/TableChatRightSection/ChatHeader/ChatHeaderInfo.js +18 -9
  152. package/dist/components/TableChat/components/TableChatRightSection/ChatInput/ChatInput.d.ts.map +1 -1
  153. package/dist/components/TableChat/components/TableChatRightSection/ChatInput/ChatInput.js +7 -9
  154. package/dist/components/TableChat/components/TableChatRightSection/ChatMessageAvatar/ChatMessageAvatar.js +1 -1
  155. package/dist/components/TableChat/components/TableChatRightSection/ChatMessages/ChatMessage.d.ts +1 -2
  156. package/dist/components/TableChat/components/TableChatRightSection/ChatMessages/ChatMessage.d.ts.map +1 -1
  157. package/dist/components/TableChat/components/TableChatRightSection/ChatMessages/ChatMessage.js +5 -9
  158. package/dist/components/TableChat/components/TableChatRightSection/DateSeparator/DateSeparator.js +1 -1
  159. package/dist/components/TableChat/components/TableChatRightSection/PinedChatPanel/PinedChatPanel.d.ts.map +1 -1
  160. package/dist/components/TableChat/components/TableChatRightSection/PinedChatPanel/PinedChatPanel.js +6 -18
  161. package/dist/components/TableChat/components/TableChatRightSection/TableChatRightSection.d.ts +1 -3
  162. package/dist/components/TableChat/components/TableChatRightSection/TableChatRightSection.d.ts.map +1 -1
  163. package/dist/components/TableChat/components/TableChatRightSection/TableChatRightSection.js +4 -13
  164. package/dist/components/TableChat/components/TextEditor/Mention.js +1 -1
  165. package/dist/components/TableChat/components/TextEditor/MentionList.js +1 -1
  166. package/dist/components/TableChat/utils/formatChatTimestamp.js +14 -0
  167. package/dist/components/TableOld/AgGridHeader.d.ts.map +1 -1
  168. package/dist/components/TableOld/AgGridHeader.js +10 -4
  169. package/dist/components/TableOld/index.d.ts.map +1 -1
  170. package/dist/components/TableOld/index.js +3 -1
  171. package/dist/components/TableOld/tableFunctions.d.ts.map +1 -1
  172. package/dist/components/TableOld/tableFunctions.js +176 -104
  173. package/dist/components/TableOld/tableHeader.d.ts +2 -1
  174. package/dist/components/TableOld/tableHeader.d.ts.map +1 -1
  175. package/dist/components/TableOld/tableHeader.js +2 -0
  176. package/dist/components/TextArea/index.js +1 -1
  177. package/dist/mcp-component-registry.json +1 -1
  178. package/dist/node_modules/@impactsmartsuite/impact-icons/dist/index.js +5195 -0
  179. package/dist/node_modules/@mui/icons-material/North.js +17 -0
  180. package/dist/node_modules/call-bind/index.js +1 -1
  181. package/dist/node_modules/global-cache/index.js +4 -5
  182. package/dist/node_modules/hoist-non-react-statics/node_modules/react-is/index.js +1 -1
  183. package/dist/node_modules/is-callable/index.js +1 -1
  184. package/dist/node_modules/is-symbol/index.js +1 -1
  185. package/dist/node_modules/lodash/lodash.js +1 -1
  186. package/dist/node_modules/object-inspect/index.js +1 -2
  187. package/dist/node_modules/react-with-styles-interface-css/dist/index.js +1 -1
  188. package/dist/utils/helper.d.ts +4 -2
  189. package/dist/utils/helper.d.ts.map +1 -1
  190. package/dist/utils/helper.js +13 -8
  191. package/package.json +5 -4
  192. package/dist/components/TableChat/components/TableChatRightSection/ChatEditedMessageType/ChatEditedMessageType.d.ts.map +0 -1
@@ -1,39 +1,30 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState, useEffect, useCallback } from "react";
2
+ import { useState, useEffect } from "react";
3
3
  import moment from "moment";
4
4
  import { getAssetUrl } from "../../utils/assetBase.js";
5
5
  const calendarIcon = getAssetUrl("icons/calendar.svg");
6
- const NUMBER_POSITIONS = [0, 1, 3, 4, 6, 7, 8, 9];
7
- const FORMAT_MAP = {
8
- "DD-MM-YYYY": { day: [0, 2], month: [3, 5], year: [6, 10] },
9
- "MM-DD-YYYY": { day: [3, 5], month: [0, 2], year: [6, 10] },
10
- "YYYY-MM-DD": { day: [8, 10], month: [5, 7], year: [0, 4] }
11
- };
12
6
  function DateRangePickerInput({
13
- id,
14
- "data-testid": dataTestId,
15
7
  inputContainerRef,
16
- startDateString = "",
17
- onStartDateFocus,
8
+ startDateString,
18
9
  startDateInputRef,
19
10
  startDateInputProps,
20
- endDateString = "",
21
- onEndDateFocus,
11
+ endDateString,
22
12
  endDateInputRef,
23
13
  endDateInputProps,
24
14
  isDisabled,
25
15
  isError,
26
- isOpen = false,
16
+ onStartDateFocus,
17
+ onEndDateFocus,
27
18
  displayFormat = "DD-MM-YYYY",
28
19
  onStartDateStringChange,
29
20
  onEndDateStringChange,
30
21
  minDate,
31
22
  maxDate,
32
- readOnly = false,
23
+ readOnly,
33
24
  isOutsideRange,
34
25
  onErrorStateChange,
35
- clearErrorsTrigger = 0,
36
- resetTrigger = 0,
26
+ clearErrorsTrigger,
27
+ resetTrigger,
37
28
  customIcon
38
29
  }) {
39
30
  const [startInputValue, setStartInputValue] = useState("");
@@ -42,12 +33,42 @@ function DateRangePickerInput({
42
33
  const [endErrorState, setEndErrorState] = useState(false);
43
34
  const [startPendingCursorPosition, setStartPendingCursorPosition] = useState(null);
44
35
  const [endPendingCursorPosition, setEndPendingCursorPosition] = useState(null);
36
+ const NUMBER_POSITIONS = [0, 1, 3, 4, 6, 7, 8, 9];
37
+ useEffect(() => {
38
+ if (startPendingCursorPosition !== null && startDateInputRef.current) {
39
+ startDateInputRef.current.setSelectionRange(
40
+ startPendingCursorPosition,
41
+ startPendingCursorPosition
42
+ );
43
+ setStartPendingCursorPosition(null);
44
+ }
45
+ }, [startInputValue, startPendingCursorPosition]);
46
+ useEffect(() => {
47
+ if (endPendingCursorPosition !== null && endDateInputRef.current) {
48
+ endDateInputRef.current.setSelectionRange(endPendingCursorPosition, endPendingCursorPosition);
49
+ setEndPendingCursorPosition(null);
50
+ }
51
+ }, [endInputValue, endPendingCursorPosition]);
45
52
  useEffect(() => {
46
- setStartInputValue(startDateString ?? "");
53
+ if (startDateString) {
54
+ setStartInputValue(startDateString);
55
+ } else {
56
+ setStartInputValue("");
57
+ }
47
58
  }, [startDateString]);
48
59
  useEffect(() => {
49
- setEndInputValue(endDateString ?? "");
60
+ if (endDateString) {
61
+ setEndInputValue(endDateString);
62
+ } else {
63
+ setEndInputValue("");
64
+ }
50
65
  }, [endDateString]);
66
+ useEffect(() => {
67
+ const hasErrors = startErrorState || endErrorState;
68
+ if (onErrorStateChange) {
69
+ onErrorStateChange(hasErrors);
70
+ }
71
+ }, [startErrorState, endErrorState, onErrorStateChange]);
51
72
  useEffect(() => {
52
73
  if (clearErrorsTrigger > 0) {
53
74
  setStartErrorState(false);
@@ -64,275 +85,299 @@ function DateRangePickerInput({
64
85
  onEndDateStringChange == null ? void 0 : onEndDateStringChange(null);
65
86
  }
66
87
  }, [resetTrigger]);
67
- useEffect(() => {
68
- const hasErrors = startErrorState || endErrorState;
69
- onErrorStateChange == null ? void 0 : onErrorStateChange(hasErrors);
70
- }, [startErrorState, endErrorState, onErrorStateChange]);
71
- useEffect(() => {
72
- if (startPendingCursorPosition != null && startDateInputRef.current) {
73
- startDateInputRef.current.setSelectionRange(
74
- startPendingCursorPosition,
75
- startPendingCursorPosition
76
- );
77
- setStartPendingCursorPosition(null);
88
+ const validateDate = (date, isStartDate) => {
89
+ if (!date) return false;
90
+ if (minDate && moment(date).isBefore(minDate, "day")) {
91
+ return false;
78
92
  }
79
- }, [startInputValue, startPendingCursorPosition, startDateInputRef]);
80
- useEffect(() => {
81
- if (endPendingCursorPosition != null && endDateInputRef.current) {
82
- endDateInputRef.current.setSelectionRange(endPendingCursorPosition, endPendingCursorPosition);
83
- setEndPendingCursorPosition(null);
93
+ if (maxDate && moment(date).isAfter(maxDate, "day")) {
94
+ return false;
84
95
  }
85
- }, [endInputValue, endPendingCursorPosition, endDateInputRef]);
86
- const validateDate = useCallback(
87
- (date, isStartDate) => {
88
- if (minDate != null && date.isBefore(minDate, "day")) return false;
89
- if (maxDate != null && date.isAfter(maxDate, "day")) return false;
90
- const formatInfo = FORMAT_MAP[displayFormat] ?? FORMAT_MAP["DD-MM-YYYY"];
91
- if (!formatInfo) return false;
92
- const inputVal = isStartDate ? startInputValue : endInputValue;
93
- const day = parseInt(inputVal.substring(formatInfo.day[0], formatInfo.day[1]), 10) || 0;
94
- const month = parseInt(inputVal.substring(formatInfo.month[0], formatInfo.month[1]), 10) || 0;
95
- const year = parseInt(inputVal.substring(formatInfo.year[0], formatInfo.year[1]), 10) || 0;
96
- if (month < 1 || month > 12) return false;
97
- const lastDay = moment(`${year}-${month}`, "YYYY-M").daysInMonth();
98
- if (day < 1 || day > lastDay) return false;
99
- if (isStartDate && endInputValue) {
100
- const endDateParsed = moment(endInputValue, displayFormat, true);
101
- if (endDateParsed.isValid() && date.isAfter(endDateParsed, "day")) return false;
96
+ const inputValue = isStartDate ? startInputValue : endInputValue;
97
+ const format = displayFormat || "DD-MM-YYYY";
98
+ const formatMap = {
99
+ "DD-MM-YYYY": { day: [0, 2], month: [3, 5], year: [6, 10] },
100
+ "MM-DD-YYYY": { day: [3, 5], month: [0, 2], year: [6, 10] },
101
+ "YYYY-MM-DD": { day: [8, 10], month: [5, 7], year: [0, 4] }
102
+ };
103
+ const formatInfo = formatMap[format] || formatMap["DD-MM-YYYY"];
104
+ const day = parseInt(inputValue.substring(formatInfo.day[0], formatInfo.day[1]));
105
+ const month = parseInt(inputValue.substring(formatInfo.month[0], formatInfo.month[1]));
106
+ const year = parseInt(inputValue.substring(formatInfo.year[0], formatInfo.year[1]));
107
+ if (month < 1 || month > 12) {
108
+ return false;
109
+ }
110
+ const lastDayOfMonth = moment(`${year}-${month}`, "YYYY-M").daysInMonth();
111
+ if (day < 1 || day > lastDayOfMonth) {
112
+ return false;
113
+ }
114
+ if (isStartDate && endInputValue) {
115
+ const endDate = moment(endInputValue, displayFormat, true);
116
+ if (endDate.isValid() && moment(date).isAfter(endDate, "day")) {
117
+ return false;
102
118
  }
103
- if (!isStartDate && startInputValue) {
104
- const startDateParsed = moment(startInputValue, displayFormat, true);
105
- if (startDateParsed.isValid() && date.isBefore(startDateParsed, "day")) return false;
119
+ }
120
+ if (!isStartDate && startInputValue) {
121
+ const startDate = moment(startInputValue, displayFormat, true);
122
+ if (startDate.isValid() && moment(date).isBefore(startDate, "day")) {
123
+ return false;
106
124
  }
107
- if (isOutsideRange == null ? void 0 : isOutsideRange(date)) return false;
108
- return true;
109
- },
110
- [displayFormat, minDate, maxDate, startInputValue, endInputValue, isOutsideRange]
111
- );
112
- const handleStartFocus = () => {
125
+ }
126
+ if (isOutsideRange == null ? void 0 : isOutsideRange(moment(date))) {
127
+ return false;
128
+ }
129
+ return true;
130
+ };
131
+ const handleStartDateInputFocus = () => {
113
132
  if (!startInputValue) {
114
133
  setStartInputValue(displayFormat);
115
134
  setTimeout(() => {
116
- var _a;
117
- (_a = startDateInputRef.current) == null ? void 0 : _a.setSelectionRange(0, 0);
135
+ if (startDateInputRef.current) {
136
+ startDateInputRef.current.setSelectionRange(0, 0);
137
+ }
118
138
  }, 0);
119
139
  }
120
140
  onStartDateFocus();
121
141
  };
122
- const handleEndFocus = () => {
142
+ const handleEndDateInputFocus = () => {
123
143
  if (!endInputValue) {
124
144
  setEndInputValue(displayFormat);
125
145
  setTimeout(() => {
126
- var _a;
127
- (_a = endDateInputRef.current) == null ? void 0 : _a.setSelectionRange(0, 0);
146
+ if (endDateInputRef.current) {
147
+ endDateInputRef.current.setSelectionRange(0, 0);
148
+ }
128
149
  }, 0);
129
150
  }
130
151
  onEndDateFocus();
131
152
  };
132
- const handleStartBlur = () => {
133
- const parsed = moment(startInputValue, displayFormat, true);
134
- if (parsed.isValid()) {
135
- const valid = validateDate(parsed, true);
136
- setStartErrorState(!valid);
137
- if (valid) onStartDateStringChange == null ? void 0 : onStartDateStringChange(parsed);
153
+ const handleStartDateInputBlur = () => {
154
+ const parsedDate = moment(startInputValue, displayFormat, true);
155
+ if (parsedDate.isValid()) {
156
+ const isValid = validateDate(parsedDate, true);
157
+ setStartErrorState(!isValid);
158
+ if (isValid) {
159
+ onStartDateStringChange == null ? void 0 : onStartDateStringChange(parsedDate);
160
+ }
138
161
  } else {
139
162
  setStartErrorState(true);
140
163
  }
141
164
  if (!startInputValue || startInputValue === displayFormat) {
142
165
  setStartInputValue("");
143
166
  setStartErrorState(false);
144
- if (!isOpen) {
145
- onStartDateStringChange == null ? void 0 : onStartDateStringChange(null);
146
- }
167
+ onStartDateStringChange == null ? void 0 : onStartDateStringChange(null);
147
168
  }
148
169
  };
149
- const handleEndBlur = () => {
150
- const parsed = moment(endInputValue, displayFormat, true);
151
- if (parsed.isValid()) {
152
- const valid = validateDate(parsed, false);
153
- setEndErrorState(!valid);
154
- if (valid) onEndDateStringChange == null ? void 0 : onEndDateStringChange(parsed);
170
+ const handleEndDateInputBlur = () => {
171
+ const parsedDate = moment(endInputValue, displayFormat, true);
172
+ if (parsedDate.isValid()) {
173
+ const isValid = validateDate(parsedDate, false);
174
+ setEndErrorState(!isValid);
175
+ if (isValid) {
176
+ onEndDateStringChange == null ? void 0 : onEndDateStringChange(parsedDate);
177
+ }
155
178
  } else {
156
179
  setEndErrorState(true);
157
180
  }
158
181
  if (!endInputValue || endInputValue === displayFormat) {
159
182
  setEndInputValue("");
160
183
  setEndErrorState(false);
161
- if (!isOpen) {
162
- onEndDateStringChange == null ? void 0 : onEndDateStringChange(null);
184
+ onEndDateStringChange == null ? void 0 : onEndDateStringChange(null);
185
+ }
186
+ };
187
+ const handleStartDateInputClick = () => {
188
+ if (startDateInputRef.current) {
189
+ const cursor = startDateInputRef.current.selectionStart;
190
+ if (cursor >= NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1) {
191
+ startDateInputRef.current.setSelectionRange(
192
+ NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1,
193
+ NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1
194
+ );
195
+ return;
196
+ }
197
+ if (!NUMBER_POSITIONS.includes(cursor)) {
198
+ const nextPos = NUMBER_POSITIONS.find((pos) => pos >= cursor);
199
+ const fallbackPos = NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1];
200
+ startDateInputRef.current.setSelectionRange(
201
+ nextPos !== void 0 ? nextPos : fallbackPos,
202
+ nextPos !== void 0 ? nextPos : fallbackPos
203
+ );
163
204
  }
164
205
  }
165
206
  };
166
- const handleStartChange = (e) => {
207
+ const handleEndDateInputClick = () => {
208
+ if (endDateInputRef.current) {
209
+ const cursor = endDateInputRef.current.selectionStart;
210
+ if (cursor >= NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1) {
211
+ endDateInputRef.current.setSelectionRange(
212
+ NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1,
213
+ NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] + 1
214
+ );
215
+ return;
216
+ }
217
+ if (!NUMBER_POSITIONS.includes(cursor)) {
218
+ const nextPos = NUMBER_POSITIONS.find((pos) => pos >= cursor);
219
+ const fallbackPos = NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1];
220
+ endDateInputRef.current.setSelectionRange(
221
+ nextPos !== void 0 ? nextPos : fallbackPos,
222
+ nextPos !== void 0 ? nextPos : fallbackPos
223
+ );
224
+ }
225
+ }
226
+ };
227
+ const handleStartDateInputChange = (e) => {
228
+ var _a;
167
229
  const input = e.target;
168
230
  const value = input.value;
169
- const cursorPosition = input.selectionStart ?? 0;
170
- if (cursorPosition < 1) return;
231
+ const cursorPosition = input.selectionStart;
232
+ if (cursorPosition == null || cursorPosition < 1) return;
171
233
  const newChar = value[cursorPosition - 1];
172
- if (newChar == null || !/^\d$/.test(newChar)) return;
234
+ if (!/^\d$/.test(newChar)) return;
173
235
  const pos = cursorPosition - 1;
174
236
  if (!NUMBER_POSITIONS.includes(pos)) {
175
- e.preventDefault();
176
- const next = NUMBER_POSITIONS.find((p) => p > pos) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1];
177
- setStartPendingCursorPosition(next ?? null);
237
+ (_a = e.preventDefault) == null ? void 0 : _a.call(e);
238
+ setStartPendingCursorPosition(
239
+ NUMBER_POSITIONS.find((p) => p > pos) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1]
240
+ );
178
241
  return;
179
242
  }
180
243
  const newValue = startInputValue.slice(0, pos) + newChar + startInputValue.slice(pos + 1);
181
244
  if (newValue.length > displayFormat.length) return;
182
245
  setStartInputValue(newValue);
183
246
  onStartDateStringChange == null ? void 0 : onStartDateStringChange(newValue);
184
- const idx = NUMBER_POSITIONS.indexOf(pos);
185
- if (idx < NUMBER_POSITIONS.length - 1) {
186
- setStartPendingCursorPosition(NUMBER_POSITIONS[idx + 1] ?? null);
247
+ const currentIndex = NUMBER_POSITIONS.indexOf(pos);
248
+ if (currentIndex < NUMBER_POSITIONS.length - 1) {
249
+ const nextPos = NUMBER_POSITIONS[currentIndex + 1];
250
+ setStartPendingCursorPosition(nextPos);
187
251
  } else {
188
- const parsed = moment(newValue, displayFormat, true);
189
- const valid = parsed.isValid() && validateDate(parsed, true);
190
- setStartErrorState(!valid);
191
- onStartDateStringChange == null ? void 0 : onStartDateStringChange(valid ? parsed : newValue);
252
+ const parsedDate = moment(newValue, displayFormat, true);
253
+ const isValid = parsedDate.isValid() && validateDate(parsedDate, true);
254
+ setStartErrorState(!isValid);
255
+ onStartDateStringChange == null ? void 0 : onStartDateStringChange(isValid ? parsedDate : newValue);
192
256
  }
193
257
  };
194
- const handleEndChange = (e) => {
258
+ const handleEndDateInputChange = (e) => {
259
+ var _a;
195
260
  const input = e.target;
196
261
  const value = input.value;
197
- const cursorPosition = input.selectionStart ?? 0;
198
- if (cursorPosition < 1) return;
262
+ const cursorPosition = input.selectionStart;
263
+ if (cursorPosition == null || cursorPosition < 1) return;
199
264
  const newChar = value[cursorPosition - 1];
200
- if (newChar == null || !/^\d$/.test(newChar)) return;
265
+ if (!/^\d$/.test(newChar)) return;
201
266
  const pos = cursorPosition - 1;
202
267
  if (!NUMBER_POSITIONS.includes(pos)) {
203
- e.preventDefault();
204
- const next = NUMBER_POSITIONS.find((p) => p > pos) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1];
205
- setEndPendingCursorPosition(next ?? null);
268
+ (_a = e.preventDefault) == null ? void 0 : _a.call(e);
269
+ setEndPendingCursorPosition(
270
+ NUMBER_POSITIONS.find((p) => p > pos) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1]
271
+ );
206
272
  return;
207
273
  }
208
274
  const newValue = endInputValue.slice(0, pos) + newChar + endInputValue.slice(pos + 1);
209
275
  if (newValue.length > displayFormat.length) return;
210
276
  setEndInputValue(newValue);
211
277
  onEndDateStringChange == null ? void 0 : onEndDateStringChange(newValue);
212
- const idx = NUMBER_POSITIONS.indexOf(pos);
213
- if (idx < NUMBER_POSITIONS.length - 1) {
214
- setEndPendingCursorPosition(NUMBER_POSITIONS[idx + 1] ?? null);
278
+ const currentIndex = NUMBER_POSITIONS.indexOf(pos);
279
+ if (currentIndex < NUMBER_POSITIONS.length - 1) {
280
+ const nextPos = NUMBER_POSITIONS[currentIndex + 1];
281
+ setEndPendingCursorPosition(nextPos);
215
282
  } else {
216
- const parsed = moment(newValue, displayFormat, true);
217
- const valid = parsed.isValid() && validateDate(parsed, false);
218
- setEndErrorState(!valid);
219
- onEndDateStringChange == null ? void 0 : onEndDateStringChange(valid ? parsed : newValue);
283
+ const parsedDate = moment(newValue, displayFormat, true);
284
+ const isValid = parsedDate.isValid() && validateDate(parsedDate, false);
285
+ setEndErrorState(!isValid);
286
+ onEndDateStringChange == null ? void 0 : onEndDateStringChange(isValid ? parsedDate : newValue);
220
287
  }
221
288
  };
222
- const handleStartKeyDown = (e) => {
223
- var _a;
224
- if (["ArrowLeft", "ArrowRight", "Tab"].includes(e.key)) return;
289
+ const handleStartDateKeyDown = (e) => {
290
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Tab") {
291
+ return;
292
+ }
225
293
  if (e.key === "Backspace") {
226
294
  e.preventDefault();
227
- const caret = ((_a = startDateInputRef.current) == null ? void 0 : _a.selectionStart) ?? 0;
295
+ const caret = startDateInputRef.current.selectionStart;
228
296
  const deletePos = [...NUMBER_POSITIONS].reverse().find((p) => p < caret);
229
297
  if (deletePos == null) return;
230
- const sep = displayFormat[deletePos] ?? "";
231
- const newValue = startInputValue.slice(0, deletePos) + sep + startInputValue.slice(deletePos + 1);
298
+ const newValue = startInputValue.slice(0, deletePos) + displayFormat[deletePos] + // "D" | "M" | "Y"
299
+ startInputValue.slice(deletePos + 1);
232
300
  setStartInputValue(newValue);
233
301
  onStartDateStringChange == null ? void 0 : onStartDateStringChange(newValue);
234
302
  let nextCaret = deletePos;
235
- while (nextCaret > 0 && !NUMBER_POSITIONS.includes(nextCaret - 1)) nextCaret--;
303
+ while (nextCaret > 0 && !NUMBER_POSITIONS.includes(nextCaret - 1)) {
304
+ nextCaret--;
305
+ }
236
306
  setStartPendingCursorPosition(nextCaret);
237
307
  return;
238
308
  }
239
- if (!/^\d$/.test(e.key)) e.preventDefault();
309
+ if (!/^\d$/.test(e.key)) {
310
+ e.preventDefault();
311
+ }
240
312
  };
241
- const handleEndKeyDown = (e) => {
242
- var _a;
243
- if (["ArrowLeft", "ArrowRight", "Tab"].includes(e.key)) return;
313
+ const handleEndDateKeyDown = (e) => {
314
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Tab") {
315
+ return;
316
+ }
244
317
  if (e.key === "Backspace") {
245
318
  e.preventDefault();
246
- const caret = ((_a = endDateInputRef.current) == null ? void 0 : _a.selectionStart) ?? 0;
319
+ const caret = endDateInputRef.current.selectionStart;
247
320
  const deletePos = [...NUMBER_POSITIONS].reverse().find((p) => p < caret);
248
321
  if (deletePos == null) return;
249
- const sep = displayFormat[deletePos] ?? "";
250
- const newValue = endInputValue.slice(0, deletePos) + sep + endInputValue.slice(deletePos + 1);
322
+ const newValue = endInputValue.slice(0, deletePos) + displayFormat[deletePos] + // "D" | "M" | "Y"
323
+ endInputValue.slice(deletePos + 1);
251
324
  setEndInputValue(newValue);
252
325
  onEndDateStringChange == null ? void 0 : onEndDateStringChange(newValue);
253
326
  let nextCaret = deletePos;
254
- while (nextCaret > 0 && !NUMBER_POSITIONS.includes(nextCaret - 1)) nextCaret--;
327
+ while (nextCaret > 0 && !NUMBER_POSITIONS.includes(nextCaret - 1)) {
328
+ nextCaret--;
329
+ }
255
330
  setEndPendingCursorPosition(nextCaret);
256
331
  return;
257
332
  }
258
- if (!/^\d$/.test(e.key)) e.preventDefault();
259
- };
260
- const handleStartClick = () => {
261
- var _a, _b, _c;
262
- const cursor = ((_a = startDateInputRef.current) == null ? void 0 : _a.selectionStart) ?? 0;
263
- const lastPos = (NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] ?? 0) + 1;
264
- if (cursor >= lastPos) {
265
- (_b = startDateInputRef.current) == null ? void 0 : _b.setSelectionRange(lastPos, lastPos);
266
- return;
267
- }
268
- if (!NUMBER_POSITIONS.includes(cursor)) {
269
- const next = NUMBER_POSITIONS.find((p) => p >= cursor) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] ?? 0;
270
- (_c = startDateInputRef.current) == null ? void 0 : _c.setSelectionRange(next, next);
271
- }
272
- };
273
- const handleEndClick = () => {
274
- var _a, _b, _c;
275
- const cursor = ((_a = endDateInputRef.current) == null ? void 0 : _a.selectionStart) ?? 0;
276
- const lastPos = (NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] ?? 0) + 1;
277
- if (cursor >= lastPos) {
278
- (_b = endDateInputRef.current) == null ? void 0 : _b.setSelectionRange(lastPos, lastPos);
279
- return;
280
- }
281
- if (!NUMBER_POSITIONS.includes(cursor)) {
282
- const next = NUMBER_POSITIONS.find((p) => p >= cursor) ?? NUMBER_POSITIONS[NUMBER_POSITIONS.length - 1] ?? 0;
283
- (_c = endDateInputRef.current) == null ? void 0 : _c.setSelectionRange(next, next);
333
+ if (!/^\d$/.test(e.key)) {
334
+ e.preventDefault();
284
335
  }
285
336
  };
286
- const showError = Boolean(isError ?? startErrorState ?? endErrorState);
287
337
  return /* @__PURE__ */ jsxs(
288
338
  "div",
289
339
  {
290
340
  ref: inputContainerRef,
291
- className: `dateRangePicker-input-container ${isDisabled ? "dateRangePicker-input-disabled" : ""} ${showError ? "impact-dateRangePicker-error" : ""}`.trim(),
292
- "data-testid": dataTestId,
293
- id,
341
+ className: `dateRangePicker-input-container ${isDisabled ? "dateRangePicker-input-disabled" : ""}
342
+ ${isError || startErrorState || endErrorState ? "impact-dateRangePicker-error" : ""}`,
294
343
  children: [
295
344
  /* @__PURE__ */ jsx(
296
345
  "input",
297
346
  {
298
347
  ref: startDateInputRef,
299
- className: "dateRangePicker-input-start-date",
300
- "data-testid": dataTestId != null ? `${dataTestId}-start` : void 0,
301
- disabled: isDisabled,
302
- id: id != null ? `${id}-start` : void 0,
303
348
  placeholder: "Start Date",
304
349
  readOnly,
305
350
  type: "text",
306
351
  value: startInputValue,
307
- onBlur: handleStartBlur,
308
- onChange: handleStartChange,
309
- onClick: handleStartClick,
310
- onFocus: handleStartFocus,
311
- onKeyDown: handleStartKeyDown,
312
- ...startDateInputProps
352
+ onBlur: handleStartDateInputBlur,
353
+ onChange: handleStartDateInputChange,
354
+ onClick: handleStartDateInputClick,
355
+ onFocus: handleStartDateInputFocus,
356
+ onKeyDown: handleStartDateKeyDown,
357
+ ...startDateInputProps,
358
+ className: "dateRangePicker-input-start-date",
359
+ disabled: isDisabled
313
360
  }
314
361
  ),
315
362
  /* @__PURE__ */ jsx(
316
363
  "input",
317
364
  {
318
365
  ref: endDateInputRef,
319
- className: "dateRangePicker-input-end-date",
320
- "data-testid": dataTestId != null ? `${dataTestId}-end` : void 0,
321
- disabled: isDisabled,
322
- id: id != null ? `${id}-end` : void 0,
323
366
  placeholder: "End Date",
324
367
  readOnly,
325
368
  type: "text",
326
369
  value: endInputValue,
327
- onBlur: handleEndBlur,
328
- onChange: handleEndChange,
329
- onClick: handleEndClick,
330
- onFocus: handleEndFocus,
331
- onKeyDown: handleEndKeyDown,
332
- ...endDateInputProps
370
+ onBlur: handleEndDateInputBlur,
371
+ onChange: handleEndDateInputChange,
372
+ onClick: handleEndDateInputClick,
373
+ onFocus: handleEndDateInputFocus,
374
+ onKeyDown: handleEndDateKeyDown,
375
+ ...endDateInputProps,
376
+ className: "dateRangePicker-input-end-date",
377
+ disabled: isDisabled
333
378
  }
334
379
  ),
335
- customIcon != null ? /* @__PURE__ */ jsx(
380
+ customIcon ? /* @__PURE__ */ jsx(
336
381
  "span",
337
382
  {
338
383
  className: "end-date-icon",
@@ -349,7 +394,6 @@ function DateRangePickerInput({
349
394
  ) : /* @__PURE__ */ jsx(
350
395
  "span",
351
396
  {
352
- "aria-hidden": true,
353
397
  className: "end-date-icon",
354
398
  style: {
355
399
  position: "absolute",
@@ -363,9 +407,10 @@ function DateRangePickerInput({
363
407
  opacity: isDisabled ? 0.5 : 1
364
408
  },
365
409
  onClick: (e) => {
366
- var _a;
367
410
  e.stopPropagation();
368
- if (!isDisabled) (_a = startDateInputRef.current) == null ? void 0 : _a.focus();
411
+ if (startDateInputRef.current && !isDisabled) {
412
+ startDateInputRef.current.focus();
413
+ }
369
414
  }
370
415
  }
371
416
  )
@@ -1,9 +1,5 @@
1
- import { DateRangePickerProps } from './DateRangePicker.types';
1
+ import { default as React } from 'react';
2
2
 
3
3
  export type { DateRangePickerProps } from './DateRangePicker.types';
4
- /**
5
- * DateRangePicker component. Uses react-dates and moment; supports start/end date selection,
6
- * range shortcuts, min/max, portal, and footer actions.
7
- */
8
- export declare const DateRangePicker: import('react').ForwardRefExoticComponent<DateRangePickerProps & import('react').RefAttributes<HTMLDivElement | null>>;
4
+ export declare const DateRangePicker: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
9
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,qCAAqC,CAAC;AAC7C,OAAO,+BAA+B,CAAC;AAEvC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,eAAe,wHAkW3B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/index.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC;AAChC,OAAO,qCAAqC,CAAC;AAC7C,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,OAAO,+BAA+B,CAAC;AAIvC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,eAAO,MAAM,eAAe,kFA6W3B,CAAC"}