@codeleap/mobile 1.9.11 → 1.9.14

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 (194) 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 +15 -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 +77 -77
  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 +48 -48
  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 +30 -27
  21. package/dist/components/FileInput.js +204 -178
  22. package/dist/components/FileInput.js.map +1 -1
  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/Overlay.d.ts +16 -16
  54. package/dist/components/Overlay.js +69 -69
  55. package/dist/components/Overlay.js.map +0 -0
  56. package/dist/components/Pager/index.d.ts +20 -20
  57. package/dist/components/Pager/index.js +167 -167
  58. package/dist/components/Pager/index.js.map +0 -0
  59. package/dist/components/Pager/styles.d.ts +54 -54
  60. package/dist/components/Pager/styles.js +43 -43
  61. package/dist/components/Pager/styles.js.map +0 -0
  62. package/dist/components/RadioInput/index.d.ts +26 -26
  63. package/dist/components/RadioInput/index.js +72 -72
  64. package/dist/components/RadioInput/index.js.map +0 -0
  65. package/dist/components/RadioInput/styles.d.ts +57 -57
  66. package/dist/components/RadioInput/styles.js +44 -44
  67. package/dist/components/RadioInput/styles.js.map +0 -0
  68. package/dist/components/Scroll.d.ts +13 -13
  69. package/dist/components/Scroll.js +81 -81
  70. package/dist/components/Scroll.js.map +0 -0
  71. package/dist/components/Sections.d.ts +11 -11
  72. package/dist/components/Sections.js +80 -80
  73. package/dist/components/Sections.js.map +0 -0
  74. package/dist/components/Select/index.d.ts +5 -5
  75. package/dist/components/Select/index.js +150 -150
  76. package/dist/components/Select/index.js.map +0 -0
  77. package/dist/components/Select/styles.d.ts +9 -9
  78. package/dist/components/Select/styles.js +56 -56
  79. package/dist/components/Select/styles.js.map +0 -0
  80. package/dist/components/Select/types.d.ts +40 -40
  81. package/dist/components/Select/types.js +2 -2
  82. package/dist/components/Select/types.js.map +0 -0
  83. package/dist/components/Slider/Mark.d.ts +3 -3
  84. package/dist/components/Slider/Mark.js +31 -31
  85. package/dist/components/Slider/Mark.js.map +0 -0
  86. package/dist/components/Slider/Thumb.d.ts +7 -7
  87. package/dist/components/Slider/Thumb.js +29 -29
  88. package/dist/components/Slider/Thumb.js.map +0 -0
  89. package/dist/components/Slider/index.d.ts +3 -3
  90. package/dist/components/Slider/index.js +97 -97
  91. package/dist/components/Slider/index.js.map +0 -0
  92. package/dist/components/Slider/types.d.ts +25 -25
  93. package/dist/components/Slider/types.js +2 -2
  94. package/dist/components/Slider/types.js.map +0 -0
  95. package/dist/components/Switch.d.ts +13 -13
  96. package/dist/components/Switch.js +75 -75
  97. package/dist/components/Switch.js.map +0 -0
  98. package/dist/components/Text.d.ts +12 -12
  99. package/dist/components/Text.js +52 -52
  100. package/dist/components/Text.js.map +0 -0
  101. package/dist/components/TextInput.d.ts +54 -183
  102. package/dist/components/TextInput.js +179 -178
  103. package/dist/components/TextInput.js.map +1 -1
  104. package/dist/components/Touchable.d.ts +14 -14
  105. package/dist/components/Touchable.js +61 -61
  106. package/dist/components/Touchable.js.map +0 -0
  107. package/dist/components/View.d.ts +120 -120
  108. package/dist/components/View.js +54 -54
  109. package/dist/components/View.js.map +0 -0
  110. package/dist/components/components.d.ts +25 -25
  111. package/dist/components/components.js +41 -41
  112. package/dist/components/components.js.map +0 -0
  113. package/dist/index.d.ts +5 -5
  114. package/dist/index.js +28 -28
  115. package/dist/index.js.map +0 -0
  116. package/dist/modules/documentPicker.d.ts +3 -3
  117. package/dist/modules/documentPicker.js +11 -11
  118. package/dist/modules/documentPicker.js.map +0 -0
  119. package/dist/modules/fastImage.d.ts +1 -1
  120. package/dist/modules/fastImage.js +9 -9
  121. package/dist/modules/fastImage.js.map +0 -0
  122. package/dist/modules/reactNavigation.d.ts +3 -3
  123. package/dist/modules/reactNavigation.js +10 -10
  124. package/dist/modules/reactNavigation.js.map +0 -0
  125. package/dist/modules/textInputMask.d.ts +2 -12
  126. package/dist/modules/textInputMask.js +7 -7
  127. package/dist/modules/types/fileTypes.d.ts +138 -138
  128. package/dist/modules/types/fileTypes.js +2 -2
  129. package/dist/modules/types/fileTypes.js.map +0 -0
  130. package/dist/modules/types/textInputMask.d.ts +12 -12
  131. package/dist/modules/types/textInputMask.js +2 -2
  132. package/dist/types/utility.d.ts +2 -2
  133. package/dist/types/utility.js +2 -2
  134. package/dist/types/utility.js.map +0 -0
  135. package/dist/utils/OSAlert.d.ts +31 -31
  136. package/dist/utils/OSAlert.js +141 -141
  137. package/dist/utils/OSAlert.js.map +0 -0
  138. package/dist/utils/misc.d.ts +2 -2
  139. package/dist/utils/misc.js +25 -25
  140. package/dist/utils/misc.js.map +0 -0
  141. package/dist/utils/styles.d.ts +1 -1
  142. package/dist/utils/styles.js +12 -12
  143. package/dist/utils/styles.js.map +0 -0
  144. package/package.json +40 -40
  145. package/src/components/ActivityIndicator.tsx +46 -46
  146. package/src/components/Animated.tsx +34 -34
  147. package/src/components/Button.tsx +95 -95
  148. package/src/components/Checkbox/index.tsx +83 -83
  149. package/src/components/Checkbox/styles.ts +72 -72
  150. package/src/components/ContentView.tsx +58 -58
  151. package/src/components/FileInput.tsx +220 -181
  152. package/src/components/Icon.tsx +58 -58
  153. package/src/components/Image.tsx +61 -61
  154. package/src/components/List.tsx +111 -111
  155. package/src/components/Modal/index.tsx +161 -161
  156. package/src/components/Modal/styles.ts +133 -133
  157. package/src/components/Navigation/Navigation.tsx +58 -58
  158. package/src/components/Navigation/constants.ts +8 -8
  159. package/src/components/Navigation/index.tsx +3 -3
  160. package/src/components/Navigation/types.ts +35 -35
  161. package/src/components/Navigation/utils.tsx +59 -59
  162. package/src/components/Overlay.tsx +77 -77
  163. package/src/components/Pager/index.tsx +242 -242
  164. package/src/components/Pager/styles.ts +51 -51
  165. package/src/components/RadioInput/index.tsx +101 -101
  166. package/src/components/RadioInput/styles.ts +67 -67
  167. package/src/components/Scroll.tsx +106 -106
  168. package/src/components/Sections.tsx +101 -101
  169. package/src/components/Select/index.tsx +195 -195
  170. package/src/components/Select/styles.ts +81 -81
  171. package/src/components/Select/types.ts +46 -46
  172. package/src/components/Slider/Mark.tsx +46 -46
  173. package/src/components/Slider/Thumb.tsx +29 -29
  174. package/src/components/Slider/index.tsx +123 -123
  175. package/src/components/Slider/types.ts +25 -25
  176. package/src/components/Switch.tsx +81 -81
  177. package/src/components/Text.tsx +30 -30
  178. package/src/components/TextInput.tsx +245 -247
  179. package/src/components/Touchable.tsx +64 -64
  180. package/src/components/View.tsx +46 -46
  181. package/src/components/components.ts +26 -26
  182. package/src/index.ts +6 -6
  183. package/src/modules/documentPicker.ts +7 -7
  184. package/src/modules/fastImage.ts +2 -2
  185. package/src/modules/index.d.ts +496 -496
  186. package/src/modules/reactNavigation.ts +4 -4
  187. package/src/modules/textInputMask.ts +9 -9
  188. package/src/modules/types/documentPicker.d.ts +215 -215
  189. package/src/modules/types/fileTypes.ts +138 -138
  190. package/src/modules/types/textInputMask.ts +13 -12
  191. package/src/types/utility.ts +3 -3
  192. package/src/utils/OSAlert.ts +180 -180
  193. package/src/utils/misc.ts +24 -24
  194. package/src/utils/styles.ts +14 -14
