@codeleap/mobile 4.2.9 → 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,192 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
-
exports.useSortablePhotos = void 0;
|
|
60
|
-
var common_1 = require("@codeleap/common");
|
|
61
|
-
var FileInput_1 = require("../FileInput");
|
|
62
|
-
var SortableAlert = (0, common_1.CreateOSAlert)();
|
|
63
|
-
var useSortablePhotos = function (props) {
|
|
64
|
-
var onChangePhotos = props.onChangePhotos, onPressPhoto = props.onPressPhoto, modalBody = props.modalBody, modalTitle = props.modalTitle, modalCameraText = props.modalCameraText, modalDeleteText = props.modalDeleteText, modalLibraryText = props.modalLibraryText, getFilename = props.getFilename, numPhotos = props.numPhotos, loading = props.loading, currentPhotos = props.photos;
|
|
65
|
-
var input = (0, FileInput_1.useFileInput)();
|
|
66
|
-
var logger = (0, common_1.useGlobalContext)().logger;
|
|
67
|
-
var _a = (0, common_1.useState)([]), data = _a[0], setData = _a[1];
|
|
68
|
-
var onChange = function (photos) {
|
|
69
|
-
var _a = sortPhotos(photos), newPhotos = _a.newPhotos, sortedPhotos = _a.sortedPhotos;
|
|
1
|
+
import { CreateOSAlert, useEffect, useGlobalContext, useMemo, useState } from '@codeleap/common';
|
|
2
|
+
import { useFileInput } from '../FileInput';
|
|
3
|
+
const SortableAlert = CreateOSAlert();
|
|
4
|
+
export const useSortablePhotos = (props) => {
|
|
5
|
+
const { onChangePhotos, onPressPhoto, modalBody, modalTitle, modalCameraText, modalDeleteText, modalLibraryText, getFilename, numPhotos, loading, photos: currentPhotos } = props;
|
|
6
|
+
const input = useFileInput();
|
|
7
|
+
const { logger } = useGlobalContext();
|
|
8
|
+
const [data, setData] = useState([]);
|
|
9
|
+
const onChange = (photos) => {
|
|
10
|
+
const { newPhotos, sortedPhotos } = sortPhotos(photos);
|
|
70
11
|
setData(sortedPhotos);
|
|
71
12
|
onChangePhotos(newPhotos);
|
|
72
13
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var newPhotos = currentPhotos.concat(fillPhotos);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!loading && data?.length < numPhotos) {
|
|
16
|
+
const currentLength = currentPhotos?.length ?? 0;
|
|
17
|
+
const length = Math.abs(numPhotos - currentLength);
|
|
18
|
+
const fillPhotos = Array(length).fill({ filename: null, file: null });
|
|
19
|
+
const newPhotos = currentPhotos.concat(fillPhotos);
|
|
80
20
|
setData(newPhotos);
|
|
81
21
|
onChangePhotos(currentPhotos);
|
|
82
22
|
}
|
|
83
23
|
}, [loading]);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!
|
|
24
|
+
const { emptyIndexes, numberPhotosMissing } = useMemo(() => {
|
|
25
|
+
const copyPhotos = [...data];
|
|
26
|
+
const emptyIndexes = copyPhotos.reduce((indexes, photo, index) => {
|
|
27
|
+
if (!photo?.filename) {
|
|
88
28
|
indexes.push(index);
|
|
89
29
|
}
|
|
90
30
|
return indexes;
|
|
91
31
|
}, []);
|
|
92
|
-
|
|
32
|
+
const numberPhotosMissing = emptyIndexes?.length;
|
|
93
33
|
return {
|
|
94
|
-
emptyIndexes
|
|
95
|
-
numberPhotosMissing
|
|
34
|
+
emptyIndexes,
|
|
35
|
+
numberPhotosMissing,
|
|
96
36
|
};
|
|
97
|
-
}, [JSON.stringify(data)])
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
!!(photo === null || photo === void 0 ? void 0 : photo.filename) ? newPhotos.push(photo) : emptyPhotos.push(photo);
|
|
37
|
+
}, [JSON.stringify(data)]);
|
|
38
|
+
const sortPhotos = (_unorderedPhotos) => {
|
|
39
|
+
const unorderedPhotos = [..._unorderedPhotos];
|
|
40
|
+
const [newPhotos, emptyPhotos] = unorderedPhotos.reduce(([newPhotos, emptyPhotos], photo) => {
|
|
41
|
+
!!photo?.filename ? newPhotos.push(photo) : emptyPhotos.push(photo);
|
|
103
42
|
return [newPhotos, emptyPhotos];
|
|
104
|
-
}, [[], []])
|
|
105
|
-
|
|
43
|
+
}, [[], []]);
|
|
44
|
+
const sortedPhotos = newPhotos.concat(emptyPhotos);
|
|
106
45
|
return {
|
|
107
|
-
sortedPhotos
|
|
108
|
-
newPhotos
|
|
46
|
+
sortedPhotos,
|
|
47
|
+
newPhotos,
|
|
109
48
|
};
|
|
110
49
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (isMultiple) {
|
|
138
|
-
for (fileIndex in files) {
|
|
139
|
-
file = files === null || files === void 0 ? void 0 : files[fileIndex];
|
|
140
|
-
order_1 = emptyIndexes[fileIndex];
|
|
141
|
-
uri = (_a = file === null || file === void 0 ? void 0 : file.file) === null || _a === void 0 ? void 0 : _a.uri;
|
|
142
|
-
filename = getFilename(uri);
|
|
143
|
-
newPhotos[order_1] = __assign(__assign({}, newPhotos[order_1]), { filename: filename, file: uri });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
file = files === null || files === void 0 ? void 0 : files[0];
|
|
148
|
-
uri = (_b = file === null || file === void 0 ? void 0 : file.file) === null || _b === void 0 ? void 0 : _b.uri;
|
|
149
|
-
filename = getFilename(uri);
|
|
150
|
-
newPhotos[order] = __assign(__assign({}, newPhotos[order]), { filename: filename, file: uri });
|
|
151
|
-
}
|
|
152
|
-
onChange(newPhotos);
|
|
153
|
-
return [2 /*return*/];
|
|
50
|
+
const handleOpenPicker = async (pickerType, photo, order) => {
|
|
51
|
+
let files = [];
|
|
52
|
+
const isEdit = !!photo?.filename;
|
|
53
|
+
try {
|
|
54
|
+
files = await input?.openFilePicker(pickerType, {
|
|
55
|
+
multiple: isEdit ? false : props?.multiple
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
logger.error('Error opening file picker:', error);
|
|
60
|
+
}
|
|
61
|
+
if (files?.length <= 0)
|
|
62
|
+
return null;
|
|
63
|
+
const isMultiple = files?.length > 1 && !isEdit;
|
|
64
|
+
const newPhotos = [...data];
|
|
65
|
+
if (isMultiple) {
|
|
66
|
+
for (const fileIndex in files) {
|
|
67
|
+
const file = files?.[fileIndex];
|
|
68
|
+
const order = emptyIndexes[fileIndex];
|
|
69
|
+
const uri = file?.file?.uri;
|
|
70
|
+
const filename = getFilename(uri);
|
|
71
|
+
newPhotos[order] = {
|
|
72
|
+
...newPhotos[order],
|
|
73
|
+
filename,
|
|
74
|
+
file: uri,
|
|
75
|
+
};
|
|
154
76
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const file = files?.[0];
|
|
80
|
+
const uri = file?.file?.uri;
|
|
81
|
+
const filename = getFilename(uri);
|
|
82
|
+
newPhotos[order] = {
|
|
83
|
+
...newPhotos[order],
|
|
84
|
+
filename,
|
|
85
|
+
file: uri,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
onChange(newPhotos);
|
|
89
|
+
};
|
|
90
|
+
const handleDeletePhoto = (photo, order) => {
|
|
91
|
+
const newPhotos = [...data];
|
|
92
|
+
newPhotos[order] = {
|
|
93
|
+
...newPhotos[order],
|
|
94
|
+
filename: null,
|
|
95
|
+
file: null,
|
|
96
|
+
};
|
|
160
97
|
onChange(newPhotos);
|
|
161
98
|
};
|
|
162
|
-
|
|
99
|
+
const handlePressPhoto = (currentData, photo, order) => {
|
|
163
100
|
SortableAlert.custom({
|
|
164
101
|
title: modalTitle,
|
|
165
102
|
body: modalBody,
|
|
166
103
|
options: [
|
|
167
|
-
{ text: modalLibraryText, onPress:
|
|
168
|
-
{ text: modalCameraText, onPress:
|
|
169
|
-
!!
|
|
104
|
+
{ text: modalLibraryText, onPress: () => handleOpenPicker('library', photo, order) },
|
|
105
|
+
{ text: modalCameraText, onPress: () => handleOpenPicker('camera', photo, order) },
|
|
106
|
+
!!photo?.filename && { text: modalDeleteText, onPress: () => handleDeletePhoto(photo, order) },
|
|
170
107
|
],
|
|
171
108
|
// @ts-expect-error
|
|
172
109
|
isRow: false,
|
|
173
110
|
});
|
|
174
|
-
onPressPhoto
|
|
111
|
+
onPressPhoto?.(currentData, photo, order);
|
|
175
112
|
};
|
|
176
|
-
|
|
113
|
+
const onChangePhotosOrder = (newData) => {
|
|
177
114
|
onChange(newData);
|
|
178
115
|
};
|
|
179
116
|
return {
|
|
180
|
-
input
|
|
181
|
-
handlePressPhoto
|
|
182
|
-
handleDeletePhoto
|
|
183
|
-
handleOpenPicker
|
|
184
|
-
sortPhotos
|
|
185
|
-
numberPhotosMissing
|
|
186
|
-
onChangePhotosOrder
|
|
187
|
-
emptyIndexes
|
|
188
|
-
data
|
|
117
|
+
input,
|
|
118
|
+
handlePressPhoto,
|
|
119
|
+
handleDeletePhoto,
|
|
120
|
+
handleOpenPicker,
|
|
121
|
+
sortPhotos,
|
|
122
|
+
numberPhotosMissing,
|
|
123
|
+
onChangePhotosOrder,
|
|
124
|
+
emptyIndexes,
|
|
125
|
+
data,
|
|
189
126
|
};
|
|
190
127
|
};
|
|
191
|
-
exports.useSortablePhotos = useSortablePhotos;
|
|
192
128
|
//# sourceMappingURL=useSortablePhotos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSortablePhotos.js","sourceRoot":"","sources":["../../../src/components/SortablePhotos/useSortablePhotos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSortablePhotos.js","sourceRoot":"","sources":["../../../src/components/SortablePhotos/useSortablePhotos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAwB,YAAY,EAAE,MAAM,cAAc,CAAA;AAGjE,MAAM,aAAa,GAAG,aAAa,EAAE,CAAA;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAA0B,KAA6B,EAAE,EAAE;IAC1F,MAAM,EACJ,cAAc,EACd,YAAY,EACZ,SAAS,EACT,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EAAE,aAAa,EACtB,GAAG,KAAK,CAAA;IAET,MAAM,KAAK,GAAG,YAAY,EAAE,CAAA;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAA;IAErC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAM,EAAE,CAAC,CAAA;IAEzC,MAAM,QAAQ,GAAG,CAAC,MAAW,EAAE,EAAE;QAC/B,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;QAEtD,OAAO,CAAC,YAAY,CAAC,CAAA;QACrB,cAAc,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC,CAAA;IAED,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE;YACxC,MAAM,aAAa,GAAG,aAAa,EAAE,MAAM,IAAI,CAAC,CAAA;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,aAAa,CAAC,CAAA;YAClD,MAAM,UAAU,GA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,CAAC,CAAC,KAAK,EAAE,QAAQ,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;aAC/F;YACD,mBAAmB;YACnB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;QAEF,YAAY,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;IAC3C,CAAC,CAAA;IAED,MAAM,mBAAmB,GAAG,CAAC,OAAY,EAAE,EAAE;QAC3C,QAAQ,CAAC,OAAO,CAAC,CAAA;IACnB,CAAC,CAAA;IAED,OAAO;QACL,KAAK;QACL,gBAAgB;QAChB,iBAAiB;QACjB,gBAAgB;QAChB,UAAU;QACV,mBAAmB;QACnB,mBAAmB;QACnB,YAAY;QACZ,IAAI;KACL,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,115 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
28
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
29
|
-
if (ar || !(i in from)) {
|
|
30
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
31
|
-
ar[i] = from[i];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.Switch = void 0;
|
|
41
|
-
var react_1 = __importDefault(require("react"));
|
|
42
|
-
var View_1 = require("../View");
|
|
43
|
-
var InputBase_1 = require("../InputBase");
|
|
44
|
-
var __1 = require("../..");
|
|
45
|
-
var Touchable_1 = require("../Touchable");
|
|
46
|
-
var Registry_1 = require("../../Registry");
|
|
47
|
-
var hooks_1 = require("../../hooks");
|
|
48
|
-
__exportStar(require("./styles"), exports);
|
|
49
|
-
__exportStar(require("./types"), exports);
|
|
50
|
-
var reversedOrder = __spreadArray([], InputBase_1.InputBaseDefaultOrder, true).reverse();
|
|
51
|
-
var Switch = function (props) {
|
|
52
|
-
var _a;
|
|
53
|
-
var _b = (0, InputBase_1.selectInputBaseProps)(__assign(__assign({}, exports.Switch.defaultProps), props)), inputBaseProps = _b.inputBaseProps, others = _b.others;
|
|
54
|
-
var style = others.style, value = others.value, disabled = others.disabled, debugName = others.debugName, onValueChange = others.onValueChange, switchOnLeft = others.switchOnLeft;
|
|
55
|
-
var styles = (0, hooks_1.useStylesFor)(exports.Switch.styleRegistryName, style);
|
|
56
|
-
var trackAnimation = (0, __1.useAnimatedVariantStyles)({
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from '../View';
|
|
3
|
+
import { InputBase, InputBaseDefaultOrder, selectInputBaseProps } from '../InputBase';
|
|
4
|
+
import { useAnimatedVariantStyles } from '../..';
|
|
5
|
+
import { Touchable } from '../Touchable';
|
|
6
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
7
|
+
import { useStylesFor } from '../../hooks';
|
|
8
|
+
export * from './styles';
|
|
9
|
+
export * from './types';
|
|
10
|
+
const reversedOrder = [...InputBaseDefaultOrder].reverse();
|
|
11
|
+
export const Switch = (props) => {
|
|
12
|
+
const { inputBaseProps, others, } = selectInputBaseProps({
|
|
13
|
+
...Switch.defaultProps,
|
|
14
|
+
...props,
|
|
15
|
+
});
|
|
16
|
+
const { style, value, disabled, debugName, onValueChange, switchOnLeft, } = others;
|
|
17
|
+
const styles = useStylesFor(Switch.styleRegistryName, style);
|
|
18
|
+
const trackAnimation = useAnimatedVariantStyles({
|
|
57
19
|
variantStyles: styles,
|
|
58
20
|
animatedProperties: ['track:off', 'track:disabled', 'track:on', 'track:disabled-on', 'track:disabled-off'],
|
|
59
21
|
transition: styles['track:transition'],
|
|
60
|
-
updater:
|
|
22
|
+
updater: () => {
|
|
61
23
|
'worklet';
|
|
62
|
-
|
|
24
|
+
let disabledStyle = {};
|
|
63
25
|
if (disabled) {
|
|
64
26
|
disabledStyle = value ? styles['track:disabled-on'] : styles['track:disabled-off'];
|
|
65
27
|
}
|
|
66
|
-
|
|
67
|
-
return
|
|
28
|
+
const style = value ? styles['track:on'] : styles['track:off'];
|
|
29
|
+
return {
|
|
30
|
+
...style,
|
|
31
|
+
...disabledStyle,
|
|
32
|
+
};
|
|
68
33
|
},
|
|
69
34
|
dependencies: [value, disabled],
|
|
70
35
|
});
|
|
71
|
-
|
|
36
|
+
const thumbAnimation = useAnimatedVariantStyles({
|
|
72
37
|
variantStyles: styles,
|
|
73
38
|
animatedProperties: ['thumb:off', 'thumb:disabled', 'thumb:on', 'thumb:disabled-off', 'thumb:disabled-on'],
|
|
74
39
|
transition: styles['thumb:transition'],
|
|
75
|
-
updater:
|
|
40
|
+
updater: () => {
|
|
76
41
|
'worklet';
|
|
77
|
-
|
|
42
|
+
let disabledStyle = {};
|
|
78
43
|
if (disabled) {
|
|
79
44
|
disabledStyle = value ? styles['thumb:disabled-on'] : styles['thumb:disabled-off'];
|
|
80
45
|
}
|
|
81
|
-
|
|
82
|
-
return
|
|
46
|
+
const style = value ? styles['thumb:on'] : styles['thumb:off'];
|
|
47
|
+
return {
|
|
48
|
+
...style,
|
|
49
|
+
...disabledStyle,
|
|
50
|
+
};
|
|
83
51
|
},
|
|
84
52
|
dependencies: [value, disabled],
|
|
85
53
|
});
|
|
86
54
|
// @ts-expect-error
|
|
87
|
-
|
|
88
|
-
return <
|
|
89
|
-
onPress:
|
|
55
|
+
const _switchOnLeft = switchOnLeft ?? styles?.__props?.switchOnLeft;
|
|
56
|
+
return <InputBase {...inputBaseProps} debugName={debugName} wrapper={Touchable} style={styles} wrapperProps={{
|
|
57
|
+
onPress: () => {
|
|
90
58
|
onValueChange(!value);
|
|
91
59
|
},
|
|
92
|
-
disabled
|
|
60
|
+
disabled,
|
|
93
61
|
rippleDisabled: true,
|
|
94
|
-
}} order={_switchOnLeft ? reversedOrder :
|
|
95
|
-
<
|
|
96
|
-
styles
|
|
62
|
+
}} order={_switchOnLeft ? reversedOrder : InputBaseDefaultOrder} disabled={disabled}>
|
|
63
|
+
<View animated animatedStyle={trackAnimation} style={[
|
|
64
|
+
styles?.track,
|
|
97
65
|
disabled && styles['track:disabled'],
|
|
98
66
|
]}>
|
|
99
|
-
<
|
|
100
|
-
styles
|
|
67
|
+
<View animated animatedStyle={thumbAnimation} style={[
|
|
68
|
+
styles?.thumb,
|
|
101
69
|
disabled && styles['thumb:disabled'],
|
|
102
70
|
]}/>
|
|
103
|
-
</
|
|
104
|
-
</
|
|
71
|
+
</View>
|
|
72
|
+
</InputBase>;
|
|
105
73
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return exports.Switch;
|
|
74
|
+
Switch.styleRegistryName = 'Switch';
|
|
75
|
+
Switch.elements = [...InputBase.elements, 'track', 'thumb'];
|
|
76
|
+
Switch.rootElement = 'wrapper';
|
|
77
|
+
Switch.withVariantTypes = (styles) => {
|
|
78
|
+
return Switch;
|
|
112
79
|
};
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
Switch.defaultProps = {};
|
|
81
|
+
MobileStyleRegistry.registerComponent(Switch);
|
|
115
82
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,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,aAAa,GAAG,CAAC,GAAG,qBAAqB,CAAC,CAAC,OAAO,EAAE,CAAA;AAE1D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC3C,MAAM,EACJ,cAAc,EACd,MAAM,GACP,GAAG,oBAAoB,CAAC;QACvB,GAAG,MAAM,CAAC,YAAY;QACtB,GAAG,KAAK;KACT,CAAC,CAAA;IAEF,MAAM,EACJ,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,YAAY,GACb,GAAG,MAAM,CAAA;IAEV,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAE5D,MAAM,cAAc,GAAG,wBAAwB,CAAC;QAC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