UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

18 lines 891 B
import React, { forwardRef } from "react"; import { Slot } from "../../../utils/components/slot/Slot.js"; import { useFileUpload } from "../useFileUpload.js"; const Trigger = forwardRef(({ children, multiple = true, accept, onSelect, validator, maxSizeInBytes, }, ref) => { const { onChange, inputRef, mergedRef } = useFileUpload({ ref, onSelect, validator, accept, maxSizeInBytes, disabled: false, }); return (React.createElement(React.Fragment, null, React.createElement(Slot, { onClick: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }, children), React.createElement("input", { ref: mergedRef, type: "file", style: { display: "none" }, multiple: multiple, accept: accept, onChange: onChange }))); }); export default Trigger; //# sourceMappingURL=Trigger.js.map