@@ -1,179 +1,205 @@
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;
105
- var _d = react_1.default.useState(null), file = _d[0], setFile = _d[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
- if (documentPicker_1.DocumentPicker.isCancel(err_1)) {
126
- logger.log('User cancelled the picker.', null, 'Component');
127
- }
128
- else {
129
- throw err_1;
130
- }
131
- return [3 /*break*/, 3];
132
- case 3: return [2 /*return*/];
133
- }
134
- });
135
- });
136
- }
137
- var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
138
- var handlePickerResolution = function (data) {
139
- onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
140
- parsePickerData(data),
141
- ]);
142
- };
143
- var openFilePicker = function () { return __awaiter(void 0, void 0, void 0, function () {
144
- var _a, _b;
145
- return __generator(this, function (_c) {
146
- if (type === 'image') {
147
- 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: [
148
- __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 () {
149
- documentPicker_1.ImageCropPicker.openCamera(mergedOptions).then(handlePickerResolution);
150
- } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
151
- __assign({ text: 'Library', onPress: function () {
152
- documentPicker_1.ImageCropPicker.openPicker(mergedOptions).then(handlePickerResolution);
153
- } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
154
- __assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
155
- ] }));
156
- }
157
- else {
158
- openFileSystem();
159
- }
160
- return [2 /*return*/];
161
- });
162
- }); };
163
- var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
164
- styles: styles,
165
- variants: variants,
166
- });
167
- (0, react_1.useImperativeHandle)(ref, function () { return ({
168
- openFilePicker: openFilePicker,
169
- }); });
170
- var filenames = file ? file.map(function (f) { return f.name; }) : '';
171
- if (mode === 'button') {
172
- return (<View_1.View style={variantStyles.wrapper}>
173
- <TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
174
- <Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
175
- </View_1.View>);
176
- }
177
- return null;
178
- });
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
+ var emptyPromise = function () { return __awaiter(void 0, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ return [2 /*return*/];
106
+ });
107
+ }); };
108
+ exports.FileInput = (0, react_1.forwardRef)(function (fileInputProps, ref) {
109
+ 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 ? emptyPromise : _d, _e = fileInputProps.onOpenGallery, onOpenGallery = _e === void 0 ? emptyPromise : _e, onError = fileInputProps.onError;
110
+ var _f = react_1.default.useState(null), file = _f[0], setFile = _f[1];
111
+ var logger = (0, common_1.useCodeleapContext)().logger;
112
+ function openFileSystem() {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var files, err_1;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0:
118
+ _a.trys.push([0, 2, , 3]);
119
+ return [4 /*yield*/, documentPicker_1.DocumentPicker.pick(options)];
120
+ case 1:
121
+ files = _a.sent();
122
+ if (!Array.isArray(files)) {
123
+ files = [files];
124
+ }
125
+ setFile(files);
126
+ onFileSelect(files.map(function (file) { return ({ preview: file.uri, file: file }); }));
127
+ return [3 /*break*/, 3];
128
+ case 2:
129
+ err_1 = _a.sent();
130
+ handleError(err_1);
131
+ return [3 /*break*/, 3];
132
+ case 3: return [2 /*return*/];
133
+ }
134
+ });
135
+ });
136
+ }
137
+ function handleError(err) {
138
+ var warn = documentPicker_1.DocumentPicker.isCancel(err) || String(err).includes('Error: User cancelled');
139
+ if (warn) {
140
+ // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
141
+ logger.warn(err);
142
+ console.warn(err);
143
+ }
144
+ else {
145
+ // NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
146
+ logger.error(err);
147
+ console.error(err);
148
+ if (onError) {
149
+ onError(err);
150
+ }
151
+ else {
152
+ OSAlert_1.default.error({
153
+ title: 'Error',
154
+ body: err.message,
155
+ });
156
+ }
157
+ }
158
+ }
159
+ var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
160
+ var handlePickerResolution = function (data) {
161
+ onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
162
+ parsePickerData(data),
163
+ ]);
164
+ };
165
+ var openFilePicker = function () { return __awaiter(void 0, void 0, void 0, function () {
166
+ var _a, _b;
167
+ return __generator(this, function (_c) {
168
+ if (type === 'image') {
169
+ 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: [
170
+ __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 () {
171
+ onOpenCamera().then(function () {
172
+ documentPicker_1.ImageCropPicker.openCamera(mergedOptions).then(handlePickerResolution);
173
+ }).catch(onError);
174
+ } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
175
+ __assign({ text: 'Library', onPress: function () {
176
+ onOpenGallery().then(function () {
177
+ documentPicker_1.ImageCropPicker.openPicker(mergedOptions).then(handlePickerResolution);
178
+ }).catch(onError);
179
+ } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
180
+ __assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
181
+ ] }));
182
+ }
183
+ else {
184
+ openFileSystem();
185
+ }
186
+ return [2 /*return*/];
187
+ });
188
+ }); };
189
+ var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
190
+ styles: styles,
191
+ variants: variants,
192
+ });
193
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
194
+ openFilePicker: openFilePicker,
195
+ }); });
196
+ var filenames = file ? file.map(function (f) { return f.name; }) : '';
197
+ if (mode === 'button') {
198
+ return (<View_1.View style={variantStyles.wrapper}>
199
+ <TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
200
+ <Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
201
+ </View_1.View>);
202
+ }
203
+ return null;
204
+ });
179
205
  //# sourceMappingURL=FileInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/components/FileInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAC9D,4DAA2E;AAC3E,2CASyB;AAEzB,mCAA8C;AAC9C,+BAA6B;AAC7B,yCAAwC;AACxC,6DAAsC;AAyBtC,IAAM,cAAc,GAAG;IACrB,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,IAAI;CACf,CAAA;AAED,SAAS,eAAe,CAAC,IAAQ;IAE/B,IAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjD,IAAM,CAAC,GAA2B;QAChC,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,IAAI;QACd,WAAW,EAAE,IAAI,CAAC,IAAI;KACvB,CAAA;IAED,OAAO;QACL,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,IAAI,CAAC,IAAI;KACnB,CAAA;AACH,CAAC;AAEY,QAAA,SAAS,GAAG,IAAA,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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAClC,IAAI,WAAW,CAAC,EAEpB;MAAA,EAAE,WAAI,CAAC,CACR,CAAA;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
