Skip to content

Commit

Permalink
Merge pull request #394 from freon4dsl/fix-focus
Browse files Browse the repository at this point in the history
Fix focus
  • Loading branch information
joswarmer authored Oct 15, 2024
2 parents f4de39f + 366db6a commit fcb88b5
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 73 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
"packages/server",
"packages/test"
],
"version": "0.7.0-beta4"
"version": "0.7.0-beta5"
}
6 changes: 3 additions & 3 deletions packages/core-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"access": "public"
},
"name": "@freon4dsl/core-svelte",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"repository": {
"type": "git",
Expand Down Expand Up @@ -45,7 +45,7 @@
"!dist/**/*.spec.*"
],
"devDependencies": {
"@freon4dsl/core": "^0.7.0-beta4",
"@freon4dsl/core": "^0.7.0-beta5",
"mobx": "^6.12.3",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/svelte": "^5.1.0",
Expand All @@ -70,7 +70,7 @@
"@material/switch": "^14.0.0",
"@smui/ripple": "^7.0.0",
"svelte": "^4.2.17",
"@freon4dsl/core": "^0.7.0-beta4",
"@freon4dsl/core": "^0.7.0-beta5",
"mobx": "^6.12.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@
LOGGER.log(" selectedOption is " + selectedOption?.label)
if (!!selectedOption) {
setTextLocalAndInBox(selectedOption.label);
selectedId = selectedOption.id
} else {
selectedId = undefined
}
selectedId = undefined
}
// because the box maybe a different one than we started with ...
// box.setFocus = setFocus; todo remove?
Expand Down Expand Up @@ -142,7 +144,9 @@
if (isActionBox(box)) {
// Try to match a regular expression, and execute the action that is associated with it
const result = box.tryToMatchRegExpAndExecuteAction(text, editor);
if (result === BehaviorExecutionResult.EXECUTED) endEditing();
if (result === BehaviorExecutionResult.EXECUTED) {
endEditing();
}
}
};
Expand Down Expand Up @@ -264,6 +268,7 @@
// stop editing
isEditing = false;
dropdownShown = false;
editor.selectNextLeaf()
}
event.preventDefault();
event.stopPropagation();
Expand All @@ -285,6 +290,8 @@
if (allOptions.length === 1) {
storeOrExecute(allOptions[0])
} else {
selectedId = box.getSelectedOption()?.id
console.log("Setting selected option to " + selectedId)
startEditing();
}
event.stopPropagation();
Expand Down Expand Up @@ -348,13 +355,15 @@
* @param selected
*/
function storeOrExecute(selected: SelectOption) {
LOGGER.log('storeOrExecute for option ' + selected.label + ' ' + box.kind);
console.log('storeOrExecute for option ' + selected.label + ' ' + box.kind + ' ' + box.role);
isEditing = false;
dropdownShown = false;
box.executeOption(editor, selected); // TODO the result of the execution is ignored
if (isActionBox(box)) { // ActionBox, action done, clear input text
setTextLocalAndInBox('');
} else {
editor.selectNextLeaf(box)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/core",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"description": "The uttermost core part of the Freon library, which enables you to build editors for the web",
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class UtilPrimHelper {
node[propertyName][index] = false;
}
});
return BehaviorExecutionResult.NULL;
return BehaviorExecutionResult.EXECUTED;
},
);
} else {
Expand Down Expand Up @@ -343,7 +343,7 @@ export class UtilPrimHelper {
node[propertyName] = false;
}
});
return BehaviorExecutionResult.NULL;
return BehaviorExecutionResult.EXECUTED;
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/meta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"access": "public"
},
"name": "@freon4dsl/meta",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
57 changes: 33 additions & 24 deletions packages/meta/src/languagedef/generator/templates/ModelTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class ModelTemplate {
Names.FreModel,
Names.FreLanguage,
Names.FreParseLocation,
"AST"
]);
const modelImports = this.findModelImports(modelDescription, myName);
const metaType = Names.metaType();
Expand Down Expand Up @@ -75,12 +76,14 @@ export class ModelTemplate {
.map(
(part) =>
`if ( oldUnit.freLanguageConcept() === "${Names.classifier(part.type)}" && oldUnit.freOwnerDescriptor().propertyName === "${part.name}" ) {
${
part.isList
? `const index = this.${part.name}.indexOf(oldUnit as ${Names.classifier(part.type)});
this.${part.name}.splice(index, 1, newUnit as ${Names.classifier(part.type)});`
: `this.${part.name} = newUnit as ${Names.classifier(part.type)};`
}
AST.changeNamed("removeUnit", () => {
${
part.isList
? `const index = this.${part.name}.indexOf(oldUnit as ${Names.classifier(part.type)});
this.${part.name}.splice(index, 1, newUnit as ${Names.classifier(part.type)});`
: `this.${part.name} = newUnit as ${Names.classifier(part.type)};`
}
})
} else`,
)
.join(" ")}
Expand All @@ -104,12 +107,14 @@ export class ModelTemplate {
.map(
(part) =>
`case "${Names.classifier(part.type)}": {
${
part.isList
? `this.${part.name}.push(newUnit as ${Names.classifier(part.type)});`
: `this.${part.name} = newUnit as ${Names.classifier(part.type)}`
}
return true;
AST.changeNamed("addUnit", () => {
${
part.isList
? `this.${part.name}.push(newUnit as ${Names.classifier(part.type)});`
: `this.${part.name} = newUnit as ${Names.classifier(part.type)}`
}
})
return true;
}`,
)
.join("\n")}
Expand All @@ -132,13 +137,15 @@ export class ModelTemplate {
.map(
(part) =>
`case "${Names.classifier(part.type)}": {
${
part.isList
? `this.${part.name}.splice(this.${part.name}.indexOf(oldUnit as ${Names.classifier(part.type)}), 1);`
: `this.${part.name} = null;`
}
return true;
}`,
AST.changeNamed("removeUnit", () => {
${
part.isList
? `this.${part.name}.splice(this.${part.name}.indexOf(oldUnit as ${Names.classifier(part.type)}), 1);`
: `this.${part.name} = null;`
}
})
return true;
}`,
)
.join("\n")}
}
Expand All @@ -159,11 +166,13 @@ export class ModelTemplate {
(part) =>
`case "${Names.classifier(part.type)}": {
const unit: ${Names.classifier(part.type)} = ${Names.classifier(part.type)}.create({});
${
part.isList
? `this.${part.name}.push(unit as ${Names.classifier(part.type)});`
: `this.${part.name} = unit as ${Names.classifier(part.type)}`
}
AST.changeNamed("newUnit", () => {
${
part.isList
? `this.${part.name}.push(unit as ${Names.classifier(part.type)});`
: `this.${part.name} = unit as ${Names.classifier(part.type)}`
}
})
return unit;
}`,
)
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/Calculator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-calculator",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/DocuProject/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-docuproject",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/Education/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-education",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/Example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-example",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Attribute {
}
Entity {
[
entity ${name} [? base ${baseEntity}] {
${abstract} entity ${name} [? base ${baseEntity}] {
${attributes }
${methods vertical }
}
Expand Down
1 change: 1 addition & 0 deletions packages/samples/Example/src/defs/LanguageDefinition.ast
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Type base BaseType {
}

concept Entity implements Type {
abstract: boolean;
attributes: Attribute[];
methods: Method[];
reference baseEntity?: Entity;
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/ExternalTester/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-external-tester",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/MpsExpressions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-mps-expressions",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/Octopus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-octopus",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/PiLanguage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-pi-language",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/samples/RulesLanguage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freon4dsl/samples-rules-language",
"version": "0.7.0-beta4",
"version": "0.7.0-beta5",
"license": "MIT",
"type": "module",
"main": "dist/index.js",
Expand All @@ -18,7 +18,7 @@
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
},
"dependencies": {
"@freon4dsl/core": "0.7.0-beta4",
"@freon4dsl/core": "0.7.0-beta5",
"@types/node": "^20.14.1",
"kotlin": "^1.5.21",
"mobx": "^6.12.3",
Expand Down
Loading

0 comments on commit fcb88b5

Please sign in to comment.