@synertech/ui 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +183 -147
- package/README.md +27 -19
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar/AvatarImage.cjs +1 -0
- package/dist/components/avatar/AvatarImage.js +1 -0
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/bar-chart/BarChart.cjs +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/box-plot/BoxPlot.cjs +1 -1
- package/dist/components/box-plot/BoxPlot.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/bullet-chart/BulletChart.cjs +1 -1
- package/dist/components/bullet-chart/BulletChart.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
- package/dist/components/card/Card.cjs +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/chart/ChartAnnotations.cjs +1 -1
- package/dist/components/chart/ChartAnnotations.js +1 -1
- package/dist/components/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartContainer.cjs +1 -1
- package/dist/components/chart/ChartContainer.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/ChartPatterns.cjs +1 -1
- package/dist/components/chart/ChartPatterns.js +1 -1
- package/dist/components/chart/ChartPlotClip.cjs +1 -0
- package/dist/components/chart/ChartPlotClip.js +1 -0
- package/dist/components/chart/ChartSync.cjs +1 -1
- package/dist/components/chart/ChartSync.js +1 -1
- package/dist/components/chart/ChartTableView.cjs +1 -1
- package/dist/components/chart/ChartTableView.js +1 -1
- package/dist/components/chart/exportSource.cjs +1 -0
- package/dist/components/chart/exportSource.js +1 -0
- package/dist/components/chart/palette.cjs +1 -1
- package/dist/components/chart/palette.js +1 -1
- package/dist/components/chart/useChartSize.cjs +1 -1
- package/dist/components/chart/useChartSize.js +1 -1
- package/dist/components/chart/utils/bins.cjs +1 -1
- package/dist/components/chart/utils/bins.js +1 -1
- package/dist/components/chart/utils/cartesian.cjs +1 -1
- package/dist/components/chart/utils/cartesian.js +1 -1
- package/dist/components/chart/utils/export.cjs +7 -1
- package/dist/components/chart/utils/export.js +7 -1
- package/dist/components/chart/utils/format.cjs +1 -1
- package/dist/components/chart/utils/format.js +1 -1
- package/dist/components/chart/utils/keyboard.cjs +1 -1
- package/dist/components/chart/utils/keyboard.js +1 -1
- package/dist/components/chart/utils/period.cjs +1 -1
- package/dist/components/chart/utils/period.js +1 -1
- package/dist/components/chart/utils/regression.cjs +1 -0
- package/dist/components/chart/utils/regression.js +1 -0
- package/dist/components/chart/utils/stack.cjs +1 -1
- package/dist/components/chart/utils/stack.js +1 -1
- package/dist/components/chart/utils/ticks.cjs +1 -1
- package/dist/components/chart/utils/ticks.js +1 -1
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/circular-progress/CircularProgress.cjs +1 -1
- package/dist/components/circular-progress/CircularProgress.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.js +1 -1
- package/dist/components/detachable/Detachable.cjs +1 -1
- package/dist/components/detachable/Detachable.js +1 -1
- package/dist/components/detachable/popup-window.cjs +1 -0
- package/dist/components/detachable/popup-window.js +1 -0
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/divider/Divider.cjs +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/footer/FooterBottom.cjs +1 -1
- package/dist/components/footer/FooterBottom.js +1 -1
- package/dist/components/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +5 -4
- package/dist/components/form/mention-input/MentionInput.js +5 -4
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/form/shared/InputWrapper.cjs +1 -1
- package/dist/components/form/shared/InputWrapper.js +1 -1
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
- package/dist/components/funnel-chart/FunnelChart.js +1 -1
- package/dist/components/gantt-chart/GanttChart.cjs +1 -1
- package/dist/components/gantt-chart/GanttChart.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/line-chart/LineChart.cjs +1 -1
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pie-chart/PieChart.cjs +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/progress-bar/ProgressBar.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scatter-chart/index.cjs +1 -1
- package/dist/components/scatter-chart/index.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
- package/dist/components/schema-editor/utils/sql-export.cjs +4 -4
- package/dist/components/schema-editor/utils/sql-export.js +7 -7
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sparkline/Sparkline.cjs +1 -1
- package/dist/components/sparkline/Sparkline.js +1 -1
- package/dist/components/table/TableRow.cjs +1 -1
- package/dist/components/table/TableRow.js +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
- package/dist/index.d.cts +433 -170
- package/dist/index.d.ts +433 -170
- package/dist/lib/accept.cjs +1 -0
- package/dist/lib/accept.js +1 -0
- package/dist/lib/css-value.cjs +1 -0
- package/dist/lib/css-value.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -1
- package/dist/lib/ui-labels.js +1 -1
- package/dist/styles-no-preflight.css +10270 -0
- package/dist/styles.css +301 -28
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -24,26 +24,29 @@ import "@synertech/ui/styles.css";
|
|
|
24
24
|
|
|
25
25
|
That's it! Components are now fully styled and ready to use. 🎉
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
<summary><strong>Advanced: Using your own Tailwind configuration (optional)</strong></summary>
|
|
27
|
+
#### Your application compiles Tailwind CSS itself
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
The package ships a second stylesheet. It holds the same components, the same classes and
|
|
30
|
+
the same variables, and leaves out one thing: Tailwind's **preflight**, the reset Tailwind
|
|
31
|
+
puts under a page — margins and paddings to zero, `box-sizing: border-box`, headings, lists
|
|
32
|
+
and images stripped of the browser's styles, buttons and fields inheriting the font. That
|
|
33
|
+
reset applies to the whole page, not only to the components.
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"w-4", "h-4", "w-5", "h-5", "w-6", "h-6",
|
|
41
|
-
"bg-blue-600", "bg-green-600", "bg-purple-600", "bg-orange-600",
|
|
42
|
-
],
|
|
43
|
-
}
|
|
35
|
+
| Your application | Import |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| Does not compile Tailwind CSS | `@synertech/ui/styles.css`. The components are drawn on the reset, so it comes with them — and it reaches your own headings and lists too. |
|
|
38
|
+
| Compiles Tailwind CSS (`@import "tailwindcss"` in its stylesheet) | `@synertech/ui/styles-no-preflight.css`. Your page already has the reset, and a second copy, loaded after your stylesheet in the same `base` layer, undoes what you wrote there: a heading size, a link colour. |
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
// An application whose own stylesheet starts with @import "tailwindcss"
|
|
42
|
+
import "@synertech/ui/styles-no-preflight.css";
|
|
44
43
|
```
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
- **Only on a page that has the preflight.** Without it the components are not drawn as
|
|
46
|
+
shipped: a button takes the browser's grey background and border, a field its own font,
|
|
47
|
+
every box its own sizing.
|
|
48
|
+
- **Your `base` rules reach the components** where they leave an element as it is: a link
|
|
49
|
+
the library does not underline takes the underline you give links.
|
|
47
50
|
|
|
48
51
|
### 3. Dark mode
|
|
49
52
|
|
|
@@ -197,7 +200,7 @@ import { Input } from "@synertech/ui";
|
|
|
197
200
|
### Layout (Header & Footer)
|
|
198
201
|
|
|
199
202
|
```tsx
|
|
200
|
-
import { Header, Footer } from "@synertech/ui";
|
|
203
|
+
import { Header, Footer, FooterBottom } from "@synertech/ui";
|
|
201
204
|
|
|
202
205
|
<Header
|
|
203
206
|
logo={<span className="font-bold">MyApp</span>}
|
|
@@ -207,7 +210,10 @@ import { Header, Footer } from "@synertech/ui";
|
|
|
207
210
|
]}
|
|
208
211
|
/>
|
|
209
212
|
|
|
210
|
-
<Footer
|
|
213
|
+
<Footer>
|
|
214
|
+
{/* The copyright is the application's: a text, or any content (a link, a translation) */}
|
|
215
|
+
<FooterBottom copyright="© 2026 MyApp" />
|
|
216
|
+
</Footer>
|
|
211
217
|
```
|
|
212
218
|
|
|
213
219
|
### Modal
|
|
@@ -465,7 +471,9 @@ The library ships with pre-compiled CSS. Simply import it once:
|
|
|
465
471
|
import "@synertech/ui/styles.css";
|
|
466
472
|
```
|
|
467
473
|
|
|
468
|
-
|
|
474
|
+
An application that compiles Tailwind CSS itself imports `@synertech/ui/styles-no-preflight.css`
|
|
475
|
+
instead: the same sheet without Tailwind's reset, which its own stylesheet already has. See
|
|
476
|
+
the [installation section](#2-import-the-styles).
|
|
469
477
|
|
|
470
478
|
|
|
471
479
|
## Table Suite
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var J=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var J=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var He=(t,c)=>{for(var o in c)J(t,o,{get:c[o],enumerable:!0})},Ue=(t,c,o,w)=>{if(c&&typeof c=="object"||typeof c=="function")for(let p of We(c))!$e.call(t,p)&&p!==o&&J(t,p,{get:()=>c[p],enumerable:!(w=ze(c,p))||w.enumerable});return t};var Fe=t=>Ue(J({},"__esModule",{value:!0}),t);var nn={};He(nn,{AdvanceDetachable:()=>Ie});module.exports=Fe(nn);var e=require("react"),Se=require("react-dom"),Ne=require("../detachable/useMovableContent.cjs"),f=require("../detachable/popup-window.cjs"),X=require("../../lib/layer-document.cjs"),d=require("react/jsx-runtime");function _e(...t){return t.filter(Boolean).join(" ")}var je="@synertech/ui/AdvanceDetachable",Je=300,qe="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Te={clock:0,writer:""};function Xe(t,c){return t.clock>c.clock||t.clock===c.clock&&t.writer>c.writer}var Ce=(t,c)=>t===void 0||c(t),q=t=>typeof t=="string",Ge=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0;function Ke(t,c){if(typeof t!="object"||t===null)return!1;let o=t;return o.channel!==c||!q(o.instanceId)?!1:o.type==="hello"?!0:o.type==="value-sync"&&q(o.payload)&&Ce(o.clock,Ge)&&Ce(o.writer,q)}var Qe=0;function Ye(){return`${Date.now()}-${++Qe}-${Math.random().toString(36).slice(2,8)}`}function Ae(t){try{return JSON.stringify(t)}catch{return String(t)}}function Ee(t){try{return JSON.parse(t)}catch{return t}}function Ze(){return typeof BroadcastChannel<"u"}function en({mode:t,id:c,title:o="",children:w,value:p,defaultValue:Me,onValueChange:G,isDetached:K,defaultDetached:Le=!1,onDetachedChange:Q,onPopupBlocked:Y,features:Z,target:ee,autoFocus:ne=!0,className:Pe,detachedBodyClassName:te,disabled:re=!1,readOnly:ce=!1,closeOnMainWindowUnload:oe=!0,name:ue,serialize:le,deserialize:ae},Ve){let a=K!==void 0,[xe,k]=(0,e.useState)(Le),T=a?K:xe,x=p!==void 0,[Be,Oe]=(0,e.useState)(Me),m=x?p:Be,[y,se]=(0,e.useState)(null),u=(0,e.useRef)(null),E=(0,e.useRef)(null),v=(0,e.useRef)(null),S=(0,e.useRef)(null),B=(0,e.useRef)(null),N=(0,e.useRef)(!1),C=(0,e.useRef)(null),I=(0,e.useRef)(null),M=(0,e.useRef)(null),h=(0,e.useRef)(null),s=(0,e.useRef)(Te),ie=(0,e.useRef)(null),[b]=(0,e.useState)(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),i=(0,e.useRef)({title:o,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:c});i.current={title:o,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:c};let L=(0,e.useRef)(le??Ae);L.current=le??Ae;let de=(0,e.useRef)(ae??Ee);de.current=ae??Ee;let fe=(0,e.useRef)(G);fe.current=G;let R=(0,e.useRef)(Q);R.current=Q;let pe=(0,e.useRef)(Y);pe.current=Y;let A=(0,Ne.useMovableContent)(t==="detach"?y:null),O=(0,e.useRef)(A.bringBack);O.current=A.bringBack;let z=(0,e.useRef)(T);z.current=T;let ge=(0,e.useRef)(m);ge.current=m;let g=`${je}/${c}`,P=(0,e.useCallback)(()=>{C.current?.(),C.current=null,S.current&&(clearInterval(S.current),S.current=null),B.current?.(),B.current=null,se(null)},[]),V=(0,e.useCallback)(()=>{v.current&&(v.current.close(),v.current=null),I.current&&typeof window<"u"&&(window.removeEventListener("message",I.current),I.current=null)},[]),D=(0,e.useCallback)(n=>{let r={channel:g,instanceId:b,messageId:Ye(),origin:"main",timestamp:Date.now(),...n};v.current?v.current.postMessage(r):u.current&&!u.current.closed&&u.current.postMessage(r,"/")},[g,b]),W=(0,e.useCallback)(n=>{if(!Ke(n,g)||n.instanceId===b||i.current.readOnly)return;if(n.type==="hello"){if(s.current.clock===0||h.current===null)return;D({type:"value-sync",payload:h.current,...s.current});return}if(n.payload===void 0)return;let r=typeof n.clock=="number"?{clock:n.clock,writer:typeof n.writer=="string"?n.writer:n.instanceId}:{clock:s.current.clock+1,writer:n.instanceId};if(!Xe(r,s.current)||(s.current=r,n.payload===h.current)||(h.current=n.payload,n.payload===M.current))return;let l=de.current(n.payload);x||Oe(l),fe.current?.(l)},[g,b,x,D]),me=(0,e.useCallback)(()=>{if(V(),!(typeof window>"u")){if(ie.current!==g){ie.current=g,s.current=Te,h.current=null;let n=ge.current;M.current=n===void 0?null:L.current(n)}if(Ze()){let n=new BroadcastChannel(g),r=l=>W(l.data);n.addEventListener("message",r),v.current=n}else{let n=r=>{let l=u.current;!l||r.source!==l||r.origin===window.location.origin&&W(r.data)};window.addEventListener("message",n),I.current=n}i.current.readOnly||D({type:"hello"})}},[g,V,W,D]),he=(0,e.useCallback)(n=>{let r=L.current(n);r!==M.current&&(M.current=r,!i.current.readOnly&&r!==h.current&&(h.current=r,s.current={clock:s.current.clock+1,writer:b},D({type:"value-sync",payload:r,...s.current})))},[b,D]),we=(0,e.useCallback)(()=>{if(typeof window>"u"||i.current.disabled||N.current||u.current&&!u.current.closed)return;N.current=!0;let n=i.current,r=window.open("",n.target||"",n.features||qe),l=r?(0,f.popupDocument)(r):null;if(!r||!l){N.current=!1,a||k(!1),R.current?.(!1),pe.current?.();return}(0,f.severOpener)(r),u.current=r,E.current=l,l.title=n.title||document.title;let De=l.createElement("div");l.body.appendChild(De),se(De),B.current=(0,f.mirrorDocument)(document,l,{bodyClassName:n.detachedBodyClassName});let ke=!1,j=()=>{ke||(ke=!0,O.current(),P(),u.current=null,E.current=null,a||k(!1),R.current?.(!1))};r.addEventListener("pagehide",j),C.current=()=>r.removeEventListener("pagehide",j),S.current=setInterval(()=>{(0,f.popupDocument)(r,l)||j()},Je),n.autoFocus&&r.focus(),N.current=!1},[a,P]),ye=(0,e.useCallback)(()=>{O.current();let n=u.current;u.current=null,E.current=null,P(),n&&!n.closed&&n.close()},[P]),ve=(0,e.useRef)(we);ve.current=we;let $=(0,e.useRef)(ye);$.current=ye;let be=(0,e.useRef)(he);be.current=he;let H=(0,e.useCallback)(()=>{i.current.disabled||(a||k(!0),R.current?.(!0))},[a]),U=(0,e.useCallback)(()=>{a||k(!1),R.current?.(!1)},[a]),F=(0,e.useCallback)(()=>{let n=!z.current;n&&i.current.disabled||(a||k(n),R.current?.(n))},[a]);(0,e.useImperativeHandle)(Ve,()=>({open:H,close:U,toggle:F,get isDetached(){return z.current},get window(){return u.current}}),[H,U,F]),(0,e.useEffect)(()=>(me(),()=>V()),[me,V]),(0,e.useEffect)(()=>{if(T)return ve.current(),()=>$.current();$.current()},[T]),(0,e.useEffect)(()=>{m!==void 0&&be.current(m)},[m]),(0,e.useEffect)(()=>{let n=u.current,r=E.current;n&&r&&o&&(0,f.setPopupTitle)(n,r,o)},[o]),(0,e.useEffect)(()=>{if(typeof window>"u")return;let n=()=>{i.current.closeOnMainWindowUnload&&u.current&&!u.current.closed&&u.current.close()};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n);let r=u.current;C.current?.(),C.current=null,u.current=null,r&&!r.closed&&r.close()}},[]);let _=typeof w=="function"?w({open:H,close:U,toggle:F,detached:T,windowRef:u.current}):w,Re=t==="detach"&&y!==null;return(0,d.jsxs)(d.Fragment,{children:[ue&&m!==void 0&&(0,d.jsx)("input",{type:"hidden",name:ue,value:L.current(m)}),(0,d.jsx)("div",{ref:A.hostRef,className:_e(Pe),hidden:Re,children:A.inline(_)}),A.portal((0,d.jsx)(X.LayerDocumentProvider,{document:Re?y.ownerDocument:null,children:_})),t==="clone"&&y&&(0,Se.createPortal)((0,d.jsx)(X.LayerDocumentProvider,{document:y.ownerDocument,children:_}),y)]})}var Ie=(0,e.forwardRef)(en);Ie.displayName="AdvanceDetachable";0&&(module.exports={AdvanceDetachable});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as P,useRef as r,useEffect as T,useCallback as a,useImperativeHandle as Oe,forwardRef as ze}from"react";import{createPortal as We}from"react-dom";import{useMovableContent as $e}from"../detachable/useMovableContent.js";import{mirrorDocument as He,popupDocument as Te,setPopupTitle as Ue,severOpener as Fe}from"../detachable/popup-window.js";import{LayerDocumentProvider as Ce}from"../../lib/layer-document.js";import{Fragment as tn,jsx as V,jsxs as rn}from"react/jsx-runtime";function _e(...t){return t.filter(Boolean).join(" ")}var je="@synertech/ui/AdvanceDetachable",Je=300,qe="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Ae={clock:0,writer:""};function Xe(t,l){return t.clock>l.clock||t.clock===l.clock&&t.writer>l.writer}var Ee=(t,l)=>t===void 0||l(t),q=t=>typeof t=="string",Ge=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0;function Ke(t,l){if(typeof t!="object"||t===null)return!1;let u=t;return u.channel!==l||!q(u.instanceId)?!1:u.type==="hello"?!0:u.type==="value-sync"&&q(u.payload)&&Ee(u.clock,Ge)&&Ee(u.writer,q)}var Qe=0;function Ye(){return`${Date.now()}-${++Qe}-${Math.random().toString(36).slice(2,8)}`}function Se(t){try{return JSON.stringify(t)}catch{return String(t)}}function Ne(t){try{return JSON.parse(t)}catch{return t}}function Ze(){return typeof BroadcastChannel<"u"}function en({mode:t,id:l,title:u="",children:x,value:X,defaultValue:Ie,onValueChange:G,isDetached:K,defaultDetached:Me=!1,onDetachedChange:Q,onPopupBlocked:Y,features:Z,target:ee,autoFocus:ne=!0,className:Le,detachedBodyClassName:te,disabled:re=!1,readOnly:ce=!1,closeOnMainWindowUnload:oe=!0,name:ue,serialize:le,deserialize:ae},Pe){let s=K!==void 0,[Ve,b]=P(Me),R=s?K:Ve,B=X!==void 0,[xe,Be]=P(Ie),p=B?X:xe,[m,se]=P(null),c=r(null),C=r(null),h=r(null),A=r(null),O=r(null),E=r(!1),D=r(null),S=r(null),N=r(null),g=r(null),i=r(Ae),ie=r(null),[w]=P(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),d=r({title:u,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:l});d.current={title:u,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:l};let I=r(le??Se);I.current=le??Se;let de=r(ae??Ne);de.current=ae??Ne;let fe=r(G);fe.current=G;let y=r(Q);y.current=Q;let pe=r(Y);pe.current=Y;let k=$e(t==="detach"?m:null),z=r(k.bringBack);z.current=k.bringBack;let W=r(R);W.current=R;let ge=r(p);ge.current=p;let f=`${je}/${l}`,M=a(()=>{D.current?.(),D.current=null,A.current&&(clearInterval(A.current),A.current=null),O.current?.(),O.current=null,se(null)},[]),L=a(()=>{h.current&&(h.current.close(),h.current=null),S.current&&typeof window<"u"&&(window.removeEventListener("message",S.current),S.current=null)},[]),v=a(e=>{let n={channel:f,instanceId:w,messageId:Ye(),origin:"main",timestamp:Date.now(),...e};h.current?h.current.postMessage(n):c.current&&!c.current.closed&&c.current.postMessage(n,"/")},[f,w]),$=a(e=>{if(!Ke(e,f)||e.instanceId===w||d.current.readOnly)return;if(e.type==="hello"){if(i.current.clock===0||g.current===null)return;v({type:"value-sync",payload:g.current,...i.current});return}if(e.payload===void 0)return;let n=typeof e.clock=="number"?{clock:e.clock,writer:typeof e.writer=="string"?e.writer:e.instanceId}:{clock:i.current.clock+1,writer:e.instanceId};if(!Xe(n,i.current)||(i.current=n,e.payload===g.current)||(g.current=e.payload,e.payload===N.current))return;let o=de.current(e.payload);B||Be(o),fe.current?.(o)},[f,w,B,v]),me=a(()=>{if(L(),!(typeof window>"u")){if(ie.current!==f){ie.current=f,i.current=Ae,g.current=null;let e=ge.current;N.current=e===void 0?null:I.current(e)}if(Ze()){let e=new BroadcastChannel(f),n=o=>$(o.data);e.addEventListener("message",n),h.current=e}else{let e=n=>{let o=c.current;!o||n.source!==o||n.origin===window.location.origin&&$(n.data)};window.addEventListener("message",e),S.current=e}d.current.readOnly||v({type:"hello"})}},[f,L,$,v]),he=a(e=>{let n=I.current(e);n!==N.current&&(N.current=n,!d.current.readOnly&&n!==g.current&&(g.current=n,i.current={clock:i.current.clock+1,writer:w},v({type:"value-sync",payload:n,...i.current})))},[w,v]),we=a(()=>{if(typeof window>"u"||d.current.disabled||E.current||c.current&&!c.current.closed)return;E.current=!0;let e=d.current,n=window.open("",e.target||"",e.features||qe),o=n?Te(n):null;if(!n||!o){E.current=!1,s||b(!1),y.current?.(!1),pe.current?.();return}Fe(n),c.current=n,C.current=o,o.title=e.title||document.title;let De=o.createElement("div");o.body.appendChild(De),se(De),O.current=He(document,o,{bodyClassName:e.detachedBodyClassName});let ke=!1,J=()=>{ke||(ke=!0,z.current(),M(),c.current=null,C.current=null,s||b(!1),y.current?.(!1))};n.addEventListener("pagehide",J),D.current=()=>n.removeEventListener("pagehide",J),A.current=setInterval(()=>{Te(n,o)||J()},Je),e.autoFocus&&n.focus(),E.current=!1},[s,M]),ye=a(()=>{z.current();let e=c.current;c.current=null,C.current=null,M(),e&&!e.closed&&e.close()},[M]),ve=r(we);ve.current=we;let H=r(ye);H.current=ye;let be=r(he);be.current=he;let U=a(()=>{d.current.disabled||(s||b(!0),y.current?.(!0))},[s]),F=a(()=>{s||b(!1),y.current?.(!1)},[s]),_=a(()=>{let e=!W.current;e&&d.current.disabled||(s||b(e),y.current?.(e))},[s]);Oe(Pe,()=>({open:U,close:F,toggle:_,get isDetached(){return W.current},get window(){return c.current}}),[U,F,_]),T(()=>(me(),()=>L()),[me,L]),T(()=>{if(R)return ve.current(),()=>H.current();H.current()},[R]),T(()=>{p!==void 0&&be.current(p)},[p]),T(()=>{let e=c.current,n=C.current;e&&n&&u&&Ue(e,n,u)},[u]),T(()=>{if(typeof window>"u")return;let e=()=>{d.current.closeOnMainWindowUnload&&c.current&&!c.current.closed&&c.current.close()};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e);let n=c.current;D.current?.(),D.current=null,c.current=null,n&&!n.closed&&n.close()}},[]);let j=typeof x=="function"?x({open:U,close:F,toggle:_,detached:R,windowRef:c.current}):x,Re=t==="detach"&&m!==null;return rn(tn,{children:[ue&&p!==void 0&&V("input",{type:"hidden",name:ue,value:I.current(p)}),V("div",{ref:k.hostRef,className:_e(Le),hidden:Re,children:k.inline(j)}),k.portal(V(Ce,{document:Re?m.ownerDocument:null,children:j})),t==="clone"&&m&&We(V(Ce,{document:m.ownerDocument,children:j}),m)]})}var nn=ze(en);nn.displayName="AdvanceDetachable";export{nn as AdvanceDetachable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var He=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Je=(u,i)=>{for(var r in i)He(u,r,{get:i[r],enumerable:!0})},Qe=(u,i,r,m)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of Ze(i))!qe.call(u,h)&&h!==r&&He(u,h,{get:()=>i[h],enumerable:!(m=je(i,h))||m.enumerable});return u};var et=u=>Qe(He({},"__esModule",{value:!0}),u);var st={};Je(st,{AreaChart:()=>lt});module.exports=et(st);var l=require("react"),Ke=require("../../lib/cn.cjs"),pe=require("../../lib/i18n.cjs"),te=require("../chart/ChartAnnotations.cjs"),Ne=require("../chart/ChartAxis.cjs"),Ce=require("../chart/ChartBrush.cjs"),Me=require("../chart/ChartContainer.cjs"),$e=require("../chart/ChartGrid.cjs"),Oe=require("../chart/ChartLegend.cjs"),be=require("../chart/ChartPatterns.cjs"),Xe=require("../chart/ChartSync.cjs"),Ge=require("../chart/ChartTableView.cjs"),ye=require("../chart/ChartTooltip.cjs"),H=require("../chart/palette.cjs"),L=require("../chart/utils/cartesian.cjs"),ve=require("../chart/utils/data.cjs"),ke=require("../chart/utils/decimate.cjs"),N=require("../chart/utils/format.cjs"),xe=require("../chart/utils/keyboard.cjs"),P=require("../chart/utils/path.cjs"),ne=require("../chart/utils/scales.cjs"),Pe=require("../chart/utils/stack.cjs"),_e=require("../chart/utils/ticks.cjs"),ze=require("../chart/utils/timestamp.cjs"),Ue=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),tt=.12,nt=.9,rt=10,ot=(0,l.memo)(function({bands:i,stacked:r,patterns:m,patternBaseId:h}){return(0,n.jsx)("g",{children:i.map(c=>(0,n.jsxs)("g",{children:[(0,n.jsx)("path",{d:c.area,fill:(0,be.patternFill)(m,h,c.slot,c.color),fillOpacity:r?nt:tt,stroke:"none"}),c.gap?(0,n.jsx)("path",{d:c.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,(0,n.jsx)("path",{d:c.edge,fill:"none",stroke:c.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),c.isolated.map((C,W)=>(0,n.jsx)("circle",{cx:C.x,cy:C.y,r:3,fill:c.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},W))]},c.key))})});function at({width:u,height:i,data:r,resolvedSeries:m,x:h,y:c,grid:C,size:W,curve:b,stack:S,baseline:A,connectNulls:B,referenceLines:X,annotations:R,annotationsLabel:Le,patterns:re,patternBaseId:oe,overlay:Se,maxPoints:v,brush:ae,onBrush:le,brushLabel:Ae,syncEnabled:G,margin:se,tooltip:w,onPointClick:T,plotLabel:Be,formatValue:k,formatRaw:_,formatX:D}){let[z,U]=(0,l.useState)(null),s=z!==null&&z<r.length?z:null,[Re,we]=(0,l.useState)(null),Te=(0,Xe.useChartSync)(),d=G?Te:null,t=(0,l.useMemo)(()=>{let e=m.filter(E=>!E.hidden),o=e.map(E=>E.key),a=S!=="none",f=(0,Pe.stackSeries)(r,o,S),he=a?(0,Pe.stackExtent)(f):(0,_e.extent)([...(0,ve.collectAllValues)(r,o),A]),p=(0,L.buildCartesianGeometry)({width:u,height:i,data:r,x:h,y:c,bounds:he,margin:se,placement:"point",formatValue:k,formatX:D,defaultIncludeZero:!0}),Ee=p.categoryCenters,me=p.valueScale,Ye=me(a?0:A),Fe=e.map((E,Ie)=>{let J=r.map((Q,ee)=>{let I=f[ee].segments[Ie];return{x:Ee[ee],y:I.value===null?Number.NaN:me(I.end),defined:I.value!==null}}),We=r.map((Q,ee)=>{let I=f[ee].segments[Ie];return{x:Ee[ee],y:I.value===null?Number.NaN:me(a?I.start:A),defined:I.value!==null}}),de={connectNulls:B},ge=v&&v>0&&J.length>v?(0,ke.decimateIndices)(J,v):null,fe=ge?ge.map(Q=>J[Q]):J,De=ge?ge.map(Q=>We[Q]):We;return v||(0,ke.warnPointBudget)("AreaChart",J.length),{key:E.key,color:E.color,slot:E.slot,area:a?(0,P.buildAreaPath)(fe,De,b,de):(0,P.buildAreaPath)(fe,Ye,b,de),edge:(0,P.buildLinePath)(fe,b,de),gap:a&&Ie>0?(0,P.buildLinePath)(De,b,de):"",isolated:(0,P.isolatedPoints)(fe,B)}});return{visible:e,locate:(0,L.createCategoryLocator)(p),plot:(0,L.createPlotContext)({geometry:p,width:u,height:i,data:r,series:e,formatValue:k,formatX:D}),rows:f,stacked:a,xValues:p.xValues,positions:Ee,xTicks:p.categoryTicks,yTicks:p.valueTicks,valueScale:me,innerWidth:p.innerWidth,innerHeight:p.innerHeight,margin:p.margin,bands:Fe}},[r,m,h,c,u,i,se,b,S,A,B,v,k,D]),Y=(0,l.useCallback)(e=>t.visible.map((o,a)=>{let f=(0,ve.readNumber)(r[e],o.key),he=t.rows[e].segments[a],p=f===null?"\u2014":S==="percent"?`${_(f)} (${k(he.end-he.start)})`:k(f);return{seriesKey:o.key,seriesLabel:(0,H.getSeriesLabel)(o),color:o.color,value:f,formattedValue:p,datum:r[e]}}),[r,t.visible,t.rows,S,k,_]),ie=d?d.brush:Re,y=(0,l.useCallback)(e=>{we(e),d?.setBrush(e),le?.(e)},[d,le]),g=(0,Ce.useChartBrush)({enabled:ae,active:ie!==null,centers:t.positions,xValues:t.xValues,offset:t.margin.left,orientation:"vertical",onCommit:y}),ue=(0,l.useCallback)(e=>{if(g.onPointerMove(e),w===!1||r.length===0)return;let o=e.currentTarget.getBoundingClientRect(),a=e.clientX-o.left-t.margin.left,f=(0,ne.nearestIndex)(t.positions,a);U(f>=0?f:null),d?.setHovered(f>=0?t.xValues[f]:null)},[g,w,r.length,t.margin.left,t.positions,t.xValues,d]),ce=(0,l.useCallback)(()=>{U(null),d?.setHovered(null)},[d]),K=(0,l.useCallback)(()=>{if(!T||s===null)return;let[e]=Y(s);e&&T({...e,index:s,x:t.xValues[s]})},[T,s,Y,t.xValues]),M=(0,l.useCallback)(e=>{if(r.length===0)return;let o=T&&s!==null&&t.visible.length>0;if((0,xe.pressChartMark)(e,o?K:null))return;g.onKeyDown(e,s);let a=(0,xe.chartCursorTarget)(e.key,s,r.length,"x");a!==void 0&&(e.preventDefault(),U(a),d?.setHovered(a===null?null:t.xValues[a]))},[r.length,s,g,d,t.xValues,t.visible.length,T,K]),$=(0,l.useCallback)(()=>{g.consumedClick()||K()},[g,K]),Ve=s!==null||!d?.hovered?null:(()=>{let e=(0,ne.toKey)(d.hovered),o=t.xValues.findIndex(a=>(0,ne.toKey)(a)===e);return o<0?null:o})(),x=s??Ve,F=s===null?null:Y(s),O=x===null?[]:t.visible.map((e,o)=>{let a=t.rows[x].segments[o];return a.value===null?null:{key:e.key,color:e.color,y:t.valueScale(a.end)}}).filter(e=>e!==null),j=g.dragging??ie,Z=(()=>{if(!j)return null;let e=t.locate(j.from),o=t.locate(j.to);return e===null||o===null?null:{from:e,to:o}})(),q=(0,L.splitOverlay)(Se),V=s===null||F===null?null:{x:t.xValues[s],xLabel:D(t.xValues[s],s),index:s,points:F};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:i,role:"img","aria-label":Be??[t.visible.map(e=>(0,H.getSeriesLabel)(e)).join(", "),(0,te.describeAnnotations)(R,Le)].filter(Boolean).join(". "),tabIndex:0,className:(0,Ke.cn)(Ue.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",ae&&"select-none"),onPointerDown:g.onPointerDown,onPointerMove:ue,onPointerUp:g.onPointerUp,onPointerCancel:g.onPointerUp,onPointerLeave:ce,onKeyDown:M,onBlur:ce,onClick:$,children:[re?(0,n.jsx)(be.ChartPatternDefs,{id:oe,entries:m.map(e=>({slot:e.slot,color:e.color}))}):null,(0,n.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,n.jsx)($e.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:C==="y"||C==="both"?t.yTicks.map(e=>e.offset):void 0,vertical:C==="x"||C==="both"?t.xTicks.map(e=>e.offset):void 0}),R?(0,n.jsx)(te.ChartAnnotationLayer,{layer:"under",annotations:R,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,Z?(0,n.jsx)(Ce.ChartBrushLayer,{from:Z.from,to:Z.to,width:t.innerWidth,height:t.innerHeight,live:g.dragging!==null,label:Ae}):null,q.under?.(t.plot),(0,n.jsx)(ot,{bands:t.bands,stacked:t.stacked,patterns:re&&t.stacked,patternBaseId:oe}),R?(0,n.jsx)(te.ChartAnnotationLayer,{annotations:R,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,X?.map(e=>{let o=t.valueScale(e.value),a=o<rt?o+12:o-4;return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:0,y1:o,x2:t.innerWidth,y2:o,stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?(0,n.jsx)("text",{x:t.innerWidth,y:a,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)}),q.over?.(t.plot),x!==null?(0,n.jsxs)("g",{"aria-hidden":"true",children:[(0,n.jsx)("line",{x1:t.positions[x],y1:0,x2:t.positions[x],y2:t.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:s===null?"3 3":void 0}),O.map(e=>(0,n.jsx)("circle",{cx:t.positions[x],cy:e.y,r:4,fill:e.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},e.key))]}):null]}),(0,n.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:h.hidden?null:(0,n.jsx)(Ne.ChartAxis,{orientation:"bottom",ticks:t.xTicks,length:t.innerWidth,label:h.label,size:W})}),(0,n.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:c?.hidden?null:(0,n.jsx)(Ne.ChartAxis,{orientation:"left",ticks:t.yTicks,length:t.innerHeight,showLine:!1,label:c?.label,size:W})})]}),V&&w!==!1?(0,n.jsx)(ye.ChartTooltip,{x:t.margin.left+t.positions[V.index],y:t.margin.top+(O.length>0?Math.min(...O.map(e=>e.y)):t.innerHeight/2),containerWidth:u,children:typeof w=="function"?w(V):(0,n.jsx)(ye.ChartTooltipContent,{title:V.xLabel,points:V.points})}):null]})}function lt({data:u,series:i,x:r,y:m,height:h=240,width:c,size:C="md",grid:W="y",legend:b,tooltip:S=!0,tableView:A=!1,emphasis:B,title:X,description:R,loading:Le=!1,emptyState:re,error:oe=!1,errorState:Se,onRetry:v,actions:ae,onPointClick:le,curve:Ae="monotone",stack:G="none",baseline:se=0,connectNulls:w=!1,referenceLines:T,annotations:Be,overlay:k,patterns:_=!1,legendToggle:D=!0,maxPoints:z,brush:U=!1,onBrush:s,brushLabel:Re,sync:we=!0,margin:Te,locale:d,plotLabel:t,className:Y,...ie}){let y=(0,pe.useUILocale)(d),g=(0,pe.useUILabels)(),[ue,ce]=(0,l.useState)(()=>new Set),K=(0,l.useId)(),M=(0,l.useMemo)(()=>i.map((e,o)=>({...e,slot:o,hidden:e.hidden||ue.has(e.key),color:(0,H.resolveSeriesColor)(e,o,B)})),[i,ue,B]),$=G==="percent",Ve=(0,l.useMemo)(()=>$?{domain:[0,100],...m}:m,[$,m]),x=(0,l.useMemo)(()=>m?.format??($?e=>(0,N.formatPercent)(e,{locale:y,alreadyScaled:!0,maximumFractionDigits:0}):e=>(0,N.formatAuto)(e,y)),[m?.format,$,y]),F=(0,l.useMemo)(()=>e=>(0,N.formatAuto)(e,y),[y]),O=(0,l.useMemo)(()=>r.format??(e=>r.scale==="time"?(0,ze.formatTimeValue)(e,y):(0,N.formatXValue)(e,y)),[r.format,r.scale,y]),j=(0,l.useCallback)(e=>{ce(o=>{let a=new Set(o);return a.has(e)?a.delete(e):a.add(e),a})},[]),Z=b===void 0?i.length>=2:b!==!1,q=typeof b=="string"?b:"bottom",V=M.filter(e=>!e.hidden).length;return(0,n.jsx)(Me.ChartContainer,{title:X,description:R,height:h,width:c,size:C,loading:Le,empty:u.length===0||V===0,emptyState:re,error:oe,errorState:Se,onRetry:v,actions:ae,tableView:A,legendPosition:q,legend:Z?(0,n.jsx)(Oe.ChartLegend,{items:(0,H.toLegendItems)(M,B,_&&G!=="none"),position:q,marker:"rect",size:C,onToggle:D?j:void 0}):void 0,table:A?(0,n.jsx)(Ge.ChartTableView,{data:u,series:M,xKey:r.key,xLabel:r.label??r.key,formatX:O,formatValue:F,caption:typeof X=="string"?X:void 0}):void 0,className:Y,...ie,children:({width:e})=>(0,n.jsx)(at,{width:e,height:h,data:u,resolvedSeries:M,x:r,y:Ve,grid:W,size:C,curve:Ae,stack:G,baseline:se,connectNulls:w,referenceLines:T,annotations:Be,annotationsLabel:g.chartAnnotations,patterns:_,patternBaseId:K,overlay:k,maxPoints:z,brush:U,onBrush:s,brushLabel:Re??g.chartBrush,syncEnabled:we,margin:Te,tooltip:S,onPointClick:le,plotLabel:t,formatValue:x,formatRaw:F,formatX:O})})}0&&(module.exports={AreaChart});
|
|
1
|
+
"use strict";"use client";var Ne=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var et=(c,u)=>{for(var n in u)Ne(c,n,{get:u[n],enumerable:!0})},tt=(c,u,n,d)=>{if(u&&typeof u=="object"||typeof u=="function")for(let p of Je(u))!Qe.call(c,p)&&p!==n&&Ne(c,p,{get:()=>u[p],enumerable:!(d=qe(u,p))||d.enumerable});return c};var nt=c=>tt(Ne({},"__esModule",{value:!0}),c);var ct={};et(ct,{AreaChart:()=>ut});module.exports=nt(ct);var l=require("react"),_e=require("../../lib/cn.cjs"),Ce=require("../../lib/i18n.cjs"),ae=require("../chart/ChartAnnotations.cjs"),De=require("../chart/ChartAxis.cjs"),q=require("../chart/ChartBrush.cjs"),Oe=require("../chart/ChartContainer.cjs"),Ge=require("../chart/ChartGrid.cjs"),Xe=require("../chart/ChartLegend.cjs"),ve=require("../chart/ChartPatterns.cjs"),$e=require("../chart/ChartSync.cjs"),Ue=require("../chart/ChartTableView.cjs"),ke=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),g=require("../chart/utils/cartesian.cjs"),xe=require("../chart/utils/data.cjs"),se=require("../chart/utils/decimate.cjs"),W=require("../chart/utils/format.cjs"),Se=require("../chart/utils/keyboard.cjs"),I=require("../chart/utils/path.cjs"),Z=require("../chart/utils/scales.cjs"),Pe=require("../chart/utils/stack.cjs"),ze=require("../chart/utils/ticks.cjs"),Ye=require("../chart/utils/timestamp.cjs"),Fe=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),ot=6,rt=.12,at=.9,st=10,lt=(0,l.memo)(function({bands:u,stacked:n,patterns:d,patternBaseId:p}){return(0,r.jsx)("g",{children:u.map(m=>(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:m.area,fill:(0,ve.patternFill)(d,p,m.slot,m.color),fillOpacity:n?at:rt,stroke:"none"}),m.gap?(0,r.jsx)("path",{d:m.gap,fill:"none",strokeWidth:2,stroke:A.CHART_SURFACE_COLOR}):null,(0,r.jsx)("path",{d:m.edge,fill:"none",stroke:m.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),m.isolated.map((P,$)=>(0,r.jsx)("circle",{cx:P.x,cy:P.y,r:3,fill:m.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},$))]},m.key))})});function it({width:c,height:u,data:n,resolvedSeries:d,x:p,y:m,grid:P,size:$,curve:L,stack:M,baseline:N,connectNulls:D,referenceLines:K,annotations:w,annotationsLabel:Ae,patterns:le,patternBaseId:ie,overlay:Le,maxPoints:B,brush:ue,onBrush:ce,brushLabel:Re,syncEnabled:J,margin:he,tooltip:_,onPointClick:V,plotLabel:we,formatValue:O,formatRaw:U,formatX:z,locale:me}){let[Q,ee]=(0,l.useState)(null),h=Q!==null&&Q<n.length?Q:null,[Be,Ve]=(0,l.useState)(null),Ee=(0,$e.useChartSync)(),b=J?Ee:null,e=(0,l.useMemo)(()=>{let t=d.filter(x=>!x.hidden),o=t.map(x=>x.key),s=M!=="none",i=(0,Pe.stackSeries)(n,o,M),G=(0,g.widenBounds)(s?(0,Pe.stackExtent)(i):(0,ze.extent)([...(0,xe.collectAllValues)(n,o),N]),(0,g.annotationValues)(n,p.key,K,w)),f=(0,g.buildCartesianGeometry)({locale:me,width:c,height:u,data:n,x:p,y:m,bounds:G,margin:he,placement:"point",formatValue:O,formatX:z,defaultIncludeZero:!0}),F=f.categoryCenters,y=f.valueScale,k=y(s?0:N),re=t.map((x,X)=>({top:n.map((j,H)=>{let S=i[H].segments[X];return{x:F[H],y:S.value===null?Number.NaN:y(S.end),defined:S.value!==null}}),bottom:n.map((j,H)=>{let S=i[H].segments[X];return{x:F[H],y:S.value===null?Number.NaN:y(s?S.start:N),defined:S.value!==null}})})),We=B!==void 0&&B>0&&n.length>B,je=We&&s?[...new Set(re.flatMap(({top:x})=>(0,se.decimateIndices)(x,B)))].sort((x,X)=>x-X):null,Ze=t.map((x,X)=>{let{top:j,bottom:H}=re[X],S={connectNulls:D},be=je??(We?(0,se.decimateIndices)(j,B):null),ye=be?be.map(Me=>j[Me]):j,Ke=be?be.map(Me=>H[Me]):H;return B||(0,se.warnPointBudget)("AreaChart",j.length),{key:x.key,color:x.color,slot:x.slot,area:s?(0,I.buildAreaPath)(ye,Ke,L,S):(0,I.buildAreaPath)(ye,k,L,S),edge:(0,I.buildLinePath)(ye,L,S),gap:s&&X>0?(0,I.buildLinePath)(Ke,L,S):"",isolated:(0,I.isolatedPoints)(ye,D)}});return{visible:t,locate:(0,g.createCategoryLocator)(f),span:(0,g.createSpanLocator)(f),plot:(0,g.createPlotContext)({geometry:f,width:c,height:u,data:n,series:t,formatValue:O,formatX:z}),rows:i,stacked:s,xValues:f.xValues,positions:F,xTicks:f.categoryTicks,yTicks:f.valueTicks,valueScale:y,innerWidth:f.innerWidth,innerHeight:f.innerHeight,margin:f.margin,bands:Ze}},[me,n,d,p,m,c,u,he,L,M,N,D,B,K,w,O,z]),te=(0,l.useCallback)(t=>e.visible.map((o,s)=>{let i=(0,xe.readNumber)(n[t],o.key),G=e.rows[t].segments[s],f=i===null?"\u2014":M==="percent"?`${U(i)} (${O(G.end-G.start)})`:U(i);return{seriesKey:o.key,seriesLabel:(0,A.getSeriesLabel)(o),color:o.color,value:i,formattedValue:f,datum:n[t]}}),[n,e.visible,e.rows,M,O,U]),v=b?b.brush:Be,de=(0,l.useCallback)(t=>{Ve(t),b?.setBrush(t),ce?.(t)},[b,ce]),C=(0,q.useChartBrush)({enabled:ue,active:v!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:de}),Te=(0,l.useCallback)(t=>{if(C.onPointerMove(t),_===!1||n.length===0)return;let o=t.currentTarget.getBoundingClientRect(),s=t.clientX-o.left-e.margin.left,i=(0,Z.nearestIndex)(e.positions,s);ee(i>=0?i:null),b?.setHovered(i>=0?e.xValues[i]:null)},[C,_,n.length,e.margin.left,e.positions,e.xValues,b]),pe=(0,l.useCallback)(()=>{ee(null),b?.setHovered(null)},[b]),R=(0,l.useCallback)((t,o)=>{if(!V)return;let s=te(t),i=e.rows[t]?.segments??[],G=s.map((y,k)=>({point:y,segment:i[k]})).filter(({point:y,segment:k})=>y.value!==null&&k!==void 0),f=({segment:y})=>{if(o===null)return 0;let k=e.valueScale(y.end),re=e.valueScale(e.stacked?y.start:y.end);return e.stacked&&o.y>=Math.min(k,re)&&o.y<=Math.max(k,re)?-1:Math.abs(k-o.y)},F=G.length>0?G.reduce((y,k)=>f(k)<f(y)?k:y).point:s[0];F&&V({...F,index:t,x:e.xValues[t]})},[V,te,e.rows,e.stacked,e.valueScale,e.xValues]),T=(0,l.useCallback)(t=>{if(n.length===0)return;let o=V&&h!==null&&e.visible.length>0;if((0,Se.pressChartMark)(t,o?()=>R(h,null):null))return;let s=C.onKeyDown(t,h),i=(0,Se.chartCursorTarget)(t.key,h,n.length,"x");if(i===void 0){s&&t.preventDefault();return}t.preventDefault(),ee(i),b?.setHovered(i===null?null:e.xValues[i])},[n.length,h,C,b,e.xValues,e.visible.length,V,R]),He=(0,l.useCallback)(t=>{if(C.consumedClick()||!V||n.length===0)return;let o=(0,g.plotPointer)(t,e),s=h??(o===null?-1:(0,Z.nearestIndex)(e.positions,o.x));s<0||R(s,o)},[C,V,n.length,e,h,R]),Ie=h!==null||b===null||b.hovered===null?null:(()=>{let t=(0,Z.toKey)(b.hovered),o=e.xValues.findIndex(s=>(0,Z.toKey)(s)===t);return o<0?null:o})(),E=h??Ie,ne=h===null?null:te(h),oe=E===null?[]:e.visible.map((t,o)=>{let s=e.rows[E].segments[o];return s.value===null?null:{key:t.key,color:t.color,y:e.valueScale(s.end)}}).filter(t=>t!==null),fe=C.dragging??v,Y=fe?(0,q.locateBrush)(fe,e.xValues,e.positions,e.locate):null,ge=(0,g.splitOverlay)(Le),a=h===null||ne===null?null:{x:e.xValues[h],xLabel:z(e.xValues[h],h),index:h,points:ne};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:c,height:u,role:"img","aria-label":we??[e.visible.map(t=>(0,A.getSeriesLabel)(t)).join(", "),(0,ae.describeAnnotations)(w,Ae)].filter(Boolean).join(". "),tabIndex:0,className:(0,_e.cn)(Fe.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",ue&&"select-none"),onPointerDown:C.onPointerDown,onPointerMove:Te,onPointerUp:C.onPointerUp,onPointerCancel:C.onPointerUp,onPointerLeave:pe,onKeyDown:T,onBlur:pe,onClick:He,children:[le?(0,r.jsx)(ve.ChartPatternDefs,{id:ie,entries:d.map(t=>({slot:t.slot,color:t.color}))}):null,(0,r.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,r.jsx)(Ge.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:P==="y"||P==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:P==="x"||P==="both"?e.xTicks.map(t=>t.offset):void 0}),w?(0,r.jsx)(ae.ChartAnnotationLayer,{layer:"under",annotations:w,xAt:e.locate,spanAt:e.span,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,Y?(0,r.jsx)(q.ChartBrushLayer,{from:Y.from,to:Y.to,width:e.innerWidth,height:e.innerHeight,live:C.dragging!==null,label:Re,minSpan:ot}):null,ge.under?.(e.plot),(0,r.jsx)(lt,{bands:e.bands,stacked:e.stacked,patterns:le&&e.stacked,patternBaseId:ie}),w?(0,r.jsx)(ae.ChartAnnotationLayer,{annotations:w,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,K?.map(t=>{let o=e.valueScale(t.value),s=o<st?o+12:o-4;return(0,r.jsxs)("g",{children:[(0,r.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,r.jsx)("text",{x:e.innerWidth,y:s,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),ge.over?.(e.plot),E!==null?(0,r.jsxs)("g",{"aria-hidden":"true",children:[(0,r.jsx)("line",{x1:e.positions[E],y1:0,x2:e.positions[E],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:h===null?"3 3":void 0}),oe.map(t=>(0,r.jsx)("circle",{cx:e.positions[E],cy:t.y,r:4,fill:t.color,strokeWidth:2,stroke:A.CHART_SURFACE_COLOR},t.key))]}):null]}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:$})}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:m?.hidden?null:(0,r.jsx)(De.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:m?.label,size:$})})]}),a&&_!==!1?(0,r.jsx)(ke.ChartTooltip,{x:e.margin.left+e.positions[a.index],y:e.margin.top+(oe.length>0?Math.min(...oe.map(t=>t.y)):e.innerHeight/2),containerWidth:c,children:typeof _=="function"?_(a):(0,r.jsx)(ke.ChartTooltipContent,{title:a.xLabel,points:a.points})}):null]})}function ut({data:c,series:u,x:n,y:d,height:p=240,width:m,size:P="md",grid:$="y",legend:L,tooltip:M=!0,tableView:N=!1,emphasis:D,title:K,description:w,loading:Ae=!1,emptyState:le,error:ie=!1,errorState:Le,onRetry:B,actions:ue,onPointClick:ce,curve:Re="monotone",stack:J="none",baseline:he=0,connectNulls:_=!1,referenceLines:V,annotations:we,overlay:O,patterns:U=!1,legendToggle:z=!0,maxPoints:me,brush:Q=!1,onBrush:ee,brushLabel:h,sync:Be=!0,margin:Ve,locale:Ee,plotLabel:b,className:e,...te}){let v=(0,Ce.useUILocale)(Ee),de=(0,Ce.useUILabels)(),[C,Te]=(0,l.useState)(()=>new Set),pe=(0,l.useId)(),R=(0,l.useMemo)(()=>u.map((a,t)=>({...a,slot:t,hidden:a.hidden||C.has(a.key),color:(0,A.resolveSeriesColor)(a,t,D)})),[u,C,D]),T=J==="percent",He=(0,l.useMemo)(()=>T?{domain:[0,100],...d}:d,[T,d]),Ie=(0,l.useMemo)(()=>d?.format??(T?a=>(0,W.formatPercent)(a,{locale:v,alreadyScaled:!0,maximumFractionDigits:0}):a=>(0,W.formatAuto)(a,v)),[d?.format,T,v]),E=(0,l.useMemo)(()=>!T&&d?.format||(a=>(0,W.formatExact)(a,v)),[T,d?.format,v]),ne=(0,l.useMemo)(()=>n.format??(a=>n.scale==="time"?(0,Ye.formatTimeValue)(a,v):(0,W.formatXValue)(a,v)),[n.format,n.scale,v]),oe=(0,l.useCallback)(a=>{Te(t=>{let o=new Set(t);return o.has(a)?o.delete(a):o.add(a),o})},[]),fe=L===void 0?u.length>=2:L!==!1,Y=typeof L=="string"?L:"bottom",ge=R.filter(a=>!a.hidden).length;return(0,r.jsx)(Oe.ChartContainer,{title:K,description:w,height:p,width:m,size:P,loading:Ae,empty:c.length===0||ge===0,emptyState:le,error:ie,errorState:Le,onRetry:B,actions:ue,exportSource:{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:N,legendPosition:Y,legend:fe?(0,r.jsx)(Xe.ChartLegend,{items:(0,A.toLegendItems)(R,D,U&&J!=="none"),position:Y,marker:"rect",size:P,onToggle:z?oe:void 0}):void 0,table:N?(0,r.jsx)(Ue.ChartTableView,{data:c,series:R,xKey:n.key,xLabel:n.label??n.key,formatX:ne,formatValue:E,caption:typeof K=="string"?K:void 0}):void 0,className:e,...te,children:({width:a})=>(0,r.jsx)(it,{locale:v,width:a,height:p,data:c,resolvedSeries:R,x:n,y:He,grid:$,size:P,curve:Re,stack:J,baseline:he,connectNulls:_,referenceLines:V,annotations:we,annotationsLabel:de.chartAnnotations,patterns:U,patternBaseId:pe,overlay:O,maxPoints:me,brush:Q,onBrush:ee,brushLabel:h??de.chartBrush,syncEnabled:Be,margin:Ve,tooltip:M,onPointClick:ce,plotLabel:b,formatValue:Ie,formatRaw:E,formatX:ne})})}0&&(module.exports={AreaChart});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as He,useCallback as x,useId as Ne,useMemo as K,useState as xe}from"react";import{cn as We}from"../../lib/cn.js";import{useUILabels as De,useUILocale as Ke}from"../../lib/i18n.js";import{ChartAnnotationLayer as Se,describeAnnotations as Me}from"../chart/ChartAnnotations.js";import{ChartAxis as Ae}from"../chart/ChartAxis.js";import{ChartBrushLayer as $e,useChartBrush as Oe}from"../chart/ChartBrush.js";import{ChartContainer as Xe}from"../chart/ChartContainer.js";import{ChartGrid as Ge}from"../chart/ChartGrid.js";import{ChartLegend as _e}from"../chart/ChartLegend.js";import{ChartPatternDefs as ze,patternFill as Ue}from"../chart/ChartPatterns.js";import{useChartSync as Ye}from"../chart/ChartSync.js";import{ChartTableView as Fe}from"../chart/ChartTableView.js";import{ChartTooltip as je,ChartTooltipContent as Ze}from"../chart/ChartTooltip.js";import{getSeriesLabel as Be,resolveSeriesColor as qe,toLegendItems as Je}from"../chart/palette.js";import{buildCartesianGeometry as Qe,createCategoryLocator as et,createPlotContext as tt,splitOverlay as nt}from"../chart/utils/cartesian.js";import{collectAllValues as rt,readNumber as ot}from"../chart/utils/data.js";import{decimateIndices as at,warnPointBudget as lt}from"../chart/utils/decimate.js";import{formatAuto as Re,formatPercent as st,formatXValue as it}from"../chart/utils/format.js";import{chartCursorTarget as ut,pressChartMark as ct}from"../chart/utils/keyboard.js";import{buildAreaPath as we,buildLinePath as Te,isolatedPoints as ht}from"../chart/utils/path.js";import{nearestIndex as mt,toKey as Ve}from"../chart/utils/scales.js";import{stackExtent as dt,stackSeries as gt}from"../chart/utils/stack.js";import{extent as ft}from"../chart/utils/ticks.js";import{formatTimeValue as pt}from"../chart/utils/timestamp.js";import{CHART_TOUCH as Ct}from"../chart/utils/touch.js";import{Fragment as Pt,jsx as a,jsxs as M}from"react/jsx-runtime";var bt=.12,yt=.9,vt=10,kt=He(function({bands:f,stacked:r,patterns:m,patternBaseId:b}){return a("g",{children:f.map(s=>M("g",{children:[a("path",{d:s.area,fill:Ue(m,b,s.slot,s.color),fillOpacity:r?yt:bt,stroke:"none"}),s.gap?a("path",{d:s.gap,fill:"none",strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,a("path",{d:s.edge,fill:"none",stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),s.isolated.map((d,E)=>a("circle",{cx:d.x,cy:d.y,r:3,fill:s.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},E))]},s.key))})});function xt({width:g,height:f,data:r,resolvedSeries:m,x:b,y:s,grid:d,size:E,curve:p,stack:P,baseline:L,connectNulls:S,referenceLines:$,annotations:A,annotationsLabel:me,patterns:Q,patternBaseId:ee,overlay:de,maxPoints:y,brush:te,onBrush:ne,brushLabel:ge,syncEnabled:O,margin:re,tooltip:B,onPointClick:R,plotLabel:fe,formatValue:v,formatRaw:X,formatX:I}){let[G,_]=xe(null),l=G!==null&&G<r.length?G:null,[pe,Ce]=xe(null),be=Ye(),i=O?be:null,t=K(()=>{let e=m.filter(T=>!T.hidden),n=e.map(T=>T.key),o=P!=="none",c=gt(r,n,P),se=o?dt(c):ft([...rt(r,n),L]),h=Qe({width:g,height:f,data:r,x:b,y:s,bounds:se,margin:re,placement:"point",formatValue:v,formatX:I,defaultIncludeZero:!0}),ve=h.categoryCenters,ie=h.valueScale,Ee=ie(o?0:L),Ie=e.map((T,ke)=>{let Z=r.map((q,J)=>{let V=c[J].segments[ke];return{x:ve[J],y:V.value===null?Number.NaN:ie(V.end),defined:V.value!==null}}),Pe=r.map((q,J)=>{let V=c[J].segments[ke];return{x:ve[J],y:V.value===null?Number.NaN:ie(o?V.start:L),defined:V.value!==null}}),ue={connectNulls:S},ce=y&&y>0&&Z.length>y?at(Z,y):null,he=ce?ce.map(q=>Z[q]):Z,Le=ce?ce.map(q=>Pe[q]):Pe;return y||lt("AreaChart",Z.length),{key:T.key,color:T.color,slot:T.slot,area:o?we(he,Le,p,ue):we(he,Ee,p,ue),edge:Te(he,p,ue),gap:o&&ke>0?Te(Le,p,ue):"",isolated:ht(he,S)}});return{visible:e,locate:et(h),plot:tt({geometry:h,width:g,height:f,data:r,series:e,formatValue:v,formatX:I}),rows:c,stacked:o,xValues:h.xValues,positions:ve,xTicks:h.categoryTicks,yTicks:h.valueTicks,valueScale:ie,innerWidth:h.innerWidth,innerHeight:h.innerHeight,margin:h.margin,bands:Ie}},[r,m,b,s,g,f,re,p,P,L,S,y,v,I]),z=x(e=>t.visible.map((n,o)=>{let c=ot(r[e],n.key),se=t.rows[e].segments[o],h=c===null?"\u2014":P==="percent"?`${X(c)} (${v(se.end-se.start)})`:v(c);return{seriesKey:n.key,seriesLabel:Be(n),color:n.color,value:c,formattedValue:h,datum:r[e]}}),[r,t.visible,t.rows,P,v,X]),oe=i?i.brush:pe,C=x(e=>{Ce(e),i?.setBrush(e),ne?.(e)},[i,ne]),u=Oe({enabled:te,active:oe!==null,centers:t.positions,xValues:t.xValues,offset:t.margin.left,orientation:"vertical",onCommit:C}),ae=x(e=>{if(u.onPointerMove(e),B===!1||r.length===0)return;let n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-t.margin.left,c=mt(t.positions,o);_(c>=0?c:null),i?.setHovered(c>=0?t.xValues[c]:null)},[u,B,r.length,t.margin.left,t.positions,t.xValues,i]),le=x(()=>{_(null),i?.setHovered(null)},[i]),H=x(()=>{if(!R||l===null)return;let[e]=z(l);e&&R({...e,index:l,x:t.xValues[l]})},[R,l,z,t.xValues]),N=x(e=>{if(r.length===0)return;let n=R&&l!==null&&t.visible.length>0;if(ct(e,n?H:null))return;u.onKeyDown(e,l);let o=ut(e.key,l,r.length,"x");o!==void 0&&(e.preventDefault(),_(o),i?.setHovered(o===null?null:t.xValues[o]))},[r.length,l,u,i,t.xValues,t.visible.length,R,H]),W=x(()=>{u.consumedClick()||H()},[u,H]),ye=l!==null||!i?.hovered?null:(()=>{let e=Ve(i.hovered),n=t.xValues.findIndex(o=>Ve(o)===e);return n<0?null:n})(),k=l??ye,U=l===null?null:z(l),D=k===null?[]:t.visible.map((e,n)=>{let o=t.rows[k].segments[n];return o.value===null?null:{key:e.key,color:e.color,y:t.valueScale(o.end)}}).filter(e=>e!==null),Y=u.dragging??oe,F=(()=>{if(!Y)return null;let e=t.locate(Y.from),n=t.locate(Y.to);return e===null||n===null?null:{from:e,to:n}})(),j=nt(de),w=l===null||U===null?null:{x:t.xValues[l],xLabel:I(t.xValues[l],l),index:l,points:U};return M(Pt,{children:[M("svg",{width:g,height:f,role:"img","aria-label":fe??[t.visible.map(e=>Be(e)).join(", "),Me(A,me)].filter(Boolean).join(". "),tabIndex:0,className:We(Ct,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",te&&"select-none"),onPointerDown:u.onPointerDown,onPointerMove:ae,onPointerUp:u.onPointerUp,onPointerCancel:u.onPointerUp,onPointerLeave:le,onKeyDown:N,onBlur:le,onClick:W,children:[Q?a(ze,{id:ee,entries:m.map(e=>({slot:e.slot,color:e.color}))}):null,M("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[a(Ge,{width:t.innerWidth,height:t.innerHeight,horizontal:d==="y"||d==="both"?t.yTicks.map(e=>e.offset):void 0,vertical:d==="x"||d==="both"?t.xTicks.map(e=>e.offset):void 0}),A?a(Se,{layer:"under",annotations:A,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,F?a($e,{from:F.from,to:F.to,width:t.innerWidth,height:t.innerHeight,live:u.dragging!==null,label:ge}):null,j.under?.(t.plot),a(kt,{bands:t.bands,stacked:t.stacked,patterns:Q&&t.stacked,patternBaseId:ee}),A?a(Se,{annotations:A,xAt:t.locate,yAt:t.valueScale,width:t.innerWidth,height:t.innerHeight}):null,$?.map(e=>{let n=t.valueScale(e.value),o=n<vt?n+12:n-4;return M("g",{children:[a("line",{x1:0,y1:n,x2:t.innerWidth,y2:n,stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?a("text",{x:t.innerWidth,y:o,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)}),j.over?.(t.plot),k!==null?M("g",{"aria-hidden":"true",children:[a("line",{x1:t.positions[k],y1:0,x2:t.positions[k],y2:t.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:l===null?"3 3":void 0}),D.map(e=>a("circle",{cx:t.positions[k],cy:e.y,r:4,fill:e.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},e.key))]}):null]}),a("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:b.hidden?null:a(Ae,{orientation:"bottom",ticks:t.xTicks,length:t.innerWidth,label:b.label,size:E})}),a("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:s?.hidden?null:a(Ae,{orientation:"left",ticks:t.yTicks,length:t.innerHeight,showLine:!1,label:s?.label,size:E})})]}),w&&B!==!1?a(je,{x:t.margin.left+t.positions[w.index],y:t.margin.top+(D.length>0?Math.min(...D.map(e=>e.y)):t.innerHeight/2),containerWidth:g,children:typeof B=="function"?B(w):a(Ze,{title:w.xLabel,points:w.points})}):null]})}function jt({data:g,series:f,x:r,y:m,height:b=240,width:s,size:d="md",grid:E="y",legend:p,tooltip:P=!0,tableView:L=!1,emphasis:S,title:$,description:A,loading:me=!1,emptyState:Q,error:ee=!1,errorState:de,onRetry:y,actions:te,onPointClick:ne,curve:ge="monotone",stack:O="none",baseline:re=0,connectNulls:B=!1,referenceLines:R,annotations:fe,overlay:v,patterns:X=!1,legendToggle:I=!0,maxPoints:G,brush:_=!1,onBrush:l,brushLabel:pe,sync:Ce=!0,margin:be,locale:i,plotLabel:t,className:z,...oe}){let C=Ke(i),u=De(),[ae,le]=xe(()=>new Set),H=Ne(),N=K(()=>f.map((e,n)=>({...e,slot:n,hidden:e.hidden||ae.has(e.key),color:qe(e,n,S)})),[f,ae,S]),W=O==="percent",ye=K(()=>W?{domain:[0,100],...m}:m,[W,m]),k=K(()=>m?.format??(W?e=>st(e,{locale:C,alreadyScaled:!0,maximumFractionDigits:0}):e=>Re(e,C)),[m?.format,W,C]),U=K(()=>e=>Re(e,C),[C]),D=K(()=>r.format??(e=>r.scale==="time"?pt(e,C):it(e,C)),[r.format,r.scale,C]),Y=x(e=>{le(n=>{let o=new Set(n);return o.has(e)?o.delete(e):o.add(e),o})},[]),F=p===void 0?f.length>=2:p!==!1,j=typeof p=="string"?p:"bottom",w=N.filter(e=>!e.hidden).length;return a(Xe,{title:$,description:A,height:b,width:s,size:d,loading:me,empty:g.length===0||w===0,emptyState:Q,error:ee,errorState:de,onRetry:y,actions:te,tableView:L,legendPosition:j,legend:F?a(_e,{items:Je(N,S,X&&O!=="none"),position:j,marker:"rect",size:d,onToggle:I?Y:void 0}):void 0,table:L?a(Fe,{data:g,series:N,xKey:r.key,xLabel:r.label??r.key,formatX:D,formatValue:U,caption:typeof $=="string"?$:void 0}):void 0,className:z,...oe,children:({width:e})=>a(xt,{width:e,height:b,data:g,resolvedSeries:N,x:r,y:ye,grid:E,size:d,curve:ge,stack:O,baseline:re,connectNulls:B,referenceLines:R,annotations:fe,annotationsLabel:u.chartAnnotations,patterns:X,patternBaseId:H,overlay:v,maxPoints:G,brush:_,onBrush:l,brushLabel:pe??u.chartBrush,syncEnabled:Ce,margin:be,tooltip:P,onPointClick:ne,plotLabel:t,formatValue:k,formatRaw:U,formatX:D})})}export{jt as AreaChart};
|
|
1
|
+
"use client";import{memo as De,useCallback as E,useId as Ke,useMemo as z,useState as Ae}from"react";import{cn as _e}from"../../lib/cn.js";import{useUILabels as Oe,useUILocale as Ge}from"../../lib/i18n.js";import{ChartAnnotationLayer as we,describeAnnotations as Xe}from"../chart/ChartAnnotations.js";import{ChartAxis as Be}from"../chart/ChartAxis.js";import{ChartBrushLayer as $e,locateBrush as Ue,useChartBrush as ze}from"../chart/ChartBrush.js";import{ChartContainer as Ye}from"../chart/ChartContainer.js";import{ChartGrid as Fe}from"../chart/ChartGrid.js";import{ChartLegend as je}from"../chart/ChartLegend.js";import{ChartPatternDefs as Ze,patternFill as qe}from"../chart/ChartPatterns.js";import{useChartSync as Je}from"../chart/ChartSync.js";import{ChartTableView as Qe}from"../chart/ChartTableView.js";import{ChartTooltip as et,ChartTooltipContent as tt}from"../chart/ChartTooltip.js";import{CHART_SURFACE_COLOR as Le,getSeriesLabel as Ve,resolveSeriesColor as nt,toLegendItems as ot}from"../chart/palette.js";import{annotationValues as rt,buildCartesianGeometry as at,createCategoryLocator as st,createPlotContext as lt,createSpanLocator as it,plotPointer as ut,splitOverlay as ct,widenBounds as ht}from"../chart/utils/cartesian.js";import{collectAllValues as mt,readNumber as dt}from"../chart/utils/data.js";import{decimateIndices as Ee,warnPointBudget as pt}from"../chart/utils/decimate.js";import{formatAuto as ft,formatExact as gt,formatPercent as bt,formatXValue as yt}from"../chart/utils/format.js";import{chartCursorTarget as Ct,pressChartMark as vt}from"../chart/utils/keyboard.js";import{buildAreaPath as Te,buildLinePath as He,isolatedPoints as kt}from"../chart/utils/path.js";import{nearestIndex as Ie,toKey as We}from"../chart/utils/scales.js";import{stackExtent as xt,stackSeries as St}from"../chart/utils/stack.js";import{extent as Pt}from"../chart/utils/ticks.js";import{formatTimeValue as At}from"../chart/utils/timestamp.js";import{CHART_TOUCH as Lt}from"../chart/utils/touch.js";import{Fragment as Ht,jsx as s,jsxs as Y}from"react/jsx-runtime";var Rt=6,wt=.12,Bt=.9,Vt=10,Et=De(function({bands:k,stacked:o,patterns:p,patternBaseId:x}){return s("g",{children:k.map(u=>Y("g",{children:[s("path",{d:u.area,fill:qe(p,x,u.slot,u.color),fillOpacity:o?Bt:wt,stroke:"none"}),u.gap?s("path",{d:u.gap,fill:"none",strokeWidth:2,stroke:Le}):null,s("path",{d:u.edge,fill:"none",stroke:u.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),u.isolated.map((v,_)=>s("circle",{cx:v.x,cy:v.y,r:3,fill:u.color,strokeWidth:2,stroke:Le},_))]},u.key))})});function Tt({width:C,height:k,data:o,resolvedSeries:p,x,y:u,grid:v,size:_,curve:S,stack:T,baseline:H,connectNulls:I,referenceLines:W,annotations:A,annotationsLabel:de,patterns:te,patternBaseId:ne,overlay:pe,maxPoints:L,brush:oe,onBrush:re,brushLabel:fe,syncEnabled:F,margin:ae,tooltip:M,onPointClick:R,plotLabel:ge,formatValue:N,formatRaw:O,formatX:G,locale:se}){let[j,Z]=Ae(null),i=j!==null&&j<o.length?j:null,[be,ye]=Ae(null),Ce=Je(),h=F?Ce:null,e=z(()=>{let t=p.filter(b=>!b.hidden),n=t.map(b=>b.key),a=T!=="none",l=St(o,n,T),D=ht(a?xt(l):Pt([...mt(o,n),H]),rt(o,x.key,W,A)),c=at({locale:se,width:C,height:k,data:o,x,y:u,bounds:D,margin:ae,placement:"point",formatValue:N,formatX:G,defaultIncludeZero:!0}),$=c.categoryCenters,m=c.valueScale,g=m(a?0:H),ee=t.map((b,K)=>({top:o.map((U,V)=>{let y=l[V].segments[K];return{x:$[V],y:y.value===null?Number.NaN:m(y.end),defined:y.value!==null}}),bottom:o.map((U,V)=>{let y=l[V].segments[K];return{x:$[V],y:y.value===null?Number.NaN:m(a?y.start:H),defined:y.value!==null}})})),Se=L!==void 0&&L>0&&o.length>L,Me=Se&&a?[...new Set(ee.flatMap(({top:b})=>Ee(b,L)))].sort((b,K)=>b-K):null,Ne=t.map((b,K)=>{let{top:U,bottom:V}=ee[K],y={connectNulls:I},he=Me??(Se?Ee(U,L):null),me=he?he.map(Pe=>U[Pe]):U,Re=he?he.map(Pe=>V[Pe]):V;return L||pt("AreaChart",U.length),{key:b.key,color:b.color,slot:b.slot,area:a?Te(me,Re,S,y):Te(me,g,S,y),edge:He(me,S,y),gap:a&&K>0?He(Re,S,y):"",isolated:kt(me,I)}});return{visible:t,locate:st(c),span:it(c),plot:lt({geometry:c,width:C,height:k,data:o,series:t,formatValue:N,formatX:G}),rows:l,stacked:a,xValues:c.xValues,positions:$,xTicks:c.categoryTicks,yTicks:c.valueTicks,valueScale:m,innerWidth:c.innerWidth,innerHeight:c.innerHeight,margin:c.margin,bands:Ne}},[se,o,p,x,u,C,k,ae,S,T,H,I,L,W,A,N,G]),q=E(t=>e.visible.map((n,a)=>{let l=dt(o[t],n.key),D=e.rows[t].segments[a],c=l===null?"\u2014":T==="percent"?`${O(l)} (${N(D.end-D.start)})`:O(l);return{seriesKey:n.key,seriesLabel:Ve(n),color:n.color,value:l,formattedValue:c,datum:o[t]}}),[o,e.visible,e.rows,T,N,O]),f=h?h.brush:be,le=E(t=>{ye(t),h?.setBrush(t),re?.(t)},[h,re]),d=ze({enabled:oe,active:f!==null,centers:e.positions,xValues:e.xValues,offset:e.margin.left,orientation:"vertical",onCommit:le}),ve=E(t=>{if(d.onPointerMove(t),M===!1||o.length===0)return;let n=t.currentTarget.getBoundingClientRect(),a=t.clientX-n.left-e.margin.left,l=Ie(e.positions,a);Z(l>=0?l:null),h?.setHovered(l>=0?e.xValues[l]:null)},[d,M,o.length,e.margin.left,e.positions,e.xValues,h]),ie=E(()=>{Z(null),h?.setHovered(null)},[h]),P=E((t,n)=>{if(!R)return;let a=q(t),l=e.rows[t]?.segments??[],D=a.map((m,g)=>({point:m,segment:l[g]})).filter(({point:m,segment:g})=>m.value!==null&&g!==void 0),c=({segment:m})=>{if(n===null)return 0;let g=e.valueScale(m.end),ee=e.valueScale(e.stacked?m.start:m.end);return e.stacked&&n.y>=Math.min(g,ee)&&n.y<=Math.max(g,ee)?-1:Math.abs(g-n.y)},$=D.length>0?D.reduce((m,g)=>c(g)<c(m)?g:m).point:a[0];$&&R({...$,index:t,x:e.xValues[t]})},[R,q,e.rows,e.stacked,e.valueScale,e.xValues]),B=E(t=>{if(o.length===0)return;let n=R&&i!==null&&e.visible.length>0;if(vt(t,n?()=>P(i,null):null))return;let a=d.onKeyDown(t,i),l=Ct(t.key,i,o.length,"x");if(l===void 0){a&&t.preventDefault();return}t.preventDefault(),Z(l),h?.setHovered(l===null?null:e.xValues[l])},[o.length,i,d,h,e.xValues,e.visible.length,R,P]),ke=E(t=>{if(d.consumedClick()||!R||o.length===0)return;let n=ut(t,e),a=i??(n===null?-1:Ie(e.positions,n.x));a<0||P(a,n)},[d,R,o.length,e,i,P]),xe=i!==null||h===null||h.hovered===null?null:(()=>{let t=We(h.hovered),n=e.xValues.findIndex(a=>We(a)===t);return n<0?null:n})(),w=i??xe,J=i===null?null:q(i),Q=w===null?[]:e.visible.map((t,n)=>{let a=e.rows[w].segments[n];return a.value===null?null:{key:t.key,color:t.color,y:e.valueScale(a.end)}}).filter(t=>t!==null),ue=d.dragging??f,X=ue?Ue(ue,e.xValues,e.positions,e.locate):null,ce=ct(pe),r=i===null||J===null?null:{x:e.xValues[i],xLabel:G(e.xValues[i],i),index:i,points:J};return Y(Ht,{children:[Y("svg",{width:C,height:k,role:"img","aria-label":ge??[e.visible.map(t=>Ve(t)).join(", "),Xe(A,de)].filter(Boolean).join(". "),tabIndex:0,className:_e(Lt,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",oe&&"select-none"),onPointerDown:d.onPointerDown,onPointerMove:ve,onPointerUp:d.onPointerUp,onPointerCancel:d.onPointerUp,onPointerLeave:ie,onKeyDown:B,onBlur:ie,onClick:ke,children:[te?s(Ze,{id:ne,entries:p.map(t=>({slot:t.slot,color:t.color}))}):null,Y("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[s(Fe,{width:e.innerWidth,height:e.innerHeight,horizontal:v==="y"||v==="both"?e.yTicks.map(t=>t.offset):void 0,vertical:v==="x"||v==="both"?e.xTicks.map(t=>t.offset):void 0}),A?s(we,{layer:"under",annotations:A,xAt:e.locate,spanAt:e.span,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,X?s($e,{from:X.from,to:X.to,width:e.innerWidth,height:e.innerHeight,live:d.dragging!==null,label:fe,minSpan:Rt}):null,ce.under?.(e.plot),s(Et,{bands:e.bands,stacked:e.stacked,patterns:te&&e.stacked,patternBaseId:ne}),A?s(we,{annotations:A,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight}):null,W?.map(t=>{let n=e.valueScale(t.value),a=n<Vt?n+12:n-4;return Y("g",{children:[s("line",{x1:0,y1:n,x2:e.innerWidth,y2:n,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?s("text",{x:e.innerWidth,y:a,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)}),ce.over?.(e.plot),w!==null?Y("g",{"aria-hidden":"true",children:[s("line",{x1:e.positions[w],y1:0,x2:e.positions[w],y2:e.innerHeight,className:"stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,strokeDasharray:i===null?"3 3":void 0}),Q.map(t=>s("circle",{cx:e.positions[w],cy:t.y,r:4,fill:t.color,strokeWidth:2,stroke:Le},t.key))]}):null]}),s("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:x.hidden?null:s(Be,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:x.label,size:_})}),s("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:u?.hidden?null:s(Be,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:u?.label,size:_})})]}),r&&M!==!1?s(et,{x:e.margin.left+e.positions[r.index],y:e.margin.top+(Q.length>0?Math.min(...Q.map(t=>t.y)):e.innerHeight/2),containerWidth:C,children:typeof M=="function"?M(r):s(tt,{title:r.xLabel,points:r.points})}):null]})}function an({data:C,series:k,x:o,y:p,height:x=240,width:u,size:v="md",grid:_="y",legend:S,tooltip:T=!0,tableView:H=!1,emphasis:I,title:W,description:A,loading:de=!1,emptyState:te,error:ne=!1,errorState:pe,onRetry:L,actions:oe,onPointClick:re,curve:fe="monotone",stack:F="none",baseline:ae=0,connectNulls:M=!1,referenceLines:R,annotations:ge,overlay:N,patterns:O=!1,legendToggle:G=!0,maxPoints:se,brush:j=!1,onBrush:Z,brushLabel:i,sync:be=!0,margin:ye,locale:Ce,plotLabel:h,className:e,...q}){let f=Ge(Ce),le=Oe(),[d,ve]=Ae(()=>new Set),ie=Ke(),P=z(()=>k.map((r,t)=>({...r,slot:t,hidden:r.hidden||d.has(r.key),color:nt(r,t,I)})),[k,d,I]),B=F==="percent",ke=z(()=>B?{domain:[0,100],...p}:p,[B,p]),xe=z(()=>p?.format??(B?r=>bt(r,{locale:f,alreadyScaled:!0,maximumFractionDigits:0}):r=>ft(r,f)),[p?.format,B,f]),w=z(()=>!B&&p?.format||(r=>gt(r,f)),[B,p?.format,f]),J=z(()=>o.format??(r=>o.scale==="time"?At(r,f):yt(r,f)),[o.format,o.scale,f]),Q=E(r=>{ve(t=>{let n=new Set(t);return n.has(r)?n.delete(r):n.add(r),n})},[]),ue=S===void 0?k.length>=2:S!==!1,X=typeof S=="string"?S:"bottom",ce=P.filter(r=>!r.hidden).length;return s(Ye,{title:W,description:A,height:x,width:u,size:v,loading:de,empty:C.length===0||ce===0,emptyState:te,error:ne,errorState:pe,onRetry:L,actions:oe,exportSource:{data:C,series:P,xKey:o.key,xLabel:o.label??o.key,formatX:o.format},tableView:H,legendPosition:X,legend:ue?s(je,{items:ot(P,I,O&&F!=="none"),position:X,marker:"rect",size:v,onToggle:G?Q:void 0}):void 0,table:H?s(Qe,{data:C,series:P,xKey:o.key,xLabel:o.label??o.key,formatX:J,formatValue:w,caption:typeof W=="string"?W:void 0}):void 0,className:e,...q,children:({width:r})=>s(Tt,{locale:f,width:r,height:x,data:C,resolvedSeries:P,x:o,y:ke,grid:_,size:v,curve:fe,stack:F,baseline:ae,connectNulls:M,referenceLines:R,annotations:ge,annotationsLabel:le.chartAnnotations,patterns:O,patternBaseId:ie,overlay:N,maxPoints:se,brush:j,onBrush:Z,brushLabel:i??le.chartBrush,syncEnabled:be,margin:ye,tooltip:T,onPointClick:re,plotLabel:h,formatValue:xe,formatRaw:w,formatX:J})})}export{an as AreaChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var a in e)s(r,a,{get:e[a],enumerable:!0})},v=(r,e,a,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of f(e))!u.call(r,t)&&t!==a&&s(r,t,{get:()=>e[t],enumerable:!(o=c(e,t))||o.enumerable});return r};var h=r=>v(s({},"__esModule",{value:!0}),r);var A={};x(A,{Avatar:()=>y});module.exports=h(A);var i=require("../../lib/cn.cjs"),d=require("../../lib/server-labels.cjs"),l=require("./AvatarImage.cjs"),n=require("react/jsx-runtime"),b={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},w={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function y({src:r,alt:e=d.serverUILabels.avatarAlt,fallback:a,size:o="md",variant:t="circle",border:m=!1,className:g,...p}){return(0,n.jsxs)("div",{className:(0,i.cn)("relative inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",b[o],w[t],m&&"ring-2 ring-white dark:ring-gray-900",g),...p,children:[(0,n.jsx)("span",{"aria-hidden":r?!0:void 0,children:a||e.charAt(0).toUpperCase()}),r?(0,n.jsx)(l.AvatarImage,{src:r,alt:e}):null]})}0&&(module.exports={Avatar});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as
|
|
1
|
+
import{cn as l}from"../../lib/cn.js";import{serverUILabels as m}from"../../lib/server-labels.js";import{AvatarImage as g}from"./AvatarImage.js";import{jsx as t,jsxs as f}from"react/jsx-runtime";var p={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},c={circle:"rounded-full",square:"rounded-none",rounded:"rounded-md"};function h({src:e,alt:r=m.avatarAlt,fallback:a,size:n="md",variant:o="circle",border:s=!1,className:i,...d}){return f("div",{className:l("relative inline-flex items-center justify-center overflow-hidden bg-gray-200 font-medium text-gray-600 dark:bg-gray-700 dark:text-gray-300",p[n],c[o],s&&"ring-2 ring-white dark:ring-gray-900",i),...d,children:[t("span",{"aria-hidden":e?!0:void 0,children:a||r.charAt(0).toUpperCase()}),e?t(g,{src:e,alt:r}):null]})}export{h as Avatar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var u=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of c(t))!f.call(e,l)&&l!==n&&u(e,l,{get:()=>t[l],enumerable:!(s=o(t,l))||s.enumerable});return e};var p=e=>g(u({},"__esModule",{value:!0}),e);var d={};m(d,{AvatarImage:()=>b});module.exports=p(d);var r=require("react"),i=require("react/jsx-runtime");function b({src:e,alt:t}){let[n,s]=(0,r.useState)(null),l=(0,r.useRef)(null);return(0,r.useEffect)(()=>{let a=l.current;a&&a.complete&&a.naturalWidth===0&&a.getAttribute("src")&&s(e)},[e]),n===e?(0,i.jsx)("span",{className:"sr-only",children:t}):(0,i.jsx)("img",{ref:l,src:e,alt:t,onError:()=>s(e),className:"absolute inset-0 h-full w-full object-cover"})}0&&(module.exports={AvatarImage});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useEffect as u,useRef as i,useState as o}from"react";import{jsx as s}from"react/jsx-runtime";function f({src:e,alt:l}){let[a,n]=o(null),r=i(null);return u(()=>{let t=r.current;t&&t.complete&&t.naturalWidth===0&&t.getAttribute("src")&&n(e)},[e]),a===e?s("span",{className:"sr-only",children:l}):s("img",{ref:r,src:e,alt:l,onError:()=>n(e),className:"absolute inset-0 h-full w-full object-cover"})}export{f as AvatarImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var w=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var W=(t,n)=>{for(var r in n)w(t,r,{get:n[r],enumerable:!0})},H=(t,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of I(n))!P.call(t,o)&&o!==r&&w(t,o,{get:()=>n[o],enumerable:!(s=R(n,o))||s.enumerable});return t};var T=t=>H(w({},"__esModule",{value:!0}),t);var E={};W(E,{Banner:()=>M});module.exports=T(E);var B=require("react"),a=require("../../lib/cn.cjs"),L=require("../../lib/css-value.cjs"),x=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function y({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function j({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function V({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function O({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Z={info:y,success:j,warning:V,error:O,default:y},z={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},S={info:"text-blue-600 dark:text-blue-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function k(...t){return t.map(n=>typeof n=="string"||typeof n=="number"?String(n):"").join("\0")}function C(t,n){let[r,s]=(0,B.useState)(null);return{visible:r!==t,close:()=>{s(t),n?.()}}}function F({type:t="default",title:n,description:r,children:s,icon:o,action:i,closable:c=!1,closeLabel:d,onClose:u,fullWidth:g=!1,className:m,...f}){let{visible:b,close:v}=C(k(t,n,r,s),u),l=(0,x.useUILabels)();if(!b)return null;let p=Z[t],N=s??r;return(0,e.jsxs)("div",{role:"alert",className:(0,a.cn)("flex items-start gap-3 border px-4 py-3",g?"w-full":"rounded-lg",z[t],m),...f,children:[(0,e.jsx)("div",{className:(0,a.cn)("shrink-0 mt-0.5",S[t]),children:o??(0,e.jsx)(p,{className:"w-5 h-5"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[n&&(0,e.jsx)("div",{className:"font-semibold text-sm",children:n}),N&&(0,e.jsx)("div",{className:(0,a.cn)("text-sm",n?"mt-1 opacity-90":!1),children:N}),i&&(0,e.jsx)("div",{className:"mt-3",children:i})]}),c&&(0,e.jsx)("button",{type:"button",onClick:v,className:(0,a.cn)("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":d??l.bannerClose,children:(0,e.jsx)(h,{className:"w-4 h-4"})})]})}function U({title:t,description:n,children:r,action:s,backgroundImage:o,closable:i=!1,closeLabel:c,onClose:d,fullWidth:u=!1,className:g,...m}){let{visible:f,close:b}=C(k(t,n,r,o),d),v=(0,x.useUILabels)();if(!f)return null;let l=r??n;return(0,e.jsxs)("div",{className:(0,a.cn)("relative overflow-hidden bg-gray-900 text-white",u?"w-full":"rounded-xl","py-12 px-6 sm:px-12",g),style:o?{backgroundImage:(0,L.cssUrl)(o),backgroundSize:"cover",backgroundPosition:"center"}:void 0,...m,children:[o&&(0,e.jsx)("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&(0,e.jsx)("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),l&&(0,e.jsx)("div",{className:(0,a.cn)("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:l}),s&&(0,e.jsx)("div",{className:"mt-6",children:s})]}),i&&(0,e.jsx)("button",{type:"button",onClick:b,className:(0,a.cn)("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":c??v.bannerClose,children:(0,e.jsx)(h,{className:"w-5 h-5"})})]})}function D({title:t,description:n,children:r,icon:s,action:o,badge:i,closable:c=!1,closeLabel:d,onClose:u,fullWidth:g=!1,className:m,...f}){let{visible:b,close:v}=C(k(t,n,r,i),u),l=(0,x.useUILabels)();if(!b)return null;let p=r??n;return(0,e.jsxs)("div",{className:(0,a.cn)("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",g?"w-full":"rounded-lg",m),...f,children:[s&&(0,e.jsx)("div",{className:"shrink-0",children:s}),i&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:i}),(0,e.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&(0,e.jsx)("span",{className:"font-semibold text-sm",children:t}),p&&(0,e.jsx)("span",{className:"text-sm opacity-90",children:p})]}),o&&(0,e.jsx)("div",{className:"shrink-0",children:o}),c&&(0,e.jsx)("button",{type:"button",onClick:v,className:(0,a.cn)("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":d??l.bannerClose,children:(0,e.jsx)(h,{className:"w-4 h-4"})})]})}function M({variant:t="notification",...n}){switch(t){case"hero":return(0,e.jsx)(U,{...n});case"promotion":return(0,e.jsx)(D,{...n});default:return(0,e.jsx)(F,{...n})}}M.displayName="Banner";0&&(module.exports={Banner});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as B}from"react";import{cn as a}from"../../lib/cn.js";import{cssUrl as L}from"../../lib/css-value.js";import{useUILabels as w}from"../../lib/i18n.js";import{jsx as e,jsxs as c}from"react/jsx-runtime";function y({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function M({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function R({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function I({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h({className:t}){return e("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var P={info:y,success:M,warning:R,error:I,default:y},W={info:"bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800",success:"bg-green-50 text-green-800 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800",warning:"bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-300 dark:border-yellow-800",error:"bg-red-50 text-red-800 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800",default:"bg-gray-50 text-gray-800 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"},H={info:"text-blue-600 dark:text-blue-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",default:"text-gray-600 dark:text-gray-400"};function k(...t){return t.map(n=>typeof n=="string"||typeof n=="number"?String(n):"").join("\0")}function C(t,n){let[r,o]=B(null);return{visible:r!==t,close:()=>{o(t),n?.()}}}function T({type:t="default",title:n,description:r,children:o,icon:s,action:i,closable:d=!1,closeLabel:u,onClose:g,fullWidth:m=!1,className:f,...b}){let{visible:v,close:p}=C(k(t,n,r,o),g),l=w();if(!v)return null;let x=P[t],N=o??r;return c("div",{role:"alert",className:a("flex items-start gap-3 border px-4 py-3",m?"w-full":"rounded-lg",W[t],f),...b,children:[e("div",{className:a("shrink-0 mt-0.5",H[t]),children:s??e(x,{className:"w-5 h-5"})}),c("div",{className:"flex-1 min-w-0",children:[n&&e("div",{className:"font-semibold text-sm",children:n}),N&&e("div",{className:a("text-sm",n?"mt-1 opacity-90":!1),children:N}),i&&e("div",{className:"mt-3",children:i})]}),d&&e("button",{type:"button",onClick:p,className:a("shrink-0 rounded-md p-1 transition-colors","hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":u??l.bannerClose,children:e(h,{className:"w-4 h-4"})})]})}function j({title:t,description:n,children:r,action:o,backgroundImage:s,closable:i=!1,closeLabel:d,onClose:u,fullWidth:g=!1,className:m,...f}){let{visible:b,close:v}=C(k(t,n,r,s),u),p=w();if(!b)return null;let l=r??n;return c("div",{className:a("relative overflow-hidden bg-gray-900 text-white",g?"w-full":"rounded-xl","py-12 px-6 sm:px-12",m),style:s?{backgroundImage:L(s),backgroundSize:"cover",backgroundPosition:"center"}:void 0,...f,children:[s&&e("div",{className:"absolute inset-0 bg-black/50","aria-hidden":"true"}),c("div",{className:"relative z-10 max-w-3xl mx-auto text-center",children:[t&&e("h2",{className:"text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight",children:t}),l&&e("div",{className:a("text-base sm:text-lg opacity-90",t?"mt-4":!1),children:l}),o&&e("div",{className:"mt-6",children:o})]}),i&&e("button",{type:"button",onClick:v,className:a("absolute top-4 right-4 z-10 rounded-md p-1.5 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":d??p.bannerClose,children:e(h,{className:"w-5 h-5"})})]})}function V({title:t,description:n,children:r,icon:o,action:s,badge:i,closable:d=!1,closeLabel:u,onClose:g,fullWidth:m=!1,className:f,...b}){let{visible:v,close:p}=C(k(t,n,r,i),g),l=w();if(!v)return null;let x=r??n;return c("div",{className:a("relative flex items-center gap-4 bg-linear-to-r from-indigo-600 to-purple-600 text-white px-4 py-3",m?"w-full":"rounded-lg",f),...b,children:[o&&e("div",{className:"shrink-0",children:o}),i&&e("span",{className:"shrink-0 inline-flex items-center rounded-full bg-white/20 px-2.5 py-0.5 text-xs font-semibold uppercase tracking-wide",children:i}),c("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t&&e("span",{className:"font-semibold text-sm",children:t}),x&&e("span",{className:"text-sm opacity-90",children:x})]}),s&&e("div",{className:"shrink-0",children:s}),d&&e("button",{type:"button",onClick:p,className:a("shrink-0 rounded-md p-1 text-white/80 transition-colors","hover:text-white hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-white"),"aria-label":u??l.bannerClose,children:e(h,{className:"w-4 h-4"})})]})}function O({variant:t="notification",...n}){switch(t){case"hero":return e(j,{...n});case"promotion":return e(V,{...n});default:return e(T,{...n})}}O.displayName="Banner";export{O as Banner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var rt=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Ht=Object.prototype.hasOwnProperty;var Wt=(g,c)=>{for(var n in c)rt(g,n,{get:c[n],enumerable:!0})},Nt=(g,c,n,f)=>{if(c&&typeof c=="object"||typeof c=="function")for(let d of Dt(c))!Ht.call(g,d)&&d!==n&&rt(g,d,{get:()=>c[d],enumerable:!(f=It(c,d))||f.enumerable});return g};var Ot=g=>Nt(rt({},"__esModule",{value:!0}),g);var Yt={};Wt(Yt,{BarChart:()=>Ft,resetBarChartWarnings:()=>Ut});module.exports=Ot(Yt);var s=require("react"),pt=require("../../lib/cn.cjs"),Oe=require("../../lib/i18n.cjs"),ke=require("../chart/ChartAnnotations.cjs"),ot=require("../chart/ChartAxis.cjs"),_e=require("../chart/ChartBrush.cjs"),bt=require("../chart/ChartContainer.cjs"),yt=require("../chart/ChartGrid.cjs"),Ct=require("../chart/ChartLegend.cjs"),$e=require("../chart/ChartPatterns.cjs"),vt=require("../chart/ChartScaleLegend.cjs"),xt=require("../chart/ChartSync.cjs"),kt=require("../chart/ChartTableView.cjs"),Ke=require("../chart/ChartTooltip.cjs"),w=require("../chart/palette.cjs"),U=require("../chart/utils/cartesian.cjs"),I=require("../chart/utils/data.cjs"),me=require("../chart/utils/format.cjs"),Ue=require("../chart/utils/keyboard.cjs"),St=require("../chart/utils/bins.cjs"),Xe=require("../chart/utils/path.cjs"),Se=require("../chart/utils/scales.cjs"),fe=require("../chart/utils/stack.cjs"),Bt=require("../chart/utils/text.cjs"),Be=require("../chart/utils/ticks.cjs"),Ge=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),_t=24,re=2,$t=4,de=6,Kt=10,at=!1,lt=!1;function Ut(){at=!1,lt=!1}var Xt=(0,s.memo)(function({bars:c,patterns:n,patternBaseId:f}){return(0,r.jsx)("g",{children:c.map((d,A)=>(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:d.d,fill:(0,$e.patternFill)(n,f,d.slot,d.color)}),d.label?(0,r.jsx)("text",{x:d.label.x,y:d.label.y,textAnchor:d.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:d.label.text}):null]},`${d.key}-${A}`))})}),Gt=(0,s.memo)(function({lines:c}){return(0,r.jsx)("g",{children:c.map(n=>(0,r.jsxs)("g",{children:[(0,r.jsx)("path",{d:n.d,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:n.dashed?"5 4":void 0}),n.markers.map(f=>(0,r.jsx)("circle",{cx:f.x,cy:f.y,r:3,fill:n.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${f.x}-${f.y}`))]},n.key))})});function zt({width:g,height:c,data:n,resolvedSeries:f,x:d,y:A,grid:D,size:Pe,orientation:T,stack:N,center:E,centerKey:H,valueColors:X,binned:oe,curve:we,barSize:Le,showValues:Re,referenceLines:ze,annotations:G,annotationsLabel:Fe,patterns:Ae,patternBaseId:ae,overlay:Te,brush:L,onBrush:z,brushLabel:Ye,syncEnabled:Ze,margin:le,tooltip:F,onPointClick:Y,plotLabel:Ee,formatValue:O,formatRaw:Z,formatX:ie}){let[ge,pe]=(0,s.useState)(null),m=ge!==null&&ge<n.length?ge:null,[je,qe]=(0,s.useState)(null),Je=(0,xt.useChartSync)(),C=Ze?Je:null,e=(0,s.useMemo)(()=>{let t=T==="vertical",o=f.filter(p=>!p.hidden),a=o.filter(p=>p.type!=="line"),b=o.filter(p=>p.type==="line"),R=a.map(p=>p.key),y=H!==null||N!=="none",$=H!==null?(0,fe.stackDiverging)(n,R,{centerKey:H,percent:N==="percent"}):(0,fe.stackSeries)(n,R,N),i=y?(0,fe.stackExtent)($):(0,Be.extent)((0,I.collectAllValues)(n,R)),l=(0,Be.extent)((0,I.collectAllValues)(n,b.map(p=>p.key))),u=i===null?l:l===null?i:[Math.min(i[0],l[0]),Math.max(i[1],l[1])],h=(0,U.buildCartesianGeometry)({width:g,height:c,data:n,x:d,y:A,bounds:u===null?null:[Math.min(u[0],E),Math.max(u[1],E)],margin:le,orientation:T,placement:"band",bandPaddingInner:oe?0:void 0,formatValue:O,formatX:ie,defaultIncludeZero:E===0}),{valueScale:Q,bandwidth:Ce,categoryPositions:it,innerWidth:st,innerHeight:ct}=h,Pt=Q(E),De=Math.max(1,a.length),wt=y?Ce:Ce/De,K=Math.min(Le??(oe?Number.POSITIVE_INFINITY:_t),Math.max(1,wt-(y&&!oe?0:re))),Lt=y?K:De*K+(De-1)*re,ut=(Ce-Lt)/2,ht=[],dt=p=>y?p.end>=p.start:p.end>=E;$.forEach((p,He)=>{let ee=-1,We=-1;p.segments.forEach((P,ue)=>{P.value!==null&&P.outer!==!1&&(dt(P)?ee=ue:We=ue)});let ce=0,ve=0;p.segments.forEach((P,ue)=>{if(P.value===null)return;let et=a[ue],k=dt(P),mt=Q(y?P.start:E),ft=Q(P.end),te=Math.min(mt,ft),he=Math.abs(ft-mt),At=P.base??(k?ce===0:ve===0),Tt=t?!k:k;y&&!At&&he>re&&(he-=re,Tt&&(te+=re)),k?ce+=1:ve+=1;let Ne=it[He]+(y?ut:ut+ue*(K+re)),Et=ue===(k?ee:We)?t?k?"top":"bottom":k?"right":"left":"none",Vt=t?{x:Ne,y:te,width:K,height:he}:{x:te,y:Ne,width:he,height:K},tt=null;if(Re&&!y){let nt=Z(P.value),gt=(0,Bt.estimateTextWidth)(nt,10);if(t){let ne=k?te:te+he,xe=k?ne-de:ne+de,Mt=De>1?K+re:Ce;gt<=Mt&&(k?xe>8:xe<ct-4)&&(tt={x:Ne+K/2,y:xe,anchor:"middle",text:nt})}else{let ne=k?te+he:te,xe=k?st-ne-de:ne-de;gt<=xe&&(tt={x:k?ne+de:ne-de,y:Ne+K/2,anchor:k?"start":"end",text:nt})}}ht.push({key:et.key,slot:et.slot,color:X&&P.value!==null?X(P.value):et.color,d:(0,Xe.buildBarPath)({...Vt,radius:$t,round:Et}),label:tt})})});let Rt=b.map(p=>{let He=h.categoryCenters.map((ee,We)=>{let ce=(0,I.readNumber)(n[We],p.key),ve=ce===null?Number.NaN:Q(ce);return{x:t?ee:ve,y:t?ve:ee,defined:ce!==null}});return{key:p.key,color:p.color,dashed:p.dashed,d:(0,Xe.buildLinePath)(He,we),markers:He.filter(ee=>ee.defined!==!1)}});return{vertical:t,visible:o,locate:(0,U.createCategoryLocator)(h),barSeries:a,rows:$,stacked:y,plot:(0,U.createPlotContext)({geometry:h,width:g,height:c,data:n,series:o,formatValue:O,formatX:ie}),xValues:h.xValues,categoryPositions:it,categoryCenters:h.categoryCenters,bandwidth:Ce,categoryTicks:h.categoryTicks,valueTicks:h.valueTicks,valueScale:Q,baseline:Pt,innerWidth:st,innerHeight:ct,margin:h.margin,bars:ht,lines:Rt}},[n,f,d,A,g,c,le,T,N,E,H,X,oe,we,Le,Re,O,Z,ie]),be=(0,s.useCallback)(t=>e.visible.map(o=>{let a=(0,I.readNumber)(n[t],o.key),b=e.barSeries.indexOf(o),R=b===-1?null:e.rows[t].segments[b],y=a===null?"\u2014":N==="percent"&&R!==null?`${Z(a)} (${O(R.end-R.start)})`:O(a);return{seriesKey:o.key,seriesLabel:(0,w.getSeriesLabel)(o),color:o.color,value:a,formattedValue:y,datum:n[t]}}),[n,e.visible,e.barSeries,e.rows,N,O,Z]),V=C?C.brush:je,Ve=(0,s.useCallback)(t=>{qe(t),C?.setBrush(t),z?.(t)},[C,z]),v=(0,_e.useChartBrush)({enabled:L,active:V!==null,centers:e.categoryCenters,xValues:e.xValues,offset:e.vertical?e.margin.left:e.margin.top,orientation:T,onCommit:Ve}),Qe=(0,s.useCallback)(t=>{if(v.onPointerMove(t),F===!1||n.length===0)return;let o=t.currentTarget.getBoundingClientRect(),a=e.vertical?t.clientX-o.left-e.margin.left:t.clientY-o.top-e.margin.top,b=(0,Se.nearestIndex)(e.categoryCenters,a);pe(b>=0?b:null),C?.setHovered(b>=0?e.xValues[b]:null)},[v,F,n.length,e.vertical,e.margin,e.categoryCenters,e.xValues,C]),Me=(0,s.useCallback)(()=>{pe(null),C?.setHovered(null)},[C]),x=(0,s.useCallback)(()=>{if(!Y||m===null)return;let[t]=be(m);t&&Y({...t,index:m,x:e.xValues[m]})},[Y,m,be,e.xValues]),S=(0,s.useCallback)(t=>{if(n.length===0)return;let o=Y&&m!==null&&e.visible.length>0;if((0,Ue.pressChartMark)(t,o?x:null))return;v.onKeyDown(t,m);let a=(0,Ue.chartCursorTarget)(t.key,m,n.length,e.vertical?"x":"y");a!==void 0&&(t.preventDefault(),pe(a),C?.setHovered(a===null?null:e.xValues[a]))},[n.length,m,e.vertical,v,C,e.xValues,e.visible.length,Y,x]),j=(0,s.useCallback)(()=>{v.consumedClick()||x()},[v,x]),_=m!==null||!C?.hovered?null:(()=>{let t=(0,Se.toKey)(C.hovered),o=e.xValues.findIndex(a=>(0,Se.toKey)(a)===t);return o<0?null:o})(),M=m??_,B=v.dragging??V,W=(()=>{if(!B)return null;let t=e.locate(B.from),o=e.locate(B.to);if(t===null||o===null)return null;let a=e.bandwidth/2;return{from:Math.min(t,o)-a,to:Math.max(t,o)+a}})(),q=(0,U.splitOverlay)(Te),Ie=m===null?null:be(m),J=m===null||Ie===null?null:{x:e.xValues[m],xLabel:ie(e.xValues[m],m),index:m,points:Ie},ye=t=>{let o=e.rows[t].segments.filter(a=>a.value!==null).map(a=>e.valueScale(a.end));for(let a of e.lines){let b=(0,I.readNumber)(n[t],a.key);b!==null&&o.push(e.valueScale(b))}return o},se=m===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[m],y:e.margin.top+Math.min(...ye(m),e.baseline)}:{x:e.margin.left+Math.max(...ye(m),e.baseline),y:e.margin.top+e.categoryCenters[m]};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:g,height:c,role:"img","aria-label":Ee??[e.visible.map(t=>(0,w.getSeriesLabel)(t)).join(", "),(0,ke.describeAnnotations)(G,Fe)].filter(Boolean).join(". "),tabIndex:0,className:(0,pt.cn)(L&&!e.vertical?Ge.CHART_TOUCH_VERTICAL_DRAG:Ge.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",L&&"select-none"),onPointerDown:v.onPointerDown,onPointerMove:Qe,onPointerUp:v.onPointerUp,onPointerCancel:v.onPointerUp,onPointerLeave:Me,onKeyDown:S,onBlur:Me,onClick:j,children:[Ae?(0,r.jsx)($e.ChartPatternDefs,{id:ae,entries:f.map(t=>({slot:t.slot,color:t.color}))}):null,(0,r.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,r.jsx)(yt.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(D==="y"||D==="both")?e.valueTicks.map(t=>t.offset):void 0,vertical:!e.vertical&&(D==="y"||D==="both")?e.valueTicks.map(t=>t.offset):void 0}),G?(0,r.jsx)(ke.ChartAnnotationLayer,{layer:"under",annotations:G,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight,bandwidth:e.bandwidth}):null,W?(0,r.jsx)(_e.ChartBrushLayer,{from:W.from,to:W.to,width:e.innerWidth,height:e.innerHeight,orientation:T,live:v.dragging!==null,label:Ye}):null,M!==null?(0,r.jsx)("rect",{x:e.vertical?e.categoryPositions[M]:0,y:e.vertical?0:e.categoryPositions[M],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,q.under?.(e.plot),(0,r.jsx)(Xt,{bars:e.bars,patterns:Ae,patternBaseId:ae}),e.lines.length>0?(0,r.jsx)(Gt,{lines:e.lines}):null,(0,r.jsx)("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),G?(0,r.jsx)(ke.ChartAnnotationLayer,{annotations:G,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight,bandwidth:e.bandwidth}):null,q.over?.(e.plot),ze?.map(t=>{let o=e.valueScale(t.value),a=o<Kt?o+12:o-4;return(0,r.jsxs)("g",{children:[(0,r.jsx)("line",{x1:e.vertical?0:o,y1:e.vertical?o:0,x2:e.vertical?e.innerWidth:o,y2:e.vertical?o:e.innerHeight,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,r.jsx)("text",{x:e.vertical?e.innerWidth:o+4,y:e.vertical?a:8,textAnchor:e.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)})]}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?d.hidden:A?.hidden)?null:(0,r.jsx)(ot.ChartAxis,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?d.label:A?.label,size:Pe})}),(0,r.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?A?.hidden:d.hidden)?null:(0,r.jsx)(ot.ChartAxis,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?A?.label:d.label,size:Pe})})]}),J&&se&&F!==!1?(0,r.jsx)(Ke.ChartTooltip,{x:se.x,y:se.y,containerWidth:g,children:typeof F=="function"?F(J):(0,r.jsx)(Ke.ChartTooltipContent,{title:J.xLabel,points:J.points})}):null]})}function Ft({data:g,series:c,x:n,y:f,height:d=260,width:A,size:D="md",grid:Pe="y",legend:T,tooltip:N=!0,tableView:E=!1,emphasis:H,title:X,description:oe,loading:we=!1,emptyState:Le,error:Re=!1,errorState:ze,onRetry:G,actions:Fe,onPointClick:Ae,orientation:ae="vertical",stack:Te="none",diverging:L,bins:z,curve:Ye="linear",barSize:Ze,sort:le="none",showValues:F=!1,referenceLines:Y,annotations:Ee,overlay:O,patterns:Z=!1,legendToggle:ie=!0,brush:ge=!1,onBrush:pe,brushLabel:m,sync:je=!0,margin:qe,locale:Je,plotLabel:C,className:e,...be}){let V=(0,Oe.useUILocale)(Je),Ve=(0,Oe.useUILabels)(),[v,Qe]=(0,s.useState)(()=>new Set),Me=(0,s.useId)(),x=z!==void 0&&z!==!1,S=x||typeof L!="string"?null:L,j=!x&&typeof L=="number"?L:0,_=(0,s.useMemo)(()=>{let i=S===null?null:(0,w.createDivergingScale)([0,Math.max(1,c.length-1)],{center:Math.max(0,c.findIndex(l=>l.key===S)),symmetric:!1});return c.map((l,u)=>({...l,slot:u,hidden:l.hidden||v.has(l.key),color:i&&!l.color&&!H?l.key===S?w.CHART_MUTED_COLOR:i(u):(0,w.resolveSeriesColor)(l,u,H)}))},[c,v,H,S]),M=(0,s.useMemo)(()=>i=>(0,me.formatAuto)(i,V),[V]),B=(0,s.useMemo)(()=>{if(!x)return null;c.length>1&&!at&&(at=!0,console.warn("[@synertech/ui] BarChart was given `bins` and more than one series. A histogram counts a single field \u2014 the extra series are ignored. Facet the chart, or draw the distributions side by side."));let i=c[0]?.key??"count",l=n.format?h=>n.format(h,0):h=>M(h),u=(0,St.binValues)(g.map(h=>(0,I.readNumber)(h,n.key)),z);return{rows:u.map(h=>({[n.key]:h.from,[i]:h.count})),labels:u.map(h=>`${l(h.from)}\u2013${l(h.to)}`)}},[x,z,g,n.key,n.format,c,M]),W=(0,s.useMemo)(()=>{if(B)return B.rows;if(le==="none")return g;let i=_.filter(u=>!u.hidden).map(u=>u.key),l=u=>i.reduce((h,Q)=>h+((0,I.readNumber)(u,Q)??0),0);return[...g].sort((u,h)=>le==="asc"?l(u)-l(h):l(h)-l(u))},[B,g,le,_]),q=!x&&Te==="percent",Ie=(0,s.useMemo)(()=>q?{domain:S===null?[0,100]:[-100,100],...f}:f,[q,S,f]),J=(0,s.useMemo)(()=>{let i=f?.format??(q?l=>(0,me.formatPercent)(l,{locale:V,alreadyScaled:!0,maximumFractionDigits:0}):M);return S===null?i:l=>i(Math.abs(l))},[f?.format,q,V,M,S]),ye=(0,s.useMemo)(()=>B?(i,l)=>B.labels[l]??"":n.format??(i=>(0,me.formatXValue)(i,V)),[B,n.format,V]),se=(0,s.useMemo)(()=>B?{...n,scale:"category"}:n,[B,n]),t=(0,s.useCallback)(i=>{Qe(l=>{let u=new Set(l);return u.has(i)?u.delete(i):u.add(i),u})},[]),o=ae==="vertical"?Ee:void 0;Ee&&ae!=="vertical"&&!lt&&(lt=!0,console.warn("[@synertech/ui] BarChart was given `annotations` and a horizontal orientation. Annotations are read on the category axis, which runs up the side there: they are ignored. Use `referenceLines` for a threshold on the value axis."));let a=T===void 0?c.length>=2:T!==!1,b=typeof T=="string"?T:"bottom",R=_.filter(i=>!i.hidden),y=R.length,$=(0,s.useMemo)(()=>{if(x||L===void 0||L===!1||S!==null||y!==1)return null;let i=(0,I.collectAllValues)(W,R.map(u=>u.key)),l=(0,Be.resolveDomain)([...i,j],{domain:f?.domain,includeZero:f?.includeZero??j===0,ticks:f?.ticks??5});return(0,w.createDivergingScale)(l,{center:j})},[x,L,S,y,R,W,j,f]);return(0,r.jsx)(bt.ChartContainer,{title:X,description:oe,height:d,width:A,size:D,loading:we,empty:W.length===0||y===0,emptyState:Le,error:Re,errorState:ze,onRetry:G,actions:Fe,tableView:E,legendPosition:b,legend:$?(0,r.jsx)(vt.ChartScaleLegend,{scale:$,label:f?.label,format:J,size:D,locale:V}):a?(0,r.jsx)(Ct.ChartLegend,{items:(0,w.toLegendItems)(_,H,Z),position:b,marker:"rect",size:D,onToggle:ie?t:void 0}):void 0,table:E?(0,r.jsx)(kt.ChartTableView,{data:W,series:_,xKey:se.key,xLabel:n.label??n.key,formatX:ye,formatValue:M,caption:typeof X=="string"?X:void 0}):void 0,className:e,...be,children:({width:i})=>(0,r.jsx)(zt,{width:i,height:d,data:W,resolvedSeries:_,x:se,y:Ie,grid:Pe,size:D,orientation:ae,stack:x?"none":Te,center:j,centerKey:S,valueColors:$,binned:x,curve:Ye,barSize:Ze,showValues:F,referenceLines:Y,annotations:o,annotationsLabel:Ve.chartAnnotations,patterns:Z&&$===null,patternBaseId:Me,overlay:O,brush:ge,onBrush:pe,brushLabel:m??Ve.chartBrush,syncEnabled:je,margin:qe,tooltip:N,onPointClick:Ae,plotLabel:C,formatValue:J,formatRaw:M,formatX:ye})})}0&&(module.exports={BarChart,resetBarChartWarnings});
|
|
1
|
+
"use strict";"use client";var ut=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var zt=(d,l)=>{for(var n in l)ut(d,n,{get:l[n],enumerable:!0})},Ft=(d,l,n,i)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of Ut(l))!Xt.call(d,m)&&m!==n&&ut(d,m,{get:()=>l[m],enumerable:!(i=Gt(l,m))||i.enumerable});return d};var Yt=d=>Ft(ut({},"__esModule",{value:!0}),d);var rn={};zt(rn,{BarChart:()=>nn,resetBarChartWarnings:()=>Jt});module.exports=Yt(rn);var c=require("react"),Pt=require("../../lib/cn.cjs"),Ye=require("../../lib/i18n.cjs"),Te=require("../chart/ChartAnnotations.cjs"),ht=require("../chart/ChartAxis.cjs"),ge=require("../chart/ChartBrush.cjs"),Rt=require("../chart/ChartContainer.cjs"),At=require("../chart/ChartGrid.cjs"),Et=require("../chart/ChartLegend.cjs"),Ze=require("../chart/ChartPatterns.cjs"),Mt=require("../chart/ChartScaleLegend.cjs"),Tt=require("../chart/ChartSync.cjs"),Vt=require("../chart/ChartTableView.cjs"),je=require("../chart/ChartTooltip.cjs"),L=require("../chart/palette.cjs"),x=require("../chart/utils/cartesian.cjs"),D=require("../chart/utils/data.cjs"),z=require("../chart/utils/format.cjs"),qe=require("../chart/utils/keyboard.cjs"),It=require("../chart/utils/bins.cjs"),Je=require("../chart/utils/path.cjs"),fe=require("../chart/utils/scales.cjs"),pe=require("../chart/utils/stack.cjs"),Ht=require("../chart/utils/text.cjs"),Ve=require("../chart/utils/ticks.cjs"),Qe=require("../chart/utils/touch.cjs"),o=require("react/jsx-runtime"),Zt=24,Me=2,jt=4,me=6,qt=10,dt=!1,mt=!1,ft=!1;function Jt(){dt=!1,mt=!1,ft=!1}function Lt(d,l){let n=Math.max(d.x-l.x,0,l.x-(d.x+d.width)),i=Math.max(d.y-l.y,0,l.y-(d.y+d.height));return Math.hypot(n,i)}var Qt=(0,c.memo)(function({bars:l,patterns:n,patternBaseId:i}){return(0,o.jsx)("g",{children:l.map((m,T)=>(0,o.jsxs)("g",{children:[(0,o.jsx)("path",{d:m.d,fill:(0,Ze.patternFill)(n,i,m.slot,m.color)}),m.label?(0,o.jsx)("text",{x:m.label.x,y:m.label.y,textAnchor:m.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:m.label.text}):null]},`${m.key}-${T}`))})}),en=(0,c.memo)(function({lines:l}){return(0,o.jsx)("g",{children:l.map(n=>(0,o.jsxs)("g",{children:[(0,o.jsx)("path",{d:n.d,fill:"none",stroke:n.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",strokeDasharray:n.dashed?"5 4":void 0}),n.markers.map(i=>(0,o.jsx)("circle",{cx:i.x,cy:i.y,r:3,fill:n.color,strokeWidth:2,stroke:L.CHART_SURFACE_COLOR},`${i.x}-${i.y}`))]},n.key))})});function tn({width:d,height:l,data:n,resolvedSeries:i,x:m,y:T,grid:O,size:Ie,orientation:V,stack:$,center:I,centerKey:A,valueColors:F,binned:le,curve:He,barSize:We,showValues:De,referenceLines:be,annotations:N,annotationsLabel:et,patterns:Oe,patternBaseId:ie,overlay:Ne,brush:E,onBrush:Y,brushLabel:tt,syncEnabled:nt,margin:Z,tooltip:j,onPointClick:_,plotLabel:_e,formatValue:q,formatLabel:ye,formatExact:Ce,formatX:J,locale:$e,ranked:Ke}){let[ve,xe]=(0,c.useState)(null),b=ve!==null&&ve<n.length?ve:null,[rt,ot]=(0,c.useState)(null),at=(0,Tt.useChartSync)(),p=nt?at:null,e=(0,c.useMemo)(()=>{let t=V==="vertical",r=i.filter(f=>!f.hidden),a=r.filter(f=>f.type!=="line"),u=r.filter(f=>f.type==="line"),B=a.map(f=>f.key),C=A!==null||$!=="none",k=A===null?-1:i.findIndex(f=>f.key===A),s=k<0?void 0:a.filter(f=>i.indexOf(f)<k).length,h=A!==null?(0,pe.stackDiverging)(n,B,{centerKey:A,negativeCount:s,percent:$==="percent"}):(0,pe.stackSeries)(n,B,$),g=C?(0,pe.stackExtent)(h):(0,Ve.extent)((0,D.collectAllValues)(n,B)),v=(0,Ve.extent)((0,D.collectAllValues)(n,u.map(f=>f.key))),Se=(0,x.widenBounds)(v===null?g:(0,x.widenBounds)(g,v),(0,x.annotationValues)(n,m.key,be,N)),W=(0,x.buildCartesianGeometry)({locale:$e,width:d,height:l,data:n,x:m,y:T,bounds:Se===null?null:[Math.min(Se[0],I),Math.max(Se[1],I)],margin:Z,orientation:V,placement:"band",bandPaddingInner:le?0:void 0,formatValue:q,formatX:J,defaultIncludeZero:I===0}),{valueScale:Le,bandwidth:ue,categoryPositions:gt,innerWidth:pt,innerHeight:bt}=W,Wt=Le(I),te=Math.max(1,a.length),yt=C?ue:ue/te,Xe=!C&&te>1?Math.max(0,Math.min(Me,(ue-te)/(te-1))):Me,X=Math.min(We??(le?Number.POSITIVE_INFINITY:Zt),Math.max(Math.min(1,yt),yt-(C&&!le?0:Xe))),Dt=C?X:te*X+(te-1)*Xe,Ct=(ue-Dt)/2,vt=[],it=[],xt=f=>C?f.end>=f.start:f.end>=I;h.forEach((f,Pe)=>{let ne=-1,Re=-1;f.segments.forEach((w,he)=>{w.value!==null&&w.outer!==!1&&(xt(w)?ne=he:Re=he)});let re=0,Ae=0;f.segments.forEach((w,he)=>{if(w.value===null)return;let ze=a[he],S=xt(w),kt=Le(C?w.start:I),wt=Le(w.end),oe=Math.min(kt,wt),de=Math.abs(wt-kt),Nt=w.base??(S?re===0:Ae===0),_t=t?!S:S;C&&!Nt&&de>Me&&(de-=Me,_t&&(oe+=Me)),S?re+=1:Ae+=1;let Fe=gt[Pe]+(C?Ct:Ct+he*(X+Xe)),$t=he===(S?ne:Re)?t?S?"top":"bottom":S?"right":"left":"none",Bt=t?{x:Fe,y:oe,width:X,height:de}:{x:oe,y:Fe,width:de,height:X},st=null;if(De&&!C){let ct=ye(w.value),St=(0,Ht.estimateTextWidth)(ct,10);if(t){let ae=S?oe:oe+de,Ee=S?ae-me:ae+me,Kt=te>1?X+Xe:ue;St<=Kt&&(S?Ee>8:Ee<bt-4)&&(st={x:Fe+X/2,y:Ee,anchor:"middle",text:ct})}else{let ae=S?oe+de:oe,Ee=S?pt-ae-me:ae-me;St<=Ee&&(st={x:S?ae+me:ae-me,y:Fe+X/2,anchor:S?"start":"end",text:ct})}}it.push({index:Pe,key:ze.key,...Bt}),vt.push({key:ze.key,slot:ze.slot,color:F&&w.value!==null?F(w.value):ze.color,d:(0,Je.buildBarPath)({...Bt,radius:jt,round:$t}),label:st})})});let Ot=u.map(f=>{let Pe=W.categoryCenters.map((ne,Re)=>{let re=(0,D.readNumber)(n[Re],f.key),Ae=re===null?Number.NaN:Le(re),w={x:t?ne:Ae,y:t?Ae:ne,defined:re!==null};return re!==null&&it.push({index:Re,key:f.key,x:w.x,y:w.y,width:0,height:0}),w});return{key:f.key,color:f.color,dashed:f.dashed,d:(0,Je.buildLinePath)(Pe,He),markers:Pe.filter(ne=>ne.defined!==!1)}});return{vertical:t,visible:r,locate:(0,x.createCategoryLocator)(W),span:(0,x.createSpanLocator)(W),barSeries:a,rows:h,stacked:C,plot:(0,x.createPlotContext)({geometry:W,width:d,height:l,data:n,series:r,formatValue:q,formatX:J}),xValues:W.xValues,categoryPositions:gt,categoryCenters:W.categoryCenters,bandwidth:ue,categoryTicks:W.categoryTicks,valueTicks:W.valueTicks,valueScale:Le,baseline:Wt,innerWidth:pt,innerHeight:bt,margin:W.margin,bars:vt,hits:it,lines:Ot}},[$e,n,i,m,T,d,l,Z,V,$,I,A,F,le,He,We,De,be,N,q,ye,J]),se=(0,c.useCallback)(t=>e.visible.map(r=>{let a=(0,D.readNumber)(n[t],r.key),u=e.barSeries.indexOf(r),B=u===-1?null:e.rows[t].segments[u],C=a===null?"\u2014":$==="percent"&&B!==null?`${Ce(a)} (${q(B.end-B.start)})`:Ce(a);return{seriesKey:r.key,seriesLabel:(0,L.getSeriesLabel)(r),color:r.color,value:a,formattedValue:C,datum:n[t]}}),[n,e.visible,e.barSeries,e.rows,$,q,Ce]),Ge=p?p.brush:rt,lt=(0,c.useCallback)(t=>{ot(t),p?.setBrush(t),Y?.(t)},[p,Y]),y=(0,ge.useChartBrush)({enabled:E&&!Ke,active:Ge!==null,centers:e.categoryCenters,xValues:e.xValues,offset:e.vertical?e.margin.left:e.margin.top,orientation:V,onCommit:lt}),P=(0,c.useCallback)(t=>{if(y.onPointerMove(t),j===!1||n.length===0)return;let r=t.currentTarget.getBoundingClientRect(),a=e.vertical?t.clientX-r.left-e.margin.left:t.clientY-r.top-e.margin.top,u=(0,fe.nearestIndex)(e.categoryCenters,a);xe(u>=0?u:null),p?.setHovered(u>=0?e.xValues[u]:null)},[y,j,n.length,e.vertical,e.margin,e.categoryCenters,e.xValues,p]),K=(0,c.useCallback)(()=>{xe(null),p?.setHovered(null)},[p]),R=(0,c.useCallback)((t,r)=>{if(!_)return;let a=se(t),u=r===null?[]:e.hits.filter(k=>k.index===t),B=r===null||u.length===0?null:u.reduce((k,s)=>Lt(s,r)<Lt(k,r)?s:k),C=(B&&a.find(k=>k.seriesKey===B.key))??a.find(k=>k.value!==null)??a[0];C&&_({...C,index:t,x:e.xValues[t]})},[_,se,e.hits,e.xValues]),G=(0,c.useCallback)(t=>{if(n.length===0)return;let r=_&&b!==null&&e.visible.length>0;if((0,qe.pressChartMark)(t,r?()=>R(b,null):null))return;let a=y.onKeyDown(t,b),u=(0,qe.chartCursorTarget)(t.key,b,n.length,e.vertical?"x":"y");if(u===void 0){a&&t.preventDefault();return}t.preventDefault(),xe(u),p?.setHovered(u===null?null:e.xValues[u])},[n.length,b,e.vertical,y,p,e.xValues,e.visible.length,_,R]),M=(0,c.useCallback)(t=>{if(y.consumedClick()||!_||n.length===0)return;let r=(0,x.plotPointer)(t,e),a=r===null?null:e.vertical?r.x:r.y,u=b??(a===null?-1:(0,fe.nearestIndex)(e.categoryCenters,a));u<0||R(u,r)},[y,_,n.length,e,b,R]),U=b!==null||p===null||p.hovered===null?null:(()=>{let t=(0,fe.toKey)(p.hovered),r=e.xValues.findIndex(a=>(0,fe.toKey)(a)===t);return r<0?null:r})(),H=b??U,ke=Ke?null:y.dragging??Ge,we=(()=>{if(!ke)return null;let t=(0,ge.locateBrush)(ke,e.xValues,e.categoryCenters,e.locate);if(t===null)return null;let{from:r,to:a}=t,u=e.bandwidth/2;return{from:Math.min(r,a)-u,to:Math.max(r,a)+u}})(),Be=(0,x.splitOverlay)(Ne),Ue=b===null?null:se(b),Q=b===null||Ue===null?null:{x:e.xValues[b],xLabel:J(e.xValues[b],b),index:b,points:Ue},ce=t=>{let r=e.rows[t].segments.filter(a=>a.value!==null).map(a=>e.valueScale(a.end));for(let a of e.lines){let u=(0,D.readNumber)(n[t],a.key);u!==null&&r.push(e.valueScale(u))}return r},ee=b===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[b],y:e.margin.top+Math.min(...ce(b),e.baseline)}:{x:e.margin.left+Math.max(...ce(b),e.baseline),y:e.margin.top+e.categoryCenters[b]};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("svg",{width:d,height:l,role:"img","aria-label":_e??[e.visible.map(t=>(0,L.getSeriesLabel)(t)).join(", "),(0,Te.describeAnnotations)(N,et)].filter(Boolean).join(". "),tabIndex:0,className:(0,Pt.cn)(E&&!e.vertical?Qe.CHART_TOUCH_VERTICAL_DRAG:Qe.CHART_TOUCH,"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500",E&&"select-none"),onPointerDown:y.onPointerDown,onPointerMove:P,onPointerUp:y.onPointerUp,onPointerCancel:y.onPointerUp,onPointerLeave:K,onKeyDown:G,onBlur:K,onClick:M,children:[Oe?(0,o.jsx)(Ze.ChartPatternDefs,{id:ie,entries:i.map(t=>({slot:t.slot,color:t.color}))}):null,(0,o.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,o.jsx)(At.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(O==="y"||O==="both")?e.valueTicks.map(t=>t.offset):void 0,vertical:!e.vertical&&(O==="y"||O==="both")?e.valueTicks.map(t=>t.offset):void 0}),N?(0,o.jsx)(Te.ChartAnnotationLayer,{layer:"under",annotations:N,xAt:e.locate,spanAt:e.span,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight,bandwidth:e.bandwidth}):null,we?(0,o.jsx)(ge.ChartBrushLayer,{from:we.from,to:we.to,width:e.innerWidth,height:e.innerHeight,orientation:V,live:y.dragging!==null,label:tt}):null,H!==null?(0,o.jsx)("rect",{x:e.vertical?e.categoryPositions[H]:0,y:e.vertical?0:e.categoryPositions[H],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,Be.under?.(e.plot),(0,o.jsx)(Qt,{bars:e.bars,patterns:Oe,patternBaseId:ie}),e.lines.length>0?(0,o.jsx)(en,{lines:e.lines}):null,(0,o.jsx)("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"}),N?(0,o.jsx)(Te.ChartAnnotationLayer,{annotations:N,xAt:e.locate,yAt:e.valueScale,width:e.innerWidth,height:e.innerHeight,bandwidth:e.bandwidth}):null,Be.over?.(e.plot),be?.map(t=>{let r=e.valueScale(t.value),a=r<qt?r+12:r-4;return(0,o.jsxs)("g",{children:[(0,o.jsx)("line",{x1:e.vertical?0:r,y1:e.vertical?r:0,x2:e.vertical?e.innerWidth:r,y2:e.vertical?r:e.innerHeight,stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?(0,o.jsx)("text",{x:e.vertical?e.innerWidth:r+4,y:e.vertical?a:8,textAnchor:e.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)})]}),(0,o.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?m.hidden:T?.hidden)?null:(0,o.jsx)(ht.ChartAxis,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?m.label:T?.label,size:Ie})}),(0,o.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?T?.hidden:m.hidden)?null:(0,o.jsx)(ht.ChartAxis,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?T?.label:m.label,size:Ie})})]}),Q&&ee&&j!==!1?(0,o.jsx)(je.ChartTooltip,{x:ee.x,y:ee.y,containerWidth:d,children:typeof j=="function"?j(Q):(0,o.jsx)(je.ChartTooltipContent,{title:Q.xLabel,points:Q.points})}):null]})}function nn({data:d,series:l,x:n,y:i,height:m=260,width:T,size:O="md",grid:Ie="y",legend:V,tooltip:$=!0,tableView:I=!1,emphasis:A,title:F,description:le,loading:He=!1,emptyState:We,error:De=!1,errorState:be,onRetry:N,actions:et,onPointClick:Oe,orientation:ie="vertical",stack:Ne="none",diverging:E,bins:Y,curve:tt="linear",barSize:nt,sort:Z="none",showValues:j=!1,referenceLines:_,annotations:_e,overlay:q,patterns:ye=!1,legendToggle:Ce=!0,brush:J=!1,onBrush:$e,brushLabel:Ke,sync:ve=!0,margin:xe,locale:b,plotLabel:rt,className:ot,...at}){let p=(0,Ye.useUILocale)(b),e=(0,Ye.useUILabels)(),[se,Ge]=(0,c.useState)(()=>new Set),lt=(0,c.useId)(),y=Y!==void 0&&Y!==!1,P=y||typeof E!="string"?null:E,K=!y&&typeof E=="number"?E:0,R=(0,c.useMemo)(()=>{let s=P===null?null:(0,L.createDivergingScale)([0,Math.max(1,l.length-1)],{center:Math.max(0,l.findIndex(h=>h.key===P)),symmetric:!1});return l.map((h,g)=>({...h,slot:g,hidden:h.hidden||se.has(h.key),color:s&&!h.color&&!A?h.key===P?L.CHART_MUTED_COLOR:s(g):(0,L.resolveSeriesColor)(h,g,A)}))},[l,se,A,P]),G=(0,c.useMemo)(()=>s=>(0,z.formatAuto)(s,p),[p]),M=(0,c.useMemo)(()=>{if(!y)return null;l.length>1&&!dt&&(dt=!0,console.warn("[@synertech/ui] BarChart was given `bins` and more than one series. A histogram counts a single field \u2014 the extra series are ignored. Facet the chart, or draw the distributions side by side."));let s=l[0]?.key??"count",h=n.format?v=>n.format(v,0):v=>G(v),g=(0,It.binValues)(d.map(v=>(0,D.readNumber)(v,n.key)),Y);return{rows:g.map(v=>({[n.key]:v.from,[s]:v.count})),labels:g.map(v=>`${h(v.from)}\u2013${h(v.to)}`)}},[y,Y,d,n.key,n.format,l,G]),U=(0,c.useMemo)(()=>{if(M)return M.rows;if(Z==="none")return d;let s=R.filter(g=>!g.hidden).map(g=>g.key),h=g=>s.reduce((v,Se)=>v+((0,D.readNumber)(g,Se)??0),0);return[...d].sort((g,v)=>Z==="asc"?h(g)-h(v):h(v)-h(g))},[M,d,Z,R]),H=!y&&Ne==="percent",ke=!y&&Z!=="none";J&&ke&&!ft&&(ft=!0,console.warn("[@synertech/ui] BarChart was given `brush` and `sort`. A window is a stretch of the data in its own order, and a ranking has none: the brush is ignored. Brush a chart in data order, and sort the one that ranks."));let we=(0,c.useMemo)(()=>H?{domain:P===null?[0,100]:[-100,100],...i}:i,[H,P,i]),Be=(0,c.useMemo)(()=>{let s=i?.format??(H?h=>(0,z.formatPercent)(h,{locale:p,alreadyScaled:!0,maximumFractionDigits:0}):G);return P===null?s:h=>s(Math.abs(h))},[i?.format,H,p,G,P]),Ue=(0,c.useMemo)(()=>i?.format??G,[i?.format,G]),Q=(0,c.useMemo)(()=>!H&&i?.format||(s=>(0,z.formatExact)(s,p)),[H,i?.format,p]),ce=(0,c.useMemo)(()=>M?(s,h)=>M.labels[h]??"":n.format??(s=>(0,z.formatXValue)(s,p)),[M,n.format,p]),ee=(0,c.useMemo)(()=>M?{...n,scale:"category"}:n,[M,n]),t=(0,c.useCallback)(s=>{Ge(h=>{let g=new Set(h);return g.has(s)?g.delete(s):g.add(s),g})},[]),r=ie==="vertical"?_e:void 0;_e&&ie!=="vertical"&&!mt&&(mt=!0,console.warn("[@synertech/ui] BarChart was given `annotations` and a horizontal orientation. Annotations are read on the category axis, which runs up the side there: they are ignored. Use `referenceLines` for a threshold on the value axis."));let a=V===void 0?l.length>=2:V!==!1,u=typeof V=="string"?V:"bottom",B=R.filter(s=>!s.hidden),C=B.length,k=(0,c.useMemo)(()=>{if(y||E===void 0||E===!1||P!==null||C!==1)return null;let s=(0,D.collectAllValues)(U,B.map(g=>g.key)),h=(0,Ve.resolveDomain)([...s,K],{domain:i?.domain,includeZero:i?.includeZero??K===0,ticks:i?.ticks??5});return(0,L.createDivergingScale)(h,{center:K})},[y,E,P,C,B,U,K,i]);return(0,o.jsx)(Rt.ChartContainer,{title:F,description:le,height:m,width:T,size:O,loading:He,empty:U.length===0||C===0,emptyState:We,error:De,errorState:be,onRetry:N,actions:et,exportSource:{data:U,series:R,xKey:ee.key,xLabel:n.label??n.key,formatX:M?ce:n.format},tableView:I,legendPosition:u,legend:k?(0,o.jsx)(Mt.ChartScaleLegend,{scale:k,label:i?.label,format:Be,size:O,locale:p}):a?(0,o.jsx)(Et.ChartLegend,{items:(0,L.toLegendItems)(R,A,ye),position:u,marker:"rect",size:O,onToggle:Ce?t:void 0}):void 0,table:I?(0,o.jsx)(Vt.ChartTableView,{data:U,series:R,xKey:ee.key,xLabel:n.label??n.key,formatX:ce,formatValue:Q,caption:typeof F=="string"?F:void 0}):void 0,className:ot,...at,children:({width:s})=>(0,o.jsx)(tn,{ranked:ke,locale:p,width:s,height:m,data:U,resolvedSeries:R,x:ee,y:we,grid:Ie,size:O,orientation:ie,stack:y?"none":Ne,center:K,centerKey:P,valueColors:k,binned:y,curve:tt,barSize:nt,showValues:j,referenceLines:_,annotations:r,annotationsLabel:e.chartAnnotations,patterns:ye&&k===null,patternBaseId:lt,overlay:q,brush:J,onBrush:$e,brushLabel:Ke??e.chartBrush,syncEnabled:ve,margin:xe,tooltip:$,onPointClick:Oe,plotLabel:rt,formatValue:Be,formatLabel:Ue,formatExact:Q,formatX:ce})})}0&&(module.exports={BarChart,resetBarChartWarnings});
|