UNPKG

@yamada-ui/react

Version:

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

1 lines 1.42 kB
{"version":3,"file":"use-file-button.cjs","names":["useFileInput","props"],"sources":["../../../../src/components/file-button/use-file-button.ts"],"sourcesContent":["\"use client\"\n\nimport type { PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport type { UseFileInputProps } from \"../file-input\"\nimport { useCallback } from \"react\"\nimport { ariaAttr } from \"../../utils\"\nimport { useFileInput } from \"../file-input\"\n\nexport interface UseFileButtonProps\n extends UseFileInputProps<\"button\">,\n FieldProps {}\n\nexport const useFileButton = (props: UseFileButtonProps = {}) => {\n const { interactive, clickableProps, getInputProps } =\n useFileInput<\"button\">(props)\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n (props) => ({\n ...clickableProps,\n \"aria-disabled\": ariaAttr(!interactive),\n tabIndex: interactive ? clickableProps.tabIndex : -1,\n ...props,\n }),\n [clickableProps, interactive],\n )\n\n return {\n clickableProps,\n getButtonProps,\n getInputProps,\n }\n}\n\nexport type UseFileButtonReturn = ReturnType<typeof useFileButton>\n"],"mappings":";;;;;;;;;;AAaA,MAAa,iBAAiB,QAA4B,EAAE,KAAK;CAC/D,MAAM,EAAE,aAAa,gBAAgB,kBACnCA,oCAAuB,MAAM;AAY/B,QAAO;EACL;EACA,wCAXC,aAAW;GACV,GAAG;GACH,iEAA0B,CAAC,YAAY;GACvC,UAAU,cAAc,eAAe,WAAW;GAClD,GAAGC;GACJ,GACD,CAAC,gBAAgB,YAAY,CAC9B;EAKC;EACD"}