UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

1 lines 4.14 kB
{"version":3,"file":"password-input.cjs","names":["createSlotComponent","passwordInputStyle","EyeOffIcon","EyeIcon","useGroupItemProps","usePasswordInput","useInputPropsContext","Input"],"sources":["../../../../src/components/password-input/password-input.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { HTMLStyledProps, ThemeProps, WithoutThemeProps } from \"../../core\"\nimport type { InputProps } from \"../input\"\nimport type { PasswordInputStyle } from \"./password-input.style\"\nimport type { UsePasswordInputProps } from \"./use-password-input\"\nimport { createSlotComponent } from \"../../core\"\nimport { useGroupItemProps } from \"../group\"\nimport { EyeIcon, EyeOffIcon } from \"../icon\"\nimport { Input, InputGroup, useInputPropsContext } from \"../input\"\nimport { passwordInputStyle } from \"./password-input.style\"\nimport { usePasswordInput } from \"./use-password-input\"\n\nexport interface PasswordInputProps\n extends WithoutThemeProps<InputProps, PasswordInputStyle>,\n ThemeProps<PasswordInputStyle>,\n UsePasswordInputProps {\n /**\n * The icons to be used for the visibility toggle.\n */\n visibilityIcon?: { off: ReactNode; on: ReactNode }\n /**\n * The props for the button element.\n */\n buttonProps?: PasswordInputButtonProps\n /**\n * The props for the end element.\n */\n elementProps?: InputGroup.ElementProps\n /**\n * The props for the root element.\n */\n rootProps?: InputGroup.RootProps\n}\n\nconst {\n PropsContext: PasswordInputPropsContext,\n usePropsContext: usePasswordInputPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<PasswordInputProps, PasswordInputStyle>(\n \"password-input\",\n passwordInputStyle,\n)\n\nexport { PasswordInputPropsContext, usePasswordInputPropsContext }\n\n/**\n * `PasswordInput` is a component that allows users to input passwords with a visibility toggle.\n *\n * @see https://yamada-ui.com/docs/components/password-input\n */\nexport const PasswordInput = withProvider<\"input\", PasswordInputProps>(\n ({\n className,\n css,\n colorScheme,\n visibilityIcon = { off: <EyeOffIcon />, on: <EyeIcon /> },\n buttonProps,\n elementProps,\n rootProps,\n ...props\n }) => {\n const [groupItemProps, rest] = useGroupItemProps(props)\n const { visible, getButtonProps, getInputProps } = usePasswordInput(rest)\n\n return (\n <InputGroup.Root\n className={className}\n css={css}\n colorScheme={colorScheme}\n {...groupItemProps}\n {...rootProps}\n >\n <PasswordInputField {...getInputProps()} />\n\n <InputGroup.Element clickable {...elementProps}>\n <PasswordInputButton {...getButtonProps(buttonProps)}>\n {visible ? visibilityIcon.off : visibilityIcon.on}\n </PasswordInputButton>\n </InputGroup.Element>\n </InputGroup.Root>\n )\n },\n \"root\",\n)((props) => {\n const context = useInputPropsContext()\n\n return { ...context, ...props }\n})\n\ninterface PasswordInputFieldProps extends InputProps {}\n\nconst PasswordInputField = withContext<\"input\", PasswordInputFieldProps>(\n Input,\n \"field\",\n)({ \"data-group-propagate\": \"\" })\n\ninterface PasswordInputButtonProps extends HTMLStyledProps<\"button\"> {}\n\nconst PasswordInputButton = withContext<\"button\", PasswordInputButtonProps>(\n \"button\",\n \"button\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,EACJ,cAAc,2BACd,iBAAiB,8BACjB,aACA,iBACEA,6CACF,kBACAC,gDACD;;;;;;AASD,MAAa,gBAAgB,cAC1B,EACC,WACA,KACA,aACA,iBAAiB;CAAE,KAAK,2CAACC,oCAAa;CAAE,IAAI,2CAACC,6BAAU;CAAE,EACzD,aACA,cACA,UACA,GAAG,YACC;CACJ,MAAM,CAAC,gBAAgB,QAAQC,oCAAkB,MAAM;CACvD,MAAM,EAAE,SAAS,gBAAgB,kBAAkBC,4CAAiB,KAAK;AAEzE,QACE;EACa;EACN;EACQ;EACb,GAAI;EACJ,GAAI;aAEJ,2CAAC,sBAAmB,GAAI,eAAe,GAAI,EAE3C;GAAoB;GAAU,GAAI;aAChC,2CAAC;IAAoB,GAAI,eAAe,YAAY;cACjD,UAAU,eAAe,MAAM,eAAe;KAC3B;IACH;GACL;GAGtB,OACD,EAAE,UAAU;AAGX,QAAO;EAAE,GAFOC,oCAAsB;EAEjB,GAAG;EAAO;EAC/B;AAIF,MAAM,qBAAqB,YACzBC,qBACA,QACD,CAAC,EAAE,wBAAwB,IAAI,CAAC;AAIjC,MAAM,sBAAsB,YAC1B,UACA,SACD,EAAE"}