@progress/kendo-react-upload
Version:
React Upload component helps users transfer files from their file systems to dedicated server handlers. KendoReact Upload package
77 lines (76 loc) • 2.73 kB
JavaScript
/**
* @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 n from "react";
import { classNames as f } from "@progress/kendo-react-common";
import { provideLocalizationService as I, registerForLocalization as g } from "@progress/kendo-react-intl";
import { Button as x } from "@progress/kendo-react-buttons";
import { select as r, messages as _ } from "./messages/index.mjs";
import { UploadInput as b } from "./UploadInput.mjs";
const v = (i) => /* @__PURE__ */ n.createElement("span", { "aria-hidden": !0 }, i.message);
class E extends n.Component {
constructor() {
super(...arguments), this._element = null, this._uploadInput = null, this.focus = () => {
this._element && this._element.focus();
}, this.onClick = () => {
this.actionElement && this.actionElement.click(), this.props.onClick.call(void 0, this.props.addButtonIndex);
}, this.onInputMouseDown = (e) => {
this._element && (e.preventDefault(), this._element.focus());
};
}
get actionElement() {
if (this._uploadInput)
return this._uploadInput.actionElement;
}
componentDidUpdate(e) {
const { navigationIndex: o, addButtonIndex: s, notFocusedIndex: t } = this.props;
o !== e.navigationIndex && e.navigationIndex !== t && o === s && this._element && this._element.focus();
}
render() {
const {
navigationIndex: e,
addButtonIndex: o,
tabIndex: s,
id: t,
ariaControls: c,
disabled: d,
ariaExpanded: u,
selectMessageUI: a,
...p
} = this.props, l = I(this).toLanguageString(r, _[r]), m = a || v;
return /* @__PURE__ */ n.createElement("div", { className: "k-upload-button-wrap" }, /* @__PURE__ */ n.createElement(
x,
{
type: "button",
id: t ? `${t}-select-button` : "select-button",
className: f("k-upload-button", e === o ? "k-focus" : ""),
themeColor: "base",
tabIndex: s,
onClick: this.onClick,
"aria-label": l,
"aria-controls": c,
"aria-disabled": d,
"aria-expanded": u
},
/* @__PURE__ */ n.createElement(m, { message: l })
), /* @__PURE__ */ n.createElement(
b,
{
id: t ? `${t}-files` : "files",
...p,
onMouseDown: this.onInputMouseDown,
ref: (h) => {
this._uploadInput = h;
}
}
));
}
}
g(E);
export {
E as UploadAddButton
};