@synertech/ui 0.45.0 → 0.46.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 +116 -18
- package/README.md +47 -5
- 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/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/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/ChartSync.cjs +1 -1
- package/dist/components/chart/ChartSync.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 +1 -2
- package/dist/components/chart/utils/export.js +1 -2
- package/dist/components/chart/utils/keyboard.cjs +1 -0
- package/dist/components/chart/utils/keyboard.js +1 -0
- package/dist/components/chart/utils/path.cjs +1 -1
- package/dist/components/chart/utils/path.js +1 -1
- package/dist/components/chart/utils/time.cjs +1 -1
- package/dist/components/chart/utils/time.js +1 -1
- package/dist/components/chart/utils/timestamp.cjs +1 -0
- package/dist/components/chart/utils/timestamp.js +1 -0
- package/dist/components/chart/utils/touch.cjs +1 -0
- package/dist/components/chart/utils/touch.js +1 -0
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -2
- package/dist/components/datagrid/DataGrid.js +1 -2
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/dropdown/Dropdown.cjs +1 -1
- package/dist/components/dropdown/Dropdown.js +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownItem.cjs +1 -1
- package/dist/components/dropdown/DropdownItem.js +1 -1
- package/dist/components/dropdown/DropdownRadio.cjs +1 -1
- package/dist/components/dropdown/DropdownRadio.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/index.cjs +1 -1
- package/dist/components/dropdown/hooks/index.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/index.cjs +1 -1
- package/dist/components/dropdown/index.js +1 -1
- package/dist/components/dropdown/menu-navigation.cjs +1 -0
- package/dist/components/dropdown/menu-navigation.js +1 -0
- 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/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +1 -1
- package/dist/components/form/mention-input/MentionInput.js +1 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.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/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/help-button/HelpButton.cjs +7 -7
- package/dist/components/help-button/HelpButton.js +7 -7
- package/dist/components/help-button/MarkdownEditor.cjs +1 -1
- package/dist/components/help-button/MarkdownEditor.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/label/Label.cjs +1 -1
- package/dist/components/label/Label.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/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/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.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/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/tabs/Tabs.cjs +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/TabsContent.cjs +1 -1
- package/dist/components/tabs/TabsContent.js +1 -1
- package/dist/components/tabs/TabsContext.cjs +1 -1
- package/dist/components/tabs/TabsContext.js +1 -1
- package/dist/components/tabs/TabsList.cjs +1 -1
- package/dist/components/tabs/TabsList.js +1 -1
- package/dist/components/tabs/TabsTrigger.cjs +1 -1
- package/dist/components/tabs/TabsTrigger.js +1 -1
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.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/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +830 -175
- package/dist/index.d.ts +830 -175
- package/dist/index.js +1 -1
- package/dist/lib/aria-hide.cjs +1 -1
- package/dist/lib/aria-hide.js +1 -1
- package/dist/lib/csv.cjs +2 -0
- package/dist/lib/csv.js +2 -0
- package/dist/lib/i18n.cjs +1 -1
- package/dist/lib/i18n.js +1 -1
- package/dist/lib/server-labels.cjs +1 -0
- package/dist/lib/server-labels.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -0
- package/dist/lib/ui-labels.js +1 -0
- package/dist/styles.css +3070 -264
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var ae=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var ye=(s,o)=>{for(var t in o)ae(s,t,{get:o[t],enumerable:!0})},ve=(s,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let b of ke(o))!we.call(s,b)&&b!==t&&ae(s,b,{get:()=>o[b],enumerable:!(e=Ce(o,b))||e.enumerable});return s};var Se=s=>ve(ae({},"__esModule",{value:!0}),s);var Ae={};ye(Ae,{Heatmap:()=>Xe,resetHeatmapWarnings:()=>$e});module.exports=Se(Ae);var m=require("react"),ue=require("../../lib/cn.cjs"),ne=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),ce=require("../chart/ChartScaleLegend.cjs"),he=require("../chart/ChartTableView.cjs"),ge=require("../chart/ChartTooltip.cjs"),M=require("../chart/palette.cjs"),K=require("../chart/utils/data.cjs"),Y=require("../chart/utils/format.cjs"),_=require("../chart/utils/keyboard.cjs"),k=require("../chart/utils/scales.cjs"),L=require("../chart/utils/text.cjs"),de=require("../chart/utils/ticks.cjs"),fe=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),xe=2,Le=2,Ve=12,He=16,ie="cell:",re=!1,Ee=(0,m.memo)(function({cells:o,radius:t}){return(0,r.jsx)("g",{children:o.map(e=>(0,r.jsxs)("g",{children:[(0,r.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?(0,r.jsx)("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:(0,ue.cn)("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function Re({width:s,height:o,columns:t,rows:e,lookup:b,colorScale:S,x:p,y:C,size:V,cellGap:y,cellRadius:O,showValues:B,tooltip:P,plotLabel:Q,formatValue:z,formatX:T,formatY:W,onCellClick:H}){let[E,D]=(0,m.useState)(null),c=E!==null&&E.column<t.length&&E.row<e.length?E:null,a=(0,m.useMemo)(()=>{let g=t.map((f,i)=>T(f,i)),d=e.map((f,i)=>W(f,i)),u={top:8,right:8,bottom:p.hidden?8:p.height??24+(p.label?16:0),left:C.hidden?8:C.height??(0,L.widestLabel)(d)+Ve+(C.label?16:0)},l=Math.max(0,s-u.left-u.right),v=Math.max(0,o-u.top-u.bottom),h=(0,k.createBandScale)(t.map((f,i)=>i),[0,l],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(e.map((f,i)=>i),[0,v],{paddingInner:0,paddingOuter:0}),Z=Math.max(0,h.bandwidth-y),X=Math.max(0,x.bandwidth-y),I=[];e.forEach((f,i)=>{t.forEach((te,G)=>{let n=b.get(`${(0,k.toKey)(te)}|${(0,k.toKey)(f)}`)?.value??null,w=null;if(B&&n!==null&&X>=He){let A=z(n);(0,L.estimateTextWidth)(A,10)+6<=Z&&(w=A)}I.push({key:`${G}-${i}`,column:G,row:i,x:h(G)+y/2,y:x(i)+y/2,width:Z,height:X,color:n===null?"transparent":S(n),label:w,onDark:n!==null&&S.onDark(n),missing:n===null})})});let $=(0,L.labelStride)(g.length,l,(0,L.widestLabel)(g)),q=(0,L.labelStride)(d.length,v,L.AXIS_FONT_SIZE+4),F=p.hidden?[]:g.map((f,i)=>({value:t[i],offset:h.center(i),label:f})).filter((f,i)=>i%$===0),J=C.hidden?[]:d.map((f,i)=>({value:e[i],offset:x.center(i),label:f})).filter((f,i)=>i%q===0);return{margin:u,innerWidth:l,innerHeight:v,columnScale:h,rowScale:x,cells:I,columnTicks:F,rowTicks:J}},[t,e,b,S,p,C,s,o,y,B,z,T,W]),N=(0,m.useCallback)((g,d)=>{let u=t[g],l=e[d],v=b.get(`${(0,k.toKey)(u)}|${(0,k.toKey)(l)}`),h=v?.value??null;return{x:u,y:l,xLabel:T(u,g),yLabel:W(l,d),value:h,formattedValue:h===null?"\u2014":z(h),color:h===null?"transparent":S(h),datum:v?.datum}},[t,e,b,S,z,T,W]),j=(0,m.useCallback)(g=>{if(P===!1||t.length===0||e.length===0)return;let d=g.currentTarget.getBoundingClientRect(),u=g.clientX-d.left-a.margin.left,l=g.clientY-d.top-a.margin.top,v=Math.floor(u/(a.columnScale.step||1)),h=Math.floor(l/(a.rowScale.step||1));if(v<0||v>=t.length||h<0||h>=e.length){D(null);return}D(x=>x?.column===v&&x.row===h?x:{column:v,row:h})},[P,t.length,e.length,a.margin,a.columnScale,a.rowScale]),U=(0,m.useCallback)(()=>{!H||!c||H(N(c.column,c.row))},[H,c,N]),ee=(0,m.useCallback)(g=>{if(t.length===0||e.length===0||(0,_.pressChartMark)(g,H&&c?U:null))return;let d=c?.column??null,u=c?.row??null,l;switch(g.key){case"ArrowRight":l={row:u??0,column:(0,_.stepChartCursor)(d,1,t.length)};break;case"ArrowLeft":l={row:u??0,column:(0,_.stepChartCursor)(d,-1,t.length)};break;case"ArrowDown":l={column:d??0,row:(0,_.stepChartCursor)(u,1,e.length)};break;case"ArrowUp":l={column:d??0,row:(0,_.stepChartCursor)(u,-1,e.length)};break;case"Home":l={row:u??0,column:0};break;case"End":l={row:u??0,column:t.length-1};break;case"Escape":l=null;break;default:return}g.preventDefault(),D(l)},[t.length,e.length,c,H,U]),R=c?N(c.column,c.row):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:s,height:o,role:"img","aria-label":Q??`${p.label??p.key} / ${C.label??C.key}`,tabIndex:0,className:`${fe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:j,onPointerLeave:()=>D(null),onKeyDown:ee,onBlur:()=>D(null),onClick:U,children:[(0,r.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[(0,r.jsx)(Ee,{cells:a.cells,radius:O}),c?(0,r.jsx)("rect",{x:a.columnScale(c.column)+y/2,y:a.rowScale(c.row)+y/2,width:Math.max(0,a.columnScale.bandwidth-y),height:Math.max(0,a.rowScale.bandwidth-y),rx:O,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),(0,r.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:p.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:p.label,size:V})}),(0,r.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:C.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:C.label,size:V})})]}),c&&R&&P!==!1?(0,r.jsx)(ge.ChartTooltip,{x:a.margin.left+a.columnScale.center(c.column),y:a.margin.top+a.rowScale.center(c.row),containerWidth:s,children:typeof P=="function"?P(R):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[R.yLabel," \xB7 ",R.xLabel]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:R.color},"aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:R.formattedValue})]})]})}):null]})}function se(s,o,t){if(t)return t;let e=new Map;return s.forEach((b,S)=>{let p=(0,K.readXValue)(b,o,S),C=(0,k.toKey)(p);e.has(C)||e.set(C,p)}),[...e.values()]}function Xe({data:s,x:o,y:t,value:e,format:b,domain:S,scale:p="sequential",center:C=0,steps:V,colors:y,xDomain:O,yDomain:B,cellGap:P=xe,cellRadius:Q=Le,showValues:z=!1,height:T=280,width:W,size:H="md",legend:E=!0,legendLabel:D,tooltip:c=!0,tableView:a=!1,title:N,description:j,loading:U=!1,emptyState:ee,error:R=!1,errorState:g,onRetry:d,actions:u,locale:l,plotLabel:v,onCellClick:h,className:x,...Z}){V!==void 0&&V>M.CHART_MAX_COLOR_CLASSES&&!re&&(re=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${V} colour classes. Past ${M.CHART_MAX_COLOR_CLASSES} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let X=(0,m.useMemo)(()=>se(s,o.key,O),[s,o.key,O]),I=(0,m.useMemo)(()=>se(s,t.key,B),[s,t.key,B]),$=(0,m.useMemo)(()=>{let n=new Map;return s.forEach((w,A)=>{let oe=(0,K.readNumber)(w,e);if(oe===null)return;let be=(0,K.readXValue)(w,o.key,A),pe=(0,K.readXValue)(w,t.key,A);n.set(`${(0,k.toKey)(be)}|${(0,k.toKey)(pe)}`,{value:oe,datum:w})}),n},[s,o.key,t.key,e]),q=(0,m.useMemo)(()=>b??(n=>(0,Y.formatAuto)(n,l)),[b,l]),F=(0,m.useMemo)(()=>o.format??(n=>(0,Y.formatXValue)(n,l)),[o.format,l]),J=(0,m.useMemo)(()=>t.format??(n=>(0,Y.formatXValue)(n,l)),[t.format,l]),f=(0,m.useMemo)(()=>{let n=S??(0,de.extent)([...$.values()].map(w=>w.value))??[0,1];return p==="diverging"?(0,M.createDivergingScale)(n,{center:C,steps:V,colors:y}):(0,M.createSequentialScale)(n,{steps:V,colors:y})},[S,$,p,C,V,y]),i=(0,m.useMemo)(()=>I.map(n=>{let w={[t.key]:n};return X.forEach(A=>{w[`${ie}${(0,k.toKey)(A)}`]=$.get(`${(0,k.toKey)(A)}|${(0,k.toKey)(n)}`)?.value??null}),w}),[I,X,$,t.key]),te=(0,m.useMemo)(()=>X.map((n,w)=>({key:`${ie}${(0,k.toKey)(n)}`,label:F(n,w)})),[X,F]),G=E!==!1,le=typeof E=="string"?E:"bottom";return(0,r.jsx)(me.ChartContainer,{title:N,description:j,height:T,width:W,size:H,loading:U,empty:$.size===0,emptyState:ee,error:R,errorState:g,onRetry:d,actions:u,tableView:a,legendPosition:le,legend:G?(0,r.jsx)(ce.ChartScaleLegend,{scale:f,label:D,format:q,size:H,locale:l}):void 0,table:a?(0,r.jsx)(he.ChartTableView,{data:i,series:te,xKey:t.key,xLabel:t.label??t.key,formatX:J,formatValue:q,caption:typeof N=="string"?N:void 0}):void 0,className:x,...Z,children:({width:n})=>(0,r.jsx)(Re,{width:n,height:T,columns:X,rows:I,lookup:$,colorScale:f,x:o,y:t,size:H,cellGap:P,cellRadius:Q,showValues:z,tooltip:c,plotLabel:v,formatValue:q,formatX:F,formatY:J,onCellClick:h})})}function $e(){re=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as de,useCallback as G,useMemo as S,useState as
|
|
1
|
+
"use client";import{memo as de,useCallback as G,useMemo as S,useState as fe}from"react";import{cn as be}from"../../lib/cn.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as pe}from"../chart/ChartContainer.js";import{ChartScaleLegend as Ce}from"../chart/ChartScaleLegend.js";import{ChartTableView as ke}from"../chart/ChartTableView.js";import{ChartTooltip as we}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as le,createDivergingScale as ye,createSequentialScale as ve}from"../chart/palette.js";import{readNumber as Se,readXValue as ee}from"../chart/utils/data.js";import{formatAuto as xe,formatXValue as oe}from"../chart/utils/format.js";import{pressChartMark as Le,stepChartCursor as Y}from"../chart/utils/keyboard.js";import{createBandScale as ie,toKey as w}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as Ve,estimateTextWidth as He,labelStride as se,widestLabel as ue}from"../chart/utils/text.js";import{extent as Ee}from"../chart/utils/ticks.js";import{CHART_TOUCH as Re}from"../chart/utils/touch.js";import{Fragment as Ne,jsx as h,jsxs as N}from"react/jsx-runtime";var Xe=2,$e=2,Ae=12,Pe=16,me="cell:",te=!1,Te=de(function({cells:g,radius:t}){return h("g",{children:g.map(e=>N("g",{children:[h("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?h("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:be("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function De({width:b,height:g,columns:t,rows:e,lookup:x,colorScale:y,x:d,y:f,size:L,cellGap:C,cellRadius:W,showValues:I,tooltip:A,plotLabel:Z,formatValue:_,formatX:P,formatY:M,onCellClick:V}){let[H,T]=fe(null),i=H!==null&&H.column<t.length&&H.row<e.length?H:null,a=S(()=>{let u=t.map((c,l)=>P(c,l)),m=e.map((c,l)=>M(c,l)),o={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:f.hidden?8:f.height??ue(m)+Ae+(f.label?16:0)},r=Math.max(0,b-o.left-o.right),k=Math.max(0,g-o.top-o.bottom),s=ie(t.map((c,l)=>l),[0,r],{paddingInner:0,paddingOuter:0}),v=ie(e.map((c,l)=>l),[0,k],{paddingInner:0,paddingOuter:0}),q=Math.max(0,s.bandwidth-C),R=Math.max(0,v.bandwidth-C),z=[];e.forEach((c,l)=>{t.forEach((j,U)=>{let n=x.get(`${w(j)}|${w(c)}`)?.value??null,p=null;if(I&&n!==null&&R>=Pe){let $=_(n);He($,10)+6<=q&&(p=$)}z.push({key:`${U}-${l}`,column:U,row:l,x:s(U)+C/2,y:v(l)+C/2,width:q,height:R,color:n===null?"transparent":y(n),label:p,onDark:n!==null&&y.onDark(n),missing:n===null})})});let X=se(u.length,r,ue(u)),O=se(m.length,k,Ve+4),B=d.hidden?[]:u.map((c,l)=>({value:t[l],offset:s.center(l),label:c})).filter((c,l)=>l%X===0),F=f.hidden?[]:m.map((c,l)=>({value:e[l],offset:v.center(l),label:c})).filter((c,l)=>l%O===0);return{margin:o,innerWidth:r,innerHeight:k,columnScale:s,rowScale:v,cells:z,columnTicks:B,rowTicks:F}},[t,e,x,y,d,f,b,g,C,I,_,P,M]),D=G((u,m)=>{let o=t[u],r=e[m],k=x.get(`${w(o)}|${w(r)}`),s=k?.value??null;return{x:o,y:r,xLabel:P(o,u),yLabel:M(r,m),value:s,formattedValue:s===null?"\u2014":_(s),color:s===null?"transparent":y(s),datum:k?.datum}},[t,e,x,y,_,P,M]),J=G(u=>{if(A===!1||t.length===0||e.length===0)return;let m=u.currentTarget.getBoundingClientRect(),o=u.clientX-m.left-a.margin.left,r=u.clientY-m.top-a.margin.top,k=Math.floor(o/(a.columnScale.step||1)),s=Math.floor(r/(a.rowScale.step||1));if(k<0||k>=t.length||s<0||s>=e.length){T(null);return}T(v=>v?.column===k&&v.row===s?v:{column:k,row:s})},[A,t.length,e.length,a.margin,a.columnScale,a.rowScale]),K=G(()=>{!V||!i||V(D(i.column,i.row))},[V,i,D]),Q=G(u=>{if(t.length===0||e.length===0||Le(u,V&&i?K:null))return;let m=i?.column??null,o=i?.row??null,r;switch(u.key){case"ArrowRight":r={row:o??0,column:Y(m,1,t.length)};break;case"ArrowLeft":r={row:o??0,column:Y(m,-1,t.length)};break;case"ArrowDown":r={column:m??0,row:Y(o,1,e.length)};break;case"ArrowUp":r={column:m??0,row:Y(o,-1,e.length)};break;case"Home":r={row:o??0,column:0};break;case"End":r={row:o??0,column:t.length-1};break;case"Escape":r=null;break;default:return}u.preventDefault(),T(r)},[t.length,e.length,i,V,K]),E=i?D(i.column,i.row):null;return N(Ne,{children:[N("svg",{width:b,height:g,role:"img","aria-label":Z??`${d.label??d.key} / ${f.label??f.key}`,tabIndex:0,className:`${Re} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:J,onPointerLeave:()=>T(null),onKeyDown:Q,onBlur:()=>T(null),onClick:K,children:[N("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[h(Te,{cells:a.cells,radius:W}),i?h("rect",{x:a.columnScale(i.column)+C/2,y:a.rowScale(i.row)+C/2,width:Math.max(0,a.columnScale.bandwidth-C),height:Math.max(0,a.rowScale.bandwidth-C),rx:W,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(re,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:d.label,size:L})}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:f.hidden?null:h(re,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:f.label,size:L})})]}),i&&E&&A!==!1?h(we,{x:a.margin.left+a.columnScale.center(i.column),y:a.margin.top+a.rowScale.center(i.row),containerWidth:b,children:typeof A=="function"?A(E):N("div",{className:"flex flex-col gap-1",children:[N("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[E.yLabel," \xB7 ",E.xLabel]}),N("div",{className:"flex items-center gap-2",children:[h("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:E.color},"aria-hidden":"true"}),h("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.formattedValue})]})]})}):null]})}function ce(b,g,t){if(t)return t;let e=new Map;return b.forEach((x,y)=>{let d=ee(x,g,y),f=w(d);e.has(f)||e.set(f,d)}),[...e.values()]}function Qe({data:b,x:g,y:t,value:e,format:x,domain:y,scale:d="sequential",center:f=0,steps:L,colors:C,xDomain:W,yDomain:I,cellGap:A=Xe,cellRadius:Z=$e,showValues:_=!1,height:P=280,width:M,size:V="md",legend:H=!0,legendLabel:T,tooltip:i=!0,tableView:a=!1,title:D,description:J,loading:K=!1,emptyState:Q,error:E=!1,errorState:u,onRetry:m,actions:o,locale:r,plotLabel:k,onCellClick:s,className:v,...q}){L!==void 0&&L>le&&!te&&(te=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${L} colour classes. Past ${le} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let R=S(()=>ce(b,g.key,W),[b,g.key,W]),z=S(()=>ce(b,t.key,I),[b,t.key,I]),X=S(()=>{let n=new Map;return b.forEach((p,$)=>{let ne=Se(p,e);if(ne===null)return;let he=ee(p,g.key,$),ge=ee(p,t.key,$);n.set(`${w(he)}|${w(ge)}`,{value:ne,datum:p})}),n},[b,g.key,t.key,e]),O=S(()=>x??(n=>xe(n,r)),[x,r]),B=S(()=>g.format??(n=>oe(n,r)),[g.format,r]),F=S(()=>t.format??(n=>oe(n,r)),[t.format,r]),c=S(()=>{let n=y??Ee([...X.values()].map(p=>p.value))??[0,1];return d==="diverging"?ye(n,{center:f,steps:L,colors:C}):ve(n,{steps:L,colors:C})},[y,X,d,f,L,C]),l=S(()=>z.map(n=>{let p={[t.key]:n};return R.forEach($=>{p[`${me}${w($)}`]=X.get(`${w($)}|${w(n)}`)?.value??null}),p}),[z,R,X,t.key]),j=S(()=>R.map((n,p)=>({key:`${me}${w(n)}`,label:B(n,p)})),[R,B]),U=H!==!1,ae=typeof H=="string"?H:"bottom";return h(pe,{title:D,description:J,height:P,width:M,size:V,loading:K,empty:X.size===0,emptyState:Q,error:E,errorState:u,onRetry:m,actions:o,tableView:a,legendPosition:ae,legend:U?h(Ce,{scale:c,label:T,format:O,size:V,locale:r}):void 0,table:a?h(ke,{data:l,series:j,xKey:t.key,xLabel:t.label??t.key,formatX:F,formatValue:O,caption:typeof D=="string"?D:void 0}):void 0,className:v,...q,children:({width:n})=>h(De,{width:n,height:P,columns:R,rows:z,lookup:X,colorScale:c,x:g,y:t,size:V,cellGap:A,cellRadius:Z,showValues:_,tooltip:i,plotLabel:k,formatValue:O,formatX:B,formatY:F,onCellClick:s})})}function je(){te=!1}export{Qe as Heatmap,je as resetHeatmapWarnings};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
2
|
-
${
|
|
1
|
+
"use strict";"use client";var j=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(t,a)=>{for(var s in a)E(t,s,{get:a[s],enumerable:!0})},W=(t,a,s,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of J(a))!X.call(t,l)&&l!==s&&E(t,l,{get:()=>a[l],enumerable:!(d=F(a,l))||d.enumerable});return t};var H=(t,a,s)=>(s=t!=null?j(Q(t)):{},W(a||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t)),Z=t=>W(E({},"__esModule",{value:!0}),t);var ue={};Y(ue,{HelpButton:()=>$,WithHelpButton:()=>ce});module.exports=Z(ue);var o=require("react"),_=H(require("dompurify"),1),U=H(require("react-markdown"),1),A=H(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,e.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),te=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,e.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,e.jsx)("polyline",{points:"7 3 7 8 15 8"})]}),re=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,e.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),oe=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,e.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),ae=(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),(0,e.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),se={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},ne={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},le={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ie=[A.default],de={h1:({...t})=>(0,e.jsx)("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({...t})=>(0,e.jsx)("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({...t})=>(0,e.jsx)("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({...t})=>(0,e.jsx)("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({...t})=>(0,e.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({...t})=>(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({className:t,children:a,...s})=>!t?.includes("language-")?(0,e.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}):(0,e.jsx)("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...t}),strong:({...t})=>(0,e.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({...t})=>(0,e.jsx)("em",{className:"italic",...t}),blockquote:({...t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function $({content:t,markdown:a=!1,position:s="bottom",size:d="sm",className:l="",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,markdownEditor:h,markdownEditorUnavailableLabel:R,labels:M}){let r=(0,D.useUILabels)(M),[y,L]=(0,o.useState)(!1),[c,b]=(0,o.useState)(!1),[v,x]=(0,o.useState)(""),[I,k]=(0,o.useState)(!1),[S,n]=(0,o.useState)(null),T=(0,o.useRef)(null),O=(0,o.useRef)(null),P=(0,o.useRef)(null),i=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!y)return;let g=w=>{T.current&&!T.current.contains(w.target)&&O.current&&!O.current.contains(w.target)&&(c||L(!1))},z=w=>{w.key==="Escape"&&(c?(b(!1),x("")):L(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",z)}},[y,c]),(0,o.useEffect)(()=>{c&&P.current&&P.current.focus()},[c]),(0,o.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let G=(0,o.useCallback)(()=>{x(typeof t=="string"?t:""),b(!0),n(null)},[t]),K=(0,o.useCallback)(()=>{b(!1),x(""),n(null)},[]),q=(0,o.useCallback)(async()=>{if(!m){n({type:"error",text:r.helpButtonNoSave});return}k(!0);try{await m(v)?(n({type:"success",text:r.helpButtonSaved}),b(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonSaveError})}catch{n({type:"error",text:r.helpButtonSaveError})}finally{k(!1)}},[v,m,r]),V=(0,o.useCallback)(async()=>{if(u&&confirm(r.helpButtonResetConfirm)){k(!0);try{await u()?(n({type:"success",text:r.helpButtonResetDone}),b(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonResetError})}catch{n({type:"error",text:r.helpButtonResetError})}finally{k(!1)}}},[u,r]),N=t;return C?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:T,onClick:()=>L(!y),className:`
|
|
2
|
+
${se[d]}
|
|
3
3
|
inline-flex items-center justify-center
|
|
4
4
|
rounded-full border border-gray-300 dark:border-gray-600
|
|
5
5
|
bg-white dark:bg-gray-800
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
hover:border-gray-400 dark:hover:border-gray-500
|
|
11
11
|
transition-all duration-150
|
|
12
12
|
focus:outline-none focus:ring-2 focus:ring-blue-500/50
|
|
13
|
-
${
|
|
14
|
-
`,"aria-label":
|
|
15
|
-
absolute z-50 ${
|
|
16
|
-
${
|
|
13
|
+
${l}
|
|
14
|
+
`,"aria-label":r.helpButtonShow,"aria-expanded":y,children:(0,e.jsx)("span",{className:"font-medium",children:"?"})}),y&&(0,e.jsxs)("div",{ref:O,className:`
|
|
15
|
+
absolute z-50 ${ne[s]}
|
|
16
|
+
${le[B]} max-h-[80vh] overflow-hidden flex flex-col
|
|
17
17
|
bg-white dark:bg-gray-900
|
|
18
18
|
border border-gray-200 dark:border-gray-700
|
|
19
19
|
rounded-xl shadow-xl
|
|
20
20
|
text-sm text-gray-700 dark:text-gray-300
|
|
21
21
|
animate-in fade-in-0 zoom-in-95 duration-150
|
|
22
|
-
`,role:"tooltip",children:[(
|
|
22
|
+
`,role:"tooltip",children:[(p||f)&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:p&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:p})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:q,disabled:I,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonSave,children:I?ae:te}),(0,e.jsx)("button",{type:"button",onClick:K,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonCancel,children:re}),u&&(0,e.jsx)("button",{type:"button",onClick:V,disabled:I,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonReset,children:oe})]}):(0,e.jsx)("button",{type:"button",onClick:G,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonEdit,children:ee})})]}),S&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${S.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:S.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:c?a?h?(0,e.jsx)(h,{value:v,onChange:x,placeholder:r.markdownEditorPlaceholder}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:R??r.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:P,"aria-label":r.helpButtonContent,value:v,onChange:g=>x(g.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:r.helpButtonContentPlaceholder})}):typeof N=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:a?(0,e.jsx)(U.default,{remarkPlugins:ie,components:de,children:N}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:_.default.sanitize(N)}})}):N})]})]}):null}function ce({children:t,content:a,markdown:s=!1,position:d="bottom",size:l="sm",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[t,(0,e.jsx)($,{content:a,markdown:s,position:d,size:l,visible:C,editable:f,onSave:m,onReset:u,width:B,title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r})]})}0&&(module.exports={HelpButton,WithHelpButton});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
2
|
-
${
|
|
1
|
+
"use client";import{useState as b,useRef as E,useEffect as W,useCallback as C}from"react";import G from"dompurify";import K from"react-markdown";import q from"remark-gfm";import{useUILabels as V}from"../../lib/i18n.js";import{Fragment as ae,jsx as e,jsxs as a}from"react/jsx-runtime";var j=a("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),F=a("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),e("polyline",{points:"17 21 17 13 7 13 7 21"}),e("polyline",{points:"7 3 7 8 15 8"})]}),J=a("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Q=a("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("polyline",{points:"1 4 1 10 7 10"}),e("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),X=a("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),e("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),Y={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},Z={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},ee={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},te=[q],re={h1:({...t})=>e("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({...t})=>e("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({...t})=>e("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({...t})=>e("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({...t})=>e("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({...t})=>e("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({className:t,children:n,...i})=>!t?.includes("language-")?e("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...i,children:n}):e("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...i,children:n}),pre:({...t})=>e("pre",{className:"my-2",...t}),a:({...t})=>e("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...t}),strong:({...t})=>e("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({...t})=>e("em",{className:"italic",...t}),blockquote:({...t})=>e("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function oe({content:t,markdown:n=!1,position:i="bottom",size:x="sm",className:B="",visible:R=!0,editable:f=!1,onSave:u,onReset:d,width:M="md",title:g,markdownEditor:h,markdownEditorUnavailableLabel:L,labels:I}){let r=V(I),[m,S]=b(!1),[l,p]=b(!1),[v,y]=b(""),[T,k]=b(!1),[O,o]=b(null),P=E(null),H=E(null),z=E(null),s=E(null);W(()=>{if(!m)return;let c=w=>{P.current&&!P.current.contains(w.target)&&H.current&&!H.current.contains(w.target)&&(l||S(!1))},_=w=>{w.key==="Escape"&&(l?(p(!1),y("")):S(!1))};return document.addEventListener("mousedown",c),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",_)}},[m,l]),W(()=>{l&&z.current&&z.current.focus()},[l]),W(()=>()=>{s.current&&clearTimeout(s.current)},[]);let U=C(()=>{y(typeof t=="string"?t:""),p(!0),o(null)},[t]),A=C(()=>{p(!1),y(""),o(null)},[]),D=C(async()=>{if(!u){o({type:"error",text:r.helpButtonNoSave});return}k(!0);try{await u(v)?(o({type:"success",text:r.helpButtonSaved}),p(!1),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(null),2e3)):o({type:"error",text:r.helpButtonSaveError})}catch{o({type:"error",text:r.helpButtonSaveError})}finally{k(!1)}},[v,u,r]),$=C(async()=>{if(d&&confirm(r.helpButtonResetConfirm)){k(!0);try{await d()?(o({type:"success",text:r.helpButtonResetDone}),p(!1),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>o(null),2e3)):o({type:"error",text:r.helpButtonResetError})}catch{o({type:"error",text:r.helpButtonResetError})}finally{k(!1)}}},[d,r]),N=t;return R?a("div",{className:"relative inline-flex items-center",children:[e("button",{type:"button",ref:P,onClick:()=>S(!m),className:`
|
|
2
|
+
${Y[x]}
|
|
3
3
|
inline-flex items-center justify-center
|
|
4
4
|
rounded-full border border-gray-300 dark:border-gray-600
|
|
5
5
|
bg-white dark:bg-gray-800
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
hover:border-gray-400 dark:hover:border-gray-500
|
|
11
11
|
transition-all duration-150
|
|
12
12
|
focus:outline-none focus:ring-2 focus:ring-blue-500/50
|
|
13
|
-
${
|
|
14
|
-
`,"aria-label":
|
|
15
|
-
absolute z-50 ${
|
|
16
|
-
${
|
|
13
|
+
${B}
|
|
14
|
+
`,"aria-label":r.helpButtonShow,"aria-expanded":m,children:e("span",{className:"font-medium",children:"?"})}),m&&a("div",{ref:H,className:`
|
|
15
|
+
absolute z-50 ${Z[i]}
|
|
16
|
+
${ee[M]} max-h-[80vh] overflow-hidden flex flex-col
|
|
17
17
|
bg-white dark:bg-gray-900
|
|
18
18
|
border border-gray-200 dark:border-gray-700
|
|
19
19
|
rounded-xl shadow-xl
|
|
20
20
|
text-sm text-gray-700 dark:text-gray-300
|
|
21
21
|
animate-in fade-in-0 zoom-in-95 duration-150
|
|
22
|
-
`,role:"tooltip",children:[(
|
|
22
|
+
`,role:"tooltip",children:[(g||f)&&a("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[e("div",{className:"flex items-center gap-2",children:g&&e("h3",{className:"text-sm font-semibold",children:g})}),f&&e("div",{className:"flex items-center gap-1",children:l?a(ae,{children:[e("button",{type:"button",onClick:D,disabled:T,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonSave,children:T?X:F}),e("button",{type:"button",onClick:A,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonCancel,children:J}),d&&e("button",{type:"button",onClick:$,disabled:T,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonReset,children:Q})]}):e("button",{type:"button",onClick:U,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonEdit,children:j})})]}),O&&e("div",{className:`px-4 py-2 text-xs ${O.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:O.text}),e("div",{className:"flex-1 overflow-y-auto p-4",children:l?n?h?e(h,{value:v,onChange:y,placeholder:r.markdownEditorPlaceholder}):e("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:L??r.markdownEditorUnavailable}):e("div",{className:"space-y-2",children:e("textarea",{ref:z,"aria-label":r.helpButtonContent,value:v,onChange:c=>y(c.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:r.helpButtonContentPlaceholder})}):typeof N=="string"?e("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:n?e(K,{remarkPlugins:te,components:re,children:N}):e("div",{dangerouslySetInnerHTML:{__html:G.sanitize(N)}})}):N})]})]}):null}function ce({children:t,content:n,markdown:i=!1,position:x="bottom",size:B="sm",visible:R=!0,editable:f=!1,onSave:u,onReset:d,width:M="md",title:g,className:h,markdownEditor:L,markdownEditorUnavailableLabel:I,labels:r}){return a("div",{className:"inline-flex items-center gap-2.5",children:[t,e(oe,{content:n,markdown:i,position:x,size:B,visible:R,editable:f,onSave:u,onReset:d,width:M,title:g,className:h,markdownEditor:L,markdownEditorUnavailableLabel:I,labels:r})]})}export{oe as HelpButton,ce as WithHelpButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var l=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var c=(n,r)=>{for(var d in r)l(n,d,{get:r[d],enumerable:!0})},k=(n,r,d,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of p(r))!u.call(n,t)&&t!==d&&l(n,t,{get:()=>r[t],enumerable:!(i=m(r,t))||i.enumerable});return n};var P=n=>k(l({},"__esModule",{value:!0}),n);var b={};c(b,{MarkdownEditor:()=>g});module.exports=P(b);var E=require("@mdxeditor/editor/style.css"),o=require("@mdxeditor/editor"),a=require("react"),s=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),h=()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(o.UndoRedo,{}),(0,e.jsx)(o.BlockTypeSelect,{}),(0,e.jsx)(o.BoldItalicUnderlineToggles,{}),(0,e.jsx)(o.CodeToggle,{}),(0,e.jsx)(o.CreateLink,{}),(0,e.jsx)(o.ListsToggle,{}),(0,e.jsx)(o.InsertThematicBreak,{})]}),w=[(0,o.headingsPlugin)(),(0,o.listsPlugin)(),(0,o.quotePlugin)(),(0,o.linkPlugin)(),(0,o.linkDialogPlugin)(),(0,o.codeBlockPlugin)({defaultCodeBlockLanguage:""}),(0,o.thematicBreakPlugin)(),(0,o.markdownShortcutPlugin)(),(0,o.toolbarPlugin)({toolbarContents:h})],g=(0,a.forwardRef)(({value:n,onChange:r,placeholder:d},i)=>{let t=(0,s.useUILabels)();return(0,e.jsx)("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-white dark:bg-gray-800",children:(0,e.jsx)(o.MDXEditor,{ref:i,markdown:n,onChange:r,placeholder:d??t.markdownEditorPlaceholder,contentEditableClassName:"prose prose-sm dark:prose-invert max-w-none p-3 min-h-[16rem] focus:outline-none",plugins:w})})});g.displayName="MarkdownEditor";0&&(module.exports={MarkdownEditor});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import"@mdxeditor/editor/style.css";import{MDXEditor as i,headingsPlugin as
|
|
1
|
+
"use client";import"@mdxeditor/editor/style.css";import{MDXEditor as i,headingsPlugin as l,listsPlugin as a,quotePlugin as s,linkPlugin as g,linkDialogPlugin as m,codeBlockPlugin as p,thematicBreakPlugin as u,markdownShortcutPlugin as c,toolbarPlugin as k,BlockTypeSelect as P,BoldItalicUnderlineToggles as h,CodeToggle as w,ListsToggle as b,CreateLink as f,InsertThematicBreak as E,UndoRedo as M}from"@mdxeditor/editor";import{forwardRef as y}from"react";import{useUILabels as T}from"../../lib/i18n.js";import{Fragment as N,jsx as o,jsxs as v}from"react/jsx-runtime";var B=()=>v(N,{children:[o(M,{}),o(P,{}),o(h,{}),o(w,{}),o(f,{}),o(b,{}),o(E,{})]}),C=[l(),a(),s(),g(),m(),p({defaultCodeBlockLanguage:""}),u(),c(),k({toolbarContents:B})],L=y(({value:e,onChange:r,placeholder:n},t)=>{let d=T();return o("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-white dark:bg-gray-800",children:o(i,{ref:t,markdown:e,onChange:r,placeholder:n??d.markdownEditorPlaceholder,contentEditableClassName:"prose prose-sm dark:prose-invert max-w-none p-3 min-h-[16rem] focus:outline-none",plugins:C})})});L.displayName="MarkdownEditor";export{L as MarkdownEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var U=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var s in e)U(t,s,{get:e[s],enumerable:!0})},$=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of B(e))!G.call(t,l)&&l!==s&&U(t,l,{get:()=>e[l],enumerable:!(i=j(e,l))||i.enumerable});return t};var z=t=>$(U({},"__esModule",{value:!0}),t);var W={};S(W,{ImageUploader:()=>O});module.exports=z(W);var a=require("react"),p=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),A={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},D=(t,e)=>new Promise((s,i)=>{let l=new FileReader;l.onload=g=>{let f=g.target?.result;s(f)},l.onerror=()=>{i(new Error(e))},l.readAsDataURL(t)});function O({value:t,onChange:e,onUpload:s,label:i,maxSize:l=5*1024*1024,accept:g="image/*",helpText:f,disabled:b=!1,className:L="",showUrlInput:E=!0,urlPlaceholder:C="https://example.com/image.jpg",labels:P,aspectRatio:h="16/9"}){let o=(0,p.useUILabels)(P),v=i??o.imageUploaderLabel,[y,k]=(0,a.useState)(!1),[I,n]=(0,a.useState)(null),c=(0,a.useRef)(null),w=(0,a.useId)(),x=(0,a.useMemo)(()=>(l/(1024*1024)).toFixed(0),[l]),F=(0,p.formatUILabel)(o.imageUploaderHelp,{formats:g==="image/*"?"JPG, PNG, GIF, WebP":g,maxSize:x}),R=(0,a.useCallback)(async u=>{let m=u.target.files?.[0];if(m){if(!m.type.startsWith("image/")){n(o.imageUploaderNotImage);return}if(m.size>l){n((0,p.formatUILabel)(o.imageUploaderTooLarge,{maxSize:x}));return}k(!0),n(null);try{if(s){let d=await s(m);e(d)}else{let d=await D(m,o.imageUploaderReadError);e(d)}c.current&&(c.current.value="")}catch(d){console.error("Upload error:",d),n(d instanceof Error?d.message:o.imageUploaderUploadError)}finally{k(!1)}}},[l,x,e,s,o]),M=(0,a.useCallback)(()=>{e(""),c.current&&(c.current.value=""),n(null)},[e]),N=(0,a.useCallback)(u=>{e(u),n(null)},[e]),T=(0,a.useCallback)(()=>{c.current?.click()},[]),H=(0,a.useCallback)(u=>{N(u.target.value)},[N]);return(0,r.jsxs)("div",{className:`space-y-2 ${L}`,children:[v&&(0,r.jsx)("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:v}),t&&(0,r.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,r.jsx)("div",{className:`relative ${A[h]} ${h==="auto"?"max-h-64":""} flex items-center justify-center`,children:(0,r.jsx)("img",{src:t,alt:o.imageUploaderPreview,className:"w-full h-full object-contain"})}),(0,r.jsx)("button",{type:"button",onClick:M,disabled:b,className:"absolute top-2 right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:o.imageUploaderRemove,children:"\xD7"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:c,type:"file","aria-label":o.imageUploaderChoose,accept:g,onChange:R,className:"hidden",disabled:b||y}),(0,r.jsx)("button",{type:"button",onClick:T,disabled:b||y,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:y?o.imageUploaderUploading:t?o.imageUploaderChangeButton:o.imageUploaderChooseButton})]}),E&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{htmlFor:w,className:"block text-xs text-gray-500 dark:text-gray-400",children:o.imageUploaderUrlLabel}),(0,r.jsx)("input",{id:w,type:"url",value:t||"",onChange:H,placeholder:C,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-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),I&&(0,r.jsxs)("div",{className:"text-red-600 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 ",I]}),(0,r.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:f||F})]})}0&&(module.exports={ImageUploader});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as N,useRef as B,useCallback as u,useMemo as G,useId as S}from"react";import{formatUILabel as L,useUILabels as $}from"../../lib/i18n.js";import{jsx as a,jsxs as m}from"react/jsx-runtime";var z={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},A=(o,r)=>new Promise((i,b)=>{let t=new FileReader;t.onload=n=>{let f=n.target?.result;i(f)},t.onerror=()=>{b(new Error(r))},t.readAsDataURL(o)});function W({value:o,onChange:r,onUpload:i,label:b,maxSize:t=5*1024*1024,accept:n="image/*",helpText:f,disabled:p=!1,className:E="",showUrlInput:C=!0,urlPlaceholder:P="https://example.com/image.jpg",labels:F,aspectRatio:U="16/9"}){let e=$(F),h=b??e.imageUploaderLabel,[y,v]=N(!1),[k,s]=N(null),d=B(null),I=S(),x=G(()=>(t/(1024*1024)).toFixed(0),[t]),R=L(e.imageUploaderHelp,{formats:n==="image/*"?"JPG, PNG, GIF, WebP":n,maxSize:x}),M=u(async c=>{let g=c.target.files?.[0];if(g){if(!g.type.startsWith("image/")){s(e.imageUploaderNotImage);return}if(g.size>t){s(L(e.imageUploaderTooLarge,{maxSize:x}));return}v(!0),s(null);try{if(i){let l=await i(g);r(l)}else{let l=await A(g,e.imageUploaderReadError);r(l)}d.current&&(d.current.value="")}catch(l){console.error("Upload error:",l),s(l instanceof Error?l.message:e.imageUploaderUploadError)}finally{v(!1)}}},[t,x,r,i,e]),T=u(()=>{r(""),d.current&&(d.current.value=""),s(null)},[r]),w=u(c=>{r(c),s(null)},[r]),H=u(()=>{d.current?.click()},[]),j=u(c=>{w(c.target.value)},[w]);return m("div",{className:`space-y-2 ${E}`,children:[h&&a("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:h}),o&&m("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:[a("div",{className:`relative ${z[U]} ${U==="auto"?"max-h-64":""} flex items-center justify-center`,children:a("img",{src:o,alt:e.imageUploaderPreview,className:"w-full h-full object-contain"})}),a("button",{type:"button",onClick:T,disabled:p,className:"absolute top-2 right-2 bg-red-500 text-white rounded-full w-6 h-6 flex items-center justify-center text-xs hover:bg-red-600 transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:e.imageUploaderRemove,children:"\xD7"})]}),m("div",{className:"flex gap-2",children:[a("input",{ref:d,type:"file","aria-label":e.imageUploaderChoose,accept:n,onChange:M,className:"hidden",disabled:p||y}),a("button",{type:"button",onClick:H,disabled:p||y,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:y?e.imageUploaderUploading:o?e.imageUploaderChangeButton:e.imageUploaderChooseButton})]}),C&&m("div",{className:"space-y-1",children:[a("label",{htmlFor:I,className:"block text-xs text-gray-500 dark:text-gray-400",children:e.imageUploaderUrlLabel}),a("input",{id:I,type:"url",value:o||"",onChange:j,placeholder:P,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-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed"})]}),k&&m("div",{className:"text-red-600 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 ",k]}),a("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:f||R})]})}export{W as ImageUploader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var V=(t,e)=>{for(var l in e)d(t,l,{get:e[l],enumerable:!0})},W=(t,e,l,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of H(e))!M.call(t,r)&&r!==l&&d(t,r,{get:()=>e[r],enumerable:!(o=T(e,r))||o.enumerable});return t};var q=t=>W(d({},"__esModule",{value:!0}),t);var P={};V(P,{Label:()=>m});module.exports=q(P);var s=require("../../lib/cn.cjs"),i=require("../../lib/server-labels.cjs"),a=require("react/jsx-runtime"),v={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},p={xs:"w-3 h-3",sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-4.5 h-4.5",xl:"w-5 h-5"},A={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},I={default:{default:"text-gray-700 dark:text-gray-200",light:"text-gray-500 dark:text-gray-400",strong:"text-gray-900 dark:text-white"},primary:{default:"text-blue-600 dark:text-blue-400",light:"text-blue-400 dark:text-blue-300",strong:"text-blue-700 dark:text-blue-300"},secondary:{default:"text-purple-600 dark:text-purple-400",light:"text-purple-400 dark:text-purple-300",strong:"text-purple-700 dark:text-purple-300"},success:{default:"text-green-600 dark:text-green-400",light:"text-green-400 dark:text-green-300",strong:"text-green-700 dark:text-green-300"},warning:{default:"text-yellow-600 dark:text-yellow-400",light:"text-yellow-400 dark:text-yellow-300",strong:"text-yellow-700 dark:text-yellow-300"},error:{default:"text-red-600 dark:text-red-400",light:"text-red-400 dark:text-red-300",strong:"text-red-700 dark:text-red-300"},info:{default:"text-cyan-600 dark:text-cyan-400",light:"text-cyan-400 dark:text-cyan-300",strong:"text-cyan-700 dark:text-cyan-300"},muted:{default:"text-gray-500 dark:text-gray-400",light:"text-gray-400 dark:text-gray-500",strong:"text-gray-600 dark:text-gray-300"}};function m({children:t,size:e="md",color:l="default",variant:o="default",weight:r="medium",textColor:b,required:n=!1,requiredIndicator:u="*",requiredLabel:y=i.serverUILabels.labelRequired,optional:f=!1,optionalText:k=i.serverUILabels.labelOptional,tooltip:h,icon:x,endIcon:g,disabled:c=!1,truncate:L=!1,as:w="label",className:C,...N}){let R=w,S=(0,s.cn)("inline-flex items-center gap-1.5 transition-colors",v[e],A[r]),z=b||I[l][o];return(0,a.jsxs)(R,{className:(0,s.cn)(S,z,c?"opacity-50 cursor-not-allowed":"cursor-default",C),title:h,"aria-disabled":c,...N,children:[x&&(0,a.jsx)("span",{className:(0,s.cn)("shrink-0",p[e]),children:x}),(0,a.jsxs)("span",{className:(0,s.cn)(L&&"truncate"),children:[t,n&&(0,a.jsx)("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:u}),n&&(0,a.jsx)("span",{className:"sr-only",children:y})]}),f&&!n&&(0,a.jsx)("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:k}),g&&(0,a.jsx)("span",{className:(0,s.cn)("shrink-0",p[e]),children:g})]})}m.displayName="Label";0&&(module.exports={Label});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as e}from"../../lib/cn.js";import{jsx as t,jsxs as
|
|
1
|
+
import{cn as e}from"../../lib/cn.js";import{serverUILabels as n}from"../../lib/server-labels.js";import{jsx as t,jsxs as i}from"react/jsx-runtime";var z={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},d={xs:"w-3 h-3",sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-4.5 h-4.5",xl:"w-5 h-5"},T={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},H={default:{default:"text-gray-700 dark:text-gray-200",light:"text-gray-500 dark:text-gray-400",strong:"text-gray-900 dark:text-white"},primary:{default:"text-blue-600 dark:text-blue-400",light:"text-blue-400 dark:text-blue-300",strong:"text-blue-700 dark:text-blue-300"},secondary:{default:"text-purple-600 dark:text-purple-400",light:"text-purple-400 dark:text-purple-300",strong:"text-purple-700 dark:text-purple-300"},success:{default:"text-green-600 dark:text-green-400",light:"text-green-400 dark:text-green-300",strong:"text-green-700 dark:text-green-300"},warning:{default:"text-yellow-600 dark:text-yellow-400",light:"text-yellow-400 dark:text-yellow-300",strong:"text-yellow-700 dark:text-yellow-300"},error:{default:"text-red-600 dark:text-red-400",light:"text-red-400 dark:text-red-300",strong:"text-red-700 dark:text-red-300"},info:{default:"text-cyan-600 dark:text-cyan-400",light:"text-cyan-400 dark:text-cyan-300",strong:"text-cyan-700 dark:text-cyan-300"},muted:{default:"text-gray-500 dark:text-gray-400",light:"text-gray-400 dark:text-gray-500",strong:"text-gray-600 dark:text-gray-300"}};function M({children:x,size:a="md",color:g="default",variant:c="default",weight:p="medium",textColor:m,required:r=!1,requiredIndicator:b="*",requiredLabel:u=n.labelRequired,optional:y=!1,optionalText:f=n.labelOptional,tooltip:k,icon:l,endIcon:s,disabled:o=!1,truncate:h=!1,as:L="label",className:w,...C}){let N=L,R=e("inline-flex items-center gap-1.5 transition-colors",z[a],T[p]),S=m||H[g][c];return i(N,{className:e(R,S,o?"opacity-50 cursor-not-allowed":"cursor-default",w),title:k,"aria-disabled":o,...C,children:[l&&t("span",{className:e("shrink-0",d[a]),children:l}),i("span",{className:e(h&&"truncate"),children:[x,r&&t("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:b}),r&&t("span",{className:"sr-only",children:u})]}),y&&!r&&t("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:f}),s&&t("span",{className:e("shrink-0",d[a]),children:s})]})}M.displayName="Label";export{M as Label};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var xe=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var Xe=(h,s)=>{for(var o in s)xe(h,o,{get:s[o],enumerable:!0})},$e=(h,s,o,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of Me(s))!Ke.call(h,u)&&u!==o&&xe(h,u,{get:()=>s[u],enumerable:!(i=De(s,u))||i.enumerable});return h};var Ge=h=>$e(xe({},"__esModule",{value:!0}),h);var Ye={};Xe(Ye,{LineChart:()=>Fe});module.exports=Ge(Ye);var l=require("react"),Re=require("../../lib/cn.cjs"),we=require("../../lib/i18n.cjs"),j=require("../chart/ChartAnnotations.cjs"),ke=require("../chart/ChartAxis.cjs"),re=require("../chart/ChartBrush.cjs"),Ae=require("../chart/ChartContainer.cjs"),Ve=require("../chart/ChartGrid.cjs"),Ee=require("../chart/ChartLegend.cjs"),Be=require("../chart/ChartSync.cjs"),Te=require("../chart/ChartTableView.cjs"),oe=require("../chart/ChartTooltip.cjs"),E=require("../chart/palette.cjs"),v=require("../chart/utils/cartesian.cjs"),U=require("../chart/utils/data.cjs"),ae=require("../chart/utils/decimate.cjs"),F=require("../chart/utils/format.cjs"),Pe=require("../chart/utils/path.cjs"),x=require("../chart/utils/scales.cjs"),He=require("../chart/utils/ticks.cjs"),n=require("react/jsx-runtime"),Oe=24,ze=10,_e=10,je=(0,l.memo)(function({lines:s,showMarkers:o}){return(0,n.jsx)("g",{children:s.map(i=>(0,n.jsxs)("g",{children:[i.solid?(0,n.jsx)("path",{d:i.solid,fill:"none",stroke:i.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,i.dashed?(0,n.jsx)("path",{d:i.dashed,fill:"none",stroke:i.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:"5 4"}):null,o?i.markers.map(u=>(0,n.jsx)("circle",{cx:u.x,cy:u.y,r:3,fill:i.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${u.x}-${u.y}`)):null]},i.key))})});function Ue({width:h,height:s,data:o,resolvedSeries:i,x:u,y:B,grid:k,size:Y,curve:P,forecastFrom:D,forecastLabel:L,markers:S,connectNulls:T,referenceLines:se,annotations:R,annotationsLabel:ie,overlay:le,maxPoints:w,brush:q,onBrush:J,brushLabel:he,syncEnabled:ue,margin:Q,tooltip:A,onPointClick:M,plotLabel:ce,formatValue:V,formatX:H}){let[K,X]=(0,l.useState)(null),c=K!==null&&K<o.length?K:null,[de,me]=(0,l.useState)(null),fe=(0,Be.useChartSync)(),m=ue?fe:null,e=(0,l.useMemo)(()=>{let t=i.filter(g=>!g.hidden),r=(0,v.buildCartesianGeometry)({width:h,height:s,data:o,x:u,y:B,bounds:(0,He.extent)((0,U.collectAllValues)(o,t.map(g=>g.key))),margin:Q,placement:"point",formatValue:V,formatX:H,extraTop:L?ze:0}),d=r.categoryCenters,y=r.valueScale,ne=D===void 0?-1:r.xValues.findIndex(g=>(0,x.toKey)(g)===(0,x.toKey)(D)),Ne=t.map(g=>{let _=o.map((I,Ie)=>{let be=(0,U.readNumber)(I,g.key);return{x:d[Ie],y:be===null?Number.NaN:y(be),defined:be!==null}}),ve={connectNulls:T},pe=ne>=0,Ce=I=>w&&w>0?(0,ae.decimatePath)(I,w):I,Le=Ce(pe?_.slice(0,ne+1):_),Se=g.dashed?Ce(_):pe?Ce(_.slice(ne)):[];return w||(0,ae.warnPointBudget)("LineChart",_.length),{key:g.key,color:g.color,solid:g.dashed?"":(0,Pe.buildLinePath)(Le,P,ve),dashed:g.dashed||pe?(0,Pe.buildLinePath)(Se,P,ve):"",markers:[...Le,...g.dashed?[]:Se].filter(I=>I.defined!==!1)}}),We=o.length>1?r.innerWidth/(o.length-1):0;return{visible:t,locate:(0,v.createCategoryLocator)(r),plot:(0,v.createPlotContext)({geometry:r,width:h,height:s,data:o,series:t,formatValue:V,formatX:H}),xValues:r.xValues,xPositions:d,xTicks:r.categoryTicks,yTicks:r.valueTicks,yScale:y,innerWidth:r.innerWidth,innerHeight:r.innerHeight,margin:r.margin,lines:Ne,forecastIndex:ne,showMarkers:S==="always"||S==="auto"&&We>=Oe&&o.length>1}},[o,i,u,B,h,s,Q,P,T,D,L,S,w,V,H]),p=(0,l.useCallback)(t=>e.visible.map(r=>{let d=(0,U.readNumber)(o[t],r.key);return{seriesKey:r.key,seriesLabel:(0,E.getSeriesLabel)(r),color:r.color,value:d,formattedValue:d===null?"\u2014":V(d),datum:o[t]}}),[o,e.visible,V]),Z=m?m.brush:de,ge=(0,l.useCallback)(t=>{me(t),m?.setBrush(t),J?.(t)},[m,J]),f=(0,re.useChartBrush)({enabled:q,active:Z!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:ge}),ee=(0,l.useCallback)(t=>{if(f.onPointerMove(t),A===!1||o.length===0)return;let r=t.currentTarget.getBoundingClientRect(),d=t.clientX-r.left-e.margin.left,y=(0,x.nearestIndex)(e.xPositions,d);X(y>=0?y:null),m?.setHovered(y>=0?e.xValues[y]:null)},[f,A,o.length,e.margin.left,e.xPositions,e.xValues,m]),$=(0,l.useCallback)(()=>{X(null),m?.setHovered(null)},[m]),ye=(0,l.useCallback)(t=>{if(o.length===0)return;f.onKeyDown(t,c);let r=o.length-1,d=c??0,y=t.key==="ArrowRight"?Math.min(r,d+1):t.key==="ArrowLeft"?Math.max(0,d-1):t.key==="Home"?0:t.key==="End"?r:t.key==="Escape"?null:void 0;y!==void 0&&(t.preventDefault(),X(y),m?.setHovered(y===null?null:e.xValues[y]))},[o.length,c,f,m,e.xValues]),N=(0,l.useCallback)(()=>{if(f.consumedClick()||!M||c===null)return;let[t]=p(c);t&&M({...t,index:c,x:e.xValues[c]})},[f,M,c,p,e.xValues]),te=c!==null||!m?.hovered?null:(()=>{let t=(0,x.toKey)(m.hovered),r=e.xValues.findIndex(d=>(0,x.toKey)(d)===t);return r<0?null:r})(),C=c??te,G=C===null?null:p(C),O=(G??[]).filter(t=>t.value!==null),W=f.dragging??Z,z=(()=>{if(!W)return null;let t=e.locate(W.from),r=e.locate(W.to);return t===null||r===null?null:{from:t,to:r}})(),a=(0,v.splitOverlay)(le),b=c===null||G===null?null:{x:e.xValues[c],xLabel:H(e.xValues[c],c),index:c,points:G};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:h,height:s,role:"img","aria-label":ce??[e.visible.map(t=>(0,E.getSeriesLabel)(t)).join(", "),(0,j.describeAnnotations)(R,ie)].filter(Boolean).join(". "),tabIndex:0,className:(0,Re.cn)("touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",q&&"select-none"),onPointerDown:f.onPointerDown,onPointerMove:ee,onPointerUp:f.onPointerUp,onPointerCancel:f.onPointerUp,onPointerLeave:$,onKeyDown:ye,onBlur:$,onClick:N,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(Ve.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:k==="y"||k==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:k==="x"||k==="both"?e.xTicks.map(t=>t.offset):void 0}),R?(0,n.jsx)(j.ChartAnnotationLayer,{layer:"under",annotations:R,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,z?(0,n.jsx)(re.ChartBrushLayer,{from:z.from,to:z.to,width:e.innerWidth,height:e.innerHeight,live:f.dragging!==null,label:he}):null,a.under?.(e.plot),se?.map(t=>{let r=e.yScale(t.value),d=r<_e?r+12:r-4;return(0,n.jsxs)("g",{children:[(0,n.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,n.jsx)("text",{x:e.innerWidth,y:d,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"}),L?(0,n.jsx)("text",{x:e.xPositions[e.forecastIndex]+4,y:-2,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:L}):null]}):null,(0,n.jsx)(je,{lines:e.lines,showMarkers:e.showMarkers}),R?(0,n.jsx)(j.ChartAnnotationLayer,{annotations:R,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,a.over?.(e.plot),C!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:e.xPositions[C],y1:0,x2:e.xPositions[C],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:c===null?"3 3":void 0}),O.map(t=>(0,n.jsx)("circle",{cx:e.xPositions[C],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:u.hidden?null:(0,n.jsx)(ke.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:u.label,size:Y})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:B?.hidden?null:(0,n.jsx)(ke.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:B?.label,size:Y})})]}),b&&A!==!1?(0,n.jsx)(oe.ChartTooltip,{x:e.margin.left+e.xPositions[b.index],y:e.margin.top+(O.length>0?Math.min(...O.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:h,children:typeof A=="function"?A(b):(0,n.jsx)(oe.ChartTooltipContent,{title:b.xLabel,points:b.points})}):null]})}function Fe({data:h,series:s,x:o,y:i,height:u=240,width:B,size:k="md",grid:Y="y",legend:P,tooltip:D=!0,tableView:L=!1,emphasis:S,title:T,description:se,loading:R=!1,emptyState:ie,error:le=!1,errorState:w,onRetry:q,actions:J,onPointClick:he,curve:ue="monotone",forecastFrom:Q,forecastLabel:A,markers:M="auto",connectNulls:ce=!1,referenceLines:V,annotations:H,overlay:K,legendToggle:X=!0,maxPoints:c,brush:de=!1,onBrush:me,brushLabel:fe,sync:m=!0,margin:e,locale:p,plotLabel:Z,className:ge,...f}){let ee=(0,we.useUILabels)(),[$,ye]=(0,l.useState)(()=>new Set),N=(0,l.useMemo)(()=>s.map((a,b)=>({...a,hidden:a.hidden||$.has(a.key),color:(0,E.resolveSeriesColor)(a,b,S)})),[s,$,S]),te=(0,l.useMemo)(()=>i?.format??(a=>(0,F.formatAuto)(a,p)),[i?.format,p]),C=(0,l.useMemo)(()=>o.format??(a=>o.scale==="time"?(0,F.formatXValue)(a instanceof Date?a:new Date((0,x.toNumber)(a)),p):(0,F.formatXValue)(a,p)),[o.format,o.scale,p]),G=(0,l.useCallback)(a=>{ye(b=>{let t=new Set(b);return t.has(a)?t.delete(a):t.add(a),t})},[]),O=P===void 0?s.length>=2:P!==!1,W=typeof P=="string"?P:"bottom",z=N.filter(a=>!a.hidden).length;return(0,n.jsx)(Ae.ChartContainer,{title:T,description:se,height:u,width:B,size:k,loading:R,empty:h.length===0||z===0,emptyState:ie,error:le,errorState:w,onRetry:q,actions:J,tableView:L,legendPosition:W,legend:O?(0,n.jsx)(Ee.ChartLegend,{items:(0,E.toLegendItems)(N,S),position:W,marker:"line",size:k,onToggle:X?G:void 0}):void 0,table:L?(0,n.jsx)(Te.ChartTableView,{data:h,series:N,xKey:o.key,xLabel:o.label??o.key,formatX:C,formatValue:te,caption:typeof T=="string"?T:void 0}):void 0,className:ge,...f,children:({width:a})=>(0,n.jsx)(Ue,{width:a,height:u,data:h,resolvedSeries:N,x:o,y:i,grid:Y,size:k,curve:ue,forecastFrom:Q,forecastLabel:A,markers:M,connectNulls:ce,referenceLines:V,annotations:H,annotationsLabel:ee.chartAnnotations,overlay:K,maxPoints:c,brush:de,onBrush:me,brushLabel:fe??ee.chartBrush,syncEnabled:m,margin:e,tooltip:D,onPointClick:he,plotLabel:Z,formatValue:te,formatX:C})})}0&&(module.exports={LineChart});
|
|
1
|
+
"use strict";"use client";var Se=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var ze=(u,s)=>{for(var r in s)Se(u,r,{get:s[r],enumerable:!0})},Ue=(u,s,r,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of Oe(s))!_e.call(u,c)&&c!==r&&Se(u,c,{get:()=>s[c],enumerable:!(i=Ge(s,c))||i.enumerable});return u};var je=u=>Ue(Se({},"__esModule",{value:!0}),u);var et={};ze(et,{LineChart:()=>Ze});module.exports=je(et);var l=require("react"),Ve=require("../../lib/cn.cjs"),Ae=require("../../lib/i18n.cjs"),j=require("../chart/ChartAnnotations.cjs"),Re=require("../chart/ChartAxis.cjs"),le=require("../chart/ChartBrush.cjs"),Te=require("../chart/ChartContainer.cjs"),Be=require("../chart/ChartGrid.cjs"),Ee=require("../chart/ChartLegend.cjs"),He=require("../chart/ChartSync.cjs"),We=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),E=require("../chart/palette.cjs"),k=require("../chart/utils/cartesian.cjs"),F=require("../chart/utils/data.cjs"),ue=require("../chart/utils/decimate.cjs"),ce=require("../chart/utils/format.cjs"),de=require("../chart/utils/keyboard.cjs"),H=require("../chart/utils/path.cjs"),B=require("../chart/utils/scales.cjs"),Ie=require("../chart/utils/ticks.cjs"),Ne=require("../chart/utils/timestamp.cjs"),De=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Fe=24,Ye=10,qe=10,Je=(0,l.memo)(function({lines:s,showMarkers:r}){return(0,n.jsx)("g",{children:s.map(i=>(0,n.jsxs)("g",{children:[i.solid?(0,n.jsx)("path",{d:i.solid,fill:"none",stroke:i.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}):null,i.dashed?(0,n.jsx)("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(c=>(0,n.jsx)("circle",{cx:c.x,cy:c.y,r:3,fill:i.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${c.x}-${c.y}`))]},i.key))})});function Qe({width:u,height:s,data:r,resolvedSeries:i,x:c,y:W,grid:C,size:Y,curve:b,forecastFrom:X,forecastLabel:v,markers:P,connectNulls:L,referenceLines:me,annotations:S,annotationsLabel:fe,overlay:ge,maxPoints:R,brush:q,onBrush:J,brushLabel:pe,syncEnabled:ye,margin:Q,tooltip:w,onPointClick:V,plotLabel:Ce,formatValue:A,formatX:I}){let[$,G]=(0,l.useState)(null),h=$!==null&&$<r.length?$:null,[be,xe]=(0,l.useState)(null),ke=(0,He.useChartSync)(),m=ye?ke:null,e=(0,l.useMemo)(()=>{let t=i.filter(f=>!f.hidden),o=(0,k.buildCartesianGeometry)({width:u,height:s,data:r,x:c,y:W,bounds:(0,Ie.extent)((0,F.collectAllValues)(r,t.map(f=>f.key))),margin:Q,placement:"point",formatValue:A,formatX:I,extraTop:v?Ye:0}),d=o.categoryCenters,T=o.valueScale,re=X===void 0?-1:o.xValues.findIndex(f=>(0,B.toKey)(f)===(0,B.toKey)(X)),Ke=t.map(f=>{let U=r.map((ie,$e)=>{let Le=(0,F.readNumber)(ie,f.key);return{x:d[$e],y:Le===null?Number.NaN:T(Le),defined:Le!==null}}),we={connectNulls:L},oe=re>=0,Pe=ie=>R&&R>0?(0,ue.decimatePath)(ie,R):ie,ae=Pe(oe?U.slice(0,re+1):U),se=f.dashed?Pe(U):oe?Pe(U.slice(re)):[];R||(0,ue.warnPointBudget)("LineChart",U.length);let Xe=f.dashed?se:oe?[...ae,...se.slice(1)]:ae;return{key:f.key,color:f.color,solid:f.dashed?"":(0,H.buildLinePath)(ae,b,we),dashed:f.dashed||oe?(0,H.buildLinePath)(se,b,we):"",markers:[...ae,...f.dashed?[]:se].filter(H.isDrawable),isolated:(0,H.isolatedPoints)(Xe,L)}}),Me=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:s,data:r,series:t,formatValue:A,formatX:I}),xValues:o.xValues,xPositions:d,xTicks:o.categoryTicks,yTicks:o.valueTicks,yScale:T,innerWidth:o.innerWidth,innerHeight:o.innerHeight,margin:o.margin,lines:Ke,forecastIndex:re,showMarkers:P==="always"||P==="auto"&&Me>=Fe&&r.length>1}},[r,i,c,W,u,s,Q,b,L,X,v,P,R,A,I]),y=(0,l.useCallback)(t=>e.visible.map(o=>{let d=(0,F.readNumber)(r[t],o.key);return{seriesKey:o.key,seriesLabel:(0,E.getSeriesLabel)(o),color:o.color,value:d,formattedValue:d===null?"\u2014":A(d),datum:r[t]}}),[r,e.visible,A]),Z=m?m.brush:be,ve=(0,l.useCallback)(t=>{xe(t),m?.setBrush(t),J?.(t)},[m,J]),g=(0,le.useChartBrush)({enabled:q,active:Z!==null,centers:e.xPositions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:ve}),ee=(0,l.useCallback)(t=>{if(g.onPointerMove(t),w===!1||r.length===0)return;let o=t.currentTarget.getBoundingClientRect(),d=t.clientX-o.left-e.margin.left,T=(0,B.nearestIndex)(e.xPositions,d);G(T>=0?T:null),m?.setHovered(T>=0?e.xValues[T]:null)},[g,w,r.length,e.margin.left,e.xPositions,e.xValues,m]),O=(0,l.useCallback)(()=>{G(null),m?.setHovered(null)},[m]),N=(0,l.useCallback)(()=>{if(!V||h===null)return;let[t]=y(h);t&&V({...t,index:h,x:e.xValues[h]})},[V,h,y,e.xValues]),D=(0,l.useCallback)(t=>{if(r.length===0)return;let o=V&&h!==null&&e.visible.length>0;if((0,de.pressChartMark)(t,o?N:null))return;g.onKeyDown(t,h);let d=(0,de.chartCursorTarget)(t.key,h,r.length,"x");d!==void 0&&(t.preventDefault(),G(d),m?.setHovered(d===null?null:e.xValues[d]))},[r.length,h,g,m,e.xValues,e.visible.length,V,N]),te=(0,l.useCallback)(()=>{g.consumedClick()||N()},[g,N]),ne=h!==null||!m?.hovered?null:(()=>{let t=(0,B.toKey)(m.hovered),o=e.xValues.findIndex(d=>(0,B.toKey)(d)===t);return o<0?null:o})(),x=h??ne,_=x===null?null:y(x),K=(_??[]).filter(t=>t.value!==null),z=g.dragging??Z,a=(()=>{if(!z)return null;let t=e.locate(z.from),o=e.locate(z.to);return t===null||o===null?null:{from:t,to:o}})(),M=(0,k.splitOverlay)(ge),p=h===null||_===null?null:{x:e.xValues[h],xLabel:I(e.xValues[h],h),index:h,points:_};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:s,role:"img","aria-label":Ce??[e.visible.map(t=>(0,E.getSeriesLabel)(t)).join(", "),(0,j.describeAnnotations)(S,fe)].filter(Boolean).join(". "),tabIndex:0,className:(0,Ve.cn)(De.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",q&&"select-none"),onPointerDown:g.onPointerDown,onPointerMove:ee,onPointerUp:g.onPointerUp,onPointerCancel:g.onPointerUp,onPointerLeave:O,onKeyDown:D,onBlur:O,onClick:te,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(Be.ChartGrid,{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}),S?(0,n.jsx)(j.ChartAnnotationLayer,{layer:"under",annotations:S,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,a?(0,n.jsx)(le.ChartBrushLayer,{from:a.from,to:a.to,width:e.innerWidth,height:e.innerHeight,live:g.dragging!==null,label:pe}):null,M.under?.(e.plot),me?.map(t=>{let o=e.yScale(t.value),d=o<qe?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:d,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)(Je,{lines:e.lines,showMarkers:e.showMarkers}),S?(0,n.jsx)(j.ChartAnnotationLayer,{annotations:S,xAt:e.locate,yAt:e.yScale,width:e.innerWidth,height:e.innerHeight}):null,M.over?.(e.plot),x!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:e.xPositions[x],y1:0,x2:e.xPositions[x],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:h===null?"3 3":void 0}),K.map(t=>(0,n.jsx)("circle",{cx:e.xPositions[x],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:c.hidden?null:(0,n.jsx)(Re.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:c.label,size:Y})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:W?.hidden?null:(0,n.jsx)(Re.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:W?.label,size:Y})})]}),p&&w!==!1?(0,n.jsx)(he.ChartTooltip,{x:e.margin.left+e.xPositions[p.index],y:e.margin.top+(K.length>0?Math.min(...K.map(t=>e.yScale(t.value))):e.innerHeight/2),containerWidth:u,children:typeof w=="function"?w(p):(0,n.jsx)(he.ChartTooltipContent,{title:p.xLabel,points:p.points})}):null]})}function Ze({data:u,series:s,x:r,y:i,height:c=240,width:W,size:C="md",grid:Y="y",legend:b,tooltip:X=!0,tableView:v=!1,emphasis:P,title:L,description:me,loading:S=!1,emptyState:fe,error:ge=!1,errorState:R,onRetry:q,actions:J,onPointClick:pe,curve:ye="monotone",forecastFrom:Q,forecastLabel:w,markers:V="auto",connectNulls:Ce=!1,referenceLines:A,annotations:I,overlay:$,legendToggle:G=!0,maxPoints:h,brush:be=!1,onBrush:xe,brushLabel:ke,sync:m=!0,margin:e,locale:y,plotLabel:Z,className:ve,...g}){let ee=(0,Ae.useUILabels)(),[O,N]=(0,l.useState)(()=>new Set),D=(0,l.useMemo)(()=>s.map((a,M)=>({...a,hidden:a.hidden||O.has(a.key),color:(0,E.resolveSeriesColor)(a,M,P)})),[s,O,P]),te=(0,l.useMemo)(()=>i?.format??(a=>(0,ce.formatAuto)(a,y)),[i?.format,y]),ne=(0,l.useMemo)(()=>r.format??(a=>r.scale==="time"?(0,Ne.formatTimeValue)(a,y):(0,ce.formatXValue)(a,y)),[r.format,r.scale,y]),x=(0,l.useCallback)(a=>{N(M=>{let p=new Set(M);return p.has(a)?p.delete(a):p.add(a),p})},[]),_=b===void 0?s.length>=2:b!==!1,K=typeof b=="string"?b:"bottom",z=D.filter(a=>!a.hidden).length;return(0,n.jsx)(Te.ChartContainer,{title:L,description:me,height:c,width:W,size:C,loading:S,empty:u.length===0||z===0,emptyState:fe,error:ge,errorState:R,onRetry:q,actions:J,tableView:v,legendPosition:K,legend:_?(0,n.jsx)(Ee.ChartLegend,{items:(0,E.toLegendItems)(D,P),position:K,marker:"line",size:C,onToggle:G?x:void 0}):void 0,table:v?(0,n.jsx)(We.ChartTableView,{data:u,series:D,xKey:r.key,xLabel:r.label??r.key,formatX:ne,formatValue:te,caption:typeof L=="string"?L:void 0}):void 0,className:ve,...g,children:({width:a})=>(0,n.jsx)(Qe,{width:a,height:c,data:u,resolvedSeries:D,x:r,y:i,grid:Y,size:C,curve:ye,forecastFrom:Q,forecastLabel:w,markers:V,connectNulls:Ce,referenceLines:A,annotations:I,annotationsLabel:ee.chartAnnotations,overlay:$,maxPoints:h,brush:be,onBrush:xe,brushLabel:ke??ee.chartBrush,syncEnabled:m,margin:e,tooltip:X,onPointClick:pe,plotLabel:Z,formatValue:te,formatX:ne})})}0&&(module.exports={LineChart});
|