(() => { const { Icon, Button } = window.TaskFlowDesignSystem_dd53c2; const MONTHS = ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"]; const short = (iso) => { const [y, m, d] = String(iso).split("-").map(Number); return `${d} ${MONTHS[m - 1]}`; }; /* Compact period picker that lives in a top bar next to the page's primary action. Collapsed it is a single pill; open it is a small glass popover. */ function PeriodFilter({ from, to, defaultFrom, defaultTo, onApply, align = "right" }) { const phone = useBreakpoint() === "mobile"; const [open, setOpen] = React.useState(false); const [hover, setHover] = React.useState(false); const [f, setF] = React.useState(from); const [t, setT] = React.useState(to); React.useEffect(() => { setF(from); setT(to); }, [from, to]); const btn = React.useRef(null); const [pos, setPos] = React.useState(null); const place = () => { const el = btn.current; if (!el) return; const r = el.getBoundingClientRect(); const w = phone ? 236 : 260; const left = Math.max(8, Math.min(window.innerWidth - w - 8, align === "right" ? r.right - w : r.left)); const openUp = r.bottom + 200 > window.innerHeight && r.top > 220; setPos({ left, top: openUp ? undefined : r.bottom + 8, bottom: openUp ? window.innerHeight - r.top + 8 : undefined, w }); }; React.useEffect(() => { if (!open) return; place(); const on = () => place(); window.addEventListener("resize", on); window.addEventListener("scroll", on, true); return () => { window.removeEventListener("resize", on); window.removeEventListener("scroll", on, true); }; }, [open]); const field = { height: 34, padding: "0 10px", borderRadius: "var(--radius-sm)", width: "100%", border: "1px solid var(--border-default)", background: "var(--white)", font: "var(--fw-semibold) var(--fs-xs)/1 var(--font-mono)", color: "var(--text-strong)", }; return ( {open && pos && ReactDOM.createPortal(( <> setOpen(false)} style={{ position: "fixed", inset: 0, zIndex: 55 }} /> {defaultFrom && ( )} ), document.body)} ); } Object.assign(window, { PeriodFilter }); })();