This repository was archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.js
53 lines (49 loc) · 1.72 KB
/
types.js
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
43
44
45
46
47
48
49
50
51
52
53
// Placeholder export to make types importable.
export function noop() { }
///////////////////////////////
// Main @composi/runtime types:
///////////////////////////////
/**
* @typedef {import('@composi/runtime').Message} Message
* @typedef {import('@composi/runtime').Send} Send
* @typedef {import('@composi/runtime').Program} Program
* @typedef {() => State} GetState
*/
/////////////////
// Project types:
/////////////////
/**
* @typedef {Object} Item
* @prop {number} key
* @prop {string} value
* @prop {boolean} [deletable]
*/
/**
* @typedef {Object} State
* @prop {number} newKey
* @prop {string} inputValue
* @prop {Item[]} items
*/
/**
* @typedef {Object} ActionMethods
* @prop {() => State} AddItem - Add new item to state items.
* @prop {(key: number) => State} DeleteItem - Delete item from state items based on key.
* @prop {(key: number) => State} MakeDeletable - Mark a list item as deletable. This triggers an animation before deletion. When done it will send the message "DeleteItem"
* @prop {(data: State) => State} SaveLocally - Save state in IndexedDB.
* @prop {(value: string) => State} UpdateInputValue - Update this value as the user types.
* @prop {(data: State) => State} UseFetchedData - Get data either from IndexedDB or from JSON file.
*/
/**
* @typedef {Object} MessageUnion
* @prop {(msg: Message, Object: ActionMethods) => State} match
* @prop {() => Message} AddItem
* @prop {(key: number) => Message} DeleteItem
* @prop {(key: number) => Message} MakeDeletable
* @prop {(data: State) => Message} SaveLocally
* @prop {(value: string) => Message} UpdateInputValue
* @prop {(data: State) => Message} UseFetchedData
*/
/**
* @typedef {Object} InputRef
* @prop {HTMLInputElement} current
*/