@mathscan/math-exercise-engine 1.0.2 → 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,14 +174,14 @@ export declare function createExpressionValidation(expression: string): Expressi
138
174
  export declare function createFreeText(value: string): FreeTextInline;
139
175
 
140
176
  /**
141
- * Create a line block
177
+ * Create a highlighted text inline element
142
178
  */
143
- export declare function createLineBlock(inlines: any[]): LineBlock;
179
+ export declare function createHighlightedText(value: string, highlight?: [number, number]): HighlightedTextInline;
144
180
 
145
181
  /**
146
- * Create a number text inline element
182
+ * Create a line block
147
183
  */
148
- export declare function createNumberText(value: string, highlight?: [number, number]): NumberTextInline;
184
+ export declare function createLineBlock(inlines: any[]): LineBlock;
149
185
 
150
186
  /**
151
187
  * Create a numeric inline input widget (W_N_I)
@@ -155,7 +191,7 @@ export declare function createNumericInput(name: string, digits: number, answer?
155
191
  /**
156
192
  * Create a numeric keypad tool
157
193
  */
158
- export declare function createNumericKeypad(includeDecimal?: boolean, includeNegative?: boolean): NumericKeypadTool;
194
+ export declare function createNumericKeypad(includeOperators?: boolean, includeDecimal?: boolean): NumericKeypadTool;
159
195
 
