@mathscan/math-exercise-engine 1.0.1 → 1.0.3

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
@@ -7,6 +7,41 @@ import { IToken } from 'chevrotain';
7
7
  import { RefAttributes } from 'react';
8
8
  import { z } from 'zod';
9
9
 
10
+ /**
11
+ * AST Node Types
12
+ *
13
+ * These are the internal AST representation types used during parsing.
14
+ */
15
+ export declare const AST_TYPES: {
16
+ /** Regular text without special formatting */
17
+ readonly FREE_TEXT: "FreeText";
18
+ /** Explicit spacing element */
19
+ readonly SPACE: "Space";
20
+ /** Text with optional character-range highlighting */
21
+ readonly HIGHLIGHTED_TEXT: "HighlightedText";
22
+ /** Inline input widget (string or numeric) */
23
+ readonly INLINE_INPUT: "InlineInput";
24
+ /** Question/instruction text block */
25
+ readonly TEXT_BLOCK: "TextBlock";
26
+ /** Line containing inline elements */
27
+ readonly LINE_BLOCK: "LineBlock";
28
+ /** Drag-and-drop options tool */
29
+ readonly DRAG_OPTIONS: "DragOptions";
30
+ /** Numeric keypad input tool */
31
+ readonly NUMERIC_KEYPAD: "NumericKeypad";
32
+ /** Simple answer matching validation */
33
+ readonly SIMPLE_VALIDATION: "SimpleValidation";
34
+ /** Expression-based validation */
35
+ readonly EXPRESSION_VALIDATION: "ExpressionValidation";
36
+ /** Root exercise document */
37
+ readonly EXERCISE_DOCUMENT: "ExerciseDocument";
38
+ };
39
+
40
+ /**
41
+ * Type helper to get all AST type values as a union type
42
+ */
43
+ export declare type ASTType = typeof AST_TYPES[keyof typeof AST_TYPES];
44
+
10
45
  /**
11
46
  * Compile DSL text directly to JSON (convenience function)
12
47
  *
@@ -41,8 +76,8 @@ export declare function compileWithAST(dsl: string): {
41
76
  validation: {
42
77
  type: "SimpleValidation";
43
78
  } | {
44
- type: "ExpressionValidation";
45
79
  expression: string;
80
+ type: "ExpressionValidation";
46
81
  };
47
82
  type: "ExerciseDocument";
48
83
  lines: {
@@ -54,7 +89,7 @@ export declare function compileWithAST(dsl: string): {
54
89
  type: "Space";
55
90
  } | {
56
91
  value: string;
57
- type: "NumberText";
92
+ type: "HighlightedText";
58
93
  highlight?: [number, number] | undefined;
59
94
  } | {
60
95
  length: number;
@@ -79,13 +114,13 @@ export declare function compileWithAST(dsl: string): {
79
114
  options: string[];
80
115
  } | {
81
116
  type: "NumericKeypad";
82
- includeDecimal: boolean;
83
- includeNegative: boolean;
117
+ includeOperators?: boolean | undefined;
118
+ includeDecimal?: boolean | undefined;
84
119
  })[] | undefined;
85
120
  };
86
121
  json: {
87
122
  validation: {
88
- mode: "expression" | "simple";
123
+ mode: "simple" | "expression";
89
124
  expression?: string | undefined;
90
125
  answers?: Record<string, string | number> | undefined;
91
126
  variables?: string[] | undefined;
@@ -105,7 +140,8 @@ export declare function compileWithAST(dsl: string): {
105
140
  options: string[];
106
141
  } | {
107
142
  type: "numeric-keypad";
108
- includeDecimal: boolean;
143
+ includeOperators?: boolean | undefined;
144
+ includeDecimal?: boolean | undefined;
109
145
  }>;
110
146
  id?: string | undefined;
111
147
  meta?: {
@@ -138,20 +174,15 @@ export declare function createExpressionValidation(expression: string): Expressi
138
174
  export declare function createFreeText(value: string): FreeTextInline;
139
175
 
140
176
  /**
141
- * @deprecated Use createStringInput or createNumericInput instead
177
+ * Create a highlighted text inline element
142
178
  */
143
- export declare function createInlineInput(name: string, inputType: "string" | "numeric", lengthOrDigits: number, answer?: string | number): InlineInputWidget;
179
+ export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
144
180
 
