@doenet/v06-to-v07 0.7.1 → 0.7.2

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.
Files changed (3) hide show
  1. package/index.js +116 -76
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -68793,6 +68793,82 @@ let P$2 = class P3 extends BlockComponent {
68793
68793
  });
68794
68794
  }
68795
68795
  };
68796
+ class Case extends BaseComponent {
68797
+ static componentType = "case";
68798
+ static rendererType = void 0;
68799
+ static inSchemaOnlyInheritAs = [];
68800
+ static allowInSchemaAsComponent = void 0;
68801
+ static includeBlankStringChildren = true;
68802
+ static keepChildrenSerialized({ serializedComponent }) {
68803
+ if (serializedComponent.children === void 0) {
68804
+ return [];
68805
+ } else {
68806
+ return Object.keys(serializedComponent.children);
68807
+ }
68808
+ }
68809
+ // since don't have child groups, tell schema about children here
68810
+ static additionalSchemaChildren = ["_base"];
68811
+ static createAttributesObject() {
68812
+ let attributes = super.createAttributesObject();
68813
+ attributes.condition = {
68814
+ createComponentOfType: "boolean"
68815
+ };
68816
+ return attributes;
68817
+ }
68818
+ static returnStateVariableDefinitions() {
68819
+ let stateVariableDefinitions = super.returnStateVariableDefinitions();
68820
+ stateVariableDefinitions.serializedChildren = {
68821
+ returnDependencies: () => ({
68822
+ serializedChildren: {
68823
+ dependencyType: "serializedChildren",
68824
+ doNotProxy: true
68825
+ }
68826
+ }),
68827
+ definition: function({ dependencyValues }) {
68828
+ return {
68829
+ setValue: {
68830
+ serializedChildren: dependencyValues.serializedChildren
68831
+ }
68832
+ };
68833
+ }
68834
+ };
68835
+ stateVariableDefinitions.conditionSatisfied = {
68836
+ public: true,
68837
+ shadowingInstructions: {
68838
+ createComponentOfType: "boolean"
68839
+ },
68840
+ returnDependencies: () => ({
68841
+ condition: {
68842
+ dependencyType: "attributeComponent",
68843
+ attributeName: "condition",
68844
+ variableNames: ["value"]
68845
+ }
68846
+ }),
68847
+ definition: function({ dependencyValues }) {
68848
+ let conditionSatisfied;
68849
+ if (dependencyValues.condition === null) {
68850
+ conditionSatisfied = true;
68851
+ } else {
68852
+ conditionSatisfied = dependencyValues.condition.stateValues.value;
68853
+ }
68854
+ return { setValue: { conditionSatisfied } };
68855
+ }
68856
+ };
68857
+ return stateVariableDefinitions;
68858
+ }
68859
+ get allPotentialRendererTypes() {
68860
+ let allPotentialRendererTypes = super.allPotentialRendererTypes;
68861
+ let additionalRendererTypes = this.potentialRendererTypesFromSerializedComponents(
68862
+ this.serializedChildren
68863
+ );
68864
+ for (let rendererType of additionalRendererTypes) {
68865
+ if (!allPotentialRendererTypes.includes(rendererType)) {
68866
+ allPotentialRendererTypes.push(rendererType);
68867
+ }
68868
+ }
68869
+ return allPotentialRendererTypes;
68870
+ }
68871
+ }
68796
68872
  class Title extends TextOrInline {
68797
68873
  static componentType = "title";
68798
68874
  }
@@ -68854,11 +68930,15 @@ class cascadeMessage extends P$2 {
68854
68930
  static rendererType = "p";
68855
68931
  static inSchemaOnlyInheritAs = [];
68856
68932
  }
68933
+ class Else extends Case {
68934
+ static componentType = "else";
68935
+ }
68857
68936
  const Aliases = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
68858
68937
  __proto__: null,
68859
68938
  Br: Br$1,
68860
68939
  Conclusion,
68861
68940
  Description,
68941
+ Else,
68862
68942
  Hr: Hr$1,
68863
68943
  Introduction,
68864
68944
  MatrixColumn,
