@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AnyFunction } from '@codeleap/common';
|
|
3
|
+
export declare type AppModalProps = {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
attachments: string[];
|
|
6
|
+
attachedTo: string[];
|
|
7
|
+
};
|
|
8
|
+
declare type TModalState = AppModalProps;
|
|
9
|
+
declare type ModalTransitionOptions = {
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
declare type TModalContext = {
|
|
13
|
+
state: Record<string, TModalState>;
|
|
14
|
+
toggleModal: (name: string, setTo?: boolean) => void;
|
|
15
|
+
setModal: (name: string, to: Partial<TModalState>) => void;
|
|
16
|
+
currentModal: string;
|
|
17
|
+
isVisible: (name: string) => boolean;
|
|
18
|
+
transition: (from: string, to: string, options?: ModalTransitionOptions) => Promise<void>;
|
|
19
|
+
attach: (modal: string, to: string) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function Provider({ children }: {
|
|
22
|
+
children: any;
|
|
23
|
+
}): JSX.Element;
|
|
24
|
+
export declare function useModalContext(): TModalContext;
|
|
25
|
+
export declare type UseModalSequenceOptions = {
|
|
26
|
+
onFinish?: AnyFunction;
|
|
27
|
+
resetOnFinish?: boolean;
|
|
28
|
+
closeLastOnFinish?: boolean;
|
|
29
|
+
waitForLastToCloseBeforeCallingFinish?: boolean;
|
|
30
|
+
transitionOpts?: Partial<Parameters<TModalContext['transition']>[2]>;
|
|
31
|
+
};
|
|
32
|
+
export declare function useModalSequence(ids: string[], options?: UseModalSequenceOptions): {
|
|
33
|
+
currentId: string;
|
|
34
|
+
nextId: string;
|
|
35
|
+
previousId: string;
|
|
36
|
+
reset: () => void;
|
|
37
|
+
next: () => void;
|
|
38
|
+
previous: () => void;
|
|
39
|
+
setModal: React.Dispatch<React.SetStateAction<number>>;
|
|
40
|
+
currentIdx: number;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.useModalSequence = exports.useModalContext = exports.Provider = void 0;
|
|
38
|
+
var React = __importStar(require("react"));
|
|
39
|
+
var common_1 = require("@codeleap/common");
|
|
40
|
+
var portal_1 = require("@gorhom/portal");
|
|
41
|
+
var ModalContext = React.createContext({});
|
|
42
|
+
function Provider(_a) {
|
|
43
|
+
var children = _a.children;
|
|
44
|
+
var _b = (0, common_1.useState)({}), modals = _b[0], setModals = _b[1];
|
|
45
|
+
var currentModal = Object.keys(modals).find(function (name) { return modals[name].visible; });
|
|
46
|
+
function isVisible(name) {
|
|
47
|
+
var _a;
|
|
48
|
+
return !!((_a = modals[name]) === null || _a === void 0 ? void 0 : _a.visible);
|
|
49
|
+
}
|
|
50
|
+
var toggleModal = function (name, set) {
|
|
51
|
+
var visible = isVisible(name);
|
|
52
|
+
var newVisible = typeof set === 'boolean' ? set : !visible;
|
|
53
|
+
setModals(function (current) {
|
|
54
|
+
var _a;
|
|
55
|
+
var attached = newVisible ? [] : current[name].attachments.map(function (m) { return [m, __assign(__assign({}, current[m]), { visible: false })]; });
|
|
56
|
+
return __assign(__assign(__assign({}, current), (_a = {}, _a[name] = __assign(__assign({}, current[name]), { visible: newVisible }), _a)), Object.fromEntries(attached));
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
var setModal = function (name, to) {
|
|
60
|
+
setModals(function (current) {
|
|
61
|
+
var _a;
|
|
62
|
+
return (__assign(__assign({}, current), (_a = {}, _a[name] = __assign(__assign({}, current[name]), to), _a)));
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var codeleapCtx = (0, common_1.useCodeleapContext)();
|
|
66
|
+
var transition = function (from, to, options) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
var _options = __assign({ duration: ((_b = (_a = codeleapCtx === null || codeleapCtx === void 0 ? void 0 : codeleapCtx.Theme) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.modalTransitionDuration) || 300 }, options);
|
|
69
|
+
var toVisible = isVisible(to);
|
|
70
|
+
var fromVisible = isVisible(from);
|
|
71
|
+
if (toVisible)
|
|
72
|
+
return;
|
|
73
|
+
if (!fromVisible && !toVisible) {
|
|
74
|
+
toggleModal(to);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
toggleModal(from);
|
|
78
|
+
return new Promise(function (resolve) {
|
|
79
|
+
setTimeout(function () {
|
|
80
|
+
if (to) {
|
|
81
|
+
toggleModal(to);
|
|
82
|
+
}
|
|
83
|
+
resolve();
|
|
84
|
+
}, _options.duration);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
function attach(modal, to) {
|
|
88
|
+
setModals(function (modals) {
|
|
89
|
+
var toModal = modals[to];
|
|
90
|
+
var _modal = modals[modal];
|
|
91
|
+
if (!toModal || !_modal)
|
|
92
|
+
return modals;
|
|
93
|
+
var isAttached = toModal.attachments.includes(modal) || _modal.attachedTo.includes(to);
|
|
94
|
+
var newVal = __assign({}, modals);
|
|
95
|
+
if (isAttached) {
|
|
96
|
+
newVal[to].attachments = newVal[to].attachments.filter(function (x) { return x !== modal; });
|
|
97
|
+
newVal[modal].attachedTo = newVal[modal].attachedTo.filter(function (x) { return x !== to; });
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
newVal[to].attachments.push(modal);
|
|
101
|
+
newVal[modal].attachedTo.push(to);
|
|
102
|
+
}
|
|
103
|
+
return newVal;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return <ModalContext.Provider value={{
|
|
107
|
+
state: modals,
|
|
108
|
+
toggleModal: toggleModal,
|
|
109
|
+
setModal: setModal,
|
|
110
|
+
currentModal: currentModal,
|
|
111
|
+
attach: attach,
|
|
112
|
+
isVisible: isVisible,
|
|
113
|
+
transition: transition,
|
|
114
|
+
}}>
|
|
115
|
+
<portal_1.PortalProvider>
|
|
116
|
+
|
|
117
|
+
{children}
|
|
118
|
+
</portal_1.PortalProvider>
|
|
119
|
+
</ModalContext.Provider>;
|
|
120
|
+
}
|
|
121
|
+
exports.Provider = Provider;
|
|
122
|
+
function useModalContext() {
|
|
123
|
+
var context = React.useContext(ModalContext);
|
|
124
|
+
return context;
|
|
125
|
+
}
|
|
126
|
+
exports.useModalContext = useModalContext;
|
|
127
|
+
function useModalSequence(ids, options) {
|
|
128
|
+
var _options = __assign({ closeLastOnFinish: true, onFinish: function () { }, resetOnFinish: false, waitForLastToCloseBeforeCallingFinish: true }, options);
|
|
129
|
+
var modals = useModalContext();
|
|
130
|
+
var _a = (0, common_1.useState)(0), idx = _a[0], setIdx = _a[1];
|
|
131
|
+
var state = {
|
|
132
|
+
currentId: ids[idx],
|
|
133
|
+
nextId: ids[idx + 1],
|
|
134
|
+
previousId: ids[idx - 1],
|
|
135
|
+
};
|
|
136
|
+
function next() {
|
|
137
|
+
if (idx === ids.length - 1) {
|
|
138
|
+
if (_options.closeLastOnFinish) {
|
|
139
|
+
modals.transition(ids[idx], null).then(function () {
|
|
140
|
+
if (_options.waitForLastToCloseBeforeCallingFinish) {
|
|
141
|
+
_options.onFinish();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (_options.resetOnFinish) {
|
|
146
|
+
reset();
|
|
147
|
+
}
|
|
148
|
+
if (!(_options.waitForLastToCloseBeforeCallingFinish && _options.closeLastOnFinish)) {
|
|
149
|
+
_options.onFinish();
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (!state.nextId)
|
|
155
|
+
return;
|
|
156
|
+
modals.transition(ids[idx], ids[idx + 1]);
|
|
157
|
+
setIdx(function (i) { return i + 1; });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function previous() {
|
|
161
|
+
if (!state.previousId)
|
|
162
|
+
return;
|
|
163
|
+
modals.transition(ids[idx], ids[idx - 1]);
|
|
164
|
+
setIdx(function (i) { return i - 1; });
|
|
165
|
+
}
|
|
166
|
+
function reset() {
|
|
167
|
+
setIdx(0);
|
|
168
|
+
}
|
|
169
|
+
return __assign({ reset: reset, next: next, previous: previous, setModal: setIdx, currentIdx: idx }, state);
|
|
170
|
+
}
|
|
171
|
+
exports.useModalSequence = useModalSequence;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B,CAAC,EAAE;gBACnF,QAAQ,CAAC,QAAQ,EAAE,CAAA;aACpB;YACD,OAAM;SACP;aAAM;YACL,IAAI,CAAC,KAAK,CAAC,MAAM;gBAAE,OAAM;YACzB,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YACzC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC,CAAA;SACnB;IACH,CAAC;IACD,SAAS,QAAQ;QACf,IAAI,CAAC,KAAK,CAAC,UAAU;YAAE,OAAM;QAC7B,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QACzC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,CAAC,CAAA;IAEpB,CAAC;IACD,SAAS,KAAK;QACZ,MAAM,CAAC,CAAC,CAAC,CAAA;IACX,CAAC;IAED,kBACE,KAAK,OAAA,EACL,IAAI,MAAA,EACJ,QAAQ,UAAA,EACR,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,GAAG,IACZ,KAAK,EAET;AAEH,CAAC;AA5DD,4CA4DC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { useModalContext, useModalSequence, Provider } from './context';
|
|
3
|
+
export declare const ModalManager: {
|
|
4
|
+
useModalContext: typeof useModalContext;
|
|
5
|
+
AbsoluteModal: import("react").FC<Omit<import("../..").ModalProps, "visible" | "toggle"> & {
|
|
6
|
+
id?: string;
|
|
7
|
+
initialVisible?: boolean;
|
|
8
|
+
parent?: string;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
toggle?: () => void;
|
|
11
|
+
}>;
|
|
12
|
+
Provider: typeof Provider;
|
|
13
|
+
useModalSequence: typeof useModalSequence;
|
|
14
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModalManager = void 0;
|
|
4
|
+
var context_1 = require("./context");
|
|
5
|
+
var components_1 = require("./components");
|
|
6
|
+
exports.ModalManager = {
|
|
7
|
+
useModalContext: context_1.useModalContext,
|
|
8
|
+
AbsoluteModal: components_1.AbsoluteModal,
|
|
9
|
+
Provider: context_1.Provider,
|
|
10
|
+
useModalSequence: context_1.useModalSequence,
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/ModalManager/index.ts"],"names":[],"mappings":";;;AAAA,qCAAuE;AACvE,2CAA4C;AAE/B,QAAA,YAAY,GAAG;IAC1B,eAAe,2BAAA;IACf,aAAa,4BAAA;IACb,QAAQ,oBAAA;IACR,gBAAgB,4BAAA;CACjB,CAAA"}
|
package/dist/utils/OSAlert.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { Alert, AlertButton } from 'react-native';
|
|
2
|
-
/**
|
|
3
|
-
* Alert.{function} receives three parameters, the last one being an object:
|
|
4
|
-
*
|
|
5
|
-
* @param {string} title text to appear in title
|
|
6
|
-
* @param {string} body text to appear in body
|
|
7
|
-
* @param {object} options array of buttons and callbacks
|
|
8
|
-
*
|
|
9
|
-
* options properties
|
|
10
|
-
* @property {string} name object description
|
|
11
|
-
* @property {function} run callback function to run on press
|
|
12
|
-
*/
|
|
13
|
-
declare type NativeAlertArgs = Parameters<typeof Alert.alert>;
|
|
14
|
-
declare type OSAlertArgs = {
|
|
15
|
-
title: NativeAlertArgs['0'];
|
|
16
|
-
body?: NativeAlertArgs['1'];
|
|
17
|
-
options?: NativeAlertArgs['2'];
|
|
18
|
-
};
|
|
19
|
-
declare type AlertEvent = AlertButton['onPress'];
|
|
20
|
-
declare type NamedEvents<E extends string> = Partial<Record<E, AlertEvent>>;
|
|
21
|
-
declare function ask({ title, body, options }: OSAlertArgs): void;
|
|
22
|
-
declare function warn(args: OSAlertArgs & NamedEvents<'onReject' | 'onAccept'>): void;
|
|
23
|
-
declare function info(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
24
|
-
declare function OSError(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
25
|
-
declare const _default: {
|
|
26
|
-
ask: typeof ask;
|
|
27
|
-
warn: typeof warn;
|
|
28
|
-
info: typeof info;
|
|
29
|
-
error: typeof OSError;
|
|
30
|
-
};
|
|
31
|
-
export default _default;
|
|
1
|
+
import { Alert, AlertButton } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Alert.{function} receives three parameters, the last one being an object:
|
|
4
|
+
*
|
|
5
|
+
* @param {string} title text to appear in title
|
|
6
|
+
* @param {string} body text to appear in body
|
|
7
|
+
* @param {object} options array of buttons and callbacks
|
|
8
|
+
*
|
|
9
|
+
* options properties
|
|
10
|
+
* @property {string} name object description
|
|
11
|
+
* @property {function} run callback function to run on press
|
|
12
|
+
*/
|
|
13
|
+
declare type NativeAlertArgs = Parameters<typeof Alert.alert>;
|
|
14
|
+
declare type OSAlertArgs = {
|
|
15
|
+
title: NativeAlertArgs['0'];
|
|
16
|
+
body?: NativeAlertArgs['1'];
|
|
17
|
+
options?: NativeAlertArgs['2'];
|
|
18
|
+
};
|
|
19
|
+
declare type AlertEvent = AlertButton['onPress'];
|
|
20
|
+
declare type NamedEvents<E extends string> = Partial<Record<E, AlertEvent>>;
|
|
21
|
+
declare function ask({ title, body, options }: OSAlertArgs): void;
|
|
22
|
+
declare function warn(args: OSAlertArgs & NamedEvents<'onReject' | 'onAccept'>): void;
|
|
23
|
+
declare function info(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
24
|
+
declare function OSError(args: OSAlertArgs & NamedEvents<'onDismiss'>): void;
|
|
25
|
+
declare const _default: {
|
|
26
|
+
ask: typeof ask;
|
|
27
|
+
warn: typeof warn;
|
|
28
|
+
info: typeof info;
|
|
29
|
+
error: typeof OSError;
|
|
30
|
+
};
|
|
31
|
+
export default _default;
|
package/dist/utils/OSAlert.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
/* eslint no-restricted-imports: 'off' */
|
|
15
|
-
/* eslint prefer-const: 'off' */
|
|
16
|
-
var react_native_1 = require("react-native");
|
|
17
|
-
var currentAlerts = {};
|
|
18
|
-
function generateAlertID(from) {
|
|
19
|
-
return [
|
|
20
|
-
from.type,
|
|
21
|
-
from.title,
|
|
22
|
-
from.body,
|
|
23
|
-
].join('-');
|
|
24
|
-
}
|
|
25
|
-
function shouldShowAlert(args, type) {
|
|
26
|
-
var alertId = generateAlertID(__assign(__assign({}, args), { type: type }));
|
|
27
|
-
if (!Object.keys(currentAlerts).includes(alertId)) {
|
|
28
|
-
currentAlerts[alertId] = true;
|
|
29
|
-
return alertId;
|
|
30
|
-
}
|
|
31
|
-
return '';
|
|
32
|
-
}
|
|
33
|
-
function popAlert(id) {
|
|
34
|
-
delete currentAlerts[id];
|
|
35
|
-
}
|
|
36
|
-
function ask(_a) {
|
|
37
|
-
var title = _a.title, body = _a.body, _b = _a.options, options = _b === void 0 ? null : _b;
|
|
38
|
-
if (!title) {
|
|
39
|
-
title = 'Quick quetion';
|
|
40
|
-
}
|
|
41
|
-
OSAlert({
|
|
42
|
-
title: title,
|
|
43
|
-
body: body,
|
|
44
|
-
options: options,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function warn(args) {
|
|
48
|
-
var id = shouldShowAlert(args, 'warn');
|
|
49
|
-
if (!id)
|
|
50
|
-
return;
|
|
51
|
-
var title = args.title, body = args.body, onAccept = args.onAccept, onReject = args.onReject;
|
|
52
|
-
if (!title) {
|
|
53
|
-
title = 'Hang on';
|
|
54
|
-
}
|
|
55
|
-
if (!body) {
|
|
56
|
-
body = 'Are you sure?';
|
|
57
|
-
}
|
|
58
|
-
if (!onReject) {
|
|
59
|
-
onReject = function () { return null; };
|
|
60
|
-
}
|
|
61
|
-
OSAlert({
|
|
62
|
-
title: title,
|
|
63
|
-
body: body,
|
|
64
|
-
options: [
|
|
65
|
-
{
|
|
66
|
-
text: 'Cancel',
|
|
67
|
-
onPress: function () {
|
|
68
|
-
popAlert(id);
|
|
69
|
-
onReject();
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
text: 'OK',
|
|
74
|
-
style: 'destructive',
|
|
75
|
-
onPress: function () {
|
|
76
|
-
popAlert(id);
|
|
77
|
-
onAccept === null || onAccept === void 0 ? void 0 : onAccept();
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function info(args) {
|
|
84
|
-
var id = shouldShowAlert(args, 'info');
|
|
85
|
-
if (!id)
|
|
86
|
-
return;
|
|
87
|
-
var title = args.title, body = args.body, _a = args.onDismiss, onDismiss = _a === void 0 ? function () { return null; } : _a;
|
|
88
|
-
if (!title) {
|
|
89
|
-
title = 'FYI';
|
|
90
|
-
}
|
|
91
|
-
OSAlert({
|
|
92
|
-
title: title,
|
|
93
|
-
body: body,
|
|
94
|
-
options: [
|
|
95
|
-
{
|
|
96
|
-
text: 'OK',
|
|
97
|
-
onPress: function () {
|
|
98
|
-
popAlert(id);
|
|
99
|
-
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function OSError(args) {
|
|
106
|
-
var id = shouldShowAlert(args, 'error');
|
|
107
|
-
if (!id)
|
|
108
|
-
return;
|
|
109
|
-
var title = args.title, body = args.body;
|
|
110
|
-
if (!title) {
|
|
111
|
-
title = 'Whoops!';
|
|
112
|
-
}
|
|
113
|
-
if (!body) {
|
|
114
|
-
body = 'Something went wrong';
|
|
115
|
-
}
|
|
116
|
-
OSAlert({
|
|
117
|
-
title: title,
|
|
118
|
-
body: body,
|
|
119
|
-
options: [
|
|
120
|
-
{
|
|
121
|
-
text: 'OK',
|
|
122
|
-
onPress: function () {
|
|
123
|
-
var _a;
|
|
124
|
-
popAlert(id);
|
|
125
|
-
(_a = args === null || args === void 0 ? void 0 : args.onDismiss) === null || _a === void 0 ? void 0 : _a.call(args);
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function OSAlert(params) {
|
|
132
|
-
react_native_1.Alert.alert(params.title, params.body, params.options, {
|
|
133
|
-
cancelable: false,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
exports.default = {
|
|
137
|
-
ask: ask,
|
|
138
|
-
warn: warn,
|
|
139
|
-
info: info,
|
|
140
|
-
error: OSError,
|
|
141
|
-
};
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
/* eslint no-restricted-imports: 'off' */
|
|
15
|
+
/* eslint prefer-const: 'off' */
|
|
16
|
+
var react_native_1 = require("react-native");
|
|
17
|
+
var currentAlerts = {};
|
|
18
|
+
function generateAlertID(from) {
|
|
19
|
+
return [
|
|
20
|
+
from.type,
|
|
21
|
+
from.title,
|
|
22
|
+
from.body,
|
|
23
|
+
].join('-');
|
|
24
|
+
}
|
|
25
|
+
function shouldShowAlert(args, type) {
|
|
26
|
+
var alertId = generateAlertID(__assign(__assign({}, args), { type: type }));
|
|
27
|
+
if (!Object.keys(currentAlerts).includes(alertId)) {
|
|
28
|
+
currentAlerts[alertId] = true;
|
|
29
|
+
return alertId;
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
function popAlert(id) {
|
|
34
|
+
delete currentAlerts[id];
|
|
35
|
+
}
|
|
36
|
+
function ask(_a) {
|
|
37
|
+
var title = _a.title, body = _a.body, _b = _a.options, options = _b === void 0 ? null : _b;
|
|
38
|
+
if (!title) {
|
|
39
|
+
title = 'Quick quetion';
|
|
40
|
+
}
|
|
41
|
+
OSAlert({
|
|
42
|
+
title: title,
|
|
43
|
+
body: body,
|
|
44
|
+
options: options,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function warn(args) {
|
|
48
|
+
var id = shouldShowAlert(args, 'warn');
|
|
49
|
+
if (!id)
|
|
50
|
+
return;
|
|
51
|
+
var title = args.title, body = args.body, onAccept = args.onAccept, onReject = args.onReject;
|
|
52
|
+
if (!title) {
|
|
53
|
+
title = 'Hang on';
|
|
54
|
+
}
|
|
55
|
+
if (!body) {
|
|
56
|
+
body = 'Are you sure?';
|
|
57
|
+
}
|
|
58
|
+
if (!onReject) {
|
|
59
|
+
onReject = function () { return null; };
|
|
60
|
+
}
|
|
61
|
+
OSAlert({
|
|
62
|
+
title: title,
|
|
63
|
+
body: body,
|
|
64
|
+
options: [
|
|
65
|
+
{
|
|
66
|
+
text: 'Cancel',
|
|
67
|
+
onPress: function () {
|
|
68
|
+
popAlert(id);
|
|
69
|
+
onReject();
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
text: 'OK',
|
|
74
|
+
style: 'destructive',
|
|
75
|
+
onPress: function () {
|
|
76
|
+
popAlert(id);
|
|
77
|
+
onAccept === null || onAccept === void 0 ? void 0 : onAccept();
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function info(args) {
|
|
84
|
+
var id = shouldShowAlert(args, 'info');
|
|
85
|
+
if (!id)
|
|
86
|
+
return;
|
|
87
|
+
var title = args.title, body = args.body, _a = args.onDismiss, onDismiss = _a === void 0 ? function () { return null; } : _a;
|
|
88
|
+
if (!title) {
|
|
89
|
+
title = 'FYI';
|
|
90
|
+
}
|
|
91
|
+
OSAlert({
|
|
92
|
+
title: title,
|
|
93
|
+
body: body,
|
|
94
|
+
options: [
|
|
95
|
+
{
|
|
96
|
+
text: 'OK',
|
|
97
|
+
onPress: function () {
|
|
98
|
+
popAlert(id);
|
|
99
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function OSError(args) {
|
|
106
|
+
var id = shouldShowAlert(args, 'error');
|
|
107
|
+
if (!id)
|
|
108
|
+
return;
|
|
109
|
+
var title = args.title, body = args.body;
|
|
110
|
+
if (!title) {
|
|
111
|
+
title = 'Whoops!';
|
|
112
|
+
}
|
|
113
|
+
if (!body) {
|
|
114
|
+
body = 'Something went wrong';
|
|
115
|
+
}
|
|
116
|
+
OSAlert({
|
|
117
|
+
title: title,
|
|
118
|
+
body: body,
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
text: 'OK',
|
|
122
|
+
onPress: function () {
|
|
123
|
+
var _a;
|
|
124
|
+
popAlert(id);
|
|
125
|
+
(_a = args === null || args === void 0 ? void 0 : args.onDismiss) === null || _a === void 0 ? void 0 : _a.call(args);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function OSAlert(params) {
|
|
132
|
+
react_native_1.Alert.alert(params.title, params.body, params.options, {
|
|
133
|
+
cancelable: false,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.default = {
|
|
137
|
+
ask: ask,
|
|
138
|
+
warn: warn,
|
|
139
|
+
info: info,
|
|
140
|
+
error: OSError,
|
|
141
|
+
};
|
|
142
142
|
//# sourceMappingURL=OSAlert.js.map
|
|
File without changes
|
package/dist/utils/misc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MobileInputFile } from '@codeleap/common';
|
|
2
|
-
export declare const stringToFile: (str: string) => MobileInputFile;
|
|
1
|
+
import { MobileInputFile } from '@codeleap/common';
|
|
2
|
+
export declare const stringToFile: (str: string) => MobileInputFile;
|
package/dist/utils/misc.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToFile = void 0;
|
|
4
|
-
var common_1 = require("@codeleap/common");
|
|
5
|
-
var stringToFile = function (str) {
|
|
6
|
-
if (!str) {
|
|
7
|
-
return {
|
|
8
|
-
file: null,
|
|
9
|
-
preview: null,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
var fileData = (0, common_1.parseFilePathData)(str);
|
|
13
|
-
var data = {
|
|
14
|
-
name: fileData.name,
|
|
15
|
-
type: 'image/' + fileData.extension,
|
|
16
|
-
size: 1000,
|
|
17
|
-
uri: str,
|
|
18
|
-
fileCopyUri: str,
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
file: data,
|
|
22
|
-
preview: data.uri,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
exports.stringToFile = stringToFile;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringToFile = void 0;
|
|
4
|
+
var common_1 = require("@codeleap/common");
|
|
5
|
+
var stringToFile = function (str) {
|
|
6
|
+
if (!str) {
|
|
7
|
+
return {
|
|
8
|
+
file: null,
|
|
9
|
+
preview: null,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
var fileData = (0, common_1.parseFilePathData)(str);
|
|
13
|
+
var data = {
|
|
14
|
+
name: fileData.name,
|
|
15
|
+
type: 'image/' + fileData.extension,
|
|
16
|
+
size: 1000,
|
|
17
|
+
uri: str,
|
|
18
|
+
fileCopyUri: str,
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
file: data,
|
|
22
|
+
preview: data.uri,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.stringToFile = stringToFile;
|
|
26
26
|
//# sourceMappingURL=misc.js.map
|
package/dist/utils/misc.js.map
CHANGED
|
File without changes
|
package/dist/utils/styles.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useLogStyles(): (name: any, styles: any) => void;
|
|
1
|
+
export declare function useLogStyles(): (name: any, styles: any) => void;
|