UNPKG

@progress/kendo-react-labels

Version:

React Labels package provides components for labelling form editors. KendoReact Labels package

9 lines (8 loc) 1.96 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 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 S=require("react"),e=require("prop-types"),u=require("@progress/kendo-react-common"),d=require("./messages/index.js"),q=require("@progress/kendo-react-intl");function R(a){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>a[n]})}}return o.default=a,Object.freeze(o)}const c=R(S),b=a=>{const{id:o,editorId:n,editorRef:t,editorDisabled:s,children:r,editorValid:p,style:L,className:f,optional:N}=a,v=q.useLocalization(),m=N?v.toLanguageString(d.labelsOptional,d.messages[d.labelsOptional]):"",D=m&&c.createElement("span",{className:"k-label-optional"},m),y=u.useUnstyled(),g=y&&y.uLabel,j=c.useCallback(i=>{var O,k;if(!s){if(t!=null&&t.current){t.current.focus&&(i.preventDefault(),t.current.focus());const l=t.current.actionElement;l&&(i.preventDefault(),l.click())}else if(n){const l=document.getElementById(n);l&&(i.preventDefault(),(O=l.focus)==null||O.call(l),(k=l.click)==null||k.call(l))}}},[t,n,s]),C=c.useMemo(()=>u.classNames(u.uLabel.label({c:g,empty:!r,invalid:p===!1,disabled:s===!0}),f),[g,r,p,s,f]);return c.createElement("label",{id:o,htmlFor:n,onClick:j,style:L,className:C},r,D)};b.propTypes={id:e.string,editorId:e.string,editorRef:e.oneOfType([e.func,e.shape({current:e.any})]),editorValid:e.bool,editorDisabled:e.bool,style:e.object,className:e.string,optional:e.bool};b.displayName="KendoReactLabel";exports.Label=b;