@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.
Files changed (150) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +116 -18
  2. package/README.md +47 -5
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/avatar/Avatar.cjs +1 -1
  6. package/dist/components/avatar/Avatar.js +1 -1
  7. package/dist/components/banner/Banner.cjs +1 -1
  8. package/dist/components/banner/Banner.js +1 -1
  9. package/dist/components/bar-chart/BarChart.cjs +1 -1
  10. package/dist/components/bar-chart/BarChart.js +1 -1
  11. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  12. package/dist/components/box-plot/BoxPlot.js +1 -1
  13. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  14. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  15. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  16. package/dist/components/bullet-chart/BulletChart.js +1 -1
  17. package/dist/components/calendar/Calendar.cjs +1 -1
  18. package/dist/components/calendar/Calendar.js +1 -1
  19. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  20. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  21. package/dist/components/chart/ChartBrush.cjs +1 -1
  22. package/dist/components/chart/ChartBrush.js +1 -1
  23. package/dist/components/chart/ChartExportButton.cjs +1 -1
  24. package/dist/components/chart/ChartExportButton.js +1 -1
  25. package/dist/components/chart/ChartSync.cjs +1 -1
  26. package/dist/components/chart/ChartSync.js +1 -1
  27. package/dist/components/chart/utils/cartesian.cjs +1 -1
  28. package/dist/components/chart/utils/cartesian.js +1 -1
  29. package/dist/components/chart/utils/export.cjs +1 -2
  30. package/dist/components/chart/utils/export.js +1 -2
  31. package/dist/components/chart/utils/keyboard.cjs +1 -0
  32. package/dist/components/chart/utils/keyboard.js +1 -0
  33. package/dist/components/chart/utils/path.cjs +1 -1
  34. package/dist/components/chart/utils/path.js +1 -1
  35. package/dist/components/chart/utils/time.cjs +1 -1
  36. package/dist/components/chart/utils/time.js +1 -1
  37. package/dist/components/chart/utils/timestamp.cjs +1 -0
  38. package/dist/components/chart/utils/timestamp.js +1 -0
  39. package/dist/components/chart/utils/touch.cjs +1 -0
  40. package/dist/components/chart/utils/touch.js +1 -0
  41. package/dist/components/chip/Chip.cjs +1 -1
  42. package/dist/components/chip/Chip.js +1 -1
  43. package/dist/components/datagrid/DataGrid.cjs +1 -2
  44. package/dist/components/datagrid/DataGrid.js +1 -2
  45. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  46. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  47. package/dist/components/dropdown/Dropdown.cjs +1 -1
  48. package/dist/components/dropdown/Dropdown.js +1 -1
  49. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  50. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  51. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  52. package/dist/components/dropdown/DropdownContent.js +1 -1
  53. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  54. package/dist/components/dropdown/DropdownItem.js +1 -1
  55. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  56. package/dist/components/dropdown/DropdownRadio.js +1 -1
  57. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  58. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  59. package/dist/components/dropdown/hooks/index.cjs +1 -1
  60. package/dist/components/dropdown/hooks/index.js +1 -1
  61. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  62. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  63. package/dist/components/dropdown/index.cjs +1 -1
  64. package/dist/components/dropdown/index.js +1 -1
  65. package/dist/components/dropdown/menu-navigation.cjs +1 -0
  66. package/dist/components/dropdown/menu-navigation.js +1 -0
  67. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  68. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  69. package/dist/components/file-selector/FileSelector.cjs +1 -1
  70. package/dist/components/file-selector/FileSelector.js +1 -1
  71. package/dist/components/form/input/Input.cjs +1 -1
  72. package/dist/components/form/input/Input.js +1 -1
  73. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  74. package/dist/components/form/mention-input/MentionInput.js +1 -1
  75. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  76. package/dist/components/form/number-input/NumberInput.js +1 -1
  77. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  78. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  79. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  80. package/dist/components/gantt-chart/GanttChart.js +1 -1
  81. package/dist/components/header/Header.cjs +1 -1
  82. package/dist/components/header/Header.js +1 -1
  83. package/dist/components/heat-map/Heatmap.cjs +1 -1
  84. package/dist/components/heat-map/Heatmap.js +1 -1
  85. package/dist/components/help-button/HelpButton.cjs +7 -7
  86. package/dist/components/help-button/HelpButton.js +7 -7
  87. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  88. package/dist/components/help-button/MarkdownEditor.js +1 -1
  89. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  90. package/dist/components/image-uploader/ImageUploader.js +1 -1
  91. package/dist/components/label/Label.cjs +1 -1
  92. package/dist/components/label/Label.js +1 -1
  93. package/dist/components/line-chart/LineChart.cjs +1 -1
  94. package/dist/components/line-chart/LineChart.js +1 -1
  95. package/dist/components/modal/Modal.cjs +1 -1
  96. package/dist/components/modal/Modal.js +1 -1
  97. package/dist/components/pagination/Pagination.cjs +1 -1
  98. package/dist/components/pagination/Pagination.js +1 -1
  99. package/dist/components/pie-chart/PieChart.cjs +1 -1
  100. package/dist/components/pie-chart/PieChart.js +1 -1
  101. package/dist/components/radio-button/RadioButton.cjs +1 -1
  102. package/dist/components/radio-button/RadioButton.js +1 -1
  103. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  104. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  105. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  106. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  107. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  108. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  109. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  110. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  111. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  112. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  113. package/dist/components/select/Select.cjs +1 -1
  114. package/dist/components/select/Select.js +1 -1
  115. package/dist/components/tabs/Tabs.cjs +1 -1
  116. package/dist/components/tabs/Tabs.js +1 -1
  117. package/dist/components/tabs/TabsContent.cjs +1 -1
  118. package/dist/components/tabs/TabsContent.js +1 -1
  119. package/dist/components/tabs/TabsContext.cjs +1 -1
  120. package/dist/components/tabs/TabsContext.js +1 -1
  121. package/dist/components/tabs/TabsList.cjs +1 -1
  122. package/dist/components/tabs/TabsList.js +1 -1
  123. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  124. package/dist/components/tabs/TabsTrigger.js +1 -1
  125. package/dist/components/toast/Toast.cjs +1 -1
  126. package/dist/components/toast/Toast.js +1 -1
  127. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  128. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  129. package/dist/components/wizard/Wizard.cjs +1 -1
  130. package/dist/components/wizard/Wizard.js +1 -1
  131. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  132. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  133. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  134. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  135. package/dist/index.cjs +1 -1
  136. package/dist/index.d.cts +830 -175
  137. package/dist/index.d.ts +830 -175
  138. package/dist/index.js +1 -1
  139. package/dist/lib/aria-hide.cjs +1 -1
  140. package/dist/lib/aria-hide.js +1 -1
  141. package/dist/lib/csv.cjs +2 -0
  142. package/dist/lib/csv.js +2 -0
  143. package/dist/lib/i18n.cjs +1 -1
  144. package/dist/lib/i18n.js +1 -1
  145. package/dist/lib/server-labels.cjs +1 -0
  146. package/dist/lib/server-labels.js +1 -0
  147. package/dist/lib/ui-labels.cjs +1 -0
  148. package/dist/lib/ui-labels.js +1 -0
  149. package/dist/styles.css +3070 -264
  150. package/package.json +14 -14
