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)

30 lines (29 loc) 947 B
import { useCallback as a } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; import S from "./useAnalytics/useFilterAnalyticsEvent.js"; import { listFrom as d } from "../utils/collection/main.js"; const z = ({ eventCategory: l, eventSubCategory: c, eventLabel: i, onResetFilter: n, onUpdateFilter: r, selectionOptions: u, selection: e }) => { const { logEvent: t } = S({ category: l, subCategory: c, label: i }), m = a(() => { e.length > 0 && (t?.("reset"), n?.()); }, [e, t, n]), g = a( ({ target: f }) => { const s = new Set(d(f?.value || "")); if (e.some((o) => !s.has(o)) || e.length !== s.size) { const o = Object.freeze([...s].sort((h, p) => h.localeCompare(p))); t?.("update", String(o)), r?.(o); } }, [e, t, r] ); return { selection: e, selectionOptions: u, onResetAction: m, updateSelection: g }; }; export { z as default };