@synertech/ui 0.50.1 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +190 -146
- package/README.md +27 -19
- package/dist/components/accordion/Accordion.cjs +1 -1
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar/AvatarImage.cjs +1 -0
- package/dist/components/avatar/AvatarImage.js +1 -0
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/bar-chart/BarChart.cjs +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/box-plot/BoxPlot.cjs +1 -1
- package/dist/components/box-plot/BoxPlot.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/bullet-chart/BulletChart.cjs +1 -1
- package/dist/components/bullet-chart/BulletChart.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
- package/dist/components/card/Card.cjs +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/chart/ChartAnnotations.cjs +1 -1
- package/dist/components/chart/ChartAnnotations.js +1 -1
- package/dist/components/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartContainer.cjs +1 -1
- package/dist/components/chart/ChartContainer.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/ChartPatterns.cjs +1 -1
- package/dist/components/chart/ChartPatterns.js +1 -1
- package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
- package/dist/components/chart/ChartPeriodPicker.js +1 -1
- package/dist/components/chart/ChartPlotClip.cjs +1 -0
- package/dist/components/chart/ChartPlotClip.js +1 -0
- package/dist/components/chart/ChartSync.cjs +1 -1
- package/dist/components/chart/ChartSync.js +1 -1
- package/dist/components/chart/ChartTableView.cjs +1 -1
- package/dist/components/chart/ChartTableView.js +1 -1
- package/dist/components/chart/exportSource.cjs +1 -0
- package/dist/components/chart/exportSource.js +1 -0
- package/dist/components/chart/palette.cjs +1 -1
- package/dist/components/chart/palette.js +1 -1
- package/dist/components/chart/useChartSize.cjs +1 -1
- package/dist/components/chart/useChartSize.js +1 -1
- package/dist/components/chart/utils/bins.cjs +1 -1
- package/dist/components/chart/utils/bins.js +1 -1
- package/dist/components/chart/utils/cartesian.cjs +1 -1
- package/dist/components/chart/utils/cartesian.js +1 -1
- package/dist/components/chart/utils/export.cjs +7 -1
- package/dist/components/chart/utils/export.js +7 -1
- package/dist/components/chart/utils/format.cjs +1 -1
- package/dist/components/chart/utils/format.js +1 -1
- package/dist/components/chart/utils/keyboard.cjs +1 -1
- package/dist/components/chart/utils/keyboard.js +1 -1
- package/dist/components/chart/utils/period.cjs +1 -1
- package/dist/components/chart/utils/period.js +1 -1
- package/dist/components/chart/utils/regression.cjs +1 -0
- package/dist/components/chart/utils/regression.js +1 -0
- package/dist/components/chart/utils/stack.cjs +1 -1
- package/dist/components/chart/utils/stack.js +1 -1
- package/dist/components/chart/utils/ticks.cjs +1 -1
- package/dist/components/chart/utils/ticks.js +1 -1
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/circular-progress/CircularProgress.cjs +1 -1
- package/dist/components/circular-progress/CircularProgress.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.js +1 -1
- package/dist/components/detachable/Detachable.cjs +1 -1
- package/dist/components/detachable/Detachable.js +1 -1
- package/dist/components/detachable/popup-window.cjs +1 -0
- package/dist/components/detachable/popup-window.js +1 -0
- package/dist/components/detachable/useMovableContent.cjs +1 -0
- package/dist/components/detachable/useMovableContent.js +1 -0
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/divider/Divider.cjs +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
- package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
- package/dist/components/dropdown/hooks/usePositioning.js +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/footer/FooterBottom.cjs +1 -1
- package/dist/components/footer/FooterBottom.js +1 -1
- package/dist/components/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +5 -1
- package/dist/components/form/mention-input/MentionInput.js +5 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/form/shared/InputWrapper.cjs +1 -1
- package/dist/components/form/shared/InputWrapper.js +1 -1
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
- package/dist/components/funnel-chart/FunnelChart.js +1 -1
- package/dist/components/gantt-chart/GanttChart.cjs +1 -1
- package/dist/components/gantt-chart/GanttChart.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/line-chart/LineChart.cjs +1 -1
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pie-chart/PieChart.cjs +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/progress-bar/ProgressBar.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scatter-chart/index.cjs +1 -1
- package/dist/components/scatter-chart/index.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
- package/dist/components/schema-editor/utils/import.cjs +1 -0
- package/dist/components/schema-editor/utils/import.js +1 -0
- package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
- package/dist/components/schema-editor/utils/sql-export.js +7 -6
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sparkline/Sparkline.cjs +1 -1
- package/dist/components/sparkline/Sparkline.js +1 -1
- package/dist/components/table/TableRow.cjs +1 -1
- package/dist/components/table/TableRow.js +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
- package/dist/components/wizard/Wizard.cjs +1 -1
- package/dist/components/wizard/Wizard.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
- package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/components/workflow-editor/utils/import.cjs +1 -0
- package/dist/components/workflow-editor/utils/import.js +1 -0
- package/dist/hooks/useDialogA11y.cjs +1 -1
- package/dist/hooks/useDialogA11y.js +1 -1
- package/dist/index.d.cts +522 -184
- package/dist/index.d.ts +522 -184
- package/dist/lib/accept.cjs +1 -0
- package/dist/lib/accept.js +1 -0
- package/dist/lib/canvas-events.cjs +1 -0
- package/dist/lib/canvas-events.js +1 -0
- package/dist/lib/css-value.cjs +1 -0
- package/dist/lib/css-value.js +1 -0
- package/dist/lib/dialog-stack.cjs +1 -1
- package/dist/lib/dialog-stack.js +1 -1
- package/dist/lib/layer-document.cjs +1 -0
- package/dist/lib/layer-document.js +1 -0
- package/dist/lib/owner-document.cjs +1 -0
- package/dist/lib/owner-document.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -1
- package/dist/lib/ui-labels.js +1 -1
- package/dist/styles-no-preflight.css +10270 -0
- package/dist/styles.css +390 -450
- package/package.json +9 -4
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
|
|
1
|
+
"use strict";"use client";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var c in r)A(e,c,{get:r[c],enumerable:!0})},M=(e,r,c,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!D.call(e,t)&&t!==c&&A(e,t,{get:()=>r[t],enumerable:!(n=z(r,t))||n.enumerable});return e};var S=e=>M(A({},"__esModule",{value:!0}),e);var G={};H(G,{Accordion:()=>$,AccordionContent:()=>F,AccordionItem:()=>q,AccordionTrigger:()=>B});module.exports=S(G);var o=require("react"),b=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),I=(0,o.createContext)(null),C=(0,o.createContext)(null);function v(){let e=(0,o.useContext)(I);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function N(){let e=(0,o.useContext)(C);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var k={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:e})=>(0,d.jsx)("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,d.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function $({type:e="single",value:r,defaultValue:c,onValueChange:n,collapsible:t=!1,variant:s="default",size:l="md",disabled:u=!1,iconPosition:a="right",icon:g,hideIcon:i=!1,className:m,children:w}){let[R,P]=(0,o.useState)(()=>c?Array.isArray(c)?c:[c]:[]),y=r!==void 0,p=y?Array.isArray(r)?r:[r]:R,h=(0,o.useCallback)(f=>{let x;e==="single"?p.includes(f)?x=t?[]:[f]:x=[f]:x=p.includes(f)?p.filter(T=>T!==f):[...p,f],y||P(x),n?.(e==="single"?x[0]??"":x)},[e,p,t,y,n]),O=(0,o.useMemo)(()=>({openItems:p,toggle:h,variant:s,size:l,disabled:u,iconPosition:a,icon:g??null,hideIcon:i}),[p,h,s,l,u,a,g,i]);return(0,d.jsx)(I.Provider,{value:O,children:(0,d.jsx)("div",{className:(0,b.cn)(K[s],m),"data-testid":"accordion",children:w})})}function q({value:e,disabled:r,className:c,children:n}){let t=v(),s=t.openItems.includes(e),l=r??t.disabled,u=(0,o.useId)(),a=`accordion-trigger-${u}`,g=`accordion-content-${u}`,i=(0,o.useMemo)(()=>({value:e,isOpen:s,disabled:l,triggerId:a,contentId:g}),[e,s,l,a,g]);return(0,d.jsx)(C.Provider,{value:i,children:(0,d.jsx)("div",{className:(0,b.cn)(L[t.variant],c),"data-state":s?"open":"closed","data-testid":"accordion-item",children:n})})}function B({className:e,icon:r,children:c}){let n=v(),t=N(),s=k[n.size],l=()=>{t.disabled||n.toggle(t.value)},u=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l())},a=r??n.icon??(0,d.jsx)(V,{className:s.icon}),g=!n.hideIcon&&(0,d.jsx)("span",{className:(0,b.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",t.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:a});return(0,d.jsxs)("button",{type:"button",id:t.triggerId,"aria-expanded":t.isOpen,"aria-controls":t.contentId,disabled:t.disabled,onClick:l,onKeyDown:u,className:(0,b.cn)("flex items-center w-full text-left font-medium transition-colors cursor-pointer",s.trigger,s.text,"text-gray-900 dark:text-gray-100",!t.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",t.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&g,(0,d.jsx)("span",{className:"flex-1",children:c}),n.iconPosition==="right"&&g]})}function F({className:e,children:r}){let c=v(),n=N(),t=k[c.size],s=(0,o.useRef)(null),l=(0,o.useRef)(null),[u,a]=(0,o.useState)(n.isOpen?void 0:0),g=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{let i=l.current;i&&(n.isOpen?i.removeAttribute("inert"):i.setAttribute("inert",""))},[n.isOpen]),(0,o.useEffect)(()=>{if(g.current){g.current=!1,a(n.isOpen?void 0:0);return}if(n.isOpen){let i=s.current;if(i){a(i.scrollHeight);let m=setTimeout(()=>a(void 0),200);return()=>clearTimeout(m)}}else{let i=s.current;i&&(a(i.scrollHeight),requestAnimationFrame(()=>a(0)))}},[n.isOpen]),(0,d.jsx)("div",{ref:l,id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:(0,d.jsx)("div",{ref:s,className:(0,b.cn)(t.content,"text-gray-600 dark:text-gray-400",t.text==="text-lg"?"text-base":"text-sm",e),children:r})})}0&&(module.exports={Accordion,AccordionContent,AccordionItem,AccordionTrigger});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as
|
|
1
|
+
"use client";import{createContext as I,useContext as C,useState as N,useCallback as M,useMemo as k,useRef as y,useEffect as h,useId as S}from"react";import{cn as x}from"../../lib/cn.js";import{jsx as d,jsxs as $}from"react/jsx-runtime";var w=I(null),R=I(null);function A(){let t=C(w);if(!t)throw new Error("Accordion sub-components must be used within <Accordion>");return t}function P(){let t=C(R);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return t}var O={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:t})=>d("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:d("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function F({type:t="single",value:a,defaultValue:l,onValueChange:e,collapsible:n=!1,variant:r="default",size:c="md",disabled:g=!1,iconPosition:i="right",icon:s,hideIcon:o=!1,className:b,children:T}){let[z,E]=N(()=>l?Array.isArray(l)?l:[l]:[]),m=a!==void 0,u=m?Array.isArray(a)?a:[a]:z,v=M(p=>{let f;t==="single"?u.includes(p)?f=n?[]:[p]:f=[p]:f=u.includes(p)?u.filter(H=>H!==p):[...u,p],m||E(f),e?.(t==="single"?f[0]??"":f)},[t,u,n,m,e]),D=k(()=>({openItems:u,toggle:v,variant:r,size:c,disabled:g,iconPosition:i,icon:s??null,hideIcon:o}),[u,v,r,c,g,i,s,o]);return d(w.Provider,{value:D,children:d("div",{className:x(K[r],b),"data-testid":"accordion",children:T})})}function G({value:t,disabled:a,className:l,children:e}){let n=A(),r=n.openItems.includes(t),c=a??n.disabled,g=S(),i=`accordion-trigger-${g}`,s=`accordion-content-${g}`,o=k(()=>({value:t,isOpen:r,disabled:c,triggerId:i,contentId:s}),[t,r,c,i,s]);return d(R.Provider,{value:o,children:d("div",{className:x(L[n.variant],l),"data-state":r?"open":"closed","data-testid":"accordion-item",children:e})})}function J({className:t,icon:a,children:l}){let e=A(),n=P(),r=O[e.size],c=()=>{n.disabled||e.toggle(n.value)},g=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),c())},i=a??e.icon??d(V,{className:r.icon}),s=!e.hideIcon&&d("span",{className:x("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return $("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:c,onKeyDown:g,className:x("flex items-center w-full text-left font-medium transition-colors cursor-pointer",r.trigger,r.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",t),"data-testid":"accordion-trigger",children:[e.iconPosition==="left"&&s,d("span",{className:"flex-1",children:l}),e.iconPosition==="right"&&s]})}function Q({className:t,children:a}){let l=A(),e=P(),n=O[l.size],r=y(null),c=y(null),[g,i]=N(e.isOpen?void 0:0),s=y(!0);return h(()=>{let o=c.current;o&&(e.isOpen?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.isOpen]),h(()=>{if(s.current){s.current=!1,i(e.isOpen?void 0:0);return}if(e.isOpen){let o=r.current;if(o){i(o.scrollHeight);let b=setTimeout(()=>i(void 0),200);return()=>clearTimeout(b)}}else{let o=r.current;o&&(i(o.scrollHeight),requestAnimationFrame(()=>i(0)))}},[e.isOpen]),d("div",{ref:c,id:e.contentId,role:"region","aria-labelledby":e.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},"data-testid":"accordion-content","data-state":e.isOpen?"open":"closed",children:d("div",{ref:r,className:x(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",t),children:a})})}export{F as Accordion,Q as AccordionContent,G as AccordionItem,J as AccordionTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";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};
|