@lookiero/checkout 0.2.18 → 0.2.20

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.
Files changed (21) hide show
  1. package/dist/infrastructure/ui/components/atoms/error/Error.d.ts +10 -0
  2. package/dist/infrastructure/ui/components/atoms/error/Error.js +5 -0
  3. package/dist/infrastructure/ui/components/atoms/error/Error.style.d.ts +6 -0
  4. package/dist/infrastructure/ui/components/atoms/error/Error.style.js +9 -0
  5. package/dist/infrastructure/ui/components/atoms/field/Field.d.ts +14 -0
  6. package/dist/infrastructure/ui/components/atoms/field/Field.js +28 -0
  7. package/dist/infrastructure/ui/components/atoms/field/Field.style.d.ts +7 -0
  8. package/dist/infrastructure/ui/components/atoms/field/Field.style.js +10 -0
  9. package/dist/infrastructure/ui/components/atoms/input/Input.d.ts +10 -0
  10. package/dist/infrastructure/ui/components/atoms/input/Input.js +29 -0
  11. package/dist/infrastructure/ui/components/atoms/input/Input.style.d.ts +15 -0
  12. package/dist/infrastructure/ui/components/atoms/input/Input.style.js +19 -0
  13. package/dist/infrastructure/ui/components/molecules/inputField/InputField.d.ts +22 -0
  14. package/dist/infrastructure/ui/components/molecules/inputField/InputField.js +26 -0
  15. package/dist/infrastructure/ui/components/molecules/inputField/InputField.style.d.ts +11 -0
  16. package/dist/infrastructure/ui/components/molecules/inputField/InputField.style.js +14 -0
  17. package/dist/infrastructure/ui/components/organisms/returnQuestions/ReturnQuestion.js +2 -5
  18. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/ReturnQuestionItem.d.ts +2 -8
  19. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/optionReturnQuestionItem/OptionReturnQuestionItem.js +4 -2
  20. package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +5 -5
  21. package/package.json +2 -1
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ import { StyleProp, TextStyle } from "react-native";
3
+ declare type ErrorStyle = StyleProp<TextStyle>;
4
+ interface ErrorProps {
5
+ readonly error?: string | null;
6
+ readonly style?: ErrorStyle;
7
+ }
8
+ declare const Error: FC<ErrorProps>;
9
+ export type { ErrorStyle };
10
+ export { Error };
@@ -0,0 +1,5 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import React from "react";
3
+ import { style } from "./Error.style";
4
+ const Error = ({ error, style: customStyle }) => (React.createElement(Text, { detail: true, level: 2, style: [style.error, customStyle] }, error));
5
+ export { Error };
@@ -0,0 +1,6 @@
1
+ declare const style: {
2
+ error: {
3
+ color: string;
4
+ };
5
+ };
6
+ export { style };
@@ -0,0 +1,9 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../theme/theme";
3
+ const { colorPrimary } = theme();
4
+ const style = StyleSheet.create({
5
+ error: {
6
+ color: colorPrimary,
7
+ },
8
+ });
9
+ export { style };
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ import { TextStyle, ViewStyle } from "react-native";
3
+ declare type FieldStyle = {
4
+ readonly field: ViewStyle;
5
+ readonly fieldText: TextStyle;
6
+ };
7
+ interface FieldProps {
8
+ readonly label: string;
9
+ readonly isFocused?: boolean;
10
+ readonly style?: FieldStyle;
11
+ }
12
+ declare const Field: FC<FieldProps>;
13
+ export type { FieldStyle };
14
+ export { Field };
@@ -0,0 +1,28 @@
1
+ import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
2
+ import { animated, useSpring } from "@react-spring/native";
3
+ import React from "react";
4
+ import { theme } from "../../../theme/theme";
5
+ import { style } from "./Field.style";
6
+ const { spaceM } = theme();
7
+ const Field = ({ label, isFocused = false, style: customStyle }) => {
8
+ const springs = useSpring(isFocused ? { scale: 0.75, translateY: -14, translateX: 0 } : { scale: 1, translateY: spaceM, translateX: spaceM });
9
+ return (React.createElement(animated.View, { pointerEvents: "none", style: [
10
+ style.field,
11
+ customStyle?.field,
12
+ {
13
+ transform: [
14
+ {
15
+ scale: springs.scale,
16
+ },
17
+ {
18
+ translateY: springs.translateY,
19
+ },
20
+ {
21
+ translateX: springs.translateX,
22
+ },
23
+ ],
24
+ },
25
+ ] },
26
+ React.createElement(Text, { detail: true, level: 1, style: customStyle?.fieldText }, label)));
27
+ };
28
+ export { Field };
@@ -0,0 +1,7 @@
1
+ declare const style: {
2
+ field: {
3
+ paddingHorizontal: number;
4
+ backgroundColor: string;
5
+ };
6
+ };
7
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../theme/theme";
3
+ const { colorBase, spaceS } = theme();
4
+ const style = StyleSheet.create({
5
+ field: {
6
+ paddingHorizontal: spaceS,
7
+ backgroundColor: colorBase,
8
+ },
9
+ });
10
+ export { style };
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ import { StyleProp, TextInputProps, TextStyle } from "react-native";
3
+ declare type InputStyle = StyleProp<TextStyle>;
4
+ interface InputProps extends TextInputProps {
5
+ readonly minHeight?: number;
6
+ readonly style?: InputStyle;
7
+ }
8
+ declare const Input: FC<InputProps>;
9
+ export type { InputStyle };
10
+ export { Input };
@@ -0,0 +1,29 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { Platform, TextInput, } from "react-native";
3
+ import { theme } from "../../../theme/theme";
4
+ import { style } from "./Input.style";
5
+ const DEFAULT_HEIGHT = 56;
6
+ const { colorGrayscaleL } = theme();
7
+ const Input = ({ minHeight = DEFAULT_HEIGHT, style: customStyle, onChange, onContentSizeChange, ...restOfProps }) => {
8
+ const [height, setHeight] = useState(minHeight);
9
+ // When content height has became smaller the onContentSizeChange does in fact triggered but the internal height is incorrect.
10
+ const handleOnContentSizeChange = useCallback((event) => {
11
+ onContentSizeChange?.(event);
12
+ if (Platform.OS === "web")
13
+ return;
14
+ setHeight(Math.max(minHeight, event.nativeEvent.contentSize.height));
15
+ }, [minHeight, onContentSizeChange]);
16
+ // It's just update textarea height based on el.scrollHeight
17
+ const handleOnChange = useCallback((event) => {
18
+ onChange?.(event);
19
+ if (Platform.OS !== "web")
20
+ return;
21
+ window.requestAnimationFrame(() => {
22
+ const element = event.nativeEvent.target;
23
+ element.style.height = "0px";
24
+ element.style.height = `${Math.max(minHeight, element.scrollHeight)}px`;
25
+ });
26
+ }, [minHeight, onChange]);
27
+ return (React.createElement(TextInput, { ...restOfProps, style: [style.input, customStyle, { height }], placeholderTextColor: colorGrayscaleL, textAlignVertical: "top", onContentSizeChange: handleOnContentSizeChange, onChange: handleOnChange, testID: "input" }));
28
+ };
29
+ export { Input };
@@ -0,0 +1,15 @@
1
+ declare const style: {
2
+ input: {
3
+ paddingHorizontal: number;
4
+ paddingTop: number;
5
+ paddingBottom: number;
6
+ borderWidth: number;
7
+ color: string;
8
+ fontFamily: string;
9
+ fontSize: number;
10
+ lineHeight: number;
11
+ letterSpacing: number;
12
+ outlineStyle: string;
13
+ };
14
+ };
15
+ export { style };
@@ -0,0 +1,19 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../theme/theme";
3
+ const { borderSize, colorContent, fontBodySize3, fontBodyHeight3, fontBodyLetterSpacing3, fontMap, spaceM } = theme();
4
+ const style = StyleSheet.create({
5
+ input: {
6
+ // paddingVertical not working in multiline mode
7
+ paddingHorizontal: spaceM,
8
+ paddingTop: spaceM,
9
+ paddingBottom: spaceM,
10
+ borderWidth: borderSize,
11
+ color: colorContent,
12
+ fontFamily: fontMap.Body,
13
+ fontSize: fontBodySize3,
14
+ lineHeight: fontBodyHeight3,
15
+ letterSpacing: fontBodyLetterSpacing3,
16
+ outlineStyle: "none",
17
+ },
18
+ });
19
+ export { style };
@@ -0,0 +1,22 @@
1
+ import { FC } from "react";
2
+ import { StyleProp, ViewStyle } from "react-native";
3
+ import { ErrorStyle } from "../../atoms/error/Error";
4
+ import { FieldStyle } from "../../atoms/field/Field";
5
+ import { InputStyle } from "../../atoms/input/Input";
6
+ declare type InputFieldStyle = FieldStyle & {
7
+ readonly inputField: StyleProp<ViewStyle>;
8
+ readonly input: InputStyle;
9
+ readonly error: ErrorStyle;
10
+ };
11
+ interface InputFieldProps {
12
+ readonly label: string;
13
+ readonly placeholder?: string;
14
+ readonly value: string | undefined;
15
+ readonly multiline?: boolean;
16
+ readonly minHeight?: number;
17
+ readonly error?: string | null;
18
+ readonly style?: Partial<InputFieldStyle>;
19
+ readonly onChange: (value: string) => void;
20
+ }
21
+ declare const InputField: FC<InputFieldProps>;
22
+ export { InputField };
@@ -0,0 +1,26 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { View } from "react-native";
3
+ import { theme } from "../../../theme/theme";
4
+ import { Error } from "../../atoms/error/Error";
5
+ import { Field } from "../../atoms/field/Field";
6
+ import { Input } from "../../atoms/input/Input";
7
+ import { style } from "./InputField.style";
8
+ const { colorContent, colorGrayscaleL, colorPrimary } = theme();
9
+ const InputField = ({ label, placeholder, value, multiline = false, minHeight, error, style: customStyle, onChange, }) => {
10
+ const [isFocused, setIsFocused] = useState(false);
11
+ const handleOnChange = useCallback((text) => onChange(text), [onChange]);
12
+ const handleOnBlur = useCallback(() => setIsFocused(false), []);
13
+ const handleOnFocus = useCallback(() => setIsFocused(true), []);
14
+ const color = error ? colorPrimary : isFocused ? colorContent : colorGrayscaleL;
15
+ return (React.createElement(View, { style: customStyle?.inputField },
16
+ React.createElement(Field, { label: label, isFocused: isFocused || !!value, style: {
17
+ field: { ...style.field, ...customStyle?.field },
18
+ fieldText: {
19
+ color,
20
+ ...customStyle?.fieldText,
21
+ },
22
+ } }),
23
+ React.createElement(Input, { value: value, placeholder: placeholder, multiline: multiline, minHeight: minHeight, onChangeText: handleOnChange, onBlur: handleOnBlur, onFocus: handleOnFocus, style: [{ borderColor: color }, customStyle?.input] }),
24
+ !!error && React.createElement(Error, { error: error, style: [style.error, customStyle?.error] })));
25
+ };
26
+ export { InputField };
@@ -0,0 +1,11 @@
1
+ declare const style: {
2
+ field: {
3
+ position: "absolute";
4
+ zIndex: number;
5
+ };
6
+ error: {
7
+ marginTop: number;
8
+ marginLeft: number;
9
+ };
10
+ };
11
+ export { style };
@@ -0,0 +1,14 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { theme } from "../../../theme/theme";
3
+ const { spaceXS, spaceL } = theme();
4
+ const style = StyleSheet.create({
5
+ field: {
6
+ position: "absolute",
7
+ zIndex: 4,
8
+ },
9
+ error: {
10
+ marginTop: spaceXS,
11
+ marginLeft: spaceL,
12
+ },
13
+ });
14
+ export { style };
@@ -1,11 +1,8 @@
1
- import React, { memo, useCallback } from "react";
2
- import { useReturnQuestionFeedbackForId } from "./behaviors/useReturnQuestionFeedback";
1
+ import React, { memo } from "react";
3
2
  import { useReturnQuestionItem } from "./behaviors/useReturnQuestionItem";
