@yuktishaalaa/yuktai 5.0.0 → 5.1.0

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React, { ReactNode } from 'react';
2
+ import React, { ReactNode, CSSProperties } from 'react';
3
3
 
4
4
  interface Plugin {
5
5
  name: string;
@@ -136,7 +136,9 @@ interface FilterConfig {
136
136
  }
137
137
  type ViewMode = "table" | "card" | "auto";
138
138
  type GridTheme = "default" | "high-contrast" | "dark" | "color-blind" | "dyslexia";
139
- type GridLocale = "en-IN" | "en-US" | "te-IN" | "hi-IN" | "ta-IN" | "bn-IN" | "mr-IN" | "kn-IN" | "ml-IN" | "gu-IN" | "pa-IN" | "ur-IN";
139
+ 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";
140
+ type GridLocale = "en-IN" | "en-US" | IndicLanguageLocale;
141
+ type GridInputLanguage = GridLocale;
140
142
  interface AIFeatures {
141
143
  search?: boolean;
142
144
  summary?: boolean;
@@ -171,21 +173,62 @@ interface GridTranslations {
171
173
  ask: string;
172
174
  }
173
175
  interface YuktaiGridRuleContext<T = Record<string, unknown>> {
176
+ /**
177
+ * Original user input.
178
+ */
174
179
  input: string;
180
+ /**
181
+ * Current grid data.
182
+ */
175
183
  data: T[];
184
+ /**
185
+ * Available grid columns.
186
+ */
176
187
  columns: {
177
188
  key: string;
178
189
  label: string;
179
190
  }[];
191
+ /**
192
+ * Execute one of the generic Grid tools.
193
+ *
194
+ * Example:
195
+ *
196
+ * executeTool("count")
197
+ *
198
+ * executeTool("filter", {
199
+ * key: "lines",
200
+ * operator: "greaterThan",
201
+ * value: 6
202
+ * })
203
+ */
204
+ executeTool: (name: string, input?: Record<string, unknown>) => Promise<{
205
+ success: boolean;
206
+ message: string;
207
+ data?: unknown;
208
+ error?: {
209
+ code: string;
210
+ };
211
+ tool?: string;
212
+ }>;
180
213
  }
181
214
  interface YuktaiGridRule<T = Record<string, unknown>> {
182
- /** Application-defined rule name. */
215
+ /**
216
+ * Application-defined rule name.
217
+ */
183
218
  name: string;
184
- /** Phrases that activate this rule. */
219
+ /**
220
+ * User phrases that activate this rule.
221
+ */
185
222
  phrases: string[];
186
- /** Optional description for documentation/debugging. */
223
+ /**
224
+ * Optional description for documentation/debugging.
225
+ */
187
226
  description?: string;
188
- /** Application-specific execution logic. */
227
+ /**
228
+ * Application-specific execution logic.
229
+ *
230
+ * The package does NOT contain application-specific rules.
231
+ */
189
232
  execute: (context: YuktaiGridRuleContext<T>) => Promise<string> | string;
190
233
  }
191
234
  interface YuktaiGridProps<T = Record<string, unknown>> {
@@ -211,18 +254,37 @@ interface YuktaiGridProps<T = Record<string, unknown>> {
211
254
  onRowClick?: (row: T, index: number) => void;
212
255
  onSortChange?: (sort: SortConfig | null) => void;
213
256
  className?: string;
214
- /** Voice input language of the embedded assistant (default: follows `locale`). */
215
- inputLanguage?: "en-US" | "te-IN";
216
- /** Prefix for tool names, e.g. "ratnalabala_poems" → "ratnalabala_poems_search". */
257
+ /**
258
+ * Voice/input language of the embedded assistant.
259
+ *
260
+ * Supports English and the 22 Indian Scheduled Languages.
261
+ */
262
+ inputLanguage?: "en-IN" | "en-US" | IndicLanguageLocale;
263
+ /**
264
+ * Prefix for WebMCP / Agent tool names.
265
+ *
266
+ * Example:
267
+ *
268
+ * "ratnalabala_poems"
269
+ *
270
+ * produces:
271
+ *
272
+ * ratnalabala_poems_search
273
+ * ratnalabala_poems_filter
274
+ * ratnalabala_poems_sort
275
+ */
217
276
  toolName?: string;
218
- /** Agent-facing tool descriptions, e.g. { search: "Search Telugu poems by title or text." } */
277
+ /**
278
+ * Agent-facing tool descriptions.
279
+ */
219
280
  toolDescriptions?: Partial<Record<"search" | "count" | "columns" | "get_row" | "highlight" | "select" | "open" | "filter" | "clear_filters" | "sort" | "clear_sort", string>>;
220
281
  /**
221
- * Expose the grid's tools to AI agents via WebMCP (document.modelContext).
222
- * Uses exactly the same tools as the embedded assistant.
282
+ * Expose Grid tools to AI agents through WebMCP.
223
283
  */
224
284
  webmcp?: boolean;
225
- /** Real WebMCP registration status (state, registered tools, errors). */
285
+ /**
286
+ * Real WebMCP registration status.
287
+ */
226
288
  onWebMCPStatusChange?: (status: {
227
289
  state: "unsupported" | "registering" | "ready" | "partial" | "error";
228
290
  registered: string[];
@@ -231,9 +293,31 @@ interface YuktaiGridProps<T = Record<string, unknown>> {
231
293
  message: string;
232
294
  }[];
233
295
  }) => void;
234
- /** Application-defined content rules executed before generic Grid intent parsing. */
296
+ /**
297
+ * Application-specific Agent rules.
298
+ *
299
+ * Example:
300
+ *
301
+ * customRules={[
302
+ * {
303
+ * name: "show-long-poems",
304
+ * phrases: ["పెద్ద పద్యాలు"],
305
+ * execute: async ({ executeTool }) => {
306
+ * const result = await executeTool("filter", {
307
+ * key: "lines",
308
+ * operator: "greaterThan",
309
+ * value: 6,
310
+ * })
311
+ *
312
+ * return result.message
313
+ * },
314
+ * },
315
+ * ]}
316
+ */
235
317
  customRules?: YuktaiGridRule<T>[];
236
- /** Every result from the Agent (assistant or WebMCP), e.g. for logging. */
318
+ /**
319
+ * Every result from the Agent.
320
+ */
237
321
  onAgentResult?: (result: {
238
322
  success: boolean;
239
323
  message: string;
@@ -395,7 +479,8 @@ interface UseGridReturn<T> {
395
479
  }
396
480
  declare function useGrid<T extends Record<string, unknown>>(options: UseGridOptions<T>): UseGridReturn<T>;
397
481
 
398
- type Language = "en-US" | "te-IN";
482
+ type UILanguage = "en-US" | "te-IN";
483
+ type InputLanguage = GridInputLanguage;
399
484
  interface YuktaiGridAIProps<T> {
400
485
  data: T[];
401
486
  columns: {
@@ -403,10 +488,6 @@ interface YuktaiGridAIProps<T> {
403
488
  label: string;
404
489
  type?: "number" | "text" | "date";
405
490
  }[];
406
- /**
407
- * Used only when no `agent` is given (4.6.x behaviour).
408
- * With an agent, every action goes through agent.ask() instead.
409
- */
410
491
  onSearch?: (query: string) => void;
411
492
  onSort?: (key: string, dir: "asc" | "desc") => void;
412
493
  theme?: "light" | "dark";
@@ -414,22 +495,19 @@ interface YuktaiGridAIProps<T> {
414
495
  * Language of AI UI and AI responses.
415
496
  * Default: English.
416
497
  */
417
- language?: Language;
498
+ language?: UILanguage;
418
499
  /**
419
500
  * Language used by browser voice recognition.
420
501
  * Default: English.
421
502
  */
422
- inputLanguage?: Language;
503
+ inputLanguage?: InputLanguage;
423
504
  /**
424
505
  * When true, AI is rendered inside the grid.
425
506
  * When false, AI uses the floating assistant UI.
426
507
  */
427
508
  embedded?: boolean;
428
509
  /**
429
- * The grid Agent (from useYuktaiGridAgent). When given, search / sort /
430
- * filter / open / clear requests are sent to agent.ask() — the same
431
- * pipeline WebMCP uses — and the Agent's result message is shown.
432
- * Questions like "highest / average / total" are still answered here.
510
+ * The grid Agent.
433
511
  */
434
512
  agent?: {
435
513
  ask: (text: string) => Promise<{
@@ -438,8 +516,10 @@ interface YuktaiGridAIProps<T> {
438
516
  }>;
439
517
  loading?: boolean;
440
518
  };
441
- /** Called when the person switches the voice input language. */
442
- onInputLanguageChange?: (language: Language) => void;
519
+ /**
520
+ * Called when the person switches the voice input language.
521
+ */
522
+ onInputLanguageChange?: (language: InputLanguage) => void;
443
523
  }
444
524
  declare function YuktaiGridAI<T extends Record<string, unknown>>({ data, columns, onSearch, onSort, theme, language, inputLanguage, embedded, agent, onInputLanguageChange, }: YuktaiGridAIProps<T>): react_jsx_runtime.JSX.Element;
445
525
 
@@ -526,7 +606,9 @@ type GridIntent = {
526
606
  tool: string;
527
607
  input: Record<string, unknown>;
528
608
  }
529
- /** "open <something>": search for it, then open the first match */
609
+ /**
610
+ * "open <something>": search for it, then open the first match
611
+ */
530
612
  | {
531
613
  kind: "open";
532
614
  text: string;
@@ -553,7 +635,7 @@ type YuktaiGridAgentProps<T = Record<string, unknown>> = {
553
635
  }[];
554
636
  /** Row ID field — must match the grid's rowKey (default "id"). */
555
637
  rowKey?: string;
556
- /** Replace the built-in regex intent parser (e.g. with an on-device LLM). */
638
+ /** Replace the built-in regex intent parser. */
557
639
  parseIntent?: (text: string, context: GridIntentContext) => GridIntent | null;
558
640
  /** Application-defined content rules executed before the generic intent parser. */
559
641
  customRules?: YuktaiGridRule<T>[];
@@ -562,7 +644,7 @@ type YuktaiGridAgentProps<T = Record<string, unknown>> = {
562
644
  };
563
645
  /** Built-in parser: exported so it can be tested and reused. */
564
646
  declare function parseGridIntent(text: string, context: GridIntentContext): GridIntent | null;
565
- declare function useYuktaiGridAgent<T = Record<string, unknown>>({ tools, data, onResult, onError, locale, columns, rowKey, parseIntent, customRules, historyLimit, }: YuktaiGridAgentProps<T>): {
647
+ declare function useYuktaiGridAgent<T = Record<string, unknown>>({ tools, data, onResult, onError, locale, columns, rowKey, parseIntent: customParseIntent, customRules, historyLimit, }: YuktaiGridAgentProps<T>): {
566
648
  loading: boolean;
567
649
  tools: GridAgentTool[];
568
650
  executeTool: (name: string, input?: Record<string, unknown>) => Promise<GridAgentResult<unknown>>;
@@ -605,6 +687,544 @@ declare function CheckIcon(props: IconProps): react_jsx_runtime.JSX.Element;
605
687
 
606
688
  declare function CloseIcon(props: IconProps): react_jsx_runtime.JSX.Element;
607
689
 
690
+ type AuditRoot = Document | Element;
691
+ /** The label a screen reader would most likely announce for this element. */
692
+ declare function accessibleName(el: Element): string;
693
+ type RGBA = {
694
+ r: number;
695
+ g: number;
696
+ b: number;
697
+ a: number;
698
+ };
699
+ declare function parseColor(value: string | null | undefined): RGBA | null;
700
+ declare function relativeLuminance(c: RGBA): number;
701
+ declare function contrastRatio(fg: RGBA, bg: RGBA): number;
702
+
703
+ type AuditSeverity = "critical" | "serious" | "moderate" | "minor";
704
+ type AuditRuleId = "html-lang" | "page-title" | "image-alt" | "heading-order" | "single-h1" | "landmark-main" | "form-label" | "button-name" | "link-name" | "color-contrast" | "positive-tabindex" | "keyboard-access" | "duplicate-id" | "form-error" | "target-size";
705
+ interface AuditIssue {
706
+ /** Stable within one report, e.g. "image-alt-3". */
707
+ id: string;
708
+ rule: AuditRuleId;
709
+ severity: AuditSeverity;
710
+ /** WCAG success criterion, e.g. "1.1.1", or "best practice". */
711
+ wcag: string;
712
+ message: string;
713
+ /** Why it matters, in plain English. */
714
+ why: string;
715
+ /** What to change. */
716
+ fix: string;
717
+ selector: string;
718
+ snippet: string;
719
+ /** True when the copilot can apply a safe fix in the browser. */
720
+ autoFixable: boolean;
721
+ element?: Element;
722
+ }
723
+ interface AuditCheck {
724
+ rule: AuditRuleId;
725
+ title: string;
726
+ passed: boolean;
727
+ issueCount: number;
728
+ }
729
+ interface AuditReport {
730
+ url: string;
731
+ title: string;
732
+ generatedAt: string;
733
+ score: number;
734
+ passed: boolean;
735
+ checks: AuditCheck[];
736
+ issues: AuditIssue[];
737
+ summary: string;
738
+ }
739
+ interface AuditOptions {
740
+ root?: AuditRoot;
741
+ /** Skip rules you don't need. */
742
+ skip?: AuditRuleId[];
743
+ /** Cap contrast checks on very large pages (default 600 elements). */
744
+ maxContrastChecks?: number;
745
+ /** Minimum interactive target size in CSS px (WCAG 2.5.8 uses 24). */
746
+ minTargetSize?: number;
747
+ }
748
+ interface RuleInfo {
749
+ title: string;
750
+ wcag: string;
751
+ severity: AuditSeverity;
752
+ why: string;
753
+ }
754
+ declare const AUDIT_RULES: Record<AuditRuleId, RuleInfo>;
755
+ declare function runQaAudit(options?: AuditOptions): AuditReport;
756
+ /** Markdown report you can download, paste into a ticket or attach to a PR. */
757
+ declare function auditToMarkdown(report: AuditReport): string;
758
+ /** JSON without DOM references, safe to store or send to a server. */
759
+ declare function auditToJSON(report: AuditReport): string;
760
+
761
+ interface CopilotFixResult {
762
+ issueId: string;
763
+ applied: boolean;
764
+ message: string;
765
+ }
766
+ interface CopilotState {
767
+ report: AuditReport | null;
768
+ watching: boolean;
769
+ appliedFixes: number;
770
+ }
771
+ interface A11yCopilotOptions extends AuditOptions {
772
+ /** Called after every scan (initial, manual or caused by DOM changes). */
773
+ onUpdate?: (state: CopilotState) => void;
774
+ /** Wait this long after DOM changes before rescanning (default 600ms). */
775
+ debounceMs?: number;
776
+ /** Apply every safe fix automatically after each scan (default false). */
777
+ autoApply?: boolean;
778
+ /** Language used when the page has no lang attribute (default: browser language). */
779
+ defaultLang?: string;
780
+ }
781
+ interface A11yCopilot {
782
+ start(): void;
783
+ stop(): void;
784
+ scan(): AuditReport;
785
+ explain(issueId: string): string;
786
+ applyFix(issueId: string): CopilotFixResult;
787
+ applyAllFixes(): CopilotFixResult[];
788
+ undoAll(): number;
789
+ getState(): CopilotState;
790
+ }
791
+ declare function createA11yCopilot(options?: A11yCopilotOptions): A11yCopilot;
792
+
793
+ interface PageOutline {
794
+ title: string;
795
+ description: string;
796
+ language: string;
797
+ headings: Array<{
798
+ level: number;
799
+ text: string;
800
+ }>;
801
+ landmarks: Record<string, number>;
802
+ counts: {
803
+ links: number;
804
+ buttons: number;
805
+ images: number;
806
+ forms: number;
807
+ tables: number;
808
+ fields: number;
809
+ };
810
+ unlabeledFields: Array<{
811
+ type: string;
812
+ hint: string;
813
+ selector: string;
814
+ }>;
815
+ imagesWithoutAlt: Array<{
816
+ src: string;
817
+ selector: string;
818
+ }>;
819
+ purpose: string;
820
+ }
821
+ interface PageAnswer {
822
+ intent: PageIntent;
823
+ answer: string;
824
+ /** Elements the answer refers to, so the UI can highlight them. */
825
+ targets: string[];
826
+ suggestions: string[];
827
+ }
828
+ type PageIntent = "purpose" | "missing-labels" | "images" | "structure" | "forms" | "links" | "counts" | "unknown";
829
+ declare function analyzePage(root?: AuditRoot): PageOutline;
830
+ declare function detectPageIntent(question: string): PageIntent;
831
+ /**
832
+ * Answers a question about the current page.
833
+ * @param summarize Optional hook (e.g. Gemini Nano or your own model) used for "purpose" questions.
834
+ */
835
+ declare function askAboutPage(question: string, options?: {
836
+ root?: AuditRoot;
837
+ summarize?: (pageText: string) => Promise<string>;
838
+ }): Promise<PageAnswer>;
839
+
840
+ interface ParsedGridQuery {
841
+ filters: GridToolFilter[];
842
+ /** Free-text terms that didn't map to a column; matched across all columns. */
843
+ search: string[];
844
+ sort: GridToolSort | null;
845
+ limit: number | null;
846
+ /** Assumptions the parser made (shown to the user so they can correct it). */
847
+ notes: string[];
848
+ /** Plain-English reading of the query. */
849
+ explanation: string;
850
+ }
851
+ interface GridQueryResult<T> {
852
+ rows: T[];
853
+ ids: string[];
854
+ parsed: ParsedGridQuery;
855
+ message: string;
856
+ }
857
+ type Row = Record<string, unknown>;
858
+ /** "₹10,000" → 10000, "1.5 lakh" → 150000, "2cr" → 20000000, "10k" → 10000. */
859
+ declare function parseAmount(text: string): number | null;
860
+ /** The column mentioned in `text` (longest name wins), or undefined. */
861
+ declare function findMentionedColumn(text: string, columns: GridToolColumn[], kind?: GridToolColumn["type"]): GridToolColumn | undefined;
862
+ interface ParseOptions<T = Row> {
863
+ /** Rows let the parser recognise values like "overdue" in a Status column. */
864
+ data?: T[];
865
+ }
866
+ declare function parseGridQuery<T = Row>(query: string, columns: GridToolColumn[], options?: ParseOptions<T>): ParsedGridQuery;
867
+ /** Runs a parsed query over rows without touching any UI. */
868
+ declare function executeGridQuery<T>(data: T[], columns: GridToolColumn[], parsed: ParsedGridQuery): T[];
869
+ /**
870
+ * Parses and runs a natural-language query, then pushes the result into the
871
+ * grid through the context callbacks (filters, sort, highlight).
872
+ */
873
+ declare function runGridQuery<T>(query: string, context: GridToolContext<T>, options?: {
874
+ apply?: boolean;
875
+ }): GridQueryResult<T>;
876
+ interface GridAnomaly {
877
+ rowId: string;
878
+ column: string;
879
+ label: string;
880
+ value: unknown;
881
+ kind: "high" | "low" | "duplicate";
882
+ reason: string;
883
+ }
884
+ /**
885
+ * Finds unusual rows: numeric values far outside the typical range
886
+ * (interquartile-range rule) and rows that duplicate another row.
887
+ */
888
+ declare function detectAnomalies<T>(data: T[], columns: GridToolColumn[], options?: {
889
+ rowKey?: string;
890
+ factor?: number;
891
+ columns?: string[];
892
+ }): GridAnomaly[];
893
+ declare function summarizeRows<T>(rows: T[], columns: GridToolColumn[]): string;
894
+ interface GridAnswer<T> {
895
+ kind: "query" | "anomalies" | "summary";
896
+ message: string;
897
+ ids: string[];
898
+ rows: T[];
899
+ anomalies?: GridAnomaly[];
900
+ }
901
+ declare function answerGridQuestion<T>(question: string, context: GridToolContext<T>): GridAnswer<T>;
902
+
903
+ type GridNavAction = "next-row" | "previous-row" | "first-row" | "last-row" | "open-row";
904
+ type VoiceA11yCommand = {
905
+ type: "setting";
906
+ patch: Partial<A11yConfig>;
907
+ say: string;
908
+ } | {
909
+ type: "reset";
910
+ say: string;
911
+ } | {
912
+ type: "grid";
913
+ action: GridNavAction;
914
+ say: string;
915
+ };
916
+ declare const FONT_STEP = 0.1;
917
+ declare const FONT_MIN = 0.8;
918
+ declare const FONT_MAX = 1.3;
919
+ /**
920
+ * Parses a transcript into a command. `current` is needed for relative
921
+ * changes such as "bigger text". Returns null when nothing matched, so you
922
+ * can pass the transcript on to other handlers (e.g. core/ai/voice.ts).
923
+ */
924
+ declare function parseVoiceA11yCommand(transcript: string, current?: Partial<A11yConfig>): VoiceA11yCommand | null;
925
+ declare const DEFAULT_A11Y_SETTINGS: Partial<A11yConfig>;
926
+ declare function moveGridRowFocus(action: GridNavAction, options?: {
927
+ root?: ParentNode;
928
+ rowSelector?: string;
929
+ }): HTMLElement | null;
930
+ interface VoiceA11yControllerOptions {
931
+ /** Current settings; the controller keeps its own copy after each change. */
932
+ initial?: Partial<A11yConfig>;
933
+ /**
934
+ * Apply new settings. Default: yuktai's wcagPlugin.execute.
935
+ * Pass your own to sync with WidgetPanel state or a settings store.
936
+ */
937
+ apply?: (config: A11yConfig) => unknown;
938
+ /** Speech recognition language, e.g. "en-IN" or "te-IN" (default "en-IN"). */
939
+ lang?: string;
940
+ /** Speak a confirmation after each command (default true). */
941
+ speak?: boolean;
942
+ /** Called for every recognised transcript, matched or not. */
943
+ onTranscript?: (text: string, command: VoiceA11yCommand | null) => void;
944
+ gridRoot?: ParentNode;
945
+ }
946
+ declare function createVoiceA11yController(options?: VoiceA11yControllerOptions): {
947
+ start: () => boolean;
948
+ stop: () => void;
949
+ /** Run a command from text (also handy for typed commands and tests). */
950
+ handle: (transcript: string) => Promise<VoiceA11yCommand | null>;
951
+ isListening: () => boolean;
952
+ getConfig: () => {
953
+ enabled: boolean;
954
+ highContrast?: boolean;
955
+ darkMode?: boolean;
956
+ reduceMotion?: boolean;
957
+ autoFix?: boolean;
958
+ fontSizeMultiplier?: number;
959
+ colorBlindMode?: ColorBlindMode;
960
+ keyboardHints?: boolean;
961
+ speechEnabled?: boolean;
962
+ showPreferencePanel?: boolean;
963
+ showAuditBadge?: boolean;
964
+ showSkipLinks?: boolean;
965
+ largeTargets?: boolean;
966
+ timeoutWarning?: number;
967
+ dyslexiaFont?: boolean;
968
+ localFont?: string;
969
+ plainEnglish?: boolean;
970
+ summarisePage?: boolean;
971
+ translateLanguage?: string;
972
+ voiceControl?: boolean;
973
+ smartLabels?: boolean;
974
+ };
975
+ };
976
+
977
+ type FormFindingLevel = "problem" | "improvement";
978
+ interface FormField {
979
+ label: string;
980
+ type: string;
981
+ name: string;
982
+ required: boolean;
983
+ hasVisibleLabel: boolean;
984
+ selector: string;
985
+ element: Element;
986
+ }
987
+ interface FormFinding {
988
+ level: FormFindingLevel;
989
+ message: string;
990
+ suggestion: string;
991
+ field?: string;
992
+ selector?: string;
993
+ }
994
+ interface FormReview {
995
+ name: string;
996
+ selector: string;
997
+ fields: FormField[];
998
+ findings: FormFinding[];
999
+ /** 0–100, higher is easier to complete. */
1000
+ score: number;
1001
+ summary: string;
1002
+ }
1003
+ interface FormReviewOptions {
1004
+ root?: AuditRoot;
1005
+ /** Extra checks for older users: font size, field count, vague buttons (default true). */
1006
+ seniorFriendly?: boolean;
1007
+ /** Forms with more fields than this get a "split into steps" suggestion (default 8). */
1008
+ maxFieldsPerStep?: number;
1009
+ }
1010
+ declare function readFormFields(form: Element): FormField[];
1011
+ declare function reviewForm(form: Element, options?: FormReviewOptions): FormReview;
1012
+ /** Reviews every <form> (and every role="form") on the page. */
1013
+ declare function reviewForms(options?: FormReviewOptions): FormReview[];
1014
+
1015
+ interface ContextPassage {
1016
+ id: string;
1017
+ source: "page" | "grid" | "custom";
1018
+ text: string;
1019
+ /** Grid row id or page section heading. */
1020
+ ref?: string;
1021
+ }
1022
+ interface ContextHit extends ContextPassage {
1023
+ score: number;
1024
+ }
1025
+ interface ContextAnswer {
1026
+ answer: string;
1027
+ hits: ContextHit[];
1028
+ /** True when `generate` produced the answer; false for extractive answers. */
1029
+ generated: boolean;
1030
+ }
1031
+ /** Unicode-aware tokens: keeps Telugu/Devanagari combining marks together. */
1032
+ declare function tokenize(text: string): string[];
1033
+ declare function pagePassages(root?: AuditRoot, maxChars?: number): ContextPassage[];
1034
+ declare function gridPassages<T>(data: T[], columns: GridToolColumn[], rowKey?: string): ContextPassage[];
1035
+ interface ContextIndexOptions<T = Record<string, unknown>> {
1036
+ /** Index the visible page text (default true). */
1037
+ includePage?: boolean;
1038
+ root?: AuditRoot;
1039
+ rows?: T[];
1040
+ columns?: GridToolColumn[];
1041
+ rowKey?: string;
1042
+ /** Extra documents, e.g. FAQ text or help articles. */
1043
+ documents?: Array<{
1044
+ id: string;
1045
+ text: string;
1046
+ }>;
1047
+ }
1048
+ declare function createContextIndex<T>(options?: ContextIndexOptions<T>): {
1049
+ search: (question: string, k?: number) => ContextHit[];
1050
+ ask: (question: string, opts?: {
1051
+ k?: number;
1052
+ generate?: (question: string, context: string) => Promise<string>;
1053
+ }) => Promise<ContextAnswer>;
1054
+ /** Call after the page or data changes. */
1055
+ rebuild: () => void;
1056
+ update(next: Partial<ContextIndexOptions<T>>): void;
1057
+ size: () => number;
1058
+ };
1059
+
1060
+ type TaskAction = "filter" | "highlight" | "sort" | "clear" | "count" | "summarize" | "anomalies" | "open" | "select";
1061
+ interface PlannedStep {
1062
+ action: TaskAction;
1063
+ /** The part of the instruction this step came from. */
1064
+ text: string;
1065
+ }
1066
+ interface StepResult extends PlannedStep {
1067
+ success: boolean;
1068
+ message: string;
1069
+ ids?: string[];
1070
+ }
1071
+ interface TaskRunResult {
1072
+ steps: StepResult[];
1073
+ before: {
1074
+ rows: number;
1075
+ filters: GridToolFilter[];
1076
+ };
1077
+ after: {
1078
+ rows: number;
1079
+ filters: GridToolFilter[];
1080
+ sort: GridToolSort | null;
1081
+ highlighted: string[];
1082
+ };
1083
+ /** "What changed", in plain English. */
1084
+ summary: string;
1085
+ }
1086
+ /** Splits an instruction into ordered steps. No model needed. */
1087
+ declare function planTasks(instruction: string): PlannedStep[];
1088
+ interface RunTasksOptions {
1089
+ /** Called after each step, so the UI can show progress. */
1090
+ onStep?: (result: StepResult, index: number, total: number) => void;
1091
+ }
1092
+ declare function runTasks<T extends Record<string, unknown>>(instruction: string, context: GridToolContext<T>, options?: RunTasksOptions): Promise<TaskRunResult>;
1093
+
1094
+ type Aggregation = "sum" | "avg" | "count" | "min" | "max";
1095
+ type Period = "day" | "week" | "month" | "quarter" | "year";
1096
+ interface GroupResult {
1097
+ group: string;
1098
+ value: number;
1099
+ count: number;
1100
+ }
1101
+ interface PeriodChange {
1102
+ group: string;
1103
+ current: number;
1104
+ previous: number;
1105
+ change: number;
1106
+ /** null when the previous value was 0 */
1107
+ changePct: number | null;
1108
+ }
1109
+ interface PeriodComparison {
1110
+ period: Period;
1111
+ current: {
1112
+ from: Date;
1113
+ to: Date;
1114
+ };
1115
+ previous: {
1116
+ from: Date;
1117
+ to: Date;
1118
+ };
1119
+ rows: PeriodChange[];
1120
+ }
1121
+ declare function aggregate(values: number[], agg: Aggregation): number;
1122
+ /** Groups rows by a column and aggregates a metric (or counts rows). Sorted high → low. */
1123
+ declare function groupBy<T>(data: T[], groupKey: string, metricKey: string | null, agg?: Aggregation): GroupResult[];
1124
+ declare function startOfPeriod(date: Date, period: Period, weekStartsOn?: number): Date;
1125
+ declare function addPeriods(date: Date, period: Period, n: number): Date;
1126
+ interface ComparePeriodsOptions {
1127
+ dateKey: string;
1128
+ metricKey: string;
1129
+ groupKey?: string;
1130
+ agg?: Aggregation;
1131
+ period: Period;
1132
+ /** "Now" for the comparison (default: today). */
1133
+ referenceDate?: Date | string;
1134
+ /**
1135
+ * true (default): compare the same elapsed time — e.g. Mon–Wed this week
1136
+ * vs Mon–Wed last week — so a half-finished week doesn't look like a drop.
1137
+ */
1138
+ toDate?: boolean;
1139
+ weekStartsOn?: number;
1140
+ }
1141
+ declare function comparePeriods<T>(data: T[], o: ComparePeriodsOptions): PeriodComparison;
1142
+ /** Time series: one aggregated value per period, oldest first. */
1143
+ declare function trend<T>(data: T[], dateKey: string, metricKey: string, period: Period, agg?: Aggregation): Array<{
1144
+ start: Date;
1145
+ value: number;
1146
+ }>;
1147
+ interface InsightAnswer {
1148
+ kind: "period-change" | "group" | "trend" | "total" | "unknown";
1149
+ answer: string;
1150
+ table: Array<Record<string, string | number>>;
1151
+ }
1152
+ declare function askInsight<T>(question: string, data: T[], columns: GridToolColumn[], options?: {
1153
+ referenceDate?: Date | string;
1154
+ }): InsightAnswer;
1155
+
1156
+ type DesignCategory = "hierarchy" | "readability" | "interaction" | "clutter" | "consistency";
1157
+ interface DesignFinding {
1158
+ category: DesignCategory;
1159
+ severity: "high" | "medium" | "low";
1160
+ message: string;
1161
+ suggestion: string;
1162
+ selector?: string;
1163
+ }
1164
+ interface DesignReview {
1165
+ score: number;
1166
+ categories: Record<DesignCategory, {
1167
+ score: number;
1168
+ findings: number;
1169
+ }>;
1170
+ findings: DesignFinding[];
1171
+ summary: string;
1172
+ }
1173
+ interface DesignReviewOptions {
1174
+ root?: AuditRoot;
1175
+ /** Minimum body text size in px (default 14; 16 recommended for seniors). */
1176
+ minFontSize?: number;
1177
+ /** Maximum comfortable line length in characters (default 90). */
1178
+ maxLineLength?: number;
1179
+ }
1180
+ declare function reviewDesign(options?: DesignReviewOptions): DesignReview;
1181
+
1182
+ interface UseAgenticGridOptions<T> {
1183
+ data: T[];
1184
+ columns: Array<{
1185
+ key: string;
1186
+ label: string;
1187
+ type?: string;
1188
+ }>;
1189
+ rowKey?: string;
1190
+ /** "Now" for questions like "this week" (default: today). */
1191
+ referenceDate?: Date | string;
1192
+ onOpenRow?: (id: string) => void;
1193
+ }
1194
+ type AgenticAnswerKind = "query" | "anomalies" | "summary" | "insight" | "tasks";
1195
+ declare function useAgenticGrid<T extends Record<string, unknown>>(options: UseAgenticGridOptions<T>): {
1196
+ /** Pass to <YuktaiGrid data={…}> */
1197
+ gridData: T[];
1198
+ /** Pass to <YuktaiGrid highlightIds={…}> */
1199
+ highlightIds: string[];
1200
+ filters: GridToolFilter[];
1201
+ sort: GridToolSort | null;
1202
+ ask: (question: string) => Promise<void>;
1203
+ reset: () => void;
1204
+ answer: string;
1205
+ kind: AgenticAnswerKind | null;
1206
+ table: Record<string, string | number>[];
1207
+ steps: StepResult[];
1208
+ busy: boolean;
1209
+ visibleIds: string[];
1210
+ };
1211
+ declare function AgenticGridBar({ grid, placeholder, examples, style, }: {
1212
+ grid: ReturnType<typeof useAgenticGrid<any>>;
1213
+ placeholder?: string;
1214
+ examples?: string[];
1215
+ style?: CSSProperties;
1216
+ }): react_jsx_runtime.JSX.Element;
1217
+ type Tab = "copilot" | "qa" | "forms" | "design" | "ask" | "voice";
1218
+ interface AgenticPanelProps {
1219
+ defaultTab?: Tab;
1220
+ /** Speech recognition language for the Voice tab (default "en-IN"). */
1221
+ voiceLang?: string;
1222
+ /** Optional model hook for Ask page, e.g. Gemini Nano or your own API. */
1223
+ generate?: (question: string, context: string) => Promise<string>;
1224
+ style?: CSSProperties;
1225
+ }
1226
+ declare function AgenticPanel({ defaultTab, voiceLang, generate, style }: AgenticPanelProps): react_jsx_runtime.JSX.Element;
1227
+
608
1228
  declare global {
609
1229
  var __yuktai_runtime__: Runtime | undefined;
610
1230
  }
@@ -638,4 +1258,4 @@ declare const YuktAI: {
638
1258
  scan(): A11yReport;
639
1259
  };
640
1260
 
641
- export { type A11yConfig, type A11yFix, type A11yReport, type AIFeatures, CheckIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, type ColorBlindMode, type CreateGridToolsOptions, type FilterConfig, type FilterOperator, type GridAgentErrorCode, type GridAgentResult, type GridAgentStep, type GridAgentTool, type GridColumn, type GridIntent, type GridIntentContext, type GridLocale, type GridTheme, type GridTool, type GridToolColumn, type GridToolContext, type GridToolErrorCode, type GridToolFilter, type GridToolFilterOperator, type GridToolId, type GridToolLocale, type GridToolResult, type GridToolSort, type GridTranslations, IconBase, type IconProps, type PaginationConfig, Runtime, SearchIcon, type Severity, type SortConfig, type SortDirection, SortDownIcon, SortUpIcon, type UseGridOptions, type UseGridReturn, type ViewMode, type VoiceFeatures, type WebMCPState, type WebMCPStatus, YuktAI, YuktAIWrapper, type YuktAIWrapperProps, YuktaiGrid, YuktaiGridAI, type YuktaiGridAIProps, useYuktaiGridAgent as YuktaiGridAgent, type YuktaiGridAgentProps, type YuktaiGridProps, YuktaiGridWebMCP, type YuktaiGridWebMCPProps, aiPlugin, applyGridFilters, clearFilters, clearSort, countGrid, createGridTools, YuktAIWrapper as default, filterGrid, getColumns, getRow, getRowId, highlightRows, openRow, parseGridIntent, searchGrid, selectRow, sortGrid, toGridToolColumns, useGrid, useYuktaiGridAgent, voicePlugin, wcagPlugin as wcag, wcagPlugin };
1261
+ export { type A11yConfig, type A11yCopilot, type A11yCopilotOptions, type A11yFix, type A11yReport, type AIFeatures, AUDIT_RULES, type AgenticAnswerKind, AgenticGridBar, AgenticPanel, type AgenticPanelProps, type Aggregation, type AuditCheck, type AuditIssue, type AuditOptions, type AuditReport, type AuditRoot, type AuditRuleId, type AuditSeverity, CheckIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, type ColorBlindMode, type ComparePeriodsOptions, type ContextAnswer, type ContextHit, type ContextIndexOptions, type ContextPassage, type CopilotFixResult, type CopilotState, type CreateGridToolsOptions, DEFAULT_A11Y_SETTINGS, type DesignCategory, type DesignFinding, type DesignReview, type DesignReviewOptions, FONT_MAX, FONT_MIN, FONT_STEP, type FilterConfig, type FilterOperator, type FormField, type FormFinding, type FormFindingLevel, type FormReview, type FormReviewOptions, type GridAgentErrorCode, type GridAgentResult, type GridAgentStep, type GridAgentTool, type GridAnomaly, type GridAnswer, type GridColumn, type GridInputLanguage, type GridIntent, type GridIntentContext, type GridLocale, type GridNavAction, type GridQueryResult, type GridTheme, type GridTool, type GridToolColumn, type GridToolContext, type GridToolErrorCode, type GridToolFilter, type GridToolFilterOperator, type GridToolId, type GridToolLocale, type GridToolResult, type GridToolSort, type GridTranslations, type GroupResult, IconBase, type IconProps, type IndicLanguageLocale, type InsightAnswer, type PageAnswer, type PageIntent, type PageOutline, type PaginationConfig, type ParseOptions, type ParsedGridQuery, type Period, type PeriodChange, type PeriodComparison, type PlannedStep, type RGBA, type RunTasksOptions, Runtime, SearchIcon, type Severity, type SortConfig, type SortDirection, SortDownIcon, SortUpIcon, type StepResult, type TaskAction, type TaskRunResult, type UseAgenticGridOptions, type UseGridOptions, type UseGridReturn, type ViewMode, type VoiceA11yCommand, type VoiceA11yControllerOptions, type VoiceFeatures, type WebMCPState, type WebMCPStatus, YuktAI, YuktAIWrapper, type YuktAIWrapperProps, YuktaiGrid, YuktaiGridAI, type YuktaiGridAIProps, useYuktaiGridAgent as YuktaiGridAgent, type YuktaiGridAgentProps, type YuktaiGridProps, type YuktaiGridRule, type YuktaiGridRuleContext, YuktaiGridWebMCP, type YuktaiGridWebMCPProps, accessibleName, addPeriods, aggregate, aiPlugin, analyzePage, answerGridQuestion, applyGridFilters, askAboutPage, askInsight, auditToJSON, auditToMarkdown, clearFilters, clearSort, comparePeriods, contrastRatio, countGrid, createA11yCopilot, createContextIndex, createGridTools, createVoiceA11yController, YuktAIWrapper as default, detectAnomalies, detectPageIntent, executeGridQuery, filterGrid, findMentionedColumn, getColumns, getRow, getRowId, gridPassages, groupBy, highlightRows, moveGridRowFocus, openRow, pagePassages, parseAmount, parseColor, parseGridIntent, parseGridQuery, parseVoiceA11yCommand, planTasks, readFormFields, relativeLuminance, reviewDesign, reviewForm, reviewForms, runGridQuery, runQaAudit, runTasks, searchGrid, selectRow, sortGrid, startOfPeriod, summarizeRows, toGridToolColumns, tokenize, trend, useAgenticGrid, useGrid, useYuktaiGridAgent, voicePlugin, wcagPlugin as wcag, wcagPlugin };