react-native-umui 1.4.11 → 1.4.21
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/lib/commonjs/Accordion.js +5 -7
- package/lib/commonjs/Accordion.js.map +1 -1
- package/lib/commonjs/Badge.js +3 -3
- package/lib/commonjs/Badge.js.map +1 -1
- package/lib/commonjs/Button.js +3 -2
- package/lib/commonjs/Button.js.map +1 -1
- package/lib/commonjs/Checkbox.js +2 -4
- package/lib/commonjs/Checkbox.js.map +1 -1
- package/lib/commonjs/Divider.js +1 -2
- package/lib/commonjs/Divider.js.map +1 -1
- package/lib/commonjs/EasyIn.js +2 -5
- package/lib/commonjs/EasyIn.js.map +1 -1
- package/lib/commonjs/FlatList.js +3 -6
- package/lib/commonjs/FlatList.js.map +1 -1
- package/lib/commonjs/FlatPanel.js +1 -2
- package/lib/commonjs/FlatPanel.js.map +1 -1
- package/lib/commonjs/Grid.js +3 -6
- package/lib/commonjs/Grid.js.map +1 -1
- package/lib/commonjs/InputField.js +4 -6
- package/lib/commonjs/InputField.js.map +1 -1
- package/lib/commonjs/Line.js +1 -1
- package/lib/commonjs/Line.js.map +1 -1
- package/lib/commonjs/Load.js +3 -6
- package/lib/commonjs/Load.js.map +1 -1
- package/lib/commonjs/Numeral.js +33 -10
- package/lib/commonjs/Numeral.js.map +1 -1
- package/lib/commonjs/PanelRK.js +2 -3
- package/lib/commonjs/PanelRK.js.map +1 -1
- package/lib/commonjs/Phone.js +13 -15
- package/lib/commonjs/Phone.js.map +1 -1
- package/lib/commonjs/Press.js +1 -2
- package/lib/commonjs/Press.js.map +1 -1
- package/lib/commonjs/Radio.js +3 -4
- package/lib/commonjs/Radio.js.map +1 -1
- package/lib/commonjs/Scroll.js +7 -11
- package/lib/commonjs/Scroll.js.map +1 -1
- package/lib/commonjs/Tab.js +6 -10
- package/lib/commonjs/Tab.js.map +1 -1
- package/lib/commonjs/Text.js +9 -26
- package/lib/commonjs/Text.js.map +1 -1
- package/lib/commonjs/TextInput.js +6 -8
- package/lib/commonjs/TextInput.js.map +1 -1
- package/lib/commonjs/common.js +3 -6
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/regions.js +9 -7
- package/lib/commonjs/regions.js.map +1 -1
- package/lib/commonjs/shadows.js +2 -3
- package/lib/commonjs/shadows.js.map +1 -1
- package/lib/module/Accordion.js +4 -4
- package/lib/module/Accordion.js.map +1 -1
- package/lib/module/Badge.js +2 -2
- package/lib/module/Badge.js.map +1 -1
- package/lib/module/Button.js +2 -1
- package/lib/module/Button.js.map +1 -1
- package/lib/module/Checkbox.js +1 -2
- package/lib/module/Checkbox.js.map +1 -1
- package/lib/module/Divider.js +0 -1
- package/lib/module/Divider.js.map +1 -1
- package/lib/module/EasyIn.js +1 -3
- package/lib/module/EasyIn.js.map +1 -1
- package/lib/module/FlatList.js +1 -2
- package/lib/module/FlatList.js.map +1 -1
- package/lib/module/FlatPanel.js +0 -1
- package/lib/module/FlatPanel.js.map +1 -1
- package/lib/module/Grid.js +2 -4
- package/lib/module/Grid.js.map +1 -1
- package/lib/module/InputField.js +3 -5
- package/lib/module/InputField.js.map +1 -1
- package/lib/module/Line.js.map +1 -1
- package/lib/module/Load.js +2 -4
- package/lib/module/Load.js.map +1 -1
- package/lib/module/Numeral.js +32 -7
- package/lib/module/Numeral.js.map +1 -1
- package/lib/module/PanelRK.js +1 -2
- package/lib/module/PanelRK.js.map +1 -1
- package/lib/module/Phone.js +10 -10
- package/lib/module/Phone.js.map +1 -1
- package/lib/module/Press.js +0 -1
- package/lib/module/Press.js.map +1 -1
- package/lib/module/Radio.js +2 -3
- package/lib/module/Radio.js.map +1 -1
- package/lib/module/Scroll.js +4 -5
- package/lib/module/Scroll.js.map +1 -1
- package/lib/module/Tab.js +5 -8
- package/lib/module/Tab.js.map +1 -1
- package/lib/module/Text.js +7 -23
- package/lib/module/Text.js.map +1 -1
- package/lib/module/TextInput.js +5 -6
- package/lib/module/TextInput.js.map +1 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/regions.js +6 -1
- package/lib/module/regions.js.map +1 -1
- package/lib/module/shadows.js +1 -1
- package/lib/module/shadows.js.map +1 -1
- package/lib/typescript/src/Accordion.d.ts.map +1 -1
- package/lib/typescript/src/Badge.d.ts.map +1 -1
- package/lib/typescript/src/Button.d.ts.map +1 -1
- package/lib/typescript/src/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/Divider.d.ts.map +1 -1
- package/lib/typescript/src/EasyIn.d.ts.map +1 -1
- package/lib/typescript/src/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/FlatPanel.d.ts.map +1 -1
- package/lib/typescript/src/Grid.d.ts.map +1 -1
- package/lib/typescript/src/InputField.d.ts +2 -1
- package/lib/typescript/src/InputField.d.ts.map +1 -1
- package/lib/typescript/src/Load.d.ts.map +1 -1
- package/lib/typescript/src/Numeral.d.ts.map +1 -1
- package/lib/typescript/src/PanelRK.d.ts.map +1 -1
- package/lib/typescript/src/Phone.d.ts.map +1 -1
- package/lib/typescript/src/Press.d.ts.map +1 -1
- package/lib/typescript/src/Radio.d.ts +1 -0
- package/lib/typescript/src/Radio.d.ts.map +1 -1
- package/lib/typescript/src/Scroll.d.ts.map +1 -1
- package/lib/typescript/src/Tab.d.ts.map +1 -1
- package/lib/typescript/src/Text.d.ts.map +1 -1
- package/lib/typescript/src/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/regions.d.ts +5 -0
- package/lib/typescript/src/regions.d.ts.map +1 -1
- package/lib/typescript/src/shadows.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/Accordion.tsx +0 -1
- package/src/Badge.tsx +0 -1
- package/src/Button.tsx +0 -142
- package/src/Checkbox.tsx +0 -1
- package/src/Divider.tsx +0 -1
- package/src/EasyIn.tsx +0 -1
- package/src/FlatList.tsx +0 -1
- package/src/FlatPanel.tsx +0 -1
- package/src/Grid.tsx +0 -1
- package/src/InputField.tsx +0 -1
- package/src/Line.tsx +0 -16
- package/src/Load.tsx +0 -68
- package/src/Numeral.tsx +0 -242
- package/src/PanelRK.tsx +0 -1
- package/src/Phone.tsx +0 -284
- package/src/Press.tsx +0 -1
- package/src/Radio.tsx +0 -1
- package/src/Scroll.tsx +0 -1
- package/src/Tab.tsx +0 -309
- package/src/Text.tsx +0 -21
- package/src/TextInput.tsx +0 -1
- package/src/common.tsx +0 -3439
- package/src/index.tsx +0 -22
- package/src/regions.ts +0 -258
- package/src/shadows.ts +0 -1
package/src/Phone.tsx
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, TextStyle, TouchableHighlight, View, ViewStyle } from "react-native";
|
|
3
|
-
import { MText } from "./Text";
|
|
4
|
-
import { aa3phone } from "./common";
|
|
5
|
-
import { MTextInput } from "./TextInput";
|
|
6
|
-
import { codesMap } from "./regions";
|
|
7
|
-
|
|
8
|
-
export enum PhoneType {
|
|
9
|
-
ANY = "ANY",
|
|
10
|
-
MOBILE = "MOBILE",
|
|
11
|
-
LAND = "LAND"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export interface PhoneRaw {
|
|
15
|
-
aa2: string;
|
|
16
|
-
code: number;
|
|
17
|
-
nn: string;
|
|
18
|
-
example?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface PhoneUtil {
|
|
22
|
-
regisons: () => string[];
|
|
23
|
-
flag: (code: string) => string;
|
|
24
|
-
/**
|
|
25
|
-
* @param phone
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
parseRaw: (phone: string) => PhoneRaw | null;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param code
|
|
32
|
-
* @param phone
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
parseRawByCountryCode: (code: string, phone: string) => PhoneRaw | null;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param code
|
|
39
|
-
* @param phone
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
pretty: (phone: string, phoneType?: PhoneType) => string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function checkList(item: AA3, phoneType: PhoneType) {
|
|
46
|
-
const regexlist: RegExp[] = []
|
|
47
|
-
const phonelenghts = item.phone_number_lengths
|
|
48
|
-
const beginwiths = item.mobile_begin_with
|
|
49
|
-
const isNotOnlyMobile = phoneType === PhoneType.MOBILE
|
|
50
|
-
|
|
51
|
-
if (phonelenghts.length && beginwiths.length) {
|
|
52
|
-
phonelenghts.forEach(pl => {
|
|
53
|
-
beginwiths.forEach(bw => {
|
|
54
|
-
const r = new RegExp(`^${item.countryCode}${isNotOnlyMobile ? bw : `[0-9]{${bw.toString().length}}`}[0-9]{${pl - (bw as number).toString().length}}$`)
|
|
55
|
-
regexlist.push(r)
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
} else if (!phonelenghts.length && beginwiths.length) {
|
|
59
|
-
beginwiths.forEach(bw => {
|
|
60
|
-
const r = new RegExp(`^${item.countryCode}${isNotOnlyMobile ? bw : `[0-9]{${bw.toString().length}}`}[0-9]`)
|
|
61
|
-
regexlist.push(r)
|
|
62
|
-
})
|
|
63
|
-
} else if (phonelenghts.length && !beginwiths.length) {
|
|
64
|
-
phonelenghts.forEach(pl => {
|
|
65
|
-
const r = new RegExp(`^${item.countryCode}[0-9]{${pl}}$`)
|
|
66
|
-
regexlist.push(r)
|
|
67
|
-
})
|
|
68
|
-
} else {
|
|
69
|
-
const r = new RegExp(`^${item.countryCode}[0-9]`)
|
|
70
|
-
regexlist.push(r)
|
|
71
|
-
}
|
|
72
|
-
return regexlist
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
interface AA3 {
|
|
76
|
-
countryCode: number;
|
|
77
|
-
mobile_begin_with?: number[];
|
|
78
|
-
phone_number_lengths?: number[];
|
|
79
|
-
flag: string;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
interface AA2 {
|
|
83
|
-
aa2: string;
|
|
84
|
-
flag: string;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
class Phone {
|
|
88
|
-
private supportAa2s: AA2[] = [];
|
|
89
|
-
|
|
90
|
-
static new() {
|
|
91
|
-
return new Phone();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
setRegions(vals: string[] = []) {
|
|
95
|
-
try {
|
|
96
|
-
vals.forEach(k => {
|
|
97
|
-
if (aa3phone[k]) {
|
|
98
|
-
this.supportAa2s.push({ aa2: k, flag: this.itemAa3ByAa2(k).flag })
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
} catch (error) {
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get supportsIat2(): AA2[] {
|
|
108
|
-
return this.supportAa2s;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
formatRaw(raw: PhoneRaw, noPlusPrefix: boolean = false) {
|
|
112
|
-
return `${noPlusPrefix ? "" : "+"}${raw.code}${raw.nn}`;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private itemAa3ByAa2(aa2: string): AA3 | null {
|
|
116
|
-
const item: AA3 = aa3phone[aa2];
|
|
117
|
-
return item ? item : null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private check(aa2: string, fullPn: string, phoneType: PhoneType = PhoneType.MOBILE): PhoneRaw | null {
|
|
121
|
-
const item: AA3 | null = this.itemAa3ByAa2(aa2)
|
|
122
|
-
const regexlist = checkList(item, phoneType)
|
|
123
|
-
if (regexlist.map(k => k.test(fullPn)).filter(k => k).length > 0) {
|
|
124
|
-
const line = `${item.mobile_begin_with.length ? item.mobile_begin_with[item.mobile_begin_with.length - 1] : ""}${"512312387612638131123"}`
|
|
125
|
-
return ({
|
|
126
|
-
aa2: aa2,
|
|
127
|
-
code: item.countryCode,
|
|
128
|
-
nn: fullPn.substring(item.countryCode.toString().length, fullPn.length),
|
|
129
|
-
example: line.substring(0, item.phone_number_lengths.length ? item.phone_number_lengths[item.mobile_begin_with.length - 1] : line.length)
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
parseRaw(fullPn: string, phoneType?: PhoneType): PhoneRaw | null {
|
|
137
|
-
try {
|
|
138
|
-
const pn = (fullPn || "").replace(/\D/g, "").replace(/ /g, "");
|
|
139
|
-
const aa2s = Object.keys(aa3phone);
|
|
140
|
-
|
|
141
|
-
let index = 0;
|
|
142
|
-
let raw: PhoneRaw | null = null;
|
|
143
|
-
|
|
144
|
-
for (index = 0; index < aa2s.length; index++) {
|
|
145
|
-
raw = this.check(aa2s[index], pn, phoneType);
|
|
146
|
-
|
|
147
|
-
if (raw) {
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return raw;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
parseRawInput(aa2: string, nn: string, phoneType?: PhoneType): PhoneRaw | null {
|
|
159
|
-
try {
|
|
160
|
-
const item: AA3 | null = this.itemAa3ByAa2(aa2);
|
|
161
|
-
if (!item) {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const fullPn = `${item.countryCode}${nn}`;
|
|
166
|
-
return this.check(aa2, fullPn, phoneType);
|
|
167
|
-
} catch (error) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
placeholder(aa2: string): string {
|
|
173
|
-
try {
|
|
174
|
-
const item: AA3 | null = this.itemAa3ByAa2(aa2);
|
|
175
|
-
if (!item) {
|
|
176
|
-
return "";
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const line = `${item.mobile_begin_with.length ? item.mobile_begin_with[item.mobile_begin_with.length - 1] : ""}${"512312387612638131123"}`;
|
|
180
|
-
|
|
181
|
-
return line.substring(0, item.phone_number_lengths.length ? item.phone_number_lengths[item.phone_number_lengths.length - 1] : line.length);
|
|
182
|
-
} catch (error) {
|
|
183
|
-
return "";
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private mask(lenght: number, pt: string, txt: string, rmt: string): string {
|
|
188
|
-
if (rmt.length === 0 || txt.length >= lenght) {
|
|
189
|
-
return txt;
|
|
190
|
-
}
|
|
191
|
-
const c = pt.at(0);
|
|
192
|
-
const v = rmt.at(0);
|
|
193
|
-
|
|
194
|
-
if (c != "#") {
|
|
195
|
-
txt += c;
|
|
196
|
-
} else {
|
|
197
|
-
txt += v;
|
|
198
|
-
rmt = rmt.split("").filter((_, i) => i != 0).join("");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
pt = pt.split("").filter((_, i) => i != 0).join("");
|
|
202
|
-
|
|
203
|
-
return this.mask(lenght, pt, txt, rmt);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
prettyMaskWoc(aa2: string, nn: string) {
|
|
207
|
-
try {
|
|
208
|
-
const item = aa3phone[aa2];
|
|
209
|
-
const mask = item?.mask?.replace(`+${item.countryCode.toString()} `, "");
|
|
210
|
-
return this.mask(mask.length, mask, "", nn);
|
|
211
|
-
} catch (error) {
|
|
212
|
-
return "";
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
prettyMask(aa2: string, nn: string) {
|
|
217
|
-
try {
|
|
218
|
-
const item = aa3phone[aa2];
|
|
219
|
-
const mask = item?.mask;
|
|
220
|
-
return this.mask(mask.length, mask, "", nn);
|
|
221
|
-
} catch (error) {
|
|
222
|
-
return "";
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export const phoneUtil: PhoneUtil = (() => {
|
|
228
|
-
function regisons() {
|
|
229
|
-
return Object.keys(codesMap);
|
|
230
|
-
}
|
|
231
|
-
function flag(code: string) {
|
|
232
|
-
return aa3phone[code]?.flag;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* @param phone
|
|
236
|
-
* @returns
|
|
237
|
-
*/
|
|
238
|
-
function parseRaw(phone: string, phoneType?: PhoneType): PhoneRaw | null {
|
|
239
|
-
try {
|
|
240
|
-
return Phone.new().parseRaw(phone, phoneType);
|
|
241
|
-
} catch (error) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @param code
|
|
247
|
-
* @param phone
|
|
248
|
-
* @returns
|
|
249
|
-
*/
|
|
250
|
-
function parseRawByCountryCode(code: string, phone: string, phoneType?: PhoneType): PhoneRaw | null {
|
|
251
|
-
try {
|
|
252
|
-
return Phone.new().parseRawInput(code, phone, phoneType);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function pretty(phone: string, phoneType?: PhoneType): string {
|
|
258
|
-
try {
|
|
259
|
-
const raw = Phone.new().parseRaw(phone.replace(/\D/g, ""), phoneType || PhoneType.ANY);
|
|
260
|
-
return Phone.new().prettyMask(raw.aa2, raw.nn);
|
|
261
|
-
} catch (error) {
|
|
262
|
-
return "";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return { regisons, flag, parseRaw, parseRawByCountryCode, pretty };
|
|
266
|
-
})();
|
|
267
|
-
|
|
268
|
-
interface MPhoneInputProps {
|
|
269
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
270
|
-
phoneStyle?: StyleProp<TextStyle>;
|
|
271
|
-
placeholder?: string;
|
|
272
|
-
disabled?: boolean;
|
|
273
|
-
noPlusPrefix?: boolean;
|
|
274
|
-
regions?: Array<keyof typeof codesMap>;
|
|
275
|
-
phoneType?: PhoneType;
|
|
276
|
-
keyboardType?: 'default' | 'number-pad' | 'decimal-pad' | 'numeric' | 'email-address' | 'phone-pad' | 'url';
|
|
277
|
-
code: string;
|
|
278
|
-
value: any;
|
|
279
|
-
onChangeCountry: (regions: string[], active?: string) => void;
|
|
280
|
-
onChange: (value: string) => void;
|
|
281
|
-
onBlur: () => void;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export function MPhoneInput({ keyboardType = "phone-pad", ...props }: MPhoneInputProps) { const [init, setInit] = React.useState<boolean>(false); const [focus, setFocus] = React.useState<boolean>(false); const [raw, setRaw] = React.useState<PhoneRaw & { pretty: string, flag: any }>({ aa2: "", nn: "", code: 0, pretty: "", flag: "" }); function onChangeCountryCode(v: string, isReset?: boolean) { try { setRaw(vals => { const item = ({ ...vals, aa2: v, nn: isReset ? "" : vals.nn, code: aa3phone[props.code]?.countryCode, flag: aa3phone[props.code]?.flag, example: Phone.new().setRegions(props.regions).placeholder(v) }); item.pretty = Phone.new().prettyMaskWoc(item.aa2, item.nn); return item; }); } catch (error) { } } function onChangeNn(v: string) { try { const value = String(v).replace(/\D/g, ""); setRaw(vals => { const item = { ...vals, nn: value }; item.pretty = Phone.new().prettyMaskWoc(item.aa2, item.nn); return item; }); } catch (error) { } } React.useEffect(() => { if (init) { const instance = Phone.new().setRegions(props.regions); const rawResponse = instance.parseRawInput(raw.aa2, raw.nn, props.phoneType); if (rawResponse) { const a = instance.formatRaw(rawResponse, props.noPlusPrefix); props.onChange(a); } else if (props.onChange) { props.onChange(""); } } }, [init, focus, raw, props.regions?.length]); React.useEffect(() => { if (init && !focus) { const rawResponse = Phone.new().setRegions(props.regions).parseRaw(props.value, props.phoneType); if (rawResponse) { const item: PhoneRaw & { pretty: string, flag: any } = { ...rawResponse, pretty: "", flag: aa3phone[rawResponse.aa2]?.flag }; item.pretty = Phone.new().prettyMaskWoc(rawResponse.aa2, raw.nn); setRaw(item); } else { onChangeCountryCode(props.code); } if (rawResponse?.nn == raw?.nn && props.code !== raw.aa2) { onChangeCountryCode(props.code, true); } } }, [init, focus, props.code, props.value]); React.useEffect(() => { setInit(true); }, []); return (<View style={[{ flex: 1, height: 45, maxHeight: 45, display: "flex", flexDirection: "row", borderWidth: 1, borderColor: "#dadce0" }, props.containerStyle]}><TouchableHighlight style={{ flex: 1, maxWidth: 55, display: "flex", justifyContent: "center", alignItems: "center", borderRightWidth: 1, borderRightColor: "#dadce0", backgroundColor: "white" }} onPress={() => props.onChangeCountry(Phone.new().setRegions(props.regions).supportsIat2.map(k => k.aa2), raw.aa2)}><MText style={{ textAlign: "center", fontSize: 23 }}>{raw.flag || "🏁"}</MText></TouchableHighlight><View style={{ flex: 1, maxWidth: 55, padding: 5, display: "flex", justifyContent: "center", alignItems: "center", backgroundColor: "white", borderRightWidth: 1, borderRightColor: "#dadce0" }}><MText style={{ color: "black", textAlign: "center", padding: 5, fontWeight: "500" }}>+{raw?.code}</MText></View><MTextInput style={[{ flex: 1, color: "black", borderWidth: 0, borderRadius: 0, minHeight: 43, height: 43 }, props.phoneStyle]} value={raw.pretty} keyboardType={keyboardType} placeholder={props.placeholder} maxLength={Phone.new().prettyMaskWoc(raw.aa2, raw.example)?.length} onChangeText={onChangeNn} onFocus={() => setFocus(true)} onBlur={() => setFocus(false)} /></View>) }
|
package/src/Press.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react"; import { Pressable, PressableProps } from "react-native"; interface MPressProps extends PressableProps { children: ReactNode; }; export function MPress({ children, ...props }: MPressProps) { return (<Pressable {...props}>{children}</Pressable>); }
|
package/src/Radio.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react"; import { TextStyle, TouchableHighlight, TouchableHighlightProps, View } from "react-native"; import { MText } from "./Text"; interface MRadioProps extends TouchableHighlightProps { name?: string; activeValue?: string | number | boolean; value: string | number | boolean; checked?: boolean; size?: number; color: string; label?: string; labelStyle?: TextStyle; onChange?: (values: string | number | boolean, checked: boolean, name?: string) => void; children?: ReactNode; }; export function MRadio({ name = "", activeValue, value, color, label, size = 26, labelStyle, style, onChange, ...props }: MRadioProps) { const checked = props.checked || value == activeValue; return (<TouchableHighlight activeOpacity={0.85} {...props} onPress={() => { if (onChange) { onChange(checked ? "" : value, !checked, name); } }} underlayColor="transparent" style={[{ flex: 1 }, style]}><View style={{ display: "flex", flexDirection: "row", alignItems: "center", minHeight: size }}><View style={{ padding: 4, width: size, height: size, borderRadius: size, borderWidth: 1, borderColor: color, backgroundColor: "white", display: "flex", justifyContent: "center", alignItems: "center" }}><View style={{ width: size - 8, height: size - 8, backgroundColor: checked ? color : "white", borderRadius: size }} /></View><MText style={[{ flex: 1, fontSize: 15, paddingLeft: 5 }, labelStyle]}>{label}</MText></View></TouchableHighlight>) }
|
package/src/Scroll.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, ReactNode } from "react"; import { RefreshControl, ScrollView, StyleProp, ViewStyle, ScrollViewProps } from "react-native"; export const styleMSVerticalCenter = { justifyContent: "center" } as any; interface MScrollProps extends ScrollViewProps { name?: string; contentContainerStyle?: StyleProp<ViewStyle>; isRefreshing?: boolean; onRefresh?: () => void; children?: ReactNode; }; export const MScroll = forwardRef<ScrollView, MScrollProps>((props, ref) => { return (<ScrollView ref={ref} contentInsetAdjustmentBehavior="automatic" contentContainerStyle={{ flexGrow: 1, backgroundColor: "transparent", paddingBottom: 175, padding: 9, ...(props.contentContainerStyle || {}) as any }} {...props} refreshControl={(props.onRefresh && (<RefreshControl refreshing={Boolean(props.isRefreshing)} onRefresh={props.onRefresh} />))}>{props.children}</ScrollView>) })
|
package/src/Tab.tsx
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, ReactElement, ReactNode } from "react";
|
|
2
|
-
import { StyleProp, View, ViewStyle, PanResponder, Animated, Dimensions, TextStyle } from "react-native";
|
|
3
|
-
import { MButton } from "./Button";
|
|
4
|
-
import { MText } from "./Text";
|
|
5
|
-
|
|
6
|
-
interface IMTabButtonProps {
|
|
7
|
-
testID?: string;
|
|
8
|
-
size?: "xs" | "sm" | "md" | "nm";
|
|
9
|
-
noSizeLimit?: boolean;
|
|
10
|
-
style?: StyleProp<ViewStyle>;
|
|
11
|
-
label?: string;
|
|
12
|
-
textAlign?: "center" | "left" | "right";
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
outline?: boolean;
|
|
15
|
-
noborder?: boolean;
|
|
16
|
-
loading?: boolean;
|
|
17
|
-
btnType?: "primary" | "success" | "warning" | "secondary" | "danger" | "light" | "navy" | "smokelight";
|
|
18
|
-
onPress?: () => void;
|
|
19
|
-
children?: ReactNode;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function MTabButton({ children, btnType = "smokelight", style, size = "md", outline = true, ...props }: IMTabButtonProps) {
|
|
23
|
-
return (
|
|
24
|
-
<MButton
|
|
25
|
-
btnType={btnType}
|
|
26
|
-
size={size}
|
|
27
|
-
outline={outline}
|
|
28
|
-
{...props}
|
|
29
|
-
style={[{ borderWidth: 1, borderColor: "#dadada" }, style]}
|
|
30
|
-
>
|
|
31
|
-
{children}
|
|
32
|
-
</MButton>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface MCustomTabProps {
|
|
37
|
-
value: string | number;
|
|
38
|
-
active: boolean;
|
|
39
|
-
disabled: boolean;
|
|
40
|
-
onPress: (value: any) => void;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
interface MTabProps {
|
|
44
|
-
value: string | number;
|
|
45
|
-
fontSize?: number;
|
|
46
|
-
textAlign?: "center" | "left" | "right";
|
|
47
|
-
fontWeight?: | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | undefined;
|
|
48
|
-
tabTextStyle?: StyleProp<TextStyle>;
|
|
49
|
-
tab: string | ((props: MCustomTabProps) => ReactNode);
|
|
50
|
-
disabled?: boolean;
|
|
51
|
-
isHidden?: boolean;
|
|
52
|
-
render?: () => ReactNode;
|
|
53
|
-
children?: ReactNode;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export function MTab(props: MTabProps) {
|
|
57
|
-
return (<React.Fragment>{props.children || props.render()}</React.Fragment>);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface TabContainerProps {
|
|
61
|
-
testID?: string;
|
|
62
|
-
tabStyle?: StyleProp<ViewStyle>;
|
|
63
|
-
isTop: boolean;
|
|
64
|
-
activeValue: string | number;
|
|
65
|
-
onChange: (value: any) => void;
|
|
66
|
-
items: Array<ReactElement<MTabProps>>;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
function TabContainer(props: TabContainerProps) {
|
|
70
|
-
return (
|
|
71
|
-
<View style={[{ width: "100%", display: "flex", flexDirection: "row", justifyContent: "space-around", alignItems: "center" }, props.tabStyle]}>
|
|
72
|
-
{props.items.filter(k => k && !k.props.isHidden).map((item, index) => {
|
|
73
|
-
const isActive = item.props.value === props.activeValue;
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Fragment key={`${index}${props.activeValue}`}>
|
|
77
|
-
{typeof item.props.tab === "string" ? (
|
|
78
|
-
<MButton
|
|
79
|
-
testID={props.testID}
|
|
80
|
-
size="md"
|
|
81
|
-
btnType={isActive ? "navy" : "light"}
|
|
82
|
-
outline={isActive}
|
|
83
|
-
disabled={item.props.disabled}
|
|
84
|
-
style={{
|
|
85
|
-
backgroundColor: "transparent",
|
|
86
|
-
flex: 1,
|
|
87
|
-
borderRadius: 0,
|
|
88
|
-
borderColor: null,
|
|
89
|
-
borderWidth: 0,
|
|
90
|
-
borderTopWidth: !props.isTop ? 2 : 0,
|
|
91
|
-
borderBottomWidth: props.isTop ? 2 : 0,
|
|
92
|
-
borderTopColor: !props.isTop && isActive ? undefined : "transparent",
|
|
93
|
-
borderBottomColor: props.isTop && isActive ? undefined : "transparent",
|
|
94
|
-
minHeight: 43,
|
|
95
|
-
maxHeight: 43
|
|
96
|
-
}}
|
|
97
|
-
onPress={() => props.onChange(item.props.value)}
|
|
98
|
-
>
|
|
99
|
-
<MText style={[{ flex: 1, color: "black", fontSize: item.props.fontSize || 15, fontWeight: item.props.fontWeight, textAlign: item.props.textAlign || "center" }, item.props.tabTextStyle]}>
|
|
100
|
-
{item.props.tab}
|
|
101
|
-
</MText>
|
|
102
|
-
</MButton>) : (
|
|
103
|
-
item.props.tab({
|
|
104
|
-
active: isActive,
|
|
105
|
-
value: item.props.value,
|
|
106
|
-
disabled: item.props.disabled,
|
|
107
|
-
onPress: props.onChange
|
|
108
|
-
})
|
|
109
|
-
)}
|
|
110
|
-
</Fragment>
|
|
111
|
-
);
|
|
112
|
-
})}
|
|
113
|
-
</View>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface MTabsProps {
|
|
118
|
-
position?: "top" | "bottom"
|
|
119
|
-
tabStyle?: StyleProp<ViewStyle>
|
|
120
|
-
active: string | number
|
|
121
|
-
children: ReactElement<MTabProps> | Array<ReactElement<MTabProps>>
|
|
122
|
-
onChange: (value: any) => void
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function MTabs({ position = "top", ...props }: MTabsProps) {
|
|
126
|
-
const fadeAnim = React.useRef(new Animated.Value(0, { useNativeDriver: true })).current;
|
|
127
|
-
const children = (Array.isArray(props.children) ? props.children : [props.children]).filter(k => (!k.props.isHidden && !k.props.disabled))
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const activeIndex = React.useMemo(() => {
|
|
131
|
-
return children.findIndex(k => k.props.value === props.active);
|
|
132
|
-
}, [props.active])
|
|
133
|
-
|
|
134
|
-
const panResponder = React.useMemo(() => {
|
|
135
|
-
fadeAnim.setValue(0)
|
|
136
|
-
return PanResponder.create({
|
|
137
|
-
onMoveShouldSetPanResponder: (_e1, gestureState) => {
|
|
138
|
-
if ((Math.abs(gestureState.dx) > (Dimensions.get("window").width / 2.5)) && (Math.abs(gestureState.dx) > Math.abs(gestureState.dy * 3.5)) && (Math.abs(gestureState.vx) > Math.abs(gestureState.vy * 2.5))) {
|
|
139
|
-
if (gestureState.dx > 0 && activeIndex > 0) {
|
|
140
|
-
props.onChange(children[activeIndex - 1].props.value)
|
|
141
|
-
return true
|
|
142
|
-
}
|
|
143
|
-
if (gestureState.dx < 0 && activeIndex < children.length - 1) {
|
|
144
|
-
props.onChange(children[activeIndex + 1].props.value)
|
|
145
|
-
return true
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if ((gestureState.dx > 0 && activeIndex > 0) || (gestureState.dx < 0 && activeIndex < children.length - 1)) {
|
|
149
|
-
fadeAnim.setValue(gestureState.dx)
|
|
150
|
-
}
|
|
151
|
-
return true
|
|
152
|
-
},
|
|
153
|
-
onPanResponderRelease(_e1, _g1) {
|
|
154
|
-
fadeAnim.setValue(0)
|
|
155
|
-
},
|
|
156
|
-
onPanResponderTerminate() {
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}, [activeIndex])
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<View style={{ flex: 1, display: "flex", flexDirection: "column" }} {...panResponder.panHandlers} onTouchEnd={() => {
|
|
164
|
-
fadeAnim.setValue(0)
|
|
165
|
-
}} onTouchCancel={()=>fadeAnim.setValue(0)}>
|
|
166
|
-
{position === "top" ? <TabContainer isTop={true} activeValue={props.active} tabStyle={props.tabStyle} items={children} onChange={props.onChange} /> : <React.Fragment></React.Fragment>}
|
|
167
|
-
|
|
168
|
-
{children.length ? <Animated.View key={activeIndex} style={{ flex: 1, transform: [{ translateX: fadeAnim }] }}>
|
|
169
|
-
{children[activeIndex]?.props?.children || children[activeIndex]?.props?.render()}
|
|
170
|
-
</Animated.View> : <React.Fragment></React.Fragment>}
|
|
171
|
-
|
|
172
|
-
{position === "bottom" ? <TabContainer isTop={false} activeValue={props.active} tabStyle={props.tabStyle} items={children} onChange={props.onChange} /> : <React.Fragment></React.Fragment>}
|
|
173
|
-
</View>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
class MTabButtonBaseProps {
|
|
180
|
-
testID?: string
|
|
181
|
-
value: string | number
|
|
182
|
-
disabled?: boolean
|
|
183
|
-
label: string
|
|
184
|
-
style?: StyleProp<ViewStyle>
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
class MTabButtonProps extends MTabButtonBaseProps {
|
|
188
|
-
activeValue?: string | number
|
|
189
|
-
onChange?: (value: any) => void
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export function MTabControlButton(props: MTabButtonProps) {
|
|
193
|
-
const isActive = props.value === props.activeValue
|
|
194
|
-
|
|
195
|
-
return (
|
|
196
|
-
<MButton
|
|
197
|
-
testID={props.testID}
|
|
198
|
-
btnType={isActive ? "navy" : "light"}
|
|
199
|
-
disabled={props.disabled}
|
|
200
|
-
style={[{ borderRadius: 0, borderWidth: 1, borderColor: "#fafafa" }, props.style]}
|
|
201
|
-
onPress={() => props.onChange(props.value)}
|
|
202
|
-
>
|
|
203
|
-
<MText style={{ color: isActive ? "white" : "black", fontSize: 15 }}>
|
|
204
|
-
{props.label}
|
|
205
|
-
</MText>
|
|
206
|
-
</MButton>
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
interface MTabContollerProps {
|
|
211
|
-
active: string | number
|
|
212
|
-
style?: StyleProp<ViewStyle>
|
|
213
|
-
children: Array<ReactElement<MTabButtonBaseProps | ReactNode>>
|
|
214
|
-
onChange: (value: any) => void
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export function MTabContoller(props: MTabContollerProps) {
|
|
218
|
-
return (
|
|
219
|
-
<View
|
|
220
|
-
style={[
|
|
221
|
-
{ width: "100%", display: "flex", flexDirection: "row", justifyContent: "space-evenly", alignItems: "center" },
|
|
222
|
-
props.style
|
|
223
|
-
]}
|
|
224
|
-
>
|
|
225
|
-
{props.children.map((k, index) => {
|
|
226
|
-
if (k.type["name"] === "MTabControlButton") {
|
|
227
|
-
return (
|
|
228
|
-
<MTabControlButton
|
|
229
|
-
key={index}
|
|
230
|
-
{...k.props as any}
|
|
231
|
-
activeValue={props.active}
|
|
232
|
-
onChange={(value) => {
|
|
233
|
-
props.onChange(value)
|
|
234
|
-
if (k.props["onChange"]) {
|
|
235
|
-
k.props["onChange"](value)
|
|
236
|
-
}
|
|
237
|
-
}}
|
|
238
|
-
/>
|
|
239
|
-
);
|
|
240
|
-
} else {
|
|
241
|
-
return k;
|
|
242
|
-
}
|
|
243
|
-
})}
|
|
244
|
-
</View>
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
interface MTabContentProps {
|
|
249
|
-
value: string | number
|
|
250
|
-
style?: StyleProp<ViewStyle>
|
|
251
|
-
children: ReactNode
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export function MTabContent(props: MTabContentProps) {
|
|
255
|
-
return (
|
|
256
|
-
<View style={[{ flex: 1 }, props.style]}>
|
|
257
|
-
{props.children}
|
|
258
|
-
</View>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
interface MTabContentsProps {
|
|
263
|
-
active: string | number
|
|
264
|
-
children: Array<ReactElement<MTabContentProps>>
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export function MTabContents(props: MTabContentsProps) {
|
|
268
|
-
return (<React.Fragment>{props.children?.find(k => k.props.value === props.active)}</React.Fragment>);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
interface MTabContainerProps {
|
|
272
|
-
style?: StyleProp<ViewStyle>
|
|
273
|
-
children: [ReactElement<MTabContollerProps>, ReactElement<MTabContentsProps>]
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export function MTabContainer(props: MTabContainerProps) {
|
|
277
|
-
return (
|
|
278
|
-
<View style={[{ flex: 1, display: "flex", flexDirection: "column" }, props.style]}>
|
|
279
|
-
{props.children}
|
|
280
|
-
</View>
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/*
|
|
285
|
-
<MTabContainer>
|
|
286
|
-
<MTabContoller active={tab} onChange={setTab}>
|
|
287
|
-
<MTabControlButton value={ORDER_GROUP_TYPE.PENDING} label="Paketlerim" />
|
|
288
|
-
<MTabControlButton value={ORDER_GROUP_TYPE.DELIVERED} label="Teslim-İptal" />
|
|
289
|
-
<MTabControlButton value={ORDER_GROUP_TYPE.ACCEPTED} label="Aktifler" />
|
|
290
|
-
<MButton color="light" onPress={()=> {}} style={{maxWidth: 41}}>
|
|
291
|
-
|
|
292
|
-
</MButton>
|
|
293
|
-
</MTabContoller>
|
|
294
|
-
|
|
295
|
-
<MTabContents active={tab}>
|
|
296
|
-
<MTabContent value={ORDER_GROUP_TYPE.PENDING}>
|
|
297
|
-
<MText style={{ color: "black" }}>{ORDER_GROUP_TYPE.PENDING}</MText>
|
|
298
|
-
</MTabContent>
|
|
299
|
-
|
|
300
|
-
<MTabContent value={ORDER_GROUP_TYPE.DELIVERED}>
|
|
301
|
-
<MText style={{ color: "black" }}>{ORDER_GROUP_TYPE.DELIVERED}</MText>
|
|
302
|
-
</MTabContent>
|
|
303
|
-
|
|
304
|
-
<MTabContent value={ORDER_GROUP_TYPE.ACCEPTED}>
|
|
305
|
-
<MText style={{ color: "black" }}>{ORDER_GROUP_TYPE.ACCEPTED}</MText>
|
|
306
|
-
</MTabContent>
|
|
307
|
-
</MTabContents>
|
|
308
|
-
</MTabContainer>
|
|
309
|
-
*/
|
package/src/Text.tsx
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react"; import {Text, TextProps } from "react-native"; interface MTextProps extends TextProps { }; export const MText = React.forwardRef<Text, MTextProps>((props, ref) => { return (<Text ref={ref} {...props} style={[{ fontSize: 15, letterSpacing: 0.59 }, props.style]}>{props.children}</Text>) })
|
|
2
|
-
|
|
3
|
-
// import React from "react";
|
|
4
|
-
// import { StyleProp, Text, TextProps, TextStyle } from "react-native"
|
|
5
|
-
|
|
6
|
-
// interface MTextProps extends TextProps {
|
|
7
|
-
// // style?: StyleProp<Omit<TextStyle, "fontSize">>
|
|
8
|
-
// }
|
|
9
|
-
|
|
10
|
-
// function lineHeight(fontSize) {
|
|
11
|
-
// const multiplier = (fontSize > 20) ? 1.5 : 1;
|
|
12
|
-
// return parseInt(fontSize + (fontSize * multiplier), 10);
|
|
13
|
-
// }
|
|
14
|
-
|
|
15
|
-
// export const MText = React.forwardRef<Text, MTextProps>((props, ref) => {
|
|
16
|
-
// return (
|
|
17
|
-
// <Text ref={ref} {...props} style={[{ fontSize: 15, letterSpacing: 0.59 }, props.style]}>
|
|
18
|
-
// {props.children}
|
|
19
|
-
// </Text>
|
|
20
|
-
// )
|
|
21
|
-
// })
|
package/src/TextInput.tsx
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import React, { StyleProp, StyleSheet, TextInput, TextInputProps, View, ViewStyle } from "react-native"; import { MText } from "./Text"; import { useEffect } from "react"; const styleOTI = StyleSheet.create({ txtInput: { flex: 1, height: 45, minHeight: 45, maxHeight: 45, borderStyle: "solid", zIndex: 101, backgroundColor: "white", color: "black", borderRadius: 3, fontSize: 16.25, paddingHorizontal: 11, paddingVertical: 5, borderWidth: 1, borderColor: "#dadce0", letterSpacing: 1 } }); interface ITextInputProps extends TextInputProps { disabled?: boolean; }; export function MTextInput({ disabled, editable, style, ...props }: ITextInputProps) { const _editable = !(disabled || editable == false); return (<TextInput autoCapitalize="none" autoFocus={false} {...props} editable={_editable} style={[styleOTI.txtInput, { backgroundColor: _editable ? "white" : "#f7f7f7" }, style]} placeholderTextColor="#919191" />); } export function MTextareaInput({ disabled, editable, style, ...props }: ITextInputProps) { const _editable = !(disabled || editable == false); return (<TextInput autoCapitalize="none" numberOfLines={4} multiline={true} autoFocus={false} {...props} editable={_editable} style={[styleOTI.txtInput, { height: null, maxHeight: null, backgroundColor: _editable ? "white" : "#f7f7f7" }, style]} placeholderTextColor="#919191" />); } interface IMPinInputMatProps extends TextInputProps { size: number; styleContainer?: StyleProp<ViewStyle>; styleBadge?: StyleProp<ViewStyle>; onFilledFully?: (value?: string)=> void; }; export function MPinInput({ size, styleContainer, onFilledFully, ...props }: IMPinInputMatProps) { useEffect(()=>{ if(props.value?.length>=size && onFilledFully){ onFilledFully(props.value); } },[size, props.value]); return (<View style={[ { flex: 1, zIndex: 9, height: 45, minHeight: 45, maxHeight: 45, paddingHorizontal: 11, display: 'flex', flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', position: 'relative' }, styleContainer ]}><TextInput {...props} style={{ flex: 1, position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, color: 'transparent', textAlign: 'center', zIndex: 3 }} secureTextEntry={true} caretHidden={true} maxLength={size} placeholder="" />{Array(Math.abs(size)).fill(null).map((_, i) => (<View key={i} style={[{ width: 45, height: 45, borderWidth: 1, borderColor: '#8080802e', backgroundColor: 'white', display: "flex", justifyContent: 'center', alignItems: "center" }, props.styleBadge]}><MText style={{ color: "black", fontSize: 17, fontWeight: "700" }}>{props.value?.at(i)}</MText></View>))}</View>) }
|