160
196
  /**
161
197
  * Create a simple validation node
@@ -256,9 +292,9 @@ export declare type ExerciseDocument = z.infer<typeof ExerciseDocumentSchema>;
256
292
  * {
257
293
  * type: "LineBlock",
258
294
  * inlines: [
259
- * { type: "NumberText", value: "151 000", highlight: [0, 3] },
295
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
260
296
  * { type: "InlineInput", name: "x", length: 1 },
261
- * { type: "NumberText", value: "54 000", highlight: [0, 3] }
297
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
262
298
  * ]
263
299
  * }
264
300
  * ],
@@ -300,16 +336,16 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
300
336
  }, {
301
337
  type: "Space";
302
338
  }>, z.ZodObject<{
303
- type: z.ZodLiteral<"NumberText">;
339
+ type: z.ZodLiteral<"HighlightedText">;
304
340
  value: z.ZodString;
305
341
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
306
342
  }, "strip", z.ZodTypeAny, {
307
343
  value: string;
308
- type: "NumberText";
344
+ type: "HighlightedText";
309
345
  highlight?: [number, number] | undefined;
310
346
  }, {
311
347
  value: string;
312
- type: "NumberText";
348
+ type: "HighlightedText";
313
349
  highlight?: [number, number] | undefined;
314
350
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
315
351
  type: z.ZodLiteral<"InlineInput">;
@@ -357,7 +393,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
357
393
  type: "Space";
358
394
  } | {
359
395
  value: string;
360
- type: "NumberText";
396
+ type: "HighlightedText";
361
397
  highlight?: [number, number] | undefined;
362
398
  } | {
363
399
  length: number;
@@ -381,7 +417,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
381
417
  type: "Space";
382
418
  } | {
383
419
  value: string;
384
- type: "NumberText";
420
+ type: "HighlightedText";
385
421
  highlight?: [number, number] | undefined;
386
422
  } | {
387
423
  length: number;
@@ -408,16 +444,16 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
408
444
  options: string[];
409
445
  }>, z.ZodObject<{
410
446
  type: z.ZodLiteral<"NumericKeypad">;
411
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
412
- includeNegative: z.ZodDefault<z.ZodBoolean>;
447
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
448
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
413
449
  }, "strip", z.ZodTypeAny, {
414
450
  type: "NumericKeypad";
415
- includeDecimal: boolean;
416
- includeNegative: boolean;
451
+ includeOperators?: boolean | undefined;
452
+ includeDecimal?: boolean | undefined;
417
453
  }, {
418
454
  type: "NumericKeypad";
455
+ includeOperators?: boolean | undefined;
419
456
  includeDecimal?: boolean | undefined;
420
- includeNegative?: boolean | undefined;
421
457
  }>]>, "many">>;
422
458
  validation: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
423
459
  type: z.ZodLiteral<"SimpleValidation">;
@@ -429,18 +465,18 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
429
465
  type: z.ZodLiteral<"ExpressionValidation">;
430
466
  expression: z.ZodString;
431
467
  }, "strip", z.ZodTypeAny, {
432
- type: "ExpressionValidation";
433
468
  expression: string;
434
- }, {
435
469
  type: "ExpressionValidation";
470
+ }, {
436
471
  expression: string;
472
+ type: "ExpressionValidation";
437
473
  }>]>;
438
474
  }, "strip", z.ZodTypeAny, {
439
475
  validation: {
440
476
  type: "SimpleValidation";
441
477
  } | {
442
- type: "ExpressionValidation";
443
478
  expression: string;
479
+ type: "ExpressionValidation";
444
480
  };
445
481
  type: "ExerciseDocument";
446
482
  lines: {
@@ -452,7 +488,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
452
488
  type: "Space";
453
489
  } | {
454
490
  value: string;
455
- type: "NumberText";
491
+ type: "HighlightedText";
456
492
  highlight?: [number, number] | undefined;
457
493
  } | {
458
494
  length: number;
@@ -477,15 +513,15 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
477
513
  options: string[];
478
514
  } | {
479
515
  type: "NumericKeypad";
480
- includeDecimal: boolean;
481
- includeNegative: boolean;
516
+ includeOperators?: boolean | undefined;
517
+ includeDecimal?: boolean | undefined;
482
518
  })[] | undefined;
483
519
  }, {
484
520
  validation: {
485
521
  type: "SimpleValidation";
486
522
  } | {
487
- type: "ExpressionValidation";
488
523
  expression: string;
524
+ type: "ExpressionValidation";
489
525
  };
490
526
  type: "ExerciseDocument";
491
527
  lines: {
@@ -497,7 +533,7 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
497
533
  type: "Space";
498
534
  } | {
499
535
  value: string;
500
- type: "NumberText";
536
+ type: "HighlightedText";
501
537
  highlight?: [number, number] | undefined;
502
538
  } | {
503
539
  length: number;
@@ -522,8 +558,8 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
522
558
  options: string[];
523
559
  } | {
524
560
  type: "NumericKeypad";
561
+ includeOperators?: boolean | undefined;
525
562
  includeDecimal?: boolean | undefined;
526
- includeNegative?: boolean | undefined;
527
563
  })[] | undefined;
528
564
  }>;
529
565
 
@@ -568,13 +604,16 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
568
604
  options: string[];
569
605
  }>, z.ZodObject<{
570
606
  type: z.ZodLiteral<"numeric-keypad">;
571
- includeDecimal: z.ZodBoolean;
607
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
608
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
572
609
  }, "strip", z.ZodTypeAny, {
573
610
  type: "numeric-keypad";
574
- includeDecimal: boolean;
611
+ includeOperators?: boolean | undefined;
612
+ includeDecimal?: boolean | undefined;
575
613
  }, {
576
614
  type: "numeric-keypad";
577
- includeDecimal: boolean;
615
+ includeOperators?: boolean | undefined;
616
+ includeDecimal?: boolean | undefined;
578
617
  }>]>>;
579
618
  validation: z.ZodObject<{
580
619
  mode: z.ZodEnum<["simple", "expression"]>;
@@ -582,12 +621,12 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
582
621
  expression: z.ZodOptional<z.ZodString>;
583
622
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
584
623
  }, "strip", z.ZodTypeAny, {
585
- mode: "expression" | "simple";
624
+ mode: "simple" | "expression";
586
625
  expression?: string | undefined;
587
626
  answers?: Record<string, string | number> | undefined;
588
627
  variables?: string[] | undefined;
589
628
  }, {
590
- mode: "expression" | "simple";
629
+ mode: "simple" | "expression";
591
630
  expression?: string | undefined;
592
631
  answers?: Record<string, string | number> | undefined;
593
632
  variables?: string[] | undefined;
@@ -610,7 +649,7 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
610
649
  }>>;
611
650
  }, "strip", z.ZodTypeAny, {
612
651
  validation: {
613
- mode: "expression" | "simple";
652
+ mode: "simple" | "expression";
614
653
  expression?: string | undefined;
615
654
  answers?: Record<string, string | number> | undefined;
616
655
  variables?: string[] | undefined;
@@ -630,7 +669,8 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
630
669
  options: string[];
631
670
  } | {
632
671
  type: "numeric-keypad";
633
- includeDecimal: boolean;
672
+ includeOperators?: boolean | undefined;
673
+ includeDecimal?: boolean | undefined;
634
674
  }>;
635
675
  id?: string | undefined;
636
676
  meta?: {
@@ -641,7 +681,7 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
641
681
  } | undefined;
642
682
  }, {
643
683
  validation: {
644
- mode: "expression" | "simple";
684
+ mode: "simple" | "expression";
645
685
  expression?: string | undefined;
646
686
  answers?: Record<string, string | number> | undefined;
647
687
  variables?: string[] | undefined;
@@ -661,7 +701,8 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
661
701
  options: string[];
662
702
  } | {
663
703
  type: "numeric-keypad";
664
- includeDecimal: boolean;
704
+ includeOperators?: boolean | undefined;
705
+ includeDecimal?: boolean | undefined;
665
706
  }>;
666
707
  id?: string | undefined;
667
708
  meta?: {
@@ -732,11 +773,11 @@ export declare const ExpressionValidationSchema: z.ZodObject<{
732
773
  type: z.ZodLiteral<"ExpressionValidation">;
733
774
  expression: z.ZodString;
734
775
  }, "strip", z.ZodTypeAny, {
735
- type: "ExpressionValidation";
736
776
  expression: string;
737
- }, {
738
777
  type: "ExpressionValidation";
778
+ }, {
739
779
  expression: string;
780
+ type: "ExpressionValidation";
740
781
  }>;
741
782
 
742
783
  /**
@@ -809,6 +850,53 @@ export declare const GroupItemSchema: z.ZodObject<{
809
850
  items: any[];
810
851
  }>;
811
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
+
812
900
  export declare type InlineInputJSON = z.infer<typeof InlineInputJSONSchema>;
813
901
 
814
902
  export declare const InlineInputJSONSchema: z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
@@ -922,16 +1010,16 @@ export declare const InlineNodeSchema: z.ZodUnion<[z.ZodObject<{
922
1010
  }, {
923
1011
  type: "Space";
924
1012
  }>, z.ZodObject<{
925
- type: z.ZodLiteral<"NumberText">;
1013
+ type: z.ZodLiteral<"HighlightedText">;
926
1014
  value: z.ZodString;
927
1015
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
928
1016
  }, "strip", z.ZodTypeAny, {
929
1017
  value: string;
930
- type: "NumberText";
1018
+ type: "HighlightedText";
931
1019
  highlight?: [number, number] | undefined;
932
1020
  }, {
933
1021
  value: string;
934
- type: "NumberText";
1022
+ type: "HighlightedText";
935
1023
  highlight?: [number, number] | undefined;
936
1024
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
937
1025
  type: z.ZodLiteral<"InlineInput">;
@@ -993,6 +1081,13 @@ export declare function isGroupItem(item: LayoutItem): item is Extract<LayoutIte
993
1081
  type: 'group';
994
1082
  }>;
995
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
+
996
1091
  export declare function isInlineInput(value: unknown): value is InlineInputWidget;
997
1092
 
998
1093
  /**
@@ -1013,13 +1108,6 @@ export declare function isLinebreak(item: LayoutItem): item is Extract<LayoutIte
1013
1108
  type: 'linebreak';
1014
1109
  }>;
1015
1110
 
1016
- /**
1017
- * Type guard for NumberText
1018
- */
1019
- export declare function isNumberText(item: LayoutItem): item is Extract<LayoutItem, {
1020
- type: 'number-text';
1021
- }>;
1022
-
1023
1111
  export declare function isNumericKeypad(value: unknown): value is NumericKeypadTool;
