@progress/kendo-react-common 14.5.0-develop.13 → 14.5.0-develop.14

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,110 @@
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
+ /**
9
+ * WebMcpProvider – Generic React Context Provider for Web MCP configuration.
10
+ *
11
+ * Wraps a section of the component tree so that any KendoReact component
12
+ * (Grid, Form, Scheduler, etc.) inside it automatically registers
13
+ * browser-native AI agent tools via `navigator.modelContext.registerTool()` (Chrome 146+).
14
+ *
15
+ * Lives in `@progress/kendo-react-common` so every component package can
16
+ * consume the context without cross-package imports.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * import { WebMcpProvider } from '@progress/kendo-react-common';
21
+ *
22
+ * <WebMcpProvider>
23
+ * <Grid data={dataResult} sortable webMcp={{ dataName: 'employees' }} />
24
+ * </WebMcpProvider>
25
+ * ```
26
+ */
27
+ import * as React from 'react';
28
+ /** @internal Result returned by a registered Web MCP tool. */
29
+ export interface WebMcpToolResult {
30
+ content: Array<{
31
+ type: 'text';
32
+ text: string;
33
+ }>;
34
+ isError?: boolean;
35
+ }
36
+ /** @internal Handle returned by `navigator.modelContext.registerTool()`. */
37
+ export interface WebMcpToolRegistration {
38
+ unregister: () => void;
39
+ }
40
+ /** @internal The `navigator.modelContext` surface in Chrome 146+. */
41
+ export interface WebMcpModelContext {
42
+ registerTool: (config: {
43
+ name: string;
44
+ description: string;
45
+ inputSchema: Record<string, unknown>;
46
+ execute: (args: Record<string, unknown>) => Promise<WebMcpToolResult>;
47
+ }) => WebMcpToolRegistration;
48
+ }
49
+ /** Describes a single tool to register via WebMcpProvider. */
50
+ export interface McpToolOption {
51
+ /** Short identifier used as suffix in the tool name. */
52
+ name: string;
53
+ /** Human-readable description shown to AI agents. */
54
+ description: string;
55
+ /** Internal command identifier used by the component's execution router. */
56
+ commandType: string;
57
+ /** Whether this tool should be registered (typically derived from component props). */
58
+ enabled: boolean;
59
+ }
60
+ /** Configuration object for the `webMcp` prop on individual components. */
61
+ export interface WebMcpProps {
62
+ /** Human-readable data name exposed to AI agents. Overrides the provider's `dataName`. */
63
+ dataName?: string;
64
+ /** Called after every tool invocation. */
65
+ onToolExecute?: (toolName: string, args: Record<string, unknown>) => void;
66
+ }
67
+ /** Shared Web MCP configuration propagated via React Context. */
68
+ export interface WebMcpContextValue {
69
+ /** Human-readable data name exposed to AI agents. Any language works. Optional when each component provides its own via `webMcp={{ dataName }}`. */
70
+ dataName?: string;
71
+ /** Called after every tool invocation. */
72
+ onToolExecute?: (toolName: string, args: Record<string, unknown>) => void;
73
+ /**
74
+ * Registration callback provided by a smart provider.
75
+ * Components call this to announce themselves so the provider can
76
+ * create tools on their behalf. Returns an unregister function.
77
+ *
78
+ * @param componentType - Identifier string, e.g. 'textbox', 'grid'.
79
+ * @param handle - The imperative handle exposed via forwardRef.
80
+ * @param props - The current React props of the component.
81
+ * @param webMcpConfig - Component-level webMcp config (when object), or undefined (when boolean).
82
+ * @returns A cleanup function that removes the registration.
83
+ */
84
+ register?: (componentType: string, handle: unknown, propsRef: {
85
+ current: unknown;
86
+ }, webMcpConfig?: Record<string, unknown>) => () => void;
87
+ }
88
+ /** Props accepted by `<WebMcpProvider>`. */
89
+ export interface WebMcpProviderProps extends WebMcpContextValue {
90
+ children: React.ReactNode;
91
+ }
92
+ /** @internal */
93
+ export declare const WebMcpContext: React.Context<WebMcpContextValue | null>;
94
+ /** Provides Web MCP configuration to all descendant KendoReact components. */
95
+ export declare const WebMcpProvider: React.FC<WebMcpProviderProps>;
96
+ /** Returns the `navigator.modelContext` if available (Chrome 146+), or `null`. */
97
+ export declare function getModelContext(): WebMcpModelContext | null;
98
+ /**
99
+ * Tiny hook that components call to register themselves with a parent
100
+ * `WebMcpProvider`. Only runs when `webMcp` is truthy — zero cost otherwise.
101
+ *
102
+ * The component package only needs this single call — all tool creation
103
+ * logic lives in the provider's adapter (in `@progress/kendo-react-webmcp`).
104
+ *
105
+ * @param componentType - Identifier string, e.g. 'textbox', 'grid'.
106
+ * @param handle - Ref to the component's imperative handle.
107
+ * @param props - The current React props.
108
+ * @param webMcp - The component's `webMcp` prop. `true` for defaults, object for config.
109
+ */
110
+ export declare function useWebMcpRegister(componentType: string, handle: React.RefObject<unknown>, props: unknown, webMcp?: boolean | WebMcpProps): void;
@@ -0,0 +1,9 @@
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 client";
9
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");function l(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,e.get?e:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const o=l(a),i=o.createContext(null);i.displayName="WebMcpContext";const g=({children:t,dataName:r,onToolExecute:n})=>{const e=o.useMemo(()=>({dataName:r,onToolExecute:n}),[r,n]);return o.createElement(i.Provider,{value:e},t)};function d(){return typeof navigator!="undefined"&&navigator.modelContext?navigator.modelContext:null}function b(t,r,n,e){const c=o.useContext(i),u=o.useRef(n);u.current=n;const s=o.useMemo(()=>typeof e=="object"?JSON.stringify(e):String(!!e),[e]);o.useEffect(()=>{if(!e||!(c!=null&&c.register))return;const f=typeof e=="object"?e:void 0;return c.register(t,r.current,u,f)},[s,c,t,r])}exports.WebMcpContext=i;exports.WebMcpProvider=g;exports.getModelContext=d;exports.useWebMcpRegister=b;
@@ -0,0 +1,41 @@
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 client";
9
+ import * as t from "react";
10
+ const s = t.createContext(null);
11
+ s.displayName = "WebMcpContext";
12
+ const g = ({ children: i, dataName: n, onToolExecute: r }) => {
13
+ const e = t.useMemo(() => ({ dataName: n, onToolExecute: r }), [n, r]);
14
+ return /* @__PURE__ */ t.createElement(s.Provider, { value: e }, i);
15
+ };
16
+ function a() {
17
+ return typeof navigator != "undefined" && navigator.modelContext ? navigator.modelContext : null;
18
+ }
19
+ function l(i, n, r, e) {
20
+ const o = t.useContext(s), u = t.useRef(r);
21
+ u.current = r;
22
+ const f = t.useMemo(
23
+ () => typeof e == "object" ? JSON.stringify(e) : String(!!e),
24
+ // webMcp is intentionally listed as the only dep — we want a stable key
25
+ // based on the serialised value, not the object reference.
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ [e]
28
+ );
29
+ t.useEffect(() => {
30
+ if (!e || !(o != null && o.register))
31
+ return;
32
+ const c = typeof e == "object" ? e : void 0;
33
+ return o.register(i, n.current, u, c);
34
+ }, [f, o, i, n]);
35
+ }
36
+ export {
37
+ s as WebMcpContext,
38
+ g as WebMcpProvider,
39
+ a as getModelContext,
40
+ l as useWebMcpRegister
41
+ };