Skip to content

Commit

Permalink
Convert list components to composites (#249)
Browse files Browse the repository at this point in the history
* convert mathList, numberList, textList, booleanList
* correctly shadow composites that shadow prop variables
* numberLists merge math lists with single child
* inverse definition of text will attempt to update a composite-generated list
* list props on text, textInput, math, mathInput
  • Loading branch information
dqnykamp authored Oct 30, 2024
1 parent 3f1bfe8 commit 0909ca2
Show file tree
Hide file tree
Showing 65 changed files with 10,004 additions and 14,413 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"tabWidth": 4
},
"dependencies": {
"math-expressions": "^2.0.0-alpha70",
"math-expressions": "^2.0.0-alpha71",
"react-router-dom": "^6.26.2"
}
}
2 changes: 1 addition & 1 deletion packages/doenetml-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@doenet/doenetml-iframe",
"type": "module",
"description": "A renderer for DoenetML contained in an iframe",
"version": "0.7.0-alpha20",
"version": "0.7.0-alpha21",
"license": "AGPL-3.0-or-later",
"homepage": "https://github.com/Doenet/DoenetML#readme",
"private": true,
Expand Down
264 changes: 205 additions & 59 deletions packages/doenetml-worker/src/Core.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/doenetml-worker/src/CoreWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ async function createCore(args) {
}
queuedRequestActions = [];
} catch (e) {
// throw e;
postMessage({
messageType: "inErrorState",
coreId: coreArgs.coreId,
Expand Down
2 changes: 0 additions & 2 deletions packages/doenetml-worker/src/components/Aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ export class Ylabel extends Label {

export class MatrixRow extends MathList {
static componentType = "matrixRow";
static rendererType = "mathList";
static excludeFromSchema = true;
}

export class MatrixColumn extends MathList {
static componentType = "matrixColumn";
static rendererType = "mathList";
static excludeFromSchema = true;
}

Expand Down
31 changes: 6 additions & 25 deletions packages/doenetml-worker/src/components/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export default class Answer extends InlineComponent {
};
attributes.type = {
createPrimitiveOfType: "string",
createStateVariable: "type",
defaultValue: null,
};

attributes.disableAfterCorrect = {
Expand Down Expand Up @@ -251,8 +253,8 @@ export default class Answer extends InlineComponent {
componentAttributes,
componentInfoObjects,
}) {
// if chidren are strings and macros
// wrap with award and type
// if children are strings and macros
// wrap with award

function checkForResponseDescendant(components) {
for (let component of components) {
Expand Down Expand Up @@ -355,7 +357,7 @@ export default class Answer extends InlineComponent {
} else if (
componentIsSpecifiedType(grandChild, "when")
) {
// have to test for when before boolean, sincd when is derived from boolean!
// have to test for `when` before `boolean`, since `when` is derived from `boolean`!
} else if (
componentIsSpecifiedType(grandChild, "math") ||
componentIsSpecifiedType(
Expand Down Expand Up @@ -596,28 +598,7 @@ export default class Answer extends InlineComponent {
...childrenToNotWrapEnd,
];
} else {
// if have one child and it has a specified componentType
// then no need to wrap with componentType

let needToWrapWithComponentType =
childrenToWrap.length > 1 ||
(componentInfoObjects.isInheritedComponentType({
inheritedComponentType: childrenToWrap[0].componentType,
baseComponentType: "_composite",
}) &&
!childrenToWrap[0].props?.componentType);

let awardChildren;
if (needToWrapWithComponentType) {
awardChildren = [
{
componentType: type,
children: childrenToWrap,
},
];
} else {
awardChildren = childrenToWrap;
}
let awardChildren = childrenToWrap;
newChildren = [
...childrenToNotWrapBegin,
{
Expand Down
Loading

0 comments on commit 0909ca2

Please sign in to comment.