UNPKG

@progress/kendo-react-dropdowns

Version:

React DropDowns offer an interface for users to select different items from a list and more. KendoReact Dropdowns package

9 lines (8 loc) 2.25 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";const d=require("@progress/kendo-react-common"),g=require("react");function m(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const h=m(g);class f extends h.Component{constructor(){super(...arguments),this._input=null}get input(){return this._input}componentDidUpdate(t){const e=t.value,s=t.suggestedText,{value:n,suggestedText:r,focused:p}=this.props,a=this.input,i=e!==n||r!==s,c=i&&e.startsWith(n)&&!(s&&r&&s.endsWith(r)),l=d.getActiveElement(document);p&&a&&l!==a&&a.focus(),r&&i&&!c&&a&&a.setSelectionRange(n.length-r.length,n.length)}render(){const{expanded:t=!1,disabled:e,role:s="listbox",render:n,tabIndex:r,accessKey:p,unstyled:a,inputAttributes:i}=this.props,c=a&&a.uDropDownsBase,l={tabIndex:r,accessKey:p},u=h.createElement("input",{autoComplete:"off",id:this.props.id,type:"text",key:"searchbar",size:this.props.size,placeholder:this.props.placeholder,className:d.classNames(d.uDropDownsBase.inputInner({c})),role:s,name:this.props.name,value:this.props.value,onChange:this.props.onChange,ref:b=>this._input=b,onKeyDown:this.props.onKeyDown,onFocus:this.props.onFocus,onBlur:this.props.onBlur,onClick:this.props.onClick,"aria-disabled":e||void 0,disabled:e||void 0,readOnly:this.props.readOnly||void 0,title:this.props.title,"aria-haspopup":"listbox","aria-expanded":t,"aria-owns":this.props.owns,"aria-activedescendant":t?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,i)});return n?n.call(void 0,u):u}}module.exports=f;