From fdbde37a5e4fed01482b23cc0bf95a8731105bd2 Mon Sep 17 00:00:00 2001 From: takejohn Date: Mon, 13 Jan 2025 16:35:30 +0900 Subject: [PATCH] =?UTF-8?q?=E5=9E=8B=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/aiscript/ui.ts | 20 +++++++++---------- .../frontend/test/components/MkAsUi.test.ts | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/frontend/src/scripts/aiscript/ui.ts b/packages/frontend/src/scripts/aiscript/ui.ts index ca92b27ff5..9d2d0ac501 100644 --- a/packages/frontend/src/scripts/aiscript/ui.ts +++ b/packages/frontend/src/scripts/aiscript/ui.ts @@ -59,13 +59,13 @@ export type AsUiMfm = AsUiComponentBase & { bold?: boolean; color?: string; font?: Font; - onClickEv?: (evId: string) => Promise; + onClickEv?: (evId: string) => void | Promise; }; export type AsUiButton = AsUiComponentBase & { type: 'button'; text?: string; - onClick?: () => Promise; + onClick?: () => void | Promise; primary?: boolean; rounded?: boolean; disabled?: boolean; @@ -73,12 +73,12 @@ export type AsUiButton = AsUiComponentBase & { export type AsUiButtons = AsUiComponentBase & { type: 'buttons'; - buttons?: AsUiButton[]; + buttons?: Options[]; }; export type AsUiSwitch = AsUiComponentBase & { type: 'switch'; - onChange?: (v: boolean) => Promise; + onChange?: (v: boolean) => void | Promise; default?: boolean; label?: string; caption?: string; @@ -86,7 +86,7 @@ export type AsUiSwitch = AsUiComponentBase & { export type AsUiTextarea = AsUiComponentBase & { type: 'textarea'; - onInput?: (v: string) => Promise; + onInput?: (v: string) => void | Promise; default?: string; label?: string; caption?: string; @@ -94,7 +94,7 @@ export type AsUiTextarea = AsUiComponentBase & { export type AsUiTextInput = AsUiComponentBase & { type: 'textInput'; - onInput?: (v: string) => Promise; + onInput?: (v: string) => void | Promise; default?: string; label?: string; caption?: string; @@ -102,7 +102,7 @@ export type AsUiTextInput = AsUiComponentBase & { export type AsUiNumberInput = AsUiComponentBase & { type: 'numberInput'; - onInput?: (v: number) => Promise; + onInput?: (v: number) => void | Promise; default?: number; label?: string; caption?: string; @@ -114,7 +114,7 @@ export type AsUiSelect = AsUiComponentBase & { text: string; value: string; }[]; - onChange?: (v: string) => Promise; + onChange?: (v: string) => void | Promise; default?: string; label?: string; caption?: string; @@ -149,9 +149,7 @@ export type AsUiPostForm = AsUiComponentBase & { export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton | AsUiPostForm; -type Options = T extends AsUiButtons - ? Omit & { 'buttons'?: Options[] } - : Omit; +type Options = Omit; export function patch(id: string, def: values.Value, call: (fn: values.VFn, args: values.Value[]) => Promise) { // TODO diff --git a/packages/frontend/test/components/MkAsUi.test.ts b/packages/frontend/test/components/MkAsUi.test.ts index 07f74ce864..2a23b9abc0 100644 --- a/packages/frontend/test/components/MkAsUi.test.ts +++ b/packages/frontend/test/components/MkAsUi.test.ts @@ -76,12 +76,10 @@ describe('MkAsUi', () => { buttons: [ { text: 'left', - id: 'test', onClick: vi.fn(), }, { text: 'right', - id: 'test', onClick: vi.fn(), }, ],