UNPKG

@progress/kendo-react-common

Version:

React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package

61 lines (60 loc) 1.58 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as l from "react"; import { KENDO_PASTE_EVENT_NAME as i } from "./KendoPasteEvent.mjs"; function g(n, t) { const { fieldName: e, onValueChange: r } = t; if (!n || !e) return { unsubscribe: () => { } }; const s = E(n), u = (c) => { const a = c, { fieldValues: o } = a.detail; if (o && e in o) { const f = o[e]; r(f); } }; return s.addEventListener(i, u), { unsubscribe: () => { s.removeEventListener(i, u); } }; } function T(n, t) { const { fieldName: e, onValueChange: r, enabled: s = !0 } = t, u = l.useRef(r); l.useEffect(() => { u.current = r; }, [r]), l.useEffect(() => { if (!s || !e) return; const c = n.current; if (!c) return; const a = E(c), o = (f) => { const v = f, { fieldValues: d } = v.detail; if (d && e in d) { const m = d[e]; u.current(m); } }; return a.addEventListener(i, o), () => { a.removeEventListener(i, o); }; }, [n, e, s]); } function E(n) { const t = n.closest("form"); if (t) return t; const e = n.closest(".k-form"); return e || document.body; } export { g as subscribeToKendoPaste, T as useKendoPaste };