Huakun Shen ad30a8c3bb
fix: duplicate api calls from comlink (#27)
* refactor: replace comlink with kkrpc

* fix: import path in api pkg and btn styling in ui iframe page

* fix: fixed fetch API from kkRPC migrate

* refactor: replace comlink-stdio with kkrpc

* update deno lock

* bump @kksh/api

* update API version

* publish api pkg again to fix kkrpc version

* update pnpm lock

* dep: fix dependency problems

* dep: update deno.lock

* chore: remove 2 submodules

they were added only for integration development

* update pnpm lock

* fix: test template path

* format: with prettier

* downgrade next version

* ci: try to fix next build on windows

* try to fix CI

* Revert "try to fix CI"

This reverts commit b9c63c392f50f1d2d3ceec406e49b1af2348c740.

* upgrade tauri-api-adapter

* try to fix next

* remove templates from pnpm workspace

* update CI test

* publish @kksh/api with upgraded tauri-api-adapter to fix nextjs template
2024-11-19 05:57:31 -05:00

97 lines
1.9 KiB
TypeScript

import {
Action,
app,
expose,
Form,
fs,
Icon,
IconEnum,
List,
Markdown,
path,
shell,
toast,
ui,
WorkerExtension
} from "@kksh/api/ui/worker"
class ExtensionTemplate extends WorkerExtension {
async onFormSubmit(value: Record<string, any>): Promise<void> {
console.log("Form submitted", value)
toast.success(`Form submitted: ${JSON.stringify(value)}`)
}
async load() {
console.log("form-view load")
const markdown = new Markdown(`# Hello World
<img src="https://github.com/huakunshen.png" />`)
// markdown.toModel
return ui.render(markdown)
const form = new Form.Form({
title: "Form 1",
key: "form1",
submitBtnText: "Download",
fields: [
new Form.DateField({
key: "birthday",
label: "Date of Birth",
hideLabel: false,
description: "Enter your date of birth"
}),
new Form.NumberField({
key: "age",
label: "Age",
default: 18,
placeholder: "Enter your age",
optional: true,
description: "Enter your age"
}),
new Form.InputField({
key: "name",
label: "Name",
default: "Huakun"
}),
new Form.InputField({
key: "name2",
label: "Name 2"
}),
new Form.BooleanField({
key: "isActive",
label: "Is Active",
description: "Is the user active?"
}),
new Form.SelectField({
key: "gender",
label: "Gender",
options: ["Male", "Female", "Other"],
description: "Select your gender"
})
]
})
console.log(form)
console.log(form.toModel())
return ui.render(form)
}
async onActionSelected(actionValue: string): Promise<void> {
switch (actionValue) {
case "open":
break
default:
break
}
}
onSearchTermChange(term: string): Promise<void> {
console.log("Search term changed to:", term)
return Promise.resolve()
}
onListItemSelected(value: string): Promise<void> {
console.log("Item selected:", value)
return Promise.resolve()
}
}
expose(new ExtensionTemplate())