@codeleap/mobile 1.9.14 → 1.9.17
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/CodeLeap-Mobile-Packages.code-workspace +7 -7
- package/dist/components/ActivityIndicator.d.ts +13 -13
- package/dist/components/ActivityIndicator.js +54 -54
- package/dist/components/ActivityIndicator.js.map +0 -0
- package/dist/components/Animated.d.ts +15 -15
- package/dist/components/Animated.js +58 -58
- package/dist/components/Animated.js.map +0 -0
- package/dist/components/Button.d.ts +125 -125
- package/dist/components/Button.js +82 -82
- package/dist/components/Button.js.map +0 -0
- package/dist/components/Checkbox/index.d.ts +15 -15
- package/dist/components/Checkbox/index.js +77 -77
- package/dist/components/Checkbox/index.js.map +0 -0
- package/dist/components/Checkbox/styles.d.ts +55 -55
- package/dist/components/Checkbox/styles.js +48 -48
- package/dist/components/Checkbox/styles.js.map +0 -0
- package/dist/components/ContentView.d.ts +10 -10
- package/dist/components/ContentView.js +50 -50
- package/dist/components/ContentView.js.map +0 -0
- package/dist/components/FileInput.d.ts +28 -30
- package/dist/components/FileInput.js +195 -204
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Icon.d.ts +12 -12
- package/dist/components/Icon.js +70 -70
- package/dist/components/Icon.js.map +0 -0
- package/dist/components/Image.d.ts +18 -18
- package/dist/components/Image.js +59 -59
- package/dist/components/Image.js.map +0 -0
- package/dist/components/List.d.ts +14 -14
- package/dist/components/List.js +83 -83
- package/dist/components/List.js.map +0 -0
- package/dist/components/Modal/index.d.ts +26 -26
- package/dist/components/Modal/index.js +112 -112
- package/dist/components/Modal/index.js.map +0 -0
- package/dist/components/Modal/styles.d.ts +69 -69
- package/dist/components/Modal/styles.js +64 -64
- package/dist/components/Modal/styles.js.map +0 -0
- package/dist/components/Navigation/Navigation.d.ts +3 -3
- package/dist/components/Navigation/Navigation.js +87 -87
- package/dist/components/Navigation/Navigation.js.map +0 -0
- package/dist/components/Navigation/constants.d.ts +5 -5
- package/dist/components/Navigation/constants.js +10 -10
- package/dist/components/Navigation/constants.js.map +0 -0
- package/dist/components/Navigation/index.d.ts +3 -3
- package/dist/components/Navigation/index.js +19 -19
- package/dist/components/Navigation/index.js.map +0 -0
- package/dist/components/Navigation/types.d.ts +26 -26
- package/dist/components/Navigation/types.js +7 -7
- package/dist/components/Navigation/types.js.map +0 -0
- package/dist/components/Navigation/utils.d.ts +3 -3
- package/dist/components/Navigation/utils.js +69 -69
- package/dist/components/Navigation/utils.js.map +0 -0
- package/dist/components/Overlay.d.ts +16 -16
- package/dist/components/Overlay.js +69 -69
- package/dist/components/Overlay.js.map +0 -0
- package/dist/components/Pager/index.d.ts +20 -20
- package/dist/components/Pager/index.js +167 -167
- package/dist/components/Pager/index.js.map +0 -0
- package/dist/components/Pager/styles.d.ts +54 -54
- package/dist/components/Pager/styles.js +43 -43
- package/dist/components/Pager/styles.js.map +0 -0
- package/dist/components/RadioInput/index.d.ts +26 -26
- package/dist/components/RadioInput/index.js +72 -72
- package/dist/components/RadioInput/index.js.map +0 -0
- package/dist/components/RadioInput/styles.d.ts +57 -57
- package/dist/components/RadioInput/styles.js +44 -44
- package/dist/components/RadioInput/styles.js.map +0 -0
- package/dist/components/Scroll.d.ts +13 -13
- package/dist/components/Scroll.js +81 -81
- package/dist/components/Scroll.js.map +0 -0
- package/dist/components/Sections.d.ts +11 -11
- package/dist/components/Sections.js +80 -80
- package/dist/components/Sections.js.map +0 -0
- package/dist/components/Select/index.d.ts +5 -5
- package/dist/components/Select/index.js +150 -150
- package/dist/components/Select/index.js.map +0 -0
- package/dist/components/Select/styles.d.ts +9 -9
- package/dist/components/Select/styles.js +56 -56
- package/dist/components/Select/styles.js.map +0 -0
- package/dist/components/Select/types.d.ts +40 -40
- package/dist/components/Select/types.js +2 -2
- package/dist/components/Select/types.js.map +0 -0
- package/dist/components/Slider/Mark.d.ts +3 -3
- package/dist/components/Slider/Mark.js +31 -31
- package/dist/components/Slider/Mark.js.map +0 -0
- package/dist/components/Slider/Thumb.d.ts +7 -7
- package/dist/components/Slider/Thumb.js +29 -29
- package/dist/components/Slider/Thumb.js.map +0 -0
- package/dist/components/Slider/index.d.ts +3 -3
- package/dist/components/Slider/index.js +97 -97
- package/dist/components/Slider/index.js.map +0 -0
- package/dist/components/Slider/types.d.ts +25 -25
- package/dist/components/Slider/types.js +2 -2
- package/dist/components/Slider/types.js.map +0 -0
- package/dist/components/Switch.d.ts +13 -13
- package/dist/components/Switch.js +75 -75
- package/dist/components/Switch.js.map +0 -0
- package/dist/components/Text.d.ts +12 -12
- package/dist/components/Text.js +52 -52
- package/dist/components/Text.js.map +0 -0
- package/dist/components/TextInput.d.ts +183 -54
- package/dist/components/TextInput.js +178 -179
- package/dist/components/TextInput.js.map +1 -1
- package/dist/components/Touchable.d.ts +14 -14
- package/dist/components/Touchable.js +61 -61
- package/dist/components/Touchable.js.map +0 -0
- package/dist/components/View.d.ts +120 -120
- package/dist/components/View.js +54 -54
- package/dist/components/View.js.map +0 -0
- package/dist/components/components.d.ts +25 -25
- package/dist/components/components.js +41 -41
- package/dist/components/components.js.map +0 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +28 -28
- package/dist/index.js.map +0 -0
- package/dist/modules/documentPicker.d.ts +3 -3
- package/dist/modules/documentPicker.js +11 -11
- package/dist/modules/documentPicker.js.map +0 -0
- package/dist/modules/fastImage.d.ts +1 -1
- package/dist/modules/fastImage.js +9 -9
- package/dist/modules/fastImage.js.map +0 -0
- package/dist/modules/reactNavigation.d.ts +3 -3
- package/dist/modules/reactNavigation.js +10 -10
- package/dist/modules/reactNavigation.js.map +0 -0
- package/dist/modules/textInputMask.d.ts +12 -2
- package/dist/modules/textInputMask.js +7 -7
- package/dist/modules/types/fileTypes.d.ts +138 -138
- package/dist/modules/types/fileTypes.js +2 -2
- package/dist/modules/types/fileTypes.js.map +0 -0
- package/dist/modules/types/textInputMask.d.ts +12 -12
- package/dist/modules/types/textInputMask.js +2 -2
- package/dist/types/utility.d.ts +2 -2
- package/dist/types/utility.js +2 -2
- package/dist/types/utility.js.map +0 -0
- package/dist/utils/OSAlert.d.ts +31 -31
- package/dist/utils/OSAlert.js +141 -141
- package/dist/utils/OSAlert.js.map +0 -0
- package/dist/utils/misc.d.ts +2 -2
- package/dist/utils/misc.js +25 -25
- package/dist/utils/misc.js.map +0 -0
- package/dist/utils/styles.d.ts +1 -1
- package/dist/utils/styles.js +12 -12
- package/dist/utils/styles.js.map +0 -0
- package/package.json +40 -40
- package/src/components/ActivityIndicator.tsx +46 -46
- package/src/components/Animated.tsx +34 -34
- package/src/components/Button.tsx +95 -95
- package/src/components/Checkbox/index.tsx +85 -83
- package/src/components/Checkbox/styles.ts +76 -72
- package/src/components/ContentView.tsx +58 -58
- package/src/components/FileInput.tsx +229 -220
- package/src/components/Icon.tsx +58 -58
- package/src/components/Image.tsx +61 -61
- package/src/components/List.tsx +111 -111
- package/src/components/Modal/index.tsx +161 -161
- package/src/components/Modal/styles.ts +133 -133
- package/src/components/Navigation/Navigation.tsx +58 -58
- package/src/components/Navigation/constants.ts +8 -8
- package/src/components/Navigation/index.tsx +3 -3
- package/src/components/Navigation/types.ts +35 -35
- package/src/components/Navigation/utils.tsx +59 -59
- package/src/components/Overlay.tsx +77 -77
- package/src/components/Pager/index.tsx +242 -242
- package/src/components/Pager/styles.ts +51 -51
- package/src/components/RadioInput/index.tsx +101 -101
- package/src/components/RadioInput/styles.ts +67 -67
- package/src/components/Scroll.tsx +106 -106
- package/src/components/Sections.tsx +101 -101
- package/src/components/Select/index.tsx +195 -195
- package/src/components/Select/styles.ts +81 -81
- package/src/components/Select/types.ts +46 -46
- package/src/components/Slider/Mark.tsx +46 -46
- package/src/components/Slider/Thumb.tsx +29 -29
- package/src/components/Slider/index.tsx +123 -123
- package/src/components/Slider/types.ts +25 -25
- package/src/components/Switch.tsx +81 -81
- package/src/components/Text.tsx +30 -30
- package/src/components/TextInput.tsx +245 -245
- package/src/components/Touchable.tsx +64 -64
- package/src/components/View.tsx +46 -46
- package/src/components/components.ts +26 -26
- package/src/index.ts +6 -6
- package/src/modules/documentPicker.ts +7 -7
- package/src/modules/fastImage.ts +2 -2
- package/src/modules/index.d.ts +496 -496
- package/src/modules/reactNavigation.ts +4 -4
- package/src/modules/textInputMask.ts +9 -9
- package/src/modules/types/documentPicker.d.ts +215 -215
- package/src/modules/types/fileTypes.ts +138 -138
- package/src/modules/types/textInputMask.ts +13 -13
- package/src/types/utility.ts +3 -3
- package/src/utils/OSAlert.ts +180 -180
- package/src/utils/misc.ts +24 -24
- package/src/utils/styles.ts +14 -14
|
@@ -1,205 +1,196 @@
|
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
files
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
141
|
-
logger.
|
|
142
|
-
console.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
variants:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
});
|
|
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, onError = fileInputProps.onError;
|
|
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
|
+
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.error(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 openFilePicker = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
return __generator(this, function (_c) {
|
|
163
|
+
if (type === 'image') {
|
|
164
|
+
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: [
|
|
165
|
+
__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 () {
|
|
166
|
+
documentPicker_1.ImageCropPicker.openCamera(mergedOptions).then(handlePickerResolution).catch(handleError);
|
|
167
|
+
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
|
|
168
|
+
__assign({ text: 'Library', onPress: function () {
|
|
169
|
+
documentPicker_1.ImageCropPicker.openPicker(mergedOptions).then(handlePickerResolution).catch(handleError);
|
|
170
|
+
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
|
|
171
|
+
__assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
|
|
172
|
+
] }));
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
openFileSystem();
|
|
176
|
+
}
|
|
177
|
+
return [2 /*return*/];
|
|
178
|
+
});
|
|
179
|
+
}); };
|
|
180
|
+
var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
|
|
181
|
+
styles: styles,
|
|
182
|
+
variants: variants,
|
|
183
|
+
});
|
|
184
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
185
|
+
openFilePicker: openFilePicker,
|
|
186
|
+
}); });
|
|
187
|
+
var filenames = file ? file.map(function (f) { return f.name; }) : '';
|
|
188
|
+
if (mode === 'button') {
|
|
189
|
+
return (<View_1.View style={variantStyles.wrapper}>
|
|
190
|
+
<TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
|
|
191
|
+
<Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
|
|
192
|
+
</View_1.View>);
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
});
|
|
205
196
|
//# 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;
|
|
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;AA0BtC,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,kBAAU,EAGjC,UAAC,cAAc,EAAE,GAAG;IAElB,IAAA,KAcE,cAAc,KAdD,EAAf,IAAI,mBAAG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AChC,IAAI,CAAC,CAAC,SAAS,IAAI,WAAW,CAAC,CAC/B,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAC9B,IAAI,CAAC,CAAC,QAAQ,IAAK,iBAAqC,CAAC,CACzD,QAAQ,CAAC,CAAC,SAAS,CAAC,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>;
|
package/dist/components/Icon.js
CHANGED
|
@@ -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
|