@mathscan/math-exercise-engine 1.2.3 → 1.2.4
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 +20 -0
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +10 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6239,6 +6239,7 @@ export declare function compileWithAST(dsl: string): {
|
|
|
6239
6239
|
backgroundColor?: string | undefined;
|
|
6240
6240
|
}[];
|
|
6241
6241
|
cols: number;
|
|
6242
|
+
borderColor: string;
|
|
6242
6243
|
} | {
|
|
6243
6244
|
type: "VerticalOperationBlock";
|
|
6244
6245
|
items: ({
|
|
@@ -7402,6 +7403,7 @@ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
7402
7403
|
}>, z.ZodObject<{
|
|
7403
7404
|
type: z.ZodLiteral<"TableBlock">;
|
|
7404
7405
|
cols: z.ZodNumber;
|
|
7406
|
+
borderColor: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
7405
7407
|
rows: z.ZodArray<z.ZodObject<{
|
|
7406
7408
|
type: z.ZodLiteral<"TableRow">;
|
|
7407
7409
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
@@ -8095,6 +8097,7 @@ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
8095
8097
|
backgroundColor?: string | undefined;
|
|
8096
8098
|
}[];
|
|
8097
8099
|
cols: number;
|
|
8100
|
+
borderColor: string;
|
|
8098
8101
|
}, {
|
|
8099
8102
|
type: "TableBlock";
|
|
8100
8103
|
rows: {
|
|
@@ -8186,6 +8189,7 @@ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
8186
8189
|
backgroundColor?: string | undefined;
|
|
8187
8190
|
}[];
|
|
8188
8191
|
cols: number;
|
|
8192
|
+
borderColor?: string | undefined;
|
|
8189
8193
|
}>, z.ZodObject<{
|
|
8190
8194
|
type: z.ZodLiteral<"RadioOptions">;
|
|
8191
8195
|
name: z.ZodString;
|
|
@@ -16281,6 +16285,9 @@ export declare function createVopRow(cells: VopCell[], op?: VopOperator): VopRow
|
|
|
16281
16285
|
|
|
16282
16286
|
export declare function createVopSeparator(): VopSeparator;
|
|
16283
16287
|
|
|
16288
|
+
/** Default color used for table borders and internal separators. */
|
|
16289
|
+
export declare const DEFAULT_TABLE_BORDER_COLOR = "#7c6cf2";
|
|
16290
|
+
|
|
16284
16291
|
export declare type DisplayInlineNode = z.infer<typeof DisplayInlineNodeSchema>;
|
|
16285
16292
|
|
|
16286
16293
|
export declare const DisplayInlineNodeSchema: z.ZodUnion<[z.ZodObject<{
|
|
@@ -16995,6 +17002,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
16995
17002
|
}>, z.ZodObject<{
|
|
16996
17003
|
type: z.ZodLiteral<"TableBlock">;
|
|
16997
17004
|
cols: z.ZodNumber;
|
|
17005
|
+
borderColor: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
16998
17006
|
rows: z.ZodArray<z.ZodObject<{
|
|
16999
17007
|
type: z.ZodLiteral<"TableRow">;
|
|
17000
17008
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
@@ -17688,6 +17696,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
17688
17696
|
backgroundColor?: string | undefined;
|
|
17689
17697
|
}[];
|
|
17690
17698
|
cols: number;
|
|
17699
|
+
borderColor: string;
|
|
17691
17700
|
}, {
|
|
17692
17701
|
type: "TableBlock";
|
|
17693
17702
|
rows: {
|
|
@@ -17779,6 +17788,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
17779
17788
|
backgroundColor?: string | undefined;
|
|
17780
17789
|
}[];
|
|
17781
17790
|
cols: number;
|
|
17791
|
+
borderColor?: string | undefined;
|
|
17782
17792
|
}>, z.ZodObject<{
|
|
17783
17793
|
type: z.ZodLiteral<"RadioOptions">;
|
|
17784
17794
|
name: z.ZodString;
|
|
@@ -26123,6 +26133,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
26123
26133
|
backgroundColor?: string | undefined;
|
|
26124
26134
|
}[];
|
|
26125
26135
|
cols: number;
|
|
26136
|
+
borderColor: string;
|
|
26126
26137
|
} | {
|
|
26127
26138
|
type: "VerticalOperationBlock";
|
|
26128
26139
|
items: ({
|
|
@@ -27119,6 +27130,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
27119
27130
|
backgroundColor?: string | undefined;
|
|
27120
27131
|
}[];
|
|
27121
27132
|
cols: number;
|
|
27133
|
+
borderColor?: string | undefined;
|
|
27122
27134
|
} | {
|
|
27123
27135
|
type: "VerticalOperationBlock";
|
|
27124
27136
|
items: ({
|
|
@@ -28115,6 +28127,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
28115
28127
|
backgroundColor?: string | undefined;
|
|
28116
28128
|
}[];
|
|
28117
28129
|
cols: number;
|
|
28130
|
+
borderColor: string;
|
|
28118
28131
|
} | {
|
|
28119
28132
|
type: "VerticalOperationBlock";
|
|
28120
28133
|
items: ({
|
|
@@ -29111,6 +29124,7 @@ export declare const ExerciseDocumentSchema: z.ZodEffects<z.ZodObject<{
|
|
|
29111
29124
|
backgroundColor?: string | undefined;
|
|
29112
29125
|
}[];
|
|
29113
29126
|
cols: number;
|
|
29127
|
+
borderColor?: string | undefined;
|
|
29114
29128
|
} | {
|
|
29115
29129
|
type: "VerticalOperationBlock";
|
|
29116
29130
|
items: ({
|
|
@@ -38876,6 +38890,7 @@ export declare type TableBlock = z.infer<typeof TableBlockSchema>;
|
|
|
38876
38890
|
declare const TableBlockSchema: z.ZodObject<{
|
|
38877
38891
|
type: z.ZodLiteral<"TableBlock">;
|
|
38878
38892
|
cols: z.ZodNumber;
|
|
38893
|
+
borderColor: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
38879
38894
|
rows: z.ZodArray<z.ZodObject<{
|
|
38880
38895
|
type: z.ZodLiteral<"TableRow">;
|
|
38881
38896
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
@@ -39569,6 +39584,7 @@ declare const TableBlockSchema: z.ZodObject<{
|
|
|
39569
39584
|
backgroundColor?: string | undefined;
|
|
39570
39585
|
}[];
|
|
39571
39586
|
cols: number;
|
|
39587
|
+
borderColor: string;
|
|
39572
39588
|
}, {
|
|
39573
39589
|
type: "TableBlock";
|
|
39574
39590
|
rows: {
|
|
@@ -39660,6 +39676,7 @@ declare const TableBlockSchema: z.ZodObject<{
|
|
|
39660
39676
|
backgroundColor?: string | undefined;
|
|
39661
39677
|
}[];
|
|
39662
39678
|
cols: number;
|
|
39679
|
+
borderColor?: string | undefined;
|
|
39663
39680
|
}>;
|
|
39664
39681
|
|
|
39665
39682
|
export declare type TableCell = z.infer<typeof TableCellSchema>;
|
|
@@ -40120,6 +40137,7 @@ export declare const TableItemSchema: z.ZodObject<{
|
|
|
40120
40137
|
id: z.ZodString;
|
|
40121
40138
|
type: z.ZodLiteral<"table">;
|
|
40122
40139
|
cols: z.ZodNumber;
|
|
40140
|
+
borderColor: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
|
|
40123
40141
|
rows: z.ZodArray<z.ZodObject<{
|
|
40124
40142
|
id: z.ZodString;
|
|
40125
40143
|
type: z.ZodLiteral<"table-row">;
|
|
@@ -40187,6 +40205,7 @@ export declare const TableItemSchema: z.ZodObject<{
|
|
|
40187
40205
|
backgroundColor?: string | undefined;
|
|
40188
40206
|
}[];
|
|
40189
40207
|
cols: number;
|
|
40208
|
+
borderColor: string;
|
|
40190
40209
|
id: string;
|
|
40191
40210
|
}, {
|
|
40192
40211
|
type: "table";
|
|
@@ -40205,6 +40224,7 @@ export declare const TableItemSchema: z.ZodObject<{
|
|
|
40205
40224
|
}[];
|
|
40206
40225
|
cols: number;
|
|
40207
40226
|
id: string;
|
|
40227
|
+
borderColor?: string | undefined;
|
|
40208
40228
|
}>;
|
|
40209
40229
|
|
|
40210
40230
|
export declare type TableRow = z.infer<typeof TableRowSchema>;
|
package/dist/index.js
CHANGED
|
@@ -267,6 +267,10 @@ const HEX_COLOR_REGEX = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;
|
|
|
267
267
|
const isNumberLineHighlightColor = (value) => NUMBER_LINE_HIGHLIGHT_COLORS.includes(value) || HEX_COLOR_REGEX.test(value);
|
|
268
268
|
const highlightColorMessage = (block) => `${block}: color must be one of ${NUMBER_LINE_HIGHLIGHT_COLORS.join(", ")} or a hex value (e.g. "#3B82F6")`;
|
|
269
269
|
const NUMBER_LINE_DRAG_MODES = ["axis", "inputs"];
|
|
270
|
+
const DEFAULT_TABLE_BORDER_COLOR = "#7c6cf2";
|
|
271
|
+
const isTableBorderColor = (value) => value.toLowerCase() === "transparent" || HEX_COLOR_REGEX.test(value);
|
|
272
|
+
const TABLE_BORDER_COLOR_ERROR = 'TABLE: bordercolor must be "transparent" or a hex value (e.g. "#E67E22" or "#F00")';
|
|
273
|
+
const TableBorderColorSchema = zod.z.string({ message: TABLE_BORDER_COLOR_ERROR }).refine(isTableBorderColor, { message: TABLE_BORDER_COLOR_ERROR }).default(DEFAULT_TABLE_BORDER_COLOR);
|
|
270
274
|
function getFractionKey(widgetId, part) {
|
|
271
275
|
return `${widgetId}__${part}`;
|
|
272
276
|
}
|
|
@@ -2536,12 +2540,14 @@ function createTableRow(cells, backgroundColor) {
|
|
|
2536
2540
|
const TableBlockSchema = zod.z.object({
|
|
2537
2541
|
type: zod.z.literal(AST_TYPES.TABLE_BLOCK),
|
|
2538
2542
|
cols: zod.z.number().int().positive(),
|
|
2543
|
+
borderColor: TableBorderColorSchema,
|
|
2539
2544
|
rows: zod.z.array(TableRowSchema).min(1)
|
|
2540
2545
|
});
|
|
2541
|
-
function createTableBlock(cols, rows) {
|
|
2546
|
+
function createTableBlock(cols, rows, borderColor) {
|
|
2542
2547
|
return TableBlockSchema.parse({
|
|
2543
2548
|
type: AST_TYPES.TABLE_BLOCK,
|
|
2544
2549
|
cols,
|
|
2550
|
+
borderColor,
|
|
2545
2551
|
rows
|
|
2546
2552
|
});
|
|
2547
2553
|
}
|
|
@@ -3486,8 +3492,10 @@ class NaturalDSLVisitor extends BaseCstVisitor {
|
|
|
3486
3492
|
table(ctx) {
|
|
3487
3493
|
const params = this.visit(ctx.parameterList);
|
|
3488
3494
|
const cols = params.cols;
|
|
3495
|
+
const borderColorParam = params.bordercolor;
|
|
3496
|
+
const borderColor = borderColorParam === void 0 ? void 0 : String(borderColorParam);
|
|
3489
3497
|
const rows = ctx.row.map((r) => this.visit(r));
|
|
3490
|
-
return createTableBlock(cols, rows);
|
|
3498
|
+
return createTableBlock(cols, rows, borderColor);
|
|
3491
3499
|
}
|
|
3492
3500
|
row(ctx) {
|
|
3493
3501
|
const params = ctx.parameterList ? this.visit(ctx.parameterList) : {};
|
|
@@ -4282,6 +4290,7 @@ const TableItemSchema = zod.z.object({
|
|
|
4282
4290
|
id: zod.z.string(),
|
|
4283
4291
|
type: zod.z.literal(JSON_TYPES.TABLE),
|
|
4284
4292
|
cols: zod.z.number().int().positive(),
|
|
4293
|
+
borderColor: TableBorderColorSchema,
|
|
4285
4294
|
rows: zod.z.array(TableRowItemSchema)
|
|
4286
4295
|
});
|
|
4287
4296
|
const NumberLinePositionItemSchema = zod.z.object({
|
|
@@ -10866,6 +10875,7 @@ function transformTable(table, idGenerator, inlineDragIds) {
|
|
|
10866
10875
|
id: idGenerator.generate(JSON_TYPES.TABLE),
|
|
10867
10876
|
type: JSON_TYPES.TABLE,
|
|
10868
10877
|
cols: table.cols,
|
|
10878
|
+
borderColor: table.borderColor,
|
|
10869
10879
|
rows
|
|
10870
10880
|
};
|
|
10871
10881
|
}
|
|
@@ -20627,7 +20637,10 @@ const LayoutRenderer = ({
|
|
|
20627
20637
|
)) });
|
|
20628
20638
|
case JSON_TYPES.TABLE: {
|
|
20629
20639
|
const totalRows = item.rows.length;
|
|
20630
|
-
|
|
20640
|
+
const tableStyle = {
|
|
20641
|
+
"--exercise-table-border-color": item.borderColor ?? DEFAULT_TABLE_BORDER_COLOR
|
|
20642
|
+
};
|
|
20643
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "exercise-table-container", style: tableStyle, children: /* @__PURE__ */ jsxRuntime.jsx("table", { className: "exercise-table", children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: item.rows.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "exercise-table-row", style: { backgroundColor: row.backgroundColor }, children: row.cells.map((cell) => {
|
|
20631
20644
|
const rowspan = cell.rowspan || 1;
|
|
20632
20645
|
const isLastRow = rowIndex + rowspan - 1 >= totalRows - 1;
|
|
20633
20646
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -21333,6 +21346,7 @@ exports.ClockItemSchema = ClockItemSchema;
|
|
|
21333
21346
|
exports.ColorTextInlineSchema = ColorTextInlineSchema;
|
|
21334
21347
|
exports.ColorTextSchema = ColorTextSchema;
|
|
21335
21348
|
exports.ContentBlockSchema = ContentBlockSchema;
|
|
21349
|
+
exports.DEFAULT_TABLE_BORDER_COLOR = DEFAULT_TABLE_BORDER_COLOR;
|
|
21336
21350
|
exports.DisplayInlineNodeSchema = DisplayInlineNodeSchema;
|
|
21337
21351
|
exports.DragOptionsJSONSchema = DragOptionsJSONSchema;
|
|
21338
21352
|
exports.DragOptionsToolSchema = DragOptionsToolSchema;
|