rte-utils 1.2.1 → 1.2.2
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.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useState as a,useEffect as e}from"react";var r=function(r){var n=r.max,o=r.relative,c=r.barHeight,h=void 0===c?103:c,m=r.barWidth,l=void 0===m?32:m,s=r.children,d=a(0),v=d[0],g=d[1],x=Math.min(o.value/n.value*100,100)/100*h;return e(function(){g(0);var t=Date.now(),i=function(){var a=Date.now()-t,e=Math.min(a/1e3,1),r=1-Math.pow(1-e,4);g(x*r),e<1&&requestAnimationFrame(i)};requestAnimationFrame(i)},[x]),t("div",{className:"histogram-container",children:i("div",{className:"histogram-content",children:[t("div",{className:"histogram-bar",style:{height:"".concat(h,"px"),width:"".concat(l,"px")},children:i("svg",{width:l,height:h,viewBox:"0 0 ".concat(l," ").concat(h),className:"histogram-svg",children:[t("rect",{x:"0",y:"0",width:l,height:h,fill:n.color,rx:"2"}),t("rect",{x:"0",y:h-v,width:l,height:v,fill:o.color,rx:"2"})]})}),s&&t("div",{className:"histogram-text-container",children:s})]})})};export{r as Histogram};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n\n // Calculate target height\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight]);\n\n return (\n <div className=\"histogram-container\">\n <div className=\"histogram-content\">\n <div \n className=\"histogram-bar\"\n style={{\n height: `${barHeight}px`,\n width: `${barWidth}px`\n }}\n >\n <svg\n width={barWidth}\n height={barHeight}\n viewBox={`0 0 ${barWidth} ${barHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <rect\n x=\"0\"\n y=\"0\"\n width={barWidth}\n height={barHeight}\n fill={max.color}\n rx=\"2\"\n />\n {/* Foreground bar (relative value) with animation */}\n <rect\n x=\"0\"\n y={barHeight - animatedHeight}\n width={barWidth}\n height={animatedHeight}\n fill={relative.color}\n rx=\"2\"\n />\n </svg>\n </div>\n {children && (\n <div className=\"histogram-text-container\">\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["Histogram","_a","max","relative","_b","barHeight","_c","barWidth","children","_d","useState","animatedHeight","setAnimatedHeight","targetHeight","Math","min","value","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","_jsx","className","_jsxs","style","height","concat","width","viewBox","x","y","fill","color","rx"],"mappings":"kGAsBO,IAAMA,EAAsC,SAACC,OAClDC,EAAGD,EAAAC,IACHC,EAAQF,EAAAE,SACRC,EAAeH,EAAAI,UAAfA,OAAY,IAAAD,EAAA,MACZE,EAAAL,EAAAM,SAAAA,OAAQ,IAAAD,EAAG,GAAEA,EACbE,EAAQP,EAAAO,SAEFC,EAAsCC,EAAS,GAA9CC,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAGlCI,EAAgBC,KAAKC,IAAKZ,EAASa,MAAQd,EAAIc,MAAS,IAAK,KAAO,IAAOX,EA0BjF,OAvBAY,EAAU,WACRL,EAAkB,GAElB,IAAMM,EAAYC,KAAKC,MAGjBC,EAAU,WACd,IAAMC,EAAUH,KAAKC,MAAQF,EACvBK,EAAWT,KAAKC,IAAIO,EAJX,IAI+B,GAGxCE,EAAe,EAAIV,KAAKW,IAAI,EAAIF,EAAU,GAEhDX,EAAkBC,EAAeW,GAE7BD,EAAW,GACbG,sBAAsBL,EAE1B,EAEAK,sBAAsBL,EACxB,EAAG,CAACR,IAGFc,EAAK,MAAA,CAAAC,UAAU,+BACbC,EAAK,MAAA,CAAAD,UAAU,8BACbD,EACE,MAAA,CAAAC,UAAU,gBACVE,MAAO,CACLC,OAAQ,GAAGC,OAAA3B,EAAa,MACxB4B,MAAO,GAAGD,OAAAzB,EAAY,OAGxBC,SAAAqB,EAAA,MAAA,CACEI,MAAO1B,EACPwB,OAAQ1B,EACR6B,QAAS,OAAOF,OAAAzB,cAAYF,GAC5BuB,UAAU,gBAGVpB,SAAA,CAAAmB,EAAA,OAAA,CACEQ,EAAE,IACFC,EAAE,IACFH,MAAO1B,EACPwB,OAAQ1B,EACRgC,KAAMnC,EAAIoC,MACVC,GAAG,MAGLZ,EAAA,OAAA,CACEQ,EAAE,IACFC,EAAG/B,EAAYM,EACfsB,MAAO1B,EACPwB,OAAQpB,EACR0B,KAAMlC,EAASmC,MACfC,GAAG,WAIR/B,GACCmB,SAAKC,UAAU,2BACZpB,SAAAA,QAMb"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("react/jsx-runtime"),e=require("react");exports.Histogram=function(i){var a=i.max,r=i.relative,s=i.barHeight,c=void 0===s?103:s,n=i.barWidth,o=void 0===n?32:n,h=i.children,l=e.useState(0),m=l[0],x=l[1],d=Math.min(r.value/a.value*100,100)/100*c;return e.useEffect(function(){x(0);var t=Date.now(),e=function(){var i=Date.now()-t,a=Math.min(i/1e3,1),r=1-Math.pow(1-a,4);x(d*r),a<1&&requestAnimationFrame(e)};requestAnimationFrame(e)},[d]),t.jsx("div",{className:"histogram-container",children:t.jsxs("div",{className:"histogram-content",children:[t.jsx("div",{className:"histogram-bar",style:{height:"".concat(c,"px"),width:"".concat(o,"px")},children:t.jsxs("svg",{width:o,height:c,viewBox:"0 0 ".concat(o," ").concat(c),className:"histogram-svg",children:[t.jsx("rect",{x:"0",y:"0",width:o,height:c,fill:a.color,rx:"2"}),t.jsx("rect",{x:"0",y:c-m,width:o,height:m,fill:r.color,rx:"2"})]})}),h&&t.jsx("div",{className:"histogram-text-container",children:h})]})})};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/components/Histogram.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport \"./Histogram.css\";\n\ninterface HistogramProps {\n /** Maximum value configuration with value and color */\n max: {\n value: number;\n color: string;\n };\n /** Relative/current value configuration with value and color */\n relative: {\n value: number;\n color: string;\n };\n /** Height of the histogram bar in pixels */\n barHeight?: number;\n /** Width of the histogram bar in pixels */\n barWidth?: number;\n /** Child components (typically text content) */\n children?: React.ReactNode;\n}\n\nexport const Histogram: React.FC<HistogramProps> = ({\n max,\n relative,\n barHeight = 103,\n barWidth = 32,\n children,\n}) => {\n const [animatedHeight, setAnimatedHeight] = useState(0);\n\n // Calculate target height\n const targetHeight = (Math.min((relative.value / max.value) * 100, 100) / 100) * barHeight;\n\n // Simple Chart.js-like animation: always animate from 0 to target\n useEffect(() => {\n setAnimatedHeight(0);\n \n const startTime = Date.now();\n const duration = 1000;\n\n const animate = () => {\n const elapsed = Date.now() - startTime;\n const progress = Math.min(elapsed / duration, 1);\n\n // Chart.js-like easing (easeOutQuart)\n const easeOutQuart = 1 - Math.pow(1 - progress, 4);\n \n setAnimatedHeight(targetHeight * easeOutQuart);\n\n if (progress < 1) {\n requestAnimationFrame(animate);\n }\n };\n\n requestAnimationFrame(animate);\n }, [targetHeight]);\n\n return (\n <div className=\"histogram-container\">\n <div className=\"histogram-content\">\n <div \n className=\"histogram-bar\"\n style={{\n height: `${barHeight}px`,\n width: `${barWidth}px`\n }}\n >\n <svg\n width={barWidth}\n height={barHeight}\n viewBox={`0 0 ${barWidth} ${barHeight}`}\n className=\"histogram-svg\"\n >\n {/* Background bar (max value) */}\n <rect\n x=\"0\"\n y=\"0\"\n width={barWidth}\n height={barHeight}\n fill={max.color}\n rx=\"2\"\n />\n {/* Foreground bar (relative value) with animation */}\n <rect\n x=\"0\"\n y={barHeight - animatedHeight}\n width={barWidth}\n height={animatedHeight}\n fill={relative.color}\n rx=\"2\"\n />\n </svg>\n </div>\n {children && (\n <div className=\"histogram-text-container\">\n {children}\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"names":["_a","max","relative","_b","barHeight","_c","barWidth","children","_d","useState","animatedHeight","setAnimatedHeight","targetHeight","Math","min","value","useEffect","startTime","Date","now","animate","elapsed","progress","easeOutQuart","pow","requestAnimationFrame","_jsx","className","_jsxs","jsxs","jsx","style","height","concat","width","viewBox","x","y","fill","color","rx"],"mappings":"qFAsBmD,S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