@progress/kendo-react-inputs
Version:
React Inputs offer a customizable interface for users to enter and pick different information. KendoReact Input package
9 lines (8 loc) • 2.59 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
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),t=require("prop-types"),n=require("@progress/kendo-react-common");function K(a){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(l,s,r.get?r:{enumerable:!0,get:()=>a[s]})}}return l.default=a,Object.freeze(l)}const e=K(M),k=n.createPropsContext(),g=e.forwardRef((a,l)=>{const s=n.usePropsContext(k,a),{ariaDescribedBy:r,checked:y,children:B,className:x,disabled:o,id:h,size:F=L.size,label:d,labelPlacement:I,name:O,style:j,tabIndex:q,value:m,valid:z,onChange:v,onFocus:b,onBlur:p,required:S,...T}=s,C=n.useUnstyled(),f=C&&C.uRadioButton,u=e.useRef(null),R=e.useCallback(()=>{u.current&&u.current.focus()},[]),i=e.useCallback(()=>({element:u.current,focus:R}),[R]);e.useImperativeHandle(l,i);const P=n.useId(),D=e.useCallback(c=>{n.dispatchEvent(v,c,i(),{value:m})},[v,m,o]),w=e.useCallback(c=>{b&&!o&&n.dispatchEvent(b,c,i(),void 0)},[b,o]),_=e.useCallback(c=>{p&&!o&&n.dispatchEvent(p,c,i(),void 0)},[p,o]),H={type:"radio",id:h||P,name:O,className:n.classNames(n.uRadioButton.input({c:f,size:F,invalid:z===!1,checked:y}),x),ref:u,disabled:o,tabIndex:n.getTabIndex(q,o),checked:y,style:j,"aria-describedby":r,"aria-required":S,value:m,onChange:D,onFocus:w,onBlur:_,...T},E=e.createElement(e.Fragment,null,d!==void 0?e.createElement("label",{className:n.classNames(n.uRadioButton.label({c:f})),htmlFor:h||P,style:{userSelect:"none"},"aria-label":d},d):null),N=e.createElement("span",{className:n.classNames(n.uRadioButton.wrap({c:f}))},e.createElement("input",{...H}));return I==="before"?e.createElement(e.Fragment,null,E,N,B):e.createElement(e.Fragment,null,N,E,B)});g.propTypes={ariaDescribedBy:t.string,checked:t.bool,className:t.string,disabled:t.bool,id:t.string,size:t.oneOf([null,"small","medium","large"]),label:t.string,labelPlacement:t.string,name:t.string,style:t.object,tabIndex:t.number,value:t.any,valid:t.bool,onChange:t.func,onFocus:t.func,onBlur:t.func};const L={size:"medium"};g.displayName="KendoRadioButton";exports.RadioButton=g;exports.RadioButtonPropsContext=k;