@progress/kendo-react-common 13.4.0-develop.4 → 13.4.0-develop.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import * as React from 'react';
9
+ /**
10
+ * Options for the useKendoPaste hook.
11
+ */
12
+ export interface UseKendoPasteOptions {
13
+ /**
14
+ * The field name to listen for in the smart paste event.
15
+ * This is typically the component's `name` or `id` prop.
16
+ * When the event contains a value for this field, the onValueChange callback is called.
17
+ *
18
+ * If undefined or empty, the hook will not subscribe to events.
19
+ */
20
+ fieldName?: string;
21
+ /**
22
+ * Callback fired when a value is received for this field from the smart paste event.
23
+ *
24
+ * @param value - The new value from the smart paste event
25
+ */
26
+ onValueChange: (value: any) => void;
27
+ /**
28
+ * Whether the smart paste subscription is enabled.
29
+ * When false, the hook will not listen for smart paste events.
30
+ *
31
+ * @default true
32
+ */
33
+ enabled?: boolean;
34
+ }
35
+ /**
36
+ * Options for subscribing to smart paste events in class components.
37
+ */
38
+ export interface KendoPasteSubscriptionOptions {
39
+ /**
40
+ * The field name to listen for in the smart paste event.
41
+ */
42
+ fieldName?: string;
43
+ /**
44
+ * Callback fired when a value is received for this field from the smart paste event.
45
+ */
46
+ onValueChange: (value: any) => void;
47
+ }
48
+ /**
49
+ * Result of subscribing to smart paste events, used to unsubscribe later.
50
+ */
51
+ export interface KendoPasteSubscription {
52
+ /**
53
+ * Unsubscribe from smart paste events.
54
+ * Call this in componentWillUnmount to clean up the event listener.
55
+ */
56
+ unsubscribe: () => void;
57
+ }
58
+ /**
59
+ * Subscribe to smart paste events for class components.
60
+ * Call this in componentDidMount and store the result.
61
+ * Call unsubscribe() in componentWillUnmount.
62
+ *
63
+ * @param element - The DOM element to use for finding the event target
64
+ * @param options - Configuration options for the smart paste subscription
65
+ * @returns A subscription object with an unsubscribe method
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * class MyComponent extends React.Component {
70
+ * private KendoPasteSubscription?: KendoPasteSubscription;
71
+ *
72
+ * componentDidMount() {
73
+ * this.KendoPasteSubscription = subscribeToKendoPaste(this.element, {
74
+ * fieldName: this.props.name,
75
+ * onValueChange: (value) => this.handleSmartPasteValue(value)
76
+ * });
77
+ * }
78
+ *
79
+ * componentWillUnmount() {
80
+ * this.KendoPasteSubscription?.unsubscribe();
81
+ * }
82
+ * }
83
+ * ```
84
+ */
85
+ export declare function subscribeToKendoPaste(element: Element | null | undefined, options: KendoPasteSubscriptionOptions): KendoPasteSubscription;
86
+ /**
87
+ * A React hook that subscribes a component to smart paste events.
88
+ * When a SmartPasteButton dispatches a populate event, this hook will
89
+ * call the onValueChange callback if the event contains a value for the specified field.
90
+ *
91
+ * The field is identified by the `name` or `id` prop of the component.
92
+ * Works with both KendoReact Form components and native HTML form elements.
93
+ *
94
+ * @param elementRef - A ref to the DOM element that will be used to find the event target
95
+ * @param options - Configuration options for the smart paste subscription
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * const inputRef = React.useRef<HTMLInputElement>(null);
100
+ * const [value, setValue] = React.useState('');
101
+ *
102
+ * // Using name prop as field identifier
103
+ * useKendoPaste(inputRef, {
104
+ * fieldName: 'firstName', // matches the name prop
105
+ * onValueChange: (newValue) => setValue(newValue)
106
+ * });
107
+ *
108
+ * return <input ref={inputRef} name="firstName" value={value} onChange={(e) => setValue(e.target.value)} />;
109
+ * ```
110
+ */
111
+ export declare function useKendoPaste(elementRef: React.RefObject<Element | null>, options: UseKendoPasteOptions): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "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;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import * as l from "react";
9
+ import { KENDO_PASTE_EVENT_NAME as i } from "./KendoPasteEvent.mjs";
10
+ function g(n, t) {
11
+ const { fieldName: e, onValueChange: r } = t;
12
+ if (!n || !e)
13
+ return { unsubscribe: () => {
14
+ } };
15
+ const s = E(n), u = (c) => {
16
+ const a = c, { fieldValues: o } = a.detail;
17
+ if (o && e in o) {
18
+ const f = o[e];
19
+ r(f);
20
+ }
21
+ };
22
+ return s.addEventListener(i, u), {
23
+ unsubscribe: () => {
24
+ s.removeEventListener(i, u);
25
+ }
26
+ };
27
+ }
28
+ function T(n, t) {
29
+ const { fieldName: e, onValueChange: r, enabled: s = !0 } = t, u = l.useRef(r);
30
+ l.useEffect(() => {
31
+ u.current = r;
32
+ }, [r]), l.useEffect(() => {
33
+ if (!s || !e)
34
+ return;
35
+ const c = n.current;
36
+ if (!c)
37
+ return;
38
+ const a = E(c), o = (f) => {
39
+ const v = f, { fieldValues: d } = v.detail;
40
+ if (d && e in d) {
41
+ const m = d[e];
42
+ u.current(m);
43
+ }
44
+ };
45
+ return a.addEventListener(i, o), () => {
46
+ a.removeEventListener(i, o);
47
+ };
48
+ }, [n, e, s]);
49
+ }
50
+ function E(n) {
51
+ const t = n.closest("form");
52
+ if (t)
53
+ return t;
54
+ const e = n.closest(".k-form");
55
+ return e || document.body;
56
+ }
57
+ export {
58
+ g as subscribeToKendoPaste,
59
+ T as useKendoPaste
60
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-common",
3
- "version": "13.4.0-develop.4",
3
+ "version": "13.4.0-develop.5",
4
4
  "description": "React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package",
5
5
  "author": "Progress",
6
6
  "license": "SEE LICENSE IN LICENSE.md",