@codeleap/mobile 1.9.25 → 1.9.26

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 (202) hide show
  1. package/CodeLeap-Mobile-Packages.code-workspace +7 -7
  2. package/dist/components/ActivityIndicator.d.ts +13 -13
  3. package/dist/components/ActivityIndicator.js +54 -54
  4. package/dist/components/ActivityIndicator.js.map +0 -0
  5. package/dist/components/Animated.d.ts +123 -15
  6. package/dist/components/Animated.js +58 -58
  7. package/dist/components/Animated.js.map +0 -0
  8. package/dist/components/Button.d.ts +125 -125
  9. package/dist/components/Button.js +82 -82
  10. package/dist/components/Button.js.map +0 -0
  11. package/dist/components/Checkbox/index.d.ts +15 -15
  12. package/dist/components/Checkbox/index.js +79 -79
  13. package/dist/components/Checkbox/index.js.map +0 -0
  14. package/dist/components/Checkbox/styles.d.ts +55 -55
  15. package/dist/components/Checkbox/styles.js +51 -51
  16. package/dist/components/Checkbox/styles.js.map +0 -0
  17. package/dist/components/ContentView.d.ts +10 -10
  18. package/dist/components/ContentView.js +50 -50
  19. package/dist/components/ContentView.js.map +0 -0
  20. package/dist/components/FileInput.d.ts +31 -31
  21. package/dist/components/FileInput.js +230 -230
  22. package/dist/components/FileInput.js.map +0 -0
  23. package/dist/components/Icon.d.ts +12 -12
  24. package/dist/components/Icon.js +70 -70
  25. package/dist/components/Icon.js.map +0 -0
  26. package/dist/components/Image.d.ts +18 -18
  27. package/dist/components/Image.js +59 -59
  28. package/dist/components/Image.js.map +0 -0
  29. package/dist/components/List.d.ts +14 -14
  30. package/dist/components/List.js +83 -83
  31. package/dist/components/List.js.map +0 -0
  32. package/dist/components/Modal/index.d.ts +26 -26
  33. package/dist/components/Modal/index.js +112 -112
  34. package/dist/components/Modal/index.js.map +0 -0
  35. package/dist/components/Modal/styles.d.ts +69 -69
  36. package/dist/components/Modal/styles.js +64 -64
  37. package/dist/components/Modal/styles.js.map +0 -0
  38. package/dist/components/Navigation/Navigation.d.ts +3 -3
  39. package/dist/components/Navigation/Navigation.js +87 -87
  40. package/dist/components/Navigation/Navigation.js.map +0 -0
  41. package/dist/components/Navigation/constants.d.ts +5 -5
  42. package/dist/components/Navigation/constants.js +10 -10
  43. package/dist/components/Navigation/constants.js.map +0 -0
  44. package/dist/components/Navigation/index.d.ts +3 -3
  45. package/dist/components/Navigation/index.js +19 -19
  46. package/dist/components/Navigation/index.js.map +0 -0
  47. package/dist/components/Navigation/types.d.ts +26 -26
  48. package/dist/components/Navigation/types.js +7 -7
  49. package/dist/components/Navigation/types.js.map +0 -0
  50. package/dist/components/Navigation/utils.d.ts +3 -3
  51. package/dist/components/Navigation/utils.js +69 -69
  52. package/dist/components/Navigation/utils.js.map +0 -0
  53. package/dist/components/NewPager/index.d.ts +26 -0
  54. package/dist/components/NewPager/index.js +92 -0
  55. package/dist/components/NewPager/index.js.map +1 -0
  56. package/dist/components/NewPager/styles.d.ts +87 -0
  57. package/dist/components/NewPager/styles.js +70 -0
  58. package/dist/components/NewPager/styles.js.map +1 -0
  59. package/dist/components/Overlay.d.ts +16 -16
  60. package/dist/components/Overlay.js +69 -69
  61. package/dist/components/Overlay.js.map +0 -0
  62. package/dist/components/Pager/index.d.ts +20 -20
  63. package/dist/components/Pager/index.js +167 -167
  64. package/dist/components/Pager/index.js.map +0 -0
  65. package/dist/components/Pager/styles.d.ts +54 -54
  66. package/dist/components/Pager/styles.js +43 -43
  67. package/dist/components/Pager/styles.js.map +0 -0
  68. package/dist/components/RadioInput/index.d.ts +26 -26
  69. package/dist/components/RadioInput/index.js +72 -72
  70. package/dist/components/RadioInput/index.js.map +0 -0
  71. package/dist/components/RadioInput/styles.d.ts +57 -57
  72. package/dist/components/RadioInput/styles.js +44 -44
  73. package/dist/components/RadioInput/styles.js.map +0 -0
  74. package/dist/components/Scroll.d.ts +13 -13
  75. package/dist/components/Scroll.js +81 -81
  76. package/dist/components/Scroll.js.map +0 -0
  77. package/dist/components/Sections.d.ts +11 -11
  78. package/dist/components/Sections.js +80 -80
  79. package/dist/components/Sections.js.map +0 -0
  80. package/dist/components/Select/index.d.ts +5 -5
  81. package/dist/components/Select/index.js +150 -150
  82. package/dist/components/Select/index.js.map +0 -0
  83. package/dist/components/Select/styles.d.ts +9 -9
  84. package/dist/components/Select/styles.js +56 -56
  85. package/dist/components/Select/styles.js.map +0 -0
  86. package/dist/components/Select/types.d.ts +40 -40
  87. package/dist/components/Select/types.js +2 -2
  88. package/dist/components/Select/types.js.map +0 -0
  89. package/dist/components/Slider/Mark.d.ts +3 -3
  90. package/dist/components/Slider/Mark.js +31 -31
  91. package/dist/components/Slider/Mark.js.map +0 -0
  92. package/dist/components/Slider/Thumb.d.ts +7 -7
  93. package/dist/components/Slider/Thumb.js +29 -29
  94. package/dist/components/Slider/Thumb.js.map +0 -0
  95. package/dist/components/Slider/index.d.ts +3 -3
  96. package/dist/components/Slider/index.js +97 -97
  97. package/dist/components/Slider/index.js.map +0 -0
  98. package/dist/components/Slider/types.d.ts +25 -25
  99. package/dist/components/Slider/types.js +2 -2
  100. package/dist/components/Slider/types.js.map +0 -0
  101. package/dist/components/Switch.d.ts +13 -13
  102. package/dist/components/Switch.js +75 -75
  103. package/dist/components/Switch.js.map +0 -0
  104. package/dist/components/Text.d.ts +12 -12
  105. package/dist/components/Text.js +52 -52
  106. package/dist/components/Text.js.map +0 -0
  107. package/dist/components/TextInput.d.ts +183 -183
  108. package/dist/components/TextInput.js +180 -180
  109. package/dist/components/TextInput.js.map +0 -0
  110. package/dist/components/Touchable.d.ts +14 -14
  111. package/dist/components/Touchable.js +75 -75
  112. package/dist/components/Touchable.js.map +0 -0
  113. package/dist/components/View.d.ts +123 -120
  114. package/dist/components/View.js +55 -54
  115. package/dist/components/View.js.map +1 -1
  116. package/dist/components/components.d.ts +26 -25
  117. package/dist/components/components.js +42 -41
  118. package/dist/components/components.js.map +1 -1
  119. package/dist/index.d.ts +5 -5
  120. package/dist/index.js +28 -28
  121. package/dist/index.js.map +0 -0
  122. package/dist/modules/documentPicker.d.ts +3 -3
  123. package/dist/modules/documentPicker.js +11 -11
  124. package/dist/modules/documentPicker.js.map +0 -0
  125. package/dist/modules/fastImage.d.ts +1 -1
  126. package/dist/modules/fastImage.js +9 -9
  127. package/dist/modules/fastImage.js.map +0 -0
  128. package/dist/modules/reactNavigation.d.ts +3 -3
  129. package/dist/modules/reactNavigation.js +10 -10
  130. package/dist/modules/reactNavigation.js.map +0 -0
  131. package/dist/modules/textInputMask.d.ts +12 -12
  132. package/dist/modules/textInputMask.js +7 -7
  133. package/dist/modules/types/fileTypes.d.ts +138 -138
  134. package/dist/modules/types/fileTypes.js +2 -2
  135. package/dist/modules/types/fileTypes.js.map +0 -0
  136. package/dist/modules/types/textInputMask.d.ts +12 -12
  137. package/dist/modules/types/textInputMask.js +2 -2
  138. package/dist/types/utility.d.ts +2 -2
  139. package/dist/types/utility.js +2 -2
  140. package/dist/types/utility.js.map +0 -0
  141. package/dist/utils/OSAlert.d.ts +31 -31
  142. package/dist/utils/OSAlert.js +141 -141
  143. package/dist/utils/OSAlert.js.map +0 -0
  144. package/dist/utils/misc.d.ts +2 -2
  145. package/dist/utils/misc.js +25 -25
  146. package/dist/utils/misc.js.map +0 -0
  147. package/dist/utils/styles.d.ts +1 -1
  148. package/dist/utils/styles.js +12 -12
  149. package/dist/utils/styles.js.map +0 -0
  150. package/package.json +42 -40
  151. package/src/components/ActivityIndicator.tsx +46 -46
  152. package/src/components/Animated.tsx +34 -34
  153. package/src/components/Button.tsx +95 -95
  154. package/src/components/Checkbox/index.tsx +85 -85
  155. package/src/components/Checkbox/styles.ts +76 -76
  156. package/src/components/ContentView.tsx +58 -58
  157. package/src/components/FileInput.tsx +230 -230
  158. package/src/components/Icon.tsx +58 -58
  159. package/src/components/Image.tsx +61 -61
  160. package/src/components/List.tsx +111 -111
  161. package/src/components/Modal/index.tsx +161 -161
  162. package/src/components/Modal/styles.ts +133 -133
  163. package/src/components/Navigation/Navigation.tsx +58 -58
  164. package/src/components/Navigation/constants.ts +8 -8
  165. package/src/components/Navigation/index.tsx +3 -3
  166. package/src/components/Navigation/types.ts +35 -35
  167. package/src/components/Navigation/utils.tsx +59 -59
  168. package/src/components/NewPager/index.tsx +123 -0
  169. package/src/components/NewPager/styles.ts +76 -0
  170. package/src/components/Overlay.tsx +77 -77
  171. package/src/components/Pager/index.tsx +242 -242
  172. package/src/components/Pager/styles.ts +52 -51
  173. package/src/components/RadioInput/index.tsx +101 -101
  174. package/src/components/RadioInput/styles.ts +67 -67
  175. package/src/components/Scroll.tsx +106 -106
  176. package/src/components/Sections.tsx +101 -101
  177. package/src/components/Select/index.tsx +195 -195
  178. package/src/components/Select/styles.ts +81 -81
  179. package/src/components/Select/types.ts +46 -46
  180. package/src/components/Slider/Mark.tsx +46 -46
  181. package/src/components/Slider/Thumb.tsx +29 -29
  182. package/src/components/Slider/index.tsx +123 -123
  183. package/src/components/Slider/types.ts +25 -25
  184. package/src/components/Switch.tsx +81 -81
  185. package/src/components/Text.tsx +30 -30
  186. package/src/components/TextInput.tsx +247 -247
  187. package/src/components/Touchable.tsx +78 -78
  188. package/src/components/View.tsx +48 -46
  189. package/src/components/components.ts +27 -26
  190. package/src/index.ts +6 -6
  191. package/src/modules/documentPicker.ts +7 -7
  192. package/src/modules/fastImage.ts +2 -2
  193. package/src/modules/index.d.ts +496 -496
  194. package/src/modules/reactNavigation.ts +4 -4
  195. package/src/modules/textInputMask.ts +9 -9
  196. package/src/modules/types/documentPicker.d.ts +215 -215
  197. package/src/modules/types/fileTypes.ts +138 -138
  198. package/src/modules/types/textInputMask.ts +13 -13
  199. package/src/types/utility.ts +3 -3
  200. package/src/utils/OSAlert.ts +180 -180
  201. package/src/utils/misc.ts +24 -24
  202. package/src/utils/styles.ts +14 -14
