import { type ViewStyle, type TextStyle, StyleSheet } from "react-native"; import { type TextInputDynamicStyleType, type TextInputTypes, type TextInputType } from "./type"; import type { Mutable } from "../../types"; export const TEXT_INPUT_TYPE_STYLES: Record< TextInputType, TextInputTypes > = { default: { focusBorderColor: "emphasized", borderColor: "emphasized", hideTextIconColor: "mid", placeholderColor: "low", containerColor: "mid", hideTextColor: "mid", titleColor: "high", inputColor: "mid", iconColor: "mid" }, danger: { placeholderColor: "dangerLow", hideTextIconColor: "danger", focusBorderColor: "danger", containerColor: "danger", hideTextColor: "danger", borderColor: "danger", titleColor: "danger", inputColor: "danger", iconColor: "danger" }, success: { placeholderColor: "successLow", hideTextIconColor: "success", focusBorderColor: "success", containerColor: "success", hideTextColor: "success", borderColor: "success", titleColor: "success", inputColor: "success", iconColor: "success" }, warning: { placeholderColor: "warningLow", hideTextIconColor: "warning", focusBorderColor: "warning", containerColor: "warning", hideTextColor: "warning", borderColor: "warning", titleColor: "warning", inputColor: "warning", iconColor: "warning" }, info: { placeholderColor: "infoLow", hideTextIconColor: "info", focusBorderColor: "info", containerColor: "info", hideTextColor: "info", borderColor: "info", titleColor: "info", inputColor: "info", iconColor: "info" }, question: { focusBorderColor: "emphasized", borderColor: "emphasized", hideTextIconColor: "mid", placeholderColor: "low", containerColor: "mid", hideTextColor: "mid", titleColor: "mid", inputColor: "mid", iconColor: "mid" } }; export const getTextInputType = ({ type }: { type: TextInputType; }) => { const currentType = TEXT_INPUT_TYPE_STYLES[type]; return currentType; }; // TODO: PLACECHOLDER CODE ADD. const stylesheet = StyleSheet.create({ container: { flexDirection: "column", boxSizing: "border-box", display: "flex" }, content: { boxSizing: "border-box", flexDirection: "row", borderStyle: "solid", alignItems: "center", position: "relative", display: "flex" }, input: { backgroundColor: "transparent", textAlignVertical: "center", borderColor: "transparent", paddingBottom: 0, paddingRight: 0, paddingLeft: 0, borderWidth: 0, paddingTop: 0, minHeight: 20, width: "100%", zIndex: 99 }, cleanButton: { justifyContent: "center", alignItems: "center", alignSelf: "center", display: "flex", zIndex: 99 }, hideTextIconContainer: { justifyContent: "center", alignItems: "center", alignSelf: "center", display: "flex", zIndex: 99, height: 18 }, title: { }, icon: { justifyContent: "center", alignContent: "center", alignItems: "center", display: "flex", zIndex: 99 }, required: { }, hintTextIcon: { }, hintText: { flexDirection: "row", alignItems: "center", display: "flex" }, subTitle: { }, overlay: { position: "absolute", zIndex: 98, bottom: 0, right: 0, left: 0, top: 0 }, rightIcon: { justifyContent: "center", alignItems: "center", alignSelf: "center", display: "flex", zIndex: 99 } }); export const useStyles = ({ spreadBehaviour, inlineSpaces, currentType, typography, isDisabled, radiuses, borders, colors, spaces, type }: TextInputDynamicStyleType) => { const styleType = type === "danger" ? "error" : type === "question" ? "neutral" : type; const styles = { container: { } as Mutable, content: { backgroundColor: colors.content.container[currentType.containerColor], borderColor: colors.content.container[currentType.containerColor], paddingBottom: spaces.spacingMd, paddingRight: spaces.spacingMd, borderRadius: radiuses.actions, paddingLeft: spaces.spacingMd, paddingTop: spaces.spacingMd, borderWidth: borders.line } as Mutable, input: { ...typography.labelLargeSize, color: colors.content.text[currentType.inputColor] } as Mutable, cleanButton: { marginLeft: spaces.spacingSm } as Mutable, hideTextIconContainer: { marginLeft: spaces.spacingSm } as Mutable, title: { marginBottom: spaces.spacingSm } as Mutable, icon: { marginRight: spaces.spacingSm } as Mutable, required: { marginRight: inlineSpaces.required } as Mutable, hintTextIcon: { marginRight: spaces.spacingXs } as Mutable, hintText: { marginTop: spaces.spacingSm } as Mutable, subTitle: { marginLeft: inlineSpaces.subTitle } as Mutable, overlay: { borderRadius: radiuses.actions - 1 } as Mutable, rightIcon: { marginLeft: spaces.spacingSm } as Mutable }; if(isDisabled) { const disableStyleType = styleType === "default" ? "neutral" : styleType; styles.overlay.backgroundColor = colors.system.state.overlay.disabled[disableStyleType]; styles.container.borderColor = colors.system.state.overlay.disabled[disableStyleType]; styles.input.color = colors.content.text.disabled; } if (spreadBehaviour === "baseline") { styles.container.alignSelf = spreadBehaviour; styles.container.width = "auto"; } if (spreadBehaviour === "stretch") { styles.container.justifyContent = "center"; styles.container.width = "100%"; } return styles; }; export default stylesheet;