diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue
index bc1e25957b..ec214f0396 100644
--- a/packages/frontend/src/components/MkAsUi.vue
+++ b/packages/frontend/src/components/MkAsUi.vue
@@ -33,6 +33,12 @@
{{ c.text }}
+
+ {{ c.title }}
+
+
+
+
@@ -50,6 +56,7 @@ import MkSwitch from '@/components/form/switch.vue';
import MkTextarea from '@/components/form/textarea.vue';
import MkSelect from '@/components/form/select.vue';
import { AsUiComponent } from '@/scripts/aiscript/ui';
+import FormFolder from '@/components/form/folder.vue';
const props = withDefaults(defineProps<{
component: AsUiComponent;
diff --git a/packages/frontend/src/scripts/aiscript/ui.ts b/packages/frontend/src/scripts/aiscript/ui.ts
index f4c89b8276..6e0e312116 100644
--- a/packages/frontend/src/scripts/aiscript/ui.ts
+++ b/packages/frontend/src/scripts/aiscript/ui.ts
@@ -100,6 +100,13 @@ export type AsUiSelect = AsUiComponentBase & {
caption?: string;
};
+export type AsUiFolder = AsUiComponentBase & {
+ type: 'folder';
+ children?: AsUiComponent['id'][];
+ title?: string;
+ opened?: boolean;
+};
+
export type AsUiPostFormButton = AsUiComponentBase & {
type: 'postFormButton';
text?: string;
@@ -110,7 +117,7 @@ export type AsUiPostFormButton = AsUiComponentBase & {
};
};
-export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiPostFormButton;
+export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton;
export function patch(id: string, def: values.Value, call: (fn: values.VFn, args: values.Value[]) => Promise) {
// TODO
@@ -389,6 +396,26 @@ function getSelectOptions(def: values.Value | undefined, call: (fn: values.VFn,
};
}
+function getFolderOptions(def: values.Value | undefined): Omit {
+ utils.assertObject(def);
+
+ const children = def.value.get('children');
+ if (children) utils.assertArray(children);
+ const title = def.value.get('title');
+ if (title) utils.assertString(title);
+ const opened = def.value.get('opened');
+ if (opened) utils.assertBoolean(opened);
+
+ return {
+ children: children ? children.value.map(v => {
+ utils.assertObject(v);
+ return v.value.get('id').value;
+ }) : [],
+ title: title?.value ?? '',
+ opened: opened?.value ?? true,
+ };
+}
+
function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: values.VFn, args: values.Value[]) => Promise): Omit {
utils.assertObject(def);
@@ -519,6 +546,10 @@ export function registerAsUiLib(components: Ref[], done: (root: R
return createComponentInstance('select', def, id, getSelectOptions, opts.call);
}),
+ 'Ui:C:folder': values.FN_NATIVE(async ([def, id], opts) => {
+ return createComponentInstance('folder', def, id, getFolderOptions, opts.call);
+ }),
+
'Ui:C:postFormButton': values.FN_NATIVE(async ([def, id], opts) => {
return createComponentInstance('postFormButton', def, id, getPostFormButtonOptions, opts.call);
}),