UNPKG

@progress/kendo-react-common

Version:

React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package

10 lines (9 loc) 2.63 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 client"; "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),i=require("prop-types"),S=require("../classNames.js"),M=require("../unstyled/icons.js"),H=require("../unstyled/unstyled-context.js");function R(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(l,s,r.get?r:{enumerable:!0,get:()=>e[s]})}}return l.default=e,Object.freeze(l)}const t=R(q),m=t.forwardRef((e,l)=>{const{children:s,className:r,svgClassName:N,icon:n,flip:f,id:p,tabIndex:z,size:g,style:a,svgStyle:I,themeColor:u,viewBox:v,name:_,onClick:P,...O}=e,w=t.useRef(null),y=H.useUnstyled(),h=y&&y.uSvgIcon;t.useImperativeHandle(l,()=>({element:w.current}));const b=t.useMemo(()=>n?n.name:c.icon,[n]),d=t.useMemo(()=>n?n.content:void 0,[n]),x=t.useMemo(()=>g||c.size,[g]),o=t.useMemo(()=>f||c.flip,[f]),C=t.useMemo(()=>v||c.viewBox,[v]),j=t.useMemo(()=>S.classNames(M.uSvgIcon.wrapper({c:h,iconNameProp:b,themeColor:u,flipH:o==="horizontal"||o==="both",flipV:o==="vertical"||o==="both",size:x}),r),[h,b,u,o,x,r]),B=t.useMemo(()=>e.width&&e.height?{width:e.width,height:e.height,...a}:e.width?{width:e.width,height:e.width,...a}:e.height?{width:e.height,height:e.height,...a}:{...a},[e.width,e.height,a]),T=t.useMemo(()=>d?{__html:d}:void 0,[d]);return t.createElement("span",{className:S.classNames(M.uSvgIcon.svg({c:h,themeColor:u,flipH:o==="horizontal"||o==="both",flipV:o==="vertical"||o==="both"}),j),style:B,ref:w,onClick:P,"aria-hidden":!0},t.createElement("svg",{id:p,className:N,style:I,"aria-hidden":!0,tabIndex:z,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:n?n.viewBox:C,dangerouslySetInnerHTML:T,...O},n?void 0:s))});m.propTypes={style:i.object,classNames:i.string,children:i.any,icon:i.object,themeColor:i.oneOf(["inherit","primary","secondary","tertiary","info","success","error","warning","dark","light","inverse"]),size:i.oneOf(["default","xsmall","small","medium","large","xlarge","xxlarge","xxxlarge"]),flip:i.oneOf(["default","horizontal","vertical","both"])};const c={size:"default",flip:"default",icon:"",viewBox:"0 0 24 24"};m.displayName="KendoSvgIcon";exports.SvgIcon=m;