@progress/kendo-react-dropdowns
Version:
React DropDowns offer an interface for users to select different items from a list and more. KendoReact Dropdowns package
78 lines (77 loc) • 2.62 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 { getActiveElement as u, classNames as b, uDropDownsBase as g } from "@progress/kendo-react-common";
import * as c from "react";
class y extends c.Component {
constructor() {
super(...arguments), this._input = null;
}
/**
* @hidden
*/
get input() {
return this._input;
}
componentDidUpdate(a) {
const i = a.value, o = a.suggestedText, { value: s, suggestedText: t, focused: n } = this.props, e = this.input, r = i !== s || t !== o, p = r && i.startsWith(s) && !(o && t && o.endsWith(t)), l = u(document);
n && e && l !== e && e.focus(), t && r && !p && e && e.setSelectionRange(s.length - t.length, s.length);
}
render() {
const {
expanded: a = !1,
disabled: i,
role: o = "listbox",
render: s,
tabIndex: t,
accessKey: n,
unstyled: e,
inputAttributes: r
} = this.props, p = e && e.uDropDownsBase, l = {
tabIndex: t,
accessKey: n
}, d = /* @__PURE__ */ c.createElement(
"input",
{
autoComplete: "off",
id: this.props.id,
type: "text",
key: "searchbar",
size: this.props.size,
placeholder: this.props.placeholder,
className: b(g.inputInner({ c: p })),
role: o,
name: this.props.name,
value: this.props.value,
onChange: this.props.onChange,
ref: (h) => this._input = h,
onKeyDown: this.props.onKeyDown,
onFocus: this.props.onFocus,
onBlur: this.props.onBlur,
onClick: this.props.onClick,
"aria-disabled": i || void 0,
disabled: i || void 0,
readOnly: this.props.readOnly || void 0,
title: this.props.title,
"aria-haspopup": "listbox",
"aria-expanded": a,
"aria-owns": this.props.owns,
"aria-activedescendant": a ? this.props.activedescendant : void 0,
"aria-describedby": this.props.ariaDescribedBy,
"aria-labelledby": this.props.ariaLabelledBy,
"aria-label": this.props.ariaLabel,
"aria-required": this.props.ariaRequired,
"aria-controls": this.props.ariaControls,
...Object.assign({}, l, r)
}
);
return s ? s.call(void 0, d) : d;
}
}
export {
y as default
};