@@ -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
@@ -1,18 +1,18 @@
1
- import * as React from 'react';
2
- import { ComponentVariants, ImageStyles, MobileInputFile } from '@codeleap/common';
3
- import { ComponentPropsWithoutRef } from 'react';
4
- import { Image as NativeImage, ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
5
- import { FastImage } from '../modules/fastImage';
6
- declare type NativeImageProps = ComponentPropsWithoutRef<typeof NativeImage>;
7
- export declare type ImageProps = Omit<NativeImageProps, 'source' | 'style'> & {
8
- variants?: ComponentVariants<typeof ImageStyles>['variants'];
9
- fast?: boolean;
10
- style?: StyleProp<ImageStyle | TextStyle | ViewStyle>;
11
- source: (NativeImageProps['source'] & {
12
- priority?: keyof typeof FastImage.priority;
13
- }) | MobileInputFile | string;
14
- resizeMode?: keyof typeof FastImage.resizeMode;
15
- };
16
- export declare const ImageComponent: React.FC<ImageProps>;
17
- export declare const Image: React.NamedExoticComponent<ImageProps>;
18
- export {};
1
+ import * as React from 'react';
2
+ import { ComponentVariants, ImageStyles, MobileInputFile } from '@codeleap/common';
3
+ import { ComponentPropsWithoutRef } from 'react';
4
+ import { Image as NativeImage, ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
5
+ import { FastImage } from '../modules/fastImage';
6
+ declare type NativeImageProps = ComponentPropsWithoutRef<typeof NativeImage>;
7
+ export declare type ImageProps = Omit<NativeImageProps, 'source' | 'style'> & {
8
+ variants?: ComponentVariants<typeof ImageStyles>['variants'];
9
+ fast?: boolean;
10
+ style?: StyleProp<ImageStyle | TextStyle | ViewStyle>;
11
+ source: (NativeImageProps['source'] & {
12
+ priority?: keyof typeof FastImage.priority;
13
+ }) | MobileInputFile | string;
14
+ resizeMode?: keyof typeof FastImage.resizeMode;
15
+ };
16
+ export declare const ImageComponent: React.FC<ImageProps>;
17
+ export declare const Image: React.NamedExoticComponent<ImageProps>;
18
+ export {};