145
181
  /**
146
182
  * Create a line block
147
183
  */
148
184
  export declare function createLineBlock(inlines: any[]): LineBlock;
149
185
 
150
- /**
151
- * Create a number text inline element
152
- */
153
- export declare function createNumberText(value: string, highlight?: [number, number]): NumberTextInline;
154
-
155
186
  /**
156
187
  * Create a numeric inline input widget (W_N_I)
157
188
  */
@@ -160,7 +191,7 @@ export declare function createNumericInput(name: string, digits: number, answer?
160
191
  /**
161
192
  * Create a numeric keypad tool
162
193
  */
163
- export declare function createNumericKeypad(includeDecimal?: boolean, includeNegative?: boolean): NumericKeypadTool;
194
+ export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
164
195
 
165
196
  /**
166
197
  * Create a simple validation node
@@ -261,9 +292,9 @@ export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
261
292
  * {
262
293
  * type: "LineBlock",
263
294
  * inlines: [
264
- * { type: "NumberText", value: "151 000", highlight: [0, 3] },
295
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
265
296
  * { type: "InlineInput", name: "x", length: 1 },
266
- * { type: "NumberText", value: "54 000", highlight: [0, 3] }
297
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
267
298
  * ]
268
299
  * }
269
300
  * ],
@@ -305,16 +336,16 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
305
336
  }, {
306
337
  type: "Space";
307
338
  }>, z.ZodObject<{
308
- type: z.ZodLiteral<"NumberText">;
339
+ type: z.ZodLiteral<"HighlightedText">;
309
340
  value: z.ZodString;
310
341
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
311
342
  }, "strip", z.ZodTypeAny, {
312
343
  value: string;
313
- type: "NumberText";
344
+ type: "HighlightedText";
314
345
  highlight?: [number, number] | undefined;
315
346
  }, {
316
347
  value: string;
317
- type: "NumberText";
348
+ type: "HighlightedText";
318
349
  highlight?: [number, number] | undefined;
319
350
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
320
351
  type: z.ZodLiteral<"InlineInput">;
@@ -362,7 +393,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
362
393
  type: "Space";
363
394
  } | {
364
395
  value: string;
365
- type: "NumberText";
396
+ type: "HighlightedText";
366
397
  highlight?: [number, number] | undefined;
367
398
  } | {
368
399
  length: number;
@@ -386,7 +417,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
386
417
  type: "Space";
387
418
  } | {
388
419
  value: string;
389
- type: "NumberText";
420
+ type: "HighlightedText";
390
421
  highlight?: [number, number] | undefined;
391
422
  } | {
392
423
  length: number;
@@ -413,16 +444,16 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
413
444
  options: string[];
414
445
  }>, z.ZodObject<{
415
446
  type: z.ZodLiteral<"NumericKeypad">;
416
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
417
- includeNegative: z.ZodDefault<z.ZodBoolean>;
447
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
448
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
418
449
  }, "strip", z.ZodTypeAny, {
419
450
  type: "NumericKeypad";
420
- includeDecimal: boolean;
421
- includeNegative: boolean;
451
+ includeOperators?: boolean | undefined;
452
+ includeDecimal?: boolean | undefined;
422
453
  }, {
423
454
  type: "NumericKeypad";
455
+ includeOperators?: boolean | undefined;
424
456
  includeDecimal?: boolean | undefined;
425
- includeNegative?: boolean | undefined;
426
457
  }>]>, "many">>;
427
458
  validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
428
459
  type: z.ZodLiteral<"SimpleValidation">;
@@ -434,18 +465,18 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
434
465
  type: z.ZodLiteral<"ExpressionValidation">;
435
466
  expression: z.ZodString;
436
467
  }, "strip", z.ZodTypeAny, {
437
- type: "ExpressionValidation";
438
468
  expression: string;
439
- }, {
440
469
  type: "ExpressionValidation";
470
+ }, {
441
471
  expression: string;
472
+ type: "ExpressionValidation";
442
473
  }>]>;
443
474
  }, "strip", z.ZodTypeAny, {
444
475
  validation: {
445
476
  type: "SimpleValidation";
446
477
  } | {
447
- type: "ExpressionValidation";
448
478
  expression: string;
479
+ type: "ExpressionValidation";
449
480
  };
450
481
  type: "ExerciseDocument";
451
482
  lines: {
@@ -457,7 +488,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
457
488
  type: "Space";
458
489
  } | {
459
490
  value: string;
460
- type: "NumberText";
491
+ type: "HighlightedText";
461
492
  highlight?: [number, number] | undefined;
462
493
  } | {
463
494
  length: number;
@@ -482,15 +513,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
482
513
  options: string[];
483
514
  } | {
484
515
  type: "NumericKeypad";
485
- includeDecimal: boolean;
486
- includeNegative: boolean;
516
+ includeOperators?: boolean | undefined;
517
+ includeDecimal?: boolean | undefined;
487
518
  })[] | undefined;
488
519
  }, {
489
520
  validation: {
490
521
  type: "SimpleValidation";
491
522
  } | {
492
- type: "ExpressionValidation";
493
523
  expression: string;
524
+ type: "ExpressionValidation";
494
525
  };
495
526
  type: "ExerciseDocument";
496
527
  lines: {
@@ -502,7 +533,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
502
533
  type: "Space";
503
534
  } | {
504
535
  value: string;
505
- type: "NumberText";
536
+ type: "HighlightedText";
506
537
  highlight?: [number, number] | undefined;
507
538
  } | {
508
539
  length: number;
@@ -527,8 +558,8 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
527
558
  options: string[];
528
559
  } | {
529
560
  type: "NumericKeypad";
561
+ includeOperators?: boolean | undefined;
530
562
  includeDecimal?: boolean | undefined;
531
- includeNegative?: boolean | undefined;
532
563
  })[] | undefined;
533
564
  }>;
534
565
 
@@ -573,13 +604,16 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
573
604
  options: string[];
574
605
  }>, z.ZodObject<{
575
606
  type: z.ZodLiteral<"numeric-keypad">;
576
- includeDecimal: z.ZodBoolean;
607
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
608
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
577
609
  }, "strip", z.ZodTypeAny, {
578
610
  type: "numeric-keypad";
579
- includeDecimal: boolean;
611
+ includeOperators?: boolean | undefined;
612
+ includeDecimal?: boolean | undefined;
580
613
  }, {
581
614
  type: "numeric-keypad";
582
- includeDecimal: boolean;
615
+ includeOperators?: boolean | undefined;
616
+ includeDecimal?: boolean | undefined;
583
617
  }>]>>;
584
618
  validation: z.ZodObject<{
585
619
  mode: z.ZodEnum<["simple", "expression"]>;
@@ -587,12 +621,12 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
587
621
  expression: z.ZodOptional<z.ZodString>;
588
622
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
589
623
  }, "strip", z.ZodTypeAny, {
590
- mode: "expression" | "simple";
624
+ mode: "simple" | "expression";
591
625
  expression?: string | undefined;
592
626
  answers?: Record<string, string | number> | undefined;
593
627
  variables?: string[] | undefined;
594
628
  }, {
595
- mode: "expression" | "simple";
629
+ mode: "simple" | "expression";
596
630
  expression?: string | undefined;
597
631
  answers?: Record<string, string | number> | undefined;
598
632
  variables?: string[] | undefined;
@@ -615,7 +649,7 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
615
649
  }>>;
616
650
  }, "strip", z.ZodTypeAny, {
617
651
  validation: {
618
- mode: "expression" | "simple";
652
+ mode: "simple" | "expression";
619
653
  expression?: string | undefined;
620
654
  answers?: Record<string, string | number> | undefined;
621
655
  variables?: string[] | undefined;
@@ -635,7 +669,8 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
635
669
  options: string[];
636
670
  } | {
637
671
  type: "numeric-keypad";
638
- includeDecimal: boolean;
672
+ includeOperators?: boolean | undefined;
673
+ includeDecimal?: boolean | undefined;
639
674
  }>;
640
675
  id?: string | undefined;
641
676
  meta?: {
@@ -646,7 +681,7 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
646
681
  } | undefined;
647
682
  }, {
648
683
  validation: {
649
- mode: "expression" | "simple";
684
+ mode: "simple" | "expression";
650
685
  expression?: string | undefined;
651
686
  answers?: Record<string, string | number> | undefined;
652
687
  variables?: string[] | undefined;
@@ -666,7 +701,8 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
666
701
  options: string[];
667
702
  } | {
668
703
  type: "numeric-keypad";
669
- includeDecimal: boolean;
704
+ includeOperators?: boolean | undefined;
705
+ includeDecimal?: boolean | undefined;
670
706
  }>;
671
707
  id?: string | undefined;
672
708
  meta?: {
@@ -737,11 +773,11 @@ export declare const ExpressionValidationSchema: z.ZodObject<{
737
773
  type: z.ZodLiteral<"ExpressionValidation">;
738
774
  expression: z.ZodString;
739
775
  }, "strip", z.ZodTypeAny, {
740
- type: "ExpressionValidation";
741
776
  expression: string;
742
- }, {
743
777
  type: "ExpressionValidation";
778
+ }, {
744
779
  expression: string;
780
+ type: "ExpressionValidation";
745
781
  }>;
746
782
 
747
783
  /**
@@ -814,6 +850,53 @@ export declare const GroupItemSchema: z.ZodObject<{
814
850
  items: any[];
815
851
  }>;
816
852
 
853
+ export declare type HighlightedText = z.infer<typeof HighlightedTextSchema>;
854
+
855
+ export declare type HighlightedTextInline = z.infer<typeof HighlightedTextInlineSchema>;
856
+
857
+ /**
858
+ * Highlighted text inline schema - text with optional highlighting
859
+ *
860
+ * highlight: [start, end] character positions for visual emphasis
861
+ *
862
+ * @example
863
+ * {
864
+ * type: "HighlightedText",
865
+ * value: "151 000",
866
+ * highlight: [0, 3] // Highlights "151"
867
+ * }
868
+ */
869
+ export declare const HighlightedTextInlineSchema: z.ZodObject<{
870
+ type: z.ZodLiteral<"HighlightedText">;
871
+ value: z.ZodString;
872
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
873
+ }, "strip", z.ZodTypeAny, {
874
+ value: string;
875
+ type: "HighlightedText";
876
+ highlight?: [number, number] | undefined;
877
+ }, {
878
+ value: string;
879
+ type: "HighlightedText";
880
+ highlight?: [number, number] | undefined;
881
+ }>;
882
+
883
+ export declare const HighlightedTextSchema: z.ZodObject<{
884
+ id: z.ZodString;
885
+ type: z.ZodLiteral<"highlighted-text">;
886
+ value: z.ZodString;
887
+ highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
888
+ }, "strip", z.ZodTypeAny, {
889
+ value: string;
890
+ type: "highlighted-text";
891
+ id: string;
892
+ highlight?: [number, number] | undefined;
893
+ }, {
894
+ value: string;
895
+ type: "highlighted-text";
896
+ id: string;
897
+ highlight?: [number, number] | undefined;
898
+ }>;
899
+
817
900
  export declare type InlineInputJSON = z.infer<typeof InlineInputJSONSchema>;
818
901
 
819
902
  export declare const InlineInputJSONSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
@@ -927,16 +1010,16 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
927
1010
  }, {
928
1011
  type: "Space";
929
1012
  }>, z.ZodObject<{
930
- type: z.ZodLiteral<"NumberText">;
1013
+ type: z.ZodLiteral<"HighlightedText">;
931
1014
  value: z.ZodString;
932
1015
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
933
1016
  }, "strip", z.ZodTypeAny, {
934
1017
  value: string;
935
- type: "NumberText";
1018
+ type: "HighlightedText";
936
1019
  highlight?: [number, number] | undefined;
937
1020
  }, {
938
1021
  value: string;
939
- type: "NumberText";
1022
+ type: "HighlightedText";
940
1023
  highlight?: [number, number] | undefined;
941
1024
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
942
1025
  type: z.ZodLiteral<"InlineInput">;
@@ -998,6 +1081,13 @@ export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutIte
998
1081
  type: 'group';
999
1082
  }>;
