@lookiero/checkout 0.2.28 → 0.2.29
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/infrastructure/ui/shared/components/molecules/selectField/SelectField.d.ts +24 -0
- package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.js +26 -0
- package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.style.d.ts +15 -0
- package/dist/infrastructure/ui/shared/components/molecules/selectField/SelectField.style.js +18 -0
- package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.js +3 -4
- package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.style.d.ts +4 -5
- package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.style.js +4 -5
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { StyleProp, TextStyle, TouchableHighlightProps, ViewStyle } from "react-native";
|
|
3
|
+
interface SelectFieldStyle {
|
|
4
|
+
readonly selectField: StyleProp<ViewStyle>;
|
|
5
|
+
readonly modalContent: StyleProp<ViewStyle>;
|
|
6
|
+
readonly option: StyleProp<ViewStyle>;
|
|
7
|
+
readonly optionText: StyleProp<TextStyle>;
|
|
8
|
+
}
|
|
9
|
+
interface Option {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly value: string;
|
|
12
|
+
}
|
|
13
|
+
interface SelectFieldBaseProps {
|
|
14
|
+
readonly placeholder: string;
|
|
15
|
+
readonly value: string | undefined;
|
|
16
|
+
readonly options: Option[];
|
|
17
|
+
readonly style?: Partial<SelectFieldStyle>;
|
|
18
|
+
readonly onChange?: (value: string) => void;
|
|
19
|
+
}
|
|
20
|
+
interface SelectFieldProps extends Omit<TouchableHighlightProps, keyof SelectFieldBaseProps>, SelectFieldBaseProps {
|
|
21
|
+
}
|
|
22
|
+
declare const SelectField: FC<SelectFieldProps>;
|
|
23
|
+
export type { Option };
|
|
24
|
+
export { SelectField };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
2
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { TouchableHighlight, View } from "react-native";
|
|
4
|
+
import { theme } from "../../../../theme/theme";
|
|
5
|
+
import { Modal } from "../../layouts/modal/Modal";
|
|
6
|
+
import { InputField } from "../inputField/InputField";
|
|
7
|
+
import { style } from "./SelectField.style";
|
|
8
|
+
const { colorGrayscaleS } = theme();
|
|
9
|
+
const SelectField = ({ placeholder, value, options, style: customStyle, onChange = () => void 0, ...touchableRestProps }) => {
|
|
10
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
11
|
+
const handleOnPressSelectField = useCallback(() => setModalVisible(true), []);
|
|
12
|
+
const handleOnModalClose = useCallback(() => setModalVisible(false), []);
|
|
13
|
+
const handleOnPressOption = useCallback((value) => {
|
|
14
|
+
onChange(value);
|
|
15
|
+
handleOnModalClose();
|
|
16
|
+
}, [handleOnModalClose, onChange]);
|
|
17
|
+
const selectedValue = useMemo(() => options.find((option) => option.value === value), [options, value]);
|
|
18
|
+
return (React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement(TouchableHighlight, { style: customStyle?.selectField, underlayColor: colorGrayscaleS, onPress: handleOnPressSelectField, ...touchableRestProps },
|
|
20
|
+
React.createElement(View, { pointerEvents: "none" },
|
|
21
|
+
React.createElement(InputField, { editable: false, icon: "arrow-down", label: placeholder, value: selectedValue?.label }))),
|
|
22
|
+
React.createElement(Modal, { visible: modalVisible, scroll: true, onClose: handleOnModalClose },
|
|
23
|
+
React.createElement(View, { style: [style.modalContent, customStyle?.modalContent] }, options.map(({ label, value }) => (React.createElement(TouchableHighlight, { key: value, style: [style.option, customStyle?.option], underlayColor: colorGrayscaleS, onPress: () => handleOnPressOption(value) },
|
|
24
|
+
React.createElement(Text, { level: 3, style: [style.optionText, customStyle?.optionText] }, label))))))));
|
|
25
|
+
};
|
|
26
|
+
export { SelectField };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const style: {
|
|
2
|
+
modalContent: {
|
|
3
|
+
paddingBottom: number;
|
|
4
|
+
paddingHorizontal: number;
|
|
5
|
+
};
|
|
6
|
+
option: {
|
|
7
|
+
borderBottomColor: string;
|
|
8
|
+
borderBottomWidth: number;
|
|
9
|
+
paddingVertical: number;
|
|
10
|
+
};
|
|
11
|
+
optionText: {
|
|
12
|
+
lineHeight: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export { style };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../theme/theme";
|
|
3
|
+
const { borderSize, colorGrayscaleS, spaceM, spaceXL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
modalContent: {
|
|
6
|
+
paddingBottom: spaceXL,
|
|
7
|
+
paddingHorizontal: spaceXL,
|
|
8
|
+
},
|
|
9
|
+
option: {
|
|
10
|
+
borderBottomColor: colorGrayscaleS,
|
|
11
|
+
borderBottomWidth: borderSize,
|
|
12
|
+
paddingVertical: spaceM,
|
|
13
|
+
},
|
|
14
|
+
optionText: {
|
|
15
|
+
lineHeight: 24,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export { style };
|
package/dist/infrastructure/ui/views/item/components/productVariantActions/ProductVariantActions.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
2
|
import { BUTTON_VARIANT } from "@lookiero/aurora-next/build/components/atoms/Button/Button.definition";
|
|
3
|
-
import { InputField } from "@lookiero/aurora-next/build/components/atoms/InputField/InputField";
|
|
4
3
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
5
4
|
import React, { useMemo } from "react";
|
|
6
5
|
import { View } from "react-native";
|
|
7
6
|
import { I18nMessages } from "../../../../i18n/i18n";
|
|
7
|
+
import { SelectField } from "../../../../shared/components/molecules/selectField/SelectField";
|
|
8
8
|
import { style } from "./ProductVariantActions.style";
|
|
9
9
|
const ProductVariantActions = ({ sizes, size, onKeep, onReplace, onReturn }) => {
|
|
10
10
|
const sizeSelectorLabelText = useI18nMessage({ id: I18nMessages.ITEM_SIZES_LABEL });
|
|
11
11
|
const keepButtonText = useI18nMessage({ id: I18nMessages.ITEM_KEEP_BUTTON });
|
|
12
12
|
const returnButtonText = useI18nMessage({ id: I18nMessages.ITEM_RETURN_BUTTON });
|
|
13
|
-
const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({
|
|
13
|
+
const sizeSelectorOptions = useMemo(() => sizes.map((size) => ({ label: size.lookiero, value: size.id })), [sizes]);
|
|
14
14
|
const disabledSizeSelector = useMemo(() => sizeSelectorOptions.length === 1 && sizeSelectorOptions[0]?.value === size.id, [sizeSelectorOptions, size.id]);
|
|
15
15
|
return (React.createElement(View, { style: style.container },
|
|
16
16
|
React.createElement(Button, { onPress: onKeep }, keepButtonText),
|
|
17
17
|
React.createElement(View, { style: style.row },
|
|
18
|
-
!size.unique && (React.createElement(
|
|
19
|
-
React.createElement(InputField, { disabled: disabledSizeSelector, icon: "arrow-down", label: sizeSelectorLabelText, name: "size-selector", options: sizeSelectorOptions, testID: "size-selector", value: size.id, onChange: onReplace }))),
|
|
18
|
+
!size.unique && (React.createElement(SelectField, { disabled: disabledSizeSelector, options: sizeSelectorOptions, placeholder: sizeSelectorLabelText || "", style: { selectField: style.sizeSelector }, testID: "size-selector", value: size.id, onChange: onReplace })),
|
|
20
19
|
React.createElement(View, { style: style.returnButtonContainer },
|
|
21
20
|
React.createElement(Button, { variant: BUTTON_VARIANT.SECONDARY, onPress: onReturn }, returnButtonText)))));
|
|
22
21
|
};
|
|
@@ -2,11 +2,6 @@ declare const style: {
|
|
|
2
2
|
container: {
|
|
3
3
|
width: string;
|
|
4
4
|
};
|
|
5
|
-
dropdownContainer: {
|
|
6
|
-
flex: number;
|
|
7
|
-
marginRight: number;
|
|
8
|
-
zIndex: number;
|
|
9
|
-
};
|
|
10
5
|
returnButtonContainer: {
|
|
11
6
|
flex: number;
|
|
12
7
|
};
|
|
@@ -15,5 +10,9 @@ declare const style: {
|
|
|
15
10
|
flexDirection: "row";
|
|
16
11
|
marginTop: number;
|
|
17
12
|
};
|
|
13
|
+
sizeSelector: {
|
|
14
|
+
flex: number;
|
|
15
|
+
marginRight: number;
|
|
16
|
+
};
|
|
18
17
|
};
|
|
19
18
|
export { style };
|
|
@@ -5,11 +5,6 @@ const style = StyleSheet.create({
|
|
|
5
5
|
container: {
|
|
6
6
|
width: "100%",
|
|
7
7
|
},
|
|
8
|
-
dropdownContainer: {
|
|
9
|
-
flex: 1,
|
|
10
|
-
marginRight: spaceL,
|
|
11
|
-
zIndex: 4,
|
|
12
|
-
},
|
|
13
8
|
returnButtonContainer: {
|
|
14
9
|
flex: 1,
|
|
15
10
|
},
|
|
@@ -18,5 +13,9 @@ const style = StyleSheet.create({
|
|
|
18
13
|
flexDirection: "row",
|
|
19
14
|
marginTop: spaceL,
|
|
20
15
|
},
|
|
16
|
+
sizeSelector: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
marginRight: spaceL,
|
|
19
|
+
},
|
|
21
20
|
});
|
|
22
21
|
export { style };
|