@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.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
*-------------------------------------------------------------------------------------------
*/
"use client";
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),o=require("prop-types"),S=require("../classNames.js"),M=require("../unstyled/icons.js"),H=require("../unstyled/main.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),d=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]),m=t.useMemo(()=>n?n.content:void 0,[n]),x=t.useMemo(()=>g||c.size,[g]),i=t.useMemo(()=>f||c.flip,[f]),j=t.useMemo(()=>v||c.viewBox,[v]),C=t.useMemo(()=>S.classNames(M.uSvgIcon.wrapper({c:h,iconNameProp:b,themeColor:u,flipH:i==="horizontal"||i==="both",flipV:i==="vertical"||i==="both",size:x}),r),[h,b,u,i,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(()=>m?{__html:m}:void 0,[m]);return t.createElement("span",{className:S.classNames(M.uSvgIcon.svg({c:h,themeColor:u,flipH:i==="horizontal"||i==="both",flipV:i==="vertical"||i==="both"}),C),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:j,dangerouslySetInnerHTML:T,...O},n?void 0:s))});d.propTypes={style:o.object,classNames:o.string,children:o.any,icon:o.object,themeColor:o.oneOf(["inherit","primary","secondary","tertiary","info","success","error","warning","dark","light","inverse"]),size:o.oneOf(["default","xsmall","small","medium","large","xlarge","xxlarge","xxxlarge"]),flip:o.oneOf(["default","horizontal","vertical","both"])};const c={size:"default",flip:"default",icon:"",viewBox:"0 0 24 24"};d.displayName="KendoSvgIcon";exports.SvgIcon=d;