@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.
Files changed (103) hide show
  1. package/dist/components/ActivityIndicator.d.ts +13 -0
  2. package/dist/components/ActivityIndicator.js +49 -0
  3. package/dist/components/ActivityIndicator.js.map +1 -0
  4. package/dist/components/Button.d.ts +116 -0
  5. package/dist/components/Button.js +57 -0
  6. package/dist/components/Button.js.map +1 -0
  7. package/dist/components/Checkbox/index.d.ts +14 -0
  8. package/dist/components/Checkbox/index.js +75 -0
  9. package/dist/components/Checkbox/index.js.map +1 -0
  10. package/dist/components/Checkbox/styles.d.ts +48 -0
  11. package/dist/components/Checkbox/styles.js +49 -0
  12. package/dist/components/Checkbox/styles.js.map +1 -0
  13. package/dist/components/Checkbox.d.ts +12 -0
  14. package/dist/components/Checkbox.js +61 -0
  15. package/dist/components/Checkbox.js.map +1 -0
  16. package/dist/components/Drawer.d.ts +23 -0
  17. package/dist/components/Drawer.js +78 -0
  18. package/dist/components/Drawer.js.map +1 -0
  19. package/dist/components/FileInput.d.ts +2 -0
  20. package/dist/components/FileInput.js +28 -0
  21. package/dist/components/FileInput.js.map +1 -0
  22. package/dist/components/Icon.d.ts +13 -0
  23. package/dist/components/Icon.js +47 -0
  24. package/dist/components/Icon.js.map +1 -0
  25. package/dist/components/Image.d.ts +16 -0
  26. package/dist/components/Image.js +48 -0
  27. package/dist/components/Image.js.map +1 -0
  28. package/dist/components/Navigation.d.ts +30 -0
  29. package/dist/components/Navigation.js +126 -0
  30. package/dist/components/Navigation.js.map +1 -0
  31. package/dist/components/RadioInput/index.d.ts +25 -0
  32. package/dist/components/RadioInput/index.js +75 -0
  33. package/dist/components/RadioInput/index.js.map +1 -0
  34. package/dist/components/RadioInput/styles.d.ts +50 -0
  35. package/dist/components/RadioInput/styles.js +45 -0
  36. package/dist/components/RadioInput/styles.js.map +1 -0
  37. package/dist/components/Scroll.d.ts +104 -0
  38. package/dist/components/Scroll.js +73 -0
  39. package/dist/components/Scroll.js.map +1 -0
  40. package/dist/components/Select/index.d.ts +2 -0
  41. package/dist/components/Select/index.js +31 -0
  42. package/dist/components/Select/index.js.map +1 -0
  43. package/dist/components/Slider.d.ts +20 -0
  44. package/dist/components/Slider.js +130 -0
  45. package/dist/components/Slider.js.map +1 -0
  46. package/dist/components/Switch.d.ts +13 -0
  47. package/dist/components/Switch.js +73 -0
  48. package/dist/components/Switch.js.map +1 -0
  49. package/dist/components/Text.d.ts +12 -0
  50. package/dist/components/Text.js +49 -0
  51. package/dist/components/Text.js.map +1 -0
  52. package/dist/components/TextInput.d.ts +146 -0
  53. package/dist/components/TextInput.js +147 -0
  54. package/dist/components/TextInput.js.map +1 -0
  55. package/dist/components/Touchable.d.ts +19 -0
  56. package/dist/components/Touchable.js +62 -0
  57. package/dist/components/Touchable.js.map +1 -0
  58. package/dist/components/View.d.ts +190 -0
  59. package/dist/components/View.js +53 -0
  60. package/dist/components/View.js.map +1 -0
  61. package/dist/components/index.d.ts +16 -0
  62. package/dist/components/index.js +29 -0
  63. package/dist/components/index.js.map +1 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/index.js +20 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/modules/fastImage.d.ts +1 -0
  68. package/dist/modules/fastImage.js +10 -0
  69. package/dist/modules/fastImage.js.map +1 -0
  70. package/dist/types/utility.d.ts +2 -0
  71. package/dist/types/utility.js +3 -0
  72. package/dist/types/utility.js.map +1 -0
  73. package/dist/utils/OSAlert.d.ts +31 -0
  74. package/dist/utils/OSAlert.js +89 -0
  75. package/dist/utils/OSAlert.js.map +1 -0
  76. package/dist/utils/styles.d.ts +1 -0
  77. package/dist/utils/styles.js +13 -0
  78. package/dist/utils/styles.js.map +1 -0
  79. package/package.json +32 -0
  80. package/src/components/ActivityIndicator.tsx +37 -0
  81. package/src/components/Button.tsx +61 -0
  82. package/src/components/Checkbox/index.tsx +68 -0
  83. package/src/components/Checkbox/styles.ts +63 -0
  84. package/src/components/FileInput.tsx +6 -0
  85. package/src/components/Icon.tsx +35 -0
  86. package/src/components/Image.tsx +43 -0
  87. package/src/components/Navigation.tsx +125 -0
  88. package/src/components/RadioInput/index.tsx +76 -0
  89. package/src/components/RadioInput/styles.ts +62 -0
  90. package/src/components/Scroll.tsx +87 -0
  91. package/src/components/Select/index.tsx +8 -0
  92. package/src/components/Slider.tsx +198 -0
  93. package/src/components/Switch.tsx +73 -0
  94. package/src/components/Text.tsx +31 -0
  95. package/src/components/TextInput.tsx +206 -0
  96. package/src/components/Touchable.tsx +54 -0
  97. package/src/components/View.tsx +53 -0
  98. package/src/components/index.ts +16 -0
  99. package/src/index.ts +2 -0
  100. package/src/modules/fastImage.ts +2 -0
  101. package/src/types/utility.ts +3 -0
  102. package/src/utils/OSAlert.ts +122 -0
  103. 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
+ }