@synertech/ui 0.50.1 → 0.52.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/.claude/skills/use-synertech-ui/SKILL.md +190 -146
- package/README.md +27 -19
- package/dist/components/accordion/Accordion.cjs +1 -1
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar/AvatarImage.cjs +1 -0
- package/dist/components/avatar/AvatarImage.js +1 -0
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/bar-chart/BarChart.cjs +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/box-plot/BoxPlot.cjs +1 -1
- package/dist/components/box-plot/BoxPlot.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/bullet-chart/BulletChart.cjs +1 -1
- package/dist/components/bullet-chart/BulletChart.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
- package/dist/components/card/Card.cjs +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/chart/ChartAnnotations.cjs +1 -1
- package/dist/components/chart/ChartAnnotations.js +1 -1
- package/dist/components/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartContainer.cjs +1 -1
- package/dist/components/chart/ChartContainer.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/ChartPatterns.cjs +1 -1
- package/dist/components/chart/ChartPatterns.js +1 -1
- package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
- package/dist/components/chart/ChartPeriodPicker.js +1 -1
- package/dist/components/chart/ChartPlotClip.cjs +1 -0
- package/dist/components/chart/ChartPlotClip.js +1 -0
- package/dist/components/chart/ChartSync.cjs +1 -1
- package/dist/components/chart/ChartSync.js +1 -1
- package/dist/components/chart/ChartTableView.cjs +1 -1
- package/dist/components/chart/ChartTableView.js +1 -1
- package/dist/components/chart/exportSource.cjs +1 -0
- package/dist/components/chart/exportSource.js +1 -0
- package/dist/components/chart/palette.cjs +1 -1
- package/dist/components/chart/palette.js +1 -1
- package/dist/components/chart/useChartSize.cjs +1 -1
- package/dist/components/chart/useChartSize.js +1 -1
- package/dist/components/chart/utils/bins.cjs +1 -1
- package/dist/components/chart/utils/bins.js +1 -1
- package/dist/components/chart/utils/cartesian.cjs +1 -1
- package/dist/components/chart/utils/cartesian.js +1 -1
- package/dist/components/chart/utils/export.cjs +7 -1
- package/dist/components/chart/utils/export.js +7 -1
- package/dist/components/chart/utils/format.cjs +1 -1
- package/dist/components/chart/utils/format.js +1 -1
- package/dist/components/chart/utils/keyboard.cjs +1 -1
- package/dist/components/chart/utils/keyboard.js +1 -1
- package/dist/components/chart/utils/period.cjs +1 -1
- package/dist/components/chart/utils/period.js +1 -1
- package/dist/components/chart/utils/regression.cjs +1 -0
- package/dist/components/chart/utils/regression.js +1 -0
- package/dist/components/chart/utils/stack.cjs +1 -1
- package/dist/components/chart/utils/stack.js +1 -1
- package/dist/components/chart/utils/ticks.cjs +1 -1
- package/dist/components/chart/utils/ticks.js +1 -1
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/circular-progress/CircularProgress.cjs +1 -1
- package/dist/components/circular-progress/CircularProgress.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.js +1 -1
- package/dist/components/detachable/Detachable.cjs +1 -1
- package/dist/components/detachable/Detachable.js +1 -1
- package/dist/components/detachable/popup-window.cjs +1 -0
- package/dist/components/detachable/popup-window.js +1 -0
- package/dist/components/detachable/useMovableContent.cjs +1 -0
- package/dist/components/detachable/useMovableContent.js +1 -0
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/divider/Divider.cjs +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
- package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
- package/dist/components/dropdown/hooks/usePositioning.js +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/footer/FooterBottom.cjs +1 -1
- package/dist/components/footer/FooterBottom.js +1 -1
- package/dist/components/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +5 -1
- package/dist/components/form/mention-input/MentionInput.js +5 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/form/shared/InputWrapper.cjs +1 -1
- package/dist/components/form/shared/InputWrapper.js +1 -1
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
- package/dist/components/funnel-chart/FunnelChart.js +1 -1
- package/dist/components/gantt-chart/GanttChart.cjs +1 -1
- package/dist/components/gantt-chart/GanttChart.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/line-chart/LineChart.cjs +1 -1
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pie-chart/PieChart.cjs +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/progress-bar/ProgressBar.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scatter-chart/index.cjs +1 -1
- package/dist/components/scatter-chart/index.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
- package/dist/components/schema-editor/utils/import.cjs +1 -0
- package/dist/components/schema-editor/utils/import.js +1 -0
- package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
- package/dist/components/schema-editor/utils/sql-export.js +7 -6
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sparkline/Sparkline.cjs +1 -1
- package/dist/components/sparkline/Sparkline.js +1 -1
- package/dist/components/table/TableRow.cjs +1 -1
- package/dist/components/table/TableRow.js +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
- package/dist/components/wizard/Wizard.cjs +1 -1
- package/dist/components/wizard/Wizard.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/components/workflow-editor/utils/import.cjs +1 -0
- package/dist/components/workflow-editor/utils/import.js +1 -0
- package/dist/hooks/useDialogA11y.cjs +1 -1
- package/dist/hooks/useDialogA11y.js +1 -1
- package/dist/index.d.cts +522 -184
- package/dist/index.d.ts +522 -184
- package/dist/lib/accept.cjs +1 -0
- package/dist/lib/accept.js +1 -0
- package/dist/lib/canvas-events.cjs +1 -0
- package/dist/lib/canvas-events.js +1 -0
- package/dist/lib/css-value.cjs +1 -0
- package/dist/lib/css-value.js +1 -0
- package/dist/lib/dialog-stack.cjs +1 -1
- package/dist/lib/dialog-stack.js +1 -1
- package/dist/lib/layer-document.cjs +1 -0
- package/dist/lib/layer-document.js +1 -0
- package/dist/lib/owner-document.cjs +1 -0
- package/dist/lib/owner-document.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -1
- package/dist/lib/ui-labels.js +1 -1
- package/dist/styles-no-preflight.css +10270 -0
- package/dist/styles.css +390 -450
- package/package.json +9 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var ne=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var ne=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var Se=(o,r)=>{for(var e in r)ne(o,e,{get:r[e],enumerable:!0})},xe=(o,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let b of ye(r))!ve.call(o,b)&&b!==e&&ne(o,b,{get:()=>r[b],enumerable:!(t=we(r,b))||t.enumerable});return o};var Le=o=>xe(ne({},"__esModule",{value:!0}),o);var Te={};Se(Te,{Heatmap:()=>Ae,resetHeatmapWarnings:()=>Pe});module.exports=Le(Te);var m=require("react"),ce=require("../../lib/cn.cjs"),me=require("../../lib/i18n.cjs"),re=require("../chart/ChartAxis.cjs"),he=require("../chart/ChartContainer.cjs"),ge=require("../chart/ChartScaleLegend.cjs"),de=require("../chart/ChartTableView.cjs"),fe=require("../chart/ChartTooltip.cjs"),z=require("../chart/palette.cjs"),O=require("../chart/utils/data.cjs"),J=require("../chart/utils/format.cjs"),M=require("../chart/utils/keyboard.cjs"),k=require("../chart/utils/scales.cjs"),V=require("../chart/utils/text.cjs"),be=require("../chart/utils/ticks.cjs"),pe=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Ve=2,He=2,Xe=12,Ee=16,se="cell:",le=!1,Re=(0,m.memo)(function({cells:r,radius:e}){return(0,n.jsx)("g",{children:r.map(t=>(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:e,fill:t.missing?void 0:t.color,className:t.missing?"fill-gray-100 dark:fill-gray-800":void 0}),t.label?(0,n.jsx)("text",{x:t.x+t.width/2,y:t.y+t.height/2,textAnchor:"middle",dominantBaseline:"central",className:(0,ce.cn)("text-[10px] [font-variant-numeric:tabular-nums]",t.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:t.label}):null]},t.key))})});function $e({width:o,height:r,columns:e,rows:t,lookup:b,colorScale:S,x:p,y:C,size:H,cellGap:y,cellRadius:B,showValues:U,tooltip:T,plotLabel:ee,formatValue:W,formatX:D,formatY:I,onCellClick:X}){let[R,N]=(0,m.useState)(null),s=R!==null&&R.column<e.length&&R.row<t.length?R:null,a=(0,m.useMemo)(()=>{let g=e.map((f,l)=>D(f,l)),d=t.map((f,l)=>I(f,l)),u={top:8,right:8,bottom:p.hidden?8:p.height??24+(p.label?16:0),left:C.hidden?8:C.height??(0,V.widestLabel)(d)+Xe+(C.label?16:0)},c=Math.max(0,o-u.left-u.right),v=Math.max(0,r-u.top-u.bottom),h=(0,k.createBandScale)(e.map((f,l)=>l),[0,c],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(t.map((f,l)=>l),[0,v],{paddingInner:0,paddingOuter:0}),Q=Math.max(0,h.bandwidth-y),L=Math.max(0,x.bandwidth-y),A=[];t.forEach((f,l)=>{e.forEach((j,K)=>{let E=b.get(`${(0,k.toKey)(j)}|${(0,k.toKey)(f)}`)?.value??null,i=null;if(U&&E!==null&&L>=Ee){let w=W(E);(0,V.estimateTextWidth)(w,10)+6<=Q&&(i=w)}A.push({key:`${K}-${l}`,column:K,row:l,x:h(K)+y/2,y:x(l)+y/2,width:Q,height:L,color:E===null?"transparent":S(E),label:i,onDark:E!==null&&S.onDark(E),missing:E===null})})});let F=(0,V.labelStride)(g.length,c,(0,V.widestLabel)(g)),P=(0,V.labelStride)(d.length,v,V.AXIS_FONT_SIZE+4),G=p.hidden?[]:g.map((f,l)=>({value:e[l],offset:h.center(l),label:f})).filter((f,l)=>l%F===0),Y=C.hidden?[]:d.map((f,l)=>({value:t[l],offset:x.center(l),label:f})).filter((f,l)=>l%P===0);return{margin:u,innerWidth:c,innerHeight:v,columnScale:h,rowScale:x,cells:A,columnTicks:G,rowTicks:Y}},[e,t,b,S,p,C,o,r,y,U,W,D,I]),_=(0,m.useCallback)((g,d)=>{let u=e[g],c=t[d],v=b.get(`${(0,k.toKey)(u)}|${(0,k.toKey)(c)}`),h=v?.value??null;return{x:u,y:c,xLabel:D(u,g),yLabel:I(c,d),value:h,formattedValue:h===null?"\u2014":W(h),color:h===null?"transparent":S(h),datum:v?.datum}},[e,t,b,S,W,D,I]),te=(0,m.useCallback)(g=>{if(T===!1||e.length===0||t.length===0)return;let d=g.currentTarget.getBoundingClientRect(),u=g.clientX-d.left-a.margin.left,c=g.clientY-d.top-a.margin.top,v=Math.floor(u/(a.columnScale.step||1)),h=Math.floor(c/(a.rowScale.step||1));if(v<0||v>=e.length||h<0||h>=t.length){N(null);return}N(x=>x?.column===v&&x.row===h?x:{column:v,row:h})},[T,e.length,t.length,a.margin,a.columnScale,a.rowScale]),q=(0,m.useCallback)(()=>{!X||!s||X(_(s.column,s.row))},[X,s,_]),ae=(0,m.useCallback)(g=>{if(e.length===0||t.length===0||(0,M.pressChartMark)(g,X&&s?q:null))return;let d=s?.column??null,u=s?.row??null,c;switch(g.key){case"ArrowRight":c={row:u??0,column:(0,M.stepChartCursor)(d,1,e.length)};break;case"ArrowLeft":c={row:u??0,column:(0,M.stepChartCursor)(d,-1,e.length)};break;case"ArrowDown":c={column:d??0,row:(0,M.stepChartCursor)(u,1,t.length)};break;case"ArrowUp":c={column:d??0,row:(0,M.stepChartCursor)(u,-1,t.length)};break;case"Home":c={row:u??0,column:0};break;case"End":c={row:u??0,column:e.length-1};break;case"Escape":if(s===null)return;c=null;break;default:return}g.preventDefault(),N(c)},[e.length,t.length,s,X,q]),$=s?_(s.column,s.row):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:o,height:r,role:"img","aria-label":ee??`${p.label??p.key} / ${C.label??C.key}`,tabIndex:0,className:`${pe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:te,onPointerLeave:()=>N(null),onKeyDown:ae,onBlur:()=>N(null),onClick:q,children:[(0,n.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[(0,n.jsx)(Re,{cells:a.cells,radius:B}),s?(0,n.jsx)("rect",{x:a.columnScale(s.column)+y/2,y:a.rowScale(s.row)+y/2,width:Math.max(0,a.columnScale.bandwidth-y),height:Math.max(0,a.rowScale.bandwidth-y),rx:B,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),(0,n.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:p.hidden?null:(0,n.jsx)(re.ChartAxis,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:p.label,size:H})}),(0,n.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:C.hidden?null:(0,n.jsx)(re.ChartAxis,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:C.label,size:H})})]}),s&&$&&T!==!1?(0,n.jsx)(fe.ChartTooltip,{x:a.margin.left+a.columnScale.center(s.column),y:a.margin.top+a.rowScale.center(s.row),containerWidth:o,children:typeof T=="function"?T($):(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsxs)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[$.yLabel," \xB7 ",$.xLabel]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$.color},"aria-hidden":"true"}),(0,n.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:$.formattedValue})]})]})}):null]})}function ue(o,r,e){if(e)return e;let t=new Map;return o.forEach((b,S)=>{let p=(0,O.readXValue)(b,r,S),C=(0,k.toKey)(p);t.has(C)||t.set(C,p)}),[...t.values()]}function Ae({data:o,x:r,y:e,value:t,format:b,domain:S,scale:p="sequential",center:C=0,steps:H,colors:y,xDomain:B,yDomain:U,cellGap:T=Ve,cellRadius:ee=He,showValues:W=!1,height:D=280,width:I,size:X="md",legend:R=!0,legendLabel:N,tooltip:s=!0,tableView:a=!1,title:_,description:te,loading:q=!1,emptyState:ae,error:$=!1,errorState:g,onRetry:d,actions:u,locale:c,plotLabel:v,onCellClick:h,className:x,...Q}){let L=(0,me.useUILocale)(c);H!==void 0&&H>z.CHART_MAX_COLOR_CLASSES&&!le&&(le=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${H} colour classes. Past ${z.CHART_MAX_COLOR_CLASSES} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let A=(0,m.useMemo)(()=>ue(o,r.key,B),[o,r.key,B]),F=(0,m.useMemo)(()=>ue(o,e.key,U),[o,e.key,U]),P=(0,m.useMemo)(()=>{let i=new Map;return o.forEach((w,Z)=>{let ie=(0,O.readNumber)(w,t);if(ie===null)return;let Ce=(0,O.readXValue)(w,r.key,Z),ke=(0,O.readXValue)(w,e.key,Z);i.set(`${(0,k.toKey)(Ce)}|${(0,k.toKey)(ke)}`,{value:ie,datum:w})}),i},[o,r.key,e.key,t]),G=(0,m.useMemo)(()=>b??(i=>(0,J.formatAuto)(i,L)),[b,L]),Y=(0,m.useMemo)(()=>r.format??(i=>(0,J.formatXValue)(i,L)),[r.format,L]),f=(0,m.useMemo)(()=>e.format??(i=>(0,J.formatXValue)(i,L)),[e.format,L]),l=(0,m.useMemo)(()=>{let i=S??(0,be.extent)([...P.values()].map(w=>w.value))??[0,1];return p==="diverging"?(0,z.createDivergingScale)(i,{center:C,steps:H,colors:y}):(0,z.createSequentialScale)(i,{steps:H,colors:y})},[S,P,p,C,H,y]),j=(0,m.useMemo)(()=>F.map(i=>{let w={[e.key]:i};return A.forEach(Z=>{w[`${se}${(0,k.toKey)(Z)}`]=P.get(`${(0,k.toKey)(Z)}|${(0,k.toKey)(i)}`)?.value??null}),w}),[F,A,P,e.key]),K=(0,m.useMemo)(()=>A.map((i,w)=>({key:`${se}${(0,k.toKey)(i)}`,label:Y(i,w)})),[A,Y]),oe=R!==!1,E=typeof R=="string"?R:"bottom";return(0,n.jsx)(he.ChartContainer,{title:_,description:te,height:D,width:I,size:X,loading:q,empty:P.size===0,emptyState:ae,error:$,errorState:g,onRetry:d,actions:u,exportSource:{data:j,series:K,xKey:e.key,xLabel:e.label??e.key,formatX:e.format},tableView:a,legendPosition:E,legend:oe?(0,n.jsx)(ge.ChartScaleLegend,{scale:l,label:N,format:G,size:X,locale:L}):void 0,table:a?(0,n.jsx)(de.ChartTableView,{data:j,series:K,xKey:e.key,xLabel:e.label??e.key,formatX:f,formatValue:G,caption:typeof _=="string"?_:void 0}):void 0,className:x,...Q,children:({width:i})=>(0,n.jsx)($e,{width:i,height:D,columns:A,rows:F,lookup:P,colorScale:l,x:r,y:e,size:X,cellGap:T,cellRadius:ee,showValues:W,tooltip:s,plotLabel:v,formatValue:G,formatX:Y,formatY:f,onCellClick:h})})}function Pe(){le=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as fe,useCallback as
|
|
1
|
+
"use client";import{memo as fe,useCallback as Z,useMemo as x,useState as be}from"react";import{cn as pe}from"../../lib/cn.js";import{useUILocale as Ce}from"../../lib/i18n.js";import{ChartAxis as le}from"../chart/ChartAxis.js";import{ChartContainer as ke}from"../chart/ChartContainer.js";import{ChartScaleLegend as we}from"../chart/ChartScaleLegend.js";import{ChartTableView as ye}from"../chart/ChartTableView.js";import{ChartTooltip as ve}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as oe,createDivergingScale as Se,createSequentialScale as xe}from"../chart/palette.js";import{readNumber as Le,readXValue as te}from"../chart/utils/data.js";import{formatAuto as Ve,formatXValue as ie}from"../chart/utils/format.js";import{pressChartMark as He,stepChartCursor as J}from"../chart/utils/keyboard.js";import{createBandScale as se,toKey as w}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as Xe,estimateTextWidth as Ee,labelStride as ue,widestLabel as ce}from"../chart/utils/text.js";import{extent as Re}from"../chart/utils/ticks.js";import{CHART_TOUCH as $e}from"../chart/utils/touch.js";import{Fragment as Me,jsx as h,jsxs as _}from"react/jsx-runtime";var Ae=2,Pe=2,Te=12,De=16,me="cell:",ae=!1,Ne=fe(function({cells:g,radius:e}){return h("g",{children:g.map(t=>_("g",{children:[h("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:e,fill:t.missing?void 0:t.color,className:t.missing?"fill-gray-100 dark:fill-gray-800":void 0}),t.label?h("text",{x:t.x+t.width/2,y:t.y+t.height/2,textAnchor:"middle",dominantBaseline:"central",className:pe("text-[10px] [font-variant-numeric:tabular-nums]",t.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:t.label}):null]},t.key))})});function _e({width:b,height:g,columns:e,rows:t,lookup:L,colorScale:y,x:d,y:f,size:V,cellGap:C,cellRadius:I,showValues:K,tooltip:P,plotLabel:Q,formatValue:M,formatX:T,formatY:z,onCellClick:H}){let[E,D]=be(null),l=E!==null&&E.column<e.length&&E.row<t.length?E:null,a=x(()=>{let u=e.map((m,n)=>T(m,n)),c=t.map((m,n)=>z(m,n)),o={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:f.hidden?8:f.height??ce(c)+Te+(f.label?16:0)},i=Math.max(0,b-o.left-o.right),k=Math.max(0,g-o.top-o.bottom),s=se(e.map((m,n)=>n),[0,i],{paddingInner:0,paddingOuter:0}),v=se(t.map((m,n)=>n),[0,k],{paddingInner:0,paddingOuter:0}),G=Math.max(0,s.bandwidth-C),S=Math.max(0,v.bandwidth-C),$=[];t.forEach((m,n)=>{e.forEach((Y,W)=>{let X=L.get(`${w(Y)}|${w(m)}`)?.value??null,r=null;if(K&&X!==null&&S>=De){let p=M(X);Ee(p,10)+6<=G&&(r=p)}$.push({key:`${W}-${n}`,column:W,row:n,x:s(W)+C/2,y:v(n)+C/2,width:G,height:S,color:X===null?"transparent":y(X),label:r,onDark:X!==null&&y.onDark(X),missing:X===null})})});let B=ue(u.length,i,ce(u)),A=ue(c.length,k,Xe+4),U=d.hidden?[]:u.map((m,n)=>({value:e[n],offset:s.center(n),label:m})).filter((m,n)=>n%B===0),q=f.hidden?[]:c.map((m,n)=>({value:t[n],offset:v.center(n),label:m})).filter((m,n)=>n%A===0);return{margin:o,innerWidth:i,innerHeight:k,columnScale:s,rowScale:v,cells:$,columnTicks:U,rowTicks:q}},[e,t,L,y,d,f,b,g,C,K,M,T,z]),N=Z((u,c)=>{let o=e[u],i=t[c],k=L.get(`${w(o)}|${w(i)}`),s=k?.value??null;return{x:o,y:i,xLabel:T(o,u),yLabel:z(i,c),value:s,formattedValue:s===null?"\u2014":M(s),color:s===null?"transparent":y(s),datum:k?.datum}},[e,t,L,y,M,T,z]),j=Z(u=>{if(P===!1||e.length===0||t.length===0)return;let c=u.currentTarget.getBoundingClientRect(),o=u.clientX-c.left-a.margin.left,i=u.clientY-c.top-a.margin.top,k=Math.floor(o/(a.columnScale.step||1)),s=Math.floor(i/(a.rowScale.step||1));if(k<0||k>=e.length||s<0||s>=t.length){D(null);return}D(v=>v?.column===k&&v.row===s?v:{column:k,row:s})},[P,e.length,t.length,a.margin,a.columnScale,a.rowScale]),O=Z(()=>{!H||!l||H(N(l.column,l.row))},[H,l,N]),ee=Z(u=>{if(e.length===0||t.length===0||He(u,H&&l?O:null))return;let c=l?.column??null,o=l?.row??null,i;switch(u.key){case"ArrowRight":i={row:o??0,column:J(c,1,e.length)};break;case"ArrowLeft":i={row:o??0,column:J(c,-1,e.length)};break;case"ArrowDown":i={column:c??0,row:J(o,1,t.length)};break;case"ArrowUp":i={column:c??0,row:J(o,-1,t.length)};break;case"Home":i={row:o??0,column:0};break;case"End":i={row:o??0,column:e.length-1};break;case"Escape":if(l===null)return;i=null;break;default:return}u.preventDefault(),D(i)},[e.length,t.length,l,H,O]),R=l?N(l.column,l.row):null;return _(Me,{children:[_("svg",{width:b,height:g,role:"img","aria-label":Q??`${d.label??d.key} / ${f.label??f.key}`,tabIndex:0,className:`${$e} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>D(null),onKeyDown:ee,onBlur:()=>D(null),onClick:O,children:[_("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[h(Ne,{cells:a.cells,radius:I}),l?h("rect",{x:a.columnScale(l.column)+C/2,y:a.rowScale(l.row)+C/2,width:Math.max(0,a.columnScale.bandwidth-C),height:Math.max(0,a.rowScale.bandwidth-C),rx:I,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:d.hidden?null:h(le,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:d.label,size:V})}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:f.hidden?null:h(le,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:f.label,size:V})})]}),l&&R&&P!==!1?h(ve,{x:a.margin.left+a.columnScale.center(l.column),y:a.margin.top+a.rowScale.center(l.row),containerWidth:b,children:typeof P=="function"?P(R):_("div",{className:"flex flex-col gap-1",children:[_("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[R.yLabel," \xB7 ",R.xLabel]}),_("div",{className:"flex items-center gap-2",children:[h("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:R.color},"aria-hidden":"true"}),h("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:R.formattedValue})]})]})}):null]})}function he(b,g,e){if(e)return e;let t=new Map;return b.forEach((L,y)=>{let d=te(L,g,y),f=w(d);t.has(f)||t.set(f,d)}),[...t.values()]}function tt({data:b,x:g,y:e,value:t,format:L,domain:y,scale:d="sequential",center:f=0,steps:V,colors:C,xDomain:I,yDomain:K,cellGap:P=Ae,cellRadius:Q=Pe,showValues:M=!1,height:T=280,width:z,size:H="md",legend:E=!0,legendLabel:D,tooltip:l=!0,tableView:a=!1,title:N,description:j,loading:O=!1,emptyState:ee,error:R=!1,errorState:u,onRetry:c,actions:o,locale:i,plotLabel:k,onCellClick:s,className:v,...G}){let S=Ce(i);V!==void 0&&V>oe&&!ae&&(ae=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${V} colour classes. Past ${oe} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let $=x(()=>he(b,g.key,I),[b,g.key,I]),B=x(()=>he(b,e.key,K),[b,e.key,K]),A=x(()=>{let r=new Map;return b.forEach((p,F)=>{let re=Le(p,t);if(re===null)return;let ge=te(p,g.key,F),de=te(p,e.key,F);r.set(`${w(ge)}|${w(de)}`,{value:re,datum:p})}),r},[b,g.key,e.key,t]),U=x(()=>L??(r=>Ve(r,S)),[L,S]),q=x(()=>g.format??(r=>ie(r,S)),[g.format,S]),m=x(()=>e.format??(r=>ie(r,S)),[e.format,S]),n=x(()=>{let r=y??Re([...A.values()].map(p=>p.value))??[0,1];return d==="diverging"?Se(r,{center:f,steps:V,colors:C}):xe(r,{steps:V,colors:C})},[y,A,d,f,V,C]),Y=x(()=>B.map(r=>{let p={[e.key]:r};return $.forEach(F=>{p[`${me}${w(F)}`]=A.get(`${w(F)}|${w(r)}`)?.value??null}),p}),[B,$,A,e.key]),W=x(()=>$.map((r,p)=>({key:`${me}${w(r)}`,label:q(r,p)})),[$,q]),ne=E!==!1,X=typeof E=="string"?E:"bottom";return h(ke,{title:N,description:j,height:T,width:z,size:H,loading:O,empty:A.size===0,emptyState:ee,error:R,errorState:u,onRetry:c,actions:o,exportSource:{data:Y,series:W,xKey:e.key,xLabel:e.label??e.key,formatX:e.format},tableView:a,legendPosition:X,legend:ne?h(we,{scale:n,label:D,format:U,size:H,locale:S}):void 0,table:a?h(ye,{data:Y,series:W,xKey:e.key,xLabel:e.label??e.key,formatX:m,formatValue:U,caption:typeof N=="string"?N:void 0}):void 0,className:v,...G,children:({width:r})=>h(_e,{width:r,height:T,columns:$,rows:B,lookup:A,colorScale:n,x:g,y:e,size:H,cellGap:P,cellRadius:Q,showValues:M,tooltip:l,plotLabel:k,formatValue:U,formatX:q,formatY:m,onCellClick:s})})}function at(){ae=!1}export{tt as Heatmap,at as resetHeatmapWarnings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var I=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var Q=(r,e)=>{for(var s in e)I(r,s,{get:e[s],enumerable:!0})},X=(r,e,s,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J(e))!V.call(r,o)&&o!==s&&I(r,o,{get:()=>e[o],enumerable:!(p=q(e,o))||p.enumerable});return r};var Y=r=>X(I({},"__esModule",{value:!0}),r);var te={};Q(te,{ImageUploader:()=>re});module.exports=Y(te);var t=require("react"),c=require("../../lib/i18n.cjs"),y=require("../../lib/accept.cjs"),a=require("react/jsx-runtime"),Z={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},T="image/svg+xml",_=r=>(0,y.parseAccept)(r).some(e=>e===T||e===".svg"),ee=(r,e)=>new Promise((s,p)=>{let o=new FileReader;o.onload=i=>{let x=i.target?.result;s(x)},o.onerror=()=>{p(new Error(e))},o.readAsDataURL(r)});function re({value:r,onChange:e,onUpload:s,label:p,maxSize:o=5*1024*1024,accept:i="image/*",helpText:x,disabled:b=!1,className:M="",showUrlInput:A=!0,urlPlaceholder:H="https://example.com/image.jpg",labels:S,aspectRatio:N="16/9",locale:B}){let l=(0,c.useUILabels)(S),E=(0,c.useUILocale)(B),L=p??l.imageUploaderLabel,[U,F]=(0,t.useState)(!1),[P,d]=(0,t.useState)(null),f=(0,t.useRef)(null),C=(0,t.useId)(),v=(0,t.useMemo)(()=>new Intl.NumberFormat(E,{maximumFractionDigits:2}).format(o/(1024*1024)),[E,o]),g=r&&!r.startsWith("data:")?r:"",[h,R]=(0,t.useState)(g),[G,K]=(0,t.useState)(g);G!==g&&(K(g),R(g));let k=i==="image/*"?"JPG, PNG, GIF, WebP":i,O=(0,c.formatUILabel)(l.imageUploaderHelp,{formats:k,maxSize:v}),j=(0,t.useCallback)(async n=>{let D=n.target,m=D.files?.[0];if(D.value="",!!m){if(!m.type.startsWith("image/")){d(l.imageUploaderNotImage);return}if(!(0,y.matchesAccept)(m,i)||m.type.toLowerCase()===T&&!_(i)){d((0,c.formatUILabel)(l.imageUploaderTypeNotAccepted,{formats:k}));return}if(m.size>o){d((0,c.formatUILabel)(l.imageUploaderTooLarge,{maxSize:v}));return}F(!0),d(null);try{if(s){let u=await s(m);e(u)}else{let u=await ee(m,l.imageUploaderReadError);e(u)}}catch(u){console.error("Upload error:",u),d(u instanceof Error?u.message:l.imageUploaderUploadError)}finally{F(!1)}}},[i,k,o,v,e,s,l]),W=(0,t.useCallback)(()=>{e(""),f.current&&(f.current.value=""),d(null)},[e]),w=(0,t.useCallback)(()=>{let n=h.trim();return n===g?!1:(e(n),d(null),!0)},[h,g,e]),$=(0,t.useCallback)(()=>{f.current?.click()},[]),z=(0,t.useCallback)(n=>{n.key!=="Enter"||n.nativeEvent.isComposing||w()&&n.preventDefault()},[w]);return(0,a.jsxs)("div",{className:`space-y-2 ${M}`,children:[L&&(0,a.jsx)("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:L}),r&&(0,a.jsxs)("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[(0,a.jsx)("div",{className:`relative ${Z[N]} ${N==="auto"?"max-h-64":""} flex items-center justify-center`,children:(0,a.jsx)("img",{src:r,alt:l.imageUploaderPreview,className:"w-full h-full object-contain"})}),(0,a.jsx)("button",{type:"button",onClick:W,disabled:b,className:"absolute top-2 right-2 bg-red-600 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-700 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:l.imageUploaderRemove,children:"\xD7"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{ref:f,type:"file","aria-label":l.imageUploaderChoose,accept:i,onChange:j,className:"hidden",disabled:b||U}),(0,a.jsx)("button",{type:"button",onClick:$,disabled:b||U,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:U?l.imageUploaderUploading:r?l.imageUploaderChangeButton:l.imageUploaderChooseButton})]}),A&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{htmlFor:C,className:"block text-xs text-gray-500 dark:text-gray-400",children:l.imageUploaderUrlLabel}),(0,a.jsx)("input",{id:C,type:"text",inputMode:"url",value:h,onChange:n=>{R(n.target.value),d(null)},onBlur:w,onKeyDown:z,placeholder:H,disabled:b,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),P&&(0,a.jsxs)("div",{className:"text-red-700 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",P]}),(0,a.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:x||O})]})}0&&(module.exports={ImageUploader});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as f,useRef as q,useCallback as m,useMemo as J,useId as V}from"react";import{formatUILabel as I,useUILabels as Q,useUILocale as X}from"../../lib/i18n.js";import{matchesAccept as Y,parseAccept as Z}from"../../lib/accept.js";import{jsx as l,jsxs as u}from"react/jsx-runtime";var _={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},T="image/svg+xml",ee=t=>Z(t).some(r=>r===T||r===".svg"),re=(t,r)=>new Promise((g,y)=>{let o=new FileReader;o.onload=s=>{let x=s.target?.result;g(x)},o.onerror=()=>{y(new Error(r))},o.readAsDataURL(t)});function oe({value:t,onChange:r,onUpload:g,label:y,maxSize:o=5*1024*1024,accept:s="image/*",helpText:x,disabled:p=!1,className:M="",showUrlInput:A=!0,urlPlaceholder:H="https://example.com/image.jpg",labels:S,aspectRatio:N="16/9",locale:B}){let e=Q(S),E=X(B),L=y??e.imageUploaderLabel,[U,F]=f(!1),[P,n]=f(null),b=q(null),C=V(),v=J(()=>new Intl.NumberFormat(E,{maximumFractionDigits:2}).format(o/(1024*1024)),[E,o]),i=t&&!t.startsWith("data:")?t:"",[h,R]=f(i),[G,K]=f(i);G!==i&&(K(i),R(i));let k=s==="image/*"?"JPG, PNG, GIF, WebP":s,O=I(e.imageUploaderHelp,{formats:k,maxSize:v}),j=m(async a=>{let D=a.target,d=D.files?.[0];if(D.value="",!!d){if(!d.type.startsWith("image/")){n(e.imageUploaderNotImage);return}if(!Y(d,s)||d.type.toLowerCase()===T&&!ee(s)){n(I(e.imageUploaderTypeNotAccepted,{formats:k}));return}if(d.size>o){n(I(e.imageUploaderTooLarge,{maxSize:v}));return}F(!0),n(null);try{if(g){let c=await g(d);r(c)}else{let c=await re(d,e.imageUploaderReadError);r(c)}}catch(c){console.error("Upload error:",c),n(c instanceof Error?c.message:e.imageUploaderUploadError)}finally{F(!1)}}},[s,k,o,v,r,g,e]),W=m(()=>{r(""),b.current&&(b.current.value=""),n(null)},[r]),w=m(()=>{let a=h.trim();return a===i?!1:(r(a),n(null),!0)},[h,i,r]),$=m(()=>{b.current?.click()},[]),z=m(a=>{a.key!=="Enter"||a.nativeEvent.isComposing||w()&&a.preventDefault()},[w]);return u("div",{className:`space-y-2 ${M}`,children:[L&&l("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:L}),t&&u("div",{className:"relative w-full overflow-hidden rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800/50",children:[l("div",{className:`relative ${_[N]} ${N==="auto"?"max-h-64":""} flex items-center justify-center`,children:l("img",{src:t,alt:e.imageUploaderPreview,className:"w-full h-full object-contain"})}),l("button",{type:"button",onClick:W,disabled:p,className:"absolute top-2 right-2 bg-red-600 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-700 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:e.imageUploaderRemove,children:"\xD7"})]}),u("div",{className:"flex gap-2",children:[l("input",{ref:b,type:"file","aria-label":e.imageUploaderChoose,accept:s,onChange:j,className:"hidden",disabled:p||U}),l("button",{type:"button",onClick:$,disabled:p||U,className:"px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors cursor-pointer bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200",children:U?e.imageUploaderUploading:t?e.imageUploaderChangeButton:e.imageUploaderChooseButton})]}),A&&u("div",{className:"space-y-1",children:[l("label",{htmlFor:C,className:"block text-xs text-gray-500 dark:text-gray-400",children:e.imageUploaderUrlLabel}),l("input",{id:C,type:"text",inputMode:"url",value:h,onChange:a=>{R(a.target.value),n(null)},onBlur:w,onKeyDown:z,placeholder:H,disabled:p,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),P&&u("div",{className:"text-red-700 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded border border-red-200 dark:border-red-800",children:["\u274C ",P]}),l("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:x||O})]})}export{oe as ImageUploader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Re=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var ze=Object.prototype.hasOwnProperty;var Ue=(u,a)=>{for(var r in a)Re(u,r,{get:a[r],enumerable:!0})},je=(u,a,r,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of _e(a))!ze.call(u,d)&&d!==r&&Re(u,d,{get:()=>a[d],enumerable:!(s=$e(a,d))||s.enumerable});return u};var Fe=u=>je(Re({},"__esModule",{value:!0}),u);var tt={};Ue(tt,{LineChart:()=>et});module.exports=Fe(tt);var l=require("react"),Te=require("../../lib/cn.cjs"),ie=require("../../lib/i18n.cjs"),q=require("../chart/ChartAnnotations.cjs"),we=require("../chart/ChartAxis.cjs"),le=require("../chart/ChartBrush.cjs"),Be=require("../chart/ChartContainer.cjs"),Ee=require("../chart/ChartGrid.cjs"),He=require("../chart/ChartLegend.cjs"),We=require("../chart/ChartSync.cjs"),Ie=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),W=require("../chart/palette.cjs"),k=require("../chart/utils/cartesian.cjs"),J=require("../chart/utils/data.cjs"),ue=require("../chart/utils/decimate.cjs"),ce=require("../chart/utils/format.cjs"),de=require("../chart/utils/keyboard.cjs"),I=require("../chart/utils/path.cjs"),H=require("../chart/utils/scales.cjs"),Ne=require("../chart/utils/ticks.cjs"),De=require("../chart/utils/timestamp.cjs"),Ke=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Ye=24,qe=10,Je=10,Qe=(0,l.memo)(function({lines:a,showMarkers:r}){return(0,n.jsx)("g",{children:a.map(s=>(0,n.jsxs)("g",{children:[s.solid?(0,n.jsx)("path",{d:s.solid,fill:"none",stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,s.dashed?(0,n.jsx)("path",{d:s.dashed,fill:"none",stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,(r?s.markers:s.isolated).map((d,C)=>(0,n.jsx)("circle",{cx:d.x,cy:d.y,r:3,fill:s.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},C))]},s.key))})});function Ze({width:u,height:a,data:r,resolvedSeries:s,x:d,y:C,grid:b,size:Q,curve:x,forecastFrom:M,forecastLabel:v,markers:P,connectNulls:L,referenceLines:me,annotations:S,annotationsLabel:fe,overlay:ge,maxPoints:R,brush:Z,onBrush:ee,brushLabel:pe,syncEnabled:ye,margin:te,tooltip:w,onPointClick:V,plotLabel:Ce,formatValue:A,formatX:N}){let[X,G]=(0,l.useState)(null),h=X!==null&&X<r.length?X:null,[be,xe]=(0,l.useState)(null),ke=(0,We.useChartSync)(),m=ye?ke:null,e=(0,l.useMemo)(()=>{let t=s.filter(f=>!f.hidden),o=(0,k.buildCartesianGeometry)({width:u,height:a,data:r,x:d,y:C,bounds:(0,Ne.extent)((0,J.collectAllValues)(r,t.map(f=>f.key))),margin:te,placement:"point",formatValue:A,formatX:N,extraTop:v?qe:0}),c=o.categoryCenters,E=o.valueScale,oe=M===void 0?-1:o.xValues.findIndex(f=>(0,H.toKey)(f)===(0,H.toKey)(M)),Me=t.map(f=>{let j=r.map((se,Oe)=>{let Se=(0,J.readNumber)(se,f.key);return{x:c[Oe],y:Se===null?Number.NaN:E(Se),defined:Se!==null}}),Ve={connectNulls:L},ae=oe>=0,Le=se=>R&&R>0?(0,ue.decimatePath)(se,R):se,F=f.dashed?[]:Le(ae?j.slice(0,oe+1):j),Y=f.dashed?Le(j):ae?Le(j.slice(oe)):[];R||(0,ue.warnPointBudget)("LineChart",j.length);let Ge=F[F.length-1],Ae=f.dashed?Y:ae?[...F,...Y[0]===Ge?Y.slice(1):Y]:F;return{key:f.key,color:f.color,solid:f.dashed?"":(0,I.buildLinePath)(F,x,Ve),dashed:f.dashed||ae?(0,I.buildLinePath)(Y,x,Ve):"",markers:Ae.filter(I.isDrawable),isolated:(0,I.isolatedPoints)(Ae,L)}}),Xe=r.length>1?o.innerWidth/(r.length-1):0;return{visible:t,locate:(0,k.createCategoryLocator)(o),plot:(0,k.createPlotContext)({geometry:o,width:u,height:a,data:r,series:t,formatValue:A,formatX:N}),xValues:o.xValues,xPositions:c,xTicks:o.categoryTicks,yTicks:o.valueTicks,yScale:E,innerWidth:o.innerWidth,innerHeight:o.innerHeight,margin:o.margin,lines:Me,forecastIndex:oe,showMarkers:P==="always"||P==="auto"&&Xe>=Ye&&r.length>1}},[r,s,d,C,u,a,te,x,L,M,v,P,R,A,N]),O=(0,l.useCallback)(t=>e.visible.map(o=>{let c=(0,J.readNumber)(r[t],o.key);return{seriesKey:o.key,seriesLabel:(0,W.getSeriesLabel)(o),color:o.color,value:c,formattedValue:c===null?"\u2014":A(c),datum:r[t]}}),[r,e.visible,A]),ne=m?m.brush:be,ve=(0,l.useCallback)(t=>{xe(t),m?.setBrush(t),ee?.(t)},[m,ee]),g=(0,le.useChartBrush)({enabled:Z,active:ne!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:ve}),T=(0,l.useCallback)(t=>{if(g.onPointerMove(t),w===!1||r.length===0)return;let o=t.currentTarget.getBoundingClientRect(),c=t.clientX-o.left-e.margin.left,E=(0,H.nearestIndex)(e.xPositions,c);G(E>=0?E:null),m?.setHovered(E>=0?e.xValues[E]:null)},[g,w,r.length,e.margin.left,e.xPositions,e.xValues,m]),$=(0,l.useCallback)(()=>{G(null),m?.setHovered(null)},[m]),B=(0,l.useCallback)(()=>{if(!V||h===null)return;let[t]=O(h);t&&V({...t,index:h,x:e.xValues[h]})},[V,h,O,e.xValues]),Pe=(0,l.useCallback)(t=>{if(r.length===0)return;let o=V&&h!==null&&e.visible.length>0;if((0,de.pressChartMark)(t,o?B:null))return;g.onKeyDown(t,h);let c=(0,de.chartCursorTarget)(t.key,h,r.length,"x");c!==void 0&&(t.preventDefault(),G(c),m?.setHovered(c===null?null:e.xValues[c]))},[r.length,h,g,m,e.xValues,e.visible.length,V,B]),D=(0,l.useCallback)(()=>{g.consumedClick()||B()},[g,B]),re=h!==null||!m?.hovered?null:(()=>{let t=(0,H.toKey)(m.hovered),o=e.xValues.findIndex(c=>(0,H.toKey)(c)===t);return o<0?null:o})(),p=h??re,_=p===null?null:O(p),z=(_??[]).filter(t=>t.value!==null),K=g.dragging??ne,U=(()=>{if(!K)return null;let t=e.locate(K.from),o=e.locate(K.to);return t===null||o===null?null:{from:t,to:o}})(),i=(0,k.splitOverlay)(ge),y=h===null||_===null?null:{x:e.xValues[h],xLabel:N(e.xValues[h],h),index:h,points:_};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:a,role:"img","aria-label":Ce??[e.visible.map(t=>(0,W.getSeriesLabel)(t)).join(", "),(0,q.describeAnnotations)(S,fe)].filter(Boolean).join(". "),tabIndex:0,className:(0,Te.cn)(Ke.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",Z&&"select-none"),onPointerDown:g.onPointerDown,onPointerMove:T,onPointerUp:g.onPointerUp,onPointerCancel:g.onPointerUp,onPointerLeave:$,onKeyDown:Pe,onBlur:$,onClick:D,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(Ee.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:b==="y"||b==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:b==="x"||b==="both"?e.xTicks.map(t=>t.offset):void 0}),S?(0,n.jsx)(q.ChartAnnotationLayer,{layer:"under",annotations:S,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,U?(0,n.jsx)(le.ChartBrushLayer,{from:U.from,to:U.to,width:e.innerWidth,height:e.innerHeight,live:g.dragging!==null,label:pe}):null,i.under?.(e.plot),me?.map(t=>{let o=e.yScale(t.value),c=o<Je?o+12:o-4;return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:0,y1:o,x2:e.innerWidth,y2:o,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,n.jsx)("text",{x:e.innerWidth,y:c,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),e.forecastIndex>=0?(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:e.xPositions[e.forecastIndex],y1:0,x2:e.xPositions[e.forecastIndex],y2:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),v?(0,n.jsx)("text",{x:e.xPositions[e.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:v}):null]}):null,(0,n.jsx)(Qe,{lines:e.lines,showMarkers:e.showMarkers}),S?(0,n.jsx)(q.ChartAnnotationLayer,{annotations:S,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,i.over?.(e.plot),p!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:e.xPositions[p],y1:0,x2:e.xPositions[p],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:h===null?"3 3":void 0}),z.map(t=>(0,n.jsx)("circle",{cx:e.xPositions[p],cy:e.yScale(t.value),r:4,fill:t.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},t.seriesKey))]}):null]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:d.hidden?null:(0,n.jsx)(we.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:d.label,size:Q})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:C?.hidden?null:(0,n.jsx)(we.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:C?.label,size:Q})})]}),y&&w!==!1?(0,n.jsx)(he.ChartTooltip,{x:e.margin.left+e.xPositions[y.index],y:e.margin.top+(z.length>0?Math.min(...z.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:u,children:typeof w=="function"?w(y):(0,n.jsx)(he.ChartTooltipContent,{title:y.xLabel,points:y.points})}):null]})}function et({data:u,series:a,x:r,y:s,height:d=240,width:C,size:b="md",grid:Q="y",legend:x,tooltip:M=!0,tableView:v=!1,emphasis:P,title:L,description:me,loading:S=!1,emptyState:fe,error:ge=!1,errorState:R,onRetry:Z,actions:ee,onPointClick:pe,curve:ye="monotone",forecastFrom:te,forecastLabel:w,markers:V="auto",connectNulls:Ce=!1,referenceLines:A,annotations:N,overlay:X,legendToggle:G=!0,maxPoints:h,brush:be=!1,onBrush:xe,brushLabel:ke,sync:m=!0,margin:e,locale:O,plotLabel:ne,className:ve,...g}){let T=(0,ie.useUILocale)(O),$=(0,ie.useUILabels)(),[B,Pe]=(0,l.useState)(()=>new Set),D=(0,l.useMemo)(()=>a.map((i,y)=>({...i,hidden:i.hidden||B.has(i.key),color:(0,W.resolveSeriesColor)(i,y,P)})),[a,B,P]),re=(0,l.useMemo)(()=>s?.format??(i=>(0,ce.formatAuto)(i,T)),[s?.format,T]),p=(0,l.useMemo)(()=>r.format??(i=>r.scale==="time"?(0,De.formatTimeValue)(i,T):(0,ce.formatXValue)(i,T)),[r.format,r.scale,T]),_=(0,l.useCallback)(i=>{Pe(y=>{let t=new Set(y);return t.has(i)?t.delete(i):t.add(i),t})},[]),z=x===void 0?a.length>=2:x!==!1,K=typeof x=="string"?x:"bottom",U=D.filter(i=>!i.hidden).length;return(0,n.jsx)(Be.ChartContainer,{title:L,description:me,height:d,width:C,size:b,loading:S,empty:u.length===0||U===0,emptyState:fe,error:ge,errorState:R,onRetry:Z,actions:ee,tableView:v,legendPosition:K,legend:z?(0,n.jsx)(He.ChartLegend,{items:(0,W.toLegendItems)(D,P),position:K,marker:"line",size:b,onToggle:G?_:void 0}):void 0,table:v?(0,n.jsx)(Ie.ChartTableView,{data:u,series:D,xKey:r.key,xLabel:r.label??r.key,formatX:p,formatValue:re,caption:typeof L=="string"?L:void 0}):void 0,className:ve,...g,children:({width:i})=>(0,n.jsx)(Ze,{width:i,height:d,data:u,resolvedSeries:D,x:r,y:s,grid:Q,size:b,curve:ye,forecastFrom:te,forecastLabel:w,markers:V,connectNulls:Ce,referenceLines:A,annotations:N,annotationsLabel:$.chartAnnotations,overlay:X,maxPoints:h,brush:be,onBrush:xe,brushLabel:ke??$.chartBrush,syncEnabled:m,margin:e,tooltip:M,onPointClick:pe,plotLabel:ne,formatValue:re,formatX:p})})}0&&(module.exports={LineChart});
|
|
1
|
+
"use strict";"use client";var Te=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Ye=(l,s)=>{for(var n in s)Te(l,n,{get:s[n],enumerable:!0})},qe=(l,s,n,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of ze(s))!Fe.call(l,c)&&c!==n&&Te(l,c,{get:()=>s[c],enumerable:!(a=je(s,c))||a.enumerable});return l};var Je=l=>qe(Te({},"__esModule",{value:!0}),l);var it={};Ye(it,{LineChart:()=>st,resetLineChartWarnings:()=>nt});module.exports=Je(it);var u=require("react"),Ne=require("../../lib/cn.cjs"),pe=require("../../lib/i18n.cjs"),Q=require("../chart/ChartAnnotations.cjs"),Be=require("../chart/ChartAxis.cjs"),G=require("../chart/ChartBrush.cjs"),Me=require("../chart/ChartContainer.cjs"),De=require("../chart/ChartGrid.cjs"),Ke=require("../chart/ChartLegend.cjs"),Xe=require("../chart/ChartSync.cjs"),Ge=require("../chart/ChartTableView.cjs"),ye=require("../chart/ChartTooltip.cjs"),P=require("../chart/palette.cjs"),m=require("../chart/utils/cartesian.cjs"),Z=require("../chart/utils/data.cjs"),Ce=require("../chart/utils/decimate.cjs"),O=require("../chart/utils/format.cjs"),be=require("../chart/utils/keyboard.cjs"),M=require("../chart/utils/path.cjs"),E=require("../chart/utils/scales.cjs"),Oe=require("../chart/utils/ticks.cjs"),ee=require("../chart/utils/timestamp.cjs"),_e=require("../chart/utils/touch.cjs"),o=require("react/jsx-runtime"),Qe=6,Ze=24,et=10,tt=10,He=!1;function nt(){He=!1}function rt(l,s){let n=(0,E.toKey)(s),a=l.findIndex(C=>(0,E.toKey)(C)===n);if(a>=0)return a;let c=(0,ee.toTimestamp)(s);return c===null?-1:l.findIndex(C=>{let b=(0,ee.toTimestamp)(C);return b!==null&&b>=c})}var ot=(0,u.memo)(function({lines:s,showMarkers:n}){return(0,o.jsx)("g",{children:s.map(a=>(0,o.jsxs)("g",{children:[a.solid?(0,o.jsx)("path",{d:a.solid,fill:"none",stroke:a.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,a.dashed?(0,o.jsx)("path",{d:a.dashed,fill:"none",stroke:a.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,(n?a.markers:a.isolated).map((c,C)=>(0,o.jsx)("circle",{cx:c.x,cy:c.y,r:3,fill:a.color,strokeWidth:2,stroke:P.CHART_SURFACE_COLOR},C))]},a.key))})});function at({width:l,height:s,data:n,resolvedSeries:a,x:c,y:C,grid:b,size:te,curve:w,forecastFrom:T,forecastLabel:B,markers:H,connectNulls:W,referenceLines:_,annotations:L,annotationsLabel:xe,overlay:ve,maxPoints:I,brush:ne,onBrush:re,brushLabel:ke,syncEnabled:Pe,margin:oe,tooltip:N,onPointClick:S,plotLabel:Le,formatValue:$,formatExact:ae,formatX:D,locale:se}){let[U,j]=(0,u.useState)(null),d=U!==null&&U<n.length?U:null,[Se,we]=(0,u.useState)(null),Re=(0,Xe.useChartSync)(),f=Pe?Re:null,e=(0,u.useMemo)(()=>{let t=a.filter(p=>!p.hidden),r=(0,m.buildCartesianGeometry)({locale:se,width:l,height:s,data:n,x:c,y:C,bounds:(0,m.widenBounds)((0,Oe.extent)((0,Z.collectAllValues)(n,t.map(p=>p.key))),(0,m.annotationValues)(n,c.key,_,L)),margin:oe,placement:"point",formatValue:$,formatX:D,extraTop:B?et:0}),h=r.categoryCenters,g=r.valueScale,V=T===void 0?-1:rt(r.xValues,T);T!==void 0&&V<0&&n.length>0&&!He&&(He=!0,console.warn(`[@synertech/ui] LineChart was given \`forecastFrom\` = ${String(T)}, which no row is on or after. Nothing is drawn as a forecast: pass the x value of the first projected row, in the form the rows carry it.`));let me=t.map(p=>{let Y=n.map((ge,Ue)=>{let Ee=(0,Z.readNumber)(ge,p.key);return{x:h[Ue],y:Ee===null?Number.NaN:g(Ee),defined:Ee!==null}}),We={connectNulls:W},fe=V>=0,Ae=ge=>I&&I>0?(0,Ce.decimatePath)(ge,I):ge,q=p.dashed?[]:Ae(fe?Y.slice(0,V+1):Y),J=p.dashed?Ae(Y):fe?Ae(Y.slice(V)):[];I||(0,Ce.warnPointBudget)("LineChart",Y.length);let $e=q[q.length-1],Ie=p.dashed?J:fe?[...q,...J[0]===$e?J.slice(1):J]:q;return{key:p.key,color:p.color,solid:p.dashed?"":(0,M.buildLinePath)(q,w,We),dashed:p.dashed||fe?(0,M.buildLinePath)(J,w,We):"",markers:Ie.filter(M.isDrawable),isolated:(0,M.isolatedPoints)(Ie,W)}}),A=n.length>1?r.innerWidth/(n.length-1):0;return{visible:t,locate:(0,m.createCategoryLocator)(r),span:(0,m.createSpanLocator)(r),plot:(0,m.createPlotContext)({geometry:r,width:l,height:s,data:n,series:t,formatValue:$,formatX:D}),xValues:r.xValues,xPositions:h,xTicks:r.categoryTicks,yTicks:r.valueTicks,yScale:g,innerWidth:r.innerWidth,innerHeight:r.innerHeight,margin:r.margin,lines:me,forecastIndex:V,showMarkers:H==="always"||H==="auto"&&A>=Ze&&n.length>1}},[se,n,a,c,C,l,s,oe,w,W,T,B,H,I,_,L,$,D]),z=(0,u.useCallback)(t=>e.visible.map(r=>{let h=(0,Z.readNumber)(n[t],r.key);return{seriesKey:r.key,seriesLabel:(0,P.getSeriesLabel)(r),color:r.color,value:h,formattedValue:h===null?"\u2014":ae(h),datum:n[t]}}),[n,e.visible,ae]),ie=f?f.brush:Se,x=(0,u.useCallback)(t=>{we(t),f?.setBrush(t),re?.(t)},[f,re]),y=(0,G.useChartBrush)({enabled:ne,active:ie!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:x}),le=(0,u.useCallback)(t=>{if(y.onPointerMove(t),N===!1||n.length===0)return;let r=t.currentTarget.getBoundingClientRect(),h=t.clientX-r.left-e.margin.left,g=(0,E.nearestIndex)(e.xPositions,h);j(g>=0?g:null),f?.setHovered(g>=0?e.xValues[g]:null)},[y,N,n.length,e.margin.left,e.xPositions,e.xValues,f]),ue=(0,u.useCallback)(()=>{j(null),f?.setHovered(null)},[f]),v=(0,u.useCallback)((t,r)=>{if(!S)return;let h=z(t),g=h.filter(A=>A.value!==null),V=A=>r===null?0:Math.abs(e.yScale(A.value)-r.y),me=g.length>0?g.reduce((A,p)=>V(p)<V(A)?p:A):h[0];me&&S({...me,index:t,x:e.xValues[t]})},[S,z,e.yScale,e.xValues]),Ve=(0,u.useCallback)(t=>{if(n.length===0)return;let r=S&&d!==null&&e.visible.length>0;if((0,be.pressChartMark)(t,r?()=>v(d,null):null))return;let h=y.onKeyDown(t,d),g=(0,be.chartCursorTarget)(t.key,d,n.length,"x");if(g===void 0){h&&t.preventDefault();return}t.preventDefault(),j(g),f?.setHovered(g===null?null:e.xValues[g])},[n.length,d,y,f,e.xValues,e.visible.length,S,v]),ce=(0,u.useCallback)(t=>{if(y.consumedClick()||!S||n.length===0)return;let r=(0,m.plotPointer)(t,e),h=d??(r===null?-1:(0,E.nearestIndex)(e.xPositions,r.x));h<0||v(h,r)},[y,S,n.length,e,d,v]),he=d!==null||f===null||f.hovered===null?null:(()=>{let t=(0,E.toKey)(f.hovered),r=e.xValues.findIndex(h=>(0,E.toKey)(h)===t);return r<0?null:r})(),R=d??he,F=R===null?null:z(R),K=(F??[]).filter(t=>t.value!==null),de=y.dragging??ie,i=de?(0,G.locateBrush)(de,e.xValues,e.xPositions,e.locate):null,X=(0,m.splitOverlay)(ve),k=d===null||F===null?null:{x:e.xValues[d],xLabel:D(e.xValues[d],d),index:d,points:F};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("svg",{width:l,height:s,role:"img","aria-label":Le??[e.visible.map(t=>(0,P.getSeriesLabel)(t)).join(", "),(0,Q.describeAnnotations)(L,xe)].filter(Boolean).join(". "),tabIndex:0,className:(0,Ne.cn)(_e.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",ne&&"select-none"),onPointerDown:y.onPointerDown,onPointerMove:le,onPointerUp:y.onPointerUp,onPointerCancel:y.onPointerUp,onPointerLeave:ue,onKeyDown:Ve,onBlur:ue,onClick:ce,children:[(0,o.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,o.jsx)(De.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:b==="y"||b==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:b==="x"||b==="both"?e.xTicks.map(t=>t.offset):void 0}),L?(0,o.jsx)(Q.ChartAnnotationLayer,{layer:"under",annotations:L,xAt:e.locate,spanAt:e.span,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,i?(0,o.jsx)(G.ChartBrushLayer,{from:i.from,to:i.to,width:e.innerWidth,height:e.innerHeight,live:y.dragging!==null,label:ke,minSpan:Qe}):null,X.under?.(e.plot),_?.map(t=>{let r=e.yScale(t.value),h=r<tt?r+12:r-4;return(0,o.jsxs)("g",{children:[(0,o.jsx)("line",{x1:0,y1:r,x2:e.innerWidth,y2:r,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,o.jsx)("text",{x:e.innerWidth,y:h,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),e.forecastIndex>=0?(0,o.jsxs)("g",{children:[(0,o.jsx)("line",{x1:e.xPositions[e.forecastIndex],y1:0,x2:e.xPositions[e.forecastIndex],y2:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),B?(0,o.jsx)("text",{x:e.xPositions[e.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:B}):null]}):null,(0,o.jsx)(ot,{lines:e.lines,showMarkers:e.showMarkers}),L?(0,o.jsx)(Q.ChartAnnotationLayer,{annotations:L,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,X.over?.(e.plot),R!==null?(0,o.jsxs)("g",{"aria-hidden":"true",children:[(0,o.jsx)("line",{x1:e.xPositions[R],y1:0,x2:e.xPositions[R],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:d===null?"3 3":void 0}),K.map(t=>(0,o.jsx)("circle",{cx:e.xPositions[R],cy:e.yScale(t.value),r:4,fill:t.color,strokeWidth:2,stroke:P.CHART_SURFACE_COLOR},t.seriesKey))]}):null]}),(0,o.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:c.hidden?null:(0,o.jsx)(Be.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:c.label,size:te})}),(0,o.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:C?.hidden?null:(0,o.jsx)(Be.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:C?.label,size:te})})]}),k&&N!==!1?(0,o.jsx)(ye.ChartTooltip,{x:e.margin.left+e.xPositions[k.index],y:e.margin.top+(K.length>0?Math.min(...K.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:l,children:typeof N=="function"?N(k):(0,o.jsx)(ye.ChartTooltipContent,{title:k.xLabel,points:k.points})}):null]})}function st({data:l,series:s,x:n,y:a,height:c=240,width:C,size:b="md",grid:te="y",legend:w,tooltip:T=!0,tableView:B=!1,emphasis:H,title:W,description:_,loading:L=!1,emptyState:xe,error:ve=!1,errorState:I,onRetry:ne,actions:re,onPointClick:ke,curve:Pe="monotone",forecastFrom:oe,forecastLabel:N,markers:S="auto",connectNulls:Le=!1,referenceLines:$,annotations:ae,overlay:D,legendToggle:se=!0,maxPoints:U,brush:j=!1,onBrush:d,brushLabel:Se,sync:we=!0,margin:Re,locale:f,plotLabel:e,className:z,...ie}){let x=(0,pe.useUILocale)(f),y=(0,pe.useUILabels)(),[le,ue]=(0,u.useState)(()=>new Set),v=(0,u.useMemo)(()=>s.map((i,X)=>({...i,hidden:i.hidden||le.has(i.key),color:(0,P.resolveSeriesColor)(i,X,H)})),[s,le,H]),Ve=(0,u.useMemo)(()=>a?.format??(i=>(0,O.formatAuto)(i,x)),[a?.format,x]),ce=(0,u.useMemo)(()=>a?.format??(i=>(0,O.formatExact)(i,x)),[a?.format,x]),he=(0,u.useMemo)(()=>n.format??(i=>n.scale==="time"?(0,ee.formatTimeValue)(i,x):(0,O.formatXValue)(i,x)),[n.format,n.scale,x]),R=(0,u.useCallback)(i=>{ue(X=>{let k=new Set(X);return k.has(i)?k.delete(i):k.add(i),k})},[]),F=w===void 0?s.length>=2:w!==!1,K=typeof w=="string"?w:"bottom",de=v.filter(i=>!i.hidden).length;return(0,o.jsx)(Me.ChartContainer,{title:W,description:_,height:c,width:C,size:b,loading:L,empty:l.length===0||de===0,emptyState:xe,error:ve,errorState:I,onRetry:ne,actions:re,exportSource:{data:l,series:v,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:B,legendPosition:K,legend:F?(0,o.jsx)(Ke.ChartLegend,{items:(0,P.toLegendItems)(v,H),position:K,marker:"line",size:b,onToggle:se?R:void 0}):void 0,table:B?(0,o.jsx)(Ge.ChartTableView,{data:l,series:v,xKey:n.key,xLabel:n.label??n.key,formatX:he,formatValue:ce,caption:typeof W=="string"?W:void 0}):void 0,className:z,...ie,children:({width:i})=>(0,o.jsx)(at,{locale:x,width:i,height:c,data:l,resolvedSeries:v,x:n,y:a,grid:te,size:b,curve:Pe,forecastFrom:oe,forecastLabel:N,markers:S,connectNulls:Le,referenceLines:$,annotations:ae,annotationsLabel:y.chartAnnotations,overlay:D,maxPoints:U,brush:j,onBrush:d,brushLabel:Se??y.chartBrush,syncEnabled:we,margin:Re,tooltip:T,onPointClick:ke,plotLabel:e,formatValue:Ve,formatExact:ce,formatX:he})})}0&&(module.exports={LineChart,resetLineChartWarnings});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as Ae,useCallback as x,useMemo as re,useState as ye}from"react";import{cn as Te}from"../../lib/cn.js";import{useUILabels as Be,useUILocale as Ee}from"../../lib/i18n.js";import{ChartAnnotationLayer as xe,describeAnnotations as He}from"../chart/ChartAnnotations.js";import{ChartAxis as ke}from"../chart/ChartAxis.js";import{ChartBrushLayer as We,useChartBrush as Ie}from"../chart/ChartBrush.js";import{ChartContainer as Ne}from"../chart/ChartContainer.js";import{ChartGrid as De}from"../chart/ChartGrid.js";import{ChartLegend as Ke}from"../chart/ChartLegend.js";import{useChartSync as Me}from"../chart/ChartSync.js";import{ChartTableView as Xe}from"../chart/ChartTableView.js";import{ChartTooltip as Ge,ChartTooltipContent as Oe}from"../chart/ChartTooltip.js";import{getSeriesLabel as ve,resolveSeriesColor as $e,toLegendItems as _e}from"../chart/palette.js";import{buildCartesianGeometry as ze,createCategoryLocator as Ue,createPlotContext as je,splitOverlay as Fe}from"../chart/utils/cartesian.js";import{collectAllValues as Ye,readNumber as Pe}from"../chart/utils/data.js";import{decimatePath as qe,warnPointBudget as Je}from"../chart/utils/decimate.js";import{formatAuto as Qe,formatXValue as Ze}from"../chart/utils/format.js";import{chartCursorTarget as et,pressChartMark as tt}from"../chart/utils/keyboard.js";import{buildLinePath as Le,isDrawable as nt,isolatedPoints as rt}from"../chart/utils/path.js";import{nearestIndex as ot,toKey as ne}from"../chart/utils/scales.js";import{extent as at}from"../chart/utils/ticks.js";import{formatTimeValue as st}from"../chart/utils/timestamp.js";import{CHART_TOUCH as it}from"../chart/utils/touch.js";import{Fragment as mt,jsx as o,jsxs as E}from"react/jsx-runtime";var lt=24,ht=10,ut=10,ct=Ae(function({lines:m,showMarkers:r}){return o("g",{children:m.map(i=>E("g",{children:[i.solid?o("path",{d:i.solid,fill:"none",stroke:i.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,i.dashed?o("path",{d:i.dashed,fill:"none",stroke:i.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,(r?i.markers:i.isolated).map((f,y)=>o("circle",{cx:f.x,cy:f.y,r:3,fill:i.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},y))]},i.key))})});function dt({width:d,height:m,data:r,resolvedSeries:i,x:f,y,grid:C,size:j,curve:b,forecastFrom:N,forecastLabel:k,markers:v,connectNulls:P,referenceLines:oe,annotations:L,annotationsLabel:ae,overlay:se,maxPoints:S,brush:F,onBrush:Y,brushLabel:ie,syncEnabled:le,margin:q,tooltip:R,onPointClick:w,plotLabel:he,formatValue:V,formatX:H}){let[D,K]=ye(null),s=D!==null&&D<r.length?D:null,[ue,ce]=ye(null),de=Me(),h=le?de:null,e=re(()=>{let t=i.filter(u=>!u.hidden),n=ze({width:d,height:m,data:r,x:f,y,bounds:at(Ye(r,t.map(u=>u.key))),margin:q,placement:"point",formatValue:V,formatX:H,extraTop:k?ht:0}),l=n.categoryCenters,B=n.valueScale,Z=N===void 0?-1:n.xValues.findIndex(u=>ne(u)===ne(N)),Se=t.map(u=>{let _=r.map((te,Ve)=>{let pe=Pe(te,u.key);return{x:l[Ve],y:pe===null?Number.NaN:B(pe),defined:pe!==null}}),Ce={connectNulls:P},ee=Z>=0,ge=te=>S&&S>0?qe(te,S):te,z=u.dashed?[]:ge(ee?_.slice(0,Z+1):_),U=u.dashed?ge(_):ee?ge(_.slice(Z)):[];S||Je("LineChart",_.length);let we=z[z.length-1],be=u.dashed?U:ee?[...z,...U[0]===we?U.slice(1):U]:z;return{key:u.key,color:u.color,solid:u.dashed?"":Le(z,b,Ce),dashed:u.dashed||ee?Le(U,b,Ce):"",markers:be.filter(nt),isolated:rt(be,P)}}),Re=r.length>1?n.innerWidth/(r.length-1):0;return{visible:t,locate:Ue(n),plot:je({geometry:n,width:d,height:m,data:r,series:t,formatValue:V,formatX:H}),xValues:n.xValues,xPositions:l,xTicks:n.categoryTicks,yTicks:n.valueTicks,yScale:B,innerWidth:n.innerWidth,innerHeight:n.innerHeight,margin:n.margin,lines:Se,forecastIndex:Z,showMarkers:v==="always"||v==="auto"&&Re>=lt&&r.length>1}},[r,i,f,y,d,m,q,b,P,N,k,v,S,V,H]),M=x(t=>e.visible.map(n=>{let l=Pe(r[t],n.key);return{seriesKey:n.key,seriesLabel:ve(n),color:n.color,value:l,formattedValue:l===null?"\u2014":V(l),datum:r[t]}}),[r,e.visible,V]),J=h?h.brush:ue,me=x(t=>{ce(t),h?.setBrush(t),Y?.(t)},[h,Y]),c=Ie({enabled:F,active:J!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:me}),A=x(t=>{if(c.onPointerMove(t),R===!1||r.length===0)return;let n=t.currentTarget.getBoundingClientRect(),l=t.clientX-n.left-e.margin.left,B=ot(e.xPositions,l);K(B>=0?B:null),h?.setHovered(B>=0?e.xValues[B]:null)},[c,R,r.length,e.margin.left,e.xPositions,e.xValues,h]),X=x(()=>{K(null),h?.setHovered(null)},[h]),T=x(()=>{if(!w||s===null)return;let[t]=M(s);t&&w({...t,index:s,x:e.xValues[s]})},[w,s,M,e.xValues]),fe=x(t=>{if(r.length===0)return;let n=w&&s!==null&&e.visible.length>0;if(tt(t,n?T:null))return;c.onKeyDown(t,s);let l=et(t.key,s,r.length,"x");l!==void 0&&(t.preventDefault(),K(l),h?.setHovered(l===null?null:e.xValues[l]))},[r.length,s,c,h,e.xValues,e.visible.length,w,T]),W=x(()=>{c.consumedClick()||T()},[c,T]),Q=s!==null||!h?.hovered?null:(()=>{let t=ne(h.hovered),n=e.xValues.findIndex(l=>ne(l)===t);return n<0?null:n})(),g=s??Q,G=g===null?null:M(g),O=(G??[]).filter(t=>t.value!==null),I=c.dragging??J,$=(()=>{if(!I)return null;let t=e.locate(I.from),n=e.locate(I.to);return t===null||n===null?null:{from:t,to:n}})(),a=Fe(se),p=s===null||G===null?null:{x:e.xValues[s],xLabel:H(e.xValues[s],s),index:s,points:G};return E(mt,{children:[E("svg",{width:d,height:m,role:"img","aria-label":he??[e.visible.map(t=>ve(t)).join(", "),He(L,ae)].filter(Boolean).join(". "),tabIndex:0,className:Te(it,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",F&&"select-none"),onPointerDown:c.onPointerDown,onPointerMove:A,onPointerUp:c.onPointerUp,onPointerCancel:c.onPointerUp,onPointerLeave:X,onKeyDown:fe,onBlur:X,onClick:W,children:[E("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[o(De,{width:e.innerWidth,height:e.innerHeight,horizontal:C==="y"||C==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:C==="x"||C==="both"?e.xTicks.map(t=>t.offset):void 0}),L?o(xe,{layer:"under",annotations:L,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,$?o(We,{from:$.from,to:$.to,width:e.innerWidth,height:e.innerHeight,live:c.dragging!==null,label:ie}):null,a.under?.(e.plot),oe?.map(t=>{let n=e.yScale(t.value),l=n<ut?n+12:n-4;return E("g",{children:[o("line",{x1:0,y1:n,x2:e.innerWidth,y2:n,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?o("text",{x:e.innerWidth,y:l,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),e.forecastIndex>=0?E("g",{children:[o("line",{x1:e.xPositions[e.forecastIndex],y1:0,x2:e.xPositions[e.forecastIndex],y2:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),k?o("text",{x:e.xPositions[e.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:k}):null]}):null,o(ct,{lines:e.lines,showMarkers:e.showMarkers}),L?o(xe,{annotations:L,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,a.over?.(e.plot),g!==null?E("g",{"aria-hidden":"true",children:[o("line",{x1:e.xPositions[g],y1:0,x2:e.xPositions[g],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:s===null?"3 3":void 0}),O.map(t=>o("circle",{cx:e.xPositions[g],cy:e.yScale(t.value),r:4,fill:t.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},t.seriesKey))]}):null]}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:f.hidden?null:o(ke,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:f.label,size:j})}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:o(ke,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:j})})]}),p&&R!==!1?o(Ge,{x:e.margin.left+e.xPositions[p.index],y:e.margin.top+(O.length>0?Math.min(...O.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:d,children:typeof R=="function"?R(p):o(Oe,{title:p.xLabel,points:p.points})}):null]})}function Dt({data:d,series:m,x:r,y:i,height:f=240,width:y,size:C="md",grid:j="y",legend:b,tooltip:N=!0,tableView:k=!1,emphasis:v,title:P,description:oe,loading:L=!1,emptyState:ae,error:se=!1,errorState:S,onRetry:F,actions:Y,onPointClick:ie,curve:le="monotone",forecastFrom:q,forecastLabel:R,markers:w="auto",connectNulls:he=!1,referenceLines:V,annotations:H,overlay:D,legendToggle:K=!0,maxPoints:s,brush:ue=!1,onBrush:ce,brushLabel:de,sync:h=!0,margin:e,locale:M,plotLabel:J,className:me,...c}){let A=Ee(M),X=Be(),[T,fe]=ye(()=>new Set),W=re(()=>m.map((a,p)=>({...a,hidden:a.hidden||T.has(a.key),color:$e(a,p,v)})),[m,T,v]),Q=re(()=>i?.format??(a=>Qe(a,A)),[i?.format,A]),g=re(()=>r.format??(a=>r.scale==="time"?st(a,A):Ze(a,A)),[r.format,r.scale,A]),G=x(a=>{fe(p=>{let t=new Set(p);return t.has(a)?t.delete(a):t.add(a),t})},[]),O=b===void 0?m.length>=2:b!==!1,I=typeof b=="string"?b:"bottom",$=W.filter(a=>!a.hidden).length;return o(Ne,{title:P,description:oe,height:f,width:y,size:C,loading:L,empty:d.length===0||$===0,emptyState:ae,error:se,errorState:S,onRetry:F,actions:Y,tableView:k,legendPosition:I,legend:O?o(Ke,{items:_e(W,v),position:I,marker:"line",size:C,onToggle:K?G:void 0}):void 0,table:k?o(Xe,{data:d,series:W,xKey:r.key,xLabel:r.label??r.key,formatX:g,formatValue:Q,caption:typeof P=="string"?P:void 0}):void 0,className:me,...c,children:({width:a})=>o(dt,{width:a,height:f,data:d,resolvedSeries:W,x:r,y:i,grid:j,size:C,curve:le,forecastFrom:q,forecastLabel:R,markers:w,connectNulls:he,referenceLines:V,annotations:H,annotationsLabel:X.chartAnnotations,overlay:D,maxPoints:s,brush:ue,onBrush:ce,brushLabel:de??X.chartBrush,syncEnabled:h,margin:e,tooltip:N,onPointClick:ie,plotLabel:J,formatValue:Q,formatX:g})})}export{Dt as LineChart};
|
|
1
|
+
"use client";import{memo as Ie,useCallback as R,useMemo as z,useState as ve}from"react";import{cn as Ne}from"../../lib/cn.js";import{useUILabels as Me,useUILocale as De}from"../../lib/i18n.js";import{ChartAnnotationLayer as Se,describeAnnotations as Ke}from"../chart/ChartAnnotations.js";import{ChartAxis as we}from"../chart/ChartAxis.js";import{ChartBrushLayer as Xe,locateBrush as Ge,useChartBrush as Oe}from"../chart/ChartBrush.js";import{ChartContainer as _e}from"../chart/ChartContainer.js";import{ChartGrid as $e}from"../chart/ChartGrid.js";import{ChartLegend as Ue}from"../chart/ChartLegend.js";import{useChartSync as je}from"../chart/ChartSync.js";import{ChartTableView as ze}from"../chart/ChartTableView.js";import{ChartTooltip as Fe,ChartTooltipContent as Ye}from"../chart/ChartTooltip.js";import{CHART_SURFACE_COLOR as Be,getSeriesLabel as Re,resolveSeriesColor as qe,toLegendItems as Je}from"../chart/palette.js";import{annotationValues as Qe,buildCartesianGeometry as Ze,createCategoryLocator as et,createPlotContext as tt,createSpanLocator as nt,plotPointer as rt,splitOverlay as ot,widenBounds as at}from"../chart/utils/cartesian.js";import{collectAllValues as st,readNumber as Ve}from"../chart/utils/data.js";import{decimatePath as it,warnPointBudget as lt}from"../chart/utils/decimate.js";import{formatAuto as ut,formatExact as ct,formatXValue as ht}from"../chart/utils/format.js";import{chartCursorTarget as dt,pressChartMark as mt}from"../chart/utils/keyboard.js";import{buildLinePath as Ae,isDrawable as ft,isolatedPoints as gt}from"../chart/utils/path.js";import{nearestIndex as Ee,toKey as ue}from"../chart/utils/scales.js";import{extent as pt}from"../chart/utils/ticks.js";import{formatTimeValue as yt,toTimestamp as Te}from"../chart/utils/timestamp.js";import{CHART_TOUCH as bt}from"../chart/utils/touch.js";import{Fragment as wt,jsx as o,jsxs as W}from"react/jsx-runtime";var Ct=6,xt=24,vt=10,kt=10,ke=!1;function qt(){ke=!1}function Pt(d,g){let n=ue(g),s=d.findIndex(p=>ue(p)===n);if(s>=0)return s;let m=Te(g);return m===null?-1:d.findIndex(p=>{let y=Te(p);return y!==null&&y>=m})}var Lt=Ie(function({lines:g,showMarkers:n}){return o("g",{children:g.map(s=>W("g",{children:[s.solid?o("path",{d:s.solid,fill:"none",stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,s.dashed?o("path",{d:s.dashed,fill:"none",stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,(n?s.markers:s.isolated).map((m,p)=>o("circle",{cx:m.x,cy:m.y,r:3,fill:s.color,strokeWidth:2,stroke:Be},p))]},s.key))})});function St({width:d,height:g,data:n,resolvedSeries:s,x:m,y:p,grid:y,size:F,curve:P,forecastFrom:V,forecastLabel:A,markers:E,connectNulls:T,referenceLines:D,annotations:v,annotationsLabel:ce,overlay:he,maxPoints:B,brush:Y,onBrush:q,brushLabel:de,syncEnabled:me,margin:J,tooltip:H,onPointClick:k,plotLabel:fe,formatValue:K,formatExact:Q,formatX:I,locale:Z}){let[X,G]=ve(null),l=X!==null&&X<n.length?X:null,[ge,pe]=ve(null),ye=je(),u=me?ye:null,e=z(()=>{let t=s.filter(h=>!h.hidden),r=Ze({locale:Z,width:d,height:g,data:n,x:m,y:p,bounds:at(pt(st(n,t.map(h=>h.key))),Qe(n,m.key,D,v)),margin:J,placement:"point",formatValue:K,formatX:I,extraTop:A?vt:0}),i=r.categoryCenters,c=r.valueScale,S=V===void 0?-1:Pt(r.xValues,V);V!==void 0&&S<0&&n.length>0&&!ke&&(ke=!0,console.warn(`[@synertech/ui] LineChart was given \`forecastFrom\` = ${String(V)}, which no row is on or after. Nothing is drawn as a forecast: pass the x value of the first projected row, in the form the rows carry it.`));let se=t.map(h=>{let $=n.map((le,We)=>{let xe=Ve(le,h.key);return{x:i[We],y:xe===null?Number.NaN:c(xe),defined:xe!==null}}),Pe={connectNulls:T},ie=S>=0,be=le=>B&&B>0?it(le,B):le,U=h.dashed?[]:be(ie?$.slice(0,S+1):$),j=h.dashed?be($):ie?be($.slice(S)):[];B||lt("LineChart",$.length);let He=U[U.length-1],Le=h.dashed?j:ie?[...U,...j[0]===He?j.slice(1):j]:U;return{key:h.key,color:h.color,solid:h.dashed?"":Ae(U,P,Pe),dashed:h.dashed||ie?Ae(j,P,Pe):"",markers:Le.filter(ft),isolated:gt(Le,T)}}),w=n.length>1?r.innerWidth/(n.length-1):0;return{visible:t,locate:et(r),span:nt(r),plot:tt({geometry:r,width:d,height:g,data:n,series:t,formatValue:K,formatX:I}),xValues:r.xValues,xPositions:i,xTicks:r.categoryTicks,yTicks:r.valueTicks,yScale:c,innerWidth:r.innerWidth,innerHeight:r.innerHeight,margin:r.margin,lines:se,forecastIndex:S,showMarkers:E==="always"||E==="auto"&&w>=xt&&n.length>1}},[Z,n,s,m,p,d,g,J,P,T,V,A,E,B,D,v,K,I]),O=R(t=>e.visible.map(r=>{let i=Ve(n[t],r.key);return{seriesKey:r.key,seriesLabel:Re(r),color:r.color,value:i,formattedValue:i===null?"\u2014":Q(i),datum:n[t]}}),[n,e.visible,Q]),ee=u?u.brush:ge,C=R(t=>{pe(t),u?.setBrush(t),q?.(t)},[u,q]),f=Oe({enabled:Y,active:ee!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:C}),te=R(t=>{if(f.onPointerMove(t),H===!1||n.length===0)return;let r=t.currentTarget.getBoundingClientRect(),i=t.clientX-r.left-e.margin.left,c=Ee(e.xPositions,i);G(c>=0?c:null),u?.setHovered(c>=0?e.xValues[c]:null)},[f,H,n.length,e.margin.left,e.xPositions,e.xValues,u]),ne=R(()=>{G(null),u?.setHovered(null)},[u]),b=R((t,r)=>{if(!k)return;let i=O(t),c=i.filter(w=>w.value!==null),S=w=>r===null?0:Math.abs(e.yScale(w.value)-r.y),se=c.length>0?c.reduce((w,h)=>S(h)<S(w)?h:w):i[0];se&&k({...se,index:t,x:e.xValues[t]})},[k,O,e.yScale,e.xValues]),Ce=R(t=>{if(n.length===0)return;let r=k&&l!==null&&e.visible.length>0;if(mt(t,r?()=>b(l,null):null))return;let i=f.onKeyDown(t,l),c=dt(t.key,l,n.length,"x");if(c===void 0){i&&t.preventDefault();return}t.preventDefault(),G(c),u?.setHovered(c===null?null:e.xValues[c])},[n.length,l,f,u,e.xValues,e.visible.length,k,b]),re=R(t=>{if(f.consumedClick()||!k||n.length===0)return;let r=rt(t,e),i=l??(r===null?-1:Ee(e.xPositions,r.x));i<0||b(i,r)},[f,k,n.length,e,l,b]),oe=l!==null||u===null||u.hovered===null?null:(()=>{let t=ue(u.hovered),r=e.xValues.findIndex(i=>ue(i)===t);return r<0?null:r})(),L=l??oe,_=L===null?null:O(L),N=(_??[]).filter(t=>t.value!==null),ae=f.dragging??ee,a=ae?Ge(ae,e.xValues,e.xPositions,e.locate):null,M=ot(he),x=l===null||_===null?null:{x:e.xValues[l],xLabel:I(e.xValues[l],l),index:l,points:_};return W(wt,{children:[W("svg",{width:d,height:g,role:"img","aria-label":fe??[e.visible.map(t=>Re(t)).join(", "),Ke(v,ce)].filter(Boolean).join(". "),tabIndex:0,className:Ne(bt,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",Y&&"select-none"),onPointerDown:f.onPointerDown,onPointerMove:te,onPointerUp:f.onPointerUp,onPointerCancel:f.onPointerUp,onPointerLeave:ne,onKeyDown:Ce,onBlur:ne,onClick:re,children:[W("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[o($e,{width:e.innerWidth,height:e.innerHeight,horizontal:y==="y"||y==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:y==="x"||y==="both"?e.xTicks.map(t=>t.offset):void 0}),v?o(Se,{layer:"under",annotations:v,xAt:e.locate,spanAt:e.span,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,a?o(Xe,{from:a.from,to:a.to,width:e.innerWidth,height:e.innerHeight,live:f.dragging!==null,label:de,minSpan:Ct}):null,M.under?.(e.plot),D?.map(t=>{let r=e.yScale(t.value),i=r<kt?r+12:r-4;return W("g",{children:[o("line",{x1:0,y1:r,x2:e.innerWidth,y2:r,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?o("text",{x:e.innerWidth,y:i,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),e.forecastIndex>=0?W("g",{children:[o("line",{x1:e.xPositions[e.forecastIndex],y1:0,x2:e.xPositions[e.forecastIndex],y2:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,strokeDasharray:"3 3"}),A?o("text",{x:e.xPositions[e.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:A}):null]}):null,o(Lt,{lines:e.lines,showMarkers:e.showMarkers}),v?o(Se,{annotations:v,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,M.over?.(e.plot),L!==null?W("g",{"aria-hidden":"true",children:[o("line",{x1:e.xPositions[L],y1:0,x2:e.xPositions[L],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:l===null?"3 3":void 0}),N.map(t=>o("circle",{cx:e.xPositions[L],cy:e.yScale(t.value),r:4,fill:t.color,strokeWidth:2,stroke:Be},t.seriesKey))]}):null]}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:m.hidden?null:o(we,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:m.label,size:F})}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:p?.hidden?null:o(we,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:p?.label,size:F})})]}),x&&H!==!1?o(Fe,{x:e.margin.left+e.xPositions[x.index],y:e.margin.top+(N.length>0?Math.min(...N.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:d,children:typeof H=="function"?H(x):o(Ye,{title:x.xLabel,points:x.points})}):null]})}function Jt({data:d,series:g,x:n,y:s,height:m=240,width:p,size:y="md",grid:F="y",legend:P,tooltip:V=!0,tableView:A=!1,emphasis:E,title:T,description:D,loading:v=!1,emptyState:ce,error:he=!1,errorState:B,onRetry:Y,actions:q,onPointClick:de,curve:me="monotone",forecastFrom:J,forecastLabel:H,markers:k="auto",connectNulls:fe=!1,referenceLines:K,annotations:Q,overlay:I,legendToggle:Z=!0,maxPoints:X,brush:G=!1,onBrush:l,brushLabel:ge,sync:pe=!0,margin:ye,locale:u,plotLabel:e,className:O,...ee}){let C=De(u),f=Me(),[te,ne]=ve(()=>new Set),b=z(()=>g.map((a,M)=>({...a,hidden:a.hidden||te.has(a.key),color:qe(a,M,E)})),[g,te,E]),Ce=z(()=>s?.format??(a=>ut(a,C)),[s?.format,C]),re=z(()=>s?.format??(a=>ct(a,C)),[s?.format,C]),oe=z(()=>n.format??(a=>n.scale==="time"?yt(a,C):ht(a,C)),[n.format,n.scale,C]),L=R(a=>{ne(M=>{let x=new Set(M);return x.has(a)?x.delete(a):x.add(a),x})},[]),_=P===void 0?g.length>=2:P!==!1,N=typeof P=="string"?P:"bottom",ae=b.filter(a=>!a.hidden).length;return o(_e,{title:T,description:D,height:m,width:p,size:y,loading:v,empty:d.length===0||ae===0,emptyState:ce,error:he,errorState:B,onRetry:Y,actions:q,exportSource:{data:d,series:b,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:A,legendPosition:N,legend:_?o(Ue,{items:Je(b,E),position:N,marker:"line",size:y,onToggle:Z?L:void 0}):void 0,table:A?o(ze,{data:d,series:b,xKey:n.key,xLabel:n.label??n.key,formatX:oe,formatValue:re,caption:typeof T=="string"?T:void 0}):void 0,className:O,...ee,children:({width:a})=>o(St,{locale:C,width:a,height:m,data:d,resolvedSeries:b,x:n,y:s,grid:F,size:y,curve:me,forecastFrom:J,forecastLabel:H,markers:k,connectNulls:fe,referenceLines:K,annotations:Q,annotationsLabel:f.chartAnnotations,overlay:I,maxPoints:X,brush:G,onBrush:l,brushLabel:ge??f.chartBrush,syncEnabled:pe,margin:ye,tooltip:V,onPointClick:de,plotLabel:e,formatValue:Ce,formatExact:re,formatX:oe})})}export{Jt as LineChart,qt as resetLineChartWarnings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var C=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Re=(t,o)=>{for(var a in o)C(t,a,{get:o[a],enumerable:!0})},je=(t,o,a,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of De(o))!Ee.call(t,s)&&s!==a&&C(t,s,{get:()=>o[s],enumerable:!(c=Te(o,s))||c.enumerable});return t};var He=t=>je(C({},"__esModule",{value:!0}),t);var We={};Re(We,{Modal:()=>z,resetModalTitleWarning:()=>Ie});module.exports=He(We);var r=require("react"),I=require("../../hooks/useDialogA11y.cjs"),l=require("../../lib/cn.cjs"),O=require("../../lib/i18n.cjs"),W=require("../../lib/layer-document.cjs"),e=require("react/jsx-runtime"),Be={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"};function Ae(t){return typeof t=="object"&&t!==null&&typeof t.then=="function"}var F=!1;function Ie(){F=!1}function Oe(t){F||(F=!0,console.warn(`[@synertech/ui] Modal has no \`title\`: the placeholder "${t}" is shown in its place. Pass a \`title\`, or an \`aria-label\` for a dialog without a visible title.`))}var z=(0,r.forwardRef)(({isOpen:t,open:o,onClose:a,title:c,children:s,buttonLabel:$,onButtonClick:U,className:V,panelClassName:q,allowFullScreen:G=!1,showSubmit:S=!0,submitLabel:J,onSubmitClick:K,closeOnSubmit:Q=!0,onSubmitError:P,showCancel:T=!1,cancelLabel:X,onCancelClick:Y,buttonsPosition:D="right",showHeaderDivider:Z=!0,showFooterDivider:_=!0,description:x,icon:E,size:ee="md",reverseButtons:te=!1,headerClassName:re,contentClassName:ne,footerClassName:oe,titleClassName:le,descriptionClassName:ae,submitClassName:se,cancelClassName:ie,closeLabel:de,enterFullScreenLabel:ue,exitFullScreenLabel:ce,"aria-label":w,closeOnEscape:me=!0,trapFocus:be=!0,initialFocus:ge,returnFocus:fe,lockScroll:ve=!0},pe)=>{let m=o??t??!1,[b,ye]=(0,r.useState)(!1),[i,k]=(0,r.useState)(null),d=(0,O.useUILabels)(),he=c===void 0&&!w,v=c??(w?"":d.modalDefaultTitle),R=(0,r.useId)(),j=`${R}-title`,H=`${R}-description`,{dialogRef:N,dialogProps:xe}=(0,I.useDialogA11y)({open:m,onClose:a,closeOnEscape:me,trapFocus:be,initialFocus:ge,returnFocus:fe,lockScroll:ve}),M=(0,r.useRef)(0),g=(0,r.useRef)(!1),p=(0,r.useRef)(null);if((0,r.useEffect)(()=>{if(m)return()=>{M.current+=1,g.current=!1,p.current=null,k(null)}},[m]),(0,r.useEffect)(()=>{if(i!==null)return;let n=p.current;p.current=null;let u=N.current;if(!n||!u||!u.contains(n))return;let y=u.ownerDocument.activeElement;(!y||y===u.ownerDocument.body)&&n.focus()},[i,N]),!m)return null;he&&Oe(v);let we=$??J??d.confirm,ke=X??d.cancel,Ne=de??d.closeModal,Me=b?ce??d.exitFullScreen:ue??d.enterFullScreen,Le=U??K,B=async(n,u,y)=>{if(g.current)return;let Pe=M.current,L,h=null;try{let f=u?.();Ae(f)?(g.current=!0,p.current=y,k(n),L=await f):L=f}catch(f){h={error:f}}let A=M.current===Pe;if(A&&g.current&&(g.current=!1,k(null)),h){if(n==="submit"&&P){P(h.error);return}throw h.error}!A||L===!1||n==="submit"&&!Q||a()},Ce=n=>B("submit",Le,n.currentTarget),Fe=n=>B("cancel",Y,n.currentTarget),Se=(0,e.jsx)("div",{className:(0,l.cn)("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",V),"aria-hidden":!m,children:(0,e.jsx)("div",{className:(0,l.cn)("relative p-4 w-full max-h-full transition-all duration-300",b?"max-w-full h-full p-0":Be[ee]),ref:pe,children:(0,e.jsxs)("div",{...xe,ref:N,"aria-labelledby":v?j:void 0,"aria-label":v?void 0:w,"aria-describedby":x?H:void 0,className:(0,l.cn)("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",b?"rounded-none h-full flex flex-col":"rounded-lg",q),children:[(0,e.jsxs)("div",{className:(0,l.cn)("flex items-center justify-between p-4 md:p-5 rounded-t",Z&&"border-b border-gray-200 dark:border-gray-600",re),children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[E&&(0,e.jsx)("div",{className:"shrink-0 text-gray-500 dark:text-gray-300",children:E}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{id:j,className:(0,l.cn)("text-xl font-semibold text-gray-900 dark:text-white",le),children:v}),x&&(0,e.jsx)("p",{id:H,className:(0,l.cn)("mt-1 text-sm text-gray-500 dark:text-gray-300",ae),children:x})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 ms-auto",children:[G&&(0,e.jsx)("button",{type:"button",onClick:()=>ye(n=>!n),className:"text-gray-500 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white","aria-label":Me,children:b?(0,e.jsx)("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):(0,e.jsx)("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),(0,e.jsxs)("button",{type:"button",onClick:a,className:"text-gray-500 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white",children:[(0,e.jsx)("svg",{className:"w-3 h-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),(0,e.jsx)("span",{className:"sr-only",children:Ne})]})]})]}),(0,e.jsx)("div",{className:(0,l.cn)("p-4 md:p-5 space-y-4",b&&"flex-1 overflow-y-auto",ne),children:s}),(S||T)&&(0,e.jsxs)("div",{className:(0,l.cn)("flex items-center gap-2 p-4 md:p-5 rounded-b",_&&"border-t border-gray-200 dark:border-gray-600",D==="right"?"justify-end":D==="center"?"justify-center":"justify-start",te&&"flex-row-reverse",oe),children:[T&&(0,e.jsx)("button",{type:"button",onClick:Fe,disabled:i!==null,"aria-busy":i==="cancel"||void 0,className:(0,l.cn)("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",ie),children:ke}),S&&(0,e.jsx)("button",{type:"button",onClick:Ce,disabled:i!==null,"aria-busy":i==="submit"||void 0,className:(0,l.cn)("text-synertech-on-primary bg-synertech-primary-600 hover:bg-synertech-primary-700 focus:ring-4 focus:outline-none focus:ring-synertech-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center disabled:opacity-50 disabled:cursor-not-allowed",se),children:we})]})]})})});return(0,e.jsx)(W.LayerPortal,{children:Se})});z.displayName="Modal";0&&(module.exports={Modal,resetModalTitleWarning});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{forwardRef as Se,useEffect as
|
|
1
|
+
"use client";import{forwardRef as Se,useEffect as B,useId as Pe,useRef as N,useState as A}from"react";import{useDialogA11y as Te}from"../../hooks/useDialogA11y.js";import{cn as r}from"../../lib/cn.js";import{useUILabels as De}from"../../lib/i18n.js";import{LayerPortal as Ee}from"../../lib/layer-document.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";var Re={sm:"max-w-sm",md:"max-w-2xl",lg:"max-w-4xl",xl:"max-w-6xl",full:"max-w-full"};function je(n){return typeof n=="object"&&n!==null&&typeof n.then=="function"}var M=!1;function $e(){M=!1}function He(n){M||(M=!0,console.warn(`[@synertech/ui] Modal has no \`title\`: the placeholder "${n}" is shown in its place. Pass a \`title\`, or an \`aria-label\` for a dialog without a visible title.`))}var Be=Se(({isOpen:n,open:I,onClose:v,title:L,children:O,buttonLabel:W,onButtonClick:z,className:$,panelClassName:U,allowFullScreen:V=!1,showSubmit:C=!0,submitLabel:q,onSubmitClick:G,closeOnSubmit:J=!0,onSubmitError:F,showCancel:S=!1,cancelLabel:K,onCancelClick:Q,buttonsPosition:P="right",showHeaderDivider:X=!0,showFooterDivider:Y=!0,description:p,icon:T,size:Z="md",reverseButtons:_=!1,headerClassName:ee,contentClassName:te,footerClassName:re,titleClassName:ne,descriptionClassName:oe,submitClassName:le,cancelClassName:ae,closeLabel:se,enterFullScreenLabel:ie,exitFullScreenLabel:de,"aria-label":y,closeOnEscape:ue=!0,trapFocus:ce=!0,initialFocus:me,returnFocus:be,lockScroll:ge=!0},fe)=>{let i=I??n??!1,[d,ve]=A(!1),[l,h]=A(null),a=De(),pe=L===void 0&&!y,m=L??(y?"":a.modalDefaultTitle),D=Pe(),E=`${D}-title`,R=`${D}-description`,{dialogRef:x,dialogProps:ye}=Te({open:i,onClose:v,closeOnEscape:ue,trapFocus:ce,initialFocus:me,returnFocus:be,lockScroll:ge}),w=N(0),u=N(!1),b=N(null);if(B(()=>{if(i)return()=>{w.current+=1,u.current=!1,b.current=null,h(null)}},[i]),B(()=>{if(l!==null)return;let t=b.current;b.current=null;let s=x.current;if(!t||!s||!s.contains(t))return;let g=s.ownerDocument.activeElement;(!g||g===s.ownerDocument.body)&&t.focus()},[l,x]),!i)return null;pe&&He(m);let he=W??q??a.confirm,xe=K??a.cancel,we=se??a.closeModal,ke=d?de??a.exitFullScreen:ie??a.enterFullScreen,Ne=z??G,j=async(t,s,g)=>{if(u.current)return;let Fe=w.current,k,f=null;try{let c=s?.();je(c)?(u.current=!0,b.current=g,h(t),k=await c):k=c}catch(c){f={error:c}}let H=w.current===Fe;if(H&&u.current&&(u.current=!1,h(null)),f){if(t==="submit"&&F){F(f.error);return}throw f.error}!H||k===!1||t==="submit"&&!J||v()},Me=t=>j("submit",Ne,t.currentTarget),Le=t=>j("cancel",Q,t.currentTarget),Ce=e("div",{className:r("overflow-y-auto overflow-x-hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",$),"aria-hidden":!i,children:e("div",{className:r("relative p-4 w-full max-h-full transition-all duration-300",d?"max-w-full h-full p-0":Re[Z]),ref:fe,children:o("div",{...ye,ref:x,"aria-labelledby":m?E:void 0,"aria-label":m?void 0:y,"aria-describedby":p?R:void 0,className:r("relative bg-white shadow dark:bg-gray-700 border-b-4 transition-all duration-300 focus:outline-none",d?"rounded-none h-full flex flex-col":"rounded-lg",U),children:[o("div",{className:r("flex items-center justify-between p-4 md:p-5 rounded-t",X&&"border-b border-gray-200 dark:border-gray-600",ee),children:[o("div",{className:"flex items-center gap-3",children:[T&&e("div",{className:"shrink-0 text-gray-500 dark:text-gray-300",children:T}),o("div",{children:[e("h3",{id:E,className:r("text-xl font-semibold text-gray-900 dark:text-white",ne),children:m}),p&&e("p",{id:R,className:r("mt-1 text-sm text-gray-500 dark:text-gray-300",oe),children:p})]})]}),o("div",{className:"flex items-center gap-1 ms-auto",children:[V&&e("button",{type:"button",onClick:()=>ve(t=>!t),className:"text-gray-500 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white","aria-label":ke,children:d?e("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:e("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 1H1v6m16 0V1h-6m0 16h6v-6M1 11v6h6"})}):e("svg",{className:"w-3.5 h-3.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18",children:e("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M11 1h6v6M1 11v6h6m0-12L1 1m16 16-6-6"})})}),o("button",{type:"button",onClick:v,className:"text-gray-500 dark:text-gray-300 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white",children:[e("svg",{className:"w-3 h-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:e("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),e("span",{className:"sr-only",children:we})]})]})]}),e("div",{className:r("p-4 md:p-5 space-y-4",d&&"flex-1 overflow-y-auto",te),children:O}),(C||S)&&o("div",{className:r("flex items-center gap-2 p-4 md:p-5 rounded-b",Y&&"border-t border-gray-200 dark:border-gray-600",P==="right"?"justify-end":P==="center"?"justify-center":"justify-start",_&&"flex-row-reverse",re),children:[S&&e("button",{type:"button",onClick:Le,disabled:l!==null,"aria-busy":l==="cancel"||void 0,className:r("text-gray-500 bg-white hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 font-medium rounded-lg text-sm px-5 py-2.5 border border-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-600 dark:hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",ae),children:xe}),C&&e("button",{type:"button",onClick:Me,disabled:l!==null,"aria-busy":l==="submit"||void 0,className:r("text-synertech-on-primary bg-synertech-primary-600 hover:bg-synertech-primary-700 focus:ring-4 focus:outline-none focus:ring-synertech-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center disabled:opacity-50 disabled:cursor-not-allowed",le),children:he})]})]})})});return e(Ee,{children:Ce})});Be.displayName="Modal";export{Be as Modal,$e as resetModalTitleWarning};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var L=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var L=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var D=(t,r)=>{for(var o in r)L(t,o,{get:r[o],enumerable:!0})},G=(t,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of q(r))!z.call(t,i)&&i!==o&&L(t,i,{get:()=>r[i],enumerable:!(n=$(r,i))||n.enumerable});return t};var H=t=>G(L({},"__esModule",{value:!0}),t);var Z={};D(Z,{Pagination:()=>Y});module.exports=H(Z);var x=require("react"),d=require("../../lib/cn.cjs"),M=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function J(t,r,o,n){let i=(f,l)=>Array.from({length:Math.max(0,l-f+1)},(p,m)=>f+m);if(r<=n*2+o*2+3)return i(1,r);let b=Math.max(Math.min(t-o,r-n-o*2-1),n+2),v=Math.min(Math.max(t+o,n+o*2+2),r-n-1);return[...i(1,n),b>n+2?"ellipsis":n+1,...i(b,v),v<r-n-1?"ellipsis":r-n,...i(r-n+1,r)]}function K({className:t}){return(0,e.jsx)("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function Q({className:t}){return(0,e.jsx)("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function S({className:t}){return(0,e.jsx)("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function T({className:t}){return(0,e.jsx)("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var V={sm:{button:"h-7 min-w-7 px-1.5 text-xs",icon:"h-3 w-3",gap:"gap-0.5",text:"text-xs"},md:{button:"h-9 min-w-9 px-2.5 text-sm",icon:"h-4 w-4",gap:"gap-1",text:"text-sm"},lg:{button:"h-11 min-w-11 px-3.5 text-base",icon:"h-5 w-5",gap:"gap-1.5",text:"text-base"}},X={default:{base:"rounded-md font-medium transition-colors",idle:"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",active:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"},outlined:{base:"rounded-md border font-medium transition-colors",idle:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",active:"border-synertech-primary-600 bg-synertech-primary-50 text-synertech-primary-600 hover:bg-synertech-primary-100 dark:border-synertech-primary-400 dark:bg-synertech-primary-900/30 dark:text-synertech-primary-400 dark:hover:bg-synertech-primary-900/50",disabled:"border-gray-200 text-gray-300 cursor-not-allowed dark:border-gray-700 dark:text-gray-600"},minimal:{base:"rounded-md font-medium transition-colors",idle:"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",active:"text-synertech-primary-600 font-semibold hover:text-synertech-primary-700 dark:text-synertech-primary-400 dark:hover:text-synertech-primary-300",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"}};function Y({page:t,totalPages:r,onPageChange:o,size:n="md",variant:i="default",showFirstLast:b=!1,siblings:v=1,boundaries:f=1,disabled:l=!1,labels:p,totalItems:m,pageSize:y,pageSizeOptions:w,onPageSizeChange:R,className:j,...U}){let g=(0,M.useUILabels)(p),s=V[n],h=X[i],P=(0,x.useId)(),u=Math.max(0,Math.floor(r)||0),c=Math.min(Math.max(1,Math.floor(t)||1),Math.max(1,u)),F=(0,x.useMemo)(()=>J(c,u,v,f),[c,u,v,f]),k=(0,x.useCallback)(a=>{l||a<1||a>u||a===c||o(a)},[l,u,c,o]),I=c<=1,B=c>=u,W=(0,d.cn)("inline-flex items-center justify-center select-none",s.button,h.base),C=(a,N,A,_)=>(0,e.jsx)("button",{type:"button",onClick:a,disabled:l||N,"aria-label":A,"aria-disabled":l||N,className:(0,d.cn)(W,l||N?h.disabled:h.idle),children:_}),E=m!==void 0&&y?Math.min((c-1)*y+1,m):void 0,O=m!==void 0&&y?Math.min(c*y,m):void 0;return(0,e.jsxs)("nav",{"aria-label":g.paginationLabel,className:(0,d.cn)("flex items-center",s.gap,j),...U,children:[m!==void 0&&y&&(0,e.jsx)("span",{className:(0,d.cn)("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",s.text),children:(0,M.formatUILabel)(g.paginationRange,{start:E??0,end:O??0,total:m})}),w&&w.length>0&&R&&(0,e.jsxs)("div",{className:(0,d.cn)("mr-2 flex items-center whitespace-nowrap",s.gap,s.text),children:[(0,e.jsx)("label",{htmlFor:P,className:"text-gray-600 dark:text-gray-400",children:g.paginationRowsPerPage}),(0,e.jsx)("select",{id:P,value:y,onChange:a=>R(Number(a.target.value)),disabled:l,className:(0,d.cn)("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",s.text,l&&"cursor-not-allowed opacity-50"),children:w.map(a=>(0,e.jsx)("option",{value:a,children:a},a))})]}),(0,e.jsxs)("div",{className:(0,d.cn)("flex items-center",s.gap),children:[b&&C(()=>k(1),I,p?.first??g.paginationFirst,(0,e.jsx)(S,{className:s.icon})),C(()=>k(c-1),I,p?.previous??g.paginationPrevious,(0,e.jsx)(K,{className:s.icon})),F.map((a,N)=>a==="ellipsis"?(0,e.jsx)("span",{className:(0,d.cn)("inline-flex items-center justify-center select-none",s.button,"text-gray-500 dark:text-gray-400"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${N}`):(0,e.jsx)("button",{type:"button",onClick:()=>k(a),disabled:l,"aria-current":a===c?"page":void 0,"aria-label":(0,M.formatUILabel)(g.paginationPage,{page:a}),className:(0,d.cn)(W,a===c?h.active:l?h.disabled:h.idle),children:a},a)),C(()=>k(c+1),B,p?.next??g.paginationNext,(0,e.jsx)(Q,{className:s.icon})),b&&C(()=>k(u),B,p?.last??g.paginationLast,(0,e.jsx)(T,{className:s.icon}))]})]})}0&&(module.exports={Pagination});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as _,useId as $,useMemo as q}from"react";import{cn as c}from"../../lib/cn.js";import{formatUILabel as B,useUILabels as z}from"../../lib/i18n.js";import{jsx as t,jsxs as C}from"react/jsx-runtime";function D(a,s,l,r){let u=(v,i)=>Array.from({length:Math.max(0,i-v+1)},(p,d)=>v+d);if(s<=r*2+l*2+3)return u(1,s);let x=Math.max(Math.min(a-l,s-r-l*2-1),r+2),b=Math.min(Math.max(a+l,r+l*2+2),s-r-1);return[...u(1,r),x>r+2?"ellipsis":r+1,...u(x,b),b<s-r-1?"ellipsis":s-r,...u(s-r+1,s)]}function G({className:a}){return t("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function H({className:a}){return t("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}function J({className:a}){return t("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 19l-7-7 7-7M18 19l-7-7 7-7"})})}function K({className:a}){return t("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M6 5l7 7-7 7"})})}var Q={sm:{button:"h-7 min-w-7 px-1.5 text-xs",icon:"h-3 w-3",gap:"gap-0.5",text:"text-xs"},md:{button:"h-9 min-w-9 px-2.5 text-sm",icon:"h-4 w-4",gap:"gap-1",text:"text-sm"},lg:{button:"h-11 min-w-11 px-3.5 text-base",icon:"h-5 w-5",gap:"gap-1.5",text:"text-base"}},S={default:{base:"rounded-md font-medium transition-colors",idle:"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700",active:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"},outlined:{base:"rounded-md border font-medium transition-colors",idle:"border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",active:"border-synertech-primary-600 bg-synertech-primary-50 text-synertech-primary-600 hover:bg-synertech-primary-100 dark:border-synertech-primary-400 dark:bg-synertech-primary-900/30 dark:text-synertech-primary-400 dark:hover:bg-synertech-primary-900/50",disabled:"border-gray-200 text-gray-300 cursor-not-allowed dark:border-gray-700 dark:text-gray-600"},minimal:{base:"rounded-md font-medium transition-colors",idle:"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",active:"text-synertech-primary-600 font-semibold hover:text-synertech-primary-700 dark:text-synertech-primary-400 dark:hover:text-synertech-primary-300",disabled:"text-gray-300 cursor-not-allowed dark:text-gray-600"}};function Y({page:a,totalPages:s,onPageChange:l,size:r="md",variant:u="default",showFirstLast:x=!1,siblings:b=1,boundaries:v=1,disabled:i=!1,labels:p,totalItems:d,pageSize:y,pageSizeOptions:M,onPageSizeChange:w,className:W,...j}){let m=z(p),n=Q[r],h=S[u],L=$(),g=Math.max(0,Math.floor(s)||0),o=Math.min(Math.max(1,Math.floor(a)||1),Math.max(1,g)),U=q(()=>D(o,g,b,v),[o,g,b,v]),f=_(e=>{i||e<1||e>g||e===o||l(e)},[i,g,o,l]),R=o<=1,P=o>=g,I=c("inline-flex items-center justify-center select-none",n.button,h.base),N=(e,k,O,A)=>t("button",{type:"button",onClick:e,disabled:i||k,"aria-label":O,"aria-disabled":i||k,className:c(I,i||k?h.disabled:h.idle),children:A}),F=d!==void 0&&y?Math.min((o-1)*y+1,d):void 0,E=d!==void 0&&y?Math.min(o*y,d):void 0;return C("nav",{"aria-label":m.paginationLabel,className:c("flex items-center",n.gap,W),...j,children:[d!==void 0&&y&&t("span",{className:c("mr-2 text-gray-600 dark:text-gray-400 whitespace-nowrap",n.text),children:B(m.paginationRange,{start:F??0,end:E??0,total:d})}),M&&M.length>0&&w&&C("div",{className:c("mr-2 flex items-center whitespace-nowrap",n.gap,n.text),children:[t("label",{htmlFor:L,className:"text-gray-600 dark:text-gray-400",children:m.paginationRowsPerPage}),t("select",{id:L,value:y,onChange:e=>w(Number(e.target.value)),disabled:i,className:c("rounded border border-gray-300 bg-white px-1.5 py-0.5 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",n.text,i&&"cursor-not-allowed opacity-50"),children:M.map(e=>t("option",{value:e,children:e},e))})]}),C("div",{className:c("flex items-center",n.gap),children:[x&&N(()=>f(1),R,p?.first??m.paginationFirst,t(J,{className:n.icon})),N(()=>f(o-1),R,p?.previous??m.paginationPrevious,t(G,{className:n.icon})),U.map((e,k)=>e==="ellipsis"?t("span",{className:c("inline-flex items-center justify-center select-none",n.button,"text-gray-500 dark:text-gray-400"),"aria-hidden":"true",children:"\u2026"},`ellipsis-${k}`):t("button",{type:"button",onClick:()=>f(e),disabled:i,"aria-current":e===o?"page":void 0,"aria-label":B(m.paginationPage,{page:e}),className:c(I,e===o?h.active:i?h.disabled:h.idle),children:e},e)),N(()=>f(o+1),P,p?.next??m.paginationNext,t(H,{className:n.icon})),x&&N(()=>f(g),P,p?.last??m.paginationLast,t(K,{className:n.icon}))]})]})}export{Y as Pagination};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var J=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var Pe=(i,a)=>{for(var o in a)J(i,o,{get:a[o],enumerable:!0})},Re=(i,a,o,x)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of Ae(a))!ke.call(i,h)&&h!==o&&J(i,h,{get:()=>a[h],enumerable:!(x=ve(a,h))||x.enumerable});return i};var Le=i=>Re(J({},"__esModule",{value:!0}),i);var Oe={};Pe(Oe,{PieChart:()=>Te,resetPieWarnings:()=>Ve});module.exports=Le(Oe);var m=require("react"),K=require("../../lib/i18n.cjs"),se=require("../chart/ChartContainer.cjs"),ie=require("../chart/ChartLegend.cjs"),D=require("../chart/ChartPatterns.cjs"),ce=require("../chart/ChartTableView.cjs"),X=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),T=require("../chart/utils/data.cjs"),P=require("../chart/utils/format.cjs"),ue=require("../chart/utils/keyboard.cjs"),de=require("../chart/utils/path.cjs"),me=require("../chart/utils/touch.cjs"),l=require("react/jsx-runtime"),Se=.62,Me=2,Ne=3,Ee=.16,_e=64,we=22,Q=6,Y=!1;function Ie({width:i,height:a,slices:o,variant:x,innerRadius:h,showLabels:R,centerLabel:v,tooltip:k,patterns:L,patternBaseId:V,plotLabel:H,formatValue:E,locale:O,onSliceClick:S}){let[M,g]=(0,m.useState)(null),b=M!==null&&M<o.length?M:null,$=(0,m.useMemo)(()=>{let t=R?_e:8,n=R?we:8,u=Math.max(0,Math.min((i-t*2)/2,(a-n*2)/2));return{cx:i/2,cy:a/2,outerRadius:u,inner:x==="donut"?u*(h??Se):(h??0)*u,pad:u>0&&o.length>1?Me/u/2:0}},[i,a,x,h,R,o.length]),{cx:p,cy:y,outerRadius:f,inner:W,pad:_}=$,z=(0,m.useCallback)(t=>{let n=(t.startAngle+t.endAngle)/2,u=Math.sin(n)>=0,C={x:p+Math.sin(n)*(f+4),y:y-Math.cos(n)*(f+4)},d={x:p+Math.sin(n)*(f+14),y:y-Math.cos(n)*(f+14)},I={x:u?d.x+10:d.x-10,y:d.y};return{from:C,elbow:d,end:I,anchor:u?"start":"end"}},[p,y,f]),w=(0,m.useCallback)(t=>{let n=o[t];n&&S?.({key:n.key,label:n.label,value:n.value,share:n.share})},[o,S]),G=(0,m.useCallback)(t=>(0,ue.handleChartKeyDown)(t,{count:o.length,current:b,axis:"both",onMove:g,pick:S&&b!==null?()=>w(b):null}),[o.length,b,S,w]),s=b===null?null:o[b];return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("svg",{width:i,height:a,role:"img","aria-label":H??o.map(t=>t.label).join(", "),tabIndex:0,className:`${me.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerLeave:()=>g(null),onBlur:()=>g(null),onKeyDown:G,children:[L?(0,l.jsx)(D.ChartPatternDefs,{id:V,entries:o.map(t=>({slot:t.slot,color:t.color}))}):null,o.map((t,n)=>(0,l.jsx)("path",{d:(0,de.buildArcPath)({cx:p,cy:y,innerRadius:W,outerRadius:f+(b===n?Ne:0),startAngle:t.startAngle+_,endAngle:Math.max(t.startAngle+_,t.endAngle-_)}),fill:(0,D.patternFill)(L,V,t.slot,t.color),onPointerEnter:()=>k===!1?void 0:g(n),onClick:()=>w(n)},t.key)),R?o.filter(t=>t.endAngle-t.startAngle>=Ee).map(t=>{let{from:n,elbow:u,end:C,anchor:d}=z(t);return(0,l.jsxs)("g",{"aria-hidden":"true",children:[(0,l.jsx)("polyline",{points:`${n.x},${n.y} ${u.x},${u.y} ${C.x},${C.y}`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1}),(0,l.jsx)("text",{x:d==="start"?C.x+3:C.x-3,y:C.y,textAnchor:d,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:t.label})]},`label-${t.key}`)}):null,x==="donut"&&v?(0,l.jsxs)("g",{"aria-hidden":"true",children:[(0,l.jsx)("text",{x:p,y:y-(v.label?2:0),textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-900 text-lg font-semibold dark:fill-gray-100",children:v.value}),v.label?(0,l.jsx)("text",{x:p,y:y+14,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:v.label}):null]}):null]}),s&&k!==!1?(0,l.jsx)(X.ChartTooltip,{x:p+Math.sin((s.startAngle+s.endAngle)/2)*(f*.7),y:y-Math.cos((s.startAngle+s.endAngle)/2)*(f*.7),containerWidth:i,children:typeof k=="function"?k({seriesKey:s.key,seriesLabel:s.label,color:s.color,value:s.value,formattedValue:E(s.value),datum:{},share:s.share}):(0,l.jsx)(X.ChartTooltipContent,{title:s.label,points:[{seriesKey:s.key,seriesLabel:(0,P.formatPercent)(s.share,{locale:O}),color:s.color,value:s.value,formattedValue:E(s.value),datum:{}}]})}):null]})}function Te({data:i,x:a,value:o,valueLabel:x,variant:h="pie",innerRadius:R,maxSlices:v=Q,otherLabel:k,sort:L="desc",showLabels:V=!0,centerLabel:H,patterns:E=!1,height:O=260,width:S,size:M="md",legend:g,tooltip:b=!0,tableView:$=!1,title:p,description:y,loading:f=!1,emptyState:W,error:_=!1,errorState:z,onRetry:w,actions:G,locale:s,plotLabel:t,onSliceClick:n,className:u,...C}){let d=(0,K.useUILocale)(s),I=(0,K.useUILabels)(),he=(0,m.useId)(),ee=(0,m.useCallback)(c=>(0,P.formatAuto)(c,d),[d]),te=(0,m.useCallback)(c=>a.format?a.format(c,0):(0,P.formatXValue)(c,d),[a,d]),{slices:U,total:pe,rows:ae}=(0,m.useMemo)(()=>{let c=i.map((e,r)=>({key:String((0,T.readXValue)(e,a.key,r)),label:te((0,T.readXValue)(e,a.key,r)),value:(0,T.readNumber)(e,o)??0,index:r,datum:e})),B=L==="none"?c:[...c].sort((e,r)=>L==="asc"?e.value-r.value:r.value-e.value),F=Math.max(1,Math.floor(v)),re=B.length>F,Z=re?B.slice(0,F-1):B,le=re?B.slice(F-1):[],ge=new Set(Z.filter(e=>e.index<A.CHART_PALETTE_SIZE).map(e=>e.index)),be=Array.from({length:A.CHART_PALETTE_SIZE},(e,r)=>r).filter(e=>!ge.has(e)),ye=Z.filter(e=>e.index>=A.CHART_PALETTE_SIZE).sort((e,r)=>e.index-r.index),Ce=new Map(ye.map((e,r)=>[e.index,be[r]??e.index])),N=Z.map(e=>{let r=Ce.get(e.index)??e.index;return{...e,slot:r,color:(0,A.getSeriesColor)(r)}});le.length>0&&N.push({key:"__other__",label:k??I.chartOther,value:le.reduce((e,r)=>e+Math.max(0,r.value),0),index:-1,color:A.CHART_MUTED_COLOR,slot:-1,datum:{}}),N.length>Q&&!Y&&(Y=!0,console.warn(`[@synertech/ui] A PieChart is drawing ${N.length} slices. Past ${Q} the slices stop being tellable apart: lower \`maxSlices\`, or use a BarChart, which compares lengths rather than angles.`));let j=N.reduce((e,r)=>e+Math.max(0,r.value),0),q=0;return{slices:N.map(e=>{let r=j===0?0:Math.max(0,e.value)/j,xe=q;return q+=r*Math.PI*2,{...e,share:r,startAngle:xe,endAngle:q}}),total:j,rows:N.map(e=>({[a.key]:e.label,[o]:e.value}))}},[i,a.key,o,L,v,k,I.chartOther,te]),oe=[{key:o,label:x??I.chartValue}],fe=g===void 0?!0:g!==!1,ne=typeof g=="string"?g:"bottom";return(0,l.jsx)(se.ChartContainer,{title:p,description:y,height:O,width:S,size:M,loading:f,empty:U.length===0||pe===0,emptyState:W,error:_,errorState:z,onRetry:w,actions:G,exportSource:{data:ae,series:oe,xKey:a.key,xLabel:a.label??a.key},tableView:$,legendPosition:ne,legend:fe?(0,l.jsx)(ie.ChartLegend,{items:U.map(c=>({key:c.key,label:`${c.label} \xB7 ${(0,P.formatPercent)(c.share,{locale:d})}`,color:c.color,...E?{pattern:c.slot}:{}})),position:ne,marker:"rect",size:M}):void 0,table:$?(0,l.jsx)(ce.ChartTableView,{data:ae,series:oe,xKey:a.key,xLabel:a.label??a.key,formatValue:ee,caption:typeof p=="string"?p:void 0}):void 0,className:u,...C,children:({width:c})=>(0,l.jsx)(Ie,{width:c,height:O,slices:U,variant:h,innerRadius:R,showLabels:V,centerLabel:H,tooltip:b,patterns:E,patternBaseId:he,plotLabel:t,formatValue:ee,locale:d,onSliceClick:n})})}function Ve(){Y=!1}0&&(module.exports={PieChart,resetPieWarnings});
|