@wakastellar/ui 0.6.0 → 1.0.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 (62) hide show
  1. package/dist/blocks/index.d.ts +0 -39
  2. package/dist/components/DataTable/DataTable.d.ts +1 -1
  3. package/dist/components/DataTable/DataTableAdvanced.d.ts +1 -1
  4. package/dist/components/DataTable/DataTableFilters.d.ts +3 -3
  5. package/dist/components/DataTable/DataTableSelection.d.ts +12 -17
  6. package/dist/components/DataTable/hooks/useDataTable.d.ts +1 -1
  7. package/dist/components/DataTable/hooks/useDataTableAdvanced.d.ts +6 -6
  8. package/dist/components/DataTable/hooks/useDataTableExport.d.ts +4 -15
  9. package/dist/components/DataTable/hooks/useDataTableImport.d.ts +2 -16
  10. package/dist/components/DataTable/hooks/useDataTableVirtualization.d.ts +1 -1
  11. package/dist/components/DataTable/index.d.ts +2 -48
  12. package/dist/components/DataTable/types.d.ts +25 -417
  13. package/dist/components/command/index.d.ts +2 -6
  14. package/dist/components/index.d.ts +0 -26
  15. package/dist/components/language-selector/index.d.ts +1 -19
  16. package/dist/components/theme-selector/index.d.ts +0 -10
  17. package/dist/components/typography/index.d.ts +1 -1
  18. package/dist/components/waka-spinner/index.d.ts +21 -57
  19. package/dist/components/waka-theme-creator/index.d.ts +22 -73
  20. package/dist/components/waka-theme-manager/index.d.ts +1 -14
  21. package/dist/context/admincrumb-context.d.ts +1 -118
  22. package/dist/context/index.d.ts +2 -2
  23. package/dist/context/language-context.d.ts +23 -177
  24. package/dist/context/theme-context.d.ts +3 -4
  25. package/dist/context/theme-provider.d.ts +19 -57
  26. package/dist/context/waka-provider.d.ts +7 -50
  27. package/dist/hooks/use-toast.d.ts +0 -116
  28. package/dist/hooks/use-translation.d.ts +1 -24
  29. package/dist/hooks/useToast.d.ts +0 -82
  30. package/dist/index.cjs.js +36 -61
  31. package/dist/index.d.ts +3 -35
  32. package/dist/index.es.js +7873 -23890
  33. package/dist/types/provider.d.ts +17 -48
  34. package/dist/ui.css +1 -1
  35. package/dist/utils/cn.d.ts +1 -15
  36. package/dist/utils/datetime-helpers.d.ts +33 -241
  37. package/dist/utils/index.d.ts +0 -4
  38. package/dist/utils/theme-loader.d.ts +30 -140
  39. package/dist/utils/tweak.d.ts +1 -14
  40. package/package.json +40 -107
  41. package/src/styles/datepicker.css +2 -9
  42. package/src/styles/globals.css +4 -4
  43. package/dist/charts.cjs.js +0 -1
  44. package/dist/charts.es.js +0 -16
  45. package/dist/cn-CAc3sAGM.js +0 -21
  46. package/dist/cn-zrNBeCrC.js +0 -1
  47. package/dist/components/DataTable/DataTableGroupRow.d.ts +0 -35
  48. package/dist/components/DataTable/DataTableRow.d.ts +0 -30
  49. package/dist/components/WakaKeycloakLogin/WakaKeycloakLogin.d.ts +0 -3
  50. package/dist/components/WakaKeycloakLogin/index.d.ts +0 -2
  51. package/dist/components/WakaKeycloakLogin/types.d.ts +0 -56
  52. package/dist/export.cjs.js +0 -1
  53. package/dist/export.es.js +0 -5
  54. package/dist/index-CENPre_9.js +0 -466
  55. package/dist/index-CHLjUBPo.js +0 -1
  56. package/dist/rich-text.cjs.js +0 -1
  57. package/dist/rich-text.es.js +0 -4
  58. package/dist/types-Bjy1Hy76.js +0 -1111
  59. package/dist/types-CHv7a1SP.js +0 -1
  60. package/dist/useDataTableImport-DqeEL4GC.js +0 -124
  61. package/dist/useDataTableImport-sQwBFAJ_.js +0 -775
  62. package/dist/utils/logger.d.ts +0 -60
