rte-utils 1.2.22 → 1.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  export { ProductionUnit } from "./ProductionUnit";
2
+ export { ProductionUnitContainer } from "./ProductionUnitContainer";
2
3
  export { Histogram } from "./Histogram";
3
4
  export { Chip } from "./Chip";
4
5
  export { Switch } from "./Switch";
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useState as n,useRef as e,useEffect as a}from"react";var o=function(o){var c=o.label,l=o.value,r=void 0===l?"":l,d=o.onChange,h=o.type,s=void 0===h?"text":h,v=o.disabled,u=void 0!==v&&v,m=o.className,f=void 0===m?"":m,p=o.required,b=void 0!==p&&p,g=o.min,N=void 0===g?{value:0,label:"Pmin"}:g,w=o.max,C=void 0===w?{value:100,label:"Pmax"}:w,x=n(r),L=x[0],R=x[1],k=n(!1),y=k[0],z=k[1],M=n(!1),F=M[0],B=M[1],P=e(null);a(function(){R(r)},[r]);var q=["input-container",y?"input-container--focused":"",y||L.length>0?"input-container--floating":"",u?"input-container--disabled":"",F?"input-container--error":"",f].filter(Boolean).join(" ");return t("div",{className:q,children:i("div",{className:"input-constraints",children:[i("div",{className:"input-min",children:[N.label,t("br",{}),N.value]}),i("div",{className:"input-field",children:[t("input",{ref:P,type:s,value:L,onChange:function(t){var i=t.target.value;if("number"===s&&""!==i){var n=parseFloat(i);if(isNaN(n))B(!1);else{var e=n<N.value||n>C.value;B(e)}}else B(!1);R(i),null==d||d(i)},onFocus:function(){z(!0)},onBlur:function(){if(z(!1),"number"===s&&""!==L){var t=parseFloat(L);if(!isNaN(t)){var i=Math.max(N.value,Math.min(C.value,t));if(i!==t){var n=i.toString();R(n),null==d||d(n)}B(!1)}}},disabled:u,required:b,className:"input-element","aria-label":c,min:"number"===s?N.value:void 0,max:"number"===s?C.value:void 0,step:"number"===s?1:void 0}),i("label",{className:"input-label",children:[c,b&&t("span",{className:"input-required",children:"*"})]})]}),i("div",{className:"input-max",children:[C.label,t("br",{})," ",C.value]})]})})},c=function(i){var n=i.isOff;return t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M9.56529 2.85352C9.66365 2.57607 9.96837 2.43116 10.246 2.5293C13.4295 3.65507 15.3392 6.91015 14.7684 10.2383C14.1974 13.5667 11.3114 16 7.93443 16C4.55739 16 1.67151 13.5667 1.10045 10.2383C0.5296 6.91011 2.4393 3.65504 5.62291 2.5293C5.9005 2.43115 6.20523 2.57605 6.30357 2.85352C6.40176 3.13124 6.2561 3.43599 5.97838 3.53418C3.28438 4.48672 1.669 7.2423 2.1522 10.0586C2.63557 12.8747 5.07706 14.9336 7.93443 14.9336C10.7918 14.9336 13.2333 12.8747 13.7167 10.0586C14.1999 7.24233 12.5844 4.48676 9.89049 3.53418C9.61276 3.43599 9.4671 3.13124 9.56529 2.85352ZM7.93443 0C8.22892 3.10447e-05 8.46754 0.238727 8.46763 0.533203V7.4668C8.46763 7.76135 8.22898 8.00095 7.93443 8.00098C7.63986 8.00098 7.40123 7.76137 7.40123 7.4668V0.533203C7.40132 0.238707 7.63991 0 7.93443 0Z",fill:n?"#999FA1":"#009CDF"})})},l=function(i){var n=i.isOff;return t("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("circle",{cx:"16",cy:"16",r:"16",fill:n?"white":"#009cdf"})})},r=function(e){var a=e.checked,o=void 0!==a&&a,r=e.onChange,d=e.disabled,h=void 0!==d&&d,s=e.showIcon,v=void 0===s||s,u=n(o),m=u[0],f=u[1],p=void 0!==o?o:m,b=["switch",p?"switch--checked":"",h?"switch--disabled":""].filter(Boolean).join(" ");return t("div",{className:"switch-container",children:i("div",{className:"switch-wrapper",children:[v&&t("div",{className:"switch-icon",children:t(c,{isOff:!p})}),t("button",{type:"button",role:"switch","aria-checked":p,className:b,onClick:function(){if(!h){var t=!p;void 0===o&&f(t),null==r||r(t)}},disabled:h,children:t("span",{className:"switch-track",children:t("span",{className:"switch-thumb",children:t(l,{isOff:!p})})})})]})})},d=function(i){var n=i.label,e=i.bgColor,a=i.textColor,o=i.width,c=["chip-container","full-width"===(void 0===o?"fit-content":o)?"chip-container--full-width":"chip-container--fit-content"].join(" ");return t("div",{className:c,style:{backgroundColor:e},children:t("div",{className:"chip-content",children:t("p",{className:"chip-label",style:{color:a},children:n})})})},h=function(i){var n=i.bgColor,e=void 0===n?"#fff":n,a=i.children,o=i.height;return t("div",{className:"production-unit-container-box",style:{backgroundColor:e,height:o},children:a})},s=function(e){var a=e.onChangeInput,c=e.onChangeSwitch,l=e.defaultValue,s=e.defaultChecked,v=void 0!==s&&s,u=e.value,m=e.checked,f=e.unitName,p=void 0===f?"Production Unit":f,b=e.energyCost,g=void 0===b?0:b,N=e.checkedImage,w=e.uncheckedImage,C=e.readonly,x=void 0!==C&&C,L=e.min,R=void 0===L?{value:10,label:"Pmin"}:L,k=e.max,y=void 0===k?{value:100,label:"Pmax"}:k,z=n(v),M=z[0],F=z[1],B=n(l),P=B[0],q=B[1],O=void 0!==m?m:M,j=void 0!==u?u:P;return t(h,{children:i("div",{className:"production-unit-container",children:[i("div",{className:"production-unit-content",children:[t("div",{className:"image-preview-container",children:O?N:w}),i("div",{className:"production-unit-chip",children:[t("div",{className:"production-unit-chip-name",children:p}),t(d,{label:"".concat(g," MW"),width:"fit-content",bgColor:"#E1F5FD",textColor:"#005896"})]}),i("div",{className:"production-unit-switch-container",children:[t(o,{label:"PA",type:"number",onChange:function(t){var i=Number(t);void 0===u&&q(i),a&&a(i)},value:void 0!==j?j.toString():void 0,disabled:!O||x,min:{value:R.value,label:R.label},max:{value:y.value,label:y.label}})," "]})]}),t(r,{checked:O,onChange:function(t){void 0===m&&F(t),c&&c(t)},disabled:x})]})})},v=function(e){var o,c,l,r,d=e.max,h=e.relative,s=e.barHeight,v=void 0===s?103:s,u=e.barWidth,m=void 0===u?32:u,f=e.orientation,p=void 0===f?"vertical":f,b=e.cornerRadius,g=e.children,N=n(0),w=N[0],C=N[1],x=n(0),L=x[0],R=x[1],k=Math.min(h.value/d.value*100,100)/100*v,y=Math.min(h.value/d.value*100,100)/100*m;a(function(){C(0),R(0);var t=Date.now(),i=function(){var n=Date.now()-t,e=Math.min(n/1e3,1),a=1-Math.pow(1-e,4);C(k*a),R(y*a),e<1&&requestAnimationFrame(i)};requestAnimationFrame(i)},[k,y]);var z="horizontal"===p?v:m,M="horizontal"===p?m:v,F="horizontal"===p?v:m,B="horizontal"===p?m:v,P=function(t,i,n,e,a){var o=a.topLeft,c=a.topRight,l=a.bottomLeft,r=a.bottomRight;return"\n M ".concat(t+o," ").concat(i,"\n L ").concat(t+n-c," ").concat(i,"\n Q ").concat(t+n," ").concat(i," ").concat(t+n," ").concat(i+c,"\n L ").concat(t+n," ").concat(i+e-r,"\n Q ").concat(t+n," ").concat(i+e," ").concat(t+n-r," ").concat(i+e,"\n L ").concat(t+l," ").concat(i+e,"\n Q ").concat(t," ").concat(i+e," ").concat(t," ").concat(i+e-l,"\n L ").concat(t," ").concat(i+o,"\n Q ").concat(t," ").concat(i," ").concat(t+o," ").concat(i,"\n Z\n ").trim().replace(/\s+/g," ")},q={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},O=b?{topLeft:null!==(o=b.topLeft)&&void 0!==o?o:q.topLeft,topRight:null!==(c=b.topRight)&&void 0!==c?c:q.topRight,bottomLeft:null!==(l=b.bottomLeft)&&void 0!==l?l:q.bottomLeft,bottomRight:null!==(r=b.bottomRight)&&void 0!==r?r:q.bottomRight}:q;return t("div",{className:"histogram-container ".concat("horizontal"===p?"histogram-container--horizontal":""),children:i("div",{className:"histogram-content ".concat("horizontal"===p?"histogram-content--horizontal":""),children:[t("div",{className:"histogram-bar",style:{height:"".concat(M,"px"),width:"".concat(z,"px")},children:i("svg",{width:F,height:B,viewBox:"0 0 ".concat(F," ").concat(B),className:"histogram-svg",children:[t("path",{d:P(0,0,F,B,O),fill:d.color,fillOpacity:d.opacity||1}),t("path","vertical"===p?{d:P(0,B-w,F,w,{topLeft:w>=B?O.topLeft:0,topRight:w>=B?O.topRight:0,bottomLeft:O.bottomLeft,bottomRight:O.bottomRight}),fill:h.color}:{d:P(0,0,L,B,{topLeft:O.topLeft,topRight:L>=F?O.topRight:0,bottomLeft:O.bottomLeft,bottomRight:L>=F?O.bottomRight:0}),fill:h.color})]})}),g&&t("div",{className:"histogram-text-container ".concat("horizontal"===p?"histogram-text-container--horizontal":""),children:g})]})})},u=function(i){var n=i.children;return t("div",{className:"avatar-container avatar-container--clickable",children:t("div",{className:"avatar-content",children:n})})};export{u as Avatar,d as Chip,v as Histogram,o as Input,s as ProductionUnit,r as Switch};
1
+ import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useState as n,useRef as e,useEffect as a}from"react";var o=function(o){var c=o.label,l=o.value,r=void 0===l?"":l,d=o.onChange,h=o.type,s=void 0===h?"text":h,v=o.disabled,u=void 0!==v&&v,m=o.className,f=void 0===m?"":m,p=o.required,b=void 0!==p&&p,g=o.min,N=void 0===g?{value:0,label:"Pmin"}:g,w=o.max,C=void 0===w?{value:100,label:"Pmax"}:w,x=n(r),L=x[0],R=x[1],k=n(!1),y=k[0],z=k[1],M=n(!1),F=M[0],B=M[1],P=e(null);a(function(){R(r)},[r]);var q=["input-container",y?"input-container--focused":"",y||L.length>0?"input-container--floating":"",u?"input-container--disabled":"",F?"input-container--error":"",f].filter(Boolean).join(" ");return t("div",{className:q,children:i("div",{className:"input-constraints",children:[i("div",{className:"input-min",children:[N.label,t("br",{}),N.value]}),i("div",{className:"input-field",children:[t("input",{ref:P,type:s,value:L,onChange:function(t){var i=t.target.value;if("number"===s&&""!==i){var n=parseFloat(i);if(isNaN(n))B(!1);else{var e=n<N.value||n>C.value;B(e)}}else B(!1);R(i),null==d||d(i)},onFocus:function(){z(!0)},onBlur:function(){if(z(!1),"number"===s&&""!==L){var t=parseFloat(L);if(!isNaN(t)){var i=Math.max(N.value,Math.min(C.value,t));if(i!==t){var n=i.toString();R(n),null==d||d(n)}B(!1)}}},disabled:u,required:b,className:"input-element","aria-label":c,min:"number"===s?N.value:void 0,max:"number"===s?C.value:void 0,step:"number"===s?1:void 0}),i("label",{className:"input-label",children:[c,b&&t("span",{className:"input-required",children:"*"})]})]}),i("div",{className:"input-max",children:[C.label,t("br",{})," ",C.value]})]})})},c=function(i){var n=i.isOff;return t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M9.56529 2.85352C9.66365 2.57607 9.96837 2.43116 10.246 2.5293C13.4295 3.65507 15.3392 6.91015 14.7684 10.2383C14.1974 13.5667 11.3114 16 7.93443 16C4.55739 16 1.67151 13.5667 1.10045 10.2383C0.5296 6.91011 2.4393 3.65504 5.62291 2.5293C5.9005 2.43115 6.20523 2.57605 6.30357 2.85352C6.40176 3.13124 6.2561 3.43599 5.97838 3.53418C3.28438 4.48672 1.669 7.2423 2.1522 10.0586C2.63557 12.8747 5.07706 14.9336 7.93443 14.9336C10.7918 14.9336 13.2333 12.8747 13.7167 10.0586C14.1999 7.24233 12.5844 4.48676 9.89049 3.53418C9.61276 3.43599 9.4671 3.13124 9.56529 2.85352ZM7.93443 0C8.22892 3.10447e-05 8.46754 0.238727 8.46763 0.533203V7.4668C8.46763 7.76135 8.22898 8.00095 7.93443 8.00098C7.63986 8.00098 7.40123 7.76137 7.40123 7.4668V0.533203C7.40132 0.238707 7.63991 0 7.93443 0Z",fill:n?"#999FA1":"#009CDF"})})},l=function(i){var n=i.isOff;return t("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("circle",{cx:"16",cy:"16",r:"16",fill:n?"white":"#009cdf"})})},r=function(e){var a=e.checked,o=void 0!==a&&a,r=e.onChange,d=e.disabled,h=void 0!==d&&d,s=e.showIcon,v=void 0===s||s,u=n(o),m=u[0],f=u[1],p=void 0!==o?o:m,b=["switch",p?"switch--checked":"",h?"switch--disabled":""].filter(Boolean).join(" ");return t("div",{className:"switch-container",children:i("div",{className:"switch-wrapper",children:[v&&t("div",{className:"switch-icon",children:t(c,{isOff:!p})}),t("button",{type:"button",role:"switch","aria-checked":p,className:b,onClick:function(){if(!h){var t=!p;void 0===o&&f(t),null==r||r(t)}},disabled:h,children:t("span",{className:"switch-track",children:t("span",{className:"switch-thumb",children:t(l,{isOff:!p})})})})]})})},d=function(i){var n=i.label,e=i.bgColor,a=i.textColor,o=i.width,c=["chip-container","full-width"===(void 0===o?"fit-content":o)?"chip-container--full-width":"chip-container--fit-content"].join(" ");return t("div",{className:c,style:{backgroundColor:e},children:t("div",{className:"chip-content",children:t("p",{className:"chip-label",style:{color:a},children:n})})})},h=function(i){var n=i.bgColor,e=void 0===n?"#fff":n,a=i.children,o=i.height;return t("div",{className:"production-unit-container-box",style:{backgroundColor:e,height:o},children:a})},s=function(e){var a=e.onChangeInput,c=e.onChangeSwitch,l=e.defaultValue,s=e.defaultChecked,v=void 0!==s&&s,u=e.value,m=e.checked,f=e.unitName,p=void 0===f?"Production Unit":f,b=e.energyCost,g=void 0===b?0:b,N=e.checkedImage,w=e.uncheckedImage,C=e.readonly,x=void 0!==C&&C,L=e.min,R=void 0===L?{value:10,label:"Pmin"}:L,k=e.max,y=void 0===k?{value:100,label:"Pmax"}:k,z=n(v),M=z[0],F=z[1],B=n(l),P=B[0],q=B[1],O=void 0!==m?m:M,j=void 0!==u?u:P;return t(h,{children:i("div",{className:"production-unit-container",children:[i("div",{className:"production-unit-content",children:[t("div",{className:"image-preview-container",children:O?N:w}),i("div",{className:"production-unit-chip",children:[t("div",{className:"production-unit-chip-name",children:p}),t(d,{label:"".concat(g," MW"),width:"fit-content",bgColor:"#E1F5FD",textColor:"#005896"})]}),i("div",{className:"production-unit-switch-container",children:[t(o,{label:"PA",type:"number",onChange:function(t){var i=Number(t);void 0===u&&q(i),a&&a(i)},value:void 0!==j?j.toString():void 0,disabled:!O||x,min:{value:R.value,label:R.label},max:{value:y.value,label:y.label}})," "]})]}),t(r,{checked:O,onChange:function(t){void 0===m&&F(t),c&&c(t)},disabled:x})]})})},v=function(e){var o,c,l,r,d=e.max,h=e.relative,s=e.barHeight,v=void 0===s?103:s,u=e.barWidth,m=void 0===u?32:u,f=e.orientation,p=void 0===f?"vertical":f,b=e.cornerRadius,g=e.children,N=n(0),w=N[0],C=N[1],x=n(0),L=x[0],R=x[1],k=Math.min(h.value/d.value*100,100)/100*v,y=Math.min(h.value/d.value*100,100)/100*m;a(function(){C(0),R(0);var t=Date.now(),i=function(){var n=Date.now()-t,e=Math.min(n/1e3,1),a=1-Math.pow(1-e,4);C(k*a),R(y*a),e<1&&requestAnimationFrame(i)};requestAnimationFrame(i)},[k,y]);var z="horizontal"===p?v:m,M="horizontal"===p?m:v,F="horizontal"===p?v:m,B="horizontal"===p?m:v,P=function(t,i,n,e,a){var o=a.topLeft,c=a.topRight,l=a.bottomLeft,r=a.bottomRight;return"\n M ".concat(t+o," ").concat(i,"\n L ").concat(t+n-c," ").concat(i,"\n Q ").concat(t+n," ").concat(i," ").concat(t+n," ").concat(i+c,"\n L ").concat(t+n," ").concat(i+e-r,"\n Q ").concat(t+n," ").concat(i+e," ").concat(t+n-r," ").concat(i+e,"\n L ").concat(t+l," ").concat(i+e,"\n Q ").concat(t," ").concat(i+e," ").concat(t," ").concat(i+e-l,"\n L ").concat(t," ").concat(i+o,"\n Q ").concat(t," ").concat(i," ").concat(t+o," ").concat(i,"\n Z\n ").trim().replace(/\s+/g," ")},q={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},O=b?{topLeft:null!==(o=b.topLeft)&&void 0!==o?o:q.topLeft,topRight:null!==(c=b.topRight)&&void 0!==c?c:q.topRight,bottomLeft:null!==(l=b.bottomLeft)&&void 0!==l?l:q.bottomLeft,bottomRight:null!==(r=b.bottomRight)&&void 0!==r?r:q.bottomRight}:q;return t("div",{className:"histogram-container ".concat("horizontal"===p?"histogram-container--horizontal":""),children:i("div",{className:"histogram-content ".concat("horizontal"===p?"histogram-content--horizontal":""),children:[t("div",{className:"histogram-bar",style:{height:"".concat(M,"px"),width:"".concat(z,"px")},children:i("svg",{width:F,height:B,viewBox:"0 0 ".concat(F," ").concat(B),className:"histogram-svg",children:[t("path",{d:P(0,0,F,B,O),fill:d.color,fillOpacity:d.opacity||1}),t("path","vertical"===p?{d:P(0,B-w,F,w,{topLeft:w>=B?O.topLeft:0,topRight:w>=B?O.topRight:0,bottomLeft:O.bottomLeft,bottomRight:O.bottomRight}),fill:h.color}:{d:P(0,0,L,B,{topLeft:O.topLeft,topRight:L>=F?O.topRight:0,bottomLeft:O.bottomLeft,bottomRight:L>=F?O.bottomRight:0}),fill:h.color})]})}),g&&t("div",{className:"histogram-text-container ".concat("horizontal"===p?"histogram-text-container--horizontal":""),children:g})]})})},u=function(i){var n=i.children;return t("div",{className:"avatar-container avatar-container--clickable",children:t("div",{className:"avatar-content",children:n})})};export{u as Avatar,d as Chip,v as Histogram,o as Input,s as ProductionUnit,h as ProductionUnitContainer,r as Switch};
2
2
  //# sourceMappingURL=index.esm.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("react/jsx-runtime"),e=require("react"),i=function(i){var n=i.label,a=i.value,o=void 0===a?"":a,c=i.onChange,l=i.type,r=void 0===l?"text":l,s=i.disabled,d=void 0!==s&&s,h=i.className,u=void 0===h?"":h,v=i.required,m=void 0!==v&&v,f=i.min,p=void 0===f?{value:0,label:"Pmin"}:f,x=i.max,b=void 0===x?{value:100,label:"Pmax"}:x,g=e.useState(o),j=g[0],w=g[1],N=e.useState(!1),C=N[0],L=N[1],R=e.useState(!1),k=R[0],y=R[1],S=e.useRef(null);e.useEffect(function(){w(o)},[o]);var z=["input-container",C?"input-container--focused":"",C||j.length>0?"input-container--floating":"",d?"input-container--disabled":"",k?"input-container--error":"",u].filter(Boolean).join(" ");return t.jsx("div",{className:z,children:t.jsxs("div",{className:"input-constraints",children:[t.jsxs("div",{className:"input-min",children:[p.label,t.jsx("br",{}),p.value]}),t.jsxs("div",{className:"input-field",children:[t.jsx("input",{ref:S,type:r,value:j,onChange:function(t){var e=t.target.value;if("number"===r&&""!==e){var i=parseFloat(e);if(isNaN(i))y(!1);else{var n=i<p.value||i>b.value;y(n)}}else y(!1);w(e),null==c||c(e)},onFocus:function(){L(!0)},onBlur:function(){if(L(!1),"number"===r&&""!==j){var t=parseFloat(j);if(!isNaN(t)){var e=Math.max(p.value,Math.min(b.value,t));if(e!==t){var i=e.toString();w(i),null==c||c(i)}y(!1)}}},disabled:d,required:m,className:"input-element","aria-label":n,min:"number"===r?p.value:void 0,max:"number"===r?b.value:void 0,step:"number"===r?1:void 0}),t.jsxs("label",{className:"input-label",children:[n,m&&t.jsx("span",{className:"input-required",children:"*"})]})]}),t.jsxs("div",{className:"input-max",children:[b.label,t.jsx("br",{})," ",b.value]})]})})},n=function(e){var i=e.isOff;return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M9.56529 2.85352C9.66365 2.57607 9.96837 2.43116 10.246 2.5293C13.4295 3.65507 15.3392 6.91015 14.7684 10.2383C14.1974 13.5667 11.3114 16 7.93443 16C4.55739 16 1.67151 13.5667 1.10045 10.2383C0.5296 6.91011 2.4393 3.65504 5.62291 2.5293C5.9005 2.43115 6.20523 2.57605 6.30357 2.85352C6.40176 3.13124 6.2561 3.43599 5.97838 3.53418C3.28438 4.48672 1.669 7.2423 2.1522 10.0586C2.63557 12.8747 5.07706 14.9336 7.93443 14.9336C10.7918 14.9336 13.2333 12.8747 13.7167 10.0586C14.1999 7.24233 12.5844 4.48676 9.89049 3.53418C9.61276 3.43599 9.4671 3.13124 9.56529 2.85352ZM7.93443 0C8.22892 3.10447e-05 8.46754 0.238727 8.46763 0.533203V7.4668C8.46763 7.76135 8.22898 8.00095 7.93443 8.00098C7.63986 8.00098 7.40123 7.76137 7.40123 7.4668V0.533203C7.40132 0.238707 7.63991 0 7.93443 0Z",fill:i?"#999FA1":"#009CDF"})})},a=function(e){var i=e.isOff;return t.jsx("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("circle",{cx:"16",cy:"16",r:"16",fill:i?"white":"#009cdf"})})},o=function(i){var o=i.checked,c=void 0!==o&&o,l=i.onChange,r=i.disabled,s=void 0!==r&&r,d=i.showIcon,h=void 0===d||d,u=e.useState(c),v=u[0],m=u[1],f=void 0!==c?c:v,p=["switch",f?"switch--checked":"",s?"switch--disabled":""].filter(Boolean).join(" ");return t.jsx("div",{className:"switch-container",children:t.jsxs("div",{className:"switch-wrapper",children:[h&&t.jsx("div",{className:"switch-icon",children:t.jsx(n,{isOff:!f})}),t.jsx("button",{type:"button",role:"switch","aria-checked":f,className:p,onClick:function(){if(!s){var t=!f;void 0===c&&m(t),null==l||l(t)}},disabled:s,children:t.jsx("span",{className:"switch-track",children:t.jsx("span",{className:"switch-thumb",children:t.jsx(a,{isOff:!f})})})})]})})},c=function(e){var i=e.label,n=e.bgColor,a=e.textColor,o=e.width,c=["chip-container","full-width"===(void 0===o?"fit-content":o)?"chip-container--full-width":"chip-container--fit-content"].join(" ");return t.jsx("div",{className:c,style:{backgroundColor:n},children:t.jsx("div",{className:"chip-content",children:t.jsx("p",{className:"chip-label",style:{color:a},children:i})})})},l=function(e){var i=e.bgColor,n=void 0===i?"#fff":i,a=e.children,o=e.height;return t.jsx("div",{className:"production-unit-container-box",style:{backgroundColor:n,height:o},children:a})};exports.Avatar=function(e){var i=e.children;return t.jsx("div",{className:"avatar-container avatar-container--clickable",children:t.jsx("div",{className:"avatar-content",children:i})})},exports.Chip=c,exports.Histogram=function(i){var n,a,o,c,l=i.max,r=i.relative,s=i.barHeight,d=void 0===s?103:s,h=i.barWidth,u=void 0===h?32:h,v=i.orientation,m=void 0===v?"vertical":v,f=i.cornerRadius,p=i.children,x=e.useState(0),b=x[0],g=x[1],j=e.useState(0),w=j[0],N=j[1],C=Math.min(r.value/l.value*100,100)/100*d,L=Math.min(r.value/l.value*100,100)/100*u;e.useEffect(function(){g(0),N(0);var t=Date.now(),e=function(){var i=Date.now()-t,n=Math.min(i/1e3,1),a=1-Math.pow(1-n,4);g(C*a),N(L*a),n<1&&requestAnimationFrame(e)};requestAnimationFrame(e)},[C,L]);var R="horizontal"===m?d:u,k="horizontal"===m?u:d,y="horizontal"===m?d:u,S="horizontal"===m?u:d,z=function(t,e,i,n,a){var o=a.topLeft,c=a.topRight,l=a.bottomLeft,r=a.bottomRight;return"\n M ".concat(t+o," ").concat(e,"\n L ").concat(t+i-c," ").concat(e,"\n Q ").concat(t+i," ").concat(e," ").concat(t+i," ").concat(e+c,"\n L ").concat(t+i," ").concat(e+n-r,"\n Q ").concat(t+i," ").concat(e+n," ").concat(t+i-r," ").concat(e+n,"\n L ").concat(t+l," ").concat(e+n,"\n Q ").concat(t," ").concat(e+n," ").concat(t," ").concat(e+n-l,"\n L ").concat(t," ").concat(e+o,"\n Q ").concat(t," ").concat(e," ").concat(t+o," ").concat(e,"\n Z\n ").trim().replace(/\s+/g," ")},M={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},F=f?{topLeft:null!==(n=f.topLeft)&&void 0!==n?n:M.topLeft,topRight:null!==(a=f.topRight)&&void 0!==a?a:M.topRight,bottomLeft:null!==(o=f.bottomLeft)&&void 0!==o?o:M.bottomLeft,bottomRight:null!==(c=f.bottomRight)&&void 0!==c?c:M.bottomRight}:M;return t.jsx("div",{className:"histogram-container ".concat("horizontal"===m?"histogram-container--horizontal":""),children:t.jsxs("div",{className:"histogram-content ".concat("horizontal"===m?"histogram-content--horizontal":""),children:[t.jsx("div",{className:"histogram-bar",style:{height:"".concat(k,"px"),width:"".concat(R,"px")},children:t.jsxs("svg",{width:y,height:S,viewBox:"0 0 ".concat(y," ").concat(S),className:"histogram-svg",children:[t.jsx("path",{d:z(0,0,y,S,F),fill:l.color,fillOpacity:l.opacity||1}),"vertical"===m?t.jsx("path",{d:z(0,S-b,y,b,{topLeft:b>=S?F.topLeft:0,topRight:b>=S?F.topRight:0,bottomLeft:F.bottomLeft,bottomRight:F.bottomRight}),fill:r.color}):t.jsx("path",{d:z(0,0,w,S,{topLeft:F.topLeft,topRight:w>=y?F.topRight:0,bottomLeft:F.bottomLeft,bottomRight:w>=y?F.bottomRight:0}),fill:r.color})]})}),p&&t.jsx("div",{className:"histogram-text-container ".concat("horizontal"===m?"histogram-text-container--horizontal":""),children:p})]})})},exports.Input=i,exports.ProductionUnit=function(n){var a=n.onChangeInput,r=n.onChangeSwitch,s=n.defaultValue,d=n.defaultChecked,h=void 0!==d&&d,u=n.value,v=n.checked,m=n.unitName,f=void 0===m?"Production Unit":m,p=n.energyCost,x=void 0===p?0:p,b=n.checkedImage,g=n.uncheckedImage,j=n.readonly,w=void 0!==j&&j,N=n.min,C=void 0===N?{value:10,label:"Pmin"}:N,L=n.max,R=void 0===L?{value:100,label:"Pmax"}:L,k=e.useState(h),y=k[0],S=k[1],z=e.useState(s),M=z[0],F=z[1],q=void 0!==v?v:y,P=void 0!==u?u:M;return t.jsx(l,{children:t.jsxs("div",{className:"production-unit-container",children:[t.jsxs("div",{className:"production-unit-content",children:[t.jsx("div",{className:"image-preview-container",children:q?b:g}),t.jsxs("div",{className:"production-unit-chip",children:[t.jsx("div",{className:"production-unit-chip-name",children:f}),t.jsx(c,{label:"".concat(x," MW"),width:"fit-content",bgColor:"#E1F5FD",textColor:"#005896"})]}),t.jsxs("div",{className:"production-unit-switch-container",children:[t.jsx(i,{label:"PA",type:"number",onChange:function(t){var e=Number(t);void 0===u&&F(e),a&&a(e)},value:void 0!==P?P.toString():void 0,disabled:!q||w,min:{value:C.value,label:C.label},max:{value:R.value,label:R.label}})," "]})]}),t.jsx(o,{checked:q,onChange:function(t){void 0===v&&S(t),r&&r(t)},disabled:w})]})})},exports.Switch=o;
1
+ "use strict";var t=require("react/jsx-runtime"),e=require("react"),i=function(i){var n=i.label,a=i.value,o=void 0===a?"":a,c=i.onChange,l=i.type,r=void 0===l?"text":l,s=i.disabled,d=void 0!==s&&s,h=i.className,u=void 0===h?"":h,v=i.required,m=void 0!==v&&v,f=i.min,p=void 0===f?{value:0,label:"Pmin"}:f,x=i.max,b=void 0===x?{value:100,label:"Pmax"}:x,g=e.useState(o),j=g[0],w=g[1],N=e.useState(!1),C=N[0],L=N[1],R=e.useState(!1),k=R[0],y=R[1],S=e.useRef(null);e.useEffect(function(){w(o)},[o]);var z=["input-container",C?"input-container--focused":"",C||j.length>0?"input-container--floating":"",d?"input-container--disabled":"",k?"input-container--error":"",u].filter(Boolean).join(" ");return t.jsx("div",{className:z,children:t.jsxs("div",{className:"input-constraints",children:[t.jsxs("div",{className:"input-min",children:[p.label,t.jsx("br",{}),p.value]}),t.jsxs("div",{className:"input-field",children:[t.jsx("input",{ref:S,type:r,value:j,onChange:function(t){var e=t.target.value;if("number"===r&&""!==e){var i=parseFloat(e);if(isNaN(i))y(!1);else{var n=i<p.value||i>b.value;y(n)}}else y(!1);w(e),null==c||c(e)},onFocus:function(){L(!0)},onBlur:function(){if(L(!1),"number"===r&&""!==j){var t=parseFloat(j);if(!isNaN(t)){var e=Math.max(p.value,Math.min(b.value,t));if(e!==t){var i=e.toString();w(i),null==c||c(i)}y(!1)}}},disabled:d,required:m,className:"input-element","aria-label":n,min:"number"===r?p.value:void 0,max:"number"===r?b.value:void 0,step:"number"===r?1:void 0}),t.jsxs("label",{className:"input-label",children:[n,m&&t.jsx("span",{className:"input-required",children:"*"})]})]}),t.jsxs("div",{className:"input-max",children:[b.label,t.jsx("br",{})," ",b.value]})]})})},n=function(e){var i=e.isOff;return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M9.56529 2.85352C9.66365 2.57607 9.96837 2.43116 10.246 2.5293C13.4295 3.65507 15.3392 6.91015 14.7684 10.2383C14.1974 13.5667 11.3114 16 7.93443 16C4.55739 16 1.67151 13.5667 1.10045 10.2383C0.5296 6.91011 2.4393 3.65504 5.62291 2.5293C5.9005 2.43115 6.20523 2.57605 6.30357 2.85352C6.40176 3.13124 6.2561 3.43599 5.97838 3.53418C3.28438 4.48672 1.669 7.2423 2.1522 10.0586C2.63557 12.8747 5.07706 14.9336 7.93443 14.9336C10.7918 14.9336 13.2333 12.8747 13.7167 10.0586C14.1999 7.24233 12.5844 4.48676 9.89049 3.53418C9.61276 3.43599 9.4671 3.13124 9.56529 2.85352ZM7.93443 0C8.22892 3.10447e-05 8.46754 0.238727 8.46763 0.533203V7.4668C8.46763 7.76135 8.22898 8.00095 7.93443 8.00098C7.63986 8.00098 7.40123 7.76137 7.40123 7.4668V0.533203C7.40132 0.238707 7.63991 0 7.93443 0Z",fill:i?"#999FA1":"#009CDF"})})},a=function(e){var i=e.isOff;return t.jsx("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("circle",{cx:"16",cy:"16",r:"16",fill:i?"white":"#009cdf"})})},o=function(i){var o=i.checked,c=void 0!==o&&o,l=i.onChange,r=i.disabled,s=void 0!==r&&r,d=i.showIcon,h=void 0===d||d,u=e.useState(c),v=u[0],m=u[1],f=void 0!==c?c:v,p=["switch",f?"switch--checked":"",s?"switch--disabled":""].filter(Boolean).join(" ");return t.jsx("div",{className:"switch-container",children:t.jsxs("div",{className:"switch-wrapper",children:[h&&t.jsx("div",{className:"switch-icon",children:t.jsx(n,{isOff:!f})}),t.jsx("button",{type:"button",role:"switch","aria-checked":f,className:p,onClick:function(){if(!s){var t=!f;void 0===c&&m(t),null==l||l(t)}},disabled:s,children:t.jsx("span",{className:"switch-track",children:t.jsx("span",{className:"switch-thumb",children:t.jsx(a,{isOff:!f})})})})]})})},c=function(e){var i=e.label,n=e.bgColor,a=e.textColor,o=e.width,c=["chip-container","full-width"===(void 0===o?"fit-content":o)?"chip-container--full-width":"chip-container--fit-content"].join(" ");return t.jsx("div",{className:c,style:{backgroundColor:n},children:t.jsx("div",{className:"chip-content",children:t.jsx("p",{className:"chip-label",style:{color:a},children:i})})})},l=function(e){var i=e.bgColor,n=void 0===i?"#fff":i,a=e.children,o=e.height;return t.jsx("div",{className:"production-unit-container-box",style:{backgroundColor:n,height:o},children:a})};exports.Avatar=function(e){var i=e.children;return t.jsx("div",{className:"avatar-container avatar-container--clickable",children:t.jsx("div",{className:"avatar-content",children:i})})},exports.Chip=c,exports.Histogram=function(i){var n,a,o,c,l=i.max,r=i.relative,s=i.barHeight,d=void 0===s?103:s,h=i.barWidth,u=void 0===h?32:h,v=i.orientation,m=void 0===v?"vertical":v,f=i.cornerRadius,p=i.children,x=e.useState(0),b=x[0],g=x[1],j=e.useState(0),w=j[0],N=j[1],C=Math.min(r.value/l.value*100,100)/100*d,L=Math.min(r.value/l.value*100,100)/100*u;e.useEffect(function(){g(0),N(0);var t=Date.now(),e=function(){var i=Date.now()-t,n=Math.min(i/1e3,1),a=1-Math.pow(1-n,4);g(C*a),N(L*a),n<1&&requestAnimationFrame(e)};requestAnimationFrame(e)},[C,L]);var R="horizontal"===m?d:u,k="horizontal"===m?u:d,y="horizontal"===m?d:u,S="horizontal"===m?u:d,z=function(t,e,i,n,a){var o=a.topLeft,c=a.topRight,l=a.bottomLeft,r=a.bottomRight;return"\n M ".concat(t+o," ").concat(e,"\n L ").concat(t+i-c," ").concat(e,"\n Q ").concat(t+i," ").concat(e," ").concat(t+i," ").concat(e+c,"\n L ").concat(t+i," ").concat(e+n-r,"\n Q ").concat(t+i," ").concat(e+n," ").concat(t+i-r," ").concat(e+n,"\n L ").concat(t+l," ").concat(e+n,"\n Q ").concat(t," ").concat(e+n," ").concat(t," ").concat(e+n-l,"\n L ").concat(t," ").concat(e+o,"\n Q ").concat(t," ").concat(e," ").concat(t+o," ").concat(e,"\n Z\n ").trim().replace(/\s+/g," ")},M={topLeft:2,topRight:2,bottomLeft:2,bottomRight:2},F=f?{topLeft:null!==(n=f.topLeft)&&void 0!==n?n:M.topLeft,topRight:null!==(a=f.topRight)&&void 0!==a?a:M.topRight,bottomLeft:null!==(o=f.bottomLeft)&&void 0!==o?o:M.bottomLeft,bottomRight:null!==(c=f.bottomRight)&&void 0!==c?c:M.bottomRight}:M;return t.jsx("div",{className:"histogram-container ".concat("horizontal"===m?"histogram-container--horizontal":""),children:t.jsxs("div",{className:"histogram-content ".concat("horizontal"===m?"histogram-content--horizontal":""),children:[t.jsx("div",{className:"histogram-bar",style:{height:"".concat(k,"px"),width:"".concat(R,"px")},children:t.jsxs("svg",{width:y,height:S,viewBox:"0 0 ".concat(y," ").concat(S),className:"histogram-svg",children:[t.jsx("path",{d:z(0,0,y,S,F),fill:l.color,fillOpacity:l.opacity||1}),"vertical"===m?t.jsx("path",{d:z(0,S-b,y,b,{topLeft:b>=S?F.topLeft:0,topRight:b>=S?F.topRight:0,bottomLeft:F.bottomLeft,bottomRight:F.bottomRight}),fill:r.color}):t.jsx("path",{d:z(0,0,w,S,{topLeft:F.topLeft,topRight:w>=y?F.topRight:0,bottomLeft:F.bottomLeft,bottomRight:w>=y?F.bottomRight:0}),fill:r.color})]})}),p&&t.jsx("div",{className:"histogram-text-container ".concat("horizontal"===m?"histogram-text-container--horizontal":""),children:p})]})})},exports.Input=i,exports.ProductionUnit=function(n){var a=n.onChangeInput,r=n.onChangeSwitch,s=n.defaultValue,d=n.defaultChecked,h=void 0!==d&&d,u=n.value,v=n.checked,m=n.unitName,f=void 0===m?"Production Unit":m,p=n.energyCost,x=void 0===p?0:p,b=n.checkedImage,g=n.uncheckedImage,j=n.readonly,w=void 0!==j&&j,N=n.min,C=void 0===N?{value:10,label:"Pmin"}:N,L=n.max,R=void 0===L?{value:100,label:"Pmax"}:L,k=e.useState(h),y=k[0],S=k[1],z=e.useState(s),M=z[0],F=z[1],P=void 0!==v?v:y,q=void 0!==u?u:M;return t.jsx(l,{children:t.jsxs("div",{className:"production-unit-container",children:[t.jsxs("div",{className:"production-unit-content",children:[t.jsx("div",{className:"image-preview-container",children:P?b:g}),t.jsxs("div",{className:"production-unit-chip",children:[t.jsx("div",{className:"production-unit-chip-name",children:f}),t.jsx(c,{label:"".concat(x," MW"),width:"fit-content",bgColor:"#E1F5FD",textColor:"#005896"})]}),t.jsxs("div",{className:"production-unit-switch-container",children:[t.jsx(i,{label:"PA",type:"number",onChange:function(t){var e=Number(t);void 0===u&&F(e),a&&a(e)},value:void 0!==q?q.toString():void 0,disabled:!P||w,min:{value:C.value,label:C.label},max:{value:R.value,label:R.label}})," "]})]}),t.jsx(o,{checked:P,onChange:function(t){void 0===v&&S(t),r&&r(t)},disabled:w})]})})},exports.ProductionUnitContainer=l,exports.Switch=o;
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rte-utils",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "description": "React components library in TypeScript for agigox projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",