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)

429 lines (428 loc) 19.1 kB
var Xt = Object.defineProperty; var At = (m) => { throw TypeError(m); }; var qt = (m, i, e) => i in m ? Xt(m, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[i] = e; var St = (m, i, e) => qt(m, typeof i != "symbol" ? i + "" : i, e), Et = (m, i, e) => i.has(m) || At("Cannot " + e); var t = (m, i, e) => (Et(m, i, "read from private field"), e ? e.call(m) : i.get(m)), c = (m, i, e) => i.has(m) ? At("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(m) : i.set(m, e), h = (m, i, e, r) => (Et(m, i, "write to private field"), r ? r.call(m, e) : i.set(m, e), e), f = (m, i, e) => (Et(m, i, "access private method"), e); import { InteractionKeyCode as C } from "../../../../types.js"; import { SELECT_NONE as Q, CALENDAR_CONTROLS as Dt, SHIFT_BLOCK as Jt, SHIFT_PERIOD as Ot, SHIFT_FRAME as Zt, CALENDAR_SELECTIONS as $t, SELECT_MANY as z, FIRST_WEEK_DAYS as Qt, FRAME_SIZES as ti, CURSOR_NEXT_BLOCK as ii, CURSOR_PREV_BLOCK as si, CURSOR_BLOCK_END as ei, CURSOR_LINE_END as hi, CURSOR_BLOCK_START as ri, CURSOR_LINE_START as oi, CURSOR_DOWNWARD as ai, CURSOR_UPWARD as ni, CURSOR_FORWARD as ci, CURSOR_BACKWARD as li, SELECT_ONE as tt, SELECTION_FROM as R, SELECTION_TO as D, CONTROLS_NONE as fi, CONTROLS_MINIMAL as ui, CONTROLS_ALL as mi, SELECTION_COLLAPSE as di } from "../constants.js"; import { withTimezone as Rt } from "../utils.js"; import { CalendarShiftControlsFlag as It, CalendarShiftControlFlag as v } from "../types.js"; import { today as Lt } from "../../../../../primitives/time/today/main.js"; import { createIndexed as gt } from "../../../../../primitives/auxiliary/indexed/main.js"; import { createWatchlist as Si, isWatchlistUnsubscribeToken as Ei } from "../../../../../primitives/reactive/watchlist/main.js"; import { boolify as Y, boolOrTrue as _t } from "../../../../../utils/value/bool.js"; import { pickFrom as j } from "../../../../../utils/collection/main.js"; import { createEffectStack as Ht } from "../../../../../primitives/reactive/effectStack/main.js"; import Oi from "../timeframe/frames/MonthFrame.js"; import { timezoneToSystem as it, systemToTimezone as st } from "../../../../../core/Localization/datetime/restamper/utils.js"; import { EMPTY_OBJECT as V } from "../../../../../utils/value/constants.js"; import { withFreezeProxyHandlers as Ri, structFrom as gi, struct as Ci } from "../../../../../utils/struct/main.js"; import { isUndefined as wt, isFunction as H, isNullish as et, isString as Wt } from "../../../../../utils/value/is.js"; import { noop as Mt } from "../../../../../utils/common.js"; import { isBitSafeInteger as Ti } from "../../../../../utils/value/number.js"; var Bt, Kt, u, y, s, N, T, A, O, P, g, K, L, _, p, I, U, q, w, k, ot, W, x, B, J, at, nt, ct, lt, ft, ut, mt, F, Ut, xt, zt, dt, ht, o, G, Ct, vt, Yt, jt, Vt, Tt, Gt, X, pt, rt, kt, Ft, bt, yt; const d = class d { constructor() { c(this, o); St(this, "grid"); St(this, "kill"); c(this, u, V); c(this, y, !1); c(this, s); c(this, N); c(this, T); c(this, A, !1); c(this, O, Q); c(this, P, !1); c(this, g); c(this, K, (Bt = t(this, g)) == null ? void 0 : Bt.join(" ")); c(this, L); c(this, _); c(this, p); c(this, I); c(this, U); c(this, q, Lt()); c(this, w, []); c(this, k); c(this, ot, new Proxy( gt(() => { var i; return ((i = t(this, k)) == null ? void 0 : i.length) ?? 0; }, f(this, o, Tt).bind(this)), Ri({ get: (i, e, r) => { var a, l; const n = ((a = t(this, k)) == null ? void 0 : a.indexOf(e)) ?? -1; return n >= 0 ? (l = f(this, o, Tt).call(this, n)) == null ? void 0 : l[1] : Reflect.get(i, e, r); } }) )); c(this, W, Si({ blocks: () => { var i; return (i = t(this, s)) == null ? void 0 : i.size; }, cells: () => { var i; return (i = t(this, s)) == null ? void 0 : i.units; }, controls: () => j(Dt, t(this, u).controls), cursor: () => { var i; return (i = t(this, s)) == null ? void 0 : i.cursor; }, from: () => { var i; return (i = t(this, s)) == null ? void 0 : i.selectionStart; }, highlight: () => t(this, O), locale: () => { var i; return (i = t(this, s)) == null ? void 0 : i.locale; }, minified: () => Y(t(this, u).minified), origin: () => { var i; return (i = t(this, s)) == null ? void 0 : i.getTimestampAtIndex(0); }, timezone: () => { var i; return (i = t(this, s)) == null ? void 0 : i.timezone; }, to: () => { var i; return (i = t(this, s)) == null ? void 0 : i.selectionEnd; }, today: () => t(this, q).timestamp })); c(this, x, (Kt = t(this, W)) == null ? void 0 : Kt.snapshot); c(this, B, Ht(() => { var i; return t(this, p) && ((i = t(this, W)) == null ? void 0 : i.requestNotification()); })); c(this, J, Ht(() => { var i; return (i = t(this, p)) == null ? void 0 : i.call(t(this, o, G)); })); c(this, at, gi( gt( () => { var i; return ((i = t(this, s)) == null ? void 0 : i.size) ?? 0; }, (i) => { var e; return (e = t(this, s)) == null ? void 0 : e.frameBlocks[i]; } ), { config: { value: Object.defineProperties( (i) => (i && f(this, o, Yt).call(this, i), t(this, o, G)), { cursorIndex: { get: () => t(this, L), set: (i) => { t(this, y) || (et(i) ? h(this, L, void 0) : H(i) && h(this, L, i)); } }, shiftFactor: { get: () => t(this, _), set: (i) => { t(this, y) || (et(i) ? h(this, _, void 0) : H(i) && h(this, _, i)); } }, watch: { get: () => t(this, p), set: (i) => { var e, r, n, a, l; if (!t(this, y)) if (H(i)) { if (h(this, p, i), !t(this, I)) { const S = (e = t(this, B)) == null ? void 0 : e.bind(t(d, dt).bind(this)); S && (h(this, I, (r = t(this, B)) == null ? void 0 : r.bind(Mt)), h(this, U, (a = t(this, W)) == null ? void 0 : a.subscribe((n = t(this, J)) == null ? void 0 : n.bind(S))), t(this, s) && (t(this, s).effect = t(this, I))); } if (!t(this, P)) return; h(this, P, !1), (l = t(this, I)) == null || l.call(this); } else et(i) && h(this, p, void 0); } } } ) }, controls: { value: t(this, ot) }, cursor: { value: Object.defineProperties( (i) => f(d, F, ht).call(this, (e) => !!(e && f(this, o, jt).call(this, e)))(i), { valueOf: { value: () => { var i; return ((i = t(this, s)) == null ? void 0 : i.cursor) ?? -1; } } } ) }, highlight: { value: (() => { const i = () => t(this, N) === t(this, T) && wt(t(this, T)), e = (r) => (n) => f(d, F, ht).call(this, (a) => { var l, S, E, b, M; if (!(t(this, y) || !t(this, O) || t(this, O) === Q)) { if (et(a)) return f(this, o, pt).call(this); i() ? (S = t(this, s)) == null || S.updateSelection(a, di) : ((l = t(this, s)) == null || l.updateSelection(a, r), t(this, O) === z && t(this, g) && f(this, o, rt).call(this, a, r === R ? D : R, t(this, g))), h(this, N, (E = t(this, s)) == null ? void 0 : E.selectionStart), h(this, T, (b = t(this, s)) == null ? void 0 : b.selectionEnd), (M = t(this, s)) == null || M.shiftFrameToTimestamp(r === R ? t(this, N) : t(this, T)); } })(n); return Ci({ blank: { get: i }, from: { get: () => { var r; return ((r = t(this, s)) == null ? void 0 : r.selectionStart) ?? t(this, N); }, set: e(R) }, to: { get: () => { var r; return ((r = t(this, s)) == null ? void 0 : r.selectionEnd) ?? t(this, T); }, set: e(D) } }); })() }, rowspan: { get: () => { var i; return ((i = t(this, s)) == null ? void 0 : i.rowspan) ?? 0; } }, weekdays: { get: () => { var i; return ((i = t(this, s)) == null ? void 0 : i.daysOfWeek) ?? t(d, lt); } } } )); this.grid = t(this, at), this.kill = f(this, o, Vt).bind(this); } }; u = new WeakMap(), y = new WeakMap(), s = new WeakMap(), N = new WeakMap(), T = new WeakMap(), A = new WeakMap(), O = new WeakMap(), P = new WeakMap(), g = new WeakMap(), K = new WeakMap(), L = new WeakMap(), _ = new WeakMap(), p = new WeakMap(), I = new WeakMap(), U = new WeakMap(), q = new WeakMap(), w = new WeakMap(), k = new WeakMap(), ot = new WeakMap(), W = new WeakMap(), x = new WeakMap(), B = new WeakMap(), J = new WeakMap(), at = new WeakMap(), nt = new WeakMap(), ct = new WeakMap(), lt = new WeakMap(), ft = new WeakMap(), ut = new WeakMap(), mt = new WeakMap(), F = new WeakSet(), Ut = function(i) { if (!Wt(i) || !t(d, nt).test(i)) return; const e = i.split(/\s+/); return Array.from({ length: 6 }, (r, n) => parseInt(e[n] ?? "0")); }, xt = function(i) { switch (i & ~v.PREV) { case v.FRAME: return Zt; case v.PERIOD: return Ot; case v.BLOCK: default: return Jt; } }, zt = function(i) { return i & v.PREV ? -1 : 1; }, dt = new WeakMap(), ht = function(i) { var e; return ((e = t(this, B)) == null ? void 0 : e.bind(i)) ?? i; }, o = new WeakSet(), G = function() { return { ...t(this, u) }; }, Ct = function() { return new Oi(); }, vt = function(i) { return !!t(this, s) && !(i > 0 ? t(this, s).isAtEnd : t(this, s).isAtStart); }, Yt = function(i) { var n, a; if (t(this, y)) return; h(this, g, void 0); const e = i == null ? void 0 : i.highlight, r = Y(t(this, u).minified); if (Wt(e) ? h(this, g, f(n = d, F, Ut).call(n, e)) && h(this, O, z) : h(this, O, j($t, e, t(this, O))), h(this, u, { ...t(this, u), ...i, blocks: j(ti, i == null ? void 0 : i.blocks, t(this, u).blocks), controls: j(Dt, i == null ? void 0 : i.controls, t(this, u).controls), firstWeekDay: j(Qt, i == null ? void 0 : i.firstWeekDay, t(this, u).firstWeekDay), fixedBlockHeight: Y(i == null ? void 0 : i.fixedBlockHeight, t(this, u).fixedBlockHeight), highlight: t(this, O), minified: Y(i == null ? void 0 : i.minified, t(this, u).minified), trackCurrentDay: Y(i == null ? void 0 : i.trackCurrentDay, t(this, u).trackCurrentDay) }), !H(t(this, p))) { t(this, s) ? h(this, P, !0) : (h(this, s, t(this, o, Ct)), f(this, o, Ft).call(this), f(this, o, yt).call(this), f(this, o, bt).call(this)); return; } (!t(this, s) || r !== t(this, u).minified) && (h(this, s, t(this, o, Ct)), t(this, s).effect = t(this, I)), f(this, o, Ft).call(this), (a = t(this, I)) == null || a.call(this); }, jt = function(i) { if (i && t(this, s) && H(t(this, p))) { if (i instanceof KeyboardEvent) { switch (i.code) { case C.ARROW_LEFT: t(this, s).shiftFrameCursor(li); break; case C.ARROW_RIGHT: t(this, s).shiftFrameCursor(ci); break; case C.ARROW_UP: t(this, s).shiftFrameCursor(ni); break; case C.ARROW_DOWN: t(this, s).shiftFrameCursor(ai); break; case C.HOME: t(this, s).shiftFrameCursor(i.ctrlKey ? ri : oi); break; case C.END: t(this, s).shiftFrameCursor(i.ctrlKey ? ei : hi); break; case C.PAGE_UP: i.shiftKey ? t(this, s).shiftFrameByOffset(-1, Ot) : t(this, s).shiftFrameCursor(si); break; case C.PAGE_DOWN: i.shiftKey ? t(this, s).shiftFrameByOffset(1, Ot) : t(this, s).shiftFrameCursor(ii); break; case C.SPACE: case C.ENTER: return f(this, o, X).call(this), !0; default: return; } return t(this, A) && f(this, o, X).call(this, V), !0; } if (i instanceof MouseEvent && t(d, ct).includes(i.type) && H(t(this, L))) { const e = t(this, L).call(t(this, o, G), i); if (!Ti(e)) return; const r = i.type === "click"; if (!(r || t(this, A))) return; if (t(this, s).shiftFrameCursor(e), t(this, s).cursor === e) return r ? f(this, o, X).call(this) : f(this, o, X).call(this, V), !0; } } }, Vt = function() { var i; t(this, y) || ((i = t(this, U)) == null || i.call(this), h(this, B, h(this, J, h(this, L, h(this, s, h(this, O, h(this, K, h(this, x, h(this, g, h(this, _, h(this, U, h(this, W, h(this, I, h(this, p, void 0))))))))))))), h(this, u, V), h(this, A, h(this, P, !1)), h(this, y, !0)); }, Tt = function(i) { var r, n; if (!t(this, k) || i < 0 || i >= t(this, k).length) return; const e = t(this, k)[i]; if (!t(this, w)[i]) { const a = It[e], l = f(r = d, F, xt).call(r, a), S = f(n = d, F, zt).call(n, a); t(this, w)[i] = (...E) => f(d, F, ht).call(this, (...b) => { var $; const M = f(this, o, vt).call(this, S); if (!(M && b.length)) return M; const Z = f(this, o, Gt).call(this, e, b[0]); return wt(Z) ? !1 : (($ = t(this, s)) == null || $.shiftFrameByOffset(S * Z, l), !0); })(...E); } return [e, t(this, w)[i]]; }, Gt = function(i, e) { if (!(t(this, s) && H(t(this, p)))) return; if (e instanceof MouseEvent) { if (e.type !== "click") return; } else if (e instanceof KeyboardEvent) { if (!t(d, ft).includes(e.code)) return; } else return; let r = 1; if (H(t(this, _))) { const n = Number(t(this, _).call(t(this, o, G), e, i)); r = Number.isInteger(n) && n >= 1 ? n : r; } return r; }, X = function(i) { if (t(this, y) || !t(this, s)) return; switch (t(this, O)) { case z: case tt: break; case Q: default: return; } const e = t(this, s).cursor, r = Math.max(t(this, s).getTimestampAtIndex(e), t(this, s).timeslice.from), n = Math.min(t(this, s).getTimestampAtIndex(e + 1) - 1, t(this, s).timeslice.to), a = t(this, g); if (t(this, O) === tt || t(this, s).blankSelection || a) if (h(this, A, !(t(this, O) === tt || a)), t(this, O) === z && a) { const l = n >= t(this, s).selectionEnd ? R : D; l === R ? t(this, s).updateSelection(n, D) : t(this, s).updateSelection(r, R), f(this, o, rt).call(this, l === R ? t(this, s).selectionEnd : t(this, s).selectionStart, l, a); } else t(this, s).updateSelection(r, R), t(this, s).updateSelection(n, D); else { const l = i === V, S = Rt(t(this, s).timezone); if (l || h(this, A, !1), r <= t(this, s).selectionStart) { const E = new Date(it(S, t(this, s).selectionStart)), b = Math.min( st(S, E.setDate(E.getDate() + 1) - 1), t(this, s).timeslice.to ); r === t(this, s).selectionStart && n <= b && t(this, s).updateSelection(n, D), t(this, s).updateSelection(r, R); } else { const E = new Date(it(S, t(this, s).selectionEnd)), b = Math.max( st(S, E.setHours(0, 0, 0, 0)), t(this, s).timeslice.from ); r <= t(this, s).selectionEnd && r >= b && t(this, s).updateSelection(r, R), t(this, s).updateSelection(n, D); } if (l) return; } h(this, N, t(this, s).selectionStart), h(this, T, t(this, s).selectionEnd); }, pt = function() { var i; (i = t(this, s)) == null || i.clearSelection(), h(this, A, !1), h(this, N, h(this, T, void 0)); }, rt = function(i, e, r) { var Nt; if (!t(this, s)) return; const n = Rt((Nt = t(this, s)) == null ? void 0 : Nt.timezone), a = new Date(it(n, i)), l = e === R ? -1 : 1, [S = 0, E = 0, b = 0, M = 0, Z = 0, $ = 0] = r ?? []; a.setFullYear( a.getFullYear() + S * l, a.getMonth() + E * l, a.getDate() + b * l ), a.setHours( a.getHours() + M * l, a.getMinutes() + Z * l, a.getSeconds() + $ * l ), t(this, s).updateSelection(st(n, a.getTime() - l), e); }, kt = function() { var i, e; t(this, N) && ((i = t(this, s)) == null || i.updateSelection(t(this, N), R)), t(this, T) && ((e = t(this, s)) == null || e.updateSelection(t(this, T), D)), h(this, A, !1); }, Ft = function() { t(this, s) && (t(this, s).timeslice = t(this, u).timeslice, t(this, s).dynamicBlockHeight = !t(this, u).fixedBlockHeight, t(this, s).firstWeekDay = t(this, u).firstWeekDay, t(this, s).locale = t(this, u).locale, t(this, s).size = t(this, u).blocks, t(this, s).timezone = t(this, u).timezone, t(this, s).trackCurrentDay = t(this, u).trackCurrentDay, h(this, q, Lt(t(this, s).timezone)), f(this, o, kt).call(this)); }, bt = function() { var i, e, r, n, a, l; switch (t(this, O)) { case z: !_t((i = t(this, s)) == null ? void 0 : i.blankSelection) && t(this, g) && f(this, o, rt).call(this, (e = t(this, s)) == null ? void 0 : e.selectionStart, D, t(this, g)); break; case tt: if (!_t((r = t(this, s)) == null ? void 0 : r.blankSelection)) { const S = Rt((n = t(this, s)) == null ? void 0 : n.timezone), E = new Date(it(S, (a = t(this, s)) == null ? void 0 : a.selectionStart)); (l = t(this, s)) == null || l.updateSelection(st(S, E.setHours(23, 59, 59, 999)), D); } break; case Q: default: f(this, o, pt).call(this); return; } }, yt = function() { var i, e; switch ((i = t(this, W)) == null ? void 0 : i.snapshot.controls) { case mi: h(this, k, t(d, ut)); break; case ui: h(this, k, t(d, mt)); break; case fi: default: h(this, k, void 0); } t(this, w).length = 0, t(this, w).length = ((e = t(this, k)) == null ? void 0 : e.length) ?? 0; }, c(d, F), c(d, nt, /^(?:0|[1-9]\d*)(\s+(?:0|[1-9]\d*)?){0,5}?$/), c(d, ct, ["click", "mouseover", "pointerover"]), c(d, lt, gt(0, Mt)), c(d, ft, [C.ENTER, C.SPACE]), c(d, ut, Object.keys(It).filter((i) => isNaN(+i))), c(d, mt, ["PREV", "NEXT"]), c(d, dt, function(i) { var l, S; if (Ei(i)) return; let e = !1, r = !1, n = !1; const a = (l = t(this, g)) == null ? void 0 : l.join(" "); for (const E of Object.keys(i)) i[E] !== ((S = t(this, x)) == null ? void 0 : S[E]) && (E === "controls" ? e = !0 : E === "highlight" ? r = !0 : (E === "from" || E === "to") && (n = !0)); t(this, K) !== a && (h(this, K, a), r = !0), h(this, x, i), t(this, A) && !n && f(this, o, kt).call(this), e && f(this, o, yt).call(this), r && f(this, o, bt).call(this); }); let Pt = d; export { Pt as default };