@rafal.lemieszewski/tide-ui 0.89.0 → 0.90.0
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/cjs/components/fundamental/button-group.cjs +1 -1
- package/dist/cjs/components/fundamental/chart.cjs +1 -1
- package/dist/cjs/components/fundamental/file-upload.cjs +1 -1
- package/dist/es/components/fundamental/button-group.js +49 -45
- package/dist/es/components/fundamental/chart.js +3 -2
- package/dist/es/components/fundamental/file-upload.js +166 -153
- package/dist/es/style.css +1 -1
- package/dist/types/components/fundamental/button-group.d.ts +3 -3
- package/dist/types/components/fundamental/file-upload.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),g=require("react"),h=require("class-variance-authority"),u=require("../../lib/utils.cjs");function x(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(o,t,e.get?e:{enumerable:!0,get:()=>r[t]})}}return o.default=r,Object.freeze(o)}const a=x(g),l=h.cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-[var(--space-xs)] [&>*]:focus-visible:relative [&>*]:focus-visible:z-10",{variants:{orientation:{horizontal:"[&>*:not(:first-child):not([data-slot=button-group-separator])]:rounded-l-none [&>*:not(:first-child):not([data-slot=button-group-separator])]:border-l-0 [&>*:not(:last-child):not([data-slot=button-group-separator])]:rounded-r-none [&>*:has(+[data-slot=button-group-separator])]:border-r-0",vertical:"flex-col [&>*:not(:first-child):not([data-slot=button-group-separator])]:rounded-t-none [&>*:not(:first-child):not([data-slot=button-group-separator])]:border-t-0 [&>*:not(:last-child):not([data-slot=button-group-separator])]:rounded-b-none [&>*:has(+[data-slot=button-group-separator])]:border-b-0"}},defaultVariants:{orientation:"horizontal"}}),c=a.forwardRef(({className:r,orientation:o,size:t,variant:e,children:i,...v},f)=>{const m=a.Children.map(i,s=>{if(a.isValidElement(s)){const n=s.props;return n?.["data-slot"]==="button-group-separator"?a.cloneElement(s,{"data-variant":n["data-variant"]||e}):n?.["data-slot"]&&n["data-slot"]!=="button"?s:a.cloneElement(s,{size:n.size||t,variant:n.variant||e})}return s});return d.jsx("div",{ref:f,role:"group","data-slot":"button-group","data-orientation":o,className:u.cn(l({orientation:o}),r),...v,children:m})});c.displayName="ButtonGroup";const p=a.forwardRef(({className:r,asChild:o=!1,children:t,...e},i)=>o&&a.isValidElement(t)?a.cloneElement(t,{className:u.cn("bg-[var(--color-background-neutral-subtlest)] shadow-[var(--shadow-100)] flex items-center gap-[var(--space-xs)] rounded-[var(--border-radius-m)] border border-[var(--color-border-primary-subtle)] px-[var(--space-l)] [&]:text-body-sm font-medium [&_svg:not([class*='size-'])]:size-[var(--size-s)] [&_svg]:pointer-events-none",t.props.className,r)}):d.jsx("div",{ref:i,className:u.cn("bg-[var(--color-background-neutral-subtlest)] shadow-[var(--shadow-100)] flex items-center gap-[var(--space-xs)] rounded-[var(--border-radius-m)] border border-[var(--color-border-primary-subtle)] px-[var(--space-l)] [&]:text-body-sm font-medium [&_svg:not([class*='size-'])]:size-[var(--size-s)] [&_svg]:pointer-events-none",r),...e,children:t}));p.displayName="ButtonGroupText";const b=a.forwardRef(({className:r,orientation:o="vertical",...t},e)=>d.jsx("div",{ref:e,role:"separator","aria-orientation":o,"data-slot":"button-group-separator",className:u.cn("self-stretch",o==="vertical"?"border-l":"border-t","border-[var(--color-border-divider)] data-[variant=primary]:border-white data-[variant=destructive]:border-white data-[variant=success]:border-white",r),...t}));b.displayName="ButtonGroupSeparator";exports.ButtonGroup=c;exports.ButtonGroupSeparator=b;exports.ButtonGroupText=p;exports.buttonGroupVariants=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),l=require("recharts"),Oe=require("../../lib/utils.cjs"),q=(i,f=0)=>{const p=i.toFixed(f).split("."),d=p[0].replace(/\B(?=(\d{3})+(?!\d))/g," ");return f>0&&p[1]?`${d}.${p[1]}`:d},Me=(i,f,a,p=20)=>{if(!i.length)return p;let d=0;i.forEach(S=>{f.forEach(n=>{const b=S[n];typeof b=="number"?d=Math.max(d,Math.abs(b)):Array.isArray(b)&&b.forEach(c=>{typeof c=="number"&&(d=Math.max(d,Math.abs(c)))})})});const w=(a?a(d,0):d.toString()).length;return Math.max(p,w*6+12)},K={bar:["var(--color-chart-bar-1)","var(--color-chart-bar-2)","var(--color-chart-bar-3)","var(--color-chart-bar-4)","var(--color-chart-bar-5)","var(--color-chart-bar-6)"],line:["var(--color-chart-line-1)","var(--color-chart-line-2)","var(--color-chart-line-3)","var(--color-chart-line-4)","var(--color-chart-line-5)"],scatter:["var(--color-chart-scatter-1)","var(--color-chart-scatter-2)","var(--color-chart-scatter-3)","var(--color-chart-scatter-4)","var(--color-chart-scatter-5)","var(--color-chart-scatter-6)"],area:["var(--color-chart-area-1)","var(--color-chart-area-2)","var(--color-chart-area-3)","var(--color-chart-area-4)","var(--color-chart-area-5)","var(--color-chart-area-6)"],accessible:["#0066CC","#CC6600","#009966","#CC0066","#6600CC","#CC9900","#006666","#CC0000"]},T=i=>{switch(i){case"dashed":return"5 5";case"dotted":return"2 2";case"solid":default:return}},Be=(i="circle")=>f=>{const{cx:a,cy:p,r:d,fill:C,stroke:w,strokeWidth:S}=f,n=d||4;switch(i){case"triangle":const b=n*1.5,c=n*1.3,y=`M ${a},${p-b} L ${a+c},${p+b/2} L ${a-c},${p+b/2} Z`;return e.jsx("path",{d:y,fill:C,stroke:w,strokeWidth:S||0});case"square":const j=n*1.4;return e.jsx("rect",{x:a-j,y:p-j,width:j*2,height:j*2,fill:C,stroke:w,strokeWidth:S||0});case"circle":default:return e.jsx("circle",{cx:a,cy:p,r:n,fill:C,stroke:w,strokeWidth:S||0})}},Ae=i=>({verticalAlign:"bottom",align:"center"}),se=({active:i,payload:f,label:a,config:p,tooltipMaxWidth:d="max-w-xs",chartType:C,referenceMarkers:w})=>{if(!i||!f||!f.length)return null;const S=w?.filter(n=>n.xValue===a)||[];return e.jsxs("div",{className:`rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${d} z-[9999]`,role:"tooltip","aria-label":"Chart data tooltip",children:[e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:a}),f.map((n,b)=>{const c=p[n.dataKey];let y;if(c?.type==="range-area"&&n.payload){const N=n.payload[n.dataKey];Array.isArray(N)&&N.length===2?y=`${q(N[0])} – ${q(N[1])}`:y=typeof n.value=="number"?q(n.value):n.value}else y=typeof n.value=="number"?q(n.value):n.value;const j=()=>{switch(C){case"line":const N=p[n.dataKey]?.strokeStyle,E=T(N);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:E?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:E==="5 5"?"6px 100%":E==="2 2"?"2px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"composed":switch(p[n.dataKey]?.type){case"line":const I=p[n.dataKey]?.strokeStyle,$=T(I);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:$?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:$==="5 5"?"6px 100%":$==="2 2"?"2px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-2.5 h-2.5 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":case"area":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c?.label||n.dataKey,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:y})]},b)}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-[var(--space-m)]"}),S.map((n,b)=>e.jsxs(x.Fragment,{children:[n.tooltipLabel&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:n.tooltipLabel}),!n.tooltipLabel&&b===0&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:"Reference Markers:"}),n.dataPoints.map((c,y)=>{const j=()=>{switch(c.shape||"circle"){case"triangle":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M 5,2 L 8,8 L 2,8 Z",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"square":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("rect",{x:"2",y:"2",width:"6",height:"6",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"circle":default:return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c.fill||"var(--color-chart-line-1)",border:c.stroke?`${c.strokeWidth||1}px solid ${c.stroke}`:"none"}})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c.label||`Marker ${y+1}`,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:q(c.yValue)})]},`marker-${b}-point-${y}`)})]},`marker-section-${b}`))]})]})};function Ve({type:i,data:f,config:a,className:p,height:d=300,width:C,minWidth:w=240,onDataPointClick:S,onDataPointHover:n,highlightedIndex:b,showGrid:c=!0,showLegend:y=!0,showTooltip:j=!0,colorScheme:N,responsive:E=!0,maintainAspectRatio:Ie=!1,legendHeight:I,margin:$,yAxisWidth:xe,yAxisTickCount:ve,xAxisTickFormatter:$e,yAxisTickFormatter:X,showRightYAxis:le=!1,rightYAxisWidth:he,rightYAxisTickCount:oe,rightYAxisDomain:ne,rightYAxisTickFormatter:ie,title:P,description:ce,showDataTable:ze=!1,tooltipMaxWidth:F="max-w-xs",tooltipAllowEscapeViewBox:_,legendOrder:R,legendPosition:Fe="bottom",referenceMarkers:be,todayMarker:z,yAxisDomain:O,scrollable:D=!1,scrollableWidth:je,...We}){const[ke,Ke]=x.useState(0),k=x.useRef(null),fe=x.useRef(!1),ge=x.useRef(0),Ce=x.useRef(0),Pe=x.useCallback(t=>{k.current&&(fe.current=!0,ge.current=t.pageX-k.current.offsetLeft,Ce.current=k.current.scrollLeft,k.current.style.cursor="grabbing")},[]),De=x.useCallback(t=>{if(!fe.current||!k.current)return;t.preventDefault();const r=t.pageX-k.current.offsetLeft;k.current.scrollLeft=Ce.current-(r-ge.current)},[]),we=x.useCallback(()=>{fe.current=!1,k.current&&(k.current.style.cursor="grab")},[]),g=x.useMemo(()=>{if(N)return K[N];switch(i){case"bar":case"horizontal-bar":return K.bar;case"line":return K.line;case"scatter":return K.scatter;case"composed":return K.bar;default:return K.bar}},[i,N]),h=Object.keys(a).filter(t=>t!=="name"),v=x.useMemo(()=>f.map(t=>{const r={...t};return h.forEach(o=>{if(a[o].type==="range-area"){const s=t[o];Array.isArray(s)&&s.length===2&&(r[o]=s,r[`${o}_min`]=s[0],r[`${o}_max`]=s[1])}}),r}),[f,a,h]),pe=x.useMemo(()=>{if(!z)return null;const t=v.find(r=>r.name===z.xValue);return{xValue:z.xValue,showLine:!0,lineLabel:z.label??"Today",lineStyle:{stroke:"var(--color-border-error-bold)",strokeWidth:2},dataPoints:h.filter(r=>t&&t[r]!=null).map(r=>({yValue:t[r],yAxisId:a[r].yAxisId||"left",fill:"var(--color-background-error-bold)",size:4,pulsing:!0}))}},[z,v,h,a]),me=x.useMemo(()=>[...be??[],...pe?[pe]:[]],[be,pe]),U=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;Ke(r),n?.(t?.activePayload?.[0]?.payload,r)},[n]),Z=x.useCallback(()=>{n?.(null)},[n]),G=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;S?.(t?.activePayload?.[0]?.payload,r)},[S]),J=x.useMemo(()=>ke>=Math.floor(v.length/2),[ke,v.length]),de=()=>{const t={top:8,right:0,left:0,bottom:0};return{top:$?.top??t.top,right:$?.right??t.right,left:$?.left??t.left,bottom:$?.bottom??t.bottom}},Se=x.useMemo(()=>xe||Me(v,h,X,20),[xe,v,h,X]),B=x.useMemo(()=>{if(!D||O)return O;const t=v.flatMap(r=>h.map(o=>{const s=r[o];return Array.isArray(s)||typeof s=="number"?s:0}).flat());return[Math.min(0,...t),Math.max(...t)]},[D,O,v,h]),Q=x.useMemo(()=>D?je??Math.max(v.length*60,600):void 0,[D,je,v.length]),Ne=x.useMemo(()=>{if(!le)return 0;if(he)return he;const t=h.filter(r=>a[r].yAxisId==="right");return t.length===0?0:Me(v,t,ie,20)},[le,he,v,h,a,ie]),Le=x.useMemo(()=>h.some(r=>(a[r].yAxisId||"left")==="left")?"left":"right",[h,a]),Y=I?{...Ae(),wrapperStyle:{position:"absolute",bottom:0,left:0,right:0,height:I,paddingTop:8,zIndex:1}}:Ae(),H={data:v,margin:de()},ee={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:!1,tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},tickFormatter:$e},W={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Se,tickFormatter:X,...ve&&{tickCount:ve},...O&&{domain:O}},re={stroke:"var(--color-border-primary-subtle)",horizontal:!0,vertical:!1},te=({payload:t})=>{if(!t||!t.length)return null;const r=t.filter(u=>a[u.dataKey]),o=R?[...r].sort((u,A)=>{const L=R.indexOf(u.dataKey),M=R.indexOf(A.dataKey);return L===-1?1:M===-1?-1:L-M}):r,m=de().left+5;return e.jsx("div",{style:{paddingLeft:`${m}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:o.map((u,A)=>{const L=()=>{switch(i){case"line":const M=a[u.dataKey]?.strokeStyle,V=T(M);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:V?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:V==="5 5"?"8px 100%":V==="2 2"?"3px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-[6px] h-[6px] rounded-full flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"composed":switch(a[u.dataKey]?.type){case"line":const Re=a[u.dataKey]?.strokeStyle,ye=T(Re);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:ye?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:ye==="5 5"?"8px 100%":ye==="2 2"?"3px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-[8px] h-[8px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[L(),e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.value})]},A)})})})},Te=()=>{const t=R?[...R,...Object.keys(a).filter(s=>!R.includes(s))]:Object.keys(a),o=de().left+5;return e.jsx("div",{style:{paddingLeft:`${o}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:t.map((s,m)=>{const u=a[s];if(!u)return null;const A=u.color??"currentColor",L=T(u.strokeStyle),M=e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:L?`linear-gradient(to right, ${A} 50%, transparent 50%)`:A,backgroundSize:L==="5 5"?"8px 100%":L==="2 2"?"3px 100%":"100% 100%"}})});return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[M,e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.label})]},m)})})})},ue=(t="full")=>{switch(i){case"bar":return e.jsxs(l.BarChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r)})]});case"horizontal-bar":return e.jsxs(l.BarChart,{...H,layout:"vertical",onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re,horizontal:!1,vertical:!0}),e.jsx(l.XAxis,{type:"number",...ee}),e.jsx(l.YAxis,{type:"category",dataKey:"name",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:40},r)})]});case"line":return e.jsxs(l.LineChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i,referenceMarkers:me}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r)}),t!=="yaxis-only"&&me.map((r,o)=>r.showLine!==!1?e.jsx(l.ReferenceLine,{x:r.xValue,yAxisId:"left",stroke:r.lineStyle?.stroke||"#000000",strokeWidth:r.lineStyle?.strokeWidth||2,strokeDasharray:r.lineStyle?.strokeDasharray,label:r.lineLabel?s=>{const{viewBox:m}=s;return m?e.jsx("text",{x:m.x+6,y:m.y+8,dominantBaseline:"middle",fill:"var(--color-text-error-bold)",fontSize:10,fontFamily:"inherit",fontWeight:700,children:r.lineLabel}):null}:void 0},`marker-line-${o}`):null),t!=="yaxis-only"&&me.map((r,o)=>e.jsx(x.Fragment,{children:r.dataPoints?.map((s,m)=>e.jsx(l.ReferenceDot,{x:r.xValue,y:s.yValue,yAxisId:s.yAxisId||"left",r:s.size||4,fill:s.fill||"var(--color-chart-line-1)",stroke:s.stroke||"transparent",strokeWidth:s.strokeWidth||0,shape:s.pulsing?u=>{const{cx:A,cy:L}=u,M=s.size||4,V=s.fill||"var(--color-background-error-bold)";return e.jsxs("g",{children:[e.jsxs("circle",{cx:A,cy:L,r:M+1,fill:V,opacity:.3,children:[e.jsx("animate",{attributeName:"r",from:String(M+1),to:String(M+8),dur:"1.5s",repeatCount:"indefinite"}),e.jsx("animate",{attributeName:"opacity",from:"0.35",to:"0",dur:"1.5s",repeatCount:"indefinite"})]}),e.jsx("circle",{cx:A,cy:L,r:M,fill:V})]})}:Be(s.shape||"circle")},`marker-${o}-point-${m}`))},`marker-dots-${o}`))]});case"scatter":return e.jsxs(l.ScatterChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"x",type:"number",...ee}),e.jsx(l.YAxis,{dataKey:"y",type:"number",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.filter(r=>r!=="x"&&r!=="y"&&r!=="name").map((r,o)=>{const s=a[r]?.color||g[o%g.length];return e.jsx(l.Scatter,{name:a[r]?.label||r,data:f.map(m=>({x:m.x,y:m.y,[r]:m[r]})),fill:s,className:"cursor-pointer transition-colors",isAnimationActive:!1},r)})]});case"composed":return e.jsxs(l.ComposedChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="bar"?e.jsx(l.Bar,{dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length],m=a[r].type||"bar";return m==="area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??s,strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):m==="range-area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??"none",strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="line"?e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null})]});default:return e.jsx("div",{children:"Unsupported chart type"})}},Ee=()=>ze?e.jsx("div",{className:"sr-only",children:e.jsxs("table",{role:"table","aria-label":P?`Data for ${P}`:"Chart data",children:[e.jsxs("caption",{className:"sr-only",children:[P&&`${P}. `,ce||`${i} chart showing ${h.length} data series across ${f.length} categories.`]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Category"}),h.map(t=>e.jsx("th",{scope:"col",children:a[t]?.label||t},t))]})}),e.jsx("tbody",{children:f.map((t,r)=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:t.name||`Item ${r+1}`}),h.map(o=>e.jsx("td",{children:X?X(t[o],r):t[o]},o))]},r))})]})}):null,ae=x.useRef(null);return x.useEffect(()=>{const t=ae.current;if(!t)return;const r=setTimeout(()=>{t.querySelectorAll(".recharts-cartesian-axis-tick").forEach(s=>{const m=s.querySelector("text"),u=s.querySelector(".recharts-cartesian-axis-tick-line");m?.textContent?.trim()==="0"&&u&&u.setAttribute("stroke-width","2")})},100);return()=>clearTimeout(r)},[f,i]),x.useEffect(()=>{if(!D||!z||!k.current||!Q)return;const t=v.findIndex(o=>o.name===z.xValue);if(t<0)return;const r=setTimeout(()=>{if(!k.current)return;const o=k.current.offsetWidth,s=t/(v.length-1)*Q;k.current.scrollLeft=Math.max(0,s-o/2)},50);return()=>clearTimeout(r)},[D,z,Q,v]),e.jsxs("div",{ref:ae,className:Oe.cn("w-full",p),style:{minWidth:E?0:w,...typeof d=="string"?{height:d}:{}},role:"img","aria-label":P||`${i} chart`,"aria-describedby":ce?`${ae.current?.id||"chart"}-desc`:void 0,...We,children:[P&&e.jsx("h3",{className:"sr-only",id:`${ae.current?.id||"chart"}-title`,children:P}),ce&&e.jsx("p",{className:"sr-only",id:`${ae.current?.id||"chart"}-desc`,children:ce}),(()=>{const t=typeof d=="string"?d:I?d-I:d;if(D&&i!=="horizontal-bar"&&i!=="scatter"){const o=Se+(de().left??0);return e.jsxs("div",{style:{height:y&&I?d:t},children:[e.jsxs("div",{className:"flex w-full",style:{height:t},children:[e.jsx("div",{style:{width:o,flexShrink:0,overflow:"hidden"},children:e.jsx(l.ResponsiveContainer,{width:o,height:t,children:ue("yaxis-only")||e.jsx("div",{children:"Chart error"})})}),e.jsx("div",{ref:k,className:"flex-1 overflow-x-scroll overflow-y-hidden scrollbar-hide select-none",style:{cursor:"grab"},onMouseDown:Pe,onMouseMove:De,onMouseUp:we,onMouseLeave:we,children:e.jsx("div",{style:{width:Q,height:t},children:e.jsx(l.ResponsiveContainer,{width:Q,height:t,children:ue("data-only")||e.jsx("div",{children:"Chart error"})})})})]}),y&&Te()]})}const r=E?e.jsx(l.ResponsiveContainer,{width:C||"100%",height:t,children:ue()||e.jsx("div",{children:"Chart error"})}):e.jsx("div",{style:{width:C||"100%",height:t,minWidth:w},children:ue()||e.jsx("div",{children:"Chart error"})});return I?e.jsx("div",{style:{width:C||"100%"},children:r}):r})(),e.jsx(Ee,{})]})}const qe=(i,f="bar")=>{const a=K[f];return Array.from({length:i},(p,d)=>a[d%a.length])},Xe=(i,f,a)=>Array.isArray(i)?i.reduce((d,C,w)=>(d[C]={label:f?.[w]||C,color:a?.[w]},d),{}):i;exports.Chart=Ve;exports.chartColorSchemes=K;exports.createChartConfig=Xe;exports.formatNumber=q;exports.generateChartColors=qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),l=require("recharts"),Oe=require("../../lib/utils.cjs"),q=(i,f=0)=>{const p=i.toFixed(f).split("."),d=p[0].replace(/\B(?=(\d{3})+(?!\d))/g," ");return f>0&&p[1]?`${d}.${p[1]}`:d},Me=(i,f,a,p=20)=>{if(!i.length)return p;let d=0;i.forEach(S=>{f.forEach(n=>{const b=S[n];typeof b=="number"?d=Math.max(d,Math.abs(b)):Array.isArray(b)&&b.forEach(c=>{typeof c=="number"&&(d=Math.max(d,Math.abs(c)))})})});const w=(a?a(d,0):d.toString()).length;return Math.max(p,w*6+12)},K={bar:["var(--color-chart-bar-1)","var(--color-chart-bar-2)","var(--color-chart-bar-3)","var(--color-chart-bar-4)","var(--color-chart-bar-5)","var(--color-chart-bar-6)"],line:["var(--color-chart-line-1)","var(--color-chart-line-2)","var(--color-chart-line-3)","var(--color-chart-line-4)","var(--color-chart-line-5)"],scatter:["var(--color-chart-scatter-1)","var(--color-chart-scatter-2)","var(--color-chart-scatter-3)","var(--color-chart-scatter-4)","var(--color-chart-scatter-5)","var(--color-chart-scatter-6)"],area:["var(--color-chart-area-1)","var(--color-chart-area-2)","var(--color-chart-area-3)","var(--color-chart-area-4)","var(--color-chart-area-5)","var(--color-chart-area-6)"],accessible:["#0066CC","#CC6600","#009966","#CC0066","#6600CC","#CC9900","#006666","#CC0000"]},T=i=>{switch(i){case"dashed":return"5 5";case"dotted":return"2 2";case"solid":default:return}},Be=(i="circle")=>f=>{const{cx:a,cy:p,r:d,fill:C,stroke:w,strokeWidth:S}=f,n=d||4;switch(i){case"triangle":const b=n*1.5,c=n*1.3,y=`M ${a},${p-b} L ${a+c},${p+b/2} L ${a-c},${p+b/2} Z`;return e.jsx("path",{d:y,fill:C,stroke:w,strokeWidth:S||0});case"square":const j=n*1.4;return e.jsx("rect",{x:a-j,y:p-j,width:j*2,height:j*2,fill:C,stroke:w,strokeWidth:S||0});case"circle":default:return e.jsx("circle",{cx:a,cy:p,r:n,fill:C,stroke:w,strokeWidth:S||0})}},Ae=i=>({verticalAlign:"bottom",align:"center"}),se=({active:i,payload:f,label:a,config:p,tooltipMaxWidth:d="max-w-xs",chartType:C,referenceMarkers:w})=>{if(!i||!f||!f.length)return null;const S=w?.filter(n=>n.xValue===a)||[];return e.jsxs("div",{className:`rounded-[var(--border-radius-s)] border border-[var(--color-border-primary-medium)] bg-[var(--color-surface-primary)] p-[var(--space-m)] shadow-[var(--shadow-300)] min-w-[120px] ${d} z-[9999]`,role:"tooltip","aria-label":"Chart data tooltip",children:[e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:a}),f.map((n,b)=>{const c=p[n.dataKey];let y;if(c?.type==="range-area"&&n.payload){const N=n.payload[n.dataKey];Array.isArray(N)&&N.length===2?y=`${q(N[0])} – ${q(N[1])}`:y=typeof n.value=="number"?q(n.value):n.value}else y=typeof n.value=="number"?q(n.value):n.value;const j=()=>{switch(C){case"line":const N=p[n.dataKey]?.strokeStyle,E=T(N);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:E?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:E==="5 5"?"6px 100%":E==="2 2"?"2px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"composed":switch(p[n.dataKey]?.type){case"line":const I=p[n.dataKey]?.strokeStyle,$=T(I);return e.jsx("div",{className:"w-3 h-0.5 flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:$?`linear-gradient(to right, ${n.color} 50%, transparent 50%)`:n.color,backgroundSize:$==="5 5"?"6px 100%":$==="2 2"?"2px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-2.5 h-2.5 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":case"area":default:return e.jsx("div",{className:"w-2 h-2 flex-shrink-0",style:{backgroundColor:n.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c?.label||n.dataKey,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:y})]},b)}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-[var(--space-m)]"}),S.map((n,b)=>e.jsxs(x.Fragment,{children:[n.tooltipLabel&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:n.tooltipLabel}),!n.tooltipLabel&&b===0&&e.jsx("p",{className:"text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]",children:"Reference Markers:"}),n.dataPoints?.map((c,y)=>{const j=()=>{switch(c.shape||"circle"){case"triangle":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M 5,2 L 8,8 L 2,8 Z",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"square":return e.jsx("svg",{width:8,height:8,className:"flex-shrink-0",viewBox:"0 0 10 10",children:e.jsx("rect",{x:"2",y:"2",width:"6",height:"6",fill:c.fill||"var(--color-chart-line-1)",stroke:c.stroke||"transparent",strokeWidth:c.strokeWidth||0})});case"circle":default:return e.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c.fill||"var(--color-chart-line-1)",border:c.stroke?`${c.strokeWidth||1}px solid ${c.stroke}`:"none"}})}};return e.jsxs("div",{className:"flex items-center gap-[var(--space-xs)]",children:[j(),e.jsxs("span",{className:"text-body-sm text-[var(--color-text-primary)] min-w-0 break-words",children:[c.label||`Marker ${y+1}`,":"]}),e.jsx("span",{className:"text-body-medium-sm text-[var(--color-text-primary)] ml-auto pl-[16px]",children:q(c.yValue)})]},`marker-${b}-point-${y}`)})]},`marker-section-${b}`))]})]})};function Ve({type:i,data:f,config:a,className:p,height:d=300,width:C,minWidth:w=240,onDataPointClick:S,onDataPointHover:n,highlightedIndex:b,showGrid:c=!0,showLegend:y=!0,showTooltip:j=!0,colorScheme:N,responsive:E=!0,maintainAspectRatio:Ie=!1,legendHeight:I,margin:$,yAxisWidth:xe,yAxisTickCount:ve,xAxisTickFormatter:$e,yAxisTickFormatter:X,showRightYAxis:le=!1,rightYAxisWidth:he,rightYAxisTickCount:oe,rightYAxisDomain:ne,rightYAxisTickFormatter:ie,title:P,description:ce,showDataTable:ze=!1,tooltipMaxWidth:F="max-w-xs",tooltipAllowEscapeViewBox:_,legendOrder:R,legendPosition:Fe="bottom",referenceMarkers:be,todayMarker:z,yAxisDomain:O,scrollable:D=!1,scrollableWidth:je,...We}){const[ke,Ke]=x.useState(0),k=x.useRef(null),fe=x.useRef(!1),ge=x.useRef(0),Ce=x.useRef(0),Pe=x.useCallback(t=>{k.current&&(fe.current=!0,ge.current=t.pageX-k.current.offsetLeft,Ce.current=k.current.scrollLeft,k.current.style.cursor="grabbing")},[]),De=x.useCallback(t=>{if(!fe.current||!k.current)return;t.preventDefault();const r=t.pageX-k.current.offsetLeft;k.current.scrollLeft=Ce.current-(r-ge.current)},[]),we=x.useCallback(()=>{fe.current=!1,k.current&&(k.current.style.cursor="grab")},[]),g=x.useMemo(()=>{if(N)return K[N];switch(i){case"bar":case"horizontal-bar":return K.bar;case"line":return K.line;case"scatter":return K.scatter;case"composed":return K.bar;default:return K.bar}},[i,N]),h=Object.keys(a).filter(t=>t!=="name"),v=x.useMemo(()=>f.map(t=>{const r={...t};return h.forEach(o=>{if(a[o].type==="range-area"){const s=t[o];Array.isArray(s)&&s.length===2&&(r[o]=s,r[`${o}_min`]=s[0],r[`${o}_max`]=s[1])}}),r}),[f,a,h]),pe=x.useMemo(()=>{if(!z)return null;const t=v.find(r=>r.name===z.xValue);return{xValue:z.xValue,showLine:!0,lineLabel:z.label??"Today",lineStyle:{stroke:"var(--color-border-error-bold)",strokeWidth:2},dataPoints:h.filter(r=>t&&t[r]!=null).map(r=>({yValue:t[r],yAxisId:a[r].yAxisId||"left",fill:"var(--color-background-error-bold)",size:4,pulsing:!0}))}},[z,v,h,a]),me=x.useMemo(()=>[...be??[],...pe?[pe]:[]],[be,pe]),U=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;Ke(r),n?.(t?.activePayload?.[0]?.payload,r)},[n]),Z=x.useCallback(()=>{n?.(null)},[n]),G=x.useCallback(t=>{const r=t?.activeTooltipIndex??0;S?.(t?.activePayload?.[0]?.payload,r)},[S]),J=x.useMemo(()=>ke>=Math.floor(v.length/2),[ke,v.length]),de=()=>{const t={top:8,right:0,left:0,bottom:0};return{top:$?.top??t.top,right:$?.right??t.right,left:$?.left??t.left,bottom:$?.bottom??t.bottom}},Se=x.useMemo(()=>xe||Me(v,h,X,20),[xe,v,h,X]),B=x.useMemo(()=>{if(!D||O)return O;const t=v.flatMap(r=>h.map(o=>{const s=r[o];return Array.isArray(s)||typeof s=="number"?s:0}).flat());return[Math.min(0,...t),Math.max(...t)]},[D,O,v,h]),Q=x.useMemo(()=>D?je??Math.max(v.length*60,600):void 0,[D,je,v.length]),Ne=x.useMemo(()=>{if(!le)return 0;if(he)return he;const t=h.filter(r=>a[r].yAxisId==="right");return t.length===0?0:Me(v,t,ie,20)},[le,he,v,h,a,ie]),Le=x.useMemo(()=>h.some(r=>(a[r].yAxisId||"left")==="left")?"left":"right",[h,a]),Y=I?{...Ae(),wrapperStyle:{position:"absolute",bottom:0,left:0,right:0,height:I,paddingTop:8,zIndex:1}}:Ae(),H={data:v,margin:de(),tabIndex:-1},ee={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:!1,tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},tickFormatter:$e},W={axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Se,tickFormatter:X,...ve&&{tickCount:ve},...O&&{domain:O}},re={stroke:"var(--color-border-primary-subtle)",horizontal:!0,vertical:!1},te=({payload:t})=>{if(!t||!t.length)return null;const r=t.filter(u=>a[u.dataKey]),o=R?[...r].sort((u,A)=>{const L=R.indexOf(u.dataKey),M=R.indexOf(A.dataKey);return L===-1?1:M===-1?-1:L-M}):r,m=de().left+5;return e.jsx("div",{style:{paddingLeft:`${m}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:o.map((u,A)=>{const L=()=>{switch(i){case"line":const M=a[u.dataKey]?.strokeStyle,V=T(M);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:V?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:V==="5 5"?"8px 100%":V==="2 2"?"3px 100%":"100% 100%"}})});case"scatter":return e.jsx("div",{className:"w-[6px] h-[6px] rounded-full flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"composed":switch(a[u.dataKey]?.type){case"line":const Re=a[u.dataKey]?.strokeStyle,ye=T(Re);return e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:ye?`linear-gradient(to right, ${u.color} 50%, transparent 50%)`:u.color,backgroundSize:ye==="5 5"?"8px 100%":ye==="2 2"?"3px 100%":"100% 100%"}})});case"area":case"range-area":return e.jsx("div",{className:"w-[8px] h-[8px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"});case"bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}case"bar":case"horizontal-bar":default:return e.jsx("div",{className:"w-[6px] h-[6px] flex-shrink-0",style:{backgroundColor:u.color},"aria-hidden":"true"})}};return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[L(),e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.value})]},A)})})})},Te=()=>{const t=R?[...R,...Object.keys(a).filter(s=>!R.includes(s))]:Object.keys(a),o=de().left+5;return e.jsx("div",{style:{paddingLeft:`${o}px`,paddingRight:"16px"},children:e.jsx("div",{className:"flex flex-wrap justify-start items-start gap-x-[var(--space-m)] gap-y-[var(--space-s)]",children:t.map((s,m)=>{const u=a[s];if(!u)return null;const A=u.color??"currentColor",L=T(u.strokeStyle),M=e.jsx("div",{className:"w-[12px] h-[2px] flex-shrink-0 relative","aria-hidden":"true",children:e.jsx("div",{className:"w-full h-full",style:{background:L?`linear-gradient(to right, ${A} 50%, transparent 50%)`:A,backgroundSize:L==="5 5"?"8px 100%":L==="2 2"?"3px 100%":"100% 100%"}})});return e.jsxs("div",{className:"flex items-center justify-center gap-[var(--space-xs)]",children:[M,e.jsx("span",{className:"[&]:text-body-medium-xsm [&]:text-[var(--color-text-secondary)] leading-none whitespace-nowrap",children:u.label})]},m)})})})},ue=(t="full")=>{switch(i){case"bar":return e.jsxs(l.BarChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r)})]});case"horizontal-bar":return e.jsxs(l.BarChart,{...H,layout:"vertical",onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re,horizontal:!1,vertical:!0}),e.jsx(l.XAxis,{type:"number",...ee}),e.jsx(l.YAxis,{type:"category",dataKey:"name",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Bar,{dataKey:r,name:a[r].label,fill:s,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:40},r)})]});case"line":return e.jsxs(l.LineChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i,referenceMarkers:me}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r)}),t!=="yaxis-only"&&me.map((r,o)=>r.showLine!==!1?e.jsx(l.ReferenceLine,{x:r.xValue,yAxisId:"left",stroke:r.lineStyle?.stroke||"#000000",strokeWidth:r.lineStyle?.strokeWidth||2,strokeDasharray:r.lineStyle?.strokeDasharray,label:r.lineLabel?s=>{const{viewBox:m}=s;return m?e.jsx("text",{x:m.x+6,y:m.y+8,dominantBaseline:"middle",fill:"var(--color-text-error-bold)",fontSize:10,fontFamily:"inherit",fontWeight:700,children:r.lineLabel}):null}:void 0},`marker-line-${o}`):null),t!=="yaxis-only"&&me.map((r,o)=>e.jsx(x.Fragment,{children:r.dataPoints?.map((s,m)=>e.jsx(l.ReferenceDot,{x:r.xValue,y:s.yValue,yAxisId:s.yAxisId||"left",r:s.size||4,fill:s.fill||"var(--color-chart-line-1)",stroke:s.stroke||"transparent",strokeWidth:s.strokeWidth||0,shape:s.pulsing?u=>{const{cx:A,cy:L}=u,M=s.size||4,V=s.fill||"var(--color-background-error-bold)";return e.jsxs("g",{children:[e.jsxs("circle",{cx:A,cy:L,r:M+1,fill:V,opacity:.3,children:[e.jsx("animate",{attributeName:"r",from:String(M+1),to:String(M+8),dur:"1.5s",repeatCount:"indefinite"}),e.jsx("animate",{attributeName:"opacity",from:"0.35",to:"0",dur:"1.5s",repeatCount:"indefinite"})]}),e.jsx("circle",{cx:A,cy:L,r:M,fill:V})]})}:Be(s.shape||"circle")},`marker-${o}-point-${m}`))},`marker-dots-${o}`))]});case"scatter":return e.jsxs(l.ScatterChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[c&&e.jsx(l.CartesianGrid,{...re}),e.jsx(l.XAxis,{dataKey:"x",type:"number",...ee}),e.jsx(l.YAxis,{dataKey:"y",type:"number",...W}),j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.filter(r=>r!=="x"&&r!=="y"&&r!=="name").map((r,o)=>{const s=a[r]?.color||g[o%g.length];return e.jsx(l.Scatter,{name:a[r]?.label||r,data:f.map(m=>({x:m.x,y:m.y,[r]:m[r]})),fill:s,className:"cursor-pointer transition-colors",isAnimationActive:!1},r)})]});case"composed":return e.jsxs(l.ComposedChart,{...H,onMouseMove:U,onMouseLeave:Z,onClick:G,children:[t!=="yaxis-only"&&c&&e.jsx(l.CartesianGrid,{...re,yAxisId:Le}),e.jsx(l.XAxis,{dataKey:"name",...ee,...t==="yaxis-only"&&{axisLine:!1,tickLine:!1,tick:!1}}),e.jsx(l.YAxis,{yAxisId:"left",...W,hide:t==="data-only",width:t==="data-only"?0:W.width,...t!=="full"&&B?{domain:B}:{}}),t!=="yaxis-only"&&le&&e.jsx(l.YAxis,{yAxisId:"right",orientation:"right",axisLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:2},tickLine:{stroke:"var(--color-border-primary-subtle)",strokeWidth:1},tick:{fontSize:10,fill:"var(--color-text-tertiary)",fontFamily:"Inter, sans-serif"},width:Ne,tickFormatter:ie,...oe&&{tickCount:oe},...ne&&{domain:ne}}),t!=="yaxis-only"&&j&&e.jsx(l.Tooltip,{content:r=>e.jsx(se,{...r,config:a,tooltipMaxWidth:F,chartType:i}),cursor:{stroke:"var(--color-border-primary)",strokeWidth:1,fill:"var(--color-background-neutral-default)",fillOpacity:1},position:{x:void 0,y:void 0},offset:10,animationDuration:0,allowEscapeViewBox:_,reverseDirection:{x:J},wrapperStyle:{zIndex:100}}),t==="full"&&y&&e.jsx(l.Legend,{content:e.jsx(te,{}),...Y}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="bar"?e.jsx(l.Bar,{dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",fill:s,fillOpacity:t==="yaxis-only"?0:1,radius:[0,0,0,0],className:"cursor-pointer transition-colors",isAnimationActive:!1,maxBarSize:60},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length],m=a[r].type||"bar";return m==="area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??s,strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):m==="range-area"?e.jsx(l.Area,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:a[r].stroke??"none",strokeOpacity:t==="yaxis-only"?0:1,fill:a[r].fill??s,fillOpacity:t==="yaxis-only"?0:.3,className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null}),h.map((r,o)=>{const s=a[r].color||g[o%g.length];return(a[r].type||"bar")==="line"?e.jsx(l.Line,{type:"linear",dataKey:r,name:a[r].label,yAxisId:a[r].yAxisId||"left",stroke:s,strokeWidth:2,strokeOpacity:t==="yaxis-only"?0:1,strokeDasharray:T(a[r].strokeStyle),dot:t==="yaxis-only"?!1:a[r].showDots===!0?{fill:s,strokeWidth:0,r:3}:!1,activeDot:t==="yaxis-only"?!1:{r:5,fill:s},className:"cursor-pointer transition-colors",isAnimationActive:!1},r):null})]});default:return e.jsx("div",{children:"Unsupported chart type"})}},Ee=()=>ze?e.jsx("div",{className:"sr-only",children:e.jsxs("table",{role:"table","aria-label":P?`Data for ${P}`:"Chart data",children:[e.jsxs("caption",{className:"sr-only",children:[P&&`${P}. `,ce||`${i} chart showing ${h.length} data series across ${f.length} categories.`]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Category"}),h.map(t=>e.jsx("th",{scope:"col",children:a[t]?.label||t},t))]})}),e.jsx("tbody",{children:f.map((t,r)=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:t.name||`Item ${r+1}`}),h.map(o=>e.jsx("td",{children:X?X(t[o],r):t[o]},o))]},r))})]})}):null,ae=x.useRef(null);return x.useEffect(()=>{const t=ae.current;if(!t)return;const r=setTimeout(()=>{t.querySelectorAll(".recharts-cartesian-axis-tick").forEach(s=>{const m=s.querySelector("text"),u=s.querySelector(".recharts-cartesian-axis-tick-line");m?.textContent?.trim()==="0"&&u&&u.setAttribute("stroke-width","2")})},100);return()=>clearTimeout(r)},[f,i]),x.useEffect(()=>{if(!D||!z||!k.current||!Q)return;const t=v.findIndex(o=>o.name===z.xValue);if(t<0)return;const r=setTimeout(()=>{if(!k.current)return;const o=k.current.offsetWidth,s=t/(v.length-1)*Q;k.current.scrollLeft=Math.max(0,s-o/2)},50);return()=>clearTimeout(r)},[D,z,Q,v]),e.jsxs("div",{ref:ae,className:Oe.cn("w-full",p),style:{minWidth:E?0:w,...typeof d=="string"?{height:d}:{}},role:"img","aria-label":P||`${i} chart`,"aria-describedby":ce?`${ae.current?.id||"chart"}-desc`:void 0,...We,children:[P&&e.jsx("h3",{className:"sr-only",id:`${ae.current?.id||"chart"}-title`,children:P}),ce&&e.jsx("p",{className:"sr-only",id:`${ae.current?.id||"chart"}-desc`,children:ce}),(()=>{const t=typeof d=="string"?d:I?d-I:d;if(D&&i!=="horizontal-bar"&&i!=="scatter"){const o=Se+(de().left??0);return e.jsxs("div",{style:{height:y&&I?d:t},children:[e.jsxs("div",{className:"flex w-full",style:{height:t},children:[e.jsx("div",{style:{width:o,flexShrink:0,overflow:"hidden"},children:e.jsx(l.ResponsiveContainer,{width:o,height:t,children:ue("yaxis-only")||e.jsx("div",{children:"Chart error"})})}),e.jsx("div",{ref:k,className:"flex-1 overflow-x-scroll overflow-y-hidden scrollbar-hide select-none",style:{cursor:"grab"},onMouseDown:Pe,onMouseMove:De,onMouseUp:we,onMouseLeave:we,children:e.jsx("div",{style:{width:Q,height:t},children:e.jsx(l.ResponsiveContainer,{width:Q,height:t,children:ue("data-only")||e.jsx("div",{children:"Chart error"})})})})]}),y&&Te()]})}const r=E?e.jsx(l.ResponsiveContainer,{width:C||"100%",height:t,children:ue()||e.jsx("div",{children:"Chart error"})}):e.jsx("div",{style:{width:C||"100%",height:t,minWidth:w},children:ue()||e.jsx("div",{children:"Chart error"})});return I?e.jsx("div",{style:{width:C||"100%"},children:r}):r})(),e.jsx(Ee,{})]})}const qe=(i,f="bar")=>{const a=K[f];return Array.from({length:i},(p,d)=>a[d%a.length])},Xe=(i,f,a)=>Array.isArray(i)?i.reduce((d,C,w)=>(d[C]={label:f?.[w]||C,color:a?.[w]},d),{}):i;exports.Chart=Ve;exports.chartColorSchemes=K;exports.createChartConfig=Xe;exports.formatNumber=q;exports.generateChartColors=qe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),Q=require("react"),v=require("../../lib/utils.cjs"),Y=require("class-variance-authority"),T=require("./button.cjs"),Z=require("./progress.cjs"),V=require("./icon.cjs"),ee=require("lucide-react"),te=require("./badge.cjs");function re(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const c=re(Q),W=c.createContext(null),U=()=>{const t=c.useContext(W);if(!t)throw new Error("useFileUpload must be used within a FileUpload component");return t};function oe(t){return t instanceof File}const D=c.forwardRef(({className:t,files:e,onFilesChange:r,maxFiles:o=10,maxSize:s=10*1024*1024,accept:l,disabled:p=!1,multiple:f=!0,onUpload:d,onDelete:u,uploadMode:h="auto",children:b,...w},j)=>{const F=c.useMemo(()=>({files:e,onFilesChange:r,maxFiles:o,maxSize:s,accept:l,disabled:p,multiple:f,onUpload:d,onDelete:u,uploadMode:h}),[e,r,o,s,l,p,f,d,u,h]);return a.jsx(W.Provider,{value:F,children:a.jsx("div",{ref:j,className:v.cn("space-y-4",t),...w,children:b})})});D.displayName="FileUploadRoot";const ae=Y.cva("relative flex flex-col items-center justify-center rounded-[var(--border-radius-l)] border-2 border-dashed p-6 text-center transition-colors duration-200",{variants:{isDragActive:{true:"border-[var(--color-border-brand-bold)] bg-[var(--color-background-brand-subtle)]",false:"border-[var(--color-interaction-border-input)] hover:border-[var(--color-border-brand-bold)]"},disabled:{true:"cursor-not-allowed opacity-50",false:"cursor-pointer"}},defaultVariants:{isDragActive:!1,disabled:!1}}),I=c.forwardRef(({className:t,children:e,...r},o)=>{const{files:s,onFilesChange:l,maxFiles:p,maxSize:f,accept:d,disabled:u,multiple:h,onUpload:b,uploadMode:w}=U(),[j,F]=c.useState(!1),A=c.useRef(null),$=n=>{if(f&&n.size>f)return`File size must be less than ${L(f)}`;if(d&&d.length>0){const i=n.type,y=`.${n.name.split(".").pop()?.toLowerCase()}`;if(!d.some(m=>{if(m.startsWith("."))return m.toLowerCase()===y;if(m.includes("*")){const x=m.split("/")[0];return i.startsWith(x)}return i===m}))return`File type not supported. Accepted types: ${d.join(", ")}`}return null},B=async n=>{const i=[],y=s.length;if(Array.from(n).forEach((g,m)=>{if(p&&y+i.length>=p)return;const x=$(g),O={id:`${Date.now()}-${m}`,file:g,status:x?"error":"pending",error:x||void 0,progress:0};if(g.type.startsWith("image/")){const S=new FileReader;S.onload=H=>{const J=s.map(N=>N.id===O.id?{...N,preview:H.target?.result}:N);l(J)},S.readAsDataURL(g)}i.push(O)}),i.length>0&&(l([...s,...i]),w==="auto"&&b)){const g=i.filter(m=>m.status!=="error");g.length>0&&await b(g)}},E=n=>{n.preventDefault(),n.stopPropagation(),u||F(!0)},_=n=>{n.preventDefault(),n.stopPropagation(),F(!1)},G=n=>{if(n.preventDefault(),n.stopPropagation(),F(!1),u)return;const i=n.dataTransfer.files;i.length>0&&B(i)},K=()=>{u||A.current?.click()},X=n=>{const i=n.target.files;i&&B(i),n.target.value=""};return a.jsxs("div",{ref:o,className:v.cn(ae({isDragActive:j,disabled:u}),t),onDragOver:E,onDragLeave:_,onDrop:G,onClick:K,role:"button",tabIndex:u?-1:0,"aria-label":"Upload files",...r,children:[a.jsx("input",{ref:A,type:"file",multiple:h,accept:d?.join(","),disabled:u,className:"hidden",onChange:X}),e]})});I.displayName="FileUploadDropzone";const R=c.forwardRef(({children:t,onClick:e,...r},o)=>{const{disabled:s,files:l,onUpload:p}=U(),f=async d=>{if(e?.(d),p){const u=l.filter(h=>h.status==="pending");u.length>0&&await p(u)}};return a.jsx(T.Button,{ref:o,disabled:s,onClick:f,...r,children:t})});R.displayName="FileUploadTrigger";const P=c.forwardRef(({className:t,children:e,...r},o)=>a.jsx("div",{ref:o,className:v.cn("space-y-2",t),...r,children:e}));P.displayName="FileUploadList";const C=c.forwardRef(({className:t,file:e,children:r,...o},s)=>a.jsx("div",{ref:s,className:v.cn("flex items-center gap-3 rounded-[var(--border-radius-l)] border p-3","border-[var(--color-border-primary)]",e.status==="error"&&"border-[var(--color-border-error-bold)] bg-[var(--color-background-error-subtle)]",e.status==="success"&&"border-[var(--color-border-success-bold)] bg-[var(--color-background-success-subtle)]",t),...o,children:r}));C.displayName="FileUploadItem";const z=c.forwardRef(({className:t,file:e,...r},o)=>{const s=l=>l.startsWith("image/")?"image":l.startsWith("video/")?"video":l.startsWith("audio/")?"volume-2":l.includes("pdf")||l.includes("text/")||l.includes("application/json")?"file-text":"file";return a.jsx("div",{ref:o,className:v.cn("flex h-10 w-10 items-center justify-center rounded",t),...r,children:e.preview&&oe(e.file)?a.jsx("img",{src:e.preview,alt:e.file.name,className:"h-full w-full rounded object-cover"}):a.jsx(V.Icon,{name:s(e.file.type??""),className:"h-5 w-5 text-[var(--color-text-secondary)]"})})});z.displayName="FileUploadItemPreview";const M=c.forwardRef(({className:t,file:e,children:r,...o},s)=>a.jsx("div",{ref:s,className:v.cn("flex-1 space-y-1",t),...o,children:r??a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"text-body-sm truncate font-medium",children:e.file.name}),a.jsx(te.Badge,{children:e.status})]}),a.jsx("p",{className:"text-caption-sm text-[var(--color-text-secondary)]",children:L(e.file.size)}),e.error&&a.jsx("p",{className:"text-caption-sm text-[var(--color-text-error-bold)]",children:e.error})]})}));M.displayName="FileUploadItemMetadata";const k=c.forwardRef(({className:t,file:e,variant:r="linear",...o},s)=>e.status!=="uploading"||e.progress===void 0?null:a.jsxs("div",{ref:s,className:v.cn("w-full",t),...o,children:[a.jsx(Z.Progress,{value:e.progress,className:"h-2"}),a.jsxs("p",{className:"text-caption-sm mt-1 text-[var(--color-text-secondary)]",children:[Math.round(e.progress),"%"]})]}));k.displayName="FileUploadItemProgress";const q=c.forwardRef(({file:t,...e},r)=>{const{files:o,onFilesChange:s,onDelete:l}=U(),p=async()=>{if(l)try{await l(t)}catch{return}const f=o.filter(d=>d.id!==t.id);s(f)};return a.jsx(T.Button,{ref:r,variant:"ghost",size:"s",onClick:p,"aria-label":`Remove ${t.file.name}`,...e,children:a.jsx(V.Icon,{name:ee.X,className:"h-4 w-4"})})});q.displayName="FileUploadItemDelete";const L=t=>{if(t===0)return"0 Bytes";const e=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,o)).toFixed(2))+" "+r[o]},se={Root:D,Dropzone:I,Trigger:R,List:P,Item:C,ItemPreview:z,ItemMetadata:M,ItemProgress:k,ItemDelete:q};exports.FileUpload=se;exports.FileUploadDropzone=I;exports.FileUploadItem=C;exports.FileUploadItemDelete=q;exports.FileUploadItemMetadata=M;exports.FileUploadItemPreview=z;exports.FileUploadItemProgress=k;exports.FileUploadList=P;exports.FileUploadRoot=D;exports.FileUploadTrigger=R;exports.formatFileSize=L;exports.useFileUpload=U;
|
|
@@ -1,86 +1,90 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { cva as
|
|
4
|
-
import { cn as
|
|
5
|
-
|
|
6
|
-
const b = m(
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import { cva as c } from "class-variance-authority";
|
|
4
|
+
import { cn as d } from "../../lib/utils.js";
|
|
5
|
+
const v = c(
|
|
7
6
|
"flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-[var(--space-xs)] [&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
|
|
8
7
|
{
|
|
9
8
|
variants: {
|
|
10
9
|
orientation: {
|
|
11
|
-
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
12
|
-
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
10
|
+
horizontal: "[&>*:not(:first-child):not([data-slot=button-group-separator])]:rounded-l-none [&>*:not(:first-child):not([data-slot=button-group-separator])]:border-l-0 [&>*:not(:last-child):not([data-slot=button-group-separator])]:rounded-r-none [&>*:has(+[data-slot=button-group-separator])]:border-r-0",
|
|
11
|
+
vertical: "flex-col [&>*:not(:first-child):not([data-slot=button-group-separator])]:rounded-t-none [&>*:not(:first-child):not([data-slot=button-group-separator])]:border-t-0 [&>*:not(:last-child):not([data-slot=button-group-separator])]:rounded-b-none [&>*:has(+[data-slot=button-group-separator])]:border-b-0"
|
|
13
12
|
}
|
|
14
13
|
},
|
|
15
14
|
defaultVariants: {
|
|
16
15
|
orientation: "horizontal"
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
),
|
|
20
|
-
({ className:
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
18
|
+
), m = /* @__PURE__ */ r.forwardRef(
|
|
19
|
+
({ className: a, orientation: o, size: t, variant: e, children: i, ...u }, p) => {
|
|
20
|
+
const b = r.Children.map(i, (s) => {
|
|
21
|
+
if (r.isValidElement(s)) {
|
|
23
22
|
const n = s.props;
|
|
24
|
-
return n?.["data-slot"]
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return n?.["data-slot"] === "button-group-separator" ? r.cloneElement(s, {
|
|
24
|
+
"data-variant": n["data-variant"] || e
|
|
25
|
+
}) : n?.["data-slot"] && n["data-slot"] !== "button" ? s : r.cloneElement(s, {
|
|
26
|
+
size: n.size || t,
|
|
27
|
+
variant: n.variant || e
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
return s;
|
|
30
31
|
});
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ l(
|
|
32
33
|
"div",
|
|
33
34
|
{
|
|
34
35
|
ref: p,
|
|
35
36
|
role: "group",
|
|
36
37
|
"data-slot": "button-group",
|
|
37
|
-
"data-orientation":
|
|
38
|
-
className:
|
|
38
|
+
"data-orientation": o,
|
|
39
|
+
className: d(v({ orientation: o }), a),
|
|
39
40
|
...u,
|
|
40
|
-
children:
|
|
41
|
+
children: b
|
|
41
42
|
}
|
|
42
43
|
);
|
|
43
44
|
}
|
|
44
45
|
);
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
({ className:
|
|
48
|
-
className:
|
|
46
|
+
m.displayName = "ButtonGroup";
|
|
47
|
+
const f = /* @__PURE__ */ r.forwardRef(
|
|
48
|
+
({ className: a, asChild: o = !1, children: t, ...e }, i) => o && r.isValidElement(t) ? r.cloneElement(t, {
|
|
49
|
+
className: d(
|
|
49
50
|
"bg-[var(--color-background-neutral-subtlest)] shadow-[var(--shadow-100)] flex items-center gap-[var(--space-xs)] rounded-[var(--border-radius-m)] border border-[var(--color-border-primary-subtle)] px-[var(--space-l)] [&]:text-body-sm font-medium [&_svg:not([class*='size-'])]:size-[var(--size-s)] [&_svg]:pointer-events-none",
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
t.props.className,
|
|
52
|
+
a
|
|
52
53
|
)
|
|
53
|
-
}) : /* @__PURE__ */
|
|
54
|
+
}) : /* @__PURE__ */ l(
|
|
54
55
|
"div",
|
|
55
56
|
{
|
|
56
|
-
ref:
|
|
57
|
-
className:
|
|
57
|
+
ref: i,
|
|
58
|
+
className: d(
|
|
58
59
|
"bg-[var(--color-background-neutral-subtlest)] shadow-[var(--shadow-100)] flex items-center gap-[var(--space-xs)] rounded-[var(--border-radius-m)] border border-[var(--color-border-primary-subtle)] px-[var(--space-l)] [&]:text-body-sm font-medium [&_svg:not([class*='size-'])]:size-[var(--size-s)] [&_svg]:pointer-events-none",
|
|
59
|
-
|
|
60
|
+
a
|
|
60
61
|
),
|
|
61
|
-
...
|
|
62
|
-
children:
|
|
62
|
+
...e,
|
|
63
|
+
children: t
|
|
63
64
|
}
|
|
64
65
|
)
|
|
65
66
|
);
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
f.displayName = "ButtonGroupText";
|
|
68
|
+
const g = /* @__PURE__ */ r.forwardRef(({ className: a, orientation: o = "vertical", ...t }, e) => /* @__PURE__ */ l(
|
|
69
|
+
"div",
|
|
69
70
|
{
|
|
70
|
-
ref:
|
|
71
|
+
ref: e,
|
|
72
|
+
role: "separator",
|
|
73
|
+
"aria-orientation": o,
|
|
71
74
|
"data-slot": "button-group-separator",
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
75
|
+
className: d(
|
|
76
|
+
"self-stretch",
|
|
77
|
+
o === "vertical" ? "border-l" : "border-t",
|
|
78
|
+
"border-[var(--color-border-divider)] data-[variant=primary]:border-white data-[variant=destructive]:border-white data-[variant=success]:border-white",
|
|
79
|
+
a
|
|
76
80
|
),
|
|
77
|
-
...
|
|
81
|
+
...t
|
|
78
82
|
}
|
|
79
83
|
));
|
|
80
|
-
|
|
84
|
+
g.displayName = "ButtonGroupSeparator";
|
|
81
85
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
m as ButtonGroup,
|
|
87
|
+
g as ButtonGroupSeparator,
|
|
88
|
+
f as ButtonGroupText,
|
|
89
|
+
v as buttonGroupVariants
|
|
86
90
|
};
|
|
@@ -266,7 +266,7 @@ const ce = (n, f = 0) => {
|
|
|
266
266
|
N.map((o, v) => /* @__PURE__ */ u(S.Fragment, { children: [
|
|
267
267
|
o.tooltipLabel && /* @__PURE__ */ r("p", { className: "text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]", children: o.tooltipLabel }),
|
|
268
268
|
!o.tooltipLabel && v === 0 && /* @__PURE__ */ r("p", { className: "text-label-sm mb-[var(--space-xs)] text-[var(--color-text-primary)]", children: "Reference Markers:" }),
|
|
269
|
-
o.dataPoints
|
|
269
|
+
o.dataPoints?.map((i, m) => /* @__PURE__ */ u("div", { className: "flex items-center gap-[var(--space-xs)]", children: [
|
|
270
270
|
(() => {
|
|
271
271
|
switch (i.shape || "circle") {
|
|
272
272
|
case "triangle":
|
|
@@ -463,7 +463,8 @@ function pr({
|
|
|
463
463
|
}
|
|
464
464
|
} : Be(), ee = {
|
|
465
465
|
data: y,
|
|
466
|
-
margin: me()
|
|
466
|
+
margin: me(),
|
|
467
|
+
tabIndex: -1
|
|
467
468
|
}, re = {
|
|
468
469
|
axisLine: { stroke: "var(--color-border-primary-subtle)", strokeWidth: 2 },
|
|
469
470
|
tickLine: !1,
|