UNPKG

@rnwonder/react-date-picker

Version:

A lightweight, customizable, and accessible date picker component for React applications.

76 lines (75 loc) 2.38 kB
import { C as H, q as O, N as $, B as x, O as y } from "./general-DZqASQRm-DXQPvh4C.js"; import { a as k, D as j, F as B, H as C, w as I, d as P, v as W, A as q, k as A } from "./format-CMbjATj9-B6oamtiF.js"; const F = ({ inputRef: s, dropDownRef: f, positionX: v, positionY: e }) => { const m = typeof s == "function" ? s() : s, l = typeof f == "function" ? f() : f; if (!m || !l) return {}; const t = m == null ? void 0 : m.getBoundingClientRect(), o = l == null ? void 0 : l.offsetHeight, n = l == null ? void 0 : l.offsetWidth, d = window.innerHeight - (t == null ? void 0 : t.bottom), a = t == null ? void 0 : t.top, g = t == null ? void 0 : t.left, h = window.innerWidth - (t == null ? void 0 : t.right), D = window.innerWidth; let i, T; const p = e === "top" || e === "bottom", b = `${(t == null ? void 0 : t.top) - o - 10}px`, w = `${t == null ? void 0 : t.bottom}px`; e === "top" && (i = b), e === "bottom" && (i = w), d > o && !p ? i = w : (a > o && !p || d < o && e === "bottom" && a > o) && (i = b), (!(d > o) && !(a > o) && !p || e === "top" && !(a > o) || e === "bottom" && !(d > o) && !(a > o)) && (i = "0px"); let r = 0; if (v === "left") r = g >= n ? g - n : 0; else if (v === "right") r = h >= n ? t == null ? void 0 : t.right : D - n; else { const c = (t == null ? void 0 : t.left) + (t == null ? void 0 : t.width) / 2, u = n / 2; c - u >= 0 && c + u <= D ? r = c - u : c - u < 0 ? r = 0 : r = D - n; } return T = `${r}px`, { top: i, left: T }; }, M = () => ({ getToday: y, convertDateObjectToDate: A, convertDateToDateObject: q, checkIfItsTodayDate: x, isBeforeDate: $, getMonthName: O, formatDate: W, clickOutside: H, convert24HourTo12Hour: P, getAmPm: I, convert12HourTo24Hour: C, getCurrentTime: B, smartDropDownPosition: F, labelFormat: j, leadingZeros: k }), N = M(), { getToday: X, convertDateObjectToDate: Y, convertDateToDateObject: z, checkIfItsTodayDate: E, isBeforeDate: G, getMonthName: J, formatDate: K, clickOutside: L, convert24HourTo12Hour: Q, getAmPm: S, convert12HourTo24Hour: U, getCurrentTime: V, smartDropDownPosition: _, labelFormat: tt, leadingZeros: ot } = N; export { L as D, S as T, Y as a, z as c, _ as d, tt as f, V as g, J as i, U as l, K as m, E as n, ot as p, X as r, G as s, Q as u };