@codeleap/mobile 1.9.25 → 1.9.28
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 +123 -15
- package/dist/components/Animated.js +58 -58
- package/dist/components/Animated.js.map +0 -0
- package/dist/components/Button.d.ts +132 -125
- package/dist/components/Button.js +93 -82
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +15 -15
- package/dist/components/Checkbox/index.js +79 -79
- package/dist/components/Checkbox/index.js.map +0 -0
- package/dist/components/Checkbox/styles.d.ts +55 -55
- package/dist/components/Checkbox/styles.js +51 -51
- 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/EmptyPlaceholder.d.ts +12 -0
- package/dist/components/EmptyPlaceholder.js +54 -0
- package/dist/components/EmptyPlaceholder.js.map +1 -0
- package/dist/components/FileInput.d.ts +31 -31
- package/dist/components/FileInput.js +230 -230
- package/dist/components/FileInput.js.map +0 -0
- package/dist/components/Gap.d.ts +8 -0
- package/dist/components/Gap.js +60 -0
- package/dist/components/Gap.js.map +1 -0
- 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 +84 -83
- package/dist/components/List.js.map +1 -1
- package/dist/components/Modal/index.d.ts +27 -26
- package/dist/components/Modal/index.js +113 -112
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +64 -69
- package/dist/components/Modal/styles.js +59 -64
- package/dist/components/Modal/styles.js.map +1 -1
- 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/NewPager/index.d.ts +26 -0
- package/dist/components/NewPager/index.js +88 -0
- package/dist/components/NewPager/index.js.map +1 -0
- package/dist/components/NewPager/styles.d.ts +87 -0
- package/dist/components/NewPager/styles.js +70 -0
- package/dist/components/NewPager/styles.js.map +1 -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 -183
- package/dist/components/TextInput.js +180 -180
- package/dist/components/TextInput.js.map +0 -0
- package/dist/components/Touchable.d.ts +14 -14
- package/dist/components/Touchable.js +75 -75
- package/dist/components/Touchable.js.map +0 -0
- package/dist/components/View.d.ts +123 -120
- package/dist/components/View.js +55 -54
- package/dist/components/View.js.map +1 -1
- package/dist/components/components.d.ts +28 -25
- package/dist/components/components.js +44 -41
- package/dist/components/components.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +30 -28
- package/dist/index.js.map +1 -1
- 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 +9 -12
- 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 +7 -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/ModalManager/components.d.ts +12 -0
- package/dist/utils/ModalManager/components.js +79 -0
- package/dist/utils/ModalManager/components.js.map +1 -0
- package/dist/utils/ModalManager/context.d.ts +42 -0
- package/dist/utils/ModalManager/context.js +172 -0
- package/dist/utils/ModalManager/context.js.map +1 -0
- package/dist/utils/ModalManager/index.d.ts +14 -0
- package/dist/utils/ModalManager/index.js +12 -0
- package/dist/utils/ModalManager/index.js.map +1 -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 +43 -40
- package/src/components/ActivityIndicator.tsx +46 -46
- package/src/components/Animated.tsx +34 -34
- package/src/components/Button.tsx +117 -95
- package/src/components/Checkbox/index.tsx +85 -85
- package/src/components/Checkbox/styles.ts +76 -76
- package/src/components/ContentView.tsx +58 -58
- package/src/components/EmptyPlaceholder.tsx +53 -0
- package/src/components/FileInput.tsx +230 -230
- package/src/components/Gap.tsx +40 -0
- package/src/components/Icon.tsx +58 -58
- package/src/components/Image.tsx +61 -61
- package/src/components/List.tsx +116 -111
- package/src/components/Modal/index.tsx +162 -161
- package/src/components/Modal/styles.ts +126 -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/NewPager/index.tsx +121 -0
- package/src/components/NewPager/styles.ts +76 -0
- 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 +247 -247
- package/src/components/Touchable.tsx +78 -78
- package/src/components/View.tsx +48 -46
- package/src/components/components.ts +28 -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 +9 -13
- package/src/types/utility.ts +3 -3
- package/src/utils/ModalManager/components.tsx +58 -0
- package/src/utils/ModalManager/context.tsx +208 -0
- package/src/utils/ModalManager/index.ts +9 -0
- package/src/utils/OSAlert.ts +180 -180
- package/src/utils/misc.ts +24 -24
- package/src/utils/styles.ts +14 -14
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComponentVariants, FileInputComposition, FileInputStyles, IconPlaceholder, MobileInputFile } from '@codeleap/common';
|
|
3
|
-
import { StylesOf } from '../types/utility';
|
|
4
|
-
import { ButtonProps } from './Button';
|
|
5
|
-
import OSAlert from '../utils/OSAlert';
|
|
6
|
-
import { Options } from 'react-native-image-crop-picker';
|
|
7
|
-
import { DocumentPickerOptions } from '../modules/types/documentPicker';
|
|
8
|
-
export declare type FileInputRef = {
|
|
9
|
-
openFilePicker: (string?: 'camera' | 'library') => void;
|
|
10
|
-
};
|
|
11
|
-
export declare type FileInputProps = {
|
|
12
|
-
label?: string;
|
|
13
|
-
iconName?: IconPlaceholder;
|
|
14
|
-
styles?: StylesOf<FileInputComposition>;
|
|
15
|
-
mode: 'hidden' | 'button';
|
|
16
|
-
variants?: ComponentVariants<typeof FileInputStyles>['variants'];
|
|
17
|
-
onFileSelect(files: MobileInputFile[]): void;
|
|
18
|
-
options?: DocumentPickerOptions<any>;
|
|
19
|
-
buttonProps?: ButtonProps;
|
|
20
|
-
ref?: FileInputRef;
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
type?: 'image' | 'anyFile';
|
|
23
|
-
alertProps?: Parameters<typeof OSAlert.ask>[0];
|
|
24
|
-
pickerOptions?: Partial<Options>;
|
|
25
|
-
required?: boolean;
|
|
26
|
-
onOpenCamera?: (resolve: (() => void)) => Promise<void>;
|
|
27
|
-
onOpenFileSystem?: (resolve: (() => void)) => Promise<void>;
|
|
28
|
-
onOpenGallery?: (resolve: (() => void)) => Promise<void>;
|
|
29
|
-
onError?: (error: any) => void;
|
|
30
|
-
};
|
|
31
|
-
export declare const FileInput: React.ForwardRefExoticComponent<Pick<FileInputProps, "label" | "variants" | "styles" | "onError" | "placeholder" | "type" | "options" | "required" | "buttonProps" | "iconName" | "mode" | "onFileSelect" | "alertProps" | "pickerOptions" | "onOpenCamera" | "onOpenFileSystem" | "onOpenGallery"> & React.RefAttributes<FileInputRef>>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentVariants, FileInputComposition, FileInputStyles, IconPlaceholder, MobileInputFile } from '@codeleap/common';
|
|
3
|
+
import { StylesOf } from '../types/utility';
|
|
4
|
+
import { ButtonProps } from './Button';
|
|
5
|
+
import OSAlert from '../utils/OSAlert';
|
|
6
|
+
import { Options } from 'react-native-image-crop-picker';
|
|
7
|
+
import { DocumentPickerOptions } from '../modules/types/documentPicker';
|
|
8
|
+
export declare type FileInputRef = {
|
|
9
|
+
openFilePicker: (string?: 'camera' | 'library') => void;
|
|
10
|
+
};
|
|
11
|
+
export declare type FileInputProps = {
|
|
12
|
+
label?: string;
|
|
13
|
+
iconName?: IconPlaceholder;
|
|
14
|
+
styles?: StylesOf<FileInputComposition>;
|
|
15
|
+
mode: 'hidden' | 'button';
|
|
16
|
+
variants?: ComponentVariants<typeof FileInputStyles>['variants'];
|
|
17
|
+
onFileSelect(files: MobileInputFile[]): void;
|
|
18
|
+
options?: DocumentPickerOptions<any>;
|
|
19
|
+
buttonProps?: ButtonProps;
|
|
20
|
+
ref?: FileInputRef;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
type?: 'image' | 'anyFile';
|
|
23
|
+
alertProps?: Parameters<typeof OSAlert.ask>[0];
|
|
24
|
+
pickerOptions?: Partial<Options>;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
onOpenCamera?: (resolve: (() => void)) => Promise<void>;
|
|
27
|
+
onOpenFileSystem?: (resolve: (() => void)) => Promise<void>;
|
|
28
|
+
onOpenGallery?: (resolve: (() => void)) => Promise<void>;
|
|
29
|
+
onError?: (error: any) => void;
|
|
30
|
+
};
|
|
31
|
+
export declare const FileInput: React.ForwardRefExoticComponent<Pick<FileInputProps, "label" | "variants" | "styles" | "onError" | "placeholder" | "type" | "options" | "required" | "buttonProps" | "iconName" | "mode" | "onFileSelect" | "alertProps" | "pickerOptions" | "onOpenCamera" | "onOpenFileSystem" | "onOpenGallery"> & React.RefAttributes<FileInputRef>>;
|
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
|
-
};
|
|
75
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
-
exports.FileInput = void 0;
|
|
77
|
-
var react_1 = __importStar(require("react"));
|
|
78
|
-
var documentPicker_1 = require("../modules/documentPicker");
|
|
79
|
-
var common_1 = require("@codeleap/common");
|
|
80
|
-
var Button_1 = require("./Button");
|
|
81
|
-
var View_1 = require("./View");
|
|
82
|
-
var TextInput_1 = require("./TextInput");
|
|
83
|
-
var OSAlert_1 = __importDefault(require("../utils/OSAlert"));
|
|
84
|
-
var pickerDefaults = {
|
|
85
|
-
width: 300,
|
|
86
|
-
height: 400,
|
|
87
|
-
cropping: true,
|
|
88
|
-
};
|
|
89
|
-
function parsePickerData(data) {
|
|
90
|
-
var filePathData = (0, common_1.parseFilePathData)(data.path);
|
|
91
|
-
var d = {
|
|
92
|
-
name: filePathData.name,
|
|
93
|
-
size: data.size,
|
|
94
|
-
type: data.mime,
|
|
95
|
-
uri: data.path,
|
|
96
|
-
fileCopyUri: data.path,
|
|
97
|
-
};
|
|
98
|
-
return {
|
|
99
|
-
file: d,
|
|
100
|
-
preview: data.path,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
exports.FileInput = (0, react_1.forwardRef)(function (fileInputProps, ref) {
|
|
104
|
-
var _a = fileInputProps.mode, mode = _a === void 0 ? 'hidden' : _a, onFileSelect = fileInputProps.onFileSelect, iconName = fileInputProps.iconName, styles = fileInputProps.styles, label = fileInputProps.label, variants = fileInputProps.variants, options = fileInputProps.options, _b = fileInputProps.type, type = _b === void 0 ? 'image' : _b, alertProps = fileInputProps.alertProps, _c = fileInputProps.placeholder, placeholder = _c === void 0 ? 'Select a file' : _c, pickerOptions = fileInputProps.pickerOptions, required = fileInputProps.required, buttonProps = fileInputProps.buttonProps, _d = fileInputProps.onOpenCamera, onOpenCamera = _d === void 0 ? null : _d, _e = fileInputProps.onOpenGallery, onOpenGallery = _e === void 0 ? null : _e, _f = fileInputProps.onOpenFileSystem, onOpenFileSystem = _f === void 0 ? null : _f, onError = fileInputProps.onError;
|
|
105
|
-
var _g = react_1.default.useState(null), file = _g[0], setFile = _g[1];
|
|
106
|
-
var logger = (0, common_1.useCodeleapContext)().logger;
|
|
107
|
-
function openFileSystem() {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
var files, err_1;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
_a.trys.push([0, 2, , 3]);
|
|
114
|
-
return [4 /*yield*/, documentPicker_1.DocumentPicker.pick(options)];
|
|
115
|
-
case 1:
|
|
116
|
-
files = _a.sent();
|
|
117
|
-
if (!Array.isArray(files)) {
|
|
118
|
-
files = [files];
|
|
119
|
-
}
|
|
120
|
-
setFile(files);
|
|
121
|
-
onFileSelect(files.map(function (file) { return ({ preview: file.uri, file: file }); }));
|
|
122
|
-
return [3 /*break*/, 3];
|
|
123
|
-
case 2:
|
|
124
|
-
err_1 = _a.sent();
|
|
125
|
-
handleError(err_1);
|
|
126
|
-
return [3 /*break*/, 3];
|
|
127
|
-
case 3: return [2 /*return*/];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function handleError(err) {
|
|
133
|
-
var warn = documentPicker_1.DocumentPicker.isCancel(err) || String(err).includes('Error: User cancelled');
|
|
134
|
-
if (warn) {
|
|
135
|
-
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
136
|
-
logger.warn(err);
|
|
137
|
-
console.warn(err);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
141
|
-
logger.error(err);
|
|
142
|
-
console.warn(err);
|
|
143
|
-
if (onError) {
|
|
144
|
-
onError(err);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
OSAlert_1.default.error({
|
|
148
|
-
title: 'Error',
|
|
149
|
-
body: err.message,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
|
|
155
|
-
var handlePickerResolution = function (data) {
|
|
156
|
-
onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
|
|
157
|
-
parsePickerData(data),
|
|
158
|
-
]);
|
|
159
|
-
};
|
|
160
|
-
var onPress = function (open, options) {
|
|
161
|
-
if (open == 'fs') {
|
|
162
|
-
openFileSystem();
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
var call = open === 'camera' ? 'openCamera' : 'openPicker';
|
|
166
|
-
documentPicker_1.ImageCropPicker[call](__assign(__assign({}, mergedOptions), (options || {}))).then(handlePickerResolution);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
var openFilePicker = function (imageSource) {
|
|
170
|
-
if (imageSource === void 0) { imageSource = null; }
|
|
171
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
-
var _a, _b;
|
|
173
|
-
return __generator(this, function (_c) {
|
|
174
|
-
if (type === 'image') {
|
|
175
|
-
if (imageSource === 'camera') {
|
|
176
|
-
onPress('camera');
|
|
177
|
-
}
|
|
178
|
-
else if (imageSource === 'library') {
|
|
179
|
-
onPress('library');
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
OSAlert_1.default.ask(__assign(__assign({ title: 'Change Image', body: 'Do you want to take a new picture or select an existing one?' }, alertProps), { options: [
|
|
183
|
-
__assign({ text: ((_b = (_a = alertProps === null || alertProps === void 0 ? void 0 : alertProps.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || 'Camera', onPress: function () {
|
|
184
|
-
if (onOpenCamera) {
|
|
185
|
-
onOpenCamera(function () { return onPress('camera'); });
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
onPress('camera');
|
|
189
|
-
}
|
|
190
|
-
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
|
|
191
|
-
__assign({ text: 'Library', onPress: function () {
|
|
192
|
-
if (onOpenGallery) {
|
|
193
|
-
onOpenGallery(function () { return onPress('library'); });
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
onPress('library');
|
|
197
|
-
}
|
|
198
|
-
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
|
|
199
|
-
__assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
|
|
200
|
-
] }));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
if (onOpenFileSystem) {
|
|
205
|
-
onOpenFileSystem(function () { return onPress('fs'); });
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
onPress('fs');
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return [2 /*return*/];
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
|
|
216
|
-
styles: styles,
|
|
217
|
-
variants: variants,
|
|
218
|
-
});
|
|
219
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
220
|
-
openFilePicker: openFilePicker,
|
|
221
|
-
}); });
|
|
222
|
-
var filenames = file ? file.map(function (f) { return f.name; }) : '';
|
|
223
|
-
if (mode === 'button') {
|
|
224
|
-
return (<View_1.View style={variantStyles.wrapper}>
|
|
225
|
-
<TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
|
|
226
|
-
<Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
|
|
227
|
-
</View_1.View>);
|
|
228
|
-
}
|
|
229
|
-
return null;
|
|
230
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
73
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
74
|
+
};
|
|
75
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
76
|
+
exports.FileInput = void 0;
|
|
77
|
+
var react_1 = __importStar(require("react"));
|
|
78
|
+
var documentPicker_1 = require("../modules/documentPicker");
|
|
79
|
+
var common_1 = require("@codeleap/common");
|
|
80
|
+
var Button_1 = require("./Button");
|
|
81
|
+
var View_1 = require("./View");
|
|
82
|
+
var TextInput_1 = require("./TextInput");
|
|
83
|
+
var OSAlert_1 = __importDefault(require("../utils/OSAlert"));
|
|
84
|
+
var pickerDefaults = {
|
|
85
|
+
width: 300,
|
|
86
|
+
height: 400,
|
|
87
|
+
cropping: true,
|
|
88
|
+
};
|
|
89
|
+
function parsePickerData(data) {
|
|
90
|
+
var filePathData = (0, common_1.parseFilePathData)(data.path);
|
|
91
|
+
var d = {
|
|
92
|
+
name: filePathData.name,
|
|
93
|
+
size: data.size,
|
|
94
|
+
type: data.mime,
|
|
95
|
+
uri: data.path,
|
|
96
|
+
fileCopyUri: data.path,
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
file: d,
|
|
100
|
+
preview: data.path,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
exports.FileInput = (0, react_1.forwardRef)(function (fileInputProps, ref) {
|
|
104
|
+
var _a = fileInputProps.mode, mode = _a === void 0 ? 'hidden' : _a, onFileSelect = fileInputProps.onFileSelect, iconName = fileInputProps.iconName, styles = fileInputProps.styles, label = fileInputProps.label, variants = fileInputProps.variants, options = fileInputProps.options, _b = fileInputProps.type, type = _b === void 0 ? 'image' : _b, alertProps = fileInputProps.alertProps, _c = fileInputProps.placeholder, placeholder = _c === void 0 ? 'Select a file' : _c, pickerOptions = fileInputProps.pickerOptions, required = fileInputProps.required, buttonProps = fileInputProps.buttonProps, _d = fileInputProps.onOpenCamera, onOpenCamera = _d === void 0 ? null : _d, _e = fileInputProps.onOpenGallery, onOpenGallery = _e === void 0 ? null : _e, _f = fileInputProps.onOpenFileSystem, onOpenFileSystem = _f === void 0 ? null : _f, onError = fileInputProps.onError;
|
|
105
|
+
var _g = react_1.default.useState(null), file = _g[0], setFile = _g[1];
|
|
106
|
+
var logger = (0, common_1.useCodeleapContext)().logger;
|
|
107
|
+
function openFileSystem() {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
+
var files, err_1;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
_a.trys.push([0, 2, , 3]);
|
|
114
|
+
return [4 /*yield*/, documentPicker_1.DocumentPicker.pick(options)];
|
|
115
|
+
case 1:
|
|
116
|
+
files = _a.sent();
|
|
117
|
+
if (!Array.isArray(files)) {
|
|
118
|
+
files = [files];
|
|
119
|
+
}
|
|
120
|
+
setFile(files);
|
|
121
|
+
onFileSelect(files.map(function (file) { return ({ preview: file.uri, file: file }); }));
|
|
122
|
+
return [3 /*break*/, 3];
|
|
123
|
+
case 2:
|
|
124
|
+
err_1 = _a.sent();
|
|
125
|
+
handleError(err_1);
|
|
126
|
+
return [3 /*break*/, 3];
|
|
127
|
+
case 3: return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function handleError(err) {
|
|
133
|
+
var warn = documentPicker_1.DocumentPicker.isCancel(err) || String(err).includes('Error: User cancelled');
|
|
134
|
+
if (warn) {
|
|
135
|
+
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
136
|
+
logger.warn(err);
|
|
137
|
+
console.warn(err);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
141
|
+
logger.error(err);
|
|
142
|
+
console.warn(err);
|
|
143
|
+
if (onError) {
|
|
144
|
+
onError(err);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
OSAlert_1.default.error({
|
|
148
|
+
title: 'Error',
|
|
149
|
+
body: err.message,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
var mergedOptions = __assign(__assign({}, pickerDefaults), pickerOptions);
|
|
155
|
+
var handlePickerResolution = function (data) {
|
|
156
|
+
onFileSelect(mergedOptions.multiple ? data.map(parsePickerData) : [
|
|
157
|
+
parsePickerData(data),
|
|
158
|
+
]);
|
|
159
|
+
};
|
|
160
|
+
var onPress = function (open, options) {
|
|
161
|
+
if (open == 'fs') {
|
|
162
|
+
openFileSystem();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
var call = open === 'camera' ? 'openCamera' : 'openPicker';
|
|
166
|
+
documentPicker_1.ImageCropPicker[call](__assign(__assign({}, mergedOptions), (options || {}))).then(handlePickerResolution);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var openFilePicker = function (imageSource) {
|
|
170
|
+
if (imageSource === void 0) { imageSource = null; }
|
|
171
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
return __generator(this, function (_c) {
|
|
174
|
+
if (type === 'image') {
|
|
175
|
+
if (imageSource === 'camera') {
|
|
176
|
+
onPress('camera');
|
|
177
|
+
}
|
|
178
|
+
else if (imageSource === 'library') {
|
|
179
|
+
onPress('library');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
OSAlert_1.default.ask(__assign(__assign({ title: 'Change Image', body: 'Do you want to take a new picture or select an existing one?' }, alertProps), { options: [
|
|
183
|
+
__assign({ text: ((_b = (_a = alertProps === null || alertProps === void 0 ? void 0 : alertProps.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) || 'Camera', onPress: function () {
|
|
184
|
+
if (onOpenCamera) {
|
|
185
|
+
onOpenCamera(function () { return onPress('camera'); });
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
onPress('camera');
|
|
189
|
+
}
|
|
190
|
+
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[1]),
|
|
191
|
+
__assign({ text: 'Library', onPress: function () {
|
|
192
|
+
if (onOpenGallery) {
|
|
193
|
+
onOpenGallery(function () { return onPress('library'); });
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
onPress('library');
|
|
197
|
+
}
|
|
198
|
+
} }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[2]),
|
|
199
|
+
__assign({ text: 'Cancel', style: 'cancel', onPress: function () { } }, alertProps === null || alertProps === void 0 ? void 0 : alertProps.options[0]),
|
|
200
|
+
] }));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
if (onOpenFileSystem) {
|
|
205
|
+
onOpenFileSystem(function () { return onPress('fs'); });
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
onPress('fs');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return [2 /*return*/];
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
var variantStyles = (0, common_1.useDefaultComponentStyle)('FileInput', {
|
|
216
|
+
styles: styles,
|
|
217
|
+
variants: variants,
|
|
218
|
+
});
|
|
219
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
220
|
+
openFilePicker: openFilePicker,
|
|
221
|
+
}); });
|
|
222
|
+
var filenames = file ? file.map(function (f) { return f.name; }) : '';
|
|
223
|
+
if (mode === 'button') {
|
|
224
|
+
return (<View_1.View style={variantStyles.wrapper}>
|
|
225
|
+
<TextInput_1.InputLabel label={label} style={variantStyles.label} required={required}/>
|
|
226
|
+
<Button_1.Button onPress={function () { return openFilePicker(); }} text={filenames || placeholder} debugName={'Open file picker'} icon={iconName || 'fileInputButton'} variants={filenames ? '' : 'icon'} {...buttonProps}/>
|
|
227
|
+
</View_1.View>);
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
});
|
|
231
231
|
//# sourceMappingURL=FileInput.js.map
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.Gap = void 0;
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var common_1 = require("@codeleap/common");
|
|
31
|
+
var View_1 = require("./View");
|
|
32
|
+
var Gap = function (_a) {
|
|
33
|
+
var _b;
|
|
34
|
+
var children = _a.children, value = _a.value, _c = _a.defaultProps, defaultProps = _c === void 0 ? {} : _c, props = __rest(_a, ["children", "value", "defaultProps"]);
|
|
35
|
+
var Theme = (0, common_1.useCodeleapContext)().Theme;
|
|
36
|
+
var horizontal = (_b = props.variants) === null || _b === void 0 ? void 0 : _b.includes('row');
|
|
37
|
+
return (<View_1.View {...props}>
|
|
38
|
+
{react_1.default.Children.toArray(children).map(function (Element, idx, childArr) {
|
|
39
|
+
if (react_1.default.isValidElement(Element)) {
|
|
40
|
+
var props_1 = __assign(__assign({}, Element.props), defaultProps);
|
|
41
|
+
var spacingFunction = horizontal ? 'marginHorizontal' : 'marginVertical';
|
|
42
|
+
switch (idx) {
|
|
43
|
+
case 0:
|
|
44
|
+
spacingFunction = horizontal ? 'marginRight' : 'marginBottom';
|
|
45
|
+
break;
|
|
46
|
+
case childArr.length - 1:
|
|
47
|
+
spacingFunction = horizontal ? 'marginLeft' : 'marginTop';
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
props_1.style = [props_1.style, Theme.spacing[spacingFunction](value / 2)];
|
|
53
|
+
return react_1.default.cloneElement(Element, props_1);
|
|
54
|
+
}
|
|
55
|
+
return Element;
|
|
56
|
+
})}
|
|
57
|
+
</View_1.View>);
|
|
58
|
+
};
|
|
59
|
+
exports.Gap = Gap;
|
|
60
|
+
//# sourceMappingURL=Gap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Gap.js","sourceRoot":"","sources":["../../src/components/Gap.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAyB;AACzB,2CAAqD;AACrD,+BAAwC;AAQjC,IAAM,GAAG,GAAsB,UAAC,EAAgD;;IAA9C,IAAA,QAAQ,cAAA,EAAE,KAAK,WAAA,EAAE,oBAAiB,EAAjB,YAAY,mBAAG,EAAE,KAAA,EAAK,KAAK,cAA9C,qCAAgD,CAAF;IAC3E,IAAA,KAAK,GAAK,IAAA,2BAAkB,GAAE,MAAzB,CAAyB;IACtC,IAAM,UAAU,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IAClD,OAAO,CACL,CAAC,WAAI,CAAC,IAAI,KAAK,CAAC,CACd;MAAA,CACE,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,GAAG,EAAE,QAAQ;YAC1D,IAAI,eAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;gBACjC,IAAM,OAAK,yBAAQ,OAAO,CAAC,KAAK,GAAK,YAAY,CAAE,CAAA;gBAEnD,IAAI,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAA;gBACxE,QAAQ,GAAG,EAAE;oBACX,KAAK,CAAC;wBACJ,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAA;wBAC7D,MAAK;oBACP,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC;wBACtB,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAA;wBACzD,MAAK;oBACP;wBACE,MAAK;iBACR;gBACD,OAAK,CAAC,KAAK,GAAG,CAAC,OAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;gBACtE,OAAO,eAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAK,CAAC,CAAA;aAC1C;YACD,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAEN;IAAA,EAAE,WAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AA7BY,QAAA,GAAG,OA6Bf"}
|
|
@@ -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>;
|