{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAyCM,MAAM,0DAAc,CAAA,GAAA,iBAAS,EAAE,SAAS,YAAY,KAAuB,EAAE,GAAmC;IACrH,IAAI,YAAC,QAAQ,qBAAE,iBAAiB,kBAAE,cAAc,iBAAE,aAAa,YAAE,QAAQ,mBAAE,eAAe,EAAE,GAAG,MAAK,GAAG;IACvG,IAAI,WAAW,CAAA,GAAA,mBAAW,EAAE;IAC5B,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,MAAM;QAAC,QAAQ;IAAI;IAEjD,qBACE,gFACE,gCAAC,CAAA,GAAA,qBAAa;QACZ,SAAS;YACP,IAAI,SAAS,OAAO,EAAE,OACpB,SAAS,OAAO,CAAC,KAAK,GAAG;YAE3B,SAAS,OAAO,EAAE;QACpB;OACC,yBAEH,gCAAC,CAAA,GAAA,yCAAI;QACF,GAAG,QAAQ;QACZ,WAAU;QACV,MAAK;QACL,KAAK;QACL,OAAO;YAAC,SAAS;QAAM;QACvB,QAAQ,mBAAmB;QAC3B,UAAU,CAAC,IAAM,WAAW,CAAA,GAAA,qBAAa,EAAE,GAAG,KAAK;QACnD,SAAS;QACT,UAAU;QACV,mBAAmB;QACnB,iBAAiB,kBAAkB,KAAK;;AAGhD","sources":["packages/react-aria-components/src/FileTrigger.tsx"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\n\nimport {getEventTarget} from 'react-aria/private/utils/shadowdom/DOMFunctions';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {Input} from './Input';\nimport {PressResponder} from 'react-aria/private/interactions/PressResponder';\nimport React, {ForwardedRef, forwardRef, ReactNode} from 'react';\nimport {useObjectRef} from 'react-aria/useObjectRef';\n\nexport interface FileTriggerProps extends GlobalDOMAttributes<HTMLInputElement> {\n  /**\n   * Specifies what mime type of files are allowed.\n   */\n  acceptedFileTypes?: ReadonlyArray<string>,\n  /**\n   * Whether multiple files can be selected.\n   */\n  allowsMultiple?: boolean,\n  /**\n   * Specifies the use of a media capture mechanism to capture the media on the spot.\n   */\n  defaultCamera?: 'user' | 'environment',\n  /**\n   * Handler when a user selects a file.\n   */\n  onSelect?: (files: FileList | null) => void,\n  /**\n   * The children of the component.\n   */\n  children?: ReactNode,\n  /**\n   * Enables the selection of directories instead of individual files.\n   */\n  acceptDirectory?: boolean\n}\n\n/**\n * A FileTrigger allows a user to access the file system with any pressable React Aria or React Spectrum component, or custom components built with usePress.\n */\nexport const FileTrigger = forwardRef(function FileTrigger(props: FileTriggerProps, ref: ForwardedRef<HTMLInputElement>) {\n  let {onSelect, acceptedFileTypes, allowsMultiple, defaultCamera, children, acceptDirectory, ...rest} = props;\n  let inputRef = useObjectRef(ref);\n  let domProps = filterDOMProps(rest, {global: true});\n\n  return (\n    <>\n      <PressResponder\n        onPress={() => {\n          if (inputRef.current?.value) {\n            inputRef.current.value = '';\n          }\n          inputRef.current?.click();\n        }}>\n        {children}\n      </PressResponder>\n      <Input\n        {...domProps}\n        className=\"\"\n        type=\"file\"\n        ref={inputRef}\n        style={{display: 'none'}}\n        accept={acceptedFileTypes?.toString()}\n        onChange={(e) => onSelect?.(getEventTarget(e).files)}\n        capture={defaultCamera}\n        multiple={allowsMultiple}\n        // @ts-expect-error\n        webkitdirectory={acceptDirectory ? '' : undefined} />\n    </>\n  );\n});\n"],"names":[],"version":3,"file":"FileTrigger.mjs.map"}