UNPKG

@progress/kendo-react-upload

Version:

React Upload component helps users transfer files from their file systems to dedicated server handlers. KendoReact Upload package

75 lines (74 loc) 3.04 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 s from "react"; import { Keys as m, classNames as a } from "@progress/kendo-react-common"; import { provideLocalizationService as f, registerForLocalization as b } from "@progress/kendo-react-intl"; import { clearSelectedFiles as c, messages as d, uploadSelectedFiles as p } from "./messages/index.mjs"; class C extends s.Component { constructor() { super(...arguments), this._uploadElement = null, this._clearElement = null, this.onClearClick = () => { this.props.disabled || this.props.onClear && this.props.onClear.call(void 0); }, this.checkEnterKey = (e) => e.keyCode === m.enter, this.onUploadClick = () => { this.props.disabled || (this.props.onClick.call(void 0, this.props.uploadButtonIndex), this.props.onUpload && this.props.onUpload.call(void 0)); }; } componentDidUpdate(e) { const { navigationIndex: o, clearButtonIndex: i, uploadButtonIndex: l } = this.props; o !== e.navigationIndex && (o === i && this._clearElement && this._clearElement.focus(), o === l && this._uploadElement && this._uploadElement.focus()); } render() { const { disabled: e, navigationIndex: o, clearButtonIndex: i, uploadButtonIndex: l, actionsLayout: n } = this.props, r = f(this), u = a("k-actions", "k-hstack", { "k-justify-content-start": n === "start", "k-justify-content-center": n === "center", "k-justify-content-end": n === "end", "k-justify-content-stretch": n === "stretched" }), k = a( "k-button k-button-md k-rounded-md k-button-solid k-button-solid-base", "k-clear-selected", e ? "k-disabled" : "", o === i ? "k-focus" : "" ), h = a( "k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary", "k-primary", "k-upload-selected", e ? "k-disabled" : "", o === l ? "k-focus" : "" ); return /* @__PURE__ */ s.createElement("div", { className: u }, /* @__PURE__ */ s.createElement( "button", { ref: (t) => { this._clearElement = t; }, type: "button", className: k, tabIndex: 0, onClick: this.onClearClick, onKeyDown: (t) => this.checkEnterKey(t) && this.onClearClick() }, r.toLanguageString(c, d[c]) ), /* @__PURE__ */ s.createElement( "button", { ref: (t) => { this._uploadElement = t; }, type: "button", className: h, tabIndex: 0, onClick: this.onUploadClick, onKeyDown: (t) => this.checkEnterKey(t) && this.onUploadClick() }, r.toLanguageString(p, d[p]) )); } } b(C); export { C as UploadActionButtons };