@codeleap/mobile 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ActivityIndicator.d.ts +13 -0
- package/dist/components/ActivityIndicator.js +49 -0
- package/dist/components/ActivityIndicator.js.map +1 -0
- package/dist/components/Button.d.ts +116 -0
- package/dist/components/Button.js +57 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +14 -0
- package/dist/components/Checkbox/index.js +75 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Checkbox/styles.d.ts +48 -0
- package/dist/components/Checkbox/styles.js +49 -0
- package/dist/components/Checkbox/styles.js.map +1 -0
- package/dist/components/Checkbox.d.ts +12 -0
- package/dist/components/Checkbox.js +61 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Drawer.d.ts +23 -0
- package/dist/components/Drawer.js +78 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/FileInput.d.ts +2 -0
- package/dist/components/FileInput.js +28 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/Icon.d.ts +13 -0
- package/dist/components/Icon.js +47 -0
- package/dist/components/Icon.js.map +1 -0
- package/dist/components/Image.d.ts +16 -0
- package/dist/components/Image.js +48 -0
- package/dist/components/Image.js.map +1 -0
- package/dist/components/Navigation.d.ts +30 -0
- package/dist/components/Navigation.js +126 -0
- package/dist/components/Navigation.js.map +1 -0
- package/dist/components/RadioInput/index.d.ts +25 -0
- package/dist/components/RadioInput/index.js +75 -0
- package/dist/components/RadioInput/index.js.map +1 -0
- package/dist/components/RadioInput/styles.d.ts +50 -0
- package/dist/components/RadioInput/styles.js +45 -0
- package/dist/components/RadioInput/styles.js.map +1 -0
- package/dist/components/Scroll.d.ts +104 -0
- package/dist/components/Scroll.js +73 -0
- package/dist/components/Scroll.js.map +1 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/index.js +31 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Slider.d.ts +20 -0
- package/dist/components/Slider.js +130 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Switch.d.ts +13 -0
- package/dist/components/Switch.js +73 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Text.d.ts +12 -0
- package/dist/components/Text.js +49 -0
- package/dist/components/Text.js.map +1 -0
- package/dist/components/TextInput.d.ts +146 -0
- package/dist/components/TextInput.js +147 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/Touchable.d.ts +19 -0
- package/dist/components/Touchable.js +62 -0
- package/dist/components/Touchable.js.map +1 -0
- package/dist/components/View.d.ts +190 -0
- package/dist/components/View.js +53 -0
- package/dist/components/View.js.map +1 -0
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +29 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/fastImage.d.ts +1 -0
- package/dist/modules/fastImage.js +10 -0
- package/dist/modules/fastImage.js.map +1 -0
- package/dist/types/utility.d.ts +2 -0
- package/dist/types/utility.js +3 -0
- package/dist/types/utility.js.map +1 -0
- package/dist/utils/OSAlert.d.ts +31 -0
- package/dist/utils/OSAlert.js +89 -0
- package/dist/utils/OSAlert.js.map +1 -0
- package/dist/utils/styles.d.ts +1 -0
- package/dist/utils/styles.js +13 -0
- package/dist/utils/styles.js.map +1 -0
- package/package.json +32 -0
- package/src/components/ActivityIndicator.tsx +37 -0
- package/src/components/Button.tsx +61 -0
- package/src/components/Checkbox/index.tsx +68 -0
- package/src/components/Checkbox/styles.ts +63 -0
- package/src/components/FileInput.tsx +6 -0
- package/src/components/Icon.tsx +35 -0
- package/src/components/Image.tsx +43 -0
- package/src/components/Navigation.tsx +125 -0
- package/src/components/RadioInput/index.tsx +76 -0
- package/src/components/RadioInput/styles.ts +62 -0
- package/src/components/Scroll.tsx +87 -0
- package/src/components/Select/index.tsx +8 -0
- package/src/components/Slider.tsx +198 -0
- package/src/components/Switch.tsx +73 -0
- package/src/components/Text.tsx +31 -0
- package/src/components/TextInput.tsx +206 -0
- package/src/components/Touchable.tsx +54 -0
- package/src/components/View.tsx +53 -0
- package/src/components/index.ts +16 -0
- package/src/index.ts +2 -0
- package/src/modules/fastImage.ts +2 -0
- package/src/types/utility.ts +3 -0
- package/src/utils/OSAlert.ts +122 -0
- package/src/utils/styles.ts +17 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* eslint no-restricted-imports: 'off' */
|
|
2
|
+
import { Alert, AlertButton } from 'react-native'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Alert.{function} receives three parameters, the last one being an object:
|
|
7
|
+
*
|
|
8
|
+
* @param {string} title text to appear in title
|
|
9
|
+
* @param {string} body text to appear in body
|
|
10
|
+
* @param {object} options array of buttons and callbacks
|
|
11
|
+
*
|
|
12
|
+
* options properties
|
|
13
|
+
* @property {string} name object description
|
|
14
|
+
* @property {function} run callback function to run on press
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
type NativeAlertArgs = Parameters<typeof Alert.alert>
|
|
18
|
+
|
|
19
|
+
type OSAlertArgs = {
|
|
20
|
+
title:NativeAlertArgs['0'],
|
|
21
|
+
body?: NativeAlertArgs['1']
|
|
22
|
+
options?: NativeAlertArgs['2']
|
|
23
|
+
}
|
|
24
|
+
type AlertEvent = AlertButton['onPress']
|
|
25
|
+
|
|
26
|
+
type NamedEvents<E extends string> = Partial<Record<E, AlertEvent>>
|
|
27
|
+
|
|
28
|
+
function ask({ title, body, options = null }:OSAlertArgs) {
|
|
29
|
+
|
|
30
|
+
if (!title) {
|
|
31
|
+
title = 'Quick quetion'
|
|
32
|
+
}
|
|
33
|
+
OSAlert({
|
|
34
|
+
title,
|
|
35
|
+
body,
|
|
36
|
+
options,
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function warn({ title, body, onAccept, onReject }:OSAlertArgs & NamedEvents<'onReject'|'onAccept'>) {
|
|
41
|
+
|
|
42
|
+
if (!title) {
|
|
43
|
+
title = 'Hang on'
|
|
44
|
+
}
|
|
45
|
+
if (!body) {
|
|
46
|
+
body = 'Are you sure?'
|
|
47
|
+
}
|
|
48
|
+
if (!onReject) {
|
|
49
|
+
onReject = () => null
|
|
50
|
+
}
|
|
51
|
+
OSAlert({
|
|
52
|
+
title,
|
|
53
|
+
body,
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
text: 'Cancel',
|
|
57
|
+
onPress:onReject,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
text: 'OK',
|
|
61
|
+
style: 'destructive',
|
|
62
|
+
onPress: onAccept,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function info({ title, body, onDismiss = () => null }:OSAlertArgs & NamedEvents<'onDismiss'>) {
|
|
69
|
+
|
|
70
|
+
if (!title) {
|
|
71
|
+
title = 'FYI'
|
|
72
|
+
}
|
|
73
|
+
OSAlert({
|
|
74
|
+
title,
|
|
75
|
+
body,
|
|
76
|
+
options: [
|
|
77
|
+
{
|
|
78
|
+
text: 'OK',
|
|
79
|
+
onPress:onDismiss,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function OSError({ title, body, onDismiss = () => null }:OSAlertArgs & NamedEvents<'onDismiss'>) {
|
|
86
|
+
if (!title) {
|
|
87
|
+
title = 'Whoops!'
|
|
88
|
+
}
|
|
89
|
+
if (!body) {
|
|
90
|
+
body = 'Something went wrong'
|
|
91
|
+
}
|
|
92
|
+
OSAlert({
|
|
93
|
+
title,
|
|
94
|
+
body,
|
|
95
|
+
options: [
|
|
96
|
+
{
|
|
97
|
+
text: 'OK',
|
|
98
|
+
onPress: () => onDismiss(),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function OSAlert(params:OSAlertArgs) {
|
|
105
|
+
Alert.alert(
|
|
106
|
+
params.title,
|
|
107
|
+
params.body,
|
|
108
|
+
params.options,
|
|
109
|
+
{
|
|
110
|
+
cancelable: false,
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
export default {
|
|
117
|
+
ask,
|
|
118
|
+
warn,
|
|
119
|
+
info,
|
|
120
|
+
error: OSError,
|
|
121
|
+
}
|
|
122
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useStyle } from "@codeleap/common";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
export function useLogStyles(){
|
|
5
|
+
|
|
6
|
+
const {logger} = useStyle()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
return (name,styles) => {
|
|
10
|
+
logger.debug.blue(
|
|
11
|
+
name,
|
|
12
|
+
JSON.stringify(StyleSheet.flatten(styles), null, 2),
|
|
13
|
+
'Component Styles'
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|