@lichens-innovation/react-native-common 3.5.0 → 3.6.0
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/dist/components/dialogs/dialog-single-textinput.d.ts +16 -0
- package/dist/components/dialogs/dialog-single-textinput.js +52 -0
- package/dist/components/dialogs/dialog-single-textinput.js.map +1 -0
- package/dist/components/dialogs/index.d.ts +1 -0
- package/dist/components/dialogs/index.js +1 -0
- package/dist/components/dialogs/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ComponentProps, type FunctionComponent, type ReactNode } from 'react';
|
|
2
|
+
import { Dialog } from 'react-native-paper';
|
|
3
|
+
type DialogProps = ComponentProps<typeof Dialog>;
|
|
4
|
+
interface DialogSingleTextInputProps extends Omit<DialogProps, 'children' | 'visible'> {
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
value: string;
|
|
8
|
+
onChange: (value: string) => void;
|
|
9
|
+
errorMessage?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
onOk: () => void;
|
|
12
|
+
onCancel: () => void;
|
|
13
|
+
isVisible: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const DialogSingleTextInput: FunctionComponent<DialogSingleTextInputProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { StyleSheet } from 'react-native';
|
|
15
|
+
import { Button, Dialog, Portal, Text, TextInput } from 'react-native-paper';
|
|
16
|
+
import { useAppTheme } from '../../theme/theme';
|
|
17
|
+
import { useDialogStyles } from './use-dialog-styles';
|
|
18
|
+
export const DialogSingleTextInput = (_a) => {
|
|
19
|
+
var { title, description, value, onChange, errorMessage, placeholder, onOk, onCancel, isVisible } = _a, rest = __rest(_a, ["title", "description", "value", "onChange", "errorMessage", "placeholder", "onOk", "onCancel", "isVisible"]);
|
|
20
|
+
const { style: dialogStyleProp } = rest, dialogProps = __rest(rest, ["style"]);
|
|
21
|
+
const styles = useStyles();
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const hasTitle = !!title;
|
|
24
|
+
const hasTitleString = typeof title === 'string';
|
|
25
|
+
const hasDescription = !!description;
|
|
26
|
+
const hasDescriptionString = typeof description === 'string';
|
|
27
|
+
const hasError = !!errorMessage;
|
|
28
|
+
const isInputPopulated = value.trim().length > 0;
|
|
29
|
+
const isOkEnabled = !hasError && isInputPopulated;
|
|
30
|
+
if (!isVisible) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
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: value, onChangeText: onChange, placeholder: placeholder, error: hasError, autoFocus: true }), 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, disabled: !isOkEnabled, children: t('common:ok') })] })] })) }));
|
|
34
|
+
};
|
|
35
|
+
const useStyles = () => {
|
|
36
|
+
const theme = useAppTheme();
|
|
37
|
+
const { width, alignSelf } = useDialogStyles();
|
|
38
|
+
return StyleSheet.create({
|
|
39
|
+
button: {
|
|
40
|
+
width: 60,
|
|
41
|
+
},
|
|
42
|
+
dialog: {
|
|
43
|
+
width,
|
|
44
|
+
alignSelf,
|
|
45
|
+
},
|
|
46
|
+
errorText: {
|
|
47
|
+
marginTop: theme.spacing(1),
|
|
48
|
+
color: theme.colors.error,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=dialog-single-textinput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-single-textinput.js","sourceRoot":"","sources":["../../../src/components/dialogs/dialog-single-textinput.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAgBtD,MAAM,CAAC,MAAM,qBAAqB,GAAkD,CAAC,EAWpF,EAAE,EAAE;QAXgF,EACnF,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,SAAS,OAEV,EADI,IAAI,cAV4E,6GAWpF,CADQ;IAEP,MAAM,EAAE,KAAK,EAAE,eAAe,KAAqB,IAAI,EAApB,WAAW,UAA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,SACT,EAED,QAAQ,IAAI,KAAC,IAAI,IAAC,OAAO,EAAC,YAAY,EAAC,KAAK,EAAE,MAAM,CAAC,SAAS,YAAG,YAAY,GAAQ,IACvE,EAEjB,MAAC,MAAM,CAAC,OAAO,eACb,KAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,YAAG,CAAC,CAAC,eAAe,CAAC,GAAU,EACxD,KAAC,MAAM,IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAC,WAAW,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,WAAW,YACjF,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/dialogs/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/dialogs/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,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.
|
|
6
|
+
"version": "3.6.0",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|