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

36 lines (35 loc) • 1.04 kB
JavaScript
import { useState as f, useCallback as u, useMemo as h } from "../../external/preact/hooks/dist/hooks.module.js";
import { hasCallback as k } from "./types.js";
function o(l) {
const [n, r] = f(null), d = u(
(e) => {
var c;
return e && k(l[e.selection.type]) ? {
callback: (c = l == null ? void 0 : l[e.selection.type]) != null && c.callback ? (a) => {
var s, t;
return (t = (s = l[e.selection.type]) == null ? void 0 : s.callback) == null ? void 0 : t.call(s, { showModal: () => r(e), ...a });
} : () => {
var a;
return ((a = l[e.selection.type]) == null ? void 0 : a.showDetails) && r(e);
}
} : (r(e), {});
},
[l]
), i = u(() => r(null), []), b = h(() => {
const e = {};
for (const c in l) {
const a = l[c];
e[c] = !(a != null && a.showDetails) || !!a.callback;
}
return e;
}, [l]);
return {
selectedDetail: n,
updateDetails: d,
detailsToShow: b,
resetDetails: i
};
}
export {
o as default
};