primereact
Version:
PrimeReact is an open source UI library for React featuring a rich set of 90+ 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) • 6.34 kB
JavaScript
import*as e from"react";import{PrimeReactContext as r}from"primereact/api";import{ComponentBase as n,useHandleStyle as t}from"primereact/componentbase";import{useMergeProps as a}from"primereact/hooks";import{classNames as i}from"primereact/utils";function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},o.apply(null,arguments)}function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function s(e,r){if("object"!=l(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var t=n.call(e,r||"default");if("object"!=l(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function p(e){var r=s(e,"string");return"symbol"==l(r)?r:r+""}function u(e,r,n){return(r=p(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var m=n.extend({defaultProps:{__TYPE:"ProgressBar",__parentMetadata:null,id:null,value:null,showValue:!0,unit:"%",style:null,className:null,mode:"determinate",displayValueTemplate:null,color:null,children:void 0},css:{classes:{root:function(e){return i("indeterminate"===e.props.mode?"p-progressbar p-component p-progressbar-indeterminate":"p-progressbar p-component p-progressbar-determinate")},value:"p-progressbar-value p-progressbar-value-animate",label:"p-progressbar-label",container:"p-progressbar-indeterminate-container"},styles:"\n@layer primereact {\n .p-progressbar {\n position: relative;\n overflow: hidden;\n }\n \n .p-progressbar-determinate .p-progressbar-value {\n height: 100%;\n width: 0%;\n position: absolute;\n display: none;\n border: 0 none;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n }\n \n .p-progressbar-determinate .p-progressbar-label {\n display: inline-flex;\n }\n \n .p-progressbar-determinate .p-progressbar-value-animate {\n transition: width 1s ease-in-out;\n }\n \n .p-progressbar-indeterminate .p-progressbar-value::before {\n content: '';\n position: absolute;\n background-color: inherit;\n top: 0;\n left: 0;\n bottom: 0;\n will-change: left, right;\n -webkit-animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;\n animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;\n }\n \n .p-progressbar-indeterminate .p-progressbar-value::after {\n content: '';\n position: absolute;\n background-color: inherit;\n top: 0;\n left: 0;\n bottom: 0;\n will-change: left, right;\n -webkit-animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;\n animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;\n -webkit-animation-delay: 1.15s;\n animation-delay: 1.15s;\n }\n}\n\n@-webkit-keyframes p-progressbar-indeterminate-anim {\n 0% {\n left: -35%;\n right: 100%; }\n 60% {\n left: 100%;\n right: -90%; }\n 100% {\n left: 100%;\n right: -90%; }\n}\n@keyframes p-progressbar-indeterminate-anim {\n 0% {\n left: -35%;\n right: 100%; }\n 60% {\n left: 100%;\n right: -90%; }\n 100% {\n left: 100%;\n right: -90%; }\n}\n\n@-webkit-keyframes p-progressbar-indeterminate-anim-short {\n 0% {\n left: -200%;\n right: 100%; }\n 60% {\n left: 107%;\n right: -8%; }\n 100% {\n left: 107%;\n right: -8%; }\n}\n@keyframes p-progressbar-indeterminate-anim-short {\n 0% {\n left: -200%;\n right: 100%; }\n 60% {\n left: 107%;\n right: -8%; }\n 100% {\n left: 107%;\n right: -8%; }\n}\n",inlineStyles:{value:function(e){var r=e.props,n=Math.max(r.value,2);return"indeterminate"===r.mode?{backgroundColor:r.color}:{width:n+"%",display:"flex",backgroundColor:r.value?r.color:"transparent"}}}}});function c(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function b(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?c(Object(n),!0).forEach((function(r){u(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var f=e.memo(e.forwardRef((function(n,l){var s=a(),p=e.useContext(r),u=m.getProps(n,p),c=m.setMetaData(b({props:u},u.__parentMetadata)),f=c.ptm,d=c.cx;t(m.css.styles,c.isUnstyled,{name:"progressbar"});var g,v,y,h,w=e.useRef(null);if(e.useImperativeHandle(l,(function(){return{props:u,getElement:function(){return w.current}}})),"determinate"===u.mode)return g=u.showValue&&null!=u.value?u.displayValueTemplate?u.displayValueTemplate(u.value):u.value+u.unit:null,v=s({className:i(u.className,d("root")),style:u.style,role:"progressbar","aria-valuemin":"0","aria-valuenow":u.value,"aria-valuemax":"100"},m.getOtherProps(u),f("root")),y=s({className:d("value"),style:{width:u.value+"%",display:"flex",backgroundColor:u.color}},f("value")),h=s({className:d("label")},f("label")),e.createElement("div",o({id:u.id,ref:w},v),e.createElement("div",y,null!=g&&e.createElement("div",h,g)));if("indeterminate"===u.mode)return function(){var r=s({className:i(u.className,d("root")),style:u.style,role:"progressbar","aria-valuemin":"0","aria-valuenow":u.value,"aria-valuemax":"100"},m.getOtherProps(u),f("root")),n=s({className:d("container")},f("container")),t=s({className:d("value"),style:{backgroundColor:u.color}},f("value"));return e.createElement("div",o({id:u.id,ref:w},r),e.createElement("div",n,e.createElement("div",t)))}();throw new Error(u.mode+" is not a valid mode for the ProgressBar. Valid values are 'determinate' and 'indeterminate'")})));f.displayName="ProgressBar";export{f as ProgressBar};