@@ -1 +0,0 @@
1
- "use strict";var he=Object.create;var ie=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var Ce=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of xe(n))!ge.call(e,i)&&i!==r&&ie(e,i,{get:()=>n[i],enumerable:!(s=me(n,i))||s.enumerable});return e};var be=(e,n,r)=>(r=e!=null?he(pe(e)):{},Ce(n||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e));const t=require("react/jsx-runtime"),q=require("react"),V=require("./cn-zrNBeCrC.js"),re=require("lucide-react");function ye(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ye(q);function se({className:e,...n}){return t.jsx("div",{className:V.cn("animate-pulse rounded-md bg-muted",e),...n})}function oe(){const[e,n]=q.useState(null),[r,s]=q.useState(!0),[i,k]=q.useState(null);return q.useEffect(()=>{let f=!0;return(async()=>{try{const a=await import("recharts");f&&(n({ResponsiveContainer:a.ResponsiveContainer,BarChart:a.BarChart,LineChart:a.LineChart,AreaChart:a.AreaChart,PieChart:a.PieChart,Bar:a.Bar,Line:a.Line,Area:a.Area,Pie:a.Pie,Cell:a.Cell,XAxis:a.XAxis,YAxis:a.YAxis,CartesianGrid:a.CartesianGrid,Tooltip:a.Tooltip,Legend:a.Legend,defs:"defs",linearGradient:"linearGradient",stop:"stop"}),s(!1))}catch(a){f&&(k(a instanceof Error?a:new Error("Failed to load Recharts")),s(!1))}})(),()=>{f=!1}},[]),{components:e,loading:r,error:i,isAvailable:!r&&!i&&e!==null}}const je=["hsl(var(--chart-1, 220 70% 50%))","hsl(var(--chart-2, 160 60% 45%))","hsl(var(--chart-3, 30 80% 55%))","hsl(var(--chart-4, 280 65% 60%))","hsl(var(--chart-5, 340 75% 55%))"],J={colors:je,gridColor:"hsl(var(--border, 220 13% 91%))",axisColor:"hsl(var(--muted-foreground, 220 9% 46%))",textColor:"hsl(var(--foreground, 224 71% 4%))",tooltipBackground:"hsl(var(--popover, 0 0% 100%))",tooltipText:"hsl(var(--popover-foreground, 224 71% 4%))",tooltipBorder:"hsl(var(--border, 220 13% 91%))",fontFamily:"inherit"};function Q(e,n="default"){const r=q.useMemo(()=>({colors:e?.colors??J.colors,gridColor:e?.gridColor??J.gridColor,axisColor:e?.axisColor??J.axisColor,textColor:e?.textColor??J.textColor,tooltipBackground:e?.tooltipBackground??J.tooltipBackground,tooltipText:e?.tooltipText??J.tooltipText,tooltipBorder:e?.tooltipBorder??J.tooltipBorder,fontFamily:e?.fontFamily??J.fontFamily}),[e]),s=q.useMemo(()=>f=>r.colors[f%r.colors.length],[r.colors]),i=q.useMemo(()=>({contentStyle:{backgroundColor:r.tooltipBackground,color:r.tooltipText,border:`1px solid ${r.tooltipBorder}`,borderRadius:"var(--radius, 0.5rem)",padding:"8px 12px",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",fontFamily:r.fontFamily},wrapperStyle:{outline:"none"},itemStyle:{color:r.tooltipText,padding:"2px 0"},labelStyle:{color:r.textColor,fontWeight:600,marginBottom:"4px"}}),[r]),k=q.useMemo(()=>{const f="relative";switch(n){case"gradient":return`${f} bg-gradient-to-br from-background to-muted/20`;case"outline":return`${f} border border-border rounded-lg p-4`;case"glass":return`${f} bg-background/50 backdrop-blur-sm border border-border/50 rounded-lg p-4`;default:return f}},[n]);return{theme:r,getColor:s,tooltipStyles:i,containerClasses:k}}const ke={sm:{width:"100%",height:150},md:{width:"100%",height:250},lg:{width:"100%",height:350},xl:{width:"100%",height:450},auto:{width:"100%",height:300}},ee=j.forwardRef(({children:e,variant:n="default",size:r="md",height:s,width:i,theme:k,className:f,style:g,title:a,description:h,loading:o,error:u,responsive:c=!0},C)=>{const{components:p,loading:m,error:v,isAvailable:M}=oe(),{containerClasses:L}=Q(k,n),_=o||m,X=u||(v?"Recharts non disponible. Installez recharts pour utiliser les graphiques.":null),D=ke[r],K=i??D.width,T=s??D.height;if(_)return t.jsxs("div",{ref:C,className:V.cn(L,f),style:g,children:[a&&t.jsx(ne,{title:a,description:h}),t.jsx(se,{className:"w-full",style:{height:T}})]});if(X||!M)return t.jsxs("div",{ref:C,className:V.cn(L,f),style:g,children:[a&&t.jsx(ne,{title:a,description:h}),t.jsx("div",{className:"flex items-center justify-center text-muted-foreground text-sm border border-dashed border-border rounded-lg",style:{height:T},children:t.jsxs("div",{className:"text-center p-4",children:[t.jsx("p",{children:X||"Graphique non disponible"}),t.jsx("p",{className:"text-xs mt-1",children:"Installez recharts: pnpm add recharts"})]})})]});const{ResponsiveContainer:O}=p;return t.jsxs("div",{ref:C,className:V.cn(L,f),style:g,children:[a&&t.jsx(ne,{title:a,description:h}),c?t.jsx(O,{width:K,height:T,children:e(p)}):t.jsx("div",{style:{width:K,height:T},children:e(p)})]})});ee.displayName="WakaChart";function ne({title:e,description:n}){return t.jsxs("div",{className:"mb-4",children:[t.jsx("h3",{className:"text-lg font-semibold",children:e}),n&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n})]})}const le=j.forwardRef(({data:e,dataKeys:n,series:r,variant:s="default",size:i="md",height:k,width:f,animation:g=!0,animationDuration:a=500,grid:h=!0,tooltip:o=!0,legend:u,axis:c,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,onClick:X,responsive:D=!0,layout:K="vertical",stacked:T=!1,radius:O=4,barSize:P,barGap:b=4,barCategoryGap:E="20%"},R)=>{const{theme:A,getColor:G,tooltipStyles:$}=Q(C,s),y=j.useMemo(()=>{if(r&&r.length>0)return r;if(n&&n.length>0)return n.map((d,w)=>({dataKey:d,label:d,color:G(w)}));if(e.length>0&&"value"in e[0])return[{dataKey:"value",label:"Value",color:G(0)}];const x=e[0];return x?Object.keys(x).filter(d=>d!=="name"&&typeof x[d]=="number").map((d,w)=>({dataKey:d,label:d,color:G(w)})):[]},[r,n,e,G]),S=j.useMemo(()=>u?typeof u=="boolean"?{enabled:u,position:"bottom",align:"center"}:u:null,[u]),l=j.useMemo(()=>o?typeof o=="boolean"?{enabled:o}:o:null,[o]);return t.jsx(ee,{ref:R,variant:s,size:i,height:k,width:f,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,responsive:D,children:x=>{if(!x)return null;const{BarChart:d,Bar:w,XAxis:N,YAxis:W,CartesianGrid:H,Tooltip:I,Legend:F}=x;return t.jsxs(d,{data:e,layout:K==="horizontal"?"vertical":"horizontal",barGap:b,barCategoryGap:E,children:[h&&t.jsx(H,{strokeDasharray:"3 3",stroke:A.gridColor,horizontal:!0,vertical:!1}),c?.showXAxis!==!1&&t.jsx(N,{dataKey:"name",axisLine:{stroke:A.axisColor},tickLine:{stroke:A.axisColor},tick:{fill:A.textColor,fontSize:12},tickFormatter:c?.xAxisFormatter}),c?.showYAxis!==!1&&t.jsx(W,{axisLine:{stroke:A.axisColor},tickLine:{stroke:A.axisColor},tick:{fill:A.textColor,fontSize:12},tickFormatter:c?.yAxisFormatter,domain:c?.yAxisDomain,unit:c?.yAxisUnit}),l?.enabled!==!1&&o&&t.jsx(I,{...$,formatter:l&&typeof l!="boolean"&&l.formatter?(z,U)=>l.formatter(z,U,e[0]):z=>{const U=l&&typeof l!="boolean"&&l.valuePrefix||"",B=l&&typeof l!="boolean"&&l.valueSuffix||"";return`${U}${z}${B}`}}),S?.enabled&&t.jsx(F,{align:S.align,verticalAlign:S.position==="top"?"top":"bottom",wrapperStyle:{paddingTop:S.position==="bottom"?16:0}}),y.map((z,U)=>t.jsx(w,{dataKey:z.dataKey,name:z.label,fill:z.color||G(U),radius:O,stackId:T?"stack":void 0,barSize:P,animationDuration:a,isAnimationActive:g},z.dataKey))]})}})});le.displayName="WakaBarChart";const ce=j.forwardRef(({data:e,dataKeys:n,series:r,variant:s="default",size:i="md",height:k,width:f,animation:g=!0,animationDuration:a=500,grid:h=!0,tooltip:o=!0,legend:u,axis:c,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,onClick:X,responsive:D=!0,curve:K="monotone",dots:T=!0,dotSize:O=4,activeDot:P=!0,strokeWidth:b=2},E)=>{const{theme:R,getColor:A,tooltipStyles:G}=Q(C,s),$=j.useMemo(()=>{if(r&&r.length>0)return r;if(n&&n.length>0)return n.map((x,d)=>({dataKey:x,label:x,color:A(d),strokeWidth:b}));if(e.length>0&&"value"in e[0])return[{dataKey:"value",label:"Value",color:A(0),strokeWidth:b}];const l=e[0];return l?Object.keys(l).filter(x=>x!=="name"&&typeof l[x]=="number").map((x,d)=>({dataKey:x,label:x,color:A(d),strokeWidth:b})):[]},[r,n,e,A,b]),y=j.useMemo(()=>u?typeof u=="boolean"?{enabled:u,position:"bottom",align:"center"}:u:null,[u]),S=j.useMemo(()=>o?typeof o=="boolean"?{enabled:o}:o:null,[o]);return t.jsx(ee,{ref:E,variant:s,size:i,height:k,width:f,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,responsive:D,children:l=>{if(!l)return null;const{LineChart:x,Line:d,XAxis:w,YAxis:N,CartesianGrid:W,Tooltip:H,Legend:I}=l;return t.jsxs(x,{data:e,children:[h&&t.jsx(W,{strokeDasharray:"3 3",stroke:R.gridColor,horizontal:!0,vertical:!1}),c?.showXAxis!==!1&&t.jsx(w,{dataKey:"name",axisLine:{stroke:R.axisColor},tickLine:{stroke:R.axisColor},tick:{fill:R.textColor,fontSize:12},tickFormatter:c?.xAxisFormatter}),c?.showYAxis!==!1&&t.jsx(N,{axisLine:{stroke:R.axisColor},tickLine:{stroke:R.axisColor},tick:{fill:R.textColor,fontSize:12},tickFormatter:c?.yAxisFormatter,domain:c?.yAxisDomain,unit:c?.yAxisUnit}),S?.enabled!==!1&&o&&t.jsx(H,{...G,formatter:S&&typeof S!="boolean"&&S.formatter?(F,z)=>S.formatter(F,z,e[0]):F=>{const z=S&&typeof S!="boolean"&&S.valuePrefix||"",U=S&&typeof S!="boolean"&&S.valueSuffix||"";return`${z}${F}${U}`}}),y?.enabled&&t.jsx(I,{align:y.align,verticalAlign:y.position==="top"?"top":"bottom",wrapperStyle:{paddingTop:y.position==="bottom"?16:0}}),$.map((F,z)=>t.jsx(d,{dataKey:F.dataKey,name:F.label,stroke:F.color||A(z),strokeWidth:F.strokeWidth||b,strokeDasharray:F.strokeDasharray,type:K,dot:T?{r:O,fill:F.color||A(z)}:!1,activeDot:P?{r:O+2}:!1,animationDuration:a,isAnimationActive:g},F.dataKey))]})}})});ce.displayName="WakaLineChart";const ue=j.forwardRef(({data:e,dataKeys:n,series:r,variant:s="default",size:i="md",height:k,width:f,animation:g=!0,animationDuration:a=500,grid:h=!0,tooltip:o=!0,legend:u,axis:c,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,onClick:X,responsive:D=!0,curve:K="monotone",dots:T=!1,dotSize:O=4,activeDot:P=!0,strokeWidth:b=2,stacked:E=!1,fillOpacity:R=.3,gradientDirection:A="vertical"},G)=>{const{theme:$,getColor:y,tooltipStyles:S}=Q(C,s),l=j.useMemo(()=>{if(r&&r.length>0)return r;if(n&&n.length>0)return n.map((N,W)=>({dataKey:N,label:N,color:y(W),strokeWidth:b,fillOpacity:R}));if(e.length>0&&"value"in e[0])return[{dataKey:"value",label:"Value",color:y(0),strokeWidth:b,fillOpacity:R}];const w=e[0];return w?Object.keys(w).filter(N=>N!=="name"&&typeof w[N]=="number").map((N,W)=>({dataKey:N,label:N,color:y(W),strokeWidth:b,fillOpacity:R})):[]},[r,n,e,y,b,R]),x=j.useMemo(()=>u?typeof u=="boolean"?{enabled:u,position:"bottom",align:"center"}:u:null,[u]),d=j.useMemo(()=>o?typeof o=="boolean"?{enabled:o}:o:null,[o]);return t.jsx(ee,{ref:G,variant:s,size:i,height:k,width:f,theme:C,className:p,style:m,title:v,description:M,loading:L,error:_,responsive:D,children:w=>{if(!w)return null;const{AreaChart:N,Area:W,XAxis:H,YAxis:I,CartesianGrid:F,Tooltip:z,Legend:U}=w;return t.jsxs(N,{data:e,children:[t.jsx("defs",{children:l.map((B,Y)=>{const Z=B.color||y(Y),te=`gradient-${B.dataKey}-${Y}`;return t.jsxs("linearGradient",{id:te,x1:"0",y1:"0",x2:A==="horizontal"?"1":"0",y2:A==="horizontal"?"0":"1",children:[t.jsx("stop",{offset:"5%",stopColor:Z,stopOpacity:.8}),t.jsx("stop",{offset:"95%",stopColor:Z,stopOpacity:.1})]},te)})}),h&&t.jsx(F,{strokeDasharray:"3 3",stroke:$.gridColor,horizontal:!0,vertical:!1}),c?.showXAxis!==!1&&t.jsx(H,{dataKey:"name",axisLine:{stroke:$.axisColor},tickLine:{stroke:$.axisColor},tick:{fill:$.textColor,fontSize:12},tickFormatter:c?.xAxisFormatter}),c?.showYAxis!==!1&&t.jsx(I,{axisLine:{stroke:$.axisColor},tickLine:{stroke:$.axisColor},tick:{fill:$.textColor,fontSize:12},tickFormatter:c?.yAxisFormatter,domain:c?.yAxisDomain,unit:c?.yAxisUnit}),d?.enabled!==!1&&o&&t.jsx(z,{...S,formatter:d&&typeof d!="boolean"&&d.formatter?(B,Y)=>d.formatter(B,Y,e[0]):B=>{const Y=d&&typeof d!="boolean"&&d.valuePrefix||"",Z=d&&typeof d!="boolean"&&d.valueSuffix||"";return`${Y}${B}${Z}`}}),x?.enabled&&t.jsx(U,{align:x.align,verticalAlign:x.position==="top"?"top":"bottom",wrapperStyle:{paddingTop:x.position==="bottom"?16:0}}),l.map((B,Y)=>{const Z=B.color||y(Y),te=`gradient-${B.dataKey}-${Y}`;return t.jsx(W,{dataKey:B.dataKey,name:B.label,stroke:Z,strokeWidth:B.strokeWidth||b,fill:`url(#${te})`,fillOpacity:B.fillOpacity??R,type:K,dot:T?{r:O,fill:Z}:!1,stackId:E?"stack":void 0,animationDuration:a,isAnimationActive:g},B.dataKey)})]})}})});ue.displayName="WakaAreaChart";const de=j.forwardRef(({data:e,variant:n="default",size:r="md",height:s,width:i,animation:k=!0,animationDuration:f=500,tooltip:g=!0,legend:a=!0,theme:h,className:o,style:u,title:c,description:C,loading:p,error:m,onClick:v,responsive:M=!0,dataKey:L="value",nameKey:_="name",innerRadius:X=0,outerRadius:D="80%",startAngle:K=90,endAngle:T=-270,paddingAngle:O=2,label:P=!1,labelPosition:b="outside"},E)=>{const{theme:R,getColor:A,tooltipStyles:G}=Q(h,n),$=j.useMemo(()=>a?typeof a=="boolean"?{enabled:a,position:"bottom",align:"center"}:a:null,[a]),y=j.useMemo(()=>g?typeof g=="boolean"?{enabled:g}:g:null,[g]),S=j.useCallback(l=>{if(!P)return null;const x=Math.PI/180,d=b==="inside"?l.innerRadius+(l.outerRadius-l.innerRadius)*.5:l.outerRadius*1.1,w=l.cx+d*Math.cos(-l.midAngle*x),N=l.cy+d*Math.sin(-l.midAngle*x);let W="";return P==="percent"?W=`${(l.percent*100).toFixed(0)}%`:P==="value"?W=String(l.value):P==="name"?W=l.name:W=`${(l.percent*100).toFixed(0)}%`,t.jsx("text",{x:w,y:N,fill:b==="inside"?"#fff":R.textColor,textAnchor:w>l.cx?"start":"end",dominantBaseline:"central",fontSize:12,children:W})},[P,b,R.textColor]);return t.jsx(ee,{ref:E,variant:n,size:r,height:s,width:i,theme:h,className:o,style:u,title:c,description:C,loading:p,error:m,responsive:M,children:l=>{if(!l)return null;const{PieChart:x,Pie:d,Cell:w,Tooltip:N,Legend:W}=l;return t.jsxs(x,{children:[y?.enabled!==!1&&g&&t.jsx(N,{...G,formatter:y&&typeof y!="boolean"&&y.formatter?(H,I)=>y.formatter(H,I,e[0]):H=>{const I=y&&typeof y!="boolean"&&y.valuePrefix||"",F=y&&typeof y!="boolean"&&y.valueSuffix||"";return`${I}${H}${F}`}}),$?.enabled&&t.jsx(W,{align:$.align,verticalAlign:$.position==="top"?"top":"bottom",layout:$.position==="left"||$.position==="right"?"vertical":"horizontal",wrapperStyle:{paddingTop:$.position==="bottom"?16:0}}),t.jsx(d,{data:e,dataKey:L,nameKey:_,cx:"50%",cy:"50%",innerRadius:X,outerRadius:D,startAngle:K,endAngle:T,paddingAngle:O,animationDuration:f,isAnimationActive:k,label:P?S:!1,labelLine:P&&b==="outside",children:e.map((H,I)=>t.jsx(w,{fill:A(I),stroke:"transparent"},`cell-${I}`))})]})}})});de.displayName="WakaPieChart";const ae=j.forwardRef(({data:e,type:n="line",width:r=100,height:s=30,color:i="hsl(var(--chart-1))",fillColor:k,fillOpacity:f=.3,showMinMax:g=!1,showValue:a=!1,className:h,animation:o=!0},u)=>{const{components:c,loading:C,isAvailable:p}=oe(),m=j.useMemo(()=>e.map((b,E)=>({index:E,value:b})),[e]),{min:v,max:M,current:L}=j.useMemo(()=>{const b=e.filter(E=>typeof E=="number"&&!isNaN(E));return{min:Math.min(...b),max:Math.max(...b),current:b[b.length-1]}},[e]);if(C)return t.jsx("div",{ref:u,className:V.cn("inline-flex items-center gap-2",h),children:t.jsx("div",{className:"bg-muted animate-pulse rounded",style:{width:r,height:s}})});if(!p||!c)return t.jsxs("div",{ref:u,className:V.cn("inline-flex items-center gap-2",h),children:[t.jsx(ve,{data:e,width:r,height:s,color:i,type:n,fillColor:k,fillOpacity:f}),a&&t.jsx("span",{className:"text-sm font-medium",children:L})]});const{ResponsiveContainer:_,LineChart:X,BarChart:D,AreaChart:K,Line:T,Bar:O,Area:P}=c;return t.jsxs("div",{ref:u,className:V.cn("inline-flex items-center gap-2",h),children:[t.jsx("div",{style:{width:r,height:s},children:t.jsx(_,{width:"100%",height:"100%",children:n==="bar"?t.jsx(D,{data:m,children:t.jsx(O,{dataKey:"value",fill:i,radius:1,isAnimationActive:o})}):n==="area"?t.jsxs(K,{data:m,children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:`sparkline-gradient-${i.replace(/[^a-z0-9]/gi,"")}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[t.jsx("stop",{offset:"5%",stopColor:k||i,stopOpacity:.8}),t.jsx("stop",{offset:"95%",stopColor:k||i,stopOpacity:.1})]})}),t.jsx(P,{type:"monotone",dataKey:"value",stroke:i,fill:`url(#sparkline-gradient-${i.replace(/[^a-z0-9]/gi,"")})`,fillOpacity:f,strokeWidth:1.5,dot:!1,isAnimationActive:o})]}):t.jsx(X,{data:m,children:t.jsx(T,{type:"monotone",dataKey:"value",stroke:i,strokeWidth:1.5,dot:!1,isAnimationActive:o})})})}),g&&t.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[t.jsxs("span",{children:["↑ ",M]}),t.jsxs("span",{children:["↓ ",v]})]}),a&&t.jsx("span",{className:"text-sm font-medium",children:L})]})});ae.displayName="WakaSparkline";function ve({data:e,width:n,height:r,color:s,type:i,fillColor:k,fillOpacity:f}){const a=n-4,h=r-4,o=Math.min(...e),c=Math.max(...e)-o||1,C=e.map((m,v)=>{const M=2+v/(e.length-1||1)*a,L=2+h-(m-o)/c*h;return{x:M,y:L,value:m}});if(i==="bar"){const m=a/e.length-1;return t.jsx("svg",{width:n,height:r,children:e.map((v,M)=>{const L=(v-o)/c*h;return t.jsx("rect",{x:2+M*(m+1),y:2+h-L,width:m,height:L,fill:s,rx:1},M)})})}const p=C.map((m,v)=>`${v===0?"M":"L"} ${m.x} ${m.y}`).join(" ");if(i==="area"){const m=`${p} L ${C[C.length-1].x} ${r-2} L 2 ${r-2} Z`;return t.jsxs("svg",{width:n,height:r,children:[t.jsx("path",{d:m,fill:k||s,fillOpacity:f}),t.jsx("path",{d:p,fill:"none",stroke:s,strokeWidth:1.5})]})}return t.jsx("svg",{width:n,height:r,children:t.jsx("path",{d:p,fill:"none",stroke:s,strokeWidth:1.5})})}const fe=j.forwardRef(({data:e,type:n="sparkline",width:r=80,height:s=24,color:i,showTrend:k=!0,valueFormatter:f,className:g},a)=>{const h=j.useMemo(()=>!e||e.length===0?[]:typeof e[0]=="number"?e:e.map(p=>{const m=p.value??Object.values(p).find(v=>typeof v=="number");return typeof m=="number"?m:0}),[e]),{trend:o,trendPercent:u,currentValue:c}=j.useMemo(()=>{if(h.length<2)return{trend:"neutral",trendPercent:0,currentValue:h[0]??0};const p=h[0],m=h[h.length-1],v=m-p,M=p!==0?v/p*100:0;return{trend:v>0?"up":v<0?"down":"neutral",trendPercent:M,currentValue:m}},[h]),C=j.useMemo(()=>i||(o==="up"?"hsl(var(--chart-2, 142 76% 36%))":o==="down"?"hsl(var(--destructive, 0 84% 60%))":"hsl(var(--muted-foreground, 220 9% 46%))"),[i,o]);return h.length===0?t.jsx("div",{ref:a,className:V.cn("flex items-center gap-1 text-muted-foreground",g),children:t.jsx(re.Minus,{className:"h-3 w-3"})}):(f?f(c):c.toLocaleString(),t.jsxs("div",{ref:a,className:V.cn("flex items-center gap-2",g),children:[t.jsx(ae,{data:h,type:n==="sparkline"?"line":n,width:r,height:s,color:C,animation:!1}),k&&t.jsxs("div",{className:"flex items-center gap-1",children:[o==="up"&&t.jsx(re.TrendingUp,{className:"h-3 w-3 text-green-600 dark:text-green-400"}),o==="down"&&t.jsx(re.TrendingDown,{className:"h-3 w-3 text-red-600 dark:text-red-400"}),o==="neutral"&&t.jsx(re.Minus,{className:"h-3 w-3 text-muted-foreground"}),t.jsxs("span",{className:V.cn("text-xs font-medium",o==="up"&&"text-green-600 dark:text-green-400",o==="down"&&"text-red-600 dark:text-red-400",o==="neutral"&&"text-muted-foreground"),children:[o!=="neutral"&&(u>0?"+":""),u.toFixed(1),"%"]})]})]}))});fe.displayName="WakaMiniChart";function Ae(e){const{accessorKey:n,header:r=String(n),chartType:s="sparkline",width:i=100,height:k=24,color:f,showValue:g=!1,valueFormatter:a}=e;return{accessorKey:n,header:r,size:i+(g?60:0),enableSorting:!1,enableColumnFilter:!1,cell:h=>{const o=h.getValue();let u=[];return Array.isArray(o)&&(typeof o[0]=="number"?u=o:typeof o[0]=="object"&&o[0]!==null&&(u=o.map(c=>{const C=c.value??Object.values(c).find(p=>typeof p=="number");return typeof C=="number"?C:0}))),{type:"chart",chartType:s,data:u,width:i,height:k,color:f,showTrend:!0,valueFormatter:a}},meta:{isChartColumn:!0,chartConfig:e}}}const Se={cell:e=>{if(!Array.isArray(e))return null;let n=[];return typeof e[0]=="number"?n=e:typeof e[0]=="object"&&e[0]!==null&&(n=e.map(r=>{const s=r.value??Object.values(r).find(i=>typeof i=="number");return typeof s=="number"?s:0})),{type:"sparkline",data:n}},size:100,enableSorting:!1,enableFiltering:!1},Le=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],we={sm:{width:"100%",height:150},md:{width:"100%",height:250},lg:{width:"100%",height:350},xl:{width:"100%",height:450},auto:{width:"100%",height:300}};exports.CHART_SIZE_MAP=we;exports.DEFAULT_CHART_COLORS=Le;exports.Skeleton=se;exports.WakaAreaChart=ue;exports.WakaBarChart=le;exports.WakaChart=ee;exports.WakaLineChart=ce;exports.WakaMiniChart=fe;exports.WakaPieChart=de;exports.WakaSparkline=ae;exports.createChartColumn=Ae;exports.sparklineTemplate=Se;exports.useChartTheme=Q;exports.useRechartsLoader=oe;
@@ -1,124 +0,0 @@
1
- "use strict";var ee=Object.create;var q=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ae=(m,e,s,A)=>{if(e&&typeof e=="object"||typeof e=="function")for(let b of re(e))!oe.call(m,b)&&b!==s&&q(m,b,{get:()=>e[b],enumerable:!(A=te(e,b))||A.enumerable});return m};var H=(m,e,s)=>(s=m!=null?ee(ne(m)):{},ae(e||!m||!m.__esModule?q(s,"default",{value:m,enumerable:!0}):s,m));const p=require("react");class z{constructor(e){this.config={debug:!1,minLevel:"debug",prefix:"[WakaUI]"},e&&(this.config={...this.config,...e})}configure(e){this.config={...this.config,...e}}shouldLog(e){if(e==="error"||e==="warn")return!0;if(process.env.NODE_ENV==="production"&&!this.config.debug)return!1;const s=["debug","info","warn","error"],A=s.indexOf(e),b=s.indexOf(this.config.minLevel||"debug");return A>=b}format(e){return this.config.prefix?`${this.config.prefix} ${e}`:e}debug(e,...s){this.shouldLog("debug")&&console.log(this.format(e),...s)}info(e,...s){this.shouldLog("info")&&console.log(this.format(e),...s)}warn(e,...s){this.shouldLog("warn")&&console.warn(this.format(e),...s)}error(e,...s){this.shouldLog("error")&&console.error(this.format(e),...s)}}const Z=new z,D={UNKNOWN:"WAKA_UNKNOWN",VALIDATION:"WAKA_VALIDATION",NETWORK:"WAKA_NETWORK",TIMEOUT:"WAKA_TIMEOUT",THEME_LOAD_FAILED:"WAKA_THEME_LOAD_FAILED",THEME_PARSE_FAILED:"WAKA_THEME_PARSE_FAILED",THEME_APPLY_FAILED:"WAKA_THEME_APPLY_FAILED",LANG_LOAD_FAILED:"WAKA_LANG_LOAD_FAILED",LANG_PARSE_FAILED:"WAKA_LANG_PARSE_FAILED",TRANSLATION_MISSING:"WAKA_TRANSLATION_MISSING",DATATABLE_EXPORT_FAILED:"WAKA_DATATABLE_EXPORT_FAILED",DATATABLE_IMPORT_FAILED:"WAKA_DATATABLE_IMPORT_FAILED",DATATABLE_PARSE_FAILED:"WAKA_DATATABLE_PARSE_FAILED",COMPONENT_RENDER_FAILED:"WAKA_COMPONENT_RENDER_FAILED",COMPONENT_INIT_FAILED:"WAKA_COMPONENT_INIT_FAILED",PROVIDER_MISSING:"WAKA_PROVIDER_MISSING",PROVIDER_CONFIG_INVALID:"WAKA_PROVIDER_CONFIG_INVALID"};class v extends Error{constructor(e,s={}){super(e),this.name="WakaError",this.code=s.code||D.UNKNOWN,this.context=s.context,this.cause=s.cause,this.metadata=s.metadata,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,v)}static from(e,s={}){return e instanceof v?e:e instanceof Error?new v(e.message,{...s,cause:e}):new v(String(e),s)}toJSON(){return{name:this.name,message:this.message,code:this.code,context:this.context,metadata:this.metadata,timestamp:this.timestamp.toISOString(),stack:this.stack,cause:this.cause?.message}}}function S(m,e={}){const s=v.from(m,{code:e.code,context:e.context,metadata:e.metadata});if(e.silent||Z.error(`${e.context||"Error"}: ${s.message}`,s.toJSON()),e.onError?.(s),e.rethrow)throw s;return s}function se(m,e={}){try{return m()}catch(s){return S(s,e),e.fallback}}async function ce(m,e={}){try{return await m()}catch(s){return S(s,e),e.fallback}}function le(m,e={}){return async(...s)=>{try{return await m(...s)}catch(A){throw S(A,e)}}}function ie(m,e,s={}){if(!m)throw new v(e,{code:s.code||D.VALIDATION,context:s.context,metadata:s.metadata})}function Y(m){return m instanceof v}function ue(m,e){return Y(m)&&m.code===e}function pe(m){return(e,s=D.UNKNOWN,A)=>new v(e,{code:s,context:m,metadata:A})}async function me(m,e={}){const{maxRetries:s=3,baseDelay:A=1e3,maxDelay:b=1e4,context:L,onRetry:C}=e;let f;for(let E=0;E<=s;E++)try{return await m()}catch(w){if(f=v.from(w,{context:L}),E<s){const g=Math.min(A*Math.pow(2,E),b);C?.(E+1,f),Z.warn(`${L||"Operation"} failed (attempt ${E+1}/${s+1}), retrying in ${g}ms...`),await new Promise(y=>setTimeout(y,g))}}throw f}const de=1e3;function fe({data:m,columns:e,exportConfig:s,onError:A}){const[b,L]=p.useState(0),[C,f]=p.useState(!1),E=p.useRef(null);p.useEffect(()=>()=>{E.current&&(E.current.terminate(),E.current=null)},[]);const w=p.useMemo(()=>({formats:["csv","xlsx","json"],filename:"export",includeHeaders:!0,useWorker:!0,workerThreshold:de,...s}),[s]),g=p.useCallback(t=>{const n=t;return n.accessorKey||n.id},[]),y=p.useCallback(t=>{const n=t;return typeof t.header=="string"?t.header:(typeof t.header=="function",n.accessorKey||n.id||"")},[]),T=p.useCallback((t,n)=>{const o=g(n);if(o)return t[o]},[g]),O=p.useCallback(()=>e.filter(t=>g(t)).map(t=>({key:g(t),header:y(t)})),[e,g,y]),R=p.useCallback(async(t,n,o)=>new Promise((r,a)=>{f(!0),L(0);try{const d=`
2
- // Fonction pour convertir en CSV
3
- function convertToCSV(data, columns) {
4
- const headers = columns.map(col => col.header).join(',');
5
- const rows = data.map(row => {
6
- return columns
7
- .map(col => {
8
- const value = row[col.key];
9
- const stringValue = String(value ?? '');
10
- if (stringValue.includes(',') || stringValue.includes('"') || stringValue.includes('\\n')) {
11
- return '"' + stringValue.replace(/"/g, '""') + '"';
12
- }
13
- return stringValue;
14
- })
15
- .join(',');
16
- });
17
- return [headers, ...rows].join('\\n');
18
- }
19
-
20
- // Fonction pour convertir en JSON
21
- function convertToJSON(data) {
22
- return JSON.stringify(data, null, 2);
23
- }
24
-
25
- // Fonction pour convertir en XML
26
- function convertToXML(data, columns) {
27
- let xmlContent = '<?xml version="1.0" encoding="UTF-8"?>\\n<data>\\n';
28
- data.forEach((row, index) => {
29
- xmlContent += ' <row id="' + index + '">\\n';
30
- columns.forEach(col => {
31
- const value = row[col.key];
32
- const stringValue = String(value ?? '')
33
- .replace(/&/g, '&amp;')
34
- .replace(/</g, '&lt;')
35
- .replace(/>/g, '&gt;');
36
- xmlContent += ' <' + col.key + '>' + stringValue + '</' + col.key + '>\\n';
37
- });
38
- xmlContent += ' </row>\\n';
39
- });
40
- xmlContent += '</data>';
41
- return xmlContent;
42
- }
43
-
44
- // Traitement par chunks avec progression
45
- function processWithProgress(data, columns, format) {
46
- const CHUNK_SIZE = 500;
47
- const totalRows = data.length;
48
-
49
- if (format === 'json') {
50
- self.postMessage({ type: 'progress', progress: 50 });
51
- const result = convertToJSON(data);
52
- self.postMessage({ type: 'progress', progress: 100 });
53
- return result;
54
- }
55
-
56
- let result = '';
57
-
58
- if (format === 'csv') {
59
- result = columns.map(col => col.header).join(',') + '\\n';
60
- for (let i = 0; i < totalRows; i += CHUNK_SIZE) {
61
- const chunk = data.slice(i, Math.min(i + CHUNK_SIZE, totalRows));
62
- const chunkRows = chunk.map(row => {
63
- return columns
64
- .map(col => {
65
- const value = row[col.key];
66
- const stringValue = String(value ?? '');
67
- if (stringValue.includes(',') || stringValue.includes('"') || stringValue.includes('\\n')) {
68
- return '"' + stringValue.replace(/"/g, '""') + '"';
69
- }
70
- return stringValue;
71
- })
72
- .join(',');
73
- });
74
- result += chunkRows.join('\\n') + (i + CHUNK_SIZE < totalRows ? '\\n' : '');
75
- self.postMessage({ type: 'progress', progress: Math.round(((i + CHUNK_SIZE) / totalRows) * 100) });
76
- }
77
- return result;
78
- }
79
-
80
- if (format === 'xml') {
81
- result = '<?xml version="1.0" encoding="UTF-8"?>\\n<data>\\n';
82
- for (let i = 0; i < totalRows; i += CHUNK_SIZE) {
83
- const chunk = data.slice(i, Math.min(i + CHUNK_SIZE, totalRows));
84
- chunk.forEach((row, idx) => {
85
- result += ' <row id="' + (i + idx) + '">\\n';
86
- columns.forEach(col => {
87
- const value = row[col.key];
88
- const stringValue = String(value ?? '')
89
- .replace(/&/g, '&amp;')
90
- .replace(/</g, '&lt;')
91
- .replace(/>/g, '&gt;');
92
- result += ' <' + col.key + '>' + stringValue + '</' + col.key + '>\\n';
93
- });
94
- result += ' </row>\\n';
95
- });
96
- self.postMessage({ type: 'progress', progress: Math.round(((i + CHUNK_SIZE) / totalRows) * 100) });
97
- }
98
- result += '</data>';
99
- return result;
100
- }
101
-
102
- return result;
103
- }
104
-
105
- self.onmessage = function(e) {
106
- const { format, data, columns } = e.data;
107
- try {
108
- const content = processWithProgress(data, columns, format);
109
- self.postMessage({ type: 'success', content });
110
- } catch (error) {
111
- self.postMessage({ type: 'error', error: error.message || 'Unknown error' });
112
- }
113
- };
114
- `,h=new Blob([d],{type:"application/javascript"}),c=URL.createObjectURL(h),u=new Worker(c);E.current=u,u.onmessage=I=>{const{type:k,content:J,progress:$,error:W}=I.data;if(k==="progress")L($);else if(k==="success"){let M,K;switch(n){case"csv":M="text/csv;charset=utf-8;",K="csv";break;case"json":M="application/json",K="json";break;case"xml":M="application/xml",K="xml";break;default:M="text/plain",K="txt"}const Q=new Blob([J],{type:M}),X=document.createElement("a");X.href=URL.createObjectURL(Q),X.download=`${o}.${K}`,X.click(),URL.revokeObjectURL(X.href),u.terminate(),URL.revokeObjectURL(c),E.current=null,f(!1),L(0),r()}else k==="error"&&(u.terminate(),URL.revokeObjectURL(c),E.current=null,f(!1),L(0),a(new Error(W)))},u.onerror=I=>{u.terminate(),URL.revokeObjectURL(c),E.current=null,f(!1),L(0),a(new Error(I.message))};const x=O();u.postMessage({format:n,data:t,columns:x})}catch(d){f(!1),L(0),a(d)}}),[O]),_=p.useCallback((t,n)=>{if(!t.length)return;const o=e.filter(u=>g(u)),r=o.map(u=>y(u)).join(","),a=t.map(u=>o.map(x=>{const I=T(u,x),k=String(I??"");return k.includes(",")||k.includes('"')||k.includes(`
115
- `)?`"${k.replace(/"/g,'""')}"`:k}).join(",")),d=[r,...a].join(`
116
- `),h=new Blob([d],{type:"text/csv;charset=utf-8;"}),c=document.createElement("a");c.href=URL.createObjectURL(h),c.download=`${n||w.filename}.csv`,c.click(),URL.revokeObjectURL(c.href)},[e,w.filename,g,y,T]),U=p.useCallback((t,n)=>{const o=JSON.stringify(t,null,2),r=new Blob([o],{type:"application/json"}),a=document.createElement("a");a.href=URL.createObjectURL(r),a.download=`${n||w.filename}.json`,a.click(),URL.revokeObjectURL(a.href)},[w.filename]),N=p.useCallback(async(t,n)=>{try{if(typeof window>"u")throw new Error("XLSX export not available in server environment");let o;try{o=await import("xlsx")}catch{throw new Error("La dépendance 'xlsx' est requise pour l'export Excel. Installez-la avec: pnpm add xlsx (version >=0.18.0)")}const r=e.filter(u=>g(u)),d=[r.map(u=>y(u)),...t.map(u=>r.map(x=>T(u,x)))],h=o.utils.aoa_to_sheet(d),c=o.utils.book_new();o.utils.book_append_sheet(c,h,"Sheet1"),o.writeFile(c,`${n||w.filename}.xlsx`)}catch(o){throw S(o,{code:D.DATATABLE_EXPORT_FAILED,context:"DataTable.exportToXLSX",onError:A})}},[e,w.filename,g,y,T,A]),V=p.useCallback(async(t,n)=>{try{if(typeof window>"u")throw new Error("PDF export not available in server environment");let o;try{o=await import("jspdf")}catch{throw new Error("La dépendance 'jspdf' est requise pour l'export PDF. Installez-la avec: pnpm add jspdf (version >=2.5.0)")}try{await import("jspdf-autotable")}catch{throw new Error("La dépendance 'jspdf-autotable' est requise pour l'export PDF. Installez-la avec: pnpm add jspdf-autotable (version >=3.5.0)")}const r=new o.default,a=e.filter(c=>g(c)),d=a.map(c=>y(c)),h=t.map(c=>a.map(u=>T(c,u)));r.autoTable({head:[d],body:h,startY:20,styles:{fontSize:8},headStyles:{fillColor:[66,139,202]}}),r.save(`${n||w.filename}.pdf`)}catch(o){throw S(o,{code:D.DATATABLE_EXPORT_FAILED,context:"DataTable.exportToPDF",onError:A})}},[e,w.filename,g,y,T,A]),P=p.useCallback((t,n)=>{const o=e.filter(h=>g(h));let r=`<?xml version="1.0" encoding="UTF-8"?>
117
- <data>
118
- `;t.forEach((h,c)=>{r+=` <row id="${c}">
119
- `,o.forEach(u=>{const x=g(u);if(x){const I=T(h,u),k=String(I??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");r+=` <${x}>${k}</${x}>
120
- `}}),r+=` </row>
121
- `}),r+="</data>";const a=new Blob([r],{type:"application/xml"}),d=document.createElement("a");d.href=URL.createObjectURL(a),d.download=`${n||w.filename}.xml`,d.click(),URL.revokeObjectURL(d.href)},[e,w.filename,g,T]),F=p.useCallback(async(t,n,o)=>{const r=n||m,a=o||w.filename;if(w.onExport){w.onExport(r,t);return}const d=["csv","json","xml"];if(w.useWorker&&r.length>=w.workerThreshold&&d.includes(t.toLowerCase())&&typeof Worker<"u"){await R(r,t.toLowerCase(),a);return}switch(t.toLowerCase()){case"csv":_(r,a);break;case"json":U(r,a);break;case"xlsx":await N(r,a);break;case"pdf":await V(r,a);break;case"xml":P(r,a);break;default:throw new Error(`Format d'export non supporté: ${t}`)}},[m,w,R,_,U,N,V,P]),B=p.useCallback(async t=>F(t),[F]),l=p.useCallback(async(t,n)=>F(t,n),[F]),i=p.useCallback(()=>{E.current&&(E.current.terminate(),E.current=null,f(!1),L(0))},[]);return{exportData:F,exportAll:B,exportSelected:l,cancelExport:i,exportProgress:b,isExporting:C,supportedFormats:w.formats,isExportSupported:t=>w.formats.includes(t)}}const G=5e3,j=1e3;function he({importConfig:m,onError:e}){const[s,A]=p.useState(0),[b,L]=p.useState(!1),C=p.useRef(null),f=p.useMemo(()=>({accept:".csv,.xlsx,.json,.xml",...m}),[m]),E=p.useCallback((l,i=",")=>{const t=l.split(`
122
- `).filter(r=>r.trim());if(t.length===0)return[];const n=t[0].split(i).map(r=>r.trim().replace(/"/g,""));return t.slice(1).map(r=>{const a=r.split(i).map(h=>h.trim().replace(/"/g,"")),d={};return n.forEach((h,c)=>{d[h]=a[c]||""}),d})},[]),w=p.useCallback(async(l,i=",",t,n)=>{const o=l.split(`
123
- `).filter(c=>c.trim());if(o.length===0)return[];const r=o[0].split(i).map(c=>c.trim().replace(/"/g,"")),a=o.slice(1),d=a.length,h=[];for(let c=0;c<d;c+=j){if(n?.aborted)throw new Error("Import annulé");const u=a.slice(c,c+j),x=u.map(k=>{const J=k.split(i).map(W=>W.trim().replace(/"/g,"")),$={};return r.forEach((W,M)=>{$[W]=J[M]||""}),$});h.push(...x);const I=Math.min(100,Math.round((c+u.length)/d*100));t?.(I),await new Promise(k=>setTimeout(k,0))}return h},[]),g=p.useCallback(async(l,i,t)=>{const n=JSON.parse(l),o=Array.isArray(n)?n:[n];if(o.length<G)return i?.(100),o;const r=[],a=o.length;for(let d=0;d<a;d+=j){if(t?.aborted)throw new Error("Import annulé");const h=o.slice(d,d+j);r.push(...h);const c=Math.min(100,Math.round((d+h.length)/a*100));i?.(c),await new Promise(u=>setTimeout(u,0))}return r},[]),y=p.useCallback(l=>{try{const i=JSON.parse(l);return Array.isArray(i)?i:[i]}catch{throw new Error("Format JSON invalide")}},[]),T=p.useCallback(l=>{try{const n=new DOMParser().parseFromString(l,"text/xml").querySelectorAll("row");return Array.from(n).map(o=>{const r={};return Array.from(o.children).forEach(a=>{r[a.tagName]=a.textContent||""}),r})}catch{throw new Error("Format XML invalide")}},[]),O=p.useCallback(async l=>{try{if(typeof window>"u")throw new Error("XLSX parsing not available in server environment");let i;try{i=await import("xlsx")}catch{throw new Error("La dépendance 'xlsx' est requise pour l'import Excel. Installez-la avec: pnpm add xlsx (version >=0.18.0)")}const t=await l.arrayBuffer(),n=i.read(t,{type:"array"}),o=n.SheetNames[0],r=n.Sheets[o],a=i.utils.sheet_to_json(r,{header:1});if(a.length===0)return[];const d=a[0];return a.slice(1).map(h=>{const c=h,u={};return d.forEach((x,I)=>{u[x]=c[I]??""}),u})}catch{throw new Error("Erreur lors du parsing du fichier XLSX")}},[]),R=p.useCallback(l=>f.validate?f.validate(l):Array.isArray(l)?l.length===0?{valid:!1,errors:["Aucune donnée trouvée"]}:{valid:!0,errors:[]}:{valid:!1,errors:["Les données doivent être un tableau"]},[f.validate]),_=p.useCallback(l=>f.columnMapping?l.map(i=>{const t={};return Object.entries(f.columnMapping).forEach(([n,o])=>{i[n]!==void 0&&(t[o]=i[n])}),t}):l,[f.columnMapping]),U=p.useCallback(async l=>{const i=l.name.split(".").pop()?.toLowerCase();let t=[];try{const n=await l.text();switch(i){case"csv":t=E(n,f.parseOptions?.csv?.delimiter);break;case"json":t=y(n);break;case"xml":t=T(n);break;case"xlsx":t=await O(l);break;default:throw new Error(`Format de fichier non supporté: ${i}`)}const o=R(t);if(!o.valid)throw new Error(`Données invalides: ${o.errors.join(", ")}`);const r=_(t);return f.onImport&&f.onImport(r),r}catch(n){throw S(n,{code:D.DATATABLE_IMPORT_FAILED,context:`DataTable.importData(${l.name})`,onError:e})}},[f,E,y,T,O,R,_,e]),N=p.useCallback(()=>{const l=document.createElement("input");return l.type="file",l.accept=f.accept,l.multiple=!1,l},[f.accept]),V=p.useCallback(()=>new Promise((l,i)=>{const t=N();t.onchange=async n=>{const o=n.target.files?.[0];if(!o){i(new Error("Aucun fichier sélectionné"));return}try{const r=await U(o);l(r)}catch(r){i(r)}},t.click()}),[N,U]),P=p.useCallback(async(l,i)=>{const t=l.name.split(".").pop()?.toLowerCase();C.current=new AbortController;const n=C.current.signal;L(!0),A(0);const o=r=>{A(r),i?.onProgress?.(r)};try{const r=await l.text();let a=[];const d=r.split(`
124
- `).length;switch(t){case"csv":d>G?a=await w(r,f.parseOptions?.csv?.delimiter,o,n):(a=E(r,f.parseOptions?.csv?.delimiter),o(100));break;case"json":a=await g(r,o,n);break;case"xml":a=T(r),o(100);break;case"xlsx":a=await O(l),o(100);break;default:throw new Error(`Format de fichier non supporté: ${t}`)}if(n.aborted)throw new Error("Import annulé");const h=R(a);if(!h.valid)throw new Error(`Données invalides: ${h.errors.join(", ")}`);let c;if(a.length>G&&f.columnMapping){c=[];for(let u=0;u<a.length;u+=j){if(n.aborted)throw new Error("Import annulé");const x=a.slice(u,u+j),I=_(x);c.push(...I),i?.onChunk?.(I,c.length),await new Promise(k=>setTimeout(k,0))}}else c=_(a);return f.onImport&&f.onImport(c),c}catch(r){throw S(r,{code:D.DATATABLE_IMPORT_FAILED,context:`DataTable.importDataStreaming(${l.name})`,onError:e})}finally{L(!1),C.current=null}},[f,E,w,y,g,T,O,R,_,e]),F=p.useCallback(()=>{C.current&&(C.current.abort(),L(!1),A(0))},[]),B=p.useCallback(l=>new Promise((i,t)=>{const n=N();n.onchange=async o=>{const r=o.target.files?.[0];if(!r){t(new Error("Aucun fichier sélectionné"));return}try{const a=await P(r,l);i(a)}catch(a){t(a)}},n.click()}),[N,P]);return{importData:U,importWithUI:V,importDataStreaming:P,importWithUIStreaming:B,cancelImport:F,importProgress:s,isImporting:b,supportedFormats:f.accept?.split(",")||[],isFormatSupported:l=>{const i=l.split(".").pop()?.toLowerCase();return f.accept?.includes(i||"")||!1}}}exports.ErrorCode=D;exports.Logger=z;exports.WakaError=v;exports.assertCondition=ie;exports.createErrorFactory=pe;exports.handleError=S;exports.isErrorCode=ue;exports.isWakaError=Y;exports.logger=Z;exports.retryAsync=me;exports.tryCatch=se;exports.tryCatchAsync=ce;exports.useDataTableExport=fe;exports.useDataTableImport=he;exports.withErrorHandling=le;