1000
1083
 
1084
+ /**
1085
+ * Type guard for HighlightedText
1086
+ */
1087
+ export declare function isHighlightedText(item: LayoutItem): item is Extract<LayoutItem, {
1088
+ type: 'highlighted-text';
1089
+ }>;
1090
+
1001
1091
  export declare function isInlineInput(value: unknown): value is InlineInputWidget;
1002
1092
 
1003
1093
  /**
@@ -1018,20 +1108,6 @@ export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutIte
1018
1108
  type: 'linebreak';
1019
1109
  }>;
1020
1110
 
1021
- /**
1022
- * Type guard for NumberText
1023
- */
1024
- export declare function isNumberText(item: LayoutItem): item is Extract<LayoutItem, {
1025
- type: 'number-text';
1026
- }>;
1027
-
1028
- /**
1029
- * @deprecated Use isInlineInputJSON instead
1030
- */
1031
- export declare function isNumericInputJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
1032
- type: 'inline-input';
1033
- }>;
1034
-
1035
1111
  export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
1036
1112
 
1037
1113
  /**
@@ -1081,18 +1157,46 @@ export declare function isValidationNode(value: unknown): value is ValidationNod
1081
1157
  export declare function isValidExpression(expression: string): boolean;
1082
1158
 
1083
1159
  /**
1084
- * @deprecated Use isWidgetRef instead
1160
+ * Type guard for WidgetRef
1085
1161
  */