@@ -1,231 +1,231 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (_) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
- var __importDefault = (this && this.__importDefault) || function (mod) {
73
- return (mod && mod.__esModule) ? mod : { "default": mod };
74
- };
75
- Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.FileInput = void 0;
77
- var react_1 = __importStar(require("react"));
78
- var documentPicker_1 = require("../modules/documentPicker");
79
- var common_1 = require("@codeleap/common");
80
- var Button_1 = require("./Button");
81
- var View_1 = require("./View");
82
- var TextInput_1 = require("./TextInput");
83
- var OSAlert_1 = __importDefault(require("../utils/OSAlert"));
84
- var pickerDefaults = {
85
- width: 300,
86
- height: 400,
87
- cropping: true,
88
- };
89
- function parsePickerData(data) {
90
- var filePathData = (0, common_1.parseFilePathData)(data.path);
91
- var d = {
92
- name: filePathData.name,
93
- size: data.size,
94
- type: data.mime,
95
- uri: data.path,
96
- fileCopyUri: data.path,
97
- };
98
- return {
99
- file: d,
100
- preview: data.path,
101
- };
102
- }
103
- exports.FileInput = (0, react_1.forwardRef)(function (fileInputProps, ref) {
104
- var _a = fileInputProps.mode, mode = _a === void 0 ? 'hidden' : _a, onFileSelect = fileInputProps.onFileSelect, iconName = fileInputProps.iconName, styles = fileInputProps.styles, label = fileInputProps.label, variants = fileInputProps.variants, options = fileInputProps.options, _b = fileInputProps.type, type = _b === void 0 ? 'image' : _b, alertProps = fileInputProps.alertProps, _c = fileInputProps.placeholder, placeholder = _c === void 0 ? 'Select a file' : _c, pickerOptions = fileInputProps.pickerOptions, required = fileInputProps.required, buttonProps = fileInputProps.buttonProps, _d = fileInputProps.onOpenCamera, onOpenCamera = _d === void 0 ? null : _d, _e = fileInputProps.onOpenGallery, onOpenGallery = _e === void 0 ? null : _e, _f = fileInputProps.onOpenFileSystem, onOpenFileSystem = _f === void 0 ? null : _f, onError = fileInputProps.onError;
105
- var _g = react_1.default.useState(null), file = _g[0], setFile = _g[1];
106
- var logger = (0, common_1.useCodeleapContext)().logger;
107
- function openFileSystem() {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var files, err_1;
110
- return __generator(this, function (_a) {
111
- switch (_a.label) {
112
- case 0:
113
- _a.trys.push([0, 2, , 3]);
114
- return [4 /*yield*/, documentPicker_1.DocumentPicker.pick(options)];
115
- case 1:
116
- files = _a.sent();
117
- if (!Array.isArray(files)) {
118
- files = [files];
119
- }
120
- setFile(files);
121
- onFileSelect(files.map(function (file) { return ({ preview: file.uri, file: file }); }));
122
- return [3 /*break*/, 3];
123
- case 2:
124
- err_1 = _a.sent();
125
- handleError(err_1);
126
- return [3 /*break*/, 3];
127
- case 3: return [2 /*return*/];
128
- }
129
- });
130
- });
131
- }
132
- function handleError(err) {
133
- var warn = documentPicker_1.DocumentPicker.isCancel(err) || String(err).includes('Error: User cancelled');
134
- if (warn) {
135
- // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
136
- logger.warn(err);
137
- console.warn(err);
138
- }
139
- else {
140
- // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
141
- logger.error(err);
142
- console.warn(err);
143
- if (onError) {
144
- onError(err);
145
- }
146
- else {
147
- OSAlert_1.default.error({
148
- title: 'Error',
149
- body: err.message,
150
- });
151
- }
152
- }
153
- }
154
- var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
155
- var handlePickerResolution = function (data) {
156
- onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
157
- parsePickerData(data),
158
- ]);
159
- };
160
- var onPress = function (open, options) {
161
- if (open == 'fs') {
162
- openFileSystem();
163
- }
164
- else {
165
- var call = open === 'camera' ? 'openCamera' : 'openPicker';
166
- documentPicker_1.ImageCropPicker[call](__assign(__assign({}, mergedOptions), (options || {}))).then(handlePickerResolution);
167
- }
168
- };
169
- var openFilePicker = function (imageSource) {
170
- if (imageSource === void 0) { imageSource = null; }
171
- return __awaiter(void 0, void 0, void 0, function () {
172
- var _a, _b;
173
- return __generator(this, function (_c) {
174
- if (type === 'image') {
175
- if (imageSource === 'camera') {
176
- onPress('camera');
177
- }
178
- else if (imageSource === 'library') {
179
- onPress('library');
180
- }
181
- else {
182
- OSAlert_1.default.ask(__assign(__assign({ title: 'Change Image', body: 'Do you want to take a new picture or select an existing one?' }, alertProps), { options: [
183
- __assign({ text: ((_b = (_a = alertProps === null || alertProps === void 0 ? void 0 : alertProps.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || 'Camera', onPress: function () {
184
- if (onOpenCamera) {
185
- onOpenCamera(function () { return onPress('camera'); });
186
- }
187
- else {
188
- onPress('camera');
189
- }
190
- } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
191
- __assign({ text: 'Library', onPress: function () {
192
- if (onOpenGallery) {
193
- onOpenGallery(function () { return onPress('library'); });
194
- }
195
- else {
196
- onPress('library');
197
- }
198
- } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
199
- __assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
200
- ] }));
201
- }
202
- }
203
- else {
204
- if (onOpenFileSystem) {
205
- onOpenFileSystem(function () { return onPress('fs'); });
206
- }
207
- else {
208
- onPress('fs');
209
- }
210
- }
211
- return [2 /*return*/];
212
- });
213
- });
214
- };
215
- var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
216
- styles: styles,
217
- variants: variants,
218
- });
219
- (0, react_1.useImperativeHandle)(ref, function () { return ({
220
- openFilePicker: openFilePicker,
221
- }); });
222
- var filenames = file ? file.map(function (f) { return f.name; }) : '';
223
- if (mode === 'button') {
224
- return (<View_1.View style={variantStyles.wrapper}>
225
- <TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
226
- <Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
227
- </View_1.View>);
228
- }
229
- return null;
230
- });
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (_) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __importDefault = (this && this.__importDefault) || function (mod) {
73
+ return (mod && mod.__esModule) ? mod : { "default": mod };
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.FileInput = void 0;
77
+ var react_1 = __importStar(require("react"));
78
+ var documentPicker_1 = require("../modules/documentPicker");
79
+ var common_1 = require("@codeleap/common");
80
+ var Button_1 = require("./Button");
81
+ var View_1 = require("./View");
82
+ var TextInput_1 = require("./TextInput");
83
+ var OSAlert_1 = __importDefault(require("../utils/OSAlert"));
84
+ var pickerDefaults = {
85
+ width: 300,
86
+ height: 400,
87
+ cropping: true,
88
+ };
89
+ function parsePickerData(data) {
90
+ var filePathData = (0, common_1.parseFilePathData)(data.path);
91
+ var d = {
92
+ name: filePathData.name,
93
+ size: data.size,
94
+ type: data.mime,
95
+ uri: data.path,
96
+ fileCopyUri: data.path,
97
+ };
98
+ return {
99
+ file: d,
100
+ preview: data.path,
101
+ };
102
+ }
103
+ exports.FileInput = (0, react_1.forwardRef)(function (fileInputProps, ref) {
104
+ var _a = fileInputProps.mode, mode = _a === void 0 ? 'hidden' : _a, onFileSelect = fileInputProps.onFileSelect, iconName = fileInputProps.iconName, styles = fileInputProps.styles, label = fileInputProps.label, variants = fileInputProps.variants, options = fileInputProps.options, _b = fileInputProps.type, type = _b === void 0 ? 'image' : _b, alertProps = fileInputProps.alertProps, _c = fileInputProps.placeholder, placeholder = _c === void 0 ? 'Select a file' : _c, pickerOptions = fileInputProps.pickerOptions, required = fileInputProps.required, buttonProps = fileInputProps.buttonProps, _d = fileInputProps.onOpenCamera, onOpenCamera = _d === void 0 ? null : _d, _e = fileInputProps.onOpenGallery, onOpenGallery = _e === void 0 ? null : _e, _f = fileInputProps.onOpenFileSystem, onOpenFileSystem = _f === void 0 ? null : _f, onError = fileInputProps.onError;
105
+ var _g = react_1.default.useState(null), file = _g[0], setFile = _g[1];
106
+ var logger = (0, common_1.useCodeleapContext)().logger;
107
+ function openFileSystem() {
108
+ return __awaiter(this, void 0, void 0, function () {
109
+ var files, err_1;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0:
113
+ _a.trys.push([0, 2, , 3]);
114
+ return [4 /*yield*/, documentPicker_1.DocumentPicker.pick(options)];
115
+ case 1:
116
+ files = _a.sent();
117
+ if (!Array.isArray(files)) {
118
+ files = [files];
119
+ }
120
+ setFile(files);
121
+ onFileSelect(files.map(function (file) { return ({ preview: file.uri, file: file }); }));
122
+ return [3 /*break*/, 3];
123
+ case 2:
124
+ err_1 = _a.sent();
125
+ handleError(err_1);
126
+ return [3 /*break*/, 3];
127
+ case 3: return [2 /*return*/];
128
+ }
129
+ });
130
+ });
131
+ }
132
+ function handleError(err) {
133
+ var warn = documentPicker_1.DocumentPicker.isCancel(err) || String(err).includes('Error: User cancelled');
134
+ if (warn) {
135
+ // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
136
+ logger.warn(err);
137
+ console.warn(err);
138
+ }
139
+ else {
140
+ // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
141
+ logger.error(err);
142
+ console.warn(err);
143
+ if (onError) {
144
+ onError(err);
145
+ }
146
+ else {
147
+ OSAlert_1.default.error({
148
+ title: 'Error',
149
+ body: err.message,
150
+ });
151
+ }
152
+ }
153
+ }
154
+ var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
155
+ var handlePickerResolution = function (data) {
156
+ onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
157
+ parsePickerData(data),
158
+ ]);
159
+ };
160
+ var onPress = function (open, options) {
161
+ if (open == 'fs') {
162
+ openFileSystem();
163
+ }
164
+ else {
165
+ var call = open === 'camera' ? 'openCamera' : 'openPicker';
166
+ documentPicker_1.ImageCropPicker[call](__assign(__assign({}, mergedOptions), (options || {}))).then(handlePickerResolution);
167
+ }
168
+ };
169
+ var openFilePicker = function (imageSource) {
170
+ if (imageSource === void 0) { imageSource = null; }
171
+ return __awaiter(void 0, void 0, void 0, function () {
172
+ var _a, _b;
173
+ return __generator(this, function (_c) {
174
+ if (type === 'image') {
175
+ if (imageSource === 'camera') {
176
+ onPress('camera');
177
+ }
178
+ else if (imageSource === 'library') {
179
+ onPress('library');
180
+ }
181
+ else {
182
+ OSAlert_1.default.ask(__assign(__assign({ title: 'Change Image', body: 'Do you want to take a new picture or select an existing one?' }, alertProps), { options: [
183
+ __assign({ text: ((_b = (_a = alertProps === null || alertProps === void 0 ? void 0 : alertProps.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || 'Camera', onPress: function () {
184
+ if (onOpenCamera) {
185
+ onOpenCamera(function () { return onPress('camera'); });
186
+ }
187
+ else {
188
+ onPress('camera');
189
+ }
190
+ } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
191
+ __assign({ text: 'Library', onPress: function () {
192
+ if (onOpenGallery) {
193
+ onOpenGallery(function () { return onPress('library'); });
194
+ }
195
+ else {
196
+ onPress('library');
197
+ }
198
+ } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
199
+ __assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
200
+ ] }));
201
+ }
202
+ }
203
+ else {
204
+ if (onOpenFileSystem) {
205
+ onOpenFileSystem(function () { return onPress('fs'); });
206
+ }
207
+ else {
208
+ onPress('fs');
209
+ }
210
+ }
211
+ return [2 /*return*/];
212
+ });
213
+ });
214
+ };
215
+ var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
216
+ styles: styles,
217
+ variants: variants,
218
+ });
219
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
220
+ openFilePicker: openFilePicker,
221
+ }); });
222
+ var filenames = file ? file.map(function (f) { return f.name; }) : '';
223
+ if (mode === 'button') {
224
+ return (<View_1.View style={variantStyles.wrapper}>
225
+ <TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
226
+ <Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
227
+ </View_1.View>);
228
+ }
229
+ return null;
230
+ });
231
231
  //# sourceMappingURL=FileInput.js.map
