UNPKG

@progress/kendo-react-spreadsheet

Version:
55 lines (54 loc) 1.89 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as t from "react"; import { Button as m } from "@progress/kendo-react-buttons"; import { Upload as p } from "@progress/kendo-react-upload"; import { folderOpenIcon as f } from "@progress/kendo-svg-icons"; import { useLocalization as d } from "@progress/kendo-react-intl"; import { keys as s, messages as u } from "../messages.mjs"; const g = (r) => { const { spreadsheetRef: l } = r, i = t.useCallback((n) => { const e = n.target; if (e instanceof Element && e.parentNode) { const o = e.closest(".k-toolbar"), a = o && o.querySelector(".k-upload input"); a && a.click(); } }, []), c = t.useCallback((n) => { const e = n.newState; if (e[0] && e[0].getRawFile) { const o = e[0].getRawFile(); l.current && l.current.executeCommand({ command: "OpenCommand", options: { file: o } }); } }, []); return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement( m, { className: "k-toolbar-button", title: d().toLanguageString(s.open, u[s.open]), icon: "folder-open", svgIcon: f, fillMode: "flat", onClick: i } ), /* @__PURE__ */ t.createElement("div", { style: { display: "none" } }, /* @__PURE__ */ t.createElement( p, { restrictions: { allowedExtensions: [".xlsx"] }, onAdd: c, autoUpload: !1, defaultFiles: [], multiple: !1, accept: ".xlsx,.XLSX", withCredentials: !1 } ))); }; g.displayName = "Open"; export { g as Open };