型の修正

This commit is contained in:
takejohn 2025-01-13 16:35:30 +09:00
parent dd67a1e55c
commit fdbde37a5e
No known key found for this signature in database
GPG Key ID: F1A5A9BF81BB4892
2 changed files with 9 additions and 13 deletions

View File

@ -59,13 +59,13 @@ export type AsUiMfm = AsUiComponentBase & {
bold?: boolean; bold?: boolean;
color?: string; color?: string;
font?: Font; font?: Font;
onClickEv?: (evId: string) => Promise<void>; onClickEv?: (evId: string) => void | Promise<void>;
}; };
export type AsUiButton = AsUiComponentBase & { export type AsUiButton = AsUiComponentBase & {
type: 'button'; type: 'button';
text?: string; text?: string;
onClick?: () => Promise<void>; onClick?: () => void | Promise<void>;
primary?: boolean; primary?: boolean;
rounded?: boolean; rounded?: boolean;
disabled?: boolean; disabled?: boolean;
@ -73,12 +73,12 @@ export type AsUiButton = AsUiComponentBase & {
export type AsUiButtons = AsUiComponentBase & { export type AsUiButtons = AsUiComponentBase & {
type: 'buttons'; type: 'buttons';
buttons?: AsUiButton[]; buttons?: Options<AsUiButton>[];
}; };
export type AsUiSwitch = AsUiComponentBase & { export type AsUiSwitch = AsUiComponentBase & {
type: 'switch'; type: 'switch';
onChange?: (v: boolean) => Promise<void>; onChange?: (v: boolean) => void | Promise<void>;
default?: boolean; default?: boolean;
label?: string; label?: string;
caption?: string; caption?: string;
@ -86,7 +86,7 @@ export type AsUiSwitch = AsUiComponentBase & {
export type AsUiTextarea = AsUiComponentBase & { export type AsUiTextarea = AsUiComponentBase & {
type: 'textarea'; type: 'textarea';
onInput?: (v: string) => Promise<void>; onInput?: (v: string) => void | Promise<void>;
default?: string; default?: string;
label?: string; label?: string;
caption?: string; caption?: string;
@ -94,7 +94,7 @@ export type AsUiTextarea = AsUiComponentBase & {
export type AsUiTextInput = AsUiComponentBase & { export type AsUiTextInput = AsUiComponentBase & {
type: 'textInput'; type: 'textInput';
onInput?: (v: string) => Promise<void>; onInput?: (v: string) => void | Promise<void>;
default?: string; default?: string;
label?: string; label?: string;
caption?: string; caption?: string;
@ -102,7 +102,7 @@ export type AsUiTextInput = AsUiComponentBase & {
export type AsUiNumberInput = AsUiComponentBase & { export type AsUiNumberInput = AsUiComponentBase & {
type: 'numberInput'; type: 'numberInput';
onInput?: (v: number) => Promise<void>; onInput?: (v: number) => void | Promise<void>;
default?: number; default?: number;
label?: string; label?: string;
caption?: string; caption?: string;
@ -114,7 +114,7 @@ export type AsUiSelect = AsUiComponentBase & {
text: string; text: string;
value: string; value: string;
}[]; }[];
onChange?: (v: string) => Promise<void>; onChange?: (v: string) => void | Promise<void>;
default?: string; default?: string;
label?: string; label?: string;
caption?: 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; export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton | AsUiPostForm;
type Options<T extends AsUiComponent> = T extends AsUiButtons type Options<T extends AsUiComponent> = Omit<T, 'id' | 'type'>;
? Omit<T, 'id' | 'type' | 'buttons'> & { 'buttons'?: Options<AsUiButton>[] }
: Omit<T, 'id' | 'type'>;
export function patch(id: string, def: values.Value, call: (fn: values.VFn, args: values.Value[]) => Promise<values.Value>) { export function patch(id: string, def: values.Value, call: (fn: values.VFn, args: values.Value[]) => Promise<values.Value>) {
// TODO // TODO

View File

@ -76,12 +76,10 @@ describe('MkAsUi', () => {
buttons: [ buttons: [
{ {
text: 'left', text: 'left',
id: 'test',
onClick: vi.fn(), onClick: vi.fn(),
}, },
{ {
text: 'right', text: 'right',
id: 'test',
onClick: vi.fn(), onClick: vi.fn(),
}, },
], ],