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

36 lines (35 loc) • 1.04 kB
JavaScript
import { useState as f, useCallback as u, useMemo as k } from "../../external/preact/hooks/dist/hooks.module.js";
import { hasCallback as D } from "./types.js";
function o(l) {
const [d, r] = f(null), n = u(
(e) => {
var c;
return e && D(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 = k(() => {
const e = {};
for (const c in l) {
const a = l[c];
e[c] = !(a != null && a.showDetails) || !!a.callback;
}
return e;
}, [l]);
return {
selectedDetail: d,
updateDetails: n,
detailsToShow: b,
resetDetails: i
};
}
export {
o as default
};