1024
1112
 
1025
1113
  /**
@@ -1075,6 +1163,41 @@ export declare function isWidgetRef(item: LayoutItem): item is Extract<LayoutIte
1075
1163
  type: 'widget-ref';
1076
1164
  }>;
1077
1165
 
1166
+ /**
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
1198
+ */
1199
+ export declare type JSONType = typeof JSON_TYPES[keyof typeof JSON_TYPES];
1200
+
1078
1201
  export declare type LayoutItem = z.infer<typeof LayoutItemSchema>;
1079
1202
 
1080
1203
  export declare const LayoutItemSchema: z.ZodType<any>;
@@ -1090,6 +1213,7 @@ export declare interface LayoutRendererProps {
1090
1213
  values: Record<string, string>;
1091
1214
  droppedInputs: Set<string>;
1092
1215
  onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
1216
+ onInputFocus?: (widgetId: string) => void;
1093
1217
  }
1094
1218
 
1095
1219
  /**
@@ -1113,9 +1237,9 @@ export declare type LineBlock = z.infer<typeof LineBlockSchema>;
1113
1237
  * {
1114
1238
  * type: "LineBlock",
1115
1239
  * inlines: [
1116
- * { type: "NumberText", value: "151 000", highlight: [0, 3] },
1240
+ * { type: "HighlightedText", value: "151 000", highlight: [0, 3] },
1117
1241
  * { type: "InlineInput", name: "x", length: 1 },
1118
- * { type: "NumberText", value: "54 000", highlight: [0, 3] }
1242
+ * { type: "HighlightedText", value: "54 000", highlight: [0, 3] }
1119
1243
  * ]
1120
1244
  * }
1121
1245
  */