File without changes
@@ -1,12 +1,12 @@
1
- import * as React from 'react';
2
- import { ComponentVariants, IconPlaceholder, IconStyles } from '@codeleap/common';
3
- export declare type IconProps = {
4
- name: IconPlaceholder;
5
- style?: any;
6
- color?: string;
7
- variants?: ComponentVariants<typeof IconStyles>['variants'];
8
- renderEmptySpace?: boolean;
9
- size?: number;
10
- };
11
- export declare const IconComponent: React.FC<IconProps>;
12
- export declare const Icon: React.NamedExoticComponent<IconProps>;
1
+ import * as React from 'react';
2
+ import { ComponentVariants, IconPlaceholder, IconStyles } from '@codeleap/common';
3
+ export declare type IconProps = {
4
+ name: IconPlaceholder;
5
+ style?: any;
6
+ color?: string;
7
+ variants?: ComponentVariants<typeof IconStyles>['variants'];
8
+ renderEmptySpace?: boolean;
9
+ size?: number;
10
+ };
11
+ export declare const IconComponent: React.FC<IconProps>;
12
+ export declare const Icon: React.NamedExoticComponent<IconProps>;
@@ -1,71 +1,71 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.Icon = exports.IconComponent = void 0;
38
- var React = __importStar(require("react"));
39
- var common_1 = require("@codeleap/common");
40
- var react_native_1 = require("react-native");
41
- var View_1 = require("./View");
42
- var IconComponent = function (_a) {
43
- var _b;
44
- var name = _a.name, style = _a.style, variants = _a.variants, renderEmptySpace = _a.renderEmptySpace, otherProps = __rest(_a, ["name", "style", "variants", "renderEmptySpace"]);
45
- var _c = (0, common_1.useCodeleapContext)(), Theme = _c.Theme, logger = _c.logger;
46
- var variantStyles = (0, common_1.useDefaultComponentStyle)('Icon', {
47
- variants: variants,
48
- transform: react_native_1.StyleSheet.flatten,
49
- styles: {
50
- icon: style,
51
- },
52
- rootElement: 'icon',
53
- });
54
- if (!name) {
55
- return renderEmptySpace ? <View_1.View style={variantStyles.icon}/> : null;
56
- }
57
- var Component = (_b = Theme === null || Theme === void 0 ? void 0 : Theme.icons) === null || _b === void 0 ? void 0 : _b[name];
58
- if (!Component) {
59
- logger.warn("Icon: No icon found in theme for name \"".concat(name, "\"."), { props: { style: style, name: name, variants: variants, variantStyles: variantStyles } }, 'Component');
60
- return null;
61
- }
62
- return <Component {...otherProps} style={variantStyles.icon}/>;
63
- };
64
- exports.IconComponent = IconComponent;
65
- function areEqual(prevProps, nextProps) {
66
- var check = ['name', 'style', 'variants', 'renderEmptySpace'];
67
- var res = (0, common_1.arePropsEqual)(prevProps, nextProps, { check: check });
68
- return res;
69
- }
70
- exports.Icon = React.memo(exports.IconComponent, areEqual);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.Icon = exports.IconComponent = void 0;
38
+ var React = __importStar(require("react"));
39
+ var common_1 = require("@codeleap/common");
40
+ var react_native_1 = require("react-native");
41
+ var View_1 = require("./View");
42
+ var IconComponent = function (_a) {
43
+ var _b;
44
+ var name = _a.name, style = _a.style, variants = _a.variants, renderEmptySpace = _a.renderEmptySpace, otherProps = __rest(_a, ["name", "style", "variants", "renderEmptySpace"]);
45
+ var _c = (0, common_1.useCodeleapContext)(), Theme = _c.Theme, logger = _c.logger;
46
+ var variantStyles = (0, common_1.useDefaultComponentStyle)('Icon', {
47
+ variants: variants,
48
+ transform: react_native_1.StyleSheet.flatten,
49
+ styles: {
50
+ icon: style,
51
+ },
52
+ rootElement: 'icon',
53
+ });
54
+ if (!name) {
55
+ return renderEmptySpace ? <View_1.View style={variantStyles.icon}/> : null;
56
+ }
57
+ var Component = (_b = Theme === null || Theme === void 0 ? void 0 : Theme.icons) === null || _b === void 0 ? void 0 : _b[name];
58
+ if (!Component) {
59
+ logger.warn("Icon: No icon found in theme for name \"".concat(name, "\"."), { props: { style: style, name: name, variants: variants, variantStyles: variantStyles } }, 'Component');
60
+ return null;
61
+ }
62
+ return <Component {...otherProps} style={variantStyles.icon}/>;
63
+ };
64
+ exports.IconComponent = IconComponent;
65
+ function areEqual(prevProps, nextProps) {
66
+ var check = ['name', 'style', 'variants', 'renderEmptySpace'];
67
+ var res = (0, common_1.arePropsEqual)(prevProps, nextProps, { check: check });
68
+ return res;
69
+ }
70
+ exports.Icon = React.memo(exports.IconComponent, areEqual);
71
71
  //# sourceMappingURL=Icon.js.map
File without changes