@yuktishaalaa/yuktai 5.3.10 → 5.3.12

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.
Files changed (83) hide show
  1. package/README.md +7 -7
  2. package/dist/agent-SZENB4QE.mjs +18 -0
  3. package/dist/agentic/a11yCopilot.d.ts +32 -0
  4. package/dist/agentic/contextIndex.d.ts +58 -0
  5. package/dist/agentic/designReview.d.ts +26 -0
  6. package/dist/agentic/dom.d.ts +42 -0
  7. package/dist/agentic/formReview.d.ts +38 -0
  8. package/dist/agentic/gridQuery.d.ts +64 -0
  9. package/dist/agentic/index.d.ts +13 -0
  10. package/dist/agentic/insights.d.ts +62 -0
  11. package/dist/agentic/pageInsights.d.ts +47 -0
  12. package/dist/agentic/qaAudit.d.ts +59 -0
  13. package/dist/agentic/react.d.ts +52 -0
  14. package/dist/agentic/rust/ragCoreWasm.d.ts +3 -0
  15. package/dist/agentic/rust/ragEngine.d.ts +32 -0
  16. package/dist/agentic/taskRunner.d.ts +34 -0
  17. package/dist/agentic/voiceA11yCommands.d.ts +74 -0
  18. package/dist/chunk-K2IBRN5C.mjs +1 -0
  19. package/dist/chunk-M2OKTFX3.mjs +11 -0
  20. package/dist/chunk-N2HHE7YH.mjs +1 -0
  21. package/dist/core/a11yEngine.d.ts +5 -0
  22. package/dist/core/ai/agent.d.ts +21 -0
  23. package/dist/core/ai/labeller.d.ts +12 -0
  24. package/dist/core/ai/promptOptions.d.ts +16 -0
  25. package/dist/core/ai/rag.d.ts +7 -0
  26. package/dist/core/ai/rewriter.d.ts +13 -0
  27. package/dist/core/ai/summarizer.d.ts +8 -0
  28. package/dist/core/ai/transformers-rag.d.ts +9 -0
  29. package/dist/core/ai/translator.d.ts +14 -0
  30. package/dist/core/ai/voice.d.ts +33 -0
  31. package/dist/core/codegen/page-templates.d.ts +32 -0
  32. package/dist/core/codegen/requirement-parser.d.ts +12 -0
  33. package/dist/core/codegen/zip-generator.d.ts +2 -0
  34. package/dist/core/generateUI.d.ts +4 -0
  35. package/dist/core/renderer.d.ts +72 -0
  36. package/dist/grid/YuktaiGrid.d.ts +4 -0
  37. package/dist/grid/YuktaiGridAI.d.ts +46 -0
  38. package/dist/grid/YuktaiGridAgent.d.ts +81 -0
  39. package/dist/grid/YuktaiGridWebMCP.d.ts +54 -0
  40. package/dist/grid/gridTools.d.ts +111 -0
  41. package/dist/grid/rust/engine.d.ts +55 -0
  42. package/dist/grid/rust/gridCoreWasm.d.ts +3 -0
  43. package/dist/grid/rust/useGridCore.d.ts +2 -0
  44. package/dist/grid/types.d.ts +245 -0
  45. package/dist/grid/useGrid.d.ts +57 -0
  46. package/dist/grid/yuktaiGridRows.d.ts +35 -0
  47. package/dist/icons/CheckIcon.d.ts +2 -0
  48. package/dist/icons/ChevronLeftIcon.d.ts +2 -0
  49. package/dist/icons/ChevronRightIcon.d.ts +2 -0
  50. package/dist/icons/CloseIcon.d.ts +2 -0
  51. package/dist/icons/IconBase.d.ts +25 -0
  52. package/dist/icons/SearchIcon.d.ts +2 -0
  53. package/dist/icons/SortDownIcon.d.ts +2 -0
  54. package/dist/icons/SortUpIcon.d.ts +2 -0
  55. package/dist/icons/YuktaiIcon.d.ts +320 -0
  56. package/dist/icons/index.d.ts +16 -0
  57. package/dist/icons/paths.d.ts +167 -0
  58. package/dist/icons/variant.d.ts +42 -0
  59. package/dist/icons.d.mts +1 -568
  60. package/dist/icons.d.ts +1 -568
  61. package/dist/icons.js +1 -1
  62. package/dist/icons.mjs +1 -1
  63. package/dist/index.d.mts +2 -1337
  64. package/dist/index.d.ts +36 -1315
  65. package/dist/index.js +69 -69
  66. package/dist/index.mjs +42 -42
  67. package/dist/next/YuktAIWrapper.d.ts +2 -0
  68. package/dist/plugins/ai.d.ts +4 -0
  69. package/dist/plugins/voice.d.ts +4 -0
  70. package/dist/plugins/wcag.d.ts +98 -0
  71. package/dist/rag-O3FDQPTX.mjs +1 -0
  72. package/dist/react/CodeGenPanel.d.ts +7 -0
  73. package/dist/react/WidgetPanel.d.ts +38 -0
  74. package/dist/react/YuktAIWrapper.d.ts +35 -0
  75. package/dist/renderer.global.js +23 -23
  76. package/dist/runtime/runtime.d.ts +18 -0
  77. package/package.json +5 -3
  78. package/vanilla/index.js +51 -29
  79. package/vanilla/index.min.js +45 -45
  80. package/dist/agent-G67IA7MY.mjs +0 -18
  81. package/dist/chunk-7BGINZ5U.mjs +0 -1
  82. package/dist/chunk-P2PBML6K.mjs +0 -11
  83. package/dist/rag-Q3LUXSSD.mjs +0 -1
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+ import type { GridInputLanguage } from "./types";
3
+ type UILanguage = "en-US" | "te-IN";
4
+ type InputLanguage = GridInputLanguage;
5
+ export interface YuktaiGridAIProps<T> {
6
+ data: T[];
7
+ columns: {
8
+ key: string;
9
+ label: string;
10
+ type?: "number" | "text" | "date";
11
+ }[];
12
+ onSearch?: (query: string) => void;
13
+ onSort?: (key: string, dir: "asc" | "desc") => void;
14
+ theme?: "light" | "dark";
15
+ /**
16
+ * Language of AI UI and AI responses.
17
+ * Default: English.
18
+ */
19
+ language?: UILanguage;
20
+ /**
21
+ * Language used by browser voice recognition.
22
+ * Default: English.
23
+ */
24
+ inputLanguage?: InputLanguage;
25
+ /**
26
+ * When true, AI is rendered inside the grid.
27
+ * When false, AI uses the floating assistant UI.
28
+ */
29
+ embedded?: boolean;
30
+ /**
31
+ * The grid Agent.
32
+ */
33
+ agent?: {
34
+ ask: (text: string) => Promise<{
35
+ success: boolean;
36
+ message: string;
37
+ }>;
38
+ loading?: boolean;
39
+ };
40
+ /**
41
+ * Called when the person switches the voice input language.
42
+ */
43
+ onInputLanguageChange?: (language: InputLanguage) => void;
44
+ }
45
+ export declare function YuktaiGridAI<T extends Record<string, unknown>>({ data, columns, onSearch, onSort, theme, language, inputLanguage, embedded, agent, onInputLanguageChange, }: YuktaiGridAIProps<T>): React.JSX.Element;
46
+ export default YuktaiGridAI;
@@ -0,0 +1,81 @@
1
+ import { type GridToolErrorCode, type GridToolLocale, type GridToolResult } from "./gridTools";
2
+ import type { YuktaiGridRule } from "./types";
3
+ export type GridAgentTool = {
4
+ name: string;
5
+ description: string;
6
+ /** Optional UI label (e.g. Telugu). createGridTools() provides it. */
7
+ label?: string;
8
+ /** Optional JSON schema; its `required` list is checked before running. */
9
+ inputSchema?: Record<string, unknown>;
10
+ execute: (input: Record<string, unknown>) => Promise<unknown> | unknown;
11
+ };
12
+ export type GridAgentErrorCode = GridToolErrorCode | "NOT_UNDERSTOOD";
13
+ export type GridAgentResult<T = unknown> = Omit<GridToolResult<T>, "error"> & {
14
+ error?: {
15
+ code: GridAgentErrorCode;
16
+ };
17
+ /** Full name of the tool that produced this result */
18
+ tool?: string;
19
+ };
20
+ export type GridAgentStep = {
21
+ id: number;
22
+ tool: string;
23
+ input: Record<string, unknown>;
24
+ result: GridAgentResult;
25
+ source: "tool" | "ask";
26
+ at: number;
27
+ };
28
+ export type GridIntent = {
29
+ kind: "tool";
30
+ tool: string;
31
+ input: Record<string, unknown>;
32
+ }
33
+ /**
34
+ * "open <something>": search for it, then open the first match
35
+ */
36
+ | {
37
+ kind: "open";
38
+ text: string;
39
+ };
40
+ export type GridIntentContext = {
41
+ columns: {
42
+ key: string;
43
+ label: string;
44
+ }[];
45
+ locale: GridToolLocale;
46
+ };
47
+ export type YuktaiGridAgentProps<T = Record<string, unknown>> = {
48
+ tools: GridAgentTool[];
49
+ /** Current grid data available to application-defined rules. */
50
+ data?: T[];
51
+ onResult?: (result: GridAgentResult) => void;
52
+ onError?: (error: Error) => void;
53
+ /** Language of the agent's own messages (default "en"). */
54
+ locale?: GridToolLocale;
55
+ /** Columns, so ask() can understand "sort by <column>". */
56
+ columns?: {
57
+ key: string;
58
+ label: string;
59
+ }[];
60
+ /** Row ID field — must match the grid's rowKey (default "id"). */
61
+ rowKey?: string;
62
+ /** Replace the built-in regex intent parser. */
63
+ parseIntent?: (text: string, context: GridIntentContext) => GridIntent | null;
64
+ /** Application-defined content rules executed before the generic intent parser. */
65
+ customRules?: YuktaiGridRule<T>[];
66
+ /** How many steps to keep in history (default 20). */
67
+ historyLimit?: number;
68
+ };
69
+ /** Built-in parser: exported so it can be tested and reused. */
70
+ export declare function parseGridIntent(text: string, context: GridIntentContext): GridIntent | null;
71
+ export declare function useYuktaiGridAgent<T = Record<string, unknown>>({ tools, data, onResult, onError, locale, columns, rowKey, parseIntent: customParseIntent, customRules, historyLimit, }: YuktaiGridAgentProps<T>): {
72
+ loading: boolean;
73
+ tools: GridAgentTool[];
74
+ executeTool: (name: string, input?: Record<string, unknown>) => Promise<GridAgentResult<unknown>>;
75
+ ask: (text: string) => Promise<GridAgentResult>;
76
+ lastResult: GridAgentResult<unknown> | null;
77
+ lastError: Error | null;
78
+ history: GridAgentStep[];
79
+ clearHistory: () => void;
80
+ };
81
+ export default useYuktaiGridAgent;
@@ -0,0 +1,54 @@
1
+ import { type CreateGridToolsOptions, type GridTool, type GridToolLocale } from "./gridTools";
2
+ type ModelContextTool = {
3
+ name: string;
4
+ title: string;
5
+ description: string;
6
+ inputSchema: Record<string, unknown>;
7
+ execute: (input: any) => Promise<unknown> | unknown;
8
+ };
9
+ declare global {
10
+ interface Document {
11
+ modelContext?: {
12
+ registerTool: (tool: ModelContextTool, options?: {
13
+ signal?: AbortSignal;
14
+ }) => Promise<void>;
15
+ };
16
+ }
17
+ }
18
+ export type WebMCPState = "unsupported" | "registering" | "ready" | "partial" | "error";
19
+ export type WebMCPStatus = {
20
+ state: WebMCPState;
21
+ /** Tools that the browser actually accepted */
22
+ registered: string[];
23
+ errors: {
24
+ tool: string;
25
+ message: string;
26
+ }[];
27
+ };
28
+ type WebMCPColumn = {
29
+ key: string;
30
+ label: string;
31
+ type?: "text" | "number" | "date";
32
+ };
33
+ export type YuktaiGridWebMCPProps<T> = {
34
+ /**
35
+ * Ready-made tools (YuktaiGrid passes its own list here). When given,
36
+ * data/columns/callbacks below are not needed.
37
+ */
38
+ tools?: GridTool[];
39
+ data?: T[];
40
+ columns?: WebMCPColumn[];
41
+ rowKey?: string;
42
+ locale?: GridToolLocale;
43
+ onSelectRow?: (id: string) => void;
44
+ onHighlightRows?: (ids: string[]) => void;
45
+ onOpenRow?: (id: string) => void;
46
+ /** Tool name prefix (default "yuktai_grid") */
47
+ name?: string;
48
+ /** Agent-facing descriptions per tool, e.g. { search: "Search Telugu poems…" } */
49
+ descriptions?: CreateGridToolsOptions["descriptions"];
50
+ /** Called whenever the registration status changes */
51
+ onStatusChange?: (status: WebMCPStatus) => void;
52
+ };
53
+ export declare function YuktaiGridWebMCP<T extends Record<string, unknown>>({ tools: toolsProp, data, columns, rowKey, locale, onSelectRow, onHighlightRows, onOpenRow, name, descriptions, onStatusChange, }: YuktaiGridWebMCPProps<T>): null;
54
+ export default YuktaiGridWebMCP;
@@ -0,0 +1,111 @@
1
+ /**
2
+ * gridTools — the ONE place where YuktaiGrid tools are defined.
3
+ *
4
+ * Both the in-page Agent (useYuktaiGridAgent) and WebMCP (YuktaiGridWebMCP)
5
+ * should get their tools from `createGridTools()`, so the list an agent sees
6
+ * can never drift from the list the UI shows.
7
+ *
8
+ * Rules every tool follows:
9
+ * 1. One row-ID strategy: `getRowId(row, context.rowKey)` everywhere.
10
+ * `rowKey` must match YuktaiGrid's `rowKey` prop (default "id").
11
+ * 2. One result shape: { success, message, data?, error?: { code } }.
12
+ * 3. Never claim success for something that didn't happen:
13
+ * missing callback → NOT_SUPPORTED, unknown row → NOT_FOUND.
14
+ * 4. Never throw: tool execution is wrapped, errors become INTERNAL results.
15
+ *
16
+ * Backward compatible with 4.6.x: the existing exports keep their names and
17
+ * parameters; results only gain an optional `error` field.
18
+ */
19
+ export type GridToolColumn = {
20
+ key: string;
21
+ label: string;
22
+ type?: "text" | "number" | "date";
23
+ };
24
+ export type GridToolErrorCode = "NOT_FOUND" | "NOT_SUPPORTED" | "INVALID_INPUT" | "INTERNAL";
25
+ export type GridToolFilterOperator = "contains" | "equals" | "startsWith" | "endsWith" | "greaterThan" | "lessThan" | "between";
26
+ export type GridToolFilter = {
27
+ key: string;
28
+ operator: GridToolFilterOperator;
29
+ value: string | number | [number, number];
30
+ };
31
+ export type GridToolSort = {
32
+ key: string;
33
+ direction: "asc" | "desc";
34
+ };
35
+ /** Language of `message` (shown to people). Agent descriptions stay English. */
36
+ export type GridToolLocale = "en" | "te";
37
+ export type GridToolContext<T> = {
38
+ data: T[];
39
+ columns: GridToolColumn[];
40
+ /** Field used as the row ID by every tool (default "id"). Match YuktaiGrid's rowKey. */
41
+ rowKey?: string;
42
+ /** Language for result messages (default "en"). */
43
+ locale?: GridToolLocale;
44
+ /** Filters currently applied, so a new filter can be merged in. */
45
+ filters?: GridToolFilter[];
46
+ onSelectRow?: (id: string) => void;
47
+ onHighlightRows?: (ids: string[]) => void;
48
+ onOpenRow?: (id: string) => void;
49
+ onFiltersChange?: (filters: GridToolFilter[]) => void;
50
+ onSortChange?: (sort: GridToolSort | null) => void;
51
+ };
52
+ export type GridToolResult<T = unknown> = {
53
+ success: boolean;
54
+ message: string;
55
+ data?: T;
56
+ error?: {
57
+ code: GridToolErrorCode;
58
+ };
59
+ };
60
+ /** A tool ready for the Agent and for WebMCP `registerTool`. */
61
+ export type GridTool = {
62
+ name: string;
63
+ title: string;
64
+ /** For AI agents (English works best for tool selection). Never shown in the UI. */
65
+ description: string;
66
+ /** Short label for the UI, in the grid's locale. */
67
+ label: string;
68
+ inputSchema: Record<string, unknown>;
69
+ execute: (input: Record<string, unknown>) => Promise<GridToolResult>;
70
+ };
71
+ export type CreateGridToolsOptions = {
72
+ /** Tool name prefix, e.g. "ratnalabala_poems" → "ratnalabala_poems_search". */
73
+ name?: string;
74
+ /** Override agent descriptions per tool, keyed by the short tool id ("search", "open", …). */
75
+ descriptions?: Partial<Record<GridToolId, string>>;
76
+ };
77
+ export type GridToolId = "search" | "count" | "columns" | "get_row" | "highlight" | "select" | "open" | "filter" | "clear_filters" | "sort" | "clear_sort";
78
+ /** The single row-ID rule used by every tool. */
79
+ export declare function getRowId(row: unknown, rowKey?: string): string;
80
+ /**
81
+ * Applies filters to rows — exported so YuktaiGrid filters its rows with
82
+ * exactly the same rules the filter tool uses to count matches.
83
+ */
84
+ export declare function applyGridFilters<T>(data: T[], columns: GridToolColumn[], filters: GridToolFilter[]): T[];
85
+ /** Maps grid columns (any type) to tool columns (text / number / date). */
86
+ export declare function toGridToolColumns(columns: {
87
+ key: string;
88
+ label: string;
89
+ type?: string;
90
+ }[]): GridToolColumn[];
91
+ export declare function searchGrid<T extends Record<string, unknown>>(context: GridToolContext<T>, query: string): GridToolResult<T[]>;
92
+ export declare function countGrid<T>(context: GridToolContext<T>): GridToolResult<number>;
93
+ export declare function getColumns<T>(context: GridToolContext<T>): GridToolResult<GridToolColumn[]>;
94
+ export declare function getRow<T extends Record<string, unknown>>(context: GridToolContext<T>, id: string): GridToolResult<T>;
95
+ export declare function highlightRows<T extends Record<string, unknown>>(context: GridToolContext<T>, ids: string[]): GridToolResult<string[]>;
96
+ export declare function selectRow<T extends Record<string, unknown>>(context: GridToolContext<T>, id: string): GridToolResult<string>;
97
+ export declare function openRow<T extends Record<string, unknown>>(context: GridToolContext<T>, id: string): GridToolResult<string>;
98
+ export declare function filterGrid<T extends Record<string, unknown>>(context: GridToolContext<T>, filter: GridToolFilter): GridToolResult<{
99
+ filters: GridToolFilter[];
100
+ count: number;
101
+ }>;
102
+ export declare function clearFilters<T>(context: GridToolContext<T>): GridToolResult<GridToolFilter[]>;
103
+ export declare function sortGrid<T>(context: GridToolContext<T>, key: string, direction?: "asc" | "desc"): GridToolResult<GridToolSort>;
104
+ export declare function clearSort<T>(context: GridToolContext<T>): GridToolResult<null>;
105
+ /**
106
+ * Builds the tool list used by BOTH the Agent and WebMCP.
107
+ * Only tools the grid can actually perform are included — e.g. "open" is
108
+ * left out when no onOpenRow callback is given — so agents never see a tool
109
+ * that would just return NOT_SUPPORTED.
110
+ */
111
+ export declare function createGridTools<T extends Record<string, unknown>>(context: GridToolContext<T>, options?: CreateGridToolsOptions): GridTool[];
@@ -0,0 +1,55 @@
1
+ /** Which engine sorts and searches the grid. */
2
+ export type GridEngine = "ts" | "rust" | "auto";
3
+ /** `engine: "auto"` switches to Rust from this many rows. */
4
+ export declare const RUST_AUTO_MIN_ROWS = 10000;
5
+ /** Joins a row's column values for search. Queries containing it fall back to TypeScript. */
6
+ export declare const SEARCH_SEPARATOR = "\0";
7
+ export declare function wantsRustEngine(engine: GridEngine | undefined, rowCount: number): boolean;
8
+ /** Decodes an embedded WebAssembly module (browser atob, or Node Buffer). */
9
+ export declare function decodeBase64(b64: string): Uint8Array;
10
+ /**
11
+ * Compiles the Rust engine once per page. Resolves `null` when WebAssembly is
12
+ * not available; the grid then simply keeps using TypeScript.
13
+ */
14
+ export declare function loadGridCore(): Promise<WebAssembly.Module | null>;
15
+ /** The compiled engine if `loadGridCore()` has already finished, else null. */
16
+ export declare function getLoadedGridCore(): WebAssembly.Module | null;
17
+ /**
18
+ * One engine per grid. Holds that grid's search text inside the WebAssembly
19
+ * memory, so each keystroke only sends the query.
20
+ */
21
+ export declare class GridCore {
22
+ private readonly x;
23
+ private readonly base;
24
+ private readonly encoder;
25
+ private offsetsPtr;
26
+ private textPtr;
27
+ private textLen;
28
+ private rows;
29
+ private hasIndex;
30
+ private freePtr;
31
+ private constructor();
32
+ /** Creates an engine from a compiled module (default: the one already loaded). */
33
+ static create(mod?: WebAssembly.Module | null): GridCore | null;
34
+ private ensure;
35
+ /**
36
+ * Stores one search text per row (the grid joins its columns with
37
+ * SEARCH_SEPARATOR). Returns false when Rust can't match TypeScript
38
+ * exactly for this data; the grid then searches in TypeScript.
39
+ */
40
+ setSearchTexts(texts: string[]): boolean;
41
+ /**
42
+ * Positions (in the array given to setSearchTexts) of the rows whose text
43
+ * contains `query`, in original order. Null means "use TypeScript".
44
+ */
45
+ search(query: string): Uint32Array | null;
46
+ /**
47
+ * Row positions sorted by `keys` (NaN = empty, always last; equal keys keep
48
+ * their order). Null means "use TypeScript".
49
+ */
50
+ sortByKeys(keys: Float64Array, desc: boolean): Uint32Array | null;
51
+ }
52
+ /** "0.9 ms", "12 ms", "<0.1 ms" — for search time labels. */
53
+ export declare function formatSearchTime(ms: number): string;
54
+ /** Picks `rows[i]` for each position, keeping the given order. */
55
+ export declare function pickRows<T>(rows: readonly T[], positions: Uint32Array): T[];
@@ -0,0 +1,3 @@
1
+ /** yuktai grid-core WebAssembly (12810 bytes), base64. */
2
+ export declare const GRID_CORE_WASM_BASE64: string;
3
+ export declare const GRID_CORE_WASM_SIZE = 12810;
@@ -0,0 +1,2 @@
1
+ import { GridCore, type GridEngine } from "./engine";
2
+ export declare function useGridCore(engine: GridEngine | undefined, rowCount: number): GridCore | null;
@@ -0,0 +1,245 @@
1
+ import type { ReactNode } from "react";
2
+ import type { GridEngine } from "./rust/engine";
3
+ /** One search/sort run: what was searched, how long it took, which engine answered. */
4
+ export interface GridSearchTime {
5
+ /** The search text ("" when only sorting) */
6
+ query: string;
7
+ /** Milliseconds for search + filters + sort */
8
+ ms: number;
9
+ /** Rows after search and filters */
10
+ rows: number;
11
+ engine: "rust" | "ts";
12
+ }
13
+ export interface GridColumn<T = Record<string, unknown>> {
14
+ key: keyof T & string;
15
+ label: string;
16
+ sortable?: boolean;
17
+ filterable?: boolean;
18
+ hiddenOnMobile?: boolean;
19
+ pinned?: boolean;
20
+ width?: number | string;
21
+ render?: (value: T[keyof T], row: T, index: number) => ReactNode;
22
+ align?: "left" | "center" | "right";
23
+ type?: "text" | "number" | "date" | "boolean" | "badge";
24
+ }
25
+ export type SortDirection = "asc" | "desc" | null;
26
+ export interface SortConfig {
27
+ key: string;
28
+ direction: SortDirection;
29
+ }
30
+ export type FilterOperator = "contains" | "equals" | "startsWith" | "endsWith" | "greaterThan" | "lessThan" | "between";
31
+ export interface FilterConfig {
32
+ key: string;
33
+ operator: FilterOperator;
34
+ value: string | number | [number, number];
35
+ }
36
+ export type ViewMode = "table" | "card" | "auto";
37
+ export type GridTheme = "default" | "high-contrast" | "dark" | "color-blind" | "dyslexia";
38
+ export type IndicLanguageLocale = "as-IN" | "bn-IN" | "brx-IN" | "doi-IN" | "gu-IN" | "hi-IN" | "kn-IN" | "ks-IN" | "kok-IN" | "mai-IN" | "ml-IN" | "mni-IN" | "mr-IN" | "ne-IN" | "or-IN" | "pa-IN" | "sa-IN" | "sat-IN" | "sd-IN" | "ta-IN" | "te-IN" | "ur-IN";
39
+ export type GridLocale = "en-IN" | "en-US" | IndicLanguageLocale;
40
+ export type GridInputLanguage = GridLocale;
41
+ export interface AIFeatures {
42
+ search?: boolean;
43
+ summary?: boolean;
44
+ anomaly?: boolean;
45
+ suggest?: boolean;
46
+ }
47
+ export interface VoiceFeatures {
48
+ control?: boolean;
49
+ speakOnFocus?: boolean;
50
+ speakSummary?: boolean;
51
+ language?: string;
52
+ }
53
+ export interface PaginationConfig {
54
+ pageSize?: number;
55
+ showSizeChanger?: boolean;
56
+ sizeOptions?: number[];
57
+ }
58
+ export interface GridTranslations {
59
+ search: string;
60
+ noData: string;
61
+ loading: string;
62
+ rowsSelected: string;
63
+ page: string;
64
+ of: string;
65
+ showing: string;
66
+ to: string;
67
+ results: string;
68
+ sort: string;
69
+ filter: string;
70
+ export: string;
71
+ voice: string;
72
+ ask: string;
73
+ }
74
+ export interface YuktaiGridRuleContext<T = Record<string, unknown>> {
75
+ /**
76
+ * Original user input.
77
+ */
78
+ input: string;
79
+ /**
80
+ * Current grid data.
81
+ */
82
+ data: T[];
83
+ /**
84
+ * Available grid columns.
85
+ */
86
+ columns: {
87
+ key: string;
88
+ label: string;
89
+ }[];
90
+ /**
91
+ * Execute one of the generic Grid tools.
92
+ *
93
+ * Example:
94
+ *
95
+ * executeTool("count")
96
+ *
97
+ * executeTool("filter", {
98
+ * key: "lines",
99
+ * operator: "greaterThan",
100
+ * value: 6
101
+ * })
102
+ */
103
+ executeTool: (name: string, input?: Record<string, unknown>) => Promise<{
104
+ success: boolean;
105
+ message: string;
106
+ data?: unknown;
107
+ error?: {
108
+ code: string;
109
+ };
110
+ tool?: string;
111
+ }>;
112
+ }
113
+ export interface YuktaiGridRule<T = Record<string, unknown>> {
114
+ /**
115
+ * Application-defined rule name.
116
+ */
117
+ name: string;
118
+ /**
119
+ * User phrases that activate this rule.
120
+ */
121
+ phrases: string[];
122
+ /**
123
+ * Optional description for documentation/debugging.
124
+ */
125
+ description?: string;
126
+ /**
127
+ * Application-specific execution logic.
128
+ *
129
+ * The package does NOT contain application-specific rules.
130
+ */
131
+ execute: (context: YuktaiGridRuleContext<T>) => Promise<string> | string;
132
+ }
133
+ export interface YuktaiGridProps<T = Record<string, unknown>> {
134
+ data: T[];
135
+ columns: GridColumn<T>[];
136
+ view?: ViewMode;
137
+ mobileBreakpoint?: number;
138
+ theme?: GridTheme;
139
+ locale?: GridLocale;
140
+ ai?: boolean | AIFeatures;
141
+ voice?: boolean | VoiceFeatures;
142
+ pagination?: boolean | PaginationConfig;
143
+ search?: boolean;
144
+ selectable?: boolean;
145
+ selectedKeys?: string[];
146
+ rowKey?: keyof T & string;
147
+ loading?: boolean;
148
+ empty?: ReactNode;
149
+ highlightIds?: (string | number)[];
150
+ highlightColor?: string;
151
+ autoScrollToHighlight?: boolean;
152
+ onSelectionChange?: (keys: string[]) => void;
153
+ onRowClick?: (row: T, index: number) => void;
154
+ onSortChange?: (sort: SortConfig | null) => void;
155
+ className?: string;
156
+ /**
157
+ * Voice/input language of the embedded assistant.
158
+ *
159
+ * Supports English and the 22 Indian Scheduled Languages.
160
+ */
161
+ inputLanguage?: "en-IN" | "en-US" | IndicLanguageLocale;
162
+ /**
163
+ * Prefix for WebMCP / Agent tool names.
164
+ *
165
+ * Example:
166
+ *
167
+ * "ratnalabala_poems"
168
+ *
169
+ * produces:
170
+ *
171
+ * ratnalabala_poems_search
172
+ * ratnalabala_poems_filter
173
+ * ratnalabala_poems_sort
174
+ */
175
+ toolName?: string;
176
+ /**
177
+ * Agent-facing tool descriptions.
178
+ */
179
+ toolDescriptions?: Partial<Record<"search" | "count" | "columns" | "get_row" | "highlight" | "select" | "open" | "filter" | "clear_filters" | "sort" | "clear_sort", string>>;
180
+ /**
181
+ * Expose Grid tools to AI agents through WebMCP.
182
+ */
183
+ webmcp?: boolean;
184
+ /**
185
+ * Real WebMCP registration status.
186
+ */
187
+ onWebMCPStatusChange?: (status: {
188
+ state: "unsupported" | "registering" | "ready" | "partial" | "error";
189
+ registered: string[];
190
+ errors: {
191
+ tool: string;
192
+ message: string;
193
+ }[];
194
+ }) => void;
195
+ /**
196
+ * Application-specific Agent rules.
197
+ *
198
+ * Example:
199
+ *
200
+ * customRules={[
201
+ * {
202
+ * name: "show-long-poems",
203
+ * phrases: ["పెద్ద పద్యాలు"],
204
+ * execute: async ({ executeTool }) => {
205
+ * const result = await executeTool("filter", {
206
+ * key: "lines",
207
+ * operator: "greaterThan",
208
+ * value: 6,
209
+ * })
210
+ *
211
+ * return result.message
212
+ * },
213
+ * },
214
+ * ]}
215
+ */
216
+ customRules?: YuktaiGridRule<T>[];
217
+ /**
218
+ * Search and sort engine.
219
+ *
220
+ * - "rust" (default since v5.3.11): the Rust (WebAssembly) engine, about
221
+ * 13 KB, embedded. Falls back to TypeScript when WebAssembly is missing
222
+ * or blocked by a Content Security Policy.
223
+ * - "auto": Rust from 10,000 rows, TypeScript below
224
+ * - "ts": TypeScript only, as before v5.3.11
225
+ *
226
+ * Results are identical. Rust handles search and number/date sorting;
227
+ * text sorting always uses TypeScript (browser locale rules for Telugu).
228
+ */
229
+ engine?: GridEngine;
230
+ /**
231
+ * Show how long the last search/sort took and which engine answered,
232
+ * next to the row count, e.g. "12 rows · 0.9 ms · Rust". Default: false.
233
+ */
234
+ showSearchTime?: boolean;
235
+ /** Called after every search or sort with its time and engine. */
236
+ onSearchTime?: (info: GridSearchTime) => void;
237
+ /**
238
+ * Every result from the Agent.
239
+ */
240
+ onAgentResult?: (result: {
241
+ success: boolean;
242
+ message: string;
243
+ tool?: string;
244
+ }) => void;
245
+ }
@@ -0,0 +1,57 @@
1
+ import type { GridColumn, GridSearchTime, SortConfig, PaginationConfig } from "./types";
2
+ import { type GridToolFilter } from "./gridTools";
3
+ import { type GridEngine } from "./rust/engine";
4
+ export interface UseGridOptions<T> {
5
+ data: T[];
6
+ columns: GridColumn<T>[];
7
+ pagination?: boolean | PaginationConfig;
8
+ mobileBreakpoint?: number;
9
+ /** Locale for text sorting, e.g. "te-IN" (default: browser locale) */
10
+ locale?: string;
11
+ /** Starting filters (optional) */
12
+ initialFilters?: GridToolFilter[];
13
+ /**
14
+ * Search and sort engine: "ts" (default), "rust" (always) or "auto" (Rust
15
+ * from 10,000 rows). Same results either way; Rust is faster on big data.
16
+ */
17
+ engine?: GridEngine;
18
+ }
19
+ export interface UseGridReturn<T> {
20
+ displayedData: T[];
21
+ /** All matching rows (search + filters + sort), before pagination */
22
+ rows: T[];
23
+ totalCount: number;
24
+ filteredCount: number;
25
+ sort: SortConfig | null;
26
+ toggleSort: (key: string) => void;
27
+ /** Set sort directly (null clears it) */
28
+ setSort: (sort: SortConfig | null) => void;
29
+ clearSort: () => void;
30
+ searchQuery: string;
31
+ setSearchQuery: (q: string) => void;
32
+ filters: GridToolFilter[];
33
+ setFilters: (filters: GridToolFilter[]) => void;
34
+ /** Add or replace the filter for one column */
35
+ setFilter: (filter: GridToolFilter) => void;
36
+ /** Remove the filter for one column */
37
+ removeFilter: (key: string) => void;
38
+ clearFilters: () => void;
39
+ page: number;
40
+ pageSize: number;
41
+ totalPages: number;
42
+ setPage: (p: number) => void;
43
+ setPageSize: (s: number) => void;
44
+ isMobile: boolean;
45
+ reset: () => void;
46
+ /** Last search/sort: time in ms and which engine answered (null when neither ran) */
47
+ searchTime: GridSearchTime | null;
48
+ }
49
+ /** One search text per row: each column's normalised text, joined by SEARCH_SEPARATOR. */
50
+ export declare function gridSearchTexts<T extends Record<string, unknown>>(data: readonly T[], columns: readonly GridColumn<T>[]): string[];
51
+ /**
52
+ * Sort keys that give exactly the order of compareValues(), or null when the
53
+ * column needs TypeScript (text, booleans, mixed values …). Empty = NaN.
54
+ */
55
+ export declare function gridSortKeys<T extends Record<string, unknown>>(rows: readonly T[], key: string, type: GridColumn["type"]): Float64Array | null;
56
+ export declare function useGrid<T extends Record<string, unknown>>(options: UseGridOptions<T>): UseGridReturn<T>;
57
+ export default useGrid;