mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-20 21:49:16 +00:00

* refactor(api): rename ui subpackage name * refactor(api): update import paths for template UI schemas * chore: update dependencies and bump package versions * chore(api): bump package version to 0.1.1 * refactor(api): rename IUiIframe to IUiCustom and related types * format
98 lines
2.0 KiB
TypeScript
98 lines
2.0 KiB
TypeScript
import {
|
|
Action,
|
|
app,
|
|
expose,
|
|
Form,
|
|
fs,
|
|
Icon,
|
|
IconEnum,
|
|
List,
|
|
Markdown,
|
|
path,
|
|
shell,
|
|
TemplateUiCommand,
|
|
toast,
|
|
ui
|
|
} from "@kksh/api/ui/template"
|
|
|
|
class ExtensionTemplate extends TemplateUiCommand {
|
|
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",
|
|
showFormDataDebug: true,
|
|
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())
|