@fto-consult/expo-ui 6.23.2 → 6.23.3
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/package.json +2 -2
- package/src/components/Chip/index.js +1 -1
- package/src/components/Date/DatePickerInput/index.js +2 -2
- package/src/components/Dialog/DialogTitle.js +1 -1
- package/src/components/PhoneInput/index.js +2 -2
- package/src/components/TextField/index.js +16 -21
- package/src/components/TextField/utils.js +83 -1
- package/src/context/Provider.js +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "6.23.
|
|
3
|
+
"version": "6.23.3",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@emotion/native": "^11.11.0",
|
|
67
67
|
"@expo/html-elements": "^0.5.1",
|
|
68
68
|
"@expo/vector-icons": "^13.0.0",
|
|
69
|
-
"@fto-consult/common": "^3.
|
|
69
|
+
"@fto-consult/common": "^3.26.0",
|
|
70
70
|
"@gorhom/portal": "^1.0.14",
|
|
71
71
|
"@pchmn/expo-material3-theme": "^1.3.1",
|
|
72
72
|
"@react-native-async-storage/async-storage": "1.18.2",
|
|
@@ -7,7 +7,7 @@ import i18n from "$i18n";
|
|
|
7
7
|
import {defaultStr} from "$cutils";
|
|
8
8
|
import DateLib from "$lib/date";
|
|
9
9
|
import PropTypes from "prop-types";
|
|
10
|
-
import TextField from "$ecomponents/TextField";
|
|
10
|
+
import TextField,{inputModes} from "$ecomponents/TextField";
|
|
11
11
|
import Icon from "$ecomponents/Icon";
|
|
12
12
|
import {StyleSheet,View} from "react-native";
|
|
13
13
|
import DatePickerModal from '../DatePickerModal'
|
|
@@ -183,7 +183,7 @@ const DatePickerInput = React.forwardRef(({
|
|
|
183
183
|
label={labelText}
|
|
184
184
|
defaultValue={formattedValue}
|
|
185
185
|
placeholder={inputFormatLabel}
|
|
186
|
-
inputMode={
|
|
186
|
+
inputMode={inputModes.number}
|
|
187
187
|
mask={inputFormat}
|
|
188
188
|
keyboardAppearance={theme.dark ? 'dark' : 'default'}
|
|
189
189
|
error={hasError}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "$react";
|
|
2
2
|
import {defaultObj,defaultStr,isNonNullString} from "$cutils";
|
|
3
|
-
import TextField from "$ecomponents/TextField";
|
|
3
|
+
import TextField,{inputModes} from "$ecomponents/TextField";
|
|
4
4
|
import { StyleSheet,Image,Pressable} from 'react-native';
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
import theme,{DISABLED_OPACITY} from "$theme";
|
|
@@ -175,7 +175,7 @@ export default function PhoneInputComponent(props){
|
|
|
175
175
|
</>
|
|
176
176
|
</Pressable>
|
|
177
177
|
}
|
|
178
|
-
inputMode ={
|
|
178
|
+
inputMode ={inputModes.number}
|
|
179
179
|
defaultValue = {state.displayValue}
|
|
180
180
|
onChange = {(args)=>{
|
|
181
181
|
const {value:nValue} = args;
|
|
@@ -9,7 +9,7 @@ import Icon,{COPY_ICON} from "$ecomponents/Icon";
|
|
|
9
9
|
import Label from "$ecomponents/Label";
|
|
10
10
|
import {isAndroid as _isAndroid,isIos as _isIos,isWeb as _isWeb} from "$cplatform";
|
|
11
11
|
import {isMobileMedia,isDesktopMedia} from "$cplatform/dimensions";
|
|
12
|
-
import {keyboardTypes,FONT_SIZE,parseDecimal,HEIGHT,outlinedMode,modes,flatMode,normalMode,shadowMode} from "./utils";
|
|
12
|
+
import {keyboardTypes,inputModes,FONT_SIZE,parseDecimal,HEIGHT,outlinedMode,modes,flatMode,normalMode,shadowMode} from "./utils";
|
|
13
13
|
import {copyTextToClipboard} from "$clipboard/utils";
|
|
14
14
|
import Surface from "$ecomponents/Surface";
|
|
15
15
|
import View from "$ecomponents/View";
|
|
@@ -17,8 +17,6 @@ const PADDING_HORIZONTAL_FLAT_MODE = 2;
|
|
|
17
17
|
|
|
18
18
|
export const LINE_HEIGHT = 10;
|
|
19
19
|
|
|
20
|
-
const EnterKey = "Enter".toLowerCase();
|
|
21
|
-
const BackSpaceKey = "Backspace".toLowerCase();
|
|
22
20
|
|
|
23
21
|
export * from "./utils";
|
|
24
22
|
|
|
@@ -100,27 +98,23 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
|
|
|
100
98
|
readOnly = defaultBool(readOnly,false);
|
|
101
99
|
|
|
102
100
|
const isEditable = !disabled && !readOnly;
|
|
103
|
-
inputMode = defaultStr(inputMode).toLowerCase();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if(!keyboardTypes[inputMode]){
|
|
107
|
-
for(let i in keyboardTypes){
|
|
108
|
-
if(inputMode === keyboardTypes[i]){
|
|
109
|
-
hasFountKeyboardType = true;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
101
|
+
inputMode = defaultStr(inputMode,inputModes.default).toLowerCase();
|
|
102
|
+
if(type === "phone" || type =="email"){
|
|
103
|
+
inputMode = inputModes.phone;
|
|
113
104
|
}
|
|
114
|
-
|
|
105
|
+
const hasFountKeyboardType = inputModes[inputMode.toLowerCase().trim()];
|
|
106
|
+
if(!hasFountKeyboardType && (!inputMode || !inputModes[inputMode])){
|
|
115
107
|
if(canValueBeDecimal){
|
|
116
|
-
inputMode =
|
|
108
|
+
inputMode = inputModes.decimal;
|
|
117
109
|
} else if(type == "email"){
|
|
118
|
-
inputMode =
|
|
110
|
+
inputMode = inputModes.email;
|
|
119
111
|
} else if(type =="phone" || type =="tel"){
|
|
120
|
-
inputMode =
|
|
121
|
-
}
|
|
122
|
-
inputMode =
|
|
123
|
-
}
|
|
112
|
+
inputMode = inputModes.phone;
|
|
113
|
+
} if(inputModes[type]){
|
|
114
|
+
inputMode = inputModes[type];
|
|
115
|
+
} else {
|
|
116
|
+
inputMode = inputModes.default;
|
|
117
|
+
}
|
|
124
118
|
}
|
|
125
119
|
const isSecureText = type =="password"?true : false;
|
|
126
120
|
const [secureTextEntry,setSecureTextEntry] = React.useState(isSecureText);
|
|
@@ -350,7 +344,7 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
|
|
|
350
344
|
backgroundColor : 'transparent',
|
|
351
345
|
color : !error && !isFocused && Colors.isValid(flattenStyle.color)?flattenStyle.color : inputColor,
|
|
352
346
|
fontSize,
|
|
353
|
-
verticalAlign: '
|
|
347
|
+
verticalAlign: 'middle',
|
|
354
348
|
overflow : 'hidden',
|
|
355
349
|
},
|
|
356
350
|
isWeb && { outline: 'none'},
|
|
@@ -366,6 +360,7 @@ const TextFieldComponent = React.forwardRef((componentProps,inputRef)=>{
|
|
|
366
360
|
],
|
|
367
361
|
secureTextEntry,
|
|
368
362
|
inputMode,
|
|
363
|
+
keyboardType : inputMode in inputModes ? keyboardTypes[inputMode] : keyboardTypes.default,
|
|
369
364
|
autoCapitalize : upper?(isAndroid?'characters':"none"):autoCapitalize,
|
|
370
365
|
value : currentDefaultValue,
|
|
371
366
|
realValue : text,
|
|
@@ -1 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
/****
|
|
5
|
+
* @namespace TextField
|
|
6
|
+
* contient un ensemble d'utilitaires pour la création du composant TextField
|
|
7
|
+
*/
|
|
8
|
+
import {defaultStr,parseDecimal as NParseDecimal,defaultDecimal} from "$cutils";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const flatMode = 'flat';
|
|
12
|
+
export const outlinedMode = 'outlined';
|
|
13
|
+
export const normalMode = "normal";
|
|
14
|
+
export const shadowMode = "shadow";
|
|
15
|
+
|
|
16
|
+
export const defaultMode = outlinedMode;
|
|
17
|
+
|
|
18
|
+
export const modes = {flat:flatMode,shadow:shadowMode,outlined:outlinedMode,normal:normalMode};
|
|
19
|
+
|
|
20
|
+
export const modesObject = {
|
|
21
|
+
flat : {
|
|
22
|
+
code : flatMode,
|
|
23
|
+
label : 'Flottant',
|
|
24
|
+
},
|
|
25
|
+
shadow : {
|
|
26
|
+
code : shadowMode,
|
|
27
|
+
label : 'Ombre',
|
|
28
|
+
},
|
|
29
|
+
normal : {
|
|
30
|
+
code : normalMode,
|
|
31
|
+
label : 'Normal',
|
|
32
|
+
},
|
|
33
|
+
outlined : {
|
|
34
|
+
code : outlinedMode,
|
|
35
|
+
label : 'Décrit',
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export const HEIGHT = 56;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
export const AutoCapitalizeTypes = {
|
|
44
|
+
characters : "characters", ///all characters.
|
|
45
|
+
words : "words", //first letter of each word.
|
|
46
|
+
sentences :"sentences", //first letter of each sentence (default).
|
|
47
|
+
none : "none", ///don't auto capitalize anything.
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const keyboardTypes = {
|
|
51
|
+
default : 'default',
|
|
52
|
+
number : "number-pad",
|
|
53
|
+
numberPad : "number-pad",
|
|
54
|
+
decimal : "decimal-pad",
|
|
55
|
+
numeric : "numeric",
|
|
56
|
+
email : "email-address",
|
|
57
|
+
tel : "phone-pad",
|
|
58
|
+
phone : "phone-pad",
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const inputModes = {
|
|
62
|
+
default : 'none',
|
|
63
|
+
number : "numberic",
|
|
64
|
+
decimal : "decimal",
|
|
65
|
+
numeric : "numeric",
|
|
66
|
+
email : "email",
|
|
67
|
+
tel : "tel",
|
|
68
|
+
phone : "tel",
|
|
69
|
+
search : "search",
|
|
70
|
+
url : "url",
|
|
71
|
+
}
|
|
72
|
+
export const FONT_SIZE = 16;
|
|
73
|
+
|
|
74
|
+
export const parseDecimal = (v,type,preserveDecimalLength)=>{
|
|
75
|
+
type = defaultStr(type).trim().toLowerCase();
|
|
76
|
+
if((type =='number' || type =='decimal') && !isDecimal(v)){
|
|
77
|
+
if(v == undefined || v == null){
|
|
78
|
+
v = '';
|
|
79
|
+
}
|
|
80
|
+
v = defaultDecimal(NParseDecimal(v,preserveDecimalLength),0);
|
|
81
|
+
}
|
|
82
|
+
return v;
|
|
83
|
+
}
|
package/src/context/Provider.js
CHANGED
|
@@ -7,6 +7,7 @@ import {isObj,isNonNullString} from "$cutils";
|
|
|
7
7
|
import eMainScreens from "$escreens/mainScreens";
|
|
8
8
|
import {ExpoUIContext} from "./hooks";
|
|
9
9
|
import Login from "$eauth/Login";
|
|
10
|
+
import {modes} from "$ecomponents/TextField";
|
|
10
11
|
|
|
11
12
|
/*****
|
|
12
13
|
les utilitaires disponibles à passer au provider :
|
|
@@ -75,7 +76,17 @@ const Provider = ({children,getTableData,navigation,components,convertFiltersToS
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
theme.fonts = newTheme.fonts;
|
|
78
|
-
|
|
79
|
+
const r = typeof extendAppTheme == 'function'? extendAppTheme(theme2) : theme2;
|
|
80
|
+
return {
|
|
81
|
+
...r,
|
|
82
|
+
get textFieldMode (){
|
|
83
|
+
/***** possibilité de charger le mode d'affichage par défaut des champs textuels dans le theme de l'application */
|
|
84
|
+
if(typeof Theme.current.textFieldMode =='string' && Theme.current.textFieldMode && modes[Theme.current.textFieldMode]){
|
|
85
|
+
return modes[Theme.current.textFieldMode];
|
|
86
|
+
}
|
|
87
|
+
return isMobileMedia()? modes.shadow : modes.flat;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
79
90
|
}
|
|
80
91
|
return <ExpoUIContext.Provider
|
|
81
92
|
value={{
|