summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts/form.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-01-08 20:30:01 +0900
committerGitHub <noreply@github.com>2022-01-08 20:30:01 +0900
commit0bbde336b3636f4135de54c0ed75c7aa208534fe (patch)
tree45bb6a5c1e5397b3de351068d0eb1eeb6e3ec6c9 /packages/client/src/scripts/form.ts
parentbye room (diff)
downloadsharkey-0bbde336b3636f4135de54c0ed75c7aa208534fe.tar.gz
sharkey-0bbde336b3636f4135de54c0ed75c7aa208534fe.tar.bz2
sharkey-0bbde336b3636f4135de54c0ed75c7aa208534fe.zip
refactor: Widgetのcomposition api移行 (#8125)
* wip * wip * wip * wip * wip * wip * fix
Diffstat (limited to 'packages/client/src/scripts/form.ts')
-rw-r--r--packages/client/src/scripts/form.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/packages/client/src/scripts/form.ts b/packages/client/src/scripts/form.ts
index 7bf6cec452..7f321cc0ae 100644
--- a/packages/client/src/scripts/form.ts
+++ b/packages/client/src/scripts/form.ts
@@ -23,9 +23,37 @@ export type FormItem = {
enum: string[];
} | {
label?: string;
+ type: 'radio';
+ default: unknown | null;
+ hidden?: boolean;
+ options: {
+ label: string;
+ value: unknown;
+ }[];
+} | {
+ label?: string;
+ type: 'object';
+ default: Record<string, unknown> | null;
+ hidden: true;
+} | {
+ label?: string;
type: 'array';
default: unknown[] | null;
- hidden?: boolean;
+ hidden: true;
};
export type Form = Record<string, FormItem>;
+
+type GetItemType<Item extends FormItem> =
+ Item['type'] extends 'string' ? string :
+ Item['type'] extends 'number' ? number :
+ Item['type'] extends 'boolean' ? boolean :
+ Item['type'] extends 'radio' ? unknown :
+ Item['type'] extends 'enum' ? string :
+ Item['type'] extends 'array' ? unknown[] :
+ Item['type'] extends 'object' ? Record<string, unknown>
+ : never;
+
+export type GetFormResultType<F extends Form> = {
+ [P in keyof F]: GetItemType<F[P]>;
+};