Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Interface): Add textarea interface #356

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/nodes/pre-defined-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ This interface displays a text field that the user can type into.
import { TextInputInterface } from "baklavajs";
new TextInputInterface("Name", "Edit me");
```

## TextareaInputInterface

This interface displays a textarea field that the user can type into.

```js
import { TextareaInputInterface } from "baklavajs";
new TextareaInputInterface("Name", "Edit me");
```
2 changes: 2 additions & 0 deletions packages/renderer-vue/playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import SidebarNode from "./SidebarNode";
import DynamicNode from "./DynamicNode";
import UpdateTestNode from "./UpdateTestNode";
import MultiInputNode from "./MultiInputNode";
import { DialogNode } from "./DialogNode";

import ReactiveOutputTestNode from "./ReactiveOutputTestNode";

Expand Down Expand Up @@ -78,6 +79,7 @@ nodeInterfaceTypes.addTypes(stringType, numberType, booleanType);
editor.registerNodeType(TestNode, { category: "Tests" });
editor.registerNodeType(OutputNode, { category: "Outputs" });
editor.registerNodeType(BuilderTestNode, { category: "Tests" });
editor.registerNodeType(DialogNode);
editor.registerNodeType(MathNode);
editor.registerNodeType(AdvancedNode);
editor.registerNodeType(CommentNode, { title: "Comment" });
Expand Down
18 changes: 18 additions & 0 deletions packages/renderer-vue/playground/DialogNode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NodeInterface, defineNode } from "@baklavajs/core";
import { TextareaInputInterface } from "../src/nodeinterfaces/textareainput/TextareaInputInterface";
import { TextInputInterface } from "../src";

export const DialogNode = defineNode({
type: "dialog",
title: "Dialogue",
onCreate() {
this.width = 400;
},
inputs: {
input: () => new TextInputInterface("Title", ""),
input2: () => new TextareaInputInterface("Description", ""),
},
outputs: {
result: () => new NodeInterface("", ""),
},
});
1 change: 1 addition & 0 deletions packages/renderer-vue/src/nodeinterfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./select/SelectInterface";
export * from "./slider/SliderInterface";
export * from "./text/TextInterface";
export * from "./textinput/TextInputInterface";
export * from "./textareainput/TextareaInputInterface";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { type ComponentOptions, markRaw } from "vue";
import { NodeInterface } from "@baklavajs/core";
import TextareaInputInterfaceComponent from "./TextareaInputInterface.vue";

export class TextareaInputInterface extends NodeInterface<string> {
component = markRaw(TextareaInputInterfaceComponent) as ComponentOptions;
}

export { TextareaInputInterfaceComponent };
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<div>
<textarea v-model="v" rows="5" class="baklava-input" :placeholder="intf.name" :title="intf.name" />
</div>
</template>

<script lang="ts">
import { computed, defineComponent } from "vue";
import type { TextareaInputInterface } from "./TextareaInputInterface";

export default defineComponent({
props: {
intf: {
type: Object as () => TextareaInputInterface,
required: true,
},
modelValue: {
type: String,
required: true,
},
},
emits: ["update:modelValue"],
setup(props, { emit }) {
const v = computed({
get: () => props.modelValue,
set: (v) => {
emit("update:modelValue", v);
},
});
return { v };
},
});
</script>