@progress/kendo-react-upload
Version: 
React Upload component helps users transfer files from their file systems to dedicated server handlers. KendoReact Upload package
55 lines (54 loc) • 2.04 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 { provideLocalizationService as f, registerForLocalization as b } from "@progress/kendo-react-intl";
import * as n from "react";
import { messages as a, select as r, selectTitle as v, selectNoFilesTitle as w } from "./messages/index.mjs";
const y = /(chrome)[ \/]([\w.]+)/i, A = /(webkit)[ \/]([\w.]+)/i;
class E extends n.Component {
  constructor() {
    super(...arguments), this._input = null, this.onMouseDown = (t) => {
      this.props.onMouseDown && this.props.onMouseDown(t);
    }, this.onAdd = () => {
      const t = navigator.userAgent, e = this._input;
      e && (this.props.onAdd && e.files && this.props.onAdd.call(void 0, e.files), !t.match(y) && t.match(A) || (e.type = "", e.type = "file"));
    };
  }
  get actionElement() {
    return this._input;
  }
  render() {
    const { multiple: t, async: e, disabled: l, accept: c, hasFiles: d, ariaLabelledBy: i, ariaDescribedBy: p, id: u } = this.props, s = f(this), o = d ? v : w, h = s.toLanguageString(o, a[o]), m = s.toLanguageString(r, a[r]);
    return /* @__PURE__ */ n.createElement(
      "input",
      {
        id: u,
        ref: (g) => this._input = g,
        className: "k-hidden",
        autoComplete: "off",
        name: e.saveField,
        accept: c,
        type: "file",
        multiple: t,
        disabled: l,
        onChange: this.onAdd,
        onMouseDown: this.onMouseDown,
        title: h,
        tabIndex: -1,
        "data-testid": "upload-input-testid",
        "aria-label": i !== void 0 ? void 0 : m,
        "aria-labelledby": i,
        "aria-describedby": p,
        "aria-hidden": !0
      }
    );
  }
}
b(E);
export {
  E as UploadInput
};