primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with Prime
2 lines (1 loc) • 2.1 kB
JavaScript
import*as e from"react";import{ObjectUtils as t,classNames as n,IconUtils as l}from"primereact/utils";function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},a.apply(this,arguments)}var r=e.memo(e.forwardRef((function(s,i){var m=e.useRef(null),c=function(e,t,n){s.readOnly||t.disabled?e.preventDefault():(s.onSelect&&s.onSelect({originalEvent:e,item:t,index:n}),t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t,index:n}))},p=function(a,r){if(!1===a.visible)return null;var i=a.label+"_"+r,m=r===s.activeIndex,p=a.disabled||r!==s.activeIndex&&s.readOnly,o=p?-1:"",u=n("p-steps-item",a.className,{"p-highlight p-steps-current":m,"p-disabled":p}),d=n("p-menuitem-icon",a.icon),f=l.getJSXIcon(a.icon,{className:"p-menuitem-icon"},{props:s}),b=a.label&&e.createElement("span",{className:"p-steps-title"},a.label),v=e.createElement("a",{href:a.url||"#",className:"p-menuitem-link",role:"presentation",target:a.target,onClick:function(e){return c(e,a,r)},tabIndex:o},e.createElement("span",{className:"p-steps-number"},r+1),f,b);a.template&&(v=t.getJSXElement(a.template,a,{onClick:function(e){return c(e,a,r)},className:"p-menuitem-link",labelClassName:"p-steps-title",numberClassName:"p-steps-number",iconClassName:d,element:v,props:s,tabIndex:o,active:m,disabled:p}));return e.createElement("li",{key:i,id:a.id,className:u,style:a.style,role:"tab","aria-selected":m,"aria-expanded":m},v)};e.useImperativeHandle(i,(function(){return{props:s,getElement:function(){return m.current}}}));var o=t.findDiffKeys(s,r.defaultProps),u=n("p-steps p-component",{"p-readonly":s.readOnly},s.className),d=function(){if(s.model){var t=s.model.map(p);return e.createElement("ul",{role:"tablist"},t)}return null}();return e.createElement("div",a({id:s.id,ref:m,className:u,style:s.style},o),d)})));r.displayName="Steps",r.defaultProps={__TYPE:"Steps",id:null,model:null,activeIndex:0,readOnly:!0,style:null,className:null,onSelect:null};export{r as Steps};