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)

48 lines (47 loc) 1.64 kB
import { useMemo as f } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; import { useResponsiveContainer as b, containerQueries as g } from "./useResponsiveContainer.js"; import h from "../core/Context/preact/useCoreContext.js"; import { EMPTY_OBJECT as M } from "../utils/value/constants.js"; import { isUndefined as x } from "../utils/value/is.js"; function T(o) { let i = {}; for (const s of Object.keys(o)) x(o[s]) || (i = { ...i, [s]: o[s] }); return i; } const B = ({ fields: o, customColumns: i, columnConfig: s, fieldsKeys: l }) => { const { i18n: p } = h(), a = f(() => o.map((r) => ({ key: r })), [o]), y = b(g.up.sm); return f(() => { const r = i?.filter((e) => !o?.some((m) => m === e.key)).map((e) => e.key) || [], k = [...a, ...i?.filter((e) => e?.key) || []], d = i?.reduce((e, m) => (e[m.key] = m, e), {}) || {}, t = /* @__PURE__ */ new Map(); return k.forEach((e) => { if (d[e.key]?.visibility !== "hidden") if (t.has(e.key)) { const n = t.get(e.key); t.set(e.key, { ...n, ...e, visible: e.visibility !== "hidden", position: e.align || n.position }); } else { const { key: n, flex: u, align: c } = e, v = p.get(l?.[n] || n), C = T(s?.[n] || M); t.set(e.key, { key: n, label: v, visible: r.includes(e.key) ? y : !0, flex: u, position: c, ...C }); } }), Array.from(t.values()); }, [s, i, o, p, y, a, l]); }; export { B as useTableColumns };