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

9 lines (8 loc) 1.66 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react"),i=require("./KendoPasteEvent.js");function T(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const d=T(N);function _(t,n){const{fieldName:e,onValueChange:o}=n;if(!t||!e)return{unsubscribe:()=>{}};const s=l(t),c=u=>{const a=u,{fieldValues:r}=a.detail;if(r&&e in r){const f=r[e];o(f)}};return s.addEventListener(i.KENDO_PASTE_EVENT_NAME,c),{unsubscribe:()=>{s.removeEventListener(i.KENDO_PASTE_EVENT_NAME,c)}}}function g(t,n){const{fieldName:e,onValueChange:o,enabled:s=!0}=n,c=d.useRef(o);d.useEffect(()=>{c.current=o},[o]),d.useEffect(()=>{if(!s||!e)return;const u=t.current;if(!u)return;const a=l(u),r=f=>{const b=f,{fieldValues:E}=b.detail;if(E&&e in E){const v=E[e];c.current(v)}};return a.addEventListener(i.KENDO_PASTE_EVENT_NAME,r),()=>{a.removeEventListener(i.KENDO_PASTE_EVENT_NAME,r)}},[t,e,s])}function l(t){const n=t.closest("form");if(n)return n;const e=t.closest(".k-form");return e||document.body}exports.subscribeToKendoPaste=_;exports.useKendoPaste=g;