@codeleap/mobile 4.2.8 → 4.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Registry.js +28 -53
- package/dist/Registry.js.map +1 -1
- package/dist/components/ActionIcon/index.js +27 -67
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActionIcon/styles.js +1 -2
- package/dist/components/ActionIcon/types.js +1 -2
- package/dist/components/ActivityIndicator/index.js +22 -62
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.js +1 -2
- package/dist/components/ActivityIndicator/types.js +1 -2
- package/dist/components/Autocomplete/index.js +73 -121
- package/dist/components/Autocomplete/index.js.map +1 -1
- package/dist/components/Autocomplete/styles.js +1 -2
- package/dist/components/Autocomplete/types.js +1 -2
- package/dist/components/Avatar/index.js +49 -90
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Avatar/styles.js +1 -2
- package/dist/components/Avatar/types.js +1 -2
- package/dist/components/AvatarGroup/index.js +30 -75
- package/dist/components/AvatarGroup/index.js.map +1 -1
- package/dist/components/AvatarGroup/styles.js +1 -2
- package/dist/components/AvatarGroup/types.js +1 -2
- package/dist/components/Backdrop/index.js +26 -66
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Backdrop/styles.js +1 -2
- package/dist/components/Backdrop/types.js +1 -2
- package/dist/components/Badge/index.js +44 -85
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/styles.js +1 -2
- package/dist/components/Badge/types.js +1 -2
- package/dist/components/Button/index.js +49 -98
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -2
- package/dist/components/Button/types.js +1 -2
- package/dist/components/Calendar/index.js +27 -68
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/types.d.ts +1 -2
- package/dist/components/Calendar/types.js +1 -2
- package/dist/components/Checkbox/index.js +52 -85
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.js +1 -2
- package/dist/components/Checkbox/types.js +1 -2
- package/dist/components/DatePickerModal/index.js +61 -113
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/DatePickerModal/styles.js +1 -2
- package/dist/components/DatePickerModal/types.js +1 -2
- package/dist/components/EmptyPlaceholder/index.js +40 -69
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -2
- package/dist/components/EmptyPlaceholder/types.js +1 -2
- package/dist/components/FileInput/index.js +112 -178
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.js +1 -2
- package/dist/components/Grid/index.js +47 -97
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Grid/styles.js +1 -2
- package/dist/components/Grid/types.js +1 -2
- package/dist/components/Icon/index.js +34 -75
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.js +1 -2
- package/dist/components/Icon/types.js +1 -2
- package/dist/components/Image/index.js +53 -96
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Image/styles.js +1 -2
- package/dist/components/Image/types.js +1 -2
- package/dist/components/ImageView/Spotlight.js +75 -131
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/ImageView/component.js +8 -15
- package/dist/components/ImageView/component.js.map +1 -1
- package/dist/components/ImageView/index.js +2 -18
- package/dist/components/ImageView/index.js.map +1 -1
- package/dist/components/InputBase/index.js +35 -75
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/styles.d.ts +3 -3
- package/dist/components/InputBase/styles.js +49 -50
- package/dist/components/InputBase/styles.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +1 -0
- package/dist/components/InputBase/types.js +1 -2
- package/dist/components/InputBase/utils.js +4 -19
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.js +46 -86
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/styles.js +1 -2
- package/dist/components/List/types.js +1 -2
- package/dist/components/LoadingOverlay/index.js +28 -66
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/LoadingOverlay/styles.js +1 -2
- package/dist/components/LoadingOverlay/types.js +1 -2
- package/dist/components/Modal/index.js +77 -113
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +1 -2
- package/dist/components/Modal/types.js +1 -2
- package/dist/components/Navigation/Navigation.js +23 -66
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Navigation/constants.js +7 -10
- package/dist/components/Navigation/constants.js.map +1 -1
- package/dist/components/Navigation/index.js +3 -19
- package/dist/components/Navigation/index.js.map +1 -1
- package/dist/components/Navigation/types.js +1 -2
- package/dist/components/Navigation/utils.js +24 -59
- package/dist/components/Navigation/utils.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +132 -165
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/styles.js +1 -2
- package/dist/components/NumberIncrement/types.d.ts +2 -2
- package/dist/components/NumberIncrement/types.js +1 -2
- package/dist/components/NumberIncrement/utils.js +8 -12
- package/dist/components/NumberIncrement/utils.js.map +1 -1
- package/dist/components/Pager/PagerDots.js +17 -54
- package/dist/components/Pager/PagerDots.js.map +1 -1
- package/dist/components/Pager/index.js +43 -97
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/Pager/styles.js +1 -2
- package/dist/components/Pager/types.js +1 -2
- package/dist/components/PaginationIndicator/index.js +23 -38
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/styles.js +1 -2
- package/dist/components/PaginationIndicator/types.js +1 -2
- package/dist/components/PlacesAutocomplete/index.js +55 -106
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/PlacesAutocomplete/styles.js +1 -2
- package/dist/components/PlacesAutocomplete/types.js +1 -2
- package/dist/components/RadioInput/index.js +46 -84
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.js +1 -2
- package/dist/components/RadioInput/types.js +1 -2
- package/dist/components/RefreshControl/index.js +22 -63
- package/dist/components/RefreshControl/index.js.map +1 -1
- package/dist/components/RefreshControl/styles.js +1 -2
- package/dist/components/RefreshControl/types.js +1 -2
- package/dist/components/Scroll/index.js +33 -81
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/styles.js +1 -2
- package/dist/components/Scroll/types.js +1 -2
- package/dist/components/SearchInput/index.js +22 -69
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/context.d.ts +6 -0
- package/dist/components/SectionFilters/context.js +4 -8
- package/dist/components/SectionFilters/context.js.map +1 -1
- package/dist/components/SectionFilters/index.js +33 -76
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/types.js +1 -2
- package/dist/components/SectionFilters/useSectionFilters.d.ts +3 -0
- package/dist/components/SectionFilters/useSectionFilters.js +71 -73
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
- package/dist/components/Sections/index.d.ts +8 -8
- package/dist/components/Sections/index.js +61 -106
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/Sections/styles.d.ts +1 -1
- package/dist/components/Sections/styles.js +1 -2
- package/dist/components/Sections/types.js +1 -2
- package/dist/components/SegmentedControl/Option.js +13 -31
- package/dist/components/SegmentedControl/Option.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +71 -114
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.js +1 -2
- package/dist/components/SegmentedControl/types.js +1 -2
- package/dist/components/Select/index.js +94 -157
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/types.js +1 -2
- package/dist/components/Slider/index.js +89 -129
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +0 -6
- package/dist/components/Slider/styles.js +1 -2
- package/dist/components/Slider/types.js +1 -2
- package/dist/components/SortablePhotos/index.js +58 -91
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/styles.js +1 -2
- package/dist/components/SortablePhotos/types.js +1 -2
- package/dist/components/SortablePhotos/useSortablePhotos.js +93 -157
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.js +51 -84
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.js +1 -2
- package/dist/components/Switch/types.js +1 -2
- package/dist/components/Text/index.js +40 -88
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/styles.js +1 -2
- package/dist/components/Text/types.js +1 -2
- package/dist/components/TextInput/index.js +83 -131
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.js +1 -2
- package/dist/components/TextInput/types.js +1 -2
- package/dist/components/Touchable/index.js +69 -122
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.js +1 -2
- package/dist/components/Touchable/types.js +1 -2
- package/dist/components/View/index.js +19 -51
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.js +1 -2
- package/dist/components/View/types.js +1 -2
- package/dist/components/components.js +43 -59
- package/dist/components/components.js.map +1 -1
- package/dist/hooks/index.js +7 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +8 -43
- package/dist/index.js.map +1 -1
- package/dist/modules/PressableRipple/index.js +2 -8
- package/dist/modules/PressableRipple/index.js.map +1 -1
- package/dist/modules/PressableRipple/ripple.js +125 -163
- package/dist/modules/PressableRipple/ripple.js.map +1 -1
- package/dist/modules/PressableRipple/styles.js +9 -20
- package/dist/modules/PressableRipple/styles.js.map +1 -1
- package/dist/modules/PressableRipple/type.js +1 -2
- package/dist/modules/reactNavigation.js +10 -21
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/textInputMask.js +3 -20
- package/dist/modules/textInputMask.js.map +1 -1
- package/dist/modules/types/textInputMask.js +1 -2
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/utility.js +1 -2
- package/dist/utils/KeyboardAware/context.js +5 -14
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/KeyboardAware/index.js +3 -19
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.js +36 -41
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/KeyboardAware/types.js +1 -2
- package/dist/utils/KeyboardAware/types.js.map +1 -1
- package/dist/utils/ModalManager/components.js +24 -54
- package/dist/utils/ModalManager/components.js.map +1 -1
- package/dist/utils/ModalManager/context.js +94 -89
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/ModalManager/index.js +7 -10
- package/dist/utils/ModalManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/index.js +115 -245
- package/dist/utils/NotificationManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/types.js +1 -2
- package/dist/utils/OSAlert.js +32 -48
- package/dist/utils/OSAlert.js.map +1 -1
- package/dist/utils/PermissionManager/context.js +138 -255
- package/dist/utils/PermissionManager/context.js.map +1 -1
- package/dist/utils/PermissionManager/index.js +2 -8
- package/dist/utils/PermissionManager/index.js.map +1 -1
- package/dist/utils/PermissionManager/types.js +1 -2
- package/dist/utils/StorageManager.js +39 -46
- package/dist/utils/StorageManager.js.map +1 -1
- package/dist/utils/Subscription.js +30 -54
- package/dist/utils/Subscription.js.map +1 -1
- package/dist/utils/deprecated/notifications.js +143 -250
- package/dist/utils/deprecated/notifications.js.map +1 -1
- package/dist/utils/hooks.js +101 -120
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/index.js +14 -43
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/input.js +15 -19
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/locale.js +5 -9
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/misc.js +25 -40
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/theme.js +24 -33
- package/dist/utils/theme.js.map +1 -1
- package/dist/utils/useQueryListRefresh.js +16 -26
- package/dist/utils/useQueryListRefresh.js.map +1 -1
- package/package.json +6 -6
- package/package.json.bak +2 -2
- package/src/components/Calendar/types.ts +3 -3
- package/src/components/InputBase/styles.ts +35 -23
- package/src/components/InputBase/types.ts +1 -0
- package/src/components/NumberIncrement/index.tsx +8 -2
- package/src/components/NumberIncrement/types.ts +3 -3
- package/src/components/RadioInput/index.tsx +4 -0
- package/src/components/SectionFilters/useSectionFilters.tsx +31 -1
- package/src/components/Sections/index.tsx +3 -2
- package/src/components/Sections/styles.ts +2 -2
- package/src/components/Slider/index.tsx +9 -1
- package/src/components/Slider/styles.ts +0 -6
- package/src/components/TextInput/index.tsx +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/EmptyPlaceholder/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/EmptyPlaceholder/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EAAsB,oBAAoB,EAA8B,MAAM,kBAAkB,CAAA;AACvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAE,EAAE;IAC/D,MAAM,EAC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 -1,218 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
-
function step(op) {
|
|
41
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
43
|
-
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;
|
|
44
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
-
switch (op[0]) {
|
|
46
|
-
case 0: case 1: t = op; break;
|
|
47
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
-
default:
|
|
51
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
-
if (t[2]) _.ops.pop();
|
|
56
|
-
_.trys.pop(); continue;
|
|
57
|
-
}
|
|
58
|
-
op = body.call(thisArg, _);
|
|
59
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
|
-
};
|
|
66
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
exports.useFileInput = exports.FileInput = void 0;
|
|
68
|
-
var react_1 = require("react");
|
|
69
|
-
var common_1 = require("@codeleap/common");
|
|
70
|
-
var utils_1 = require("../../utils");
|
|
71
|
-
var react_native_image_crop_picker_1 = __importDefault(require("react-native-image-crop-picker"));
|
|
72
|
-
var react_native_document_picker_1 = __importDefault(require("react-native-document-picker"));
|
|
73
|
-
__exportStar(require("./types"), exports);
|
|
74
|
-
var pickerDefaults = {
|
|
1
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { parseFilePathData } from '@codeleap/common';
|
|
3
|
+
import { OSAlert } from '../../utils';
|
|
4
|
+
import ImageCropPicker from 'react-native-image-crop-picker';
|
|
5
|
+
import DocumentPicker from 'react-native-document-picker';
|
|
6
|
+
export * from './types';
|
|
7
|
+
const pickerDefaults = {
|
|
75
8
|
cropping: true,
|
|
76
9
|
};
|
|
77
10
|
function parsePickerData(data) {
|
|
78
|
-
|
|
79
|
-
|
|
11
|
+
const filePathData = parseFilePathData(data.path);
|
|
12
|
+
const file = {
|
|
13
|
+
...data,
|
|
14
|
+
name: filePathData.name,
|
|
15
|
+
size: data.size,
|
|
16
|
+
type: data.mime,
|
|
17
|
+
uri: data.path,
|
|
18
|
+
fileCopyUri: data.path,
|
|
19
|
+
};
|
|
80
20
|
return {
|
|
81
|
-
file
|
|
21
|
+
file,
|
|
82
22
|
preview: data.path,
|
|
83
23
|
};
|
|
84
24
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _a;
|
|
25
|
+
const _FileInput = forwardRef((fileInputProps, ref) => {
|
|
26
|
+
const { onFileSelect, options, type = 'image', alertProps, pickerOptions, onOpenCamera = null, onOpenGallery = null, onOpenFileSystem = null, onError, } = fileInputProps;
|
|
27
|
+
const resolveWithFile = useRef();
|
|
28
|
+
const handleResolve = (files) => {
|
|
90
29
|
if (resolveWithFile.current) {
|
|
91
|
-
|
|
30
|
+
resolveWithFile?.current?.(files);
|
|
92
31
|
resolveWithFile.current = null;
|
|
93
32
|
}
|
|
94
|
-
onFileSelect
|
|
33
|
+
onFileSelect?.(files);
|
|
95
34
|
};
|
|
96
|
-
function openFileSystem() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
filesWithPreview = files.map(function (file) { return ({ preview: file.uri, file: file }); });
|
|
110
|
-
handleResolve === null || handleResolve === void 0 ? void 0 : handleResolve(filesWithPreview);
|
|
111
|
-
return [3 /*break*/, 3];
|
|
112
|
-
case 2:
|
|
113
|
-
err_1 = _a.sent();
|
|
114
|
-
handleError(err_1);
|
|
115
|
-
return [3 /*break*/, 3];
|
|
116
|
-
case 3: return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
35
|
+
async function openFileSystem() {
|
|
36
|
+
try {
|
|
37
|
+
let files = await DocumentPicker.pick(options);
|
|
38
|
+
if (!Array.isArray(files)) {
|
|
39
|
+
files = [files];
|
|
40
|
+
}
|
|
41
|
+
const filesWithPreview = files.map((file) => ({ preview: file.uri, file }));
|
|
42
|
+
handleResolve?.(filesWithPreview);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
handleError(err);
|
|
46
|
+
}
|
|
120
47
|
}
|
|
121
48
|
function handleError(err) {
|
|
122
|
-
onError
|
|
49
|
+
onError?.(err);
|
|
123
50
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
51
|
+
const mergedOptions = {
|
|
52
|
+
...pickerDefaults,
|
|
53
|
+
...pickerOptions,
|
|
54
|
+
};
|
|
55
|
+
const handlePickerResolution = (data) => {
|
|
56
|
+
let imageArray = [];
|
|
127
57
|
if (!Array.isArray(data)) {
|
|
128
58
|
imageArray = [data];
|
|
129
59
|
}
|
|
130
60
|
else {
|
|
131
61
|
imageArray = data;
|
|
132
62
|
}
|
|
133
|
-
handleResolve
|
|
63
|
+
handleResolve?.(imageArray.map(parsePickerData));
|
|
134
64
|
};
|
|
135
|
-
|
|
65
|
+
const onPress = (open, options) => {
|
|
136
66
|
if (open == 'fs') {
|
|
137
67
|
openFileSystem();
|
|
138
68
|
}
|
|
139
69
|
else {
|
|
140
|
-
|
|
141
|
-
|
|
70
|
+
const call = open === 'camera' ? 'openCamera' : 'openPicker';
|
|
71
|
+
ImageCropPicker[call]({ ...mergedOptions, ...(options || {}) }).then(handlePickerResolution);
|
|
142
72
|
}
|
|
143
73
|
};
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
74
|
+
const openFilePicker = async (imageSource = null, options = {}) => {
|
|
75
|
+
if (type === 'image') {
|
|
76
|
+
if (imageSource === 'camera') {
|
|
77
|
+
onPress('camera', options);
|
|
78
|
+
}
|
|
79
|
+
else if (imageSource === 'library') {
|
|
80
|
+
onPress('library', options);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
OSAlert.ask({
|
|
84
|
+
title: 'Change Image',
|
|
85
|
+
body: 'Do you want to take a new picture or select an existing one?',
|
|
86
|
+
...alertProps,
|
|
87
|
+
options: [
|
|
88
|
+
{
|
|
89
|
+
text: alertProps?.options?.[0]?.text || 'Camera',
|
|
90
|
+
onPress: () => {
|
|
91
|
+
if (onOpenCamera) {
|
|
92
|
+
onOpenCamera(() => onPress('camera'));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
onPress('camera');
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
...alertProps?.options?.[1],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: 'Library',
|
|
102
|
+
onPress: () => {
|
|
103
|
+
if (onOpenGallery) {
|
|
104
|
+
onOpenGallery(() => onPress('library'));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
onPress('library');
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
...alertProps?.options?.[2],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
text: 'Cancel',
|
|
114
|
+
style: 'cancel',
|
|
115
|
+
onPress: () => { },
|
|
116
|
+
...alertProps?.options?.[0],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
if (onOpenFileSystem) {
|
|
124
|
+
onOpenFileSystem(() => onPress('fs'));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
onPress('fs');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
190
130
|
};
|
|
191
|
-
|
|
192
|
-
openFilePicker:
|
|
193
|
-
if (imageSource === void 0) { imageSource = null; }
|
|
194
|
-
if (options === void 0) { options = {}; }
|
|
131
|
+
useImperativeHandle(ref, () => ({
|
|
132
|
+
openFilePicker: (imageSource = null, options = {}) => {
|
|
195
133
|
openFilePicker(imageSource, options);
|
|
196
|
-
return new Promise(
|
|
134
|
+
return new Promise((resolve) => {
|
|
197
135
|
resolveWithFile.current = resolve;
|
|
198
136
|
});
|
|
199
137
|
},
|
|
200
|
-
})
|
|
138
|
+
}));
|
|
201
139
|
return null;
|
|
202
140
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (imageSource === void 0) { imageSource = null; }
|
|
209
|
-
if (options === void 0) { options = {}; }
|
|
210
|
-
return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.openFilePicker(imageSource, options);
|
|
141
|
+
export const FileInput = _FileInput;
|
|
142
|
+
export const useFileInput = () => {
|
|
143
|
+
const inputRef = useRef(null);
|
|
144
|
+
const openFilePicker = (imageSource = null, options = {}) => {
|
|
145
|
+
return inputRef.current?.openFilePicker(imageSource, options);
|
|
211
146
|
};
|
|
212
147
|
return {
|
|
213
|
-
openFilePicker
|
|
148
|
+
openFilePicker,
|
|
214
149
|
ref: inputRef,
|
|
215
150
|
};
|
|
216
151
|
};
|
|
217
|
-
exports.useFileInput = useFileInput;
|
|
218
152
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FileInput/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FileInput/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAc,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,eAA0C,MAAM,gCAAgC,CAAA;AACvF,OAAO,cAAc,MAAM,8BAA8B,CAAA;AAGzD,cAAc,SAAS,CAAA;AAEvB,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE,IAAI;CACf,CAAA;AAED,SAAS,eAAe,CAAC,IAAkB;I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CAAC,CAAC,CAAA;aACtC;iBAAM;gBAEL,OAAO,CAAC,IAAI,CAAC,CAAA;aACd;SACF;IAEH,CAAC,CAAA;IAED,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,cAAc,EAAE,CAAC,cAAoC,IAAI,EAAE,UAA4B,EAAE,EAAE,EAAE;YAC3F,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;YACpC,OAAO,IAAI,OAAO,CAAe,CAAC,OAAO,EAAE,EAAE;gBAC3C,eAAe,CAAC,OAAO,GAAG,OAAO,CAAA;YACnC,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAC,CAAA;IAEH,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,UAAiE,CAAA;AAE1F,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAe,IAAI,CAAC,CAAA;IAE3C,MAAM,cAAc,GAAG,CAAC,cAAoC,IAAI,EAAE,UAA4B,EAAE,EAAyB,EAAE;QACzH,OAAO,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC,CAAA;IAED,OAAO;QACL,cAAc;QACd,GAAG,EAAE,QAAgD;KACtD,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,110 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
37
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1
|
+
import React, { useCallback, forwardRef } from 'react';
|
|
2
|
+
import { View } from '../View';
|
|
3
|
+
import { EmptyPlaceholder } from '../EmptyPlaceholder';
|
|
4
|
+
import { RefreshControl } from '../RefreshControl';
|
|
5
|
+
import { List } from '../List';
|
|
6
|
+
import { useTheme } from '@codeleap/styles';
|
|
7
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
8
|
+
import { useStylesFor } from '../../hooks';
|
|
9
|
+
export * from './styles';
|
|
10
|
+
export * from './types';
|
|
11
|
+
const RenderSeparator = (props) => {
|
|
12
|
+
return <View style={props.separatorStyles}/>;
|
|
38
13
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.Grid = void 0;
|
|
52
|
-
var react_1 = __importStar(require("react"));
|
|
53
|
-
var View_1 = require("../View");
|
|
54
|
-
var EmptyPlaceholder_1 = require("../EmptyPlaceholder");
|
|
55
|
-
var RefreshControl_1 = require("../RefreshControl");
|
|
56
|
-
var List_1 = require("../List");
|
|
57
|
-
var styles_1 = require("@codeleap/styles");
|
|
58
|
-
var Registry_1 = require("../../Registry");
|
|
59
|
-
var hooks_1 = require("../../hooks");
|
|
60
|
-
__exportStar(require("./styles"), exports);
|
|
61
|
-
__exportStar(require("./types"), exports);
|
|
62
|
-
var RenderSeparator = function (props) {
|
|
63
|
-
return <View_1.View style={props.separatorStyles}/>;
|
|
64
|
-
};
|
|
65
|
-
exports.Grid = (0, react_1.forwardRef)(function (flatGridProps, ref) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
var _c = __assign(__assign({}, exports.Grid.defaultProps), flatGridProps), style = _c.style, onRefresh = _c.onRefresh, refreshing = _c.refreshing, placeholder = _c.placeholder, _d = _c.refreshControlProps, refreshControlProps = _d === void 0 ? {} : _d, spacing = _c.spacing, numColumns = _c.numColumns, RenderItem = _c.renderItem, props = __rest(_c, ["style", "onRefresh", "refreshing", "placeholder", "refreshControlProps", "spacing", "numColumns", "renderItem"]);
|
|
68
|
-
var themeSpacing = (0, styles_1.useTheme)(function (store) { var _a; return (_a = store.current) === null || _a === void 0 ? void 0 : _a.spacing; });
|
|
69
|
-
var styles = (0, hooks_1.useStylesFor)(exports.Grid.styleRegistryName, style);
|
|
70
|
-
var renderItem = (0, react_1.useCallback)(function (data) {
|
|
71
|
-
var _a, _b, _c, _d;
|
|
14
|
+
export const Grid = forwardRef((flatGridProps, ref) => {
|
|
15
|
+
const { style, onRefresh, refreshing, placeholder, refreshControlProps = {}, spacing, numColumns, renderItem: RenderItem, ...props } = {
|
|
16
|
+
...Grid.defaultProps,
|
|
17
|
+
...flatGridProps,
|
|
18
|
+
};
|
|
19
|
+
const themeSpacing = useTheme(store => store.current?.spacing);
|
|
20
|
+
const styles = useStylesFor(Grid.styleRegistryName, style);
|
|
21
|
+
const renderItem = useCallback((data) => {
|
|
72
22
|
if (!RenderItem)
|
|
73
23
|
return null;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
24
|
+
const listLength = props?.data?.length || 0;
|
|
25
|
+
const isFirst = data.index === 0;
|
|
26
|
+
const isLast = data.index === listLength - 1;
|
|
27
|
+
const isOnly = isFirst && isLast;
|
|
28
|
+
const idx = data.index + 1;
|
|
29
|
+
const isLastInRow = !isFirst && idx % (numColumns) === 0;
|
|
30
|
+
const isFirstInRow = isFirst || data.index % numColumns === 0;
|
|
31
|
+
const isOnlyInRow = !isFirstInRow && !isLastInRow;
|
|
32
|
+
let gap = themeSpacing?.marginRight?.(spacing / 2);
|
|
83
33
|
if (isLastInRow)
|
|
84
|
-
gap =
|
|
34
|
+
gap = themeSpacing?.marginLeft?.(spacing / 2);
|
|
85
35
|
else if (isOnlyInRow)
|
|
86
|
-
gap =
|
|
87
|
-
|
|
88
|
-
return (<
|
|
36
|
+
gap = themeSpacing?.marginHorizontal?.(spacing / 2);
|
|
37
|
+
const _itemProps = { isFirst, isLast, isOnly, isFirstInRow, isLastInRow, isOnlyInRow };
|
|
38
|
+
return (<View style={[styles.itemWrapper, gap]}>
|
|
89
39
|
<RenderItem {...data} {..._itemProps}/>
|
|
90
|
-
</
|
|
91
|
-
}, [RenderItem,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return (<
|
|
40
|
+
</View>);
|
|
41
|
+
}, [RenderItem, props?.data?.length]);
|
|
42
|
+
const separatorStyles = { height: themeSpacing?.value?.(spacing), ...styles.separator };
|
|
43
|
+
const separator = props?.separators || (!!spacing ? <RenderSeparator separatorStyles={separatorStyles}/> : null);
|
|
44
|
+
const refreshControl = !!onRefresh && <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>;
|
|
45
|
+
return (<List
|
|
96
46
|
// @ts-expect-error
|
|
97
|
-
ref={ref} {...props} ListEmptyComponent={<
|
|
47
|
+
ref={ref} {...props} ListEmptyComponent={<EmptyPlaceholder {...placeholder}/>} ListHeaderComponentStyle={styles.header} ListFooterComponentStyle={styles.footer} ItemSeparatorComponent={separator} refreshControl={refreshControl} style={styles.wrapper} contentContainerStyle={[styles.content, props?.contentContainerStyle]} showsVerticalScrollIndicator={false} numColumns={numColumns} renderItem={renderItem}/>);
|
|
98
48
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
49
|
+
Grid.styleRegistryName = 'Grid';
|
|
50
|
+
Grid.elements = ['wrapper', 'content', 'separator', 'header', 'refreshControl', 'itemWrapper', 'footer'];
|
|
51
|
+
Grid.rootElement = 'wrapper';
|
|
52
|
+
Grid.withVariantTypes = (styles) => {
|
|
53
|
+
return Grid;
|
|
104
54
|
};
|
|
105
|
-
|
|
55
|
+
Grid.defaultProps = {
|
|
106
56
|
keyboardShouldPersistTaps: 'handled',
|
|
107
57
|
refreshControlProps: {},
|
|
108
58
|
};
|
|
109
|
-
|
|
59
|
+
MobileStyleRegistry.registerComponent(Grid);
|
|
110
60
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Grid/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAiB,MAAM,OAAO,CAAA;AAErE,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;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