-
Notifications
You must be signed in to change notification settings - Fork 51
/
types.js
70 lines (60 loc) · 1.51 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// @flow
/**
* Copyright (c) Garuda Labs, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import type {
Element,
HvComponentOnUpdate,
HvComponentOptions,
PressTrigger,
StyleSheets,
} from 'hyperview/src/types';
import { TRIGGERS } from 'hyperview/src/types';
export type Props = {|
element: Element,
onUpdate: HvComponentOnUpdate,
options: HvComponentOptions,
stylesheets: StyleSheets,
|};
export type State = {|
pressed: boolean,
refreshing: boolean,
|};
export const ATTRIBUTES = {
ACTION: 'action',
DELAY: 'delay',
HIDE_DURING_LOAD: 'hide-during-load',
HREF: 'href',
HREF_STYLE: 'href-style',
ONCE: 'once',
SHOW_DURING_LOAD: 'show-during-load',
TARGET: 'target',
TRIGGER: 'trigger',
VERB: 'verb',
};
export type Attribute = $Values<typeof ATTRIBUTES>;
export type PressHandlers = {
onLongPress?: () => void,
onPressIn?: () => void,
onPressOut?: () => void,
onPress?: () => void,
};
export const PRESS_PROP_NAMES = {
ON_LONG_PRESS: 'onLongPress',
ON_PRESS_IN: 'onPressIn',
ON_PRESS_OUT: 'onPressOut',
ON_PRESS: 'onPress',
};
export type PressPropName = $Values<typeof PRESS_PROP_NAMES>;
export const PRESS_TRIGGERS_PROP_NAMES: {
[PressTrigger]: PressPropName,
} = {
[TRIGGERS.LONG_PRESS]: PRESS_PROP_NAMES.ON_LONG_PRESS,
[TRIGGERS.PRESS_IN]: PRESS_PROP_NAMES.ON_PRESS_IN,
[TRIGGERS.PRESS_OUT]: PRESS_PROP_NAMES.ON_PRESS_OUT,
[TRIGGERS.PRESS]: PRESS_PROP_NAMES.ON_PRESS,
};