@raystack/apsara 0.20.0 → 0.20.1

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
@@ -28143,6 +28143,10 @@ function DatePicker({ side = "top", dateFormat = "DD/MM/YYYY", placeholder = "DD
28143
28143
  const textFieldRef = useRef(null);
28144
28144
  const contentRef = useRef(null);
28145
28145
  const isInputFieldFocused = useRef(false);
28146
+ const calendarValRef = useRef(value);
28147
+ useEffect(() => {
28148
+ calendarValRef.current = calendarVal;
28149
+ }, [calendarVal]);
28146
28150
  function isElementOutside(el) {
28147
28151
  return !isDropdownOpenRef.current && // Month and Year dropdown from Date picker
28148
28152
  !textFieldRef.current?.contains(el) && // TextField
@@ -28155,12 +28159,12 @@ function DatePicker({ side = "top", dateFormat = "DD/MM/YYYY", placeholder = "DD
28155
28159
  }, []);
28156
28160
  function registerEventListeners() {
28157
28161
  isInputFieldFocused.current = true;
28158
- document.addEventListener('mouseup', handleMouseDown, true);
28162
+ document.addEventListener('mouseup', handleMouseDown);
28159
28163
  }
28160
28164
  function removeEventListeners() {
28161
28165
  isInputFieldFocused.current = false;
28162
28166
  setShowCalendar(false);
28163
- const updatedVal = dayjs(calendarVal).format(dateFormat);
28167
+ const updatedVal = dayjs(calendarValRef.current).format(dateFormat);
28164
28168
  if (textFieldRef.current)
28165
28169
  textFieldRef.current.value = updatedVal;
28166
28170
  if (inputState === undefined)
@@ -28170,6 +28174,7 @@ function DatePicker({ side = "top", dateFormat = "DD/MM/YYYY", placeholder = "DD
28170
28174
  const handleSelect = (day) => {
28171
28175
  onSelect(day);
28172
28176
  setCalendarVal(day);
28177
+ calendarValRef.current = day;
28173
28178
  setInputState(undefined);
28174
28179
  removeEventListeners();
28175
28180
  };