4
3
  const ReturnQuestion = ({ returnQuestion, returnQuestionParentId }) => {
5
4
  const Item = useReturnQuestionItem({ type: returnQuestion.type });
6
- const { onChange } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
7
- const handleOnChange = useCallback(({ feedback }) => onChange({ returnQuestionId: returnQuestionParentId, returnQuestionFeedback: feedback }), [onChange, returnQuestionParentId]);
8
- return (React.createElement(Item, { returnQuestion: returnQuestion, onChange: handleOnChange },
5
+ return (React.createElement(Item, { returnQuestion: returnQuestion, returnQuestionParentId: returnQuestionParentId },
9
6
  React.createElement(React.Fragment, null, returnQuestion.children?.map((childReturnQuestion) => (React.createElement(ReturnQuestion, { key: childReturnQuestion.id, returnQuestion: childReturnQuestion, returnQuestionParentId: returnQuestion.id }))))));
10
7
  };
11
8
  export default memo(ReturnQuestion);
@@ -1,15 +1,9 @@
1
1
  import { FC } from "react";
2
2
  import { ReturnQuestionProjection } from "../../../../../../projection/returnQuestion/returnQuestion";
3
- interface OnChangeReturnQuestionItemFunctionArgs {
4
- readonly feedback: string | undefined;
5
- }
6
- interface OnChangeReturnQuestionItemFunction {
7
- (args: OnChangeReturnQuestionItemFunctionArgs): void;
8
- }
9
3
  interface ReturnQuestionItemProps {
10
4
  readonly returnQuestion: ReturnQuestionProjection;
11
- readonly onChange: OnChangeReturnQuestionItemFunction;
5
+ readonly returnQuestionParentId: string;
12
6
  readonly children?: JSX.Element;
13
7
  }
14
8
  declare type ReturnQuestionItem = FC<ReturnQuestionItemProps>;
15
- export type { ReturnQuestionItem, ReturnQuestionItemProps, OnChangeReturnQuestionItemFunction };
9
+ export type { ReturnQuestionItem, ReturnQuestionItemProps };
@@ -3,10 +3,12 @@ import { useI18nMessage } from "@lookiero/i18n-react";
3
3
  import React, { useCallback } from "react";
4
4
  import { TouchableHighlight } from "react-native";
5
5
  import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
6
+ import { useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
6
7
  import { containerUnderlayColor, style } from "./OptionReturnQuestionItem.style";
7
- const OptionReturnQuestionItem = ({ returnQuestion, onChange }) => {
8
+ const OptionReturnQuestionItem = ({ returnQuestion, returnQuestionParentId, }) => {
9
+ const { onChange } = useReturnQuestionFeedbackForId({ id: returnQuestionParentId });
8
10
  const optionText = useI18nMessage({ id: returnQuestion.name, prefix: RETURN_QUESTIONS_PREFIX });
9
- const handleOnPress = useCallback(() => onChange({ feedback: returnQuestion.id }), [onChange, returnQuestion.id]);
11
+ const handleOnPress = useCallback(() => onChange({ returnQuestionId: returnQuestionParentId, returnQuestionFeedback: returnQuestion.id }), [onChange, returnQuestion.id, returnQuestionParentId]);
10
12
  return (React.createElement(TouchableHighlight, { style: style.container, onPress: handleOnPress, underlayColor: containerUnderlayColor },
11
13
  React.createElement(Text, { level: 3 }, optionText)));
12
14
  };
@@ -1,12 +1,12 @@
1
- import { InputField } from "@lookiero/aurora-next/build/components/atoms/InputField/InputField";
2
1
  import { useI18nMessage } from "@lookiero/i18n-react";
3
2
  import React, { useCallback } from "react";
4
3
  import { RETURN_QUESTIONS_PREFIX } from "../../../../../i18n/i18n";
4
+ import { InputField } from "../../../../molecules/inputField/InputField";
5
5
  import { useReturnQuestionFeedbackForId } from "../../behaviors/useReturnQuestionFeedback";
6
- const TextareaReturnQuestionItem = ({ returnQuestion, onChange }) => {
6
+ const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParentId, }) => {
7
7
  const placeholderText = useI18nMessage({ id: returnQuestion.placeholder, prefix: RETURN_QUESTIONS_PREFIX });
8
- const { feedback } = useReturnQuestionFeedbackForId({ id: returnQuestion.id });
9
- const handleOnChange = useCallback((value) => onChange({ feedback: value }), [onChange]);
10
- return (React.createElement(InputField, { name: returnQuestion.name, type: "text", multiLine: true, label: placeholderText, placeholder: placeholderText, value: feedback, onChange: handleOnChange }));
8
+ const { feedback, onChange } = useReturnQuestionFeedbackForId({ id: returnQuestionParentId });
9
+ const handleOnChange = useCallback((value) => onChange({ returnQuestionId: returnQuestionParentId, returnQuestionFeedback: value }), [onChange, returnQuestionParentId]);
10
+ return (React.createElement(InputField, { multiline: true, label: placeholderText, placeholder: placeholderText, minHeight: 96, value: feedback, onChange: handleOnChange }));
11
11
  };
12
12
  export { TextareaReturnQuestionItem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lookiero/checkout",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -27,6 +27,7 @@
27
27
  "@lookiero/i18n-react": "^0.8.0",
28
28
  "@lookiero/messaging": "^8.0.0",
29
29
  "@lookiero/messaging-react": "^8.0.0",
30
+ "@react-spring/native": "^9.5.5",
30
31
  "react-router-dom": "^6.4.1",
31
32
  "react-router-native": "^6.3.0",
32
33
  "tiny-invariant": "^1.2.0",