@lookiero/checkout 9.6.0 → 9.7.0-beta.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.
- package/dist/public/public/assets/adaptive-icon.png +0 -0
- package/dist/public/public/assets/favicon.png +0 -0
- package/dist/public/public/assets/icon.png +0 -0
- package/dist/public/public/assets/splash.png +0 -0
- package/dist/public/public/images/not-found.png +0 -0
- package/dist/src/ExpoRoot.js +1 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.js +3 -2
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.d.ts +10 -0
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.js +15 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.js +2 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +3 -3
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.d.ts +7 -0
- package/dist/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.js +10 -1
- package/dist/src/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.js +1 -2
- package/dist/src/shared/ui/components/atoms/field/Field.js +12 -15
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/ExpoRoot.tsx +1 -1
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.style.ts +19 -0
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/components/textareaCheckoutQuestionItem/TextareaCheckoutQuestionItem.tsx +17 -6
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/hostSelectReturnQuestionItem/HostSelectReturnQuestionItem.tsx +17 -3
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.style.ts +11 -1
- package/src/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.tsx +17 -7
- package/src/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.tsx +1 -1
- package/src/shared/ui/components/atoms/aspectRatioView/AspectRatioView.tsx +0 -46
- package/src/shared/ui/components/atoms/field/Field.style.ts +0 -22
- package/src/shared/ui/components/atoms/field/Field.test.tsx +0 -19
- package/src/shared/ui/components/atoms/field/Field.tsx +0 -54
- package/src/shared/ui/components/atoms/field/__snapshots__/Field.test.tsx.snap +0 -225
- package/src/shared/ui/components/molecules/inputField/InputField.style.ts +0 -40
- package/src/shared/ui/components/molecules/inputField/InputField.test.tsx +0 -41
- package/src/shared/ui/components/molecules/inputField/InputField.tsx +0 -97
- package/src/shared/ui/components/molecules/inputField/__snapshots__/InputField.test.tsx.snap +0 -172
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/src/ExpoRoot.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from "react";
|
|
2
2
|
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { InputField } from "
|
|
3
|
+
import { InputField, TextInput } from "@lookiero/sty-psp-ui";
|
|
4
4
|
import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
|
|
5
|
+
import { style } from "./TextareaCheckoutQuestionItem.style";
|
|
5
6
|
const TextareaCheckoutQuestionItem = ({ checkoutQuestion, checkoutQuestionParentId, testID, }) => {
|
|
6
7
|
const { formatMessage } = useIntl();
|
|
7
8
|
const placeholderText = useMemo(() => (checkoutQuestion.placeholder ? formatMessage({ id: checkoutQuestion.placeholder }) : ""), [formatMessage, checkoutQuestion.placeholder]);
|
|
8
9
|
const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
|
|
9
10
|
const handleOnChange = useCallback((value) => onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: value }), [onChange, checkoutQuestionParentId]);
|
|
10
|
-
return (React.createElement(InputField, { label: placeholderText, placeholder: placeholderText, testID: testID, value: feedback, multiline: true, onChange: handleOnChange }));
|
|
11
|
+
return (React.createElement(InputField, { label: placeholderText, style: { inputField: style.inputContainer, input: { container: style.inputContainer, input: style.input } }, value: feedback, input: ({ onBlur, onFocus, style }) => (React.createElement(TextInput, { placeholder: placeholderText, style: style, testID: testID, value: feedback, multiline: true, onBlur: onBlur, onChange: handleOnChange, onFocus: onFocus })) }));
|
|
11
12
|
};
|
|
12
13
|
export { TextareaCheckoutQuestionItem };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
|
+
const { space4 } = theme();
|
|
4
|
+
const INPUT_MIN_HEIGHT = 96;
|
|
5
|
+
const INPUT_MAX_HEIGHT = 242;
|
|
6
|
+
const style = StyleSheet.create({
|
|
7
|
+
input: {
|
|
8
|
+
paddingTop: space4,
|
|
9
|
+
},
|
|
10
|
+
inputContainer: {
|
|
11
|
+
maxHeight: INPUT_MAX_HEIGHT,
|
|
12
|
+
minHeight: INPUT_MIN_HEIGHT,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export { style };
|
|
@@ -3,8 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
3
3
|
import { TouchableHighlight, View } from "react-native";
|
|
4
4
|
import { ButtonIcon } from "@lookiero/aurora";
|
|
5
5
|
import { useIntl } from "@lookiero/i18n-react";
|
|
6
|
-
import { Modal } from "@lookiero/sty-psp-ui";
|
|
7
|
-
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
6
|
+
import { InputField, Modal, TextInput } from "@lookiero/sty-psp-ui";
|
|
8
7
|
import { useReturnQuestionFeedback, useReturnQuestionFeedbackForReturnQuestion, } from "../../behaviors/useReturnQuestionFeedback";
|
|
9
8
|
import { deepestReturnQuestionWithFeedbackForReturnQuestion, feedbackForReturnQuestion, } from "../../util/returnQuestionFeedback";
|
|
10
9
|
import { style, containerUnderlayColor } from "./HostSelectReturnQuestionItem.style";
|
|
@@ -34,7 +33,7 @@ const HostSelectReturnQuestionItem = ({ returnQuestion, children, portalHostName
|
|
|
34
33
|
return (React.createElement(React.Fragment, null,
|
|
35
34
|
React.createElement(TouchableHighlight, { accessibilityLabel: testID, style: style.container, testID: testID, underlayColor: containerUnderlayColor, accessible: true, onPress: handleOnPress },
|
|
36
35
|
React.createElement(View, { pointerEvents: "none" },
|
|
37
|
-
React.createElement(InputField, {
|
|
36
|
+
React.createElement(InputField, { icon: "arrow_down", label: placeholderText, value: inputValue, input: ({ onBlur, onFocus, style }) => (React.createElement(TextInput, { editable: false, placeholder: placeholderText, style: style, value: inputValue, onBlur: onBlur, onChange: () => void 0, onFocus: onFocus })) }))),
|
|
38
37
|
React.createElement(Modal, { portalHostName: portalHostName, style: deepestReturnQuestionWithFeedback && { header: style.header }, visible: modalVisible, header: deepestReturnQuestionWithFeedback && (React.createElement(ButtonIcon, { name: "arrow_left", style: style.backButton, testID: "modal-back-button", onPress: handleOnBackButtonPress })), scroll: true, showCloseButton: true, onClose: handleOnModalClose },
|
|
39
38
|
React.createElement(View, { style: style.modalContent }, children))));
|
|
40
39
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useCallback, useMemo } from "react";
|
|
3
3
|
import { View } from "@lookiero/aurora";
|
|
4
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
5
|
-
import { InputField } from "
|
|
5
|
+
import { InputField, TextInput } from "@lookiero/sty-psp-ui";
|
|
6
6
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
7
7
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
8
8
|
const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
@@ -10,7 +10,7 @@ const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, test
|
|
|
10
10
|
const placeholderText = useMemo(() => (returnQuestion.metadata.placeholder ? formatMessage({ id: returnQuestion.metadata.placeholder }) : ""), [formatMessage, returnQuestion.metadata.placeholder]);
|
|
11
11
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
12
12
|
const handleOnChange = useCallback((value) => onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: value }), [onChange, returnQuestionParent.id]);
|
|
13
|
-
return (React.createElement(View, { style: style.wrapper },
|
|
14
|
-
React.createElement(InputField, { label: placeholderText, placeholder: placeholderText, testID: testID, value: feedback, multiline: true, onChange: handleOnChange })));
|
|
13
|
+
return (React.createElement(View, { style: style.wrapper, testID: "textarea-return-question-item" },
|
|
14
|
+
React.createElement(InputField, { label: placeholderText, style: { inputField: style.inputContainer, input: { container: style.inputContainer, input: style.input } }, value: feedback, input: ({ onBlur, onFocus, style }) => (React.createElement(TextInput, { placeholder: placeholderText, style: style, testID: testID, value: feedback, multiline: true, onBlur: onBlur, onChange: handleOnChange, onFocus: onFocus })) })));
|
|
15
15
|
};
|
|
16
16
|
export { TextareaReturnQuestionItem };
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
|
-
const { colorBgBase, space6 } = theme();
|
|
3
|
+
const { colorBgBase, space4, space6 } = theme();
|
|
4
|
+
const INPUT_MIN_HEIGHT = 96;
|
|
5
|
+
const INPUT_MAX_HEIGHT = 242;
|
|
4
6
|
const style = StyleSheet.create({
|
|
7
|
+
input: {
|
|
8
|
+
paddingTop: space4,
|
|
9
|
+
},
|
|
10
|
+
inputContainer: {
|
|
11
|
+
maxHeight: INPUT_MAX_HEIGHT,
|
|
12
|
+
minHeight: INPUT_MIN_HEIGHT,
|
|
13
|
+
},
|
|
5
14
|
wrapper: {
|
|
6
15
|
backgroundColor: colorBgBase,
|
|
7
16
|
padding: space6,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { Bullets, Carousel, LazyImage, theme, useScreenSize, } from "@lookiero/sty-psp-ui";
|
|
2
|
+
import { AspectRatioView, Bullets, Carousel, LazyImage, theme, useScreenSize, } from "@lookiero/sty-psp-ui";
|
|
3
3
|
import { MediaPerspective } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
4
|
-
import { AspectRatioView } from "../../../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
|
|
5
4
|
import { useMediaImage } from "../../../../hooks/useMediaImage";
|
|
6
5
|
import { style } from "./ProductVariantSlider.style";
|
|
7
6
|
const { space16 } = theme();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { animated, useSpring } from "@react-spring/native";
|
|
1
2
|
import React, { useCallback, useState } from "react";
|
|
2
3
|
import { View } from "react-native";
|
|
3
|
-
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
4
4
|
import { Text } from "@lookiero/aurora";
|
|
5
5
|
import { theme } from "@lookiero/sty-psp-ui";
|
|
6
6
|
import { style } from "./Field.style";
|
|
@@ -9,20 +9,17 @@ const { space1, space4 } = theme();
|
|
|
9
9
|
const Field = ({ label, isFocused = false, style: customStyle }) => {
|
|
10
10
|
const [width, setWidth] = useState(0);
|
|
11
11
|
const handleOnLayout = useCallback(({ nativeEvent: { layout } }) => setWidth(layout.width), []);
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
],
|
|
24
|
-
}), [scale.value, translateX.value, translateY.value]);
|
|
25
|
-
return (React.createElement(Animated.View, { pointerEvents: "none", style: [customStyle?.field, animatedStyle], onLayout: handleOnLayout },
|
|
12
|
+
const springs = useSpring(isFocused
|
|
13
|
+
? { scale: SCALE, translateY: -14, translateX: -(((1 - SCALE) * width) / 2 + space1) }
|
|
14
|
+
: { scale: 1, translateY: space4, translateX: 0 });
|
|
15
|
+
return (React.createElement(animated.View, { pointerEvents: "none", style: [
|
|
16
|
+
{
|
|
17
|
+
transform: [{ scale: springs.scale }, { translateY: springs.translateY }, { translateX: springs.translateX }],
|
|
18
|
+
},
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
customStyle?.field,
|
|
22
|
+
], onLayout: handleOnLayout },
|
|
26
23
|
React.createElement(Text, { level: 1, numberOfLines: 1, style: [style.fieldText, customStyle?.fieldText], detail: true }, label),
|
|
27
24
|
React.createElement(View, { style: [style.fieldBackground, { opacity: isFocused ? 1 : 0 }] })));
|
|
28
25
|
};
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "9.
|
|
1
|
+
export declare const VERSION = "9.7.0-beta.1";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "9.
|
|
1
|
+
export const VERSION = "9.7.0-beta.1";
|
package/package.json
CHANGED
package/src/ExpoRoot.tsx
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
|
+
|
|
4
|
+
const { space4 } = theme();
|
|
5
|
+
|
|
6
|
+
const INPUT_MIN_HEIGHT = 96;
|
|
7
|
+
const INPUT_MAX_HEIGHT = 242;
|
|
8
|
+
|
|
9
|
+
const style = StyleSheet.create({
|
|
10
|
+
input: {
|
|
11
|
+
paddingTop: space4,
|
|
12
|
+
},
|
|
13
|
+
inputContainer: {
|
|
14
|
+
maxHeight: INPUT_MAX_HEIGHT,
|
|
15
|
+
minHeight: INPUT_MIN_HEIGHT,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { style };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from "react";
|
|
2
2
|
import { useIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { InputField } from "
|
|
3
|
+
import { InputField, TextInput } from "@lookiero/sty-psp-ui";
|
|
4
4
|
import { useCheckoutQuestionFeedbackForId } from "../../behaviors/useCheckoutQuestionFeedback";
|
|
5
5
|
import { CheckoutQuestionItem, CheckoutQuestionItemProps } from "../CheckoutQuestionItem";
|
|
6
|
+
import { style } from "./TextareaCheckoutQuestionItem.style";
|
|
6
7
|
|
|
7
8
|
const TextareaCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
8
9
|
checkoutQuestion,
|
|
@@ -17,18 +18,28 @@ const TextareaCheckoutQuestionItem: CheckoutQuestionItem = ({
|
|
|
17
18
|
|
|
18
19
|
const { feedback, onChange } = useCheckoutQuestionFeedbackForId({ id: checkoutQuestionParentId });
|
|
19
20
|
const handleOnChange = useCallback(
|
|
20
|
-
(value: string) =>
|
|
21
|
+
(value: string | undefined) =>
|
|
22
|
+
onChange({ checkoutQuestionId: checkoutQuestionParentId, checkoutQuestionFeedback: value }),
|
|
21
23
|
[onChange, checkoutQuestionParentId],
|
|
22
24
|
);
|
|
23
25
|
|
|
24
26
|
return (
|
|
25
27
|
<InputField
|
|
26
28
|
label={placeholderText}
|
|
27
|
-
|
|
28
|
-
testID={testID}
|
|
29
|
+
style={{ inputField: style.inputContainer, input: { container: style.inputContainer, input: style.input } }}
|
|
29
30
|
value={feedback}
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
input={({ onBlur, onFocus, style }) => (
|
|
32
|
+
<TextInput
|
|
33
|
+
placeholder={placeholderText}
|
|
34
|
+
style={style}
|
|
35
|
+
testID={testID}
|
|
36
|
+
value={feedback}
|
|
37
|
+
multiline
|
|
38
|
+
onBlur={onBlur}
|
|
39
|
+
onChange={handleOnChange}
|
|
40
|
+
onFocus={onFocus}
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
32
43
|
/>
|
|
33
44
|
);
|
|
34
45
|
};
|
|
@@ -3,9 +3,8 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
3
3
|
import { TouchableHighlight, View } from "react-native";
|
|
4
4
|
import { ButtonIcon } from "@lookiero/aurora";
|
|
5
5
|
import { useIntl } from "@lookiero/i18n-react";
|
|
6
|
-
import { Modal } from "@lookiero/sty-psp-ui";
|
|
6
|
+
import { InputField, Modal, TextInput } from "@lookiero/sty-psp-ui";
|
|
7
7
|
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
8
|
-
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
9
8
|
import {
|
|
10
9
|
useReturnQuestionFeedback,
|
|
11
10
|
useReturnQuestionFeedbackForReturnQuestion,
|
|
@@ -71,7 +70,22 @@ const HostSelectReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.HOST_S
|
|
|
71
70
|
onPress={handleOnPress}
|
|
72
71
|
>
|
|
73
72
|
<View pointerEvents="none">
|
|
74
|
-
<InputField
|
|
73
|
+
<InputField
|
|
74
|
+
icon="arrow_down"
|
|
75
|
+
label={placeholderText}
|
|
76
|
+
value={inputValue}
|
|
77
|
+
input={({ onBlur, onFocus, style }) => (
|
|
78
|
+
<TextInput
|
|
79
|
+
editable={false}
|
|
80
|
+
placeholder={placeholderText}
|
|
81
|
+
style={style}
|
|
82
|
+
value={inputValue}
|
|
83
|
+
onBlur={onBlur}
|
|
84
|
+
onChange={() => void 0}
|
|
85
|
+
onFocus={onFocus}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
/>
|
|
75
89
|
</View>
|
|
76
90
|
</TouchableHighlight>
|
|
77
91
|
<Modal
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
3
|
|
|
4
|
-
const { colorBgBase, space6 } = theme();
|
|
4
|
+
const { colorBgBase, space4, space6 } = theme();
|
|
5
|
+
|
|
6
|
+
const INPUT_MIN_HEIGHT = 96;
|
|
7
|
+
const INPUT_MAX_HEIGHT = 242;
|
|
5
8
|
|
|
6
9
|
const style = StyleSheet.create({
|
|
10
|
+
input: {
|
|
11
|
+
paddingTop: space4,
|
|
12
|
+
},
|
|
13
|
+
inputContainer: {
|
|
14
|
+
maxHeight: INPUT_MAX_HEIGHT,
|
|
15
|
+
minHeight: INPUT_MIN_HEIGHT,
|
|
16
|
+
},
|
|
7
17
|
wrapper: {
|
|
8
18
|
backgroundColor: colorBgBase,
|
|
9
19
|
padding: space6,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import React, { useCallback, useMemo } from "react";
|
|
3
3
|
import { View } from "@lookiero/aurora";
|
|
4
4
|
import { useIntl } from "@lookiero/i18n-react";
|
|
5
|
+
import { InputField, TextInput } from "@lookiero/sty-psp-ui";
|
|
5
6
|
import { ReturnQuestionType } from "../../../../../../../projection/returnQuestion/returnQuestion.constants";
|
|
6
|
-
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
7
7
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
8
8
|
import { ReturnQuestionItem } from "../ReturnQuestionItem";
|
|
9
9
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
@@ -22,19 +22,29 @@ const TextareaReturnQuestionItem: ReturnQuestionItem<ReturnQuestionType.TEXTAREA
|
|
|
22
22
|
|
|
23
23
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
24
24
|
const handleOnChange = useCallback(
|
|
25
|
-
(value: string) =>
|
|
25
|
+
(value: string | undefined) =>
|
|
26
|
+
onChange({ returnQuestionId: returnQuestionParent.id, returnQuestionFeedback: value }),
|
|
26
27
|
[onChange, returnQuestionParent.id],
|
|
27
28
|
);
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
|
-
<View style={style.wrapper}>
|
|
31
|
+
<View style={style.wrapper} testID="textarea-return-question-item">
|
|
31
32
|
<InputField
|
|
32
33
|
label={placeholderText}
|
|
33
|
-
|
|
34
|
-
testID={testID}
|
|
34
|
+
style={{ inputField: style.inputContainer, input: { container: style.inputContainer, input: style.input } }}
|
|
35
35
|
value={feedback}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
input={({ onBlur, onFocus, style }) => (
|
|
37
|
+
<TextInput
|
|
38
|
+
placeholder={placeholderText}
|
|
39
|
+
style={style}
|
|
40
|
+
testID={testID}
|
|
41
|
+
value={feedback}
|
|
42
|
+
multiline
|
|
43
|
+
onBlur={onBlur}
|
|
44
|
+
onChange={handleOnChange}
|
|
45
|
+
onFocus={onFocus}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
38
48
|
/>
|
|
39
49
|
</View>
|
|
40
50
|
);
|
package/src/infrastructure/ui/views/item/components/productVariantSlider/ProductVariantSlider.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { FC, useCallback, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
AspectRatioView,
|
|
3
4
|
Bullets,
|
|
4
5
|
Carousel,
|
|
5
6
|
LazyImage,
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
useScreenSize,
|
|
10
11
|
} from "@lookiero/sty-psp-ui";
|
|
11
12
|
import { MediaPerspective, MediaProjection } from "../../../../../../projection/checkoutItem/checkoutItem";
|
|
12
|
-
import { AspectRatioView } from "../../../../../../shared/ui/components/atoms/aspectRatioView/AspectRatioView";
|
|
13
13
|
import { useMediaImage } from "../../../../hooks/useMediaImage";
|
|
14
14
|
import { style } from "./ProductVariantSlider.style";
|
|
15
15
|
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React, { FC, ReactNode, useCallback, useState } from "react";
|
|
2
|
-
import { LayoutChangeEvent, StyleProp, View, ViewStyle } from "react-native";
|
|
3
|
-
|
|
4
|
-
interface Dimension {
|
|
5
|
-
readonly width?: number | undefined;
|
|
6
|
-
readonly height?: number | undefined;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
enum AspectRatioViewResizeDirection {
|
|
10
|
-
VERTICAL = "VERTICAL",
|
|
11
|
-
HORIZONTAL = "HORIZONTAL",
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface AspectRatioViewProps {
|
|
15
|
-
readonly aspectRatio?: number;
|
|
16
|
-
readonly resizeDirection?: AspectRatioViewResizeDirection;
|
|
17
|
-
readonly multiplier?: number;
|
|
18
|
-
readonly children: ReactNode;
|
|
19
|
-
readonly style?: StyleProp<ViewStyle>;
|
|
20
|
-
}
|
|
21
|
-
const AspectRatioView: FC<AspectRatioViewProps> = ({
|
|
22
|
-
aspectRatio = 1,
|
|
23
|
-
resizeDirection = AspectRatioViewResizeDirection.HORIZONTAL,
|
|
24
|
-
multiplier = 1,
|
|
25
|
-
style: customStyle = {},
|
|
26
|
-
children,
|
|
27
|
-
}) => {
|
|
28
|
-
const [{ width, height }, setDimension] = useState<Dimension>({});
|
|
29
|
-
const handleOnLayout = useCallback(
|
|
30
|
-
({ nativeEvent: { layout } }: LayoutChangeEvent) =>
|
|
31
|
-
setDimension(
|
|
32
|
-
resizeDirection === AspectRatioViewResizeDirection.HORIZONTAL
|
|
33
|
-
? { width: layout.width * multiplier, height: layout.width * aspectRatio }
|
|
34
|
-
: { width: layout.height * aspectRatio, height: layout.height },
|
|
35
|
-
),
|
|
36
|
-
[aspectRatio, multiplier, resizeDirection],
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<View onLayout={handleOnLayout}>
|
|
41
|
-
<View style={[{ width, height }, customStyle]}>{children}</View>
|
|
42
|
-
</View>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export { AspectRatioView, AspectRatioViewResizeDirection };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
2
|
-
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
|
-
|
|
4
|
-
const { colorBgBase, space1 } = theme();
|
|
5
|
-
|
|
6
|
-
const style = StyleSheet.create({
|
|
7
|
-
fieldBackground: {
|
|
8
|
-
backgroundColor: colorBgBase,
|
|
9
|
-
height: "100%",
|
|
10
|
-
position: "absolute",
|
|
11
|
-
width: "100%",
|
|
12
|
-
zIndex: 0,
|
|
13
|
-
},
|
|
14
|
-
fieldText: {
|
|
15
|
-
flexWrap: "nowrap",
|
|
16
|
-
overflow: "hidden",
|
|
17
|
-
paddingHorizontal: space1,
|
|
18
|
-
zIndex: 1,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export { style };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "../../../../../infrastructure/ui/test/render";
|
|
3
|
-
import { Field } from "./Field";
|
|
4
|
-
|
|
5
|
-
const label = "Field label";
|
|
6
|
-
|
|
7
|
-
describe("Field atom", () => {
|
|
8
|
-
it("matches the snapshot for a non-focused", () => {
|
|
9
|
-
const { toJSON } = render(<Field label={label} />);
|
|
10
|
-
|
|
11
|
-
expect(toJSON()).toMatchSnapshot("non-focused");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("matches the snapshot for focused", () => {
|
|
15
|
-
const { toJSON } = render(<Field label={label} isFocused />);
|
|
16
|
-
|
|
17
|
-
expect(toJSON()).toMatchSnapshot("focused");
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { FC, useCallback, useState } from "react";
|
|
2
|
-
import { LayoutChangeEvent, StyleProp, TextStyle, View, ViewStyle } from "react-native";
|
|
3
|
-
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
4
|
-
import { Text } from "@lookiero/aurora";
|
|
5
|
-
import { theme } from "@lookiero/sty-psp-ui";
|
|
6
|
-
import { style } from "./Field.style";
|
|
7
|
-
|
|
8
|
-
const SCALE = 0.75;
|
|
9
|
-
|
|
10
|
-
const { space1, space4 } = theme();
|
|
11
|
-
|
|
12
|
-
type FieldStyle = {
|
|
13
|
-
readonly field: StyleProp<ViewStyle>;
|
|
14
|
-
readonly fieldText: StyleProp<TextStyle>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
interface FieldProps {
|
|
18
|
-
readonly label: string;
|
|
19
|
-
readonly isFocused?: boolean;
|
|
20
|
-
readonly style?: FieldStyle;
|
|
21
|
-
}
|
|
22
|
-
const Field: FC<FieldProps> = ({ label, isFocused = false, style: customStyle }) => {
|
|
23
|
-
const [width, setWidth] = useState<number>(0);
|
|
24
|
-
const handleOnLayout = useCallback(({ nativeEvent: { layout } }: LayoutChangeEvent) => setWidth(layout.width), []);
|
|
25
|
-
|
|
26
|
-
const scale = useSharedValue(isFocused ? SCALE : 1);
|
|
27
|
-
scale.value = isFocused ? SCALE : 1;
|
|
28
|
-
const translateY = useSharedValue(isFocused ? -14 : space4);
|
|
29
|
-
translateY.value = isFocused ? -14 : space4;
|
|
30
|
-
const translateX = useSharedValue(isFocused ? -(((1 - SCALE) * width) / 2 + space1) : 0);
|
|
31
|
-
translateX.value = isFocused ? -(((1 - SCALE) * width) / 2 + space1) : 0;
|
|
32
|
-
const animatedStyle = useAnimatedStyle(
|
|
33
|
-
() => ({
|
|
34
|
-
transform: [
|
|
35
|
-
{ scale: withTiming(scale.value) },
|
|
36
|
-
{ translateY: withTiming(translateY.value) },
|
|
37
|
-
{ translateX: withTiming(translateX.value) },
|
|
38
|
-
],
|
|
39
|
-
}),
|
|
40
|
-
[scale.value, translateX.value, translateY.value],
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Animated.View pointerEvents="none" style={[customStyle?.field, animatedStyle]} onLayout={handleOnLayout}>
|
|
45
|
-
<Text level={1} numberOfLines={1} style={[style.fieldText, customStyle?.fieldText]} detail>
|
|
46
|
-
{label}
|
|
47
|
-
</Text>
|
|
48
|
-
<View style={[style.fieldBackground, { opacity: isFocused ? 1 : 0 }]} />
|
|
49
|
-
</Animated.View>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type { FieldStyle };
|
|
54
|
-
export { Field };
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Field atom matches the snapshot for a non-focused: non-focused 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
style={
|
|
6
|
-
[
|
|
7
|
-
{
|
|
8
|
-
"backgroundColor": "#FFFFFF",
|
|
9
|
-
"flex": 1,
|
|
10
|
-
},
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
<View
|
|
15
|
-
style={
|
|
16
|
-
[
|
|
17
|
-
{
|
|
18
|
-
"alignSelf": "center",
|
|
19
|
-
"left": 0,
|
|
20
|
-
"marginHorizontal": "auto",
|
|
21
|
-
"position": "absolute",
|
|
22
|
-
"right": 0,
|
|
23
|
-
"top": 0,
|
|
24
|
-
"width": "100%",
|
|
25
|
-
"zIndex": 5,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
>
|
|
30
|
-
<RCTSafeAreaView />
|
|
31
|
-
</View>
|
|
32
|
-
<View
|
|
33
|
-
collapsable={false}
|
|
34
|
-
jestAnimatedStyle={
|
|
35
|
-
{
|
|
36
|
-
"value": {
|
|
37
|
-
"transform": [
|
|
38
|
-
{
|
|
39
|
-
"scale": 1,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"translateY": 16,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"translateX": 0,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
onLayout={[Function]}
|
|
52
|
-
pointerEvents="none"
|
|
53
|
-
style={
|
|
54
|
-
{
|
|
55
|
-
"transform": [
|
|
56
|
-
{
|
|
57
|
-
"scale": 1,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"translateY": 16,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"translateX": 0,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
>
|
|
69
|
-
<Text
|
|
70
|
-
allowFontScaling={false}
|
|
71
|
-
numberOfLines={1}
|
|
72
|
-
selectable={false}
|
|
73
|
-
style={
|
|
74
|
-
[
|
|
75
|
-
{
|
|
76
|
-
"color": "#0C0A0A",
|
|
77
|
-
"flexWrap": "nowrap",
|
|
78
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
79
|
-
"fontSize": 13,
|
|
80
|
-
"letterSpacing": 0.1,
|
|
81
|
-
"lineHeight": 17,
|
|
82
|
-
"overflow": "hidden",
|
|
83
|
-
"paddingBottom": 0,
|
|
84
|
-
"paddingHorizontal": 4,
|
|
85
|
-
"paddingLeft": 0,
|
|
86
|
-
"paddingRight": 0,
|
|
87
|
-
"paddingTop": 4,
|
|
88
|
-
"zIndex": 1,
|
|
89
|
-
},
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
>
|
|
93
|
-
Field label
|
|
94
|
-
</Text>
|
|
95
|
-
<View
|
|
96
|
-
style={
|
|
97
|
-
[
|
|
98
|
-
{
|
|
99
|
-
"backgroundColor": "#FFFFFF",
|
|
100
|
-
"height": "100%",
|
|
101
|
-
"position": "absolute",
|
|
102
|
-
"width": "100%",
|
|
103
|
-
"zIndex": 0,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"opacity": 0,
|
|
107
|
-
},
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
/>
|
|
111
|
-
</View>
|
|
112
|
-
</View>
|
|
113
|
-
`;
|
|
114
|
-
|
|
115
|
-
exports[`Field atom matches the snapshot for focused: focused 1`] = `
|
|
116
|
-
<View
|
|
117
|
-
style={
|
|
118
|
-
[
|
|
119
|
-
{
|
|
120
|
-
"backgroundColor": "#FFFFFF",
|
|
121
|
-
"flex": 1,
|
|
122
|
-
},
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
>
|
|
126
|
-
<View
|
|
127
|
-
style={
|
|
128
|
-
[
|
|
129
|
-
{
|
|
130
|
-
"alignSelf": "center",
|
|
131
|
-
"left": 0,
|
|
132
|
-
"marginHorizontal": "auto",
|
|
133
|
-
"position": "absolute",
|
|
134
|
-
"right": 0,
|
|
135
|
-
"top": 0,
|
|
136
|
-
"width": "100%",
|
|
137
|
-
"zIndex": 5,
|
|
138
|
-
},
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
>
|
|
142
|
-
<RCTSafeAreaView />
|
|
143
|
-
</View>
|
|
144
|
-
<View
|
|
145
|
-
collapsable={false}
|
|
146
|
-
jestAnimatedStyle={
|
|
147
|
-
{
|
|
148
|
-
"value": {
|
|
149
|
-
"transform": [
|
|
150
|
-
{
|
|
151
|
-
"scale": 0.75,
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"translateY": -14,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"translateX": -4,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
onLayout={[Function]}
|
|
164
|
-
pointerEvents="none"
|
|
165
|
-
style={
|
|
166
|
-
{
|
|
167
|
-
"transform": [
|
|
168
|
-
{
|
|
169
|
-
"scale": 0.75,
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"translateY": -14,
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"translateX": -4,
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
>
|
|
181
|
-
<Text
|
|
182
|
-
allowFontScaling={false}
|
|
183
|
-
numberOfLines={1}
|
|
184
|
-
selectable={false}
|
|
185
|
-
style={
|
|
186
|
-
[
|
|
187
|
-
{
|
|
188
|
-
"color": "#0C0A0A",
|
|
189
|
-
"flexWrap": "nowrap",
|
|
190
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
191
|
-
"fontSize": 13,
|
|
192
|
-
"letterSpacing": 0.1,
|
|
193
|
-
"lineHeight": 17,
|
|
194
|
-
"overflow": "hidden",
|
|
195
|
-
"paddingBottom": 0,
|
|
196
|
-
"paddingHorizontal": 4,
|
|
197
|
-
"paddingLeft": 0,
|
|
198
|
-
"paddingRight": 0,
|
|
199
|
-
"paddingTop": 4,
|
|
200
|
-
"zIndex": 1,
|
|
201
|
-
},
|
|
202
|
-
]
|
|
203
|
-
}
|
|
204
|
-
>
|
|
205
|
-
Field label
|
|
206
|
-
</Text>
|
|
207
|
-
<View
|
|
208
|
-
style={
|
|
209
|
-
[
|
|
210
|
-
{
|
|
211
|
-
"backgroundColor": "#FFFFFF",
|
|
212
|
-
"height": "100%",
|
|
213
|
-
"position": "absolute",
|
|
214
|
-
"width": "100%",
|
|
215
|
-
"zIndex": 0,
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"opacity": 1,
|
|
219
|
-
},
|
|
220
|
-
]
|
|
221
|
-
}
|
|
222
|
-
/>
|
|
223
|
-
</View>
|
|
224
|
-
</View>
|
|
225
|
-
`;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { StyleSheet, Platform } from "react-native";
|
|
2
|
-
import { theme } from "@lookiero/sty-psp-ui";
|
|
3
|
-
|
|
4
|
-
const { space1, space4, space6, borderRadius2, borderWidth1 } = theme();
|
|
5
|
-
|
|
6
|
-
const style = StyleSheet.create({
|
|
7
|
-
error: {
|
|
8
|
-
marginLeft: space6,
|
|
9
|
-
marginTop: space1,
|
|
10
|
-
},
|
|
11
|
-
field: {
|
|
12
|
-
left: space4,
|
|
13
|
-
maxWidth: "100%",
|
|
14
|
-
position: "absolute",
|
|
15
|
-
zIndex: 4,
|
|
16
|
-
},
|
|
17
|
-
icon: {
|
|
18
|
-
height: 16,
|
|
19
|
-
position: "absolute",
|
|
20
|
-
right: space4,
|
|
21
|
-
top: space4,
|
|
22
|
-
width: 16,
|
|
23
|
-
zIndex: 4,
|
|
24
|
-
},
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
input: {
|
|
28
|
-
...Platform.select({
|
|
29
|
-
web: {
|
|
30
|
-
textOverflow: "ellipsis",
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
inputField: {
|
|
35
|
-
borderRadius: borderRadius2,
|
|
36
|
-
borderWidth: borderWidth1,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export { style };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { fireEvent } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { render } from "../../../../../infrastructure/ui/test/render";
|
|
4
|
-
import { InputField } from "./InputField";
|
|
5
|
-
|
|
6
|
-
const label = "InputField label";
|
|
7
|
-
const value = "InputField value";
|
|
8
|
-
const mockOnChange = jest.fn();
|
|
9
|
-
|
|
10
|
-
describe("InputField molecule", () => {
|
|
11
|
-
it("matches the snapshot", () => {
|
|
12
|
-
const { toJSON } = render(<InputField label={label} value={value} onChange={mockOnChange} />);
|
|
13
|
-
|
|
14
|
-
expect(toJSON()).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("renders correctly", () => {
|
|
18
|
-
const { getByTestId } = render(<InputField label={label} value={value} onChange={mockOnChange} />);
|
|
19
|
-
|
|
20
|
-
const newValue = "New input value";
|
|
21
|
-
fireEvent.changeText(getByTestId("input-input"), newValue);
|
|
22
|
-
|
|
23
|
-
expect(mockOnChange).toHaveBeenCalledWith(newValue);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("renders correctly if there is error", () => {
|
|
27
|
-
const error = "InputField error";
|
|
28
|
-
|
|
29
|
-
const { getByText } = render(<InputField error={error} label={label} value={value} onChange={mockOnChange} />);
|
|
30
|
-
|
|
31
|
-
expect(getByText(error)).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it.skip("renders correctly if there is an icon", () => {
|
|
35
|
-
const { getByTestId } = render(
|
|
36
|
-
<InputField icon="arrow_down" label={label} value={value} onChange={mockOnChange} />,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
expect(getByTestId("icon")).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React, { FC, useCallback, useState } from "react";
|
|
2
|
-
import { StyleProp, TextStyle, View, ViewStyle } from "react-native";
|
|
3
|
-
import { COLOR, Icon, IconName, Input, InputProperties } from "@lookiero/aurora";
|
|
4
|
-
import { Error, ErrorStyle, theme } from "@lookiero/sty-psp-ui";
|
|
5
|
-
import { Field, FieldStyle } from "../../atoms/field/Field";
|
|
6
|
-
import { style } from "./InputField.style";
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
colorBgBase,
|
|
10
|
-
colorBorderInput,
|
|
11
|
-
colorBorderInputError,
|
|
12
|
-
colorBorderInputFocus,
|
|
13
|
-
colorText,
|
|
14
|
-
colorTextError,
|
|
15
|
-
colorTextMedium,
|
|
16
|
-
iconSize,
|
|
17
|
-
space6,
|
|
18
|
-
} = theme();
|
|
19
|
-
|
|
20
|
-
const inputPaddingRightWithIcon = iconSize + space6;
|
|
21
|
-
|
|
22
|
-
type IconStyle = StyleProp<TextStyle>;
|
|
23
|
-
|
|
24
|
-
type InputFieldStyle = FieldStyle & {
|
|
25
|
-
readonly inputField: StyleProp<ViewStyle>;
|
|
26
|
-
readonly error: ErrorStyle;
|
|
27
|
-
readonly icon: IconStyle;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
interface InputFieldBaseProps {
|
|
31
|
-
readonly label: string;
|
|
32
|
-
readonly multiline?: boolean;
|
|
33
|
-
readonly error?: string | null;
|
|
34
|
-
readonly style?: Partial<InputFieldStyle>;
|
|
35
|
-
readonly onChange?: (value: string) => void;
|
|
36
|
-
readonly icon?: IconName;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface InputFieldProps extends Omit<InputProperties, keyof InputFieldBaseProps>, InputFieldBaseProps {}
|
|
40
|
-
|
|
41
|
-
const InputField: FC<InputFieldProps> = ({
|
|
42
|
-
label,
|
|
43
|
-
placeholder,
|
|
44
|
-
value,
|
|
45
|
-
multiline = false,
|
|
46
|
-
error,
|
|
47
|
-
style: customStyle,
|
|
48
|
-
onChange = () => void 0,
|
|
49
|
-
icon,
|
|
50
|
-
testID = "input",
|
|
51
|
-
...inputRestProps
|
|
52
|
-
}) => {
|
|
53
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
54
|
-
|
|
55
|
-
const handleOnChange = useCallback((text: string) => onChange(text), [onChange]);
|
|
56
|
-
|
|
57
|
-
const handleOnBlur = useCallback(() => setIsFocused(false), []);
|
|
58
|
-
|
|
59
|
-
const handleOnFocus = useCallback(() => setIsFocused(true), []);
|
|
60
|
-
|
|
61
|
-
const borderColor = error ? colorBorderInputError : isFocused ? colorBorderInputFocus : colorBorderInput;
|
|
62
|
-
const color = error ? colorTextError : isFocused ? colorText : colorTextMedium;
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<View style={[style.inputField, { borderColor }, customStyle?.inputField]} testID="input-field">
|
|
66
|
-
<Field
|
|
67
|
-
isFocused={isFocused || !!value}
|
|
68
|
-
label={label}
|
|
69
|
-
style={{
|
|
70
|
-
field: [style.field, customStyle?.field],
|
|
71
|
-
fieldText: [{ color }, customStyle?.fieldText],
|
|
72
|
-
}}
|
|
73
|
-
/>
|
|
74
|
-
<Input
|
|
75
|
-
autoCapitalize="sentences"
|
|
76
|
-
multiline={multiline}
|
|
77
|
-
multilineMaxHeight={242}
|
|
78
|
-
placeholder={placeholder}
|
|
79
|
-
placeholderTextColor={isFocused ? colorTextMedium : colorBgBase}
|
|
80
|
-
style={[!!icon && { paddingRight: inputPaddingRightWithIcon }, style.input, { color }]}
|
|
81
|
-
testID={testID}
|
|
82
|
-
value={value}
|
|
83
|
-
onBlur={handleOnBlur}
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
onChange={handleOnChange}
|
|
87
|
-
onFocus={handleOnFocus}
|
|
88
|
-
{...inputRestProps}
|
|
89
|
-
/>
|
|
90
|
-
{!!icon && <Icon color={COLOR.GRAYSCALE_L} name={icon} style={[style.icon, customStyle?.icon]} testID="icon" />}
|
|
91
|
-
{!!error && <Error error={error} style={[style.error, customStyle?.error]} />}
|
|
92
|
-
</View>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export type { InputFieldStyle };
|
|
97
|
-
export { InputField };
|
package/src/shared/ui/components/molecules/inputField/__snapshots__/InputField.test.tsx.snap
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`InputField molecule matches the snapshot 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
style={
|
|
6
|
-
[
|
|
7
|
-
{
|
|
8
|
-
"backgroundColor": "#FFFFFF",
|
|
9
|
-
"flex": 1,
|
|
10
|
-
},
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
>
|
|
14
|
-
<View
|
|
15
|
-
style={
|
|
16
|
-
[
|
|
17
|
-
{
|
|
18
|
-
"alignSelf": "center",
|
|
19
|
-
"left": 0,
|
|
20
|
-
"marginHorizontal": "auto",
|
|
21
|
-
"position": "absolute",
|
|
22
|
-
"right": 0,
|
|
23
|
-
"top": 0,
|
|
24
|
-
"width": "100%",
|
|
25
|
-
"zIndex": 5,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
>
|
|
30
|
-
<RCTSafeAreaView />
|
|
31
|
-
</View>
|
|
32
|
-
<View
|
|
33
|
-
style={
|
|
34
|
-
[
|
|
35
|
-
{
|
|
36
|
-
"borderRadius": 4,
|
|
37
|
-
"borderWidth": 1,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"borderColor": "#DAD8D8",
|
|
41
|
-
},
|
|
42
|
-
undefined,
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
testID="input-field"
|
|
46
|
-
>
|
|
47
|
-
<View
|
|
48
|
-
collapsable={false}
|
|
49
|
-
jestAnimatedStyle={
|
|
50
|
-
{
|
|
51
|
-
"value": {
|
|
52
|
-
"transform": [
|
|
53
|
-
{
|
|
54
|
-
"scale": 0.75,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"translateY": -14,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"translateX": -4,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
onLayout={[Function]}
|
|
67
|
-
pointerEvents="none"
|
|
68
|
-
style={
|
|
69
|
-
{
|
|
70
|
-
"left": 16,
|
|
71
|
-
"maxWidth": "100%",
|
|
72
|
-
"position": "absolute",
|
|
73
|
-
"transform": [
|
|
74
|
-
{
|
|
75
|
-
"scale": 0.75,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"translateY": -14,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"translateX": -4,
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
"zIndex": 4,
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
>
|
|
88
|
-
<Text
|
|
89
|
-
allowFontScaling={false}
|
|
90
|
-
numberOfLines={1}
|
|
91
|
-
selectable={false}
|
|
92
|
-
style={
|
|
93
|
-
[
|
|
94
|
-
{
|
|
95
|
-
"color": "#837C7C",
|
|
96
|
-
"flexWrap": "nowrap",
|
|
97
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
98
|
-
"fontSize": 13,
|
|
99
|
-
"letterSpacing": 0.1,
|
|
100
|
-
"lineHeight": 17,
|
|
101
|
-
"overflow": "hidden",
|
|
102
|
-
"paddingBottom": 0,
|
|
103
|
-
"paddingHorizontal": 4,
|
|
104
|
-
"paddingLeft": 0,
|
|
105
|
-
"paddingRight": 0,
|
|
106
|
-
"paddingTop": 4,
|
|
107
|
-
"zIndex": 1,
|
|
108
|
-
},
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
>
|
|
112
|
-
InputField label
|
|
113
|
-
</Text>
|
|
114
|
-
<View
|
|
115
|
-
style={
|
|
116
|
-
[
|
|
117
|
-
{
|
|
118
|
-
"backgroundColor": "#FFFFFF",
|
|
119
|
-
"height": "100%",
|
|
120
|
-
"position": "absolute",
|
|
121
|
-
"width": "100%",
|
|
122
|
-
"zIndex": 0,
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"opacity": 1,
|
|
126
|
-
},
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
/>
|
|
130
|
-
</View>
|
|
131
|
-
<TextInput
|
|
132
|
-
allowFontScaling={false}
|
|
133
|
-
autoCapitalize="sentences"
|
|
134
|
-
autoCorrect={true}
|
|
135
|
-
editable={true}
|
|
136
|
-
keyboardType="default"
|
|
137
|
-
multiline={false}
|
|
138
|
-
onBlur={[Function]}
|
|
139
|
-
onChangeText={[Function]}
|
|
140
|
-
onContentSizeChange={[Function]}
|
|
141
|
-
onFocus={[Function]}
|
|
142
|
-
placeholderTextColor="#FFFFFF"
|
|
143
|
-
secureTextEntry={false}
|
|
144
|
-
style={
|
|
145
|
-
[
|
|
146
|
-
{
|
|
147
|
-
"fontFamily": "AreaNormal-Semibold",
|
|
148
|
-
"fontSize": 15,
|
|
149
|
-
"letterSpacing": -0.3,
|
|
150
|
-
"lineHeight": 20,
|
|
151
|
-
"paddingBottom": 16,
|
|
152
|
-
"paddingLeft": 16,
|
|
153
|
-
"paddingRight": 16,
|
|
154
|
-
"paddingTop": 11,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"color": "#0C0A0A",
|
|
158
|
-
"flex": 0,
|
|
159
|
-
"height": 56,
|
|
160
|
-
},
|
|
161
|
-
{},
|
|
162
|
-
{
|
|
163
|
-
"color": "#837C7C",
|
|
164
|
-
},
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
testID="input-input"
|
|
168
|
-
value="InputField value"
|
|
169
|
-
/>
|
|
170
|
-
</View>
|
|
171
|
-
</View>
|
|
172
|
-
`;
|