1086
- export declare function isWidgetPlaceholder(item: LayoutItem): item is Extract<LayoutItem, {
1162
+ export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
1087
1163
  type: 'widget-ref';
1088
1164
  }>;
1089
1165
 
1090
1166
  /**
1091
- * Type guard for WidgetRef
1167
+ * JSON Layout Item Types
1168
+ *
1169
+ * These are the types used in the JSON output format.
1170
+ */
1171
+ export declare const JSON_TYPES: {
1172
+ /** Question/instruction text */
1173
+ readonly QUESTION_TEXT: "question-text";
1174
+ /** Regular text element */
1175
+ readonly TEXT: "text";
1176
+ /** Spacing element */
1177
+ readonly SPACE: "space";
1178
+ /** Text with optional highlighting */
1179
+ readonly HIGHLIGHTED_TEXT: "highlighted-text";
1180
+ /** Reference to a widget */
1181
+ readonly WIDGET_REF: "widget-ref";
1182
+ /** Line break element */
1183
+ readonly LINEBREAK: "linebreak";
1184
+ /** Grouped layout items */
1185
+ readonly GROUP: "group";
1186
+ /** Operator symbol */
1187
+ readonly OPERATOR: "operator";
1188
+ /** Inline input widget (string or numeric) */
1189
+ readonly INLINE_INPUT: "inline-input";
1190
+ /** Drag-and-drop options widget */
1191
+ readonly DRAG_OPTIONS: "drag-options";
1192
+ /** Numeric keypad widget */
1193
+ readonly NUMERIC_KEYPAD: "numeric-keypad";
1194
+ };
1195
+
1196
+ /**
1197
+ * Type helper to get all JSON type values as a union type
1092
1198
  */
