@lichens-innovation/react-native-common 3.8.0 → 3.8.1
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.
|
@@ -8,7 +8,7 @@ interface DialogSingleTextInputProps extends Omit<DialogProps, 'children' | 'vis
|
|
|
8
8
|
onChange: (value: string) => void;
|
|
9
9
|
errorMessage?: string;
|
|
10
10
|
placeholder?: string;
|
|
11
|
-
onOk: () => void;
|
|
11
|
+
onOk: (inputValue: string) => void;
|
|
12
12
|
onCancel: () => void;
|
|
13
13
|
isVisible: boolean;
|
|
14
14
|
}
|
|
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useState } from 'react';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { StyleSheet } from 'react-native';
|
|
15
16
|
import { Button, Dialog, Portal, Text, TextInput } from 'react-native-paper';
|
|
@@ -20,17 +21,23 @@ export const DialogSingleTextInput = (_a) => {
|
|
|
20
21
|
const { style: dialogStyleProp } = rest, dialogProps = __rest(rest, ["style"]);
|
|
21
22
|
const styles = useStyles();
|
|
22
23
|
const { t } = useTranslation();
|
|
24
|
+
const [selection, setSelection] = useState();
|
|
25
|
+
const [inputValue, setInputValue] = useState(value);
|
|
23
26
|
const hasTitle = !!title;
|
|
24
27
|
const hasTitleString = typeof title === 'string';
|
|
25
28
|
const hasDescription = !!description;
|
|
26
29
|
const hasDescriptionString = typeof description === 'string';
|
|
27
30
|
const hasError = !!errorMessage;
|
|
28
|
-
const isInputPopulated =
|
|
31
|
+
const isInputPopulated = inputValue.trim().length > 0;
|
|
29
32
|
const isOkEnabled = !hasError && isInputPopulated;
|
|
33
|
+
const onChangeText = (text) => {
|
|
34
|
+
setInputValue(text);
|
|
35
|
+
onChange(text);
|
|
36
|
+
};
|
|
30
37
|
if (!isVisible) {
|
|
31
38
|
return null;
|
|
32
39
|
}
|
|
33
|
-
return (_jsx(Portal, { children: _jsxs(Dialog, Object.assign({}, dialogProps, { style: [styles.dialog, dialogStyleProp], visible: true, onDismiss: onCancel, children: [hasTitle && _jsx(Dialog.Title, { children: hasTitleString ? _jsx(Text, { children: title }) : title }), hasDescription && (_jsx(Dialog.Content, { children: hasDescriptionString ? _jsx(Text, { children: description }) : description })), _jsxs(Dialog.Content, { children: [_jsx(TextInput, { mode: "outlined", value:
|
|
40
|
+
return (_jsx(Portal, { children: _jsxs(Dialog, Object.assign({}, dialogProps, { style: [styles.dialog, dialogStyleProp], visible: true, onDismiss: onCancel, children: [hasTitle && _jsx(Dialog.Title, { children: hasTitleString ? _jsx(Text, { children: title }) : title }), hasDescription && (_jsx(Dialog.Content, { children: hasDescriptionString ? _jsx(Text, { children: description }) : description })), _jsxs(Dialog.Content, { children: [_jsx(TextInput, { mode: "outlined", value: inputValue, onChangeText: onChangeText, selection: selection, onSelectionChange: (e) => setSelection(e.nativeEvent.selection), placeholder: placeholder, error: hasError }), hasError && _jsx(Text, { variant: "bodyMedium", style: styles.errorText, children: errorMessage })] }), _jsxs(Dialog.Actions, { children: [_jsx(Button, { onPress: onCancel, children: t('common:cancel') }), _jsx(Button, { style: styles.button, mode: "contained", onPress: () => onOk(inputValue), disabled: !isOkEnabled, children: t('common:ok') })] })] })) }));
|
|
34
41
|
};
|
|
35
42
|
const useStyles = () => {
|
|
36
43
|
const theme = useAppTheme();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-single-textinput.js","sourceRoot":"","sources":["../../../src/components/dialogs/dialog-single-textinput.tsx"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dialog-single-textinput.js","sourceRoot":"","sources":["../../../src/components/dialogs/dialog-single-textinput.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAA0E,QAAQ,EAAE,MAAM,OAAO,CAA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M,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAC,WAAW,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,WAAW,YACnG,CAAC,CAAC,WAAW,CAAC,GACR,IACM,KACV,GACF,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE,CAAC;IAE/C,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,EAAE;SACV;QACD,MAAM,EAAE;YACN,KAAK;YACL,SAAS;SACV;QACD,SAAS,EAAE;YACT,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;SAC1B;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Lichens Innovation React Native Expo shared components, utilities, hooks and services",
|
|
4
4
|
"repository": "https://github.com/Lichens-Innovation/react-native-common",
|
|
5
5
|
"author": "Lichens Innovation",
|
|
6
|
-
"version": "3.8.
|
|
6
|
+
"version": "3.8.1",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|