@@ -1 +1 @@
1
- "use strict";"use client";var te=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ke=(i,r)=>{for(var t in r)te(i,t,{get:r[t],enumerable:!0})},ye=(i,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let f of pe(r))!Ce.call(i,f)&&f!==t&&te(i,f,{get:()=>r[f],enumerable:!(e=be(r,f))||e.enumerable});return i};var we=i=>ye(te({},"__esModule",{value:!0}),i);var Re={};ke(Re,{Heatmap:()=>He,resetHeatmapWarnings:()=>Xe});module.exports=we(Re);var c=require("react"),se=require("../../lib/cn.cjs"),ae=require("../chart/ChartAxis.cjs"),ue=require("../chart/ChartContainer.cjs"),ce=require("../chart/ChartScaleLegend.cjs"),me=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),M=require("../chart/palette.cjs"),z=require("../chart/utils/data.cjs"),G=require("../chart/utils/format.cjs"),k=require("../chart/utils/scales.cjs"),L=require("../chart/utils/text.cjs"),de=require("../chart/utils/ticks.cjs"),n=require("react/jsx-runtime"),ve=2,Se=2,xe=12,Le=16,oe="cell:",ne=!1,Ve=(0,c.memo)(function({cells:r,radius:t}){return(0,n.jsx)("g",{children:r.map(e=>(0,n.jsxs)("g",{children:[(0,n.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,n.jsx)("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:(0,se.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 Ee({width:i,height:r,columns:t,rows:e,lookup:f,colorScale:S,x:b,y:p,size:V,cellGap:w,cellRadius:W,showValues:I,tooltip:$,plotLabel:J,formatValue:N,formatX:A,formatY:T,onCellClick:P}){let[m,D]=(0,c.useState)(null),a=(0,c.useMemo)(()=>{let C=t.map((g,o)=>A(g,o)),s=e.map((g,o)=>T(g,o)),l={top:8,right:8,bottom:b.hidden?8:b.height??24+(b.label?16:0),left:p.hidden?8:p.height??(0,L.widestLabel)(s)+xe+(p.label?16:0)},v=Math.max(0,i-l.left-l.right),h=Math.max(0,r-l.top-l.bottom),d=(0,k.createBandScale)(t.map((g,o)=>o),[0,v],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(e.map((g,o)=>o),[0,h],{paddingInner:0,paddingOuter:0}),Y=Math.max(0,d.bandwidth-w),Z=Math.max(0,x.bandwidth-w),X=[];e.forEach((g,o)=>{t.forEach((ee,q)=>{let E=f.get(`${(0,k.toKey)(ee)}|${(0,k.toKey)(g)}`)?.value??null,u=null;if(I&&E!==null&&Z>=Le){let y=N(E);(0,L.estimateTextWidth)(y,10)+6<=Y&&(u=y)}X.push({key:`${q}-${o}`,column:q,row:o,x:d(q)+w/2,y:x(o)+w/2,width:Y,height:Z,color:E===null?"transparent":S(E),label:u,onDark:E!==null&&S.onDark(E),missing:E===null})})});let B=(0,L.labelStride)(C.length,v,(0,L.widestLabel)(C)),R=(0,L.labelStride)(s.length,h,L.AXIS_FONT_SIZE+4),O=b.hidden?[]:C.map((g,o)=>({value:t[o],offset:d.center(o),label:g})).filter((g,o)=>o%B===0),U=p.hidden?[]:s.map((g,o)=>({value:e[o],offset:x.center(o),label:g})).filter((g,o)=>o%R===0);return{margin:l,innerWidth:v,innerHeight:h,columnScale:d,rowScale:x,cells:X,columnTicks:O,rowTicks:U}},[t,e,f,S,b,p,i,r,w,I,N,A,T]),_=(0,c.useCallback)((C,s)=>{let l=t[C],v=e[s],h=f.get(`${(0,k.toKey)(l)}|${(0,k.toKey)(v)}`),d=h?.value??null;return{x:l,y:v,xLabel:A(l,C),yLabel:T(v,s),value:d,formattedValue:d===null?"\u2014":N(d),color:d===null?"transparent":S(d),datum:h?.datum}},[t,e,f,S,N,A,T]),K=(0,c.useCallback)(C=>{if($===!1||t.length===0||e.length===0)return;let s=C.currentTarget.getBoundingClientRect(),l=C.clientX-s.left-a.margin.left,v=C.clientY-s.top-a.margin.top,h=Math.floor(l/(a.columnScale.step||1)),d=Math.floor(v/(a.rowScale.step||1));if(h<0||h>=t.length||d<0||d>=e.length){D(null);return}D(x=>x?.column===h&&x.row===d?x:{column:h,row:d})},[$,t.length,e.length,a.margin,a.columnScale,a.rowScale]),Q=(0,c.useCallback)(C=>{if(t.length===0||e.length===0)return;let s=m??{column:0,row:0},l;switch(C.key){case"ArrowRight":l={...s,column:Math.min(t.length-1,s.column+1)};break;case"ArrowLeft":l={...s,column:Math.max(0,s.column-1)};break;case"ArrowDown":l={...s,row:Math.min(e.length-1,s.row+1)};break;case"ArrowUp":l={...s,row:Math.max(0,s.row-1)};break;case"Home":l={...s,column:0};break;case"End":l={...s,column:t.length-1};break;case"Escape":l=null;break;default:l=void 0}l!==void 0&&(C.preventDefault(),D(l))},[t.length,e.length,m]),j=(0,c.useCallback)(()=>{!P||!m||P(_(m.column,m.row))},[P,m,_]),H=m?_(m.column,m.row):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:i,height:r,role:"img","aria-label":J??`${b.label??b.key} / ${p.label??p.key}`,tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:K,onPointerLeave:()=>D(null),onKeyDown:Q,onBlur:()=>D(null),onClick:j,children:[(0,n.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[(0,n.jsx)(Ve,{cells:a.cells,radius:W}),m?(0,n.jsx)("rect",{x:a.columnScale(m.column)+w/2,y:a.rowScale(m.row)+w/2,width:Math.max(0,a.columnScale.bandwidth-w),height:Math.max(0,a.rowScale.bandwidth-w),rx:W,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:b.hidden?null:(0,n.jsx)(ae.ChartAxis,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:b.label,size:V})}),(0,n.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:p.hidden?null:(0,n.jsx)(ae.ChartAxis,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:p.label,size:V})})]}),m&&H&&$!==!1?(0,n.jsx)(he.ChartTooltip,{x:a.margin.left+a.columnScale.center(m.column),y:a.margin.top+a.rowScale.center(m.row),containerWidth:i,children:typeof $=="function"?$(H):(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:[H.yLabel," \xB7 ",H.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:H.color},"aria-hidden":"true"}),(0,n.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:H.formattedValue})]})]})}):null]})}function ie(i,r,t){if(t)return t;let e=new Map;return i.forEach((f,S)=>{let b=(0,z.readXValue)(f,r,S),p=(0,k.toKey)(b);e.has(p)||e.set(p,b)}),[...e.values()]}function He({data:i,x:r,y:t,value:e,format:f,domain:S,scale:b="sequential",center:p=0,steps:V,colors:w,xDomain:W,yDomain:I,cellGap:$=ve,cellRadius:J=Se,showValues:N=!1,height:A=280,width:T,size:P="md",legend:m=!0,legendLabel:D,tooltip:a=!0,tableView:_=!1,title:K,description:Q,loading:j=!1,emptyState:H,error:C=!1,errorState:s,onRetry:l,actions:v,locale:h,plotLabel:d,onCellClick:x,className:Y,...Z}){V!==void 0&&V>M.CHART_MAX_COLOR_CLASSES&&!ne&&(ne=!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,c.useMemo)(()=>ie(i,r.key,W),[i,r.key,W]),B=(0,c.useMemo)(()=>ie(i,t.key,I),[i,t.key,I]),R=(0,c.useMemo)(()=>{let u=new Map;return i.forEach((y,F)=>{let le=(0,z.readNumber)(y,e);if(le===null)return;let ge=(0,z.readXValue)(y,r.key,F),fe=(0,z.readXValue)(y,t.key,F);u.set(`${(0,k.toKey)(ge)}|${(0,k.toKey)(fe)}`,{value:le,datum:y})}),u},[i,r.key,t.key,e]),O=(0,c.useMemo)(()=>f??(u=>(0,G.formatAuto)(u,h)),[f,h]),U=(0,c.useMemo)(()=>r.format??(u=>(0,G.formatXValue)(u,h)),[r.format,h]),g=(0,c.useMemo)(()=>t.format??(u=>(0,G.formatXValue)(u,h)),[t.format,h]),o=(0,c.useMemo)(()=>{let u=S??(0,de.extent)([...R.values()].map(y=>y.value))??[0,1];return b==="diverging"?(0,M.createDivergingScale)(u,{center:p,steps:V,colors:w}):(0,M.createSequentialScale)(u,{steps:V,colors:w})},[S,R,b,p,V,w]),ee=(0,c.useMemo)(()=>B.map(u=>{let y={[t.key]:u};return X.forEach(F=>{y[`${oe}${(0,k.toKey)(F)}`]=R.get(`${(0,k.toKey)(F)}|${(0,k.toKey)(u)}`)?.value??null}),y}),[B,X,R,t.key]),q=(0,c.useMemo)(()=>X.map((u,y)=>({key:`${oe}${(0,k.toKey)(u)}`,label:U(u,y)})),[X,U]),re=m!==!1,E=typeof m=="string"?m:"bottom";return(0,n.jsx)(ue.ChartContainer,{title:K,description:Q,height:A,width:T,size:P,loading:j,empty:R.size===0,emptyState:H,error:C,errorState:s,onRetry:l,actions:v,tableView:_,legendPosition:E,legend:re?(0,n.jsx)(ce.ChartScaleLegend,{scale:o,label:D,format:O,size:P,locale:h}):void 0,table:_?(0,n.jsx)(me.ChartTableView,{data:ee,series:q,xKey:t.key,xLabel:t.label??t.key,formatX:g,formatValue:O,caption:typeof K=="string"?K:void 0}):void 0,className:Y,...Z,children:({width:u})=>(0,n.jsx)(Ee,{width:u,height:A,columns:X,rows:B,lookup:R,colorScale:o,x:r,y:t,size:P,cellGap:$,cellRadius:J,showValues:N,tooltip:a,plotLabel:d,formatValue:O,formatX:U,formatY:g,onCellClick:x})})}function Xe(){ne=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
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 ge}from"react";import{cn as fe}from"../../lib/cn.js";import{ChartAxis as ne}from"../chart/ChartAxis.js";import{ChartContainer as be}from"../chart/ChartContainer.js";import{ChartScaleLegend as pe}from"../chart/ChartScaleLegend.js";import{ChartTableView as Ce}from"../chart/ChartTableView.js";import{ChartTooltip as ke}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as re,createDivergingScale as ye,createSequentialScale as we}from"../chart/palette.js";import{readNumber as ve,readXValue as j}from"../chart/utils/data.js";import{formatAuto as Se,formatXValue as le}from"../chart/utils/format.js";import{createBandScale as oe,toKey as y}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as xe,estimateTextWidth as Le,labelStride as ie,widestLabel as se}from"../chart/utils/text.js";import{extent as Ve}from"../chart/utils/ticks.js";import{Fragment as Pe,jsx as m,jsxs as D}from"react/jsx-runtime";var Ee=2,He=2,Xe=12,Re=16,ue="cell:",ee=!1,$e=de(function({cells:h,radius:t}){return m("g",{children:h.map(e=>D("g",{children:[m("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?m("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:fe("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 Ae({width:b,height:h,columns:t,rows:e,lookup:x,colorScale:w,x:d,y:g,size:L,cellGap:C,cellRadius:_,showValues:z,tooltip:R,plotLabel:Y,formatValue:M,formatX:$,formatY:N,onCellClick:A}){let[i,P]=ge(null),a=S(()=>{let f=t.map((c,r)=>$(c,r)),l=e.map((c,r)=>N(c,r)),n={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:g.hidden?8:g.height??se(l)+Xe+(g.label?16:0)},k=Math.max(0,b-n.left-n.right),s=Math.max(0,h-n.top-n.bottom),u=oe(t.map((c,r)=>r),[0,k],{paddingInner:0,paddingOuter:0}),v=oe(e.map((c,r)=>r),[0,s],{paddingInner:0,paddingOuter:0}),q=Math.max(0,u.bandwidth-C),F=Math.max(0,v.bandwidth-C),H=[];e.forEach((c,r)=>{t.forEach((Q,O)=>{let V=x.get(`${y(Q)}|${y(c)}`)?.value??null,o=null;if(z&&V!==null&&F>=Re){let p=M(V);Le(p,10)+6<=q&&(o=p)}H.push({key:`${O}-${r}`,column:O,row:r,x:u(O)+C/2,y:v(r)+C/2,width:q,height:F,color:V===null?"transparent":w(V),label:o,onDark:V!==null&&w.onDark(V),missing:V===null})})});let I=ie(f.length,k,se(f)),X=ie(l.length,s,xe+4),K=d.hidden?[]:f.map((c,r)=>({value:t[r],offset:u.center(r),label:c})).filter((c,r)=>r%I===0),B=g.hidden?[]:l.map((c,r)=>({value:e[r],offset:v.center(r),label:c})).filter((c,r)=>r%X===0);return{margin:n,innerWidth:k,innerHeight:s,columnScale:u,rowScale:v,cells:H,columnTicks:K,rowTicks:B}},[t,e,x,w,d,g,b,h,C,z,M,$,N]),T=G((f,l)=>{let n=t[f],k=e[l],s=x.get(`${y(n)}|${y(k)}`),u=s?.value??null;return{x:n,y:k,xLabel:$(n,f),yLabel:N(k,l),value:u,formattedValue:u===null?"\u2014":M(u),color:u===null?"transparent":w(u),datum:s?.datum}},[t,e,x,w,M,$,N]),W=G(f=>{if(R===!1||t.length===0||e.length===0)return;let l=f.currentTarget.getBoundingClientRect(),n=f.clientX-l.left-a.margin.left,k=f.clientY-l.top-a.margin.top,s=Math.floor(n/(a.columnScale.step||1)),u=Math.floor(k/(a.rowScale.step||1));if(s<0||s>=t.length||u<0||u>=e.length){P(null);return}P(v=>v?.column===s&&v.row===u?v:{column:s,row:u})},[R,t.length,e.length,a.margin,a.columnScale,a.rowScale]),Z=G(f=>{if(t.length===0||e.length===0)return;let l=i??{column:0,row:0},n;switch(f.key){case"ArrowRight":n={...l,column:Math.min(t.length-1,l.column+1)};break;case"ArrowLeft":n={...l,column:Math.max(0,l.column-1)};break;case"ArrowDown":n={...l,row:Math.min(e.length-1,l.row+1)};break;case"ArrowUp":n={...l,row:Math.max(0,l.row-1)};break;case"Home":n={...l,column:0};break;case"End":n={...l,column:t.length-1};break;case"Escape":n=null;break;default:n=void 0}n!==void 0&&(f.preventDefault(),P(n))},[t.length,e.length,i]),J=G(()=>{!A||!i||A(T(i.column,i.row))},[A,i,T]),E=i?T(i.column,i.row):null;return D(Pe,{children:[D("svg",{width:b,height:h,role:"img","aria-label":Y??`${d.label??d.key} / ${g.label??g.key}`,tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:W,onPointerLeave:()=>P(null),onKeyDown:Z,onBlur:()=>P(null),onClick:J,children:[D("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[m($e,{cells:a.cells,radius:_}),i?m("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:_,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),m("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:d.hidden?null:m(ne,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:d.label,size:L})}),m("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:g.hidden?null:m(ne,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:g.label,size:L})})]}),i&&E&&R!==!1?m(ke,{x:a.margin.left+a.columnScale.center(i.column),y:a.margin.top+a.rowScale.center(i.row),containerWidth:b,children:typeof R=="function"?R(E):D("div",{className:"flex flex-col gap-1",children:[D("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[E.yLabel," \xB7 ",E.xLabel]}),D("div",{className:"flex items-center gap-2",children:[m("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:E.color},"aria-hidden":"true"}),m("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.formattedValue})]})]})}):null]})}function ce(b,h,t){if(t)return t;let e=new Map;return b.forEach((x,w)=>{let d=j(x,h,w),g=y(d);e.has(g)||e.set(g,d)}),[...e.values()]}function Fe({data:b,x:h,y:t,value:e,format:x,domain:w,scale:d="sequential",center:g=0,steps:L,colors:C,xDomain:_,yDomain:z,cellGap:R=Ee,cellRadius:Y=He,showValues:M=!1,height:$=280,width:N,size:A="md",legend:i=!0,legendLabel:P,tooltip:a=!0,tableView:T=!1,title:W,description:Z,loading:J=!1,emptyState:E,error:f=!1,errorState:l,onRetry:n,actions:k,locale:s,plotLabel:u,onCellClick:v,className:q,...F}){L!==void 0&&L>re&&!ee&&(ee=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${L} colour classes. Past ${re} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let H=S(()=>ce(b,h.key,_),[b,h.key,_]),I=S(()=>ce(b,t.key,z),[b,t.key,z]),X=S(()=>{let o=new Map;return b.forEach((p,U)=>{let ae=ve(p,e);if(ae===null)return;let me=j(p,h.key,U),he=j(p,t.key,U);o.set(`${y(me)}|${y(he)}`,{value:ae,datum:p})}),o},[b,h.key,t.key,e]),K=S(()=>x??(o=>Se(o,s)),[x,s]),B=S(()=>h.format??(o=>le(o,s)),[h.format,s]),c=S(()=>t.format??(o=>le(o,s)),[t.format,s]),r=S(()=>{let o=w??Ve([...X.values()].map(p=>p.value))??[0,1];return d==="diverging"?ye(o,{center:g,steps:L,colors:C}):we(o,{steps:L,colors:C})},[w,X,d,g,L,C]),Q=S(()=>I.map(o=>{let p={[t.key]:o};return H.forEach(U=>{p[`${ue}${y(U)}`]=X.get(`${y(U)}|${y(o)}`)?.value??null}),p}),[I,H,X,t.key]),O=S(()=>H.map((o,p)=>({key:`${ue}${y(o)}`,label:B(o,p)})),[H,B]),te=i!==!1,V=typeof i=="string"?i:"bottom";return m(be,{title:W,description:Z,height:$,width:N,size:A,loading:J,empty:X.size===0,emptyState:E,error:f,errorState:l,onRetry:n,actions:k,tableView:T,legendPosition:V,legend:te?m(pe,{scale:r,label:P,format:K,size:A,locale:s}):void 0,table:T?m(Ce,{data:Q,series:O,xKey:t.key,xLabel:t.label??t.key,formatX:c,formatValue:K,caption:typeof W=="string"?W:void 0}):void 0,className:q,...F,children:({width:o})=>m(Ae,{width:o,height:$,columns:H,rows:I,lookup:X,colorScale:r,x:h,y:t,size:A,cellGap:R,cellRadius:Y,showValues:M,tooltip:a,plotLabel:u,formatValue:K,formatX:B,formatY:c,onCellClick:v})})}function Ge(){ee=!1}export{Fe as Heatmap,Ge as resetHeatmapWarnings};
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 V=Object.create;var w=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(t,a)=>{for(var o in a)w(t,o,{get:a[o],enumerable:!0})},P=(t,a,o,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of F(a))!Q.call(t,n)&&n!==o&&w(t,n,{get:()=>a[n],enumerable:!(i=j(a,n))||i.enumerable});return t};var z=(t,a,o)=>(o=t!=null?V(J(t)):{},P(a||!t||!t.__esModule?w(o,"default",{value:t,enumerable:!0}):o,t)),Y=t=>P(w({},"__esModule",{value:!0}),t);var ce={};X(ce,{HelpButton:()=>U,WithHelpButton:()=>de});module.exports=Y(ce);var r=require("react"),A=z(require("dompurify"),1),W=z(require("react-markdown"),1),_=z(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),Z=(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"})]}),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:"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"})]}),te=(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"})]}),re=(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"})]}),oe={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"},se={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"},ne={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},le=[_.default],ie={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,...o})=>!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",...o,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",...o,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 U({content:t,markdown:a=!1,position:o="bottom",size:i="sm",className:n="",visible:E=!0,editable:f=!1,onSave:g,onReset:c,width:C="md",title:m,markdownEditor:b,markdownEditorUnavailableLabel:M}){let R=(0,D.useUILabels)(),[y,L]=(0,r.useState)(!1),[d,p]=(0,r.useState)(!1),[v,x]=(0,r.useState)(""),[T,h]=(0,r.useState)(!1),[I,s]=(0,r.useState)(null),B=(0,r.useRef)(null),H=(0,r.useRef)(null),S=(0,r.useRef)(null),l=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!y)return;let u=N=>{B.current&&!B.current.contains(N.target)&&H.current&&!H.current.contains(N.target)&&(d||L(!1))},O=N=>{N.key==="Escape"&&(d?(p(!1),x("")):L(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",O)}},[y,d]),(0,r.useEffect)(()=>{d&&S.current&&S.current.focus()},[d]),(0,r.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let $=(0,r.useCallback)(()=>{x(typeof t=="string"?t:""),p(!0),s(null)},[t]),G=(0,r.useCallback)(()=>{p(!1),x(""),s(null)},[]),K=(0,r.useCallback)(async()=>{if(!g){s({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}h(!0);try{await g(v)?(s({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),p(!1),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:"Erreur lors de la sauvegarde"})}catch{s({type:"error",text:"Erreur lors de la sauvegarde"})}finally{h(!1)}},[v,g]),q=(0,r.useCallback)(async()=>{if(c&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){h(!0);try{await c()?(s({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),p(!1),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:"Erreur lors de la r\xE9initialisation"})}catch{s({type:"error",text:"Erreur lors de la r\xE9initialisation"})}finally{h(!1)}}},[c]),k=t;return E?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:B,onClick:()=>L(!y),className:`
2
- ${oe[i]}
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
- ${n}
14
- `,"aria-label":"Afficher l'aide","aria-expanded":y,children:(0,e.jsx)("span",{className:"font-medium",children:"?"})}),y&&(0,e.jsxs)("div",{ref:H,className:`
15
- absolute z-50 ${se[o]}
16
- ${ne[C]} max-h-[80vh] overflow-hidden flex flex-col
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:[(m||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:m&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:m})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:d?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:K,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:"Sauvegarder",children:T?ae:ee}),(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:"Annuler",children:te}),c&&(0,e.jsx)("button",{type:"button",onClick:q,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\xE9initialiser",children:re})]}):(0,e.jsx)("button",{type:"button",onClick:$,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:"Modifier",children:Z})})]}),I&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${I.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:I.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:d?a?b?(0,e.jsx)(b,{value:v,onChange:x,placeholder:"\xC9crivez en Markdown..."}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:M??R.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:S,"aria-label":"Contenu d'aide",value:v,onChange:u=>x(u.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:"\xC9crivez votre contenu d'aide..."})}):typeof k=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:a?(0,e.jsx)(W.default,{remarkPlugins:le,components:ie,children:k}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:A.default.sanitize(k)}})}):k})]})]}):null}function de({children:t,content:a,markdown:o=!1,position:i="bottom",size:n="sm",visible:E=!0,editable:f=!1,onSave:g,onReset:c,width:C="md",title:m,className:b,markdownEditor:M,markdownEditorUnavailableLabel:R}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[t,(0,e.jsx)(U,{content:a,markdown:o,position:i,size:n,visible:E,editable:f,onSave:g,onReset:c,width:C,title:m,className:b,markdownEditor:M,markdownEditorUnavailableLabel:R})]})}0&&(module.exports={HelpButton,WithHelpButton});
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 p,useRef as w,useEffect as P,useCallback as E}from"react";import $ from"dompurify";import G from"react-markdown";import K from"remark-gfm";import{useUILabels as q}from"../../lib/i18n.js";import{Fragment as ae,jsx as e,jsxs as a}from"react/jsx-runtime";var V=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"})]}),j=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"})]}),F=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"})]}),J=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"})]}),Q=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"})]}),X={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"},Y={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"},Z={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ee=[K],te={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:s,...l})=>!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",...l,children:s}):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",...l,children:s}),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 re({content:t,markdown:s=!1,position:l="bottom",size:x="sm",className:C="",visible:M=!0,editable:f=!1,onSave:c,onReset:i,width:R="md",title:u,markdownEditor:b,markdownEditorUnavailableLabel:L}){let T=q(),[g,I]=p(!1),[n,m]=p(!1),[v,y]=p(""),[B,h]=p(!1),[H,r]=p(null),S=w(null),z=w(null),O=w(null),o=w(null);P(()=>{if(!g)return;let d=N=>{S.current&&!S.current.contains(N.target)&&z.current&&!z.current.contains(N.target)&&(n||I(!1))},A=N=>{N.key==="Escape"&&(n?(m(!1),y("")):I(!1))};return document.addEventListener("mousedown",d),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",A)}},[g,n]),P(()=>{n&&O.current&&O.current.focus()},[n]),P(()=>()=>{o.current&&clearTimeout(o.current)},[]);let W=E(()=>{y(typeof t=="string"?t:""),m(!0),r(null)},[t]),_=E(()=>{m(!1),y(""),r(null)},[]),D=E(async()=>{if(!c){r({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}h(!0);try{await c(v)?(r({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),m(!1),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(null),2e3)):r({type:"error",text:"Erreur lors de la sauvegarde"})}catch{r({type:"error",text:"Erreur lors de la sauvegarde"})}finally{h(!1)}},[v,c]),U=E(async()=>{if(i&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){h(!0);try{await i()?(r({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),m(!1),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(null),2e3)):r({type:"error",text:"Erreur lors de la r\xE9initialisation"})}catch{r({type:"error",text:"Erreur lors de la r\xE9initialisation"})}finally{h(!1)}}},[i]),k=t;return M?a("div",{className:"relative inline-flex items-center",children:[e("button",{type:"button",ref:S,onClick:()=>I(!g),className:`
2
- ${X[x]}
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
- ${C}
14
- `,"aria-label":"Afficher l'aide","aria-expanded":g,children:e("span",{className:"font-medium",children:"?"})}),g&&a("div",{ref:z,className:`
15
- absolute z-50 ${Y[l]}
16
- ${Z[R]} max-h-[80vh] overflow-hidden flex flex-col
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:[(u||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:u&&e("h3",{className:"text-sm font-semibold",children:u})}),f&&e("div",{className:"flex items-center gap-1",children:n?a(ae,{children:[e("button",{type:"button",onClick:D,disabled:B,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:"Sauvegarder",children:B?Q:j}),e("button",{type:"button",onClick:_,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:"Annuler",children:F}),i&&e("button",{type:"button",onClick:U,disabled:B,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\xE9initialiser",children:J})]}):e("button",{type:"button",onClick:W,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:"Modifier",children:V})})]}),H&&e("div",{className:`px-4 py-2 text-xs ${H.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:H.text}),e("div",{className:"flex-1 overflow-y-auto p-4",children:n?s?b?e(b,{value:v,onChange:y,placeholder:"\xC9crivez en Markdown..."}):e("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:L??T.markdownEditorUnavailable}):e("div",{className:"space-y-2",children:e("textarea",{ref:O,"aria-label":"Contenu d'aide",value:v,onChange:d=>y(d.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:"\xC9crivez votre contenu d'aide..."})}):typeof k=="string"?e("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s?e(G,{remarkPlugins:ee,components:te,children:k}):e("div",{dangerouslySetInnerHTML:{__html:$.sanitize(k)}})}):k})]})]}):null}function de({children:t,content:s,markdown:l=!1,position:x="bottom",size:C="sm",visible:M=!0,editable:f=!1,onSave:c,onReset:i,width:R="md",title:u,className:b,markdownEditor:L,markdownEditorUnavailableLabel:T}){return a("div",{className:"inline-flex items-center gap-2.5",children:[t,e(re,{content:s,markdown:l,position:x,size:C,visible:M,editable:f,onSave:c,onReset:i,width:R,title:u,className:b,markdownEditor:L,markdownEditorUnavailableLabel:T})]})}export{re as HelpButton,de as WithHelpButton};
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 g=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var p=(n,r)=>{for(var t in r)l(n,t,{get:r[t],enumerable:!0})},u=(n,r,t,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of c(r))!k.call(n,i)&&i!==t&&l(n,i,{get:()=>r[i],enumerable:!(d=g(r,i))||d.enumerable});return n};var m=n=>u(l({},"__esModule",{value:!0}),n);var w={};p(w,{MarkdownEditor:()=>s});module.exports=m(w);var f=require("@mdxeditor/editor/style.css"),o=require("@mdxeditor/editor"),a=require("react"),e=require("react/jsx-runtime"),P="\xC9crivez en Markdown...",E=()=>(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,{})]}),h=[(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:E})],s=(0,a.forwardRef)(({value:n,onChange:r,placeholder:t=P},d)=>(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:d,markdown:n,onChange:r,placeholder:t,contentEditableClassName:"prose prose-sm dark:prose-invert max-w-none p-3 min-h-[16rem] focus:outline-none",plugins:h})}));s.displayName="MarkdownEditor";0&&(module.exports={MarkdownEditor});
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 d,listsPlugin as l,quotePlugin as a,linkPlugin as s,linkDialogPlugin as g,codeBlockPlugin as c,thematicBreakPlugin as k,markdownShortcutPlugin as p,toolbarPlugin as u,BlockTypeSelect as m,BoldItalicUnderlineToggles as P,CodeToggle as E,ListsToggle as h,CreateLink as w,InsertThematicBreak as M,UndoRedo as f}from"@mdxeditor/editor";import{forwardRef as T}from"react";import{Fragment as B,jsx as o,jsxs as D}from"react/jsx-runtime";var b="\xC9crivez en Markdown...",y=()=>D(B,{children:[o(f,{}),o(m,{}),o(P,{}),o(E,{}),o(w,{}),o(h,{}),o(M,{})]}),C=[d(),l(),a(),s(),g(),c({defaultCodeBlockLanguage:""}),k(),p(),u({toolbarContents:y})],L=T(({value:e,onChange:r,placeholder:n=b},t)=>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,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
+ "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 f=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var T=(a,e)=>{for(var s in e)f(a,s,{get:e[s],enumerable:!0})},H=(a,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of R(e))!$.call(a,l)&&l!==s&&f(a,l,{get:()=>e[l],enumerable:!(o=M(e,l))||o.enumerable});return a};var j=a=>H(f({},"__esModule",{value:!0}),a);var D={};T(D,{ImageUploader:()=>G});module.exports=j(D);var t=require("react"),r=require("react/jsx-runtime"),A={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},B=a=>new Promise((e,s)=>{let o=new FileReader;o.onload=l=>{let u=l.target?.result;e(u)},o.onerror=()=>{s(new Error("Erreur lors de la lecture du fichier"))},o.readAsDataURL(a)});function G({value:a,onChange:e,onUpload:s,label:o="Image",maxSize:l=5*1024*1024,accept:u="image/*",helpText:w,disabled:m=!1,className:N="",showUrlInput:I=!0,urlPlaceholder:U="https://example.com/image.jpg",aspectRatio:y="16/9"}){let[p,x]=(0,t.useState)(!1),[h,n]=(0,t.useState)(null),d=(0,t.useRef)(null),v=(0,t.useId)(),b=(0,t.useMemo)(()=>(l/(1024*1024)).toFixed(0),[l]),E=`Formats accept\xE9s : ${u==="image/*"?"JPG, PNG, GIF, WebP":u} (max ${b}MB)`,C=(0,t.useCallback)(async c=>{let g=c.target.files?.[0];if(g){if(!g.type.startsWith("image/")){n("Le fichier doit \xEAtre une image");return}if(g.size>l){n(`Le fichier est trop volumineux (max ${b}MB)`);return}x(!0),n(null);try{if(s){let i=await s(g);e(i)}else{let i=await B(g);e(i)}d.current&&(d.current.value="")}catch(i){console.error("Upload error:",i),n(i instanceof Error?i.message:"Erreur lors de l'upload")}finally{x(!1)}}},[l,b,e,s]),F=(0,t.useCallback)(()=>{e(""),d.current&&(d.current.value=""),n(null)},[e]),k=(0,t.useCallback)(c=>{e(c),n(null)},[e]),P=(0,t.useCallback)(()=>{d.current?.click()},[]),L=(0,t.useCallback)(c=>{k(c.target.value)},[k]);return(0,r.jsxs)("div",{className:`space-y-2 ${N}`,children:[o&&(0,r.jsx)("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:o}),a&&(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[y]} ${y==="auto"?"max-h-64":""} flex items-center justify-center`,children:(0,r.jsx)("img",{src:a,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),(0,r.jsx)("button",{type:"button",onClick:F,disabled:m,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:"Supprimer l'image",children:"\xD7"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:d,type:"file","aria-label":"Choisir une image",accept:u,onChange:C,className:"hidden",disabled:m||p}),(0,r.jsx)("button",{type:"button",onClick:P,disabled:m||p,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:p?"\u23F3 Upload...":a?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),I&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{htmlFor:v,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),(0,r.jsx)("input",{id:v,type:"url",value:a||"",onChange:L,placeholder:U,disabled:m,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"})]}),h&&(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 ",h]}),(0,r.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:w||E})]})}0&&(module.exports={ImageUploader});
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 w,useRef as R,useCallback as g,useMemo as $,useId as T}from"react";import{jsx as r,jsxs as m}from"react/jsx-runtime";var H={"16/9":"aspect-[16/9]","4/3":"aspect-[4/3]","1/1":"aspect-square",auto:""},j=a=>new Promise((e,n)=>{let l=new FileReader;l.onload=s=>{let d=s.target?.result;e(d)},l.onerror=()=>{n(new Error("Erreur lors de la lecture du fichier"))},l.readAsDataURL(a)});function B({value:a,onChange:e,onUpload:n,label:l="Image",maxSize:s=5*1024*1024,accept:d="image/*",helpText:N,disabled:p=!1,className:I="",showUrlInput:U=!0,urlPlaceholder:E="https://example.com/image.jpg",aspectRatio:y="16/9"}){let[b,x]=w(!1),[h,o]=w(null),i=R(null),v=T(),f=$(()=>(s/(1024*1024)).toFixed(0),[s]),C=`Formats accept\xE9s : ${d==="image/*"?"JPG, PNG, GIF, WebP":d} (max ${f}MB)`,F=g(async u=>{let c=u.target.files?.[0];if(c){if(!c.type.startsWith("image/")){o("Le fichier doit \xEAtre une image");return}if(c.size>s){o(`Le fichier est trop volumineux (max ${f}MB)`);return}x(!0),o(null);try{if(n){let t=await n(c);e(t)}else{let t=await j(c);e(t)}i.current&&(i.current.value="")}catch(t){console.error("Upload error:",t),o(t instanceof Error?t.message:"Erreur lors de l'upload")}finally{x(!1)}}},[s,f,e,n]),P=g(()=>{e(""),i.current&&(i.current.value=""),o(null)},[e]),k=g(u=>{e(u),o(null)},[e]),L=g(()=>{i.current?.click()},[]),M=g(u=>{k(u.target.value)},[k]);return m("div",{className:`space-y-2 ${I}`,children:[l&&r("label",{className:"block text-sm font-semibold text-gray-700 dark:text-gray-300",children:l}),a&&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:[r("div",{className:`relative ${H[y]} ${y==="auto"?"max-h-64":""} flex items-center justify-center`,children:r("img",{src:a,alt:"Aper\xE7u",className:"w-full h-full object-contain"})}),r("button",{type:"button",onClick:P,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:"Supprimer l'image",children:"\xD7"})]}),m("div",{className:"flex gap-2",children:[r("input",{ref:i,type:"file","aria-label":"Choisir une image",accept:d,onChange:F,className:"hidden",disabled:p||b}),r("button",{type:"button",onClick:L,disabled:p||b,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:b?"\u23F3 Upload...":a?"\u{1F4C1} Changer l'image":"\u{1F4C1} Choisir une image"})]}),U&&m("div",{className:"space-y-1",children:[r("label",{htmlFor:v,className:"block text-xs text-gray-500 dark:text-gray-400",children:"Ou URL directe :"}),r("input",{id:v,type:"url",value:a||"",onChange:M,placeholder:E,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"})]}),h&&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 ",h]}),r("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:N||C})]})}export{B as ImageUploader};
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 S=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var l in e)d(t,l,{get:e[l],enumerable:!0})},M=(t,e,l,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of z(e))!T.call(t,r)&&r!==l&&d(t,r,{get:()=>e[r],enumerable:!(o=S(e,r))||o.enumerable});return t};var V=t=>M(d({},"__esModule",{value:!0}),t);var q={};H(q,{Label:()=>p});module.exports=V(q);var s=require("../../lib/cn.cjs"),a=require("react/jsx-runtime"),W={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},c={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"},P={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 p({children:t,size:e="md",color:l="default",variant:o="default",weight:r="medium",textColor:m,required:n=!1,requiredIndicator:u="*",optional:b=!1,optionalText:y="(optional)",tooltip:f,icon:i,endIcon:x,disabled:g=!1,truncate:k=!1,as:h="label",className:L,...w}){let C=h,N=(0,s.cn)("inline-flex items-center gap-1.5 transition-colors",W[e],A[r]),R=m||P[l][o];return(0,a.jsxs)(C,{className:(0,s.cn)(N,R,g?"opacity-50 cursor-not-allowed":"cursor-default",L),title:f,"aria-disabled":g,...w,children:[i&&(0,a.jsx)("span",{className:(0,s.cn)("shrink-0",c[e]),children:i}),(0,a.jsxs)("span",{className:(0,s.cn)(k&&"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:"(required)"})]}),b&&!n&&(0,a.jsx)("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:y}),x&&(0,a.jsx)("span",{className:(0,s.cn)("shrink-0",c[e]),children:x})]})}p.displayName="Label";0&&(module.exports={Label});
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 d}from"react/jsx-runtime";var R={xs:"text-xs",sm:"text-sm",md:"text-sm",lg:"text-base",xl:"text-lg"},n={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"},S={normal:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},z={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 T({children:i,size:a="md",color:x="default",variant:g="default",weight:c="medium",textColor:p,required:r=!1,requiredIndicator:m="*",optional:u=!1,optionalText:b="(optional)",tooltip:y,icon:l,endIcon:s,disabled:o=!1,truncate:f=!1,as:k="label",className:h,...L}){let w=k,C=e("inline-flex items-center gap-1.5 transition-colors",R[a],S[c]),N=p||z[x][g];return d(w,{className:e(C,N,o?"opacity-50 cursor-not-allowed":"cursor-default",h),title:y,"aria-disabled":o,...L,children:[l&&t("span",{className:e("shrink-0",n[a]),children:l}),d("span",{className:e(f&&"truncate"),children:[i,r&&t("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:m}),r&&t("span",{className:"sr-only",children:"(required)"})]}),u&&!r&&t("span",{className:"text-gray-400 dark:text-gray-500 font-normal",children:b}),s&&t("span",{className:e("shrink-0",n[a]),children:s})]})}T.displayName="Label";export{T as Label};
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});