@webkom/react-meter-bar
Version:
A simple react meter component
29 lines (25 loc) • 14.7 kB
JavaScript
(function(S,_){typeof exports=="object"&&typeof module<"u"?module.exports=_(require("react")):typeof define=="function"&&define.amd?define(["react"],_):(S=typeof globalThis<"u"?globalThis:S||self,S["react-meter-bar"]=_(S.React))})(this,function(S){"use strict";var _={},Pe={get exports(){return _},set exports(f){_=f}},A={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Q;function xe(){if(Q)return A;Q=1;var f=S,b=Symbol.for("react.element"),y=Symbol.for("react.fragment"),h=Object.prototype.hasOwnProperty,p=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,C={key:!0,ref:!0,__self:!0,__source:!0};function $(w,c,j){var g,E={},P=null,Y=null;j!==void 0&&(P=""+j),c.key!==void 0&&(P=""+c.key),c.ref!==void 0&&(Y=c.ref);for(g in c)h.call(c,g)&&!C.hasOwnProperty(g)&&(E[g]=c[g]);if(w&&w.defaultProps)for(g in c=w.defaultProps,c)E[g]===void 0&&(E[g]=c[g]);return{$$typeof:b,type:w,key:P,ref:Y,props:E,_owner:p.current}}return A.Fragment=y,A.jsx=$,A.jsxs=$,A}var I={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ee;function je(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){var f=S,b=Symbol.for("react.element"),y=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),$=Symbol.for("react.provider"),w=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),ne=Symbol.iterator,Ae="@@iterator";function Ie(e){if(e===null||typeof e!="object")return null;var r=ne&&e[ne]||e[Ae];return typeof r=="function"?r:null}var k=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];$e("error",e,t)}}function $e(e,r,t){{var n=k.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ne=!1,We=!1,Ye=!1,Le=!1,Ve=!1,ae;ae=Symbol.for("react.module.reference");function Me(e){return!!(typeof e=="string"||typeof e=="function"||e===h||e===C||Ve||e===p||e===j||e===g||Le||e===Y||Ne||We||Ye||typeof e=="object"&&e!==null&&(e.$$typeof===P||e.$$typeof===E||e.$$typeof===$||e.$$typeof===w||e.$$typeof===c||e.$$typeof===ae||e.getModuleId!==void 0))}function Ue(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function oe(e){return e.displayName||"Context"}function R(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case y:return"Portal";case C:return"Profiler";case p:return"StrictMode";case j:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:var r=e;return oe(r)+".Consumer";case $:var t=e;return oe(t._context)+".Provider";case c:return Ue(e,e.render,"ForwardRef");case E:var n=e.displayName||null;return n!==null?n:R(e.type)||"Memo";case P:{var i=e,u=i._payload,o=i._init;try{return R(o(u))}catch{return null}}}return null}var x=Object.assign,N=0,ie,ue,se,le,fe,ce,de;function ve(){}ve.__reactDisabledLog=!0;function Be(){{if(N===0){ie=console.log,ue=console.info,se=console.warn,le=console.error,fe=console.group,ce=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}}function qe(){{if(N--,N===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:x({},e,{value:ie}),info:x({},e,{value:ue}),warn:x({},e,{value:se}),error:x({},e,{value:le}),group:x({},e,{value:fe}),groupCollapsed:x({},e,{value:ce}),groupEnd:x({},e,{value:de})})}N<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=k.ReactCurrentDispatcher,J;function L(e,r,t){{if(J===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);J=n&&n[1]||""}return`
`+J+e}}var G=!1,V;{var Je=typeof WeakMap=="function"?WeakMap:Map;V=new Je}function pe(e,r){if(!e||G)return"";{var t=V.get(e);if(t!==void 0)return t}var n;G=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Be();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(T){n=T}Reflect.construct(e,[],o)}else{try{o.call()}catch(T){n=T}e.call(o.prototype)}}else{try{throw Error()}catch(T){n=T}e()}}catch(T){if(T&&n&&typeof T.stack=="string"){for(var a=T.stack.split(`
`),v=n.stack.split(`
`),s=a.length-1,l=v.length-1;s>=1&&l>=0&&a[s]!==v[l];)l--;for(;s>=1&&l>=0;s--,l--)if(a[s]!==v[l]){if(s!==1||l!==1)do if(s--,l--,l<0||a[s]!==v[l]){var m=`
`+a[s].replace(" at new "," at ");return e.displayName&&m.includes("<anonymous>")&&(m=m.replace("<anonymous>",e.displayName)),typeof e=="function"&&V.set(e,m),m}while(s>=1&&l>=0);break}}}finally{G=!1,q.current=u,qe(),Error.prepareStackTrace=i}var D=e?e.displayName||e.name:"",we=D?L(D):"";return typeof e=="function"&&V.set(e,we),we}function Ge(e,r,t){return pe(e,!1)}function ze(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function M(e,r,t){if(e==null)return"";if(typeof e=="function")return pe(e,ze(e));if(typeof e=="string")return L(e);switch(e){case j:return L("Suspense");case g:return L("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case c:return Ge(e.render);case E:return M(e.type,r,t);case P:{var n=e,i=n._payload,u=n._init;try{return M(u(i),r,t)}catch{}}}return""}var U=Object.prototype.hasOwnProperty,ge={},he=k.ReactDebugCurrentFrame;function B(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);he.setExtraStackFrame(t)}else he.setExtraStackFrame(null)}function Ke(e,r,t,n,i){{var u=Function.call.bind(U);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var v=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(B(i),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),B(null)),a instanceof Error&&!(a.message in ge)&&(ge[a.message]=!0,B(i),d("Failed %s type: %s",t,a.message),B(null))}}}var He=Array.isArray;function z(e){return He(e)}function Xe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ze(e){try{return me(e),!1}catch{return!0}}function me(e){return""+e}function be(e){if(Ze(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Xe(e)),me(e)}var W=k.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},_e,ye,K;K={};function er(e){if(U.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function rr(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function tr(e,r){if(typeof e.ref=="string"&&W.current&&r&&W.current.stateNode!==r){var t=R(W.current.type);K[t]||(d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',R(W.current.type),e.ref),K[t]=!0)}}function nr(e,r){{var t=function(){_e||(_e=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function ar(e,r){{var t=function(){ye||(ye=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var or=function(e,r,t,n,i,u,o){var a={$$typeof:b,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function ir(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(be(t),a=""+t),rr(r)&&(be(r.key),a=""+r.key),er(r)&&(v=r.ref,tr(r,i));for(u in r)U.call(r,u)&&!Qe.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||v){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&nr(o,l),v&&ar(o,l)}return or(e,a,v,i,n,W.current,o)}}var H=k.ReactCurrentOwner,Ee=k.ReactDebugCurrentFrame;function F(e){if(e){var r=e._owner,t=M(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(t)}else Ee.setExtraStackFrame(null)}var X;X=!1;function Z(e){return typeof e=="object"&&e!==null&&e.$$typeof===b}function Re(){{if(H.current){var e=R(H.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function ur(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
Check your code at `+r+":"+t+"."}return""}}var Te={};function sr(e){{var r=Re();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=sr(r);if(Te[t])return;Te[t]=!0;var n="";e&&e._owner&&e._owner!==H.current&&(n=" It was passed a child from "+R(e._owner.type)+"."),F(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function Ce(e,r){{if(typeof e!="object")return;if(z(e))for(var t=0;t<e.length;t++){var n=e[t];Z(n)&&Oe(n,r)}else if(Z(e))e._store&&(e._store.validated=!0);else if(e){var i=Ie(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)Z(o.value)&&Oe(o.value,r)}}}function lr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===c||r.$$typeof===E))t=r.propTypes;else return;if(t){var n=R(r);Ke(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!X){X=!0;var i=R(r);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function fr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}function Se(e,r,t,n,i,u){{var o=Me(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=ur(i);v?a+=v:a+=Re();var s;e===null?s="null":z(e)?s="array":e!==void 0&&e.$$typeof===b?(s="<"+(R(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var l=ir(e,r,t,i,u);if(l==null)return l;if(o){var m=r.children;if(m!==void 0)if(n)if(z(m)){for(var D=0;D<m.length;D++)Ce(m[D],e);Object.freeze&&Object.freeze(m)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ce(m,e)}return e===h?fr(l):lr(l),l}}function cr(e,r,t){return Se(e,r,t,!0)}function dr(e,r,t){return Se(e,r,t,!1)}var vr=dr,pr=cr;I.Fragment=h,I.jsx=vr,I.jsxs=pr}()),I}(function(f){process.env.NODE_ENV==="production"?f.exports=xe():f.exports=je()})(Pe);const re=_.Fragment,O=_.jsx,te=_.jsxs,gr="",ke=({labels:f,progress:b,labelColor:y,barColor:h,separatorColor:p})=>{const C={width:`${b}%`,backgroundColor:h};return te("div",{className:"progress-bar",children:[O("div",{className:"progress-bar__label-holder",children:O(Fe,{labels:f,color:y})}),te("div",{className:"progress-bar__progress-bg",children:[O("div",{className:"progress-bar__progress",style:C}),O(De,{labels:f,color:p})]})]})},Fe=({labels:f,color:b})=>{const y=100/(f.length-1),h={color:b};return O(re,{children:f.map((p,C)=>O("span",{style:{left:`${y*C}%`,...h},className:"label",children:p},p))})},De=({labels:f,color:b})=>{const y=100/(f.length-1);return O(re,{children:f.map((h,p)=>p===0||p===f.length-1?null:O("div",{style:{left:`${y*p}%`,backgroundColor:b},className:"label progress-bar__seperator"},h))})};return ke});
//# sourceMappingURL=react-meter-bar.umd.cjs.map