1093
- export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutItem, {
1094
- type: 'widget-ref';
1095
- }>;
1199
+ export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
1096
1200
 
1097
1201
  export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
1098
1202
 
@@ -1109,6 +1213,7 @@ export declare interface LayoutRendererProps {
1109
1213
  values: Record<string, string>;
1110
1214
  droppedInputs: Set<string>;
1111
1215
  onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
1216
+ onInputFocus?: (widgetId: string) => void;
1112
1217
  }
1113
1218
 
1114
1219
  /**
@@ -1132,9 +1237,9 @@ export declare type LineBlock = z.infer<typeof LineBlockSchema>;
1132
1237
  * {
1133
1238
  * type: "LineBlock",
1134
1239
  * inlines: [
1135
- * { type: "NumberText", value: "151 000", highlight: [0, 3] },
1240
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
1136
1241
  * { type: "InlineInput", name: "x", length: 1 },
1137
- * { type: "NumberText", value: "54 000", highlight: [0, 3] }
1242
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
1138
1243
  * ]
1139
1244
  * }
1140
1245
  */
@@ -1156,16 +1261,16 @@ export declare const LineBlockSchema: z.ZodObject<{
1156
1261
  }, {
1157
1262
  type: "Space";
1158
1263
  }>, z.ZodObject<{
1159
- type: z.ZodLiteral<"NumberText">;
1264
+ type: z.ZodLiteral<"HighlightedText">;
1160
1265
  value: z.ZodString;
1161
1266
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1162
1267
  }, "strip", z.ZodTypeAny, {
1163
1268
  value: string;
1164
- type: "NumberText";
1269
+ type: "HighlightedText";
1165
1270
  highlight?: [number, number] | undefined;
1166
1271
  }, {
1167
1272
  value: string;
1168
- type: "NumberText";
1273
+ type: "HighlightedText";
1169
1274
  highlight?: [number, number] | undefined;
1170
1275
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1171
1276
  type: z.ZodLiteral<"InlineInput">;
@@ -1213,7 +1318,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1213
1318
  type: "Space";
1214
1319
  } | {
1215
1320
  value: string;
1216
- type: "NumberText";
1321
+ type: "HighlightedText";
1217
1322
  highlight?: [number, number] | undefined;
1218
1323
  } | {
1219
1324
  length: number;
@@ -1237,7 +1342,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1237
1342
  type: "Space";
1238
1343
  } | {
1239
1344
  value: string;
1240
- type: "NumberText";
1345
+ type: "HighlightedText";
1241
1346
  highlight?: [number, number] | undefined;
1242
1347
  } | {
1243
1348
  length: number;
@@ -1267,64 +1372,20 @@ export declare const LinebreakSchema: z.ZodObject<{
1267
1372
  id: string;
1268
1373
  }>;
1269
1374
 
1270
- export declare type NumberText = z.infer<typeof NumberTextSchema>;
1271
-
1272
- export declare type NumberTextInline = z.infer<typeof NumberTextInlineSchema>;
1273
-
1274
- /**
1275
- * Number text inline schema - styled numbers with optional highlighting
1276
- *
1277
- * highlight: [start, end] character positions for visual emphasis
1278
- *
1279
- * @example
1280
- * {
1281
- * type: "NumberText",
1282
- * value: "151 000",
1283
- * highlight: [0, 3] // Highlights "151"
1284
- * }
1285
- */
1286
- export declare const NumberTextInlineSchema: z.ZodObject<{
1287
- type: z.ZodLiteral<"NumberText">;
1288
- value: z.ZodString;
1289
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1290
- }, "strip", z.ZodTypeAny, {
1291
- value: string;
1292
- type: "NumberText";
1293
- highlight?: [number, number] | undefined;
1294
- }, {
1295
- value: string;
1296
- type: "NumberText";
1297
- highlight?: [number, number] | undefined;
1298
- }>;
1299
-
1300
- export declare const NumberTextSchema: z.ZodObject<{
1301
- id: z.ZodString;
1302
- type: z.ZodLiteral<"number-text">;
1303
- value: z.ZodString;
1304
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1305
- }, "strip", z.ZodTypeAny, {
1306
- value: string;
1307
- type: "number-text";
1308
- id: string;
1309
- highlight?: [number, number] | undefined;
1310
- }, {
1311
- value: string;
1312
- type: "number-text";
1313
- id: string;
1314
- highlight?: [number, number] | undefined;
1315
- }>;
1316
-
1317
1375
  export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
1318
1376
 
1319
1377
  export declare const NumericKeypadJSONSchema: z.ZodObject<{
1320
1378
  type: z.ZodLiteral<"numeric-keypad">;
1321
- includeDecimal: z.ZodBoolean;
1379
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1380
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1322
1381
  }, "strip", z.ZodTypeAny, {
1323
1382
  type: "numeric-keypad";
1324
- includeDecimal: boolean;
1383
+ includeOperators?: boolean | undefined;
1384
+ includeDecimal?: boolean | undefined;
1325
1385
  }, {
1326
1386
  type: "numeric-keypad";
1327
- includeDecimal: boolean;
1387
+ includeOperators?: boolean | undefined;
1388
+ includeDecimal?: boolean | undefined;
1328
1389
  }>;
1329
1390
 
1330
1391
  export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
@@ -1340,22 +1401,21 @@ export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1340
1401
  * @example
1341
1402
  * {
1342
1403
  * type: "NumericKeypad",
1343
- * includeDecimal: false,
1344
- * includeNegative: true
1404
+ * includeOperators: true
1345
1405
  * }
1346
1406
  */
1347
1407
  export declare const NumericKeypadToolSchema: z.ZodObject<{
1348
1408
  type: z.ZodLiteral<"NumericKeypad">;
1349
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
1350
- includeNegative: z.ZodDefault<z.ZodBoolean>;
1409
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1410
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1351
1411
  }, "strip", z.ZodTypeAny, {
1352
1412
  type: "NumericKeypad";
1353
- includeDecimal: boolean;
1354
- includeNegative: boolean;
1413
+ includeOperators?: boolean | undefined;
1414
+ includeDecimal?: boolean | undefined;
1355
1415
  }, {
1356
1416
  type: "NumericKeypad";
1417
+ includeOperators?: boolean | undefined;
1357
1418
  includeDecimal?: boolean | undefined;
1358
- includeNegative?: boolean | undefined;
1359
1419
  }>;
1360
1420
 
1361
1421
  export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
@@ -1365,13 +1425,13 @@ export declare const OperatorItemSchema: z.ZodObject<{
1365
1425
  type: z.ZodLiteral<"operator">;
1366
1426
  operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1367
1427
  }, "strip", z.ZodTypeAny, {
1428
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1368
1429
  type: "operator";
1369
1430
  id: string;
1370
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1371
1431
  }, {
1432
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1372
1433
  type: "operator";
1373
1434
  id: string;
1374
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1375
1435
  }>;
1376
1436
 
1377
1437
  export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
@@ -1595,16 +1655,16 @@ export declare const ToolNodeSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
1595
1655
  options: string[];
1596
1656
  }>, z.ZodObject<{
1597
1657
  type: z.ZodLiteral<"NumericKeypad">;
1598
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
1599
- includeNegative: z.ZodDefault<z.ZodBoolean>;
1658
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1659
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1600
1660
  }, "strip", z.ZodTypeAny, {
1601
1661
  type: "NumericKeypad";
1602
- includeDecimal: boolean;
1603
- includeNegative: boolean;
1662
+ includeOperators?: boolean | undefined;
1663
+ includeDecimal?: boolean | undefined;
1604
1664
  }, {
1605
1665
  type: "NumericKeypad";
1666
+ includeOperators?: boolean | undefined;
1606
1667
  includeDecimal?: boolean | undefined;
1607
- includeNegative?: boolean | undefined;
1608
1668
  }>]>;