@@ -1137,16 +1261,16 @@ export declare const LineBlockSchema: z.ZodObject<{
1137
1261
  }, {
1138
1262
  type: "Space";
1139
1263
  }>, z.ZodObject<{
1140
- type: z.ZodLiteral<"NumberText">;
1264
+ type: z.ZodLiteral<"HighlightedText">;
1141
1265
  value: z.ZodString;
1142
1266
  highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1143
1267
  }, "strip", z.ZodTypeAny, {
1144
1268
  value: string;
1145
- type: "NumberText";
1269
+ type: "HighlightedText";
1146
1270
  highlight?: [number, number] | undefined;
1147
1271
  }, {
1148
1272
  value: string;
1149
- type: "NumberText";
1273
+ type: "HighlightedText";
1150
1274
  highlight?: [number, number] | undefined;
1151
1275
  }>, z.ZodDiscriminatedUnion<"inputType", [z.ZodObject<{
1152
1276
  type: z.ZodLiteral<"InlineInput">;
@@ -1194,7 +1318,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1194
1318
  type: "Space";
1195
1319
  } | {
1196
1320
  value: string;
1197
- type: "NumberText";
1321
+ type: "HighlightedText";
1198
1322
  highlight?: [number, number] | undefined;
1199
1323
  } | {
1200
1324
  length: number;
@@ -1218,7 +1342,7 @@ export declare const LineBlockSchema: z.ZodObject<{
1218
1342
  type: "Space";
1219
1343
  } | {
1220
1344
  value: string;
1221
- type: "NumberText";
1345
+ type: "HighlightedText";
1222
1346
  highlight?: [number, number] | undefined;
1223
1347
  } | {
1224
1348
  length: number;
@@ -1248,64 +1372,20 @@ export declare const LinebreakSchema: z.ZodObject<{
1248
1372
  id: string;
1249
1373
  }>;
1250
1374
 
1251
- export declare type NumberText = z.infer<typeof NumberTextSchema>;
1252
-
1253
- export declare type NumberTextInline = z.infer<typeof NumberTextInlineSchema>;
1254
-
1255
- /**
1256
- * Number text inline schema - styled numbers with optional highlighting
1257
- *
1258
- * highlight: [start, end] character positions for visual emphasis
1259
- *
1260
- * @example
1261
- * {
1262
- * type: "NumberText",
1263
- * value: "151 000",
1264
- * highlight: [0, 3] // Highlights "151"
1265
- * }
1266
- */
1267
- export declare const NumberTextInlineSchema: z.ZodObject<{
1268
- type: z.ZodLiteral<"NumberText">;
1269
- value: z.ZodString;
1270
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1271
- }, "strip", z.ZodTypeAny, {
1272
- value: string;
1273
- type: "NumberText";
1274
- highlight?: [number, number] | undefined;
1275
- }, {
1276
- value: string;
1277
- type: "NumberText";
1278
- highlight?: [number, number] | undefined;
1279
- }>;
1280
-
1281
- export declare const NumberTextSchema: z.ZodObject<{
1282
- id: z.ZodString;
1283
- type: z.ZodLiteral<"number-text">;
1284
- value: z.ZodString;
1285
- highlight: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1286
- }, "strip", z.ZodTypeAny, {
1287
- value: string;
1288
- type: "number-text";
1289
- id: string;
1290
- highlight?: [number, number] | undefined;
1291
- }, {
1292
- value: string;
1293
- type: "number-text";
1294
- id: string;
1295
- highlight?: [number, number] | undefined;
1296
- }>;
1297
-
1298
1375
  export declare type NumericKeypadJSON = z.infer<typeof NumericKeypadJSONSchema>;
1299
1376
 
1300
1377
  export declare const NumericKeypadJSONSchema: z.ZodObject<{
1301
1378
  type: z.ZodLiteral<"numeric-keypad">;
1302
- includeDecimal: z.ZodBoolean;
1379
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1380
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1303
1381
  }, "strip", z.ZodTypeAny, {
1304
1382
  type: "numeric-keypad";
1305
- includeDecimal: boolean;
1383
+ includeOperators?: boolean | undefined;
1384
+ includeDecimal?: boolean | undefined;
1306
1385
  }, {
1307
1386
  type: "numeric-keypad";
1308
- includeDecimal: boolean;
1387
+ includeOperators?: boolean | undefined;
1388
+ includeDecimal?: boolean | undefined;
1309
1389
  }>;
1310
1390
 
1311
1391
  export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
@@ -1321,22 +1401,21 @@ export declare type NumericKeypadTool = z.infer<typeof NumericKeypadToolSchema>;
1321
1401
  * @example
1322
1402
  * {
1323
1403
  * type: "NumericKeypad",
1324
- * includeDecimal: false,
1325
- * includeNegative: true
1404
+ * includeOperators: true
1326
1405
  * }
1327
1406
  */
1328
1407
  export declare const NumericKeypadToolSchema: z.ZodObject<{
1329
1408
  type: z.ZodLiteral<"NumericKeypad">;
1330
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
1331
- includeNegative: z.ZodDefault<z.ZodBoolean>;
1409
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1410
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1332
1411
  }, "strip", z.ZodTypeAny, {
1333
1412
  type: "NumericKeypad";
1334
- includeDecimal: boolean;
1335
- includeNegative: boolean;
1413
+ includeOperators?: boolean | undefined;
1414
+ includeDecimal?: boolean | undefined;
1336
1415
  }, {
1337
1416
  type: "NumericKeypad";
1417
+ includeOperators?: boolean | undefined;
1338
1418
  includeDecimal?: boolean | undefined;
1339
- includeNegative?: boolean | undefined;
1340
1419
  }>;
1341
1420
 
1342
1421
  export declare type OperatorItem = z.infer<typeof OperatorItemSchema>;
@@ -1346,13 +1425,13 @@ export declare const OperatorItemSchema: z.ZodObject<{
1346
1425
  type: z.ZodLiteral<"operator">;
1347
1426
  operator: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
1348
1427
  }, "strip", z.ZodTypeAny, {
1428
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1349
1429
  type: "operator";
1350
1430
  id: string;
1351
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1352
1431
  }, {
1432
+ operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1353
1433
  type: "operator";
1354
1434
  id: string;
1355
- operator: "+" | "-" | "×" | "÷" | "=" | "<" | ">" | "?";
1356
1435
  }>;
1357
1436
 
1358
1437
  export declare const OperatorSchema: z.ZodEnum<["+", "-", "×", "÷", "=", "<", ">", "?"]>;
@@ -1576,16 +1655,16 @@ export declare const ToolNodeSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
1576
1655
  options: string[];
1577
1656
  }>, z.ZodObject<{
1578
1657
  type: z.ZodLiteral<"NumericKeypad">;
1579
- includeDecimal: z.ZodDefault<z.ZodBoolean>;
1580
- includeNegative: z.ZodDefault<z.ZodBoolean>;
1658
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
1659
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1581
1660
  }, "strip", z.ZodTypeAny, {
1582
1661
  type: "NumericKeypad";
1583
- includeDecimal: boolean;
1584
- includeNegative: boolean;
1662
+ includeOperators?: boolean | undefined;
1663
+ includeDecimal?: boolean | undefined;
1585
1664
  }, {
1586
1665
  type: "NumericKeypad";
1666
+ includeOperators?: boolean | undefined;
1587
1667
  includeDecimal?: boolean | undefined;
1588
- includeNegative?: boolean | undefined;
1589
1668
  }>]>;
1590
1669
 
1591
1670
  /**
@@ -1645,7 +1724,7 @@ export declare function validateBooleanExpression(expression: string): string |
1645
1724
  */
1646
1725
  export declare function validateExerciseJSON(data: unknown): {
1647
1726
  validation: {
1648
- mode: "expression" | "simple";
1727
+ mode: "simple" | "expression";
1649
1728
  expression?: string | undefined;
1650
1729
  answers?: Record<string, string | number> | undefined;
1651
1730
  variables?: string[] | undefined;
@@ -1665,7 +1744,8 @@ export declare function validateExerciseJSON(data: unknown): {
1665
1744
  options: string[];
1666
1745
  } | {
1667
1746
  type: "numeric-keypad";
1668
- includeDecimal: boolean;
1747
+ includeOperators?: boolean | undefined;
1748
+ includeDecimal?: boolean | undefined;
1669
1749
  }>;
1670
1750
  id?: string | undefined;
1671
1751
  meta?: {
@@ -1694,7 +1774,7 @@ export declare function validateExerciseJSON(data: unknown): {
1694
1774
  */
1695
1775
  export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseReturnType<{
1696
1776
  validation: {
1697
- mode: "expression" | "simple";
1777
+ mode: "simple" | "expression";
1698
1778
  expression?: string | undefined;
1699
1779
  answers?: Record<string, string | number> | undefined;
1700
1780
  variables?: string[] | undefined;
@@ -1714,7 +1794,8 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1714
1794
  options: string[];
1715
1795
  } | {
1716
1796
  type: "numeric-keypad";
1717
- includeDecimal: boolean;
1797
+ includeOperators?: boolean | undefined;
1798
+ includeDecimal?: boolean | undefined;
1718
1799
  }>;
1719
1800
  id?: string | undefined;
1720
1801
  meta?: {
@@ -1725,7 +1806,7 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1725
1806
  } | undefined;
1726
1807
  }, {
1727
1808
  validation: {
1728
- mode: "expression" | "simple";
1809
+ mode: "simple" | "expression";
1729
1810
  expression?: string | undefined;
1730
1811
  answers?: Record<string, string | number> | undefined;
1731
1812
  variables?: string[] | undefined;
@@ -1745,7 +1826,8 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
1745
1826
  options: string[];
1746
1827
  } | {
1747
1828
  type: "numeric-keypad";
1748
- includeDecimal: boolean;
1829
+ includeOperators?: boolean | undefined;
1830
+ includeDecimal?: boolean | undefined;
1749
1831
  }>;
1750
1832
  id?: string | undefined;
1751
1833
  meta?: {
@@ -1804,7 +1886,8 @@ export declare function validateWidgetJSON(data: unknown): {
1804
1886
  options: string[];
1805
1887
  } | {
1806
1888
  type: "numeric-keypad";
1807
- includeDecimal: boolean;
1889
+ includeOperators?: boolean | undefined;
1890
+ includeDecimal?: boolean | undefined;
1808
1891
  };
1809
1892
 
1810
1893
  /**
@@ -1826,7 +1909,8 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
1826
1909
  options: string[];
1827
1910
  } | {
1828
1911
  type: "numeric-keypad";
1829
- includeDecimal: boolean;
1912
+ includeOperators?: boolean | undefined;
1913
+ includeDecimal?: boolean | undefined;
1830
1914
  }, {
1831
1915
  length: number;
1832
1916
  type: "inline-input";
@@ -1840,7 +1924,8 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
1840
1924
  options: string[];
1841
1925
  } | {
1842
1926
  type: "numeric-keypad";
1843
- includeDecimal: boolean;
1927
+ includeOperators?: boolean | undefined;
1928
+ includeDecimal?: boolean | undefined;
1844
1929
  }>;
1845
1930
 
1846
1931
  /**
@@ -1859,12 +1944,12 @@ export declare const ValidationJSONSchema: z.ZodObject<{
1859
1944
  expression: z.ZodOptional<z.ZodString>;
1860
1945
  variables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1861
1946
  }, "strip", z.ZodTypeAny, {
1862
- mode: "expression" | "simple";
1947
+ mode: "simple" | "expression";
1863
1948
  expression?: string | undefined;
1864
1949
  answers?: Record<string, string | number> | undefined;
1865
1950
  variables?: string[] | undefined;
1866
1951
  }, {
1867
- mode: "expression" | "simple";
1952
+ mode: "simple" | "expression";
1868
1953
  expression?: string | undefined;
1869
1954
  answers?: Record<string, string | number> | undefined;
1870
1955
  variables?: string[] | undefined;
@@ -1885,11 +1970,11 @@ export declare const ValidationNodeSchema: z.ZodDiscriminatedUnion<"type", [z.Zo
1885
1970
  type: z.ZodLiteral<"ExpressionValidation">;
1886
1971
  expression: z.ZodString;
1887
1972
  }, "strip", z.ZodTypeAny, {
1888
- type: "ExpressionValidation";
1889
1973
  expression: string;
1890
- }, {
1891
1974
  type: "ExpressionValidation";
1975
+ }, {
1892
1976
  expression: string;
1977
+ type: "ExpressionValidation";
1893
1978
  }>]>;
1894
1979
 
1895
1980
  /**
@@ -1947,13 +2032,16 @@ export declare const WidgetJSONSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"inpu
1947
2032
  options: string[];
1948
2033
  }>, z.ZodObject<{
1949
2034
  type: z.ZodLiteral<"numeric-keypad">;
1950
- includeDecimal: z.ZodBoolean;
2035
+ includeOperators: z.ZodOptional<z.ZodBoolean>;
2036
+ includeDecimal: z.ZodOptional<z.ZodBoolean>;
1951
2037
  }, "strip", z.ZodTypeAny, {
1952
2038
  type: "numeric-keypad";
1953
- includeDecimal: boolean;
2039
+ includeOperators?: boolean | undefined;
2040
+ includeDecimal?: boolean | undefined;
1954
2041
  }, {
1955
2042
  type: "numeric-keypad";
1956
- includeDecimal: boolean;
2043
+ includeOperators?: boolean | undefined;
2044
+ includeDecimal?: boolean | undefined;
1957
2045
  }>]>;
1958
2046
 
1959
2047
  export declare type WidgetRef = z.infer<typeof WidgetRefSchema>;
@@ -1985,6 +2073,8 @@ export declare interface WidgetRendererProps {
1985
2073
  value: string;
1986
2074
  isDropped?: boolean;
1987
2075
  onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
2076
+ onInputFocus?: (widgetId: string) => void;
2077
+ onKeypadChange?: (value: string) => void;
1988
2078
  }
1989
2079
 
1990
2080
  /**