@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 2.59 kB
Source Map (JSON)
{"version":3,"file":"toggle.cjs","names":["createSlotComponent","toggleStyle","useToggle","useInputBorder","Portal","styled","IconButton"],"sources":["../../../../src/components/toggle/toggle.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type {\n GenericsComponent,\n ThemeProps,\n WithoutThemeProps,\n} from \"../../core\"\nimport type { IconButtonProps } from \"../button\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { ToggleStyle } from \"./toggle.style\"\nimport type { UseToggleProps } from \"./use-toggle\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { IconButton } from \"../button\"\nimport { useInputBorder } from \"../input\"\nimport { Portal } from \"../portal\"\nimport { toggleStyle } from \"./toggle.style\"\nimport { useToggle } from \"./use-toggle\"\n\nexport interface ToggleProps<Y extends string = string>\n extends Omit<\n WithoutThemeProps<IconButtonProps, ToggleStyle>,\n \"aria-label\" | \"onChange\" | \"ref\" | \"value\"\n >,\n UseToggleProps<Y>,\n Pick<UseInputBorderProps, \"errorBorderColor\">,\n ThemeProps<ToggleStyle> {}\n\nconst {\n component,\n PropsContext: TogglePropsContext,\n usePropsContext: useTogglePropsContext,\n withProvider,\n useRootComponentProps,\n} = createSlotComponent<ToggleProps, ToggleStyle>(\"toggle\", toggleStyle)\n\nexport {\n component,\n TogglePropsContext,\n useRootComponentProps,\n useTogglePropsContext,\n}\n\n/**\n * `Toggle` is a two-state button that can be either on or off.\n *\n * @see https://yamada-ui.com/docs/components/toggle\n */\nexport const Toggle = withProvider<\"button\", ToggleProps>(\n ({ errorBorderColor, icon, ...rest }: ToggleProps) => {\n const { getButtonProps, getInputProps } = useToggle(rest)\n const varProps = useInputBorder({ errorBorderColor })\n\n return (\n <>\n <Portal>\n <styled.input {...getInputProps()} />\n </Portal>\n\n <IconButton icon={icon} {...varProps} {...getButtonProps()} />\n </>\n )\n },\n \"root\",\n)() as GenericsComponent<{\n <Y extends string = string>(props: ToggleProps<Y>): ReactElement\n}>\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,EACJ,WACA,cAAc,oBACd,iBAAiB,uBACjB,cACA,0BACEA,6CAA8C,UAAUC,iCAAY;;;;;;AAcxE,MAAa,SAAS,cACnB,EAAE,kBAAkB,KAAM,GAAG,WAAwB;CACpD,MAAM,EAAE,gBAAgB,kBAAkBC,6BAAU,KAAK;CACzD,MAAM,WAAWC,wCAAe,EAAE,kBAAkB,CAAC;AAErD,QACE,qFACE,2CAACC,mCACC,2CAACC,uBAAO,SAAM,GAAI,eAAe,GAAI,GAC9B,EAET,2CAACC;EAAiB;EAAM,GAAI;EAAU,GAAI,gBAAgB;GAAI,IAC7D;GAGP,OACD,EAAE"}