@@ -140508,6 +140588,17 @@ class ConditionalContent extends CompositeComponent {
140508
140588
  static allowInSchemaAsComponent = ["_inline", "_block", "_graphical"];
140509
140589
  static createsVariants = true;
140510
140590
  static stateVariableToEvaluateAfterReplacements = "readyToExpandWhenResolved";
140591
+ static createAttributesObject() {
140592
+ let attributes = super.createAttributesObject();
140593
+ attributes.condition = {
140594
+ createComponentOfType: "boolean"
140595
+ };
140596
+ return attributes;
140597
+ }
140598
+ // conditionalContent can be authored with any children.
140599
+ // Case children will be sugared in so they are the only child group.
140600
+ // We need to allow for any children in the schema.
140601
+ static additionalSchemaChildren = ["_base", "else"];
140511
140602
  static returnChildGroups() {
140512
140603
  return [
140513
140604
  {
@@ -140518,6 +140609,27 @@ class ConditionalContent extends CompositeComponent {
140518
140609
  }
140519
140610
  static returnStateVariableDefinitions() {
140520
140611
  let stateVariableDefinitions = super.returnStateVariableDefinitions();
140612
+ stateVariableDefinitions.warnIfCondition = {
140613
+ returnDependencies: () => ({
140614
+ conditionAttribute: {
140615
+ dependencyType: "attributeComponent",
140616
+ attributeName: "condition"
140617
+ }
140618
+ }),
140619
+ definition({ dependencyValues }) {
140620
+ const warnings = [];
140621
+ if (dependencyValues.conditionAttribute) {
140622
+ warnings.push({
140623
+ message: "Attribute `condition` is ignored on a <conditionalContent> component with case or else children.",
140624
+ level: 1
140625
+ });
140626
+ }
140627
+ return {
140628
+ sendWarnings: warnings,
140629
+ setValue: { warnIfCondition: null }
140630
+ };
140631
+ }
140632
+ };
140521
140633
  stateVariableDefinitions.numCases = {
140522
140634
  additionalStateVariablesDefined: ["caseChildren"],
140523
140635
  returnDependencies: () => ({
@@ -140566,6 +140678,10 @@ class ConditionalContent extends CompositeComponent {
140566
140678
  selectedIndex: {
140567
140679
  dependencyType: "stateVariable",
140568
140680
  variableName: "selectedIndex"
140681
+ },
140682
+ warnIfCondition: {
140683
+ dependencyType: "stateVariable",
140684
+ variableName: "warnIfCondition"
140569
140685
  }
140570
140686
  }),
140571
140687
  markStale: () => ({ updateReplacements: true }),
@@ -191116,82 +191232,6 @@ class ConsiderAsResponses extends BaseComponent {
191116
191232
  return stateVariableDefinitions;
191117
191233
  }
191118
191234
  }
191119
- class Case extends BaseComponent {
191120
- static componentType = "case";
191121
- static rendererType = void 0;
191122
- static inSchemaOnlyInheritAs = [];
191123
- static allowInSchemaAsComponent = void 0;
191124
- static includeBlankStringChildren = true;
191125
- static keepChildrenSerialized({ serializedComponent }) {
191126
- if (serializedComponent.children === void 0) {
191127
- return [];
191128
- } else {
191129
- return Object.keys(serializedComponent.children);
191130
- }
191131
- }
191132
- // since don't have child groups, tell schema about children here
191133
- static additionalSchemaChildren = ["_base"];
191134
- static createAttributesObject() {
191135
- let attributes = super.createAttributesObject();
191136
- attributes.condition = {
191137
- createComponentOfType: "boolean"
191138
- };
191139
- return attributes;
191140
- }
191141
- static returnStateVariableDefinitions() {
191142
- let stateVariableDefinitions = super.returnStateVariableDefinitions();
191143
- stateVariableDefinitions.serializedChildren = {
191144
- returnDependencies: () => ({
191145
- serializedChildren: {
191146
- dependencyType: "serializedChildren",
191147
- doNotProxy: true
191148
- }
191149
- }),
191150
- definition: function({ dependencyValues }) {
191151
- return {
191152
- setValue: {
191153
- serializedChildren: dependencyValues.serializedChildren
191154
- }
191155
- };
191156
- }
191157
- };
191158
- stateVariableDefinitions.conditionSatisfied = {
191159
- public: true,
191160
- shadowingInstructions: {
191161
- createComponentOfType: "boolean"
191162
- },
191163
- returnDependencies: () => ({
191164
- condition: {
191165
- dependencyType: "attributeComponent",
191166
- attributeName: "condition",
191167
- variableNames: ["value"]
191168
- }
191169
- }),
191170
- definition: function({ dependencyValues }) {
191171
- let conditionSatisfied;
191172
- if (dependencyValues.condition === null) {
191173
- conditionSatisfied = true;
191174
- } else {
191175
- conditionSatisfied = dependencyValues.condition.stateValues.value;
191176
- }
191177
- return { setValue: { conditionSatisfied } };
191178
- }
191179
- };
191180
- return stateVariableDefinitions;
191181
- }
191182
- get allPotentialRendererTypes() {
191183
- let allPotentialRendererTypes = super.allPotentialRendererTypes;
191184
- let additionalRendererTypes = this.potentialRendererTypesFromSerializedComponents(
191185
- this.serializedChildren
191186
- );
191187
- for (let rendererType of additionalRendererTypes) {
191188
- if (!allPotentialRendererTypes.includes(rendererType)) {
191189
- allPotentialRendererTypes.push(rendererType);
191190
- }
191191
- }
191192
- return allPotentialRendererTypes;
191193
- }
191194
- }
191195
191235
  var dist = {};
191196
191236
  var formats = {};
191197
191237
  var hasRequiredFormats;