-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
44 lines (33 loc) · 1.72 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createNode, createToken, TokenVNode } from "@opennetwork/vnode";
export interface ViewOptions {
}
const ViewSymbol = Symbol("View");
export type ViewNode = TokenVNode<typeof ViewSymbol, ViewOptions>;
export const View: ViewNode = createToken(ViewSymbol);
export interface InputOptions<V> extends ViewOptions {
value?: V;
onValue?(value: V): void;
}
export type TextInputOptions = InputOptions<string>;
const TextInputSymbol = Symbol("Text Input");
export type TextInputNode = TokenVNode<typeof TextInputSymbol, TextInputOptions>;
export const TextInput: TextInputNode = createToken(TextInputSymbol);
export type NumberInputOptions = InputOptions<number>;
const NumberInputSymbol = Symbol("Number Input");
export type NumberInputNode = TokenVNode<typeof NumberInputSymbol, NumberInputOptions>;
export const NumberInput: NumberInputNode = createToken(NumberInputSymbol);
export type BooleanInputOptions = InputOptions<boolean>;
const BooleanInputSymbol = Symbol("Boolean Input");
export type BooleanInputNode = TokenVNode<typeof BooleanInputSymbol, BooleanInputOptions>;
export const BooleanInput: BooleanInputNode = createToken(BooleanInputSymbol);
export type DateInputOptions = InputOptions<Date>;
const DateInputSymbol = Symbol("Date Input");
export type DateInputNode = TokenVNode<typeof DateInputSymbol, DateInputOptions>;
export const DateInput = createToken(DateInputSymbol);
export interface ActionOptions<A = unknown> extends ViewOptions {
type?: "button" | "submit" | string;
onAction?(action: unknown extends A ? never : A): void;
}
const ActionSymbol = Symbol("Action");
export type ActionNode<A = void> = TokenVNode<typeof ActionSymbol, ActionOptions<A>>;
export const Action: ActionNode = createToken(ActionSymbol);