@adyen/adyen-platform-experience-web
Version:

69 lines (68 loc) • 3.2 kB
JavaScript
import { jsx as r } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import y from "classnames";
import { forwardRef as R } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { useState as w, useMemo as i, useCallback as s } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import b from "../../../hooks/useReflex.js";
import _ from "../Calendar/hooks/useTimezone.js";
import { DEFAULT_FIRST_WEEK_DAY as O } from "../Calendar/calendar/timerange/presets/shared/offsetWeek.js";
import v from "../Calendar/hooks/useCalendarControlsRendering.js";
/* empty css */
import I from "../../../core/Context/preact/useCoreContext.js";
import N from "./components/TimeRangeSelector/TimeRangeSelector.js";
import P from "../Calendar/Calendar.js";
import d from "../Calendar/calendar/facade/index.js";
import { boolOrTrue as D } from "../../../utils/value/bool.js";
import { EMPTY_OBJECT as L } from "../../../utils/value/constants.js";
import { noop as M } from "../../../utils/common.js";
const V = R((e, f) => {
const { i18n: n } = I(), [h, g] = v(e.renderControl), [p, a] = w(() => performance.now()), o = i(() => D(e.showTimezoneInfo), [e.showTimezoneInfo]), { clockTime: m, GMTOffset: l } = _({ timezone: e.timezone, withClock: o }), u = i(() => y([{ "adyen-pe-datepicker--with-timezone": o }, "adyen-pe-datepicker"]), [o]), T = i(() => o ? { values: { offset: l, time: m } } : L, [l, m, o]), t = b(M, f), k = s(
(z) => n.get("common.filters.types.date.calendar.label", { values: { monthOfYear: z.label } }),
[n]
), { onHighlight: c } = e, C = s(() => {
a(performance.now()), t.current?.from && t.current?.to && c?.(+t.current?.from, +t.current?.to);
}, [t, a, c]);
return /* @__PURE__ */ r("div", { className: u, "data-testid": "date-picker", children: [
/* @__PURE__ */ r("div", { className: "adyen-pe-datepicker__selector-container", children: /* @__PURE__ */ r(
N,
{
now: e.now,
calendarRef: t,
onTimeRangeSelected: e.onPresetOptionSelected,
options: e.timeRangePresetOptions,
selectedOption: e.selectedPresetOption,
timestamp: p,
timezone: e.timezone,
"aria-label": e.timeRangeSelectorLabel
}
) }),
/* @__PURE__ */ r(
"div",
{
ref: g,
role: "group",
className: "adyen-pe-datepicker__controls",
"aria-label": n.get("common.filters.types.date.calendar.navigation.label")
}
),
/* @__PURE__ */ r(
P,
{
...e,
ref: t,
firstWeekDay: O,
dynamicBlockRows: !0,
onlyCellsWithin: !0,
controls: e.controls ?? d.controls.MINIMAL,
highlight: e.highlight ?? d.highlight.MANY,
getGridLabel: k,
onHighlight: C,
renderControl: h,
trackCurrentDay: !0
}
),
o && /* @__PURE__ */ r("div", { className: "adyen-pe-datepicker__timezone", "data-testid": "date-picker-timezone", children: n.get("common.filters.types.date.timezoneInfo", T) })
] });
});
export {
V as default
};