1609
1669
 
1610
1670
  /**
@@ -1664,7 +1724,7 @@ export declare function validateBooleanExpression(expression: string): string |
1664
1724
  */
1665
1725
  export declare function validateExerciseJSON(data: unknown): {
1666
1726
  validation: {
1667
- mode: "expression" | "simple";
1727
+ mode: "simple" | "expression";
1668
1728
  expression?: string | undefined;
1669
1729
  answers?: Record<string, string | number> | undefined;
1670
1730
  variables?: string[] | undefined;
@@ -1684,7 +1744,8 @@ export declare function validateExerciseJSON(data: unknown): {
1684
1744
  options: string[];
1685
1745
  } | {
1686
1746
  type: "numeric-keypad";
1687
- includeDecimal: boolean;
1747
+ includeOperators?: boolean | undefined;
1748
+ includeDecimal?: boolean | undefined;
1688
1749
  }>;
1689
1750
  id?: string | undefined;
1690
1751
  meta?: {
@@ -1713,7 +1774,7 @@ export declare function validateExerciseJSON(data: unknown): {
1713
1774
  */
1714
1775
  export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseReturnType<{
1715
1776
  validation: {
1716
- mode: "expression" | "simple";
1777
+ mode: "simple" | "expression";
1717
1778
  expression?: string | undefined;
1718
1779
  answers?: Record<string, string | number> | undefined;
1719
1780
  variables?: string[] | undefined;
@@ -1733,7 +1794,8 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1733
1794
  options: string[];
1734
1795
  } | {
1735
1796
  type: "numeric-keypad";
1736
- includeDecimal: boolean;
1797
+ includeOperators?: boolean | undefined;
1798
+ includeDecimal?: boolean | undefined;
1737
1799
  }>;
1738
1800
  id?: string | undefined;
1739
1801
  meta?: {
@@ -1744,7 +1806,7 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1744
1806
  } | undefined;
1745
1807
  }, {
1746
1808
  validation: {
1747
- mode: "expression" | "simple";
1809
+ mode: "simple" | "expression";
1748
1810
  expression?: string | undefined;
1749
1811
  answers?: Record<string, string | number> | undefined;
1750
1812
  variables?: string[] | undefined;
@@ -1764,7 +1826,8 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1764
1826
  options: string[];
1765
1827
  } | {
1766
1828
  type: "numeric-keypad";
1767
- includeDecimal: boolean;
1829
+ includeOperators?: boolean | undefined;
1830
+ includeDecimal?: boolean | undefined;
1768
1831
  }>;
1769
1832
  id?: string | undefined;
1770
1833
  meta?: {
@@ -1823,7 +1886,8 @@ export declare function validateWidgetJSON(data: unknown): {
1823
1886
  options: string[];
1824
1887
  } | {
1825
1888
  type: "numeric-keypad";
1826
- includeDecimal: boolean;
1889
+ includeOperators?: boolean | undefined;
1890
+ includeDecimal?: boolean | undefined;
1827
1891
  };
1828
1892
 
1829
1893
  /**
@@ -1845,7 +1909,8 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
1845
1909
  options: string[];
1846
1910
  } | {
1847
1911
  type: "numeric-keypad";
1848
- includeDecimal: boolean;
1912
+ includeOperators?: boolean | undefined;
1913
+ includeDecimal?: boolean | undefined;
1849
1914
  }, {
1850
1915
  length: number;
1851
1916
  type: "inline-input";
@@ -1859,7 +1924,8 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
1859
1924
  options: string[];
1860
1925
  } | {
1861
1926
  type: "numeric-keypad";
1862
- includeDecimal: boolean;
1927
+ includeOperators?: boolean | undefined;
1928
+ includeDecimal?: boolean | undefined;
1863
1929
  }>;
1864
1930
 
1865
1931
  /**
@@ -1878,12 +1944,12 @@ export declare const ValidationJSONSchema: z.ZodObject<{
1878
1944
  expression: z.ZodOptional<z.ZodString>;
1879
1945
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1880
1946
  }, "strip", z.ZodTypeAny, {
1881
- mode: "expression" | "simple";
1947
+ mode: "simple" | "expression";
1882
1948
  expression?: string | undefined;
1883
1949
  answers?: Record<string, string | number> | undefined;
1884
1950
  variables?: string[] | undefined;
1885
1951
  }, {
1886
- mode: "expression" | "simple";
1952
+ mode: "simple" | "expression";
1887
1953
  expression?: string | undefined;
1888
1954
  answers?: Record<string, string | number> | undefined;
1889
1955
  variables?: string[] | undefined;
@@ -1904,11 +1970,11 @@ export declare const ValidationNodeSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
1904
1970
  type: z.ZodLiteral<"ExpressionValidation">;
1905
1971
  expression: z.ZodString;
1906
1972
  }, "strip", z.ZodTypeAny, {
1907
- type: "ExpressionValidation";
1908
1973
  expression: string;
1909
- }, {
1910
1974
  type: "ExpressionValidation";
1975
+ }, {
1911
1976
  expression: string;
1977
+ type: "ExpressionValidation";
1912
1978
  }>]>;
1913
1979
 
1914
1980
  /**
@@ -1966,18 +2032,19 @@ export declare const WidgetJSONSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"inpu
1966
2032
  options: string[];
1967
2033
  }>, z.ZodObject<{
1968
2034
  type: z.ZodLiteral<"numeric-keypad">;
1969
- includeDecimal: z.ZodBoolean;
2035
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2036
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1970
2037
  }, "strip", z.ZodTypeAny, {
1971
2038
  type: "numeric-keypad";
1972
- includeDecimal: boolean;
2039
+ includeOperators?: boolean | undefined;
2040
+ includeDecimal?: boolean | undefined;
1973
2041
  }, {
1974
2042
  type: "numeric-keypad";
1975
- includeDecimal: boolean;
2043
+ includeOperators?: boolean | undefined;
2044
+ includeDecimal?: boolean | undefined;
1976
2045
  }>]>;
1977
2046
 
1978
- declare type WidgetRef = z.infer<typeof WidgetRefSchema>;
1979
- export { WidgetRef as WidgetPlaceholder }
1980
- export { WidgetRef }
2047
+ export declare type WidgetRef = z.infer<typeof WidgetRefSchema>;
1981
2048
 
1982
2049
  export declare const WidgetRefSchema: z.ZodObject<{
1983
2050
  id: z.ZodString;
@@ -2006,6 +2073,8 @@ export declare interface WidgetRendererProps {
2006
2073
  value: string;
2007
2074
  isDropped?: boolean;
2008
2075
  onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
2076
+ onInputFocus?: (widgetId: string) => void;
2077
+ onKeypadChange?: (value: string) => void;
2009
2078
  }
2010
2079
 
2011
2080
  /**