UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

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