@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
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as D,useEffect as it,useMemo as _,useRef as Fe,useState as Z}from"react";import{cn as c}from"../../lib/cn.js";import{useUILabels as dt,useUILocale as ct}from"../../lib/i18n.js";import{jsx as o,jsxs as R}from"react/jsx-runtime";var ut=10080*60*1e3;function q(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function G(e){return q(e)?e:void 0}function f(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function T(e,r){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+r)}function C(e,r){return new Date(e.getFullYear(),e.getMonth()+r,1)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function x(e,r){return!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function fe(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()}function A(e,r){return e.getFullYear()*12+e.getMonth()-(r.getFullYear()*12+r.getMonth())}function ee(e){let r=`${e.getMonth()+1}`.padStart(2,"0"),i=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${i}`}function gt(e){let r=f(e);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/ut)}function ft(e){return gt(e.find(r=>r.getDay()===4)??e[0])}function Re(e,r,i){return r&&e<f(r)?f(r):i&&e>f(i)?f(i):e}function yt(e,r,i){let z=V(e),j=(z.getDay()-r+7)%7,O=T(z,-j),ae=i?6:Math.ceil((j+ye(e))/7);return Array.from({length:ae},(me,J)=>Array.from({length:7},(be,L)=>T(O,J*7+L)))}function mt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function bt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var pt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},ht={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},Dt={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},xt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},vt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function te(e,r){if(e==="multiple")return Array.isArray(r)?r.filter(q).map(f):[];if(e==="range"){let i=r??null;return{from:q(i?.from)?f(i.from):null,to:q(i?.to)?f(i.to):null}}return q(r)?f(r):null}function Pe(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function St(e){let{mode:r="single",value:i,defaultValue:z,onChange:j,max:O,month:ae,defaultMonth:me,onMonthChange:J,numberOfMonths:be=1,weekStartsOn:L=0,locale:Ye,today:Te,size:Le="md",color:v="primary",minDate:Ae,maxDate:Ee,disabledDates:$,disabled:y=!1,showOutsideDays:Be=!0,showWeekNumbers:pe=!1,fixedWeeks:Ie=!1,captionLayout:re="label",fromYear:he,toYear:De,todayButton:ne=!1,clearButton:oe=!1,footer:xe,bordered:We=!0,renderDay:ve,labels:E,className:Ve,...ze}=e,B=dt(),P=ct(Ye),p=pt[Le],w=Math.max(1,be),le=G(ae),ke=G(me),M=G(Ae),S=G(Ee),se=G(Te)?.getTime(),m=_(()=>f(se===void 0?new Date:new Date(se)),[se]),ie=i!==void 0,[Ke,_e]=Z(()=>te(r,z)),k=ie?te(r,i):Ke,de=le!==void 0,[je,Oe]=Z(()=>V(ke??Pe(te(r,z??i))??m)),u=de?V(le):je,h=D(t=>{let a=V(t);de||Oe(a),J?.(a)},[de,J]),Ce=Fe(null),ce=Fe(!1),[I,Q]=Z(()=>{let t=Pe(te(r,z??i)),a=V(ke??le??t??m),d=t&&fe(t,a)?t:fe(m,a)?m:a;return Re(d,M,S)}),$e=C(u,w-1),He=A(I,u)>=0&&A(I,$e)<=0?I:u;it(()=>{if(!ce.current)return;ce.current=!1,Ce.current?.querySelector(`[data-day="${ee(I)}"]:not([data-outside])`)?.focus()},[I,u]);let Y=D(t=>{let a=Re(f(t),M,S);ce.current=!0,Q(a);let d=C(u,w-1);A(a,u)<0?h(a):A(a,d)>0&&h(C(a,-(w-1)))},[u,w,M,S,h]),K=D(t=>y||M&&t<f(M)||S&&t>f(S)?!0:typeof $=="function"?$(t):Array.isArray($)?$.some(a=>x(a,t)):!1,[y,M,S,$]),[ue,we]=Z(null),N=D(t=>{ie||_e(t),j?.(t)},[ie,j]),X=D(t=>{let a=f(t);if(K(a))return;if(r==="multiple"){let l=k??[];if(l.some(n=>x(n,a))){N(l.filter(n=>!x(n,a)));return}if(O!==void 0&&l.length>=O)return;N([...l,a].sort((n,g)=>n.getTime()-g.getTime()));return}if(r==="range"){let l=k??{from:null,to:null};if(!l.from||l.to){N({from:a,to:null});return}N(a<l.from?{from:a,to:l.from}:{from:l.from,to:a});return}N(x(k,a)?null:a)},[r,k,O,N,K]),Ue=D(t=>{X(t),Q(f(t)),A(t,u)<0?h(t):A(t,C(u,w-1))>0&&h(C(t,-(w-1)))},[X,u,w,h]),Me=!y&&(!M||A(u,V(M))>0),Se=!y&&(!S||A(C(u,w-1),V(S))<0),Ge=D(()=>{h(C(u,-1))},[u,h]),qe=D(()=>{h(C(u,1))},[u,h]),Je=D(t=>{if(y)return;let a=I;switch(t.key){case"ArrowLeft":t.preventDefault(),Y(T(a,-1));break;case"ArrowRight":t.preventDefault(),Y(T(a,1));break;case"ArrowUp":t.preventDefault(),Y(T(a,-7));break;case"ArrowDown":t.preventDefault(),Y(T(a,7));break;case"Home":t.preventDefault(),Y(T(a,-((a.getDay()-L+7)%7)));break;case"End":t.preventDefault(),Y(T(a,6-(a.getDay()-L+7)%7));break;case"PageUp":{t.preventDefault();let d=t.shiftKey?-12:-1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}case"PageDown":{t.preventDefault();let d=t.shiftKey?12:1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}default:break}},[y,I,Y,L]),Qe=_(()=>{let t=new Intl.DateTimeFormat(P,{weekday:"short"}),a=new Intl.DateTimeFormat(P,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,b)=>{let n=T(d,(L+b)%7);return{short:t.format(n),long:a.format(n)}})},[P,L]),Xe=_(()=>{let t=new Intl.DateTimeFormat(P,{month:"long"});return Array.from({length:12},(a,d)=>t.format(new Date(2024,d,1)))},[P]),Ne=_(()=>new Intl.DateTimeFormat(P,{month:"long",year:"numeric"}),[P]),Ze=_(()=>new Intl.DateTimeFormat(P,{dateStyle:"full"}),[P]),et=_(()=>{if(re!=="dropdown")return[];let t=m.getFullYear(),a=he??M?.getFullYear()??t-100,d=De??S?.getFullYear()??t+10;return d<a?[a]:Array.from({length:d-a+1},(l,b)=>a+b)},[re,he,De,M,S,m]),F=r==="range"?k:null,tt=F&&F.from&&!F.to&&ue&&ue>F.from?ue:null,H=F?.to??tt,at=D((t,a)=>{let d=!fe(t,a),l=K(t),b=!1,n=!1,g=!1,s=!1;return r==="multiple"?b=(k??[]).some(U=>x(U,t)):r==="range"?(n=x(F?.from,t),g=x(H,t),b=n||g,s=!!(F?.from&&H&&t>F.from&&t<H)):b=x(k,t),{selected:b,today:x(t,m),outside:d,disabled:l,rangeStart:n,rangeEnd:g,inRange:s}},[r,k,F,H,K,m]),rt=t=>{let a=C(u,t),d=yt(a,L,Ie),l=t===0,b=t===w-1;return R("div",{className:"flex flex-col",children:[R("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:Ge,disabled:!Me,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Me&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(mt,{className:p.icon})}),re==="dropdown"?R("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:a.getMonth(),disabled:y,onChange:n=>h(new Date(a.getFullYear(),Number(n.target.value)-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:Xe.map((n,g)=>o("option",{value:g,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:a.getFullYear(),disabled:y,onChange:n=>h(new Date(Number(n.target.value),a.getMonth()-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:et.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:Ne.format(a)}),o("button",{type:"button",onClick:qe,disabled:!Se,"aria-label":E?.nextMonth??B.calendarNextMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Se&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:o(bt,{className:p.icon})})]}),R("table",{role:"grid","aria-label":Ne.format(a),onKeyDown:Je,className:"border-collapse",children:[o("thead",{children:R("tr",{children:[pe&&R("th",{scope:"col",className:c("font-normal text-gray-500 dark:text-gray-400",p.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),Qe.map(n=>o("th",{scope:"col",abbr:n.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>R("tr",{children:[pe&&o("td",{className:c("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:ft(n)}),n.map(g=>{let s=at(g,a),U=ee(g);if(s.outside&&!Be)return o("td",{className:"p-0"},U);let st=x(g,He)&&!s.outside,ge=s.inRange||s.rangeStart&&!!H||s.rangeEnd&&!!F?.from;return o("td",{role:"presentation",className:c("p-0",ge&&Dt[v],ge&&s.rangeStart&&"rounded-l-full",ge&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":U,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:st?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":Ze.format(g),onClick:()=>{s.disabled||Ue(g)},onMouseEnter:()=>r==="range"&&we(f(g)),onMouseLeave:()=>r==="range"&&we(null),onFocus:()=>Q(f(g)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.day,s.selected?ht[v]:s.inRange?c(xt[v],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(vt[v],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:ve?ve(g,s):g.getDate()})},U)})]},ee(n[0])))})]})]},ee(a))},nt=D(()=>{if(h(m),Q(m),K(m))return;(r==="multiple"?(k??[]).some(a=>x(a,m)):r==="single"&&x(k,m))||X(m)},[m,h,K,X,r,k]),ot=D(()=>{N(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,N]),lt=!!xe||ne||oe;return R("div",{ref:Ce,className:c("inline-block bg-white dark:bg-gray-900",We&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",Ve),...ze,children:[o("div",{className:c("flex flex-wrap",p.gap),children:Array.from({length:w},(t,a)=>rt(a))}),lt&&R("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:xe}),(ne||oe)&&R("div",{className:"flex items-center gap-2",children:[ne&&o("button",{type:"button",onClick:nt,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),oe&&o("button",{type:"button",onClick:ot,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{St as Calendar};
|
|
1
|
+
"use client";import{useCallback as v,useEffect as ct,useMemo as K,useRef as Pe,useState as ae}from"react";import{cn as g}from"../../lib/cn.js";import{useUILabels as ut,useUILocale as gt}from"../../lib/i18n.js";import{jsx as o,jsxs as P}from"react/jsx-runtime";var ft=10080*60*1e3;function J(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function q(e){return J(e)?e:void 0}function f(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function L(e,r){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+r)}function x(e,r){return new Date(e.getFullYear(),e.getMonth()+r,1)}function be(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function k(e,r){return!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function me(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()}function R(e,r){return e.getFullYear()*12+e.getMonth()-(r.getFullYear()*12+r.getMonth())}function re(e){let r=`${e.getMonth()+1}`.padStart(2,"0"),d=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${d}`}function yt(e){let r=f(e);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let d=new Date(r.getFullYear(),0,4);return d.setDate(d.getDate()-(d.getDay()+6)%7+3),1+Math.round((r.getTime()-d.getTime())/ft)}function mt(e){return yt(e.find(r=>r.getDay()===4)??e[0])}function Ye(e,r,d){return r&&e<f(r)?f(r):d&&e>f(d)?f(d):e}function bt(e,r,d){let z=V(e),j=(z.getDay()-r+7)%7,O=L(z,-j),oe=d?6:Math.ceil((j+be(e))/7);return Array.from({length:oe},(pe,Q)=>Array.from({length:7},(he,A)=>L(O,Q*7+A)))}function pt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function ht({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var Dt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},xt={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},vt={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},kt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},wt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function ne(e,r){if(e==="multiple")return Array.isArray(r)?r.filter(J).map(f):[];if(e==="range"){let d=r??null;return{from:J(d?.from)?f(d.from):null,to:J(d?.to)?f(d.to):null}}return J(r)?f(r):null}function Te(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Ft(e){let{mode:r="single",value:d,defaultValue:z,onChange:j,max:O,month:oe,defaultMonth:pe,onMonthChange:Q,numberOfMonths:he=1,weekStartsOn:A=0,locale:Le,today:Ae,size:Ee="md",color:w="primary",minDate:Be,maxDate:Ie,disabledDates:$,disabled:y=!1,showOutsideDays:We=!0,showWeekNumbers:De=!1,fixedWeeks:Ve=!1,captionLayout:H="label",fromYear:X,toYear:Z,todayButton:le=!1,clearButton:se=!1,footer:xe,bordered:ze=!0,renderDay:ve,labels:E,className:_e,...Ke}=e,B=ut(),Y=gt(Le),p=Dt[Ee],D=Math.max(1,he),ie=q(oe),ke=q(pe),M=q(Be),S=q(Ie),de=q(Ae)?.getTime(),m=K(()=>f(de===void 0?new Date:new Date(de)),[de]),ce=d!==void 0,[je,Oe]=ae(()=>ne(r,z)),C=ce?ne(r,d):je,ue=ie!==void 0,[$e,He]=ae(()=>V(ke??Te(ne(r,z??d))??m)),c=ue?V(ie):$e,h=v(t=>{let a=V(t);ue||He(a),Q?.(a)},[ue,Q]),we=Pe(null),ge=Pe(!1),[I,ee]=ae(()=>{let t=Te(ne(r,z??d)),a=V(ke??ie??t??m),u=t&&me(t,a)?t:me(m,a)?m:a;return Ye(u,M,S)}),Ue=x(c,D-1),Ge=R(I,c)>=0&&R(I,Ue)<=0?I:c;ct(()=>{if(!ge.current)return;ge.current=!1,we.current?.querySelector(`[data-day="${re(I)}"]:not([data-outside])`)?.focus()},[I,c]);let T=v(t=>{let a=Ye(f(t),M,S);ge.current=!0,ee(a);let u=x(c,D-1);R(a,c)<0?h(a):R(a,u)>0&&h(x(a,-(D-1)))},[c,D,M,S,h]),_=v(t=>y||M&&t<f(M)||S&&t>f(S)?!0:typeof $=="function"?$(t):Array.isArray($)?$.some(a=>k(a,t)):!1,[y,M,S,$]),[fe,Ce]=ae(null),N=v(t=>{ce||Oe(t),j?.(t)},[ce,j]),te=v(t=>{let a=f(t);if(_(a))return;if(r==="multiple"){let l=C??[];if(l.some(n=>k(n,a))){N(l.filter(n=>!k(n,a)));return}if(O!==void 0&&l.length>=O)return;N([...l,a].sort((n,i)=>n.getTime()-i.getTime()));return}if(r==="range"){let l=C??{from:null,to:null};if(!l.from||l.to){N({from:a,to:null});return}N(a<l.from?{from:a,to:l.from}:{from:l.from,to:a});return}N(k(C,a)?null:a)},[r,C,O,N,_]),qe=v(t=>{te(t),ee(f(t)),R(t,c)<0?h(t):R(t,x(c,D-1))>0&&h(x(t,-(D-1)))},[te,c,D,h]),Me=H==="dropdown"&&X!==void 0?new Date(X,0,1):null,Se=H==="dropdown"&&Z!==void 0?new Date(Z,11,1):null,Ne=!y&&(!M||R(c,V(M))>0)&&(!Me||R(c,Me)>0),Fe=!y&&(!S||R(x(c,D-1),V(S))<0)&&(!Se||R(x(c,D-1),Se)<0),Je=v(()=>{h(x(c,-1))},[c,h]),Qe=v(()=>{h(x(c,1))},[c,h]),Xe=v(t=>{if(y)return;let a=I;switch(t.key){case"ArrowLeft":t.preventDefault(),T(L(a,-1));break;case"ArrowRight":t.preventDefault(),T(L(a,1));break;case"ArrowUp":t.preventDefault(),T(L(a,-7));break;case"ArrowDown":t.preventDefault(),T(L(a,7));break;case"Home":t.preventDefault(),T(L(a,-((a.getDay()-A+7)%7)));break;case"End":t.preventDefault(),T(L(a,6-(a.getDay()-A+7)%7));break;case"PageUp":{t.preventDefault();let u=t.shiftKey?-12:-1,l=x(a,u),b=Math.min(a.getDate(),be(l));T(new Date(l.getFullYear(),l.getMonth(),b));break}case"PageDown":{t.preventDefault();let u=t.shiftKey?12:1,l=x(a,u),b=Math.min(a.getDate(),be(l));T(new Date(l.getFullYear(),l.getMonth(),b));break}default:break}},[y,I,T,A]),Ze=K(()=>{let t=new Intl.DateTimeFormat(Y,{weekday:"short"}),a=new Intl.DateTimeFormat(Y,{weekday:"long"}),u=new Date(2024,0,7);return Array.from({length:7},(l,b)=>{let n=L(u,(A+b)%7);return{short:t.format(n),long:a.format(n)}})},[Y,A]),et=K(()=>{let t=new Intl.DateTimeFormat(Y,{month:"long"});return Array.from({length:12},(a,u)=>t.format(new Date(2024,u,1)))},[Y]),Re=K(()=>new Intl.DateTimeFormat(Y,{month:"long",year:"numeric"}),[Y]),tt=K(()=>new Intl.DateTimeFormat(Y,{dateStyle:"full"}),[Y]),at=K(()=>{if(H!=="dropdown")return[];let t=m.getFullYear(),a=X??M?.getFullYear()??t-100,u=Z??S?.getFullYear()??t+10,l=u<a?[a]:Array.from({length:u-a+1},(n,i)=>a+i),b=Array.from({length:D},(n,i)=>x(c,i).getFullYear());return[...new Set([...l,...b])].sort((n,i)=>n-i)},[H,X,Z,M,S,m,c,D]),F=r==="range"?C:null,rt=F&&F.from&&!F.to&&fe&&fe>F.from?fe:null,U=F?.to??rt,nt=v((t,a)=>{let u=!me(t,a),l=_(t),b=!1,n=!1,i=!1,s=!1;return r==="multiple"?b=(C??[]).some(G=>k(G,t)):r==="range"?(n=k(F?.from,t),i=k(U,t),b=n||i,s=!!(F?.from&&U&&t>F.from&&t<U)):b=k(C,t),{selected:b,today:k(t,m),outside:u,disabled:l,rangeStart:n,rangeEnd:i,inRange:s}},[r,C,F,U,_,m]),ot=t=>{let a=x(c,t),u=bt(a,A,Ve),l=t===0,b=t===D-1;return P("div",{className:"flex flex-col",children:[P("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:Je,disabled:!Ne,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:g("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[w],p.nav,!Ne&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(pt,{className:p.icon})}),H==="dropdown"?P("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:a.getMonth(),disabled:y,onChange:n=>h(new Date(a.getFullYear(),Number(n.target.value)-t,1)),className:g("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[w],p.select,y&&"cursor-not-allowed opacity-50"),children:et.map((n,i)=>o("option",{value:i,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:a.getFullYear(),disabled:y,onChange:n=>h(new Date(Number(n.target.value),a.getMonth()-t,1)),className:g("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[w],p.select,y&&"cursor-not-allowed opacity-50"),children:at.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:g("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:Re.format(a)}),o("button",{type:"button",onClick:Qe,disabled:!Fe,"aria-label":E?.nextMonth??B.calendarNextMonth,className:g("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[w],p.nav,!Fe&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:o(ht,{className:p.icon})})]}),P("table",{role:"grid","aria-label":Re.format(a),onKeyDown:Xe,className:"border-collapse",children:[o("thead",{children:P("tr",{children:[De&&P("th",{scope:"col",className:g("font-normal text-gray-500 dark:text-gray-400",p.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),Ze.map(n=>o("th",{scope:"col",abbr:n.long,className:g("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:n.short},n.long))]})}),o("tbody",{children:u.map(n=>P("tr",{children:[De&&o("td",{className:g("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:mt(n)}),n.map(i=>{let s=nt(i,a),G=re(i);if(s.outside&&!We)return o("td",{className:"p-0"},G);let dt=k(i,Ge)&&!s.outside,ye=s.inRange||s.rangeStart&&!!U||s.rangeEnd&&!!F?.from;return o("td",{role:"presentation",className:g("p-0",ye&&vt[w],ye&&s.rangeStart&&"rounded-l-full",ye&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":G,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:dt?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":tt.format(i),onClick:()=>{s.disabled||qe(i)},onMouseEnter:()=>r==="range"&&Ce(f(i)),onMouseLeave:()=>r==="range"&&Ce(null),onFocus:()=>ee(f(i)),className:g("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[w],p.day,s.selected?xt[w]:s.inRange?g(kt[w],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?g(wt[w],"hover:bg-gray-100 dark:hover:bg-gray-700"):g("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:ve?ve(i,s):i.getDate()})},G)})]},re(n[0])))})]})]},re(a))},lt=v(()=>{if(h(m),ee(m),_(m))return;(r==="multiple"?(C??[]).some(a=>k(a,m)):r==="single"&&k(C,m))||te(m)},[m,h,_,te,r,C]),st=v(()=>{N(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,N]),it=!!xe||le||se;return P("div",{ref:we,className:g("inline-block bg-white dark:bg-gray-900",ze&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",_e),...Ke,children:[o("div",{className:g("flex flex-wrap",p.gap),children:Array.from({length:D},(t,a)=>ot(a))}),it&&P("div",{className:g("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:xe}),(le||se)&&P("div",{className:"flex items-center gap-2",children:[le&&o("button",{type:"button",onClick:lt,disabled:y,className:g("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[w],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),se&&o("button",{type:"button",onClick:st,disabled:y,className:g("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[w],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{Ft as Calendar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var ae=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var ve=(o,n)=>{for(var u in n)ae(o,u,{get:n[u],enumerable:!0})},Le=(o,n,u,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of we(n))!xe.call(o,c)&&c!==u&&ae(o,c,{get:()=>n[c],enumerable:!(r=ke(n,c))||r.enumerable});return o};var Pe=o=>Le(ae({},"__esModule",{value:!0}),o);var Te={};ve(Te,{CandlestickChart:()=>He});module.exports=Pe(Te);var s=require("react"),z=require("../../lib/i18n.cjs"),oe=require("../chart/ChartAxis.cjs"),he=require("../chart/ChartContainer.cjs"),ue=require("../chart/ChartGrid.cjs"),ge=require("../chart/ChartLegend.cjs"),T=require("../chart/ChartPlotClip.cjs"),de=require("../chart/ChartTableView.cjs"),me=require("../chart/ChartTooltip.cjs"),J=require("../chart/palette.cjs"),V=require("../chart/utils/cartesian.cjs"),v=require("../chart/utils/data.cjs"),Q=require("../chart/utils/format.cjs"),fe=require("../chart/utils/keyboard.cjs"),pe=require("../chart/utils/path.cjs"),be=require("../chart/utils/scales.cjs"),ye=require("../chart/utils/ticks.cjs"),Ce=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),Re=16,Ne=1.5,Se=(0,s.memo)(function({candles:n,clipId:u}){return(0,e.jsx)("g",{clipPath:`url(#${u})`,children:n.map(r=>(0,e.jsxs)("g",{children:[r.wick?(0,e.jsx)("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?(0,e.jsx)("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Ie({width:o,height:n,data:u,candles:r,x:c,y,grid:L,size:E,candleSize:G,fillRising:P,palette:X,referenceLines:R,margin:_,tooltip:f,plotLabel:ee,formatValue:p,formatX:K,onCandleClick:C,locale:N}){let[M,S]=(0,s.useState)(null),g=M!==null&&M<r.length?M:null,k=(0,z.useUILabels)(),B=(0,T.plotClipId)((0,s.useId)()),t=(0,s.useMemo)(()=>{let a=r.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),l=(0,V.buildCartesianGeometry)({locale:N,width:o,height:n,data:u,x:c,y,bounds:(0,V.widenBounds)((0,ye.extent)(a),(0,V.annotationValues)(u,c.key,R,void 0)),margin:_,orientation:"vertical",placement:"band",formatValue:p,formatX:K,defaultIncludeZero:!1}),{valueScale:b,bandwidth:W,categoryPositions:O,innerWidth:Y,innerHeight:U}=l,I=Math.min(G??Re,Math.max(1,W-2));return{rendered:r.map((i,w)=>{let d=O[w]+(W-I)/2,F=d+I/2,H=i.rising?X.up:X.down,j=i.high===null||i.low===null?null:{x:F,y1:b(i.high),y2:b(i.low)},x=null;if(i.open!==null&&i.close!==null){let Z=b(i.open),q=b(i.close);x=(0,pe.buildBarPath)({x:d,y:Math.min(Z,q),width:I,height:Math.max(Ne,Math.abs(q-Z)),radius:0,round:"none"})}return{key:`${w}`,color:H,body:x,hollow:i.rising&&!P,wick:j,left:d,width:I}}),categoryPositions:O,categoryCenters:l.categoryCenters,bandwidth:W,categoryTicks:l.categoryTicks,valueTicks:l.valueTicks,valueScale:b,innerWidth:Y,innerHeight:U,margin:l.margin}},[N,r,u,c,y,o,n,_,G,P,X,R,p,K]),te=(0,s.useCallback)(a=>{if(f===!1||r.length===0)return;let l=a.currentTarget.getBoundingClientRect(),b=a.clientX-l.left-t.margin.left;S((0,be.nearestIndex)(t.categoryCenters,b))},[f,r.length,t.margin.left,t.categoryCenters]),A=(0,s.useCallback)(()=>{!C||g===null||C(r[g])},[C,g,r]),re=(0,s.useCallback)(a=>(0,fe.handleChartKeyDown)(a,{count:r.length,current:g,axis:"x",onMove:S,pick:C?A:null}),[r.length,g,C,A]),h=g===null?null:r[g];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":ee??r.map(a=>a.label).join(", "),tabIndex:0,className:`${Ce.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:te,onPointerLeave:()=>S(null),onKeyDown:re,onBlur:()=>S(null),onClick:A,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(T.ChartPlotClip,{id:B,width:t.innerWidth,height:t.innerHeight,bleed:1}),(0,e.jsx)(ue.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:L==="y"||L==="both"?t.valueTicks.map(a=>a.offset):void 0}),g!==null?(0,e.jsx)("rect",{x:t.categoryPositions[g],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,R?.map(a=>{let l=t.valueScale(a.value);return(0,T.isOnPlot)(l,t.innerHeight)?(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:l,x2:t.innerWidth,y2:l,stroke:a.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:a.dashed===!1?void 0:"4 4"}),a.label?(0,e.jsx)("text",{x:t.innerWidth,y:l-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:a.label}):null]},`${a.value}-${a.label??""}`):null}),(0,e.jsx)(Se,{candles:t.rendered,clipId:B})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:c.hidden?null:(0,e.jsx)(oe.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:c.label,size:E})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:(0,e.jsx)(oe.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:E})})]}),h&&g!==null&&f!==!1?(0,e.jsx)(me.ChartTooltip,{x:t.margin.left+t.categoryCenters[g],y:t.margin.top+(h.high===null?t.innerHeight/2:t.valueScale(h.high)),containerWidth:o,children:typeof f=="function"?f(h):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:h.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,h.open],[k.chartHigh,h.high],[k.chartLow,h.low],[k.chartClose,h.close]].map(([a,l])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:a}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:l===null?"\u2014":p(l)})]},a))}),h.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:h.rising?k.chartRise:k.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[h.change>0?"+":"",p(h.change)]})]})]})}):null]})}function He({data:o,x:n,y:u,open:r,high:c,low:y,close:L,candleSize:E,fillRising:G=!1,colors:P,referenceLines:X,height:R=300,width:_,size:f="md",grid:ee="y",legend:p,tooltip:K=!0,tableView:C=!1,title:N,description:M,loading:S=!1,emptyState:g,error:k=!1,errorState:B,onRetry:t,actions:te,margin:A,locale:re,plotLabel:h,openLabel:a,highLabel:l,lowLabel:b,closeLabel:W,riseLabel:O,fallLabel:Y,format:U,onCandleClick:I,className:le,...i}){let w=(0,z.useUILocale)(re),d=(0,z.useUILabels)(),F=(0,s.useMemo)(()=>u?.format??U??(m=>(0,Q.formatAuto)(m,w)),[u?.format,U,w]),H=(0,s.useMemo)(()=>n.format??(m=>(0,Q.formatXValue)(m,w)),[n.format,w]),j=(0,s.useMemo)(()=>o.map((m,ne)=>{let ce=(0,v.readXValue)(m,n.key,ne),D=(0,v.readNumber)(m,r),$=(0,v.readNumber)(m,L);return{index:ne,x:ce,label:H(ce,ne),open:D,high:(0,v.readNumber)(m,c),low:(0,v.readNumber)(m,y),close:$,change:D===null||$===null?null:$-D,rising:D===null||$===null?!0:$>=D,datum:m}}),[o,n.key,r,c,y,L,H]),x=(0,s.useMemo)(()=>({up:P?.up??J.CHART_UP_COLOR,down:P?.down??J.CHART_DOWN_COLOR}),[P]),Z=(0,s.useMemo)(()=>[{key:"up",label:O??d.chartRise,color:x.up,marker:"rect"},{key:"down",label:Y??d.chartFall,color:x.down,marker:"rect"}],[x,O,Y,d.chartRise,d.chartFall]),q=p===void 0?!0:p!==!1,ie=typeof p=="string"?p:"bottom",se=[{key:r,label:a??d.chartOpen},{key:c,label:l??d.chartHigh},{key:y,label:b??d.chartLow},{key:L,label:W??d.chartClose}];return(0,e.jsx)(he.ChartContainer,{title:N,description:M,height:R,width:_,size:f,loading:S,empty:j.length===0,emptyState:g,error:k,errorState:B,onRetry:t,actions:te,exportSource:{data:o,series:se,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:C,legendPosition:ie,legend:q?(0,e.jsx)(ge.ChartLegend,{items:Z,position:ie,marker:"rect",size:f}):void 0,table:C?(0,e.jsx)(de.ChartTableView,{data:o,series:se,xKey:n.key,xLabel:n.label??n.key,formatX:H,formatValue:F,caption:typeof N=="string"?N:void 0}):void 0,className:le,...i,children:({width:m})=>(0,e.jsx)(Ie,{locale:w,width:m,height:R,data:o,candles:j,x:n,y:u,grid:ee,size:f,candleSize:E,fillRising:G,palette:x,referenceLines:X,margin:A,tooltip:K,plotLabel:h,formatValue:F,formatX:H,onCandleClick:I})})}0&&(module.exports={CandlestickChart});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as
|
|
1
|
+
"use client";import{memo as ie,useCallback as ee,useId as se,useMemo as H,useState as ce}from"react";import{useUILabels as le,useUILocale as he}from"../../lib/i18n.js";import{ChartAxis as oe}from"../chart/ChartAxis.js";import{ChartContainer as ue}from"../chart/ChartContainer.js";import{ChartGrid as ge}from"../chart/ChartGrid.js";import{ChartLegend as de}from"../chart/ChartLegend.js";import{ChartPlotClip as me,isOnPlot as fe,plotClipId as pe}from"../chart/ChartPlotClip.js";import{ChartTableView as be}from"../chart/ChartTableView.js";import{ChartTooltip as ye}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as Ce,CHART_UP_COLOR as ke}from"../chart/palette.js";import{annotationValues as we,buildCartesianGeometry as xe,widenBounds as ve}from"../chart/utils/cartesian.js";import{readNumber as j,readXValue as Le}from"../chart/utils/data.js";import{formatAuto as Pe,formatXValue as Re}from"../chart/utils/format.js";import{handleChartKeyDown as Ne}from"../chart/utils/keyboard.js";import{buildBarPath as Se}from"../chart/utils/path.js";import{nearestIndex as Ie}from"../chart/utils/scales.js";import{extent as He}from"../chart/utils/ticks.js";import{CHART_TOUCH as Te}from"../chart/utils/touch.js";import{Fragment as We,jsx as n,jsxs as b}from"react/jsx-runtime";var Ve=16,Xe=1.5,Me=ie(function({candles:a,clipId:g}){return n("g",{clipPath:`url(#${g})`,children:a.map(t=>b("g",{children:[t.wick?n("line",{x1:t.wick.x,y1:t.wick.y1,x2:t.wick.x,y2:t.wick.y2,stroke:t.color,strokeWidth:1.5}):null,t.body?n("path",{d:t.body,fill:t.hollow?"none":t.color,stroke:t.color,strokeWidth:t.hollow?1.5:0}):null]},t.key))})});function Ae({width:u,height:a,data:g,candles:t,x:d,y,grid:v,size:D,candleSize:$,fillRising:L,palette:T,referenceLines:P,margin:z,tooltip:m,plotLabel:Z,formatValue:f,formatX:E,onCandleClick:C,locale:R}){let[V,N]=ce(null),s=V!==null&&V<t.length?V:null,k=le(),G=pe(se()),e=H(()=>{let r=t.flatMap(l=>l.high===null||l.low===null?[]:[l.low,l.high]),o=xe({locale:R,width:u,height:a,data:g,x:d,y,bounds:ve(He(r),we(g,d.key,P,void 0)),margin:z,orientation:"vertical",placement:"band",formatValue:f,formatX:E,defaultIncludeZero:!1}),{valueScale:p,bandwidth:M,categoryPositions:A,innerWidth:_,innerHeight:K}=o,S=Math.min($??Ve,Math.max(1,M-2));return{rendered:t.map((l,w)=>{let c=A[w]+(M-S)/2,B=c+S/2,I=l.rising?T.up:T.down,Y=l.high===null||l.low===null?null:{x:B,y1:p(l.high),y2:p(l.low)},x=null;if(l.open!==null&&l.close!==null){let U=p(l.open),F=p(l.close);x=Se({x:c,y:Math.min(U,F),width:S,height:Math.max(Xe,Math.abs(F-U)),radius:0,round:"none"})}return{key:`${w}`,color:I,body:x,hollow:l.rising&&!L,wick:Y,left:c,width:S}}),categoryPositions:A,categoryCenters:o.categoryCenters,bandwidth:M,categoryTicks:o.categoryTicks,valueTicks:o.valueTicks,valueScale:p,innerWidth:_,innerHeight:K,margin:o.margin}},[R,t,g,d,y,u,a,z,$,L,T,P,f,E]),q=ee(r=>{if(m===!1||t.length===0)return;let o=r.currentTarget.getBoundingClientRect(),p=r.clientX-o.left-e.margin.left;N(Ie(e.categoryCenters,p))},[m,t.length,e.margin.left,e.categoryCenters]),X=ee(()=>{!C||s===null||C(t[s])},[C,s,t]),J=ee(r=>Ne(r,{count:t.length,current:s,axis:"x",onMove:N,pick:C?X:null}),[t.length,s,C,X]),i=s===null?null:t[s];return b(We,{children:[b("svg",{width:u,height:a,role:"img","aria-label":Z??t.map(r=>r.label).join(", "),tabIndex:0,className:`${Te} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:q,onPointerLeave:()=>N(null),onKeyDown:J,onBlur:()=>N(null),onClick:X,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[n(me,{id:G,width:e.innerWidth,height:e.innerHeight,bleed:1}),n(ge,{width:e.innerWidth,height:e.innerHeight,horizontal:v==="y"||v==="both"?e.valueTicks.map(r=>r.offset):void 0}),s!==null?n("rect",{x:e.categoryPositions[s],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,P?.map(r=>{let o=e.valueScale(r.value);return fe(o,e.innerHeight)?b("g",{children:[n("line",{x1:0,y1:o,x2:e.innerWidth,y2:o,stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?n("text",{x:e.innerWidth,y:o-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`):null}),n(Me,{candles:e.rendered,clipId:G})]}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:d.hidden?null:n(oe,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:d.label,size:D})}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:n(oe,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:D})})]}),i&&s!==null&&m!==!1?n(ye,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(i.high===null?e.innerHeight/2:e.valueScale(i.high)),containerWidth:u,children:typeof m=="function"?m(i):b("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:i.label}),n("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,i.open],[k.chartHigh,i.high],[k.chartLow,i.low],[k.chartClose,i.close]].map(([r,o])=>b("div",{className:"contents",children:[n("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),n("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:o===null?"\u2014":f(o)})]},r))}),i.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[n("span",{className:"text-gray-500 dark:text-gray-400",children:i.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[i.change>0?"+":"",f(i.change)]})]})]})}):null]})}function tt({data:u,x:a,y:g,open:t,high:d,low:y,close:v,candleSize:D,fillRising:$=!1,colors:L,referenceLines:T,height:P=300,width:z,size:m="md",grid:Z="y",legend:f,tooltip:E=!0,tableView:C=!1,title:R,description:V,loading:N=!1,emptyState:s,error:k=!1,errorState:G,onRetry:e,actions:q,margin:X,locale:J,plotLabel:i,openLabel:r,highLabel:o,lowLabel:p,closeLabel:M,riseLabel:A,fallLabel:_,format:K,onCandleClick:S,className:te,...l}){let w=he(J),c=le(),B=H(()=>g?.format??K??(h=>Pe(h,w)),[g?.format,K,w]),I=H(()=>a.format??(h=>Re(h,w)),[a.format,w]),Y=H(()=>u.map((h,Q)=>{let ae=Le(h,a.key,Q),W=j(h,t),O=j(h,v);return{index:Q,x:ae,label:I(ae,Q),open:W,high:j(h,d),low:j(h,y),close:O,change:W===null||O===null?null:O-W,rising:W===null||O===null?!0:O>=W,datum:h}}),[u,a.key,t,d,y,v,I]),x=H(()=>({up:L?.up??ke,down:L?.down??Ce}),[L]),U=H(()=>[{key:"up",label:A??c.chartRise,color:x.up,marker:"rect"},{key:"down",label:_??c.chartFall,color:x.down,marker:"rect"}],[x,A,_,c.chartRise,c.chartFall]),F=f===void 0?!0:f!==!1,re=typeof f=="string"?f:"bottom",ne=[{key:t,label:r??c.chartOpen},{key:d,label:o??c.chartHigh},{key:y,label:p??c.chartLow},{key:v,label:M??c.chartClose}];return n(ue,{title:R,description:V,height:P,width:z,size:m,loading:N,empty:Y.length===0,emptyState:s,error:k,errorState:G,onRetry:e,actions:q,exportSource:{data:u,series:ne,xKey:a.key,xLabel:a.label??a.key,formatX:a.format},tableView:C,legendPosition:re,legend:F?n(de,{items:U,position:re,marker:"rect",size:m}):void 0,table:C?n(be,{data:u,series:ne,xKey:a.key,xLabel:a.label??a.key,formatX:I,formatValue:B,caption:typeof R=="string"?R:void 0}):void 0,className:te,...l,children:({width:h})=>n(Ae,{locale:w,width:h,height:P,data:u,candles:Y,x:a,y:g,grid:Z,size:m,candleSize:D,fillRising:$,palette:x,referenceLines:T,margin:X,tooltip:E,plotLabel:i,formatValue:B,formatX:I,onCandleClick:S})})}export{tt as CandlestickChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var a in r)s(e,a,{get:r[a],enumerable:!0})},N=(e,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!R.call(e,n)&&n!==a&&s(e,n,{get:()=>r[n],enumerable:!(t=P(r,n))||t.enumerable});return e};var z=e=>N(s({},"__esModule",{value:!0}),e);var q={};k(q,{Card:()=>i});module.exports=z(q);var o=require("../../lib/cn.cjs"),u=require("react/jsx-runtime");function B(e,r,a){let t=a||"bg-white dark:bg-gray-800",n=r||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return(0,o.cn)("border-2 bg-transparent",n);case"elevated":return(0,o.cn)("shadow-lg border-0",t);case"filled":return(0,o.cn)(a||"bg-gray-100 dark:bg-gray-700","border-0");default:return(0,o.cn)("border",n,t)}}function W(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function S(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function V(e){switch(e){case"none":return"";case"sm":return"p-2";case"lg":return"p-6";default:return""}}function i({variant:e="default",size:r="md",rounded:a="lg",padding:t="none",bgColor:n,borderColor:c,shadowColor:g,hoverable:m=!1,clickable:d=!1,as:f="div",className:p,children:C,onClick:l,...h}){let b=f,v=m?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",w=d?"cursor-pointer active:scale-[0.98] transition-transform":"",x=g||"";return(0,u.jsx)(b,{className:(0,o.cn)("overflow-hidden",B(e,c,n),W(r),S(a),V(t),v,w,x,p),onClick:d||l?l:void 0,...h,children:C})}i.displayName="Card";0&&(module.exports={Card});
|
|
1
|
+
"use strict";var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var a in r)s(e,a,{get:r[a],enumerable:!0})},N=(e,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!R.call(e,n)&&n!==a&&s(e,n,{get:()=>r[n],enumerable:!(t=P(r,n))||t.enumerable});return e};var z=e=>N(s({},"__esModule",{value:!0}),e);var q={};k(q,{Card:()=>i});module.exports=z(q);var o=require("../../lib/cn.cjs"),u=require("react/jsx-runtime");function B(e,r,a){let t=a||"bg-white dark:bg-gray-800",n=r||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return(0,o.cn)("border-2 bg-transparent",n);case"elevated":return(0,o.cn)("shadow-lg border-0",t);case"filled":return(0,o.cn)(a||"bg-gray-100 dark:bg-gray-700","border-0");default:return(0,o.cn)("border",n,t)}}function W(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function S(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function V(e){switch(e){case"none":return"";case"sm":return"p-2";case"md":return"p-4";case"lg":return"p-6";default:return""}}function i({variant:e="default",size:r="md",rounded:a="lg",padding:t="none",bgColor:n,borderColor:c,shadowColor:g,hoverable:m=!1,clickable:d=!1,as:f="div",className:p,children:C,onClick:l,...h}){let b=f,v=m?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",w=d?"cursor-pointer active:scale-[0.98] transition-transform":"",x=g||"";return(0,u.jsx)(b,{className:(0,o.cn)("overflow-hidden",B(e,c,n),W(r),S(a),V(t),v,w,x,p),onClick:d||l?l:void 0,...h,children:C})}i.displayName="Card";0&&(module.exports={Card});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as r}from"../../lib/cn.js";import{jsx as R}from"react/jsx-runtime";function v(e,o,n){let a=n||"bg-white dark:bg-gray-800",t=o||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return r("border-2 bg-transparent",t);case"elevated":return r("shadow-lg border-0",a);case"filled":return r(n||"bg-gray-100 dark:bg-gray-700","border-0");default:return r("border",t,a)}}function w(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function x(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function P(e){switch(e){case"none":return"";case"sm":return"p-2";case"lg":return"p-6";default:return""}}function y({variant:e="default",size:o="md",rounded:n="lg",padding:a="none",bgColor:t,borderColor:l,shadowColor:i,hoverable:u=!1,clickable:s=!1,as:c="div",className:g,children:m,onClick:d,...f}){let p=c,C=u?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",h=s?"cursor-pointer active:scale-[0.98] transition-transform":"",b=i||"";return R(p,{className:r("overflow-hidden",v(e,l,t),w(o),x(n),P(a),C,h,b,g),onClick:s||d?d:void 0,...f,children:m})}y.displayName="Card";export{y as Card};
|
|
1
|
+
import{cn as r}from"../../lib/cn.js";import{jsx as R}from"react/jsx-runtime";function v(e,o,n){let a=n||"bg-white dark:bg-gray-800",t=o||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return r("border-2 bg-transparent",t);case"elevated":return r("shadow-lg border-0",a);case"filled":return r(n||"bg-gray-100 dark:bg-gray-700","border-0");default:return r("border",t,a)}}function w(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function x(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function P(e){switch(e){case"none":return"";case"sm":return"p-2";case"md":return"p-4";case"lg":return"p-6";default:return""}}function y({variant:e="default",size:o="md",rounded:n="lg",padding:a="none",bgColor:t,borderColor:l,shadowColor:i,hoverable:u=!1,clickable:s=!1,as:c="div",className:g,children:m,onClick:d,...f}){let p=c,C=u?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",h=s?"cursor-pointer active:scale-[0.98] transition-transform":"",b=i||"";return R(p,{className:r("overflow-hidden",v(e,l,t),w(o),x(n),P(a),C,h,b,g),onClick:s||d?d:void 0,...f,children:m})}y.displayName="Card";export{y as Card};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var $=(t,r)=>{for(var e in r)N(t,e,{get:r[e],enumerable:!0})},w=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of M(r))!D.call(t,l)&&l!==e&&N(t,l,{get:()=>r[l],enumerable:!(i=_(r,l))||i.enumerable});return t};var B=t=>w(N({},"__esModule",{value:!0}),t);var V={};$(V,{ChartAnnotationLayer:()=>G,describeAnnotations:()=>L});module.exports=B(V);var m=require("./utils/text.cjs"),n=require("react/jsx-runtime"),A=10,C=15,x=5,d=6,b=4,E=.1;function I({x:t,y:r,text:e,align:i}){let l=(0,m.estimateTextWidth)(e,A)+x*2,g=i==="start"?t:t-l;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:g,y:r,width:l,height:C,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),(0,n.jsx)("text",{x:g+x,y:r+C/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:e})]})}function G({annotations:t,xAt:r,spanAt:e,yAt:i,width:l,height:g,bandwidth:T=0,layer:W="over"}){if(t.length===0)return null;if(W==="under"){let a=t.filter(s=>s.type==="band");return a.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:a.map((s,o)=>{let p=e??r,c=p(s.from),u=p(s.to);if(c===null||u===null)return null;let y=Math.max(0,Math.min(c,u)-T/2),f=Math.min(l,Math.max(c,u)+T/2)-y;if(f<=0)return null;let h=s.label??"",P=(0,m.estimateTextWidth)(h,A)+x*2;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:y,y:0,width:f,height:g,fill:s.color??"var(--color-chart-muted)",opacity:E}),h&&P<=f?(0,n.jsx)(I,{x:y+2,y:2,text:h,align:"start"}):null]},`band-${o}`)})})}let v=t.filter(a=>a.type!=="band");return v.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:v.map((a,s)=>{let o=r(a.x);if(o===null)return null;let p=a.color??"var(--color-chart-muted)";if(a.type==="line"){let h=a.label??"",P=(0,m.estimateTextWidth)(h,A)+x*2,O=o+d+P<=l?"start":"end";return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:o,y1:0,x2:o,y2:g,stroke:p,strokeWidth:1,strokeDasharray:a.dashed===!1?void 0:"3 3"}),h?(0,n.jsx)(I,{x:O==="start"?o+d:o-d,y:2,text:h,align:O}):null]},`line-${s}`)}let c=i(a.y);if(!Number.isFinite(c))return null;let u=a.label??"",y=(0,m.estimateTextWidth)(u,A)+x*2,k=o+b+d+y<=l?"start":"end",f=Math.min(Math.max(0,c-C-d),g-C);return(0,n.jsxs)("g",{children:[(0,n.jsx)("circle",{cx:o,cy:c,r:b,fill:"none",stroke:p,strokeWidth:2}),u?(0,n.jsx)(I,{x:k==="start"?o+b+d:o-b-d,y:f,text:u,align:k}):null]},`point-${s}`)})})}function L(t,r){if(!t||t.length===0)return"";let e=t.map(i=>i.label).filter(i=>!!i);return e.length===0?"":`${r}: ${e.join(", ")}`}0&&(module.exports={ChartAnnotationLayer,describeAnnotations});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{estimateTextWidth as b}from"./utils/text.js";import{jsx as e,jsxs as C}from"react/jsx-runtime";var A=10,k=15,m=5,
|
|
1
|
+
import{estimateTextWidth as b}from"./utils/text.js";import{jsx as e,jsxs as C}from"react/jsx-runtime";var A=10,k=15,m=5,h=6,x=4,_=.1;function I({x:n,y:a,text:o,align:i}){let d=b(o,A)+m*2,g=i==="start"?n:n-d;return C("g",{children:[e("rect",{x:g,y:a,width:d,height:k,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),e("text",{x:g+m,y:a+k/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:o})]})}function D({annotations:n,xAt:a,spanAt:o,yAt:i,width:d,height:g,bandwidth:T=0,layer:W="over"}){if(n.length===0)return null;if(W==="under"){let t=n.filter(l=>l.type==="band");return t.length===0?null:e("g",{"aria-hidden":"true",children:t.map((l,r)=>{let p=o??a,s=p(l.from),c=p(l.to);if(s===null||c===null)return null;let y=Math.max(0,Math.min(s,c)-T/2),f=Math.min(d,Math.max(s,c)+T/2)-y;if(f<=0)return null;let u=l.label??"",N=b(u,A)+m*2;return C("g",{children:[e("rect",{x:y,y:0,width:f,height:g,fill:l.color??"var(--color-chart-muted)",opacity:_}),u&&N<=f?e(I,{x:y+2,y:2,text:u,align:"start"}):null]},`band-${r}`)})})}let v=n.filter(t=>t.type!=="band");return v.length===0?null:e("g",{"aria-hidden":"true",children:v.map((t,l)=>{let r=a(t.x);if(r===null)return null;let p=t.color??"var(--color-chart-muted)";if(t.type==="line"){let u=t.label??"",N=b(u,A)+m*2,O=r+h+N<=d?"start":"end";return C("g",{children:[e("line",{x1:r,y1:0,x2:r,y2:g,stroke:p,strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"3 3"}),u?e(I,{x:O==="start"?r+h:r-h,y:2,text:u,align:O}):null]},`line-${l}`)}let s=i(t.y);if(!Number.isFinite(s))return null;let c=t.label??"",y=b(c,A)+m*2,P=r+x+h+y<=d?"start":"end",f=Math.min(Math.max(0,s-k-h),g-k);return C("g",{children:[e("circle",{cx:r,cy:s,r:x,fill:"none",stroke:p,strokeWidth:2}),c?e(I,{x:P==="start"?r+x+h:r-x-h,y:f,text:c,align:P}):null]},`point-${l}`)})})}function $(n,a){if(!n||n.length===0)return"";let o=n.map(i=>i.label).filter(i=>!!i);return o.length===0?"":`${a}: ${o.join(", ")}`}export{D as ChartAnnotationLayer,$ as describeAnnotations};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var V=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var O=(e,r)=>{for(var n in r)V(e,n,{get:r[n],enumerable:!0})},X=(e,r,n,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of T(r))!K.call(e,o)&&o!==n&&V(e,o,{get:()=>r[o],enumerable:!(l=M(r,o))||l.enumerable});return e};var N=e=>X(V({},"__esModule",{value:!0}),e);var q={};O(q,{ChartBrushLayer:()=>L,locateBrush:()=>_,useChartBrush:()=>W});module.exports=N(q);var c=require("react"),k=require("./utils/keyboard.cjs"),R=require("./utils/scales.cjs"),G=require("./utils/timestamp.cjs"),P=require("react/jsx-runtime"),U=4,Y=.14;function L({from:e,to:r,width:n,height:l,orientation:o="vertical",live:a=!1,label:s,minSpan:f=0}){let C=o==="vertical"?n:l,p=Math.min(e,r),m=Math.max(e,r);if(m-p<f){let h=(p+m)/2;p=h-f/2,m=h+f/2}let y=Math.max(0,p),g=Math.min(C,m),d=g-y;if(d<=0)return null;let b=o==="vertical",S=b?{x:y,y:0,width:d,height:l}:{x:0,y,width:n,height:d},B=h=>b?{x1:h,y1:0,x2:h,y2:l}:{x1:0,y1:h,x2:n,y2:h};return(0,P.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,P.jsx)("rect",{...S,className:"fill-synertech-primary-500",opacity:Y}),[y,g].map(h=>(0,P.jsx)("line",{...B(h),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:a?"3 3":void 0},h))]})}function _(e,r,n,l){let o=(f,C)=>f>=0&&f<r.length&&(0,R.toKey)(r[f])===(0,R.toKey)(C)?n[f]:null,a=o(e.fromIndex,e.from)??l(e.from),s=o(e.toIndex,e.to)??l(e.to);return a===null||s===null?null:{from:a,to:s}}function F(e,r){let n=r-e;if(!(n>0))return Number.NaN;let o=n/864e5,a=new Date(r),s=o>=28&&o<=31?1:o>=89&&o<=92?3:0;return s>0?(a.setMonth(a.getMonth()+s),a.getTime()):o>=365&&o<=366?(a.setFullYear(a.getFullYear()+1),a.getTime()):r+n}function H(e,r){let n=(0,G.toTimestamp)(e[r]);if(n===null)return;if(r+1<e.length)return(0,G.toTimestamp)(e[r+1])===null?void 0:e[r+1];if(r<1)return;let l=(0,G.toTimestamp)(e[r-1]);if(l===null)return;let o=F(l,n);return Number.isFinite(o)?new Date(o):void 0}function W({enabled:e,active:r,centers:n,xValues:l,offset:o,orientation:a,onCommit:s}){let[f,C]=(0,c.useState)(null),p=(0,c.useRef)(null),m=(0,c.useRef)(!1),y=(0,c.useRef)(!1),g=(0,c.useRef)(null),d=(0,c.useCallback)((t,u)=>{let[i,E]=t<=u?[t,u]:[u,t],v=H(l,E);return{from:l[i],to:l[E],fromIndex:i,toIndex:E,...v===void 0?{}:{end:v}}},[l]),b=(0,c.useCallback)(t=>{let u=t.currentTarget.getBoundingClientRect();return a==="vertical"?t.clientX-u.left-o:t.clientY-u.top-o},[a,o]),S=(0,c.useCallback)(t=>{if(!e||n.length===0||t.button!==0)return;let u=b(t),i=(0,R.nearestIndex)(n,u);i<0||(p.current={index:i,pixel:u},m.current=!1,y.current=!1,t.currentTarget.setPointerCapture?.(t.pointerId))},[e,n,b]),B=(0,c.useCallback)(t=>{let u=p.current;if(!e||!u)return;let i=b(t);!m.current&&Math.abs(i-u.pixel)<U||(m.current=!0,C(d(u.index,(0,R.nearestIndex)(n,i))))},[e,n,b,d]),h=(0,c.useCallback)(t=>{let u=p.current;if(p.current=null,!e||!u)return;if(t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture?.(t.pointerId),!m.current){C(null),r&&s(null);return}y.current=!0,m.current=!1;let i=d(u.index,(0,R.nearestIndex)(n,b(t)));C(null),g.current=i.fromIndex,s(i)},[e,r,n,b,d,s]),D=(0,c.useCallback)((t,u)=>{if(!e||n.length===0)return!1;if(t.key==="Escape"){g.current=null;let I=r||f!==null;return C(null),r&&s(null),I}if(!t.shiftKey)return g.current=null,!1;let i=a==="vertical",E=i?"ArrowRight":"ArrowDown",v=i?"ArrowLeft":"ArrowUp";if(t.key!==E&&t.key!==v)return!1;if(u===null)return g.current=null,!1;let A=(0,k.stepChartCursor)(u,t.key===E?1:-1,n.length),w=g.current??u;return g.current=w,s(d(w,A)),!1},[e,r,f,n.length,a,d,s]),x=(0,c.useCallback)(()=>{let t=y.current;return y.current=!1,t},[]);return{dragging:f,onPointerDown:S,onPointerMove:B,onPointerUp:h,onKeyDown:D,consumedClick:x}}0&&(module.exports={ChartBrushLayer,locateBrush,useChartBrush});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as C,useRef as P,useState as M}from"react";import{stepChartCursor as T}from"./utils/keyboard.js";import{nearestIndex as S,toKey as w}from"./utils/scales.js";import{toTimestamp as B}from"./utils/timestamp.js";import{jsx as k,jsxs as U}from"react/jsx-runtime";var K=4,O=.14;function H({from:r,to:t,width:n,height:s,orientation:u="vertical",live:l=!1,label:a,minSpan:i=0}){let b=u==="vertical"?n:s,d=Math.min(r,t),h=Math.max(r,t);if(h-d<i){let f=(d+h)/2;d=f-i/2,h=f+i/2}let p=Math.max(0,d),y=Math.min(b,h),m=y-p;if(m<=0)return null;let g=u==="vertical",v=g?{x:p,y:0,width:m,height:s}:{x:0,y:p,width:n,height:m},G=f=>g?{x1:f,y1:0,x2:f,y2:s}:{x1:0,y1:f,x2:n,y2:f};return U("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[k("rect",{...v,className:"fill-synertech-primary-500",opacity:O}),[p,y].map(f=>k("line",{...G(f),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:l?"3 3":void 0},f))]})}function W(r,t,n,s){let u=(i,b)=>i>=0&&i<t.length&&w(t[i])===w(b)?n[i]:null,l=u(r.fromIndex,r.from)??s(r.from),a=u(r.toIndex,r.to)??s(r.to);return l===null||a===null?null:{from:l,to:a}}function X(r,t){let n=t-r;if(!(n>0))return Number.NaN;let u=n/864e5,l=new Date(t),a=u>=28&&u<=31?1:u>=89&&u<=92?3:0;return a>0?(l.setMonth(l.getMonth()+a),l.getTime()):u>=365&&u<=366?(l.setFullYear(l.getFullYear()+1),l.getTime()):t+n}function N(r,t){let n=B(r[t]);if(n===null)return;if(t+1<r.length)return B(r[t+1])===null?void 0:r[t+1];if(t<1)return;let s=B(r[t-1]);if(s===null)return;let u=X(s,n);return Number.isFinite(u)?new Date(u):void 0}function q({enabled:r,active:t,centers:n,xValues:s,offset:u,orientation:l,onCommit:a}){let[i,b]=M(null),d=P(null),h=P(!1),p=P(!1),y=P(null),m=C((e,o)=>{let[c,R]=e<=o?[e,o]:[o,e],E=N(s,R);return{from:s[c],to:s[R],fromIndex:c,toIndex:R,...E===void 0?{}:{end:E}}},[s]),g=C(e=>{let o=e.currentTarget.getBoundingClientRect();return l==="vertical"?e.clientX-o.left-u:e.clientY-o.top-u},[l,u]),v=C(e=>{if(!r||n.length===0||e.button!==0)return;let o=g(e),c=S(n,o);c<0||(d.current={index:c,pixel:o},h.current=!1,p.current=!1,e.currentTarget.setPointerCapture?.(e.pointerId))},[r,n,g]),G=C(e=>{let o=d.current;if(!r||!o)return;let c=g(e);!h.current&&Math.abs(c-o.pixel)<K||(h.current=!0,b(m(o.index,S(n,c))))},[r,n,g,m]),f=C(e=>{let o=d.current;if(d.current=null,!r||!o)return;if(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture?.(e.pointerId),!h.current){b(null),t&&a(null);return}p.current=!0,h.current=!1;let c=m(o.index,S(n,g(e)));b(null),y.current=c.fromIndex,a(c)},[r,t,n,g,m,a]),D=C((e,o)=>{if(!r||n.length===0)return!1;if(e.key==="Escape"){y.current=null;let I=t||i!==null;return b(null),t&&a(null),I}if(!e.shiftKey)return y.current=null,!1;let c=l==="vertical",R=c?"ArrowRight":"ArrowDown",E=c?"ArrowLeft":"ArrowUp";if(e.key!==R&&e.key!==E)return!1;if(o===null)return y.current=null,!1;let A=T(o,e.key===R?1:-1,n.length),V=y.current??o;return y.current=V,a(m(V,A)),!1},[r,t,i,n.length,l,m,a]),x=C(()=>{let e=p.current;return p.current=!1,e},[]);return{dragging:i,onPointerDown:v,onPointerMove:G,onPointerUp:f,onKeyDown:D,consumedClick:x}}export{H as ChartBrushLayer,W as locateBrush,q as useChartBrush};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var x=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var _=(r,t)=>{for(var a in t)x(r,a,{get:t[a],enumerable:!0})},ee=(r,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!Y.call(r,o)&&o!==a&&x(r,o,{get:()=>t[o],enumerable:!(l=Q(t,o))||l.enumerable});return r};var te=r=>ee(x({},"__esModule",{value:!0}),r);var se={};_(se,{ChartContainer:()=>oe});module.exports=te(se);var c=require("react"),d=require("../../lib/cn.cjs"),P=require("../../lib/i18n.cjs"),I=require("../circular-progress/CircularProgress.cjs"),T=require("./exportSource.cjs"),z=require("./useChartSize.cjs"),e=require("react/jsx-runtime"),re=(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[(0,e.jsx)("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,e.jsx)("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),ae={sm:"text-xs",md:"text-sm",lg:"text-base"};function oe({title:r,description:t,height:a=240,width:l,size:o="md",legend:i,legendPosition:u="bottom",actions:g,exportSource:A,loading:n=!1,empty:y=!1,emptyState:j,error:f=!1,errorState:H,onRetry:v,errorLabel:W,errorHintLabel:B,retryLabel:D,table:m,tableView:C=!1,showTableLabel:M,hideTableLabel:O,noDataLabel:$,loadingLabel:U,ariaLabel:w,children:h,className:V,...Z}){let s=(0,P.useUILabels)(),[p,q]=(0,c.useState)(!1),b=(0,c.useId)(),N=`${b}-table`,k=`${b}-title`,L=`${b}-description`,{ref:F,width:G,measured:J}=(0,z.useChartSize)({width:l}),R=!!m&&C==="toggle",S=!!m&&(C===!0||R&&p),E=(0,e.jsx)("div",{ref:F,className:"relative w-full",style:{height:a},"aria-busy":n||void 0,children:n&&(y||f)?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,e.jsx)(I.CircularProgress,{indeterminate:!0,size:"md","aria-label":U??s.chartLoading})}):f&&!n?(0,e.jsx)("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:H??(0,e.jsxs)(e.Fragment,{children:[re,(0,e.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:W??s.chartError}),(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:B??s.chartErrorHint}),v?(0,e.jsx)("button",{type:"button",onClick:v,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:D??s.chartRetry}):null]})}):y&&!n&&!f?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:j??$??s.chartNoData}):(0,e.jsx)("div",{className:(0,d.cn)("h-full w-full transition-opacity duration-200",n&&"opacity-60"),children:typeof h=="function"?h({width:G,height:a,measured:J}):h})});return(0,e.jsxs)("figure",{className:(0,d.cn)("flex w-full flex-col gap-3",V),"aria-label":w,"aria-labelledby":!w&&r?k:void 0,"aria-describedby":t?L:void 0,...Z,children:[r||t||g?(0,e.jsxs)("figcaption",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r?(0,e.jsx)("span",{id:k,className:(0,d.cn)("font-semibold text-gray-900 dark:text-gray-100",ae[o]),children:r}):null,t?(0,e.jsx)("span",{id:L,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),(0,e.jsx)(T.ChartExportContext.Provider,{value:A??null,children:g})]}):null,i&&u==="top"?i:null,i&&u==="right"?(0,e.jsxs)("div",{className:"flex items-start gap-4",children:[(0,e.jsx)("div",{className:"min-w-0 grow",children:E}),i]}):E,i&&u==="bottom"?i:null,R&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsx)("button",{type:"button",onClick:()=>q(K=>!K),"aria-expanded":p,"aria-controls":S?N:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:text-gray-400 dark:hover:text-white",children:p?O??s.chartHideTable:M??s.chartShowTable})}),S&&(0,e.jsx)("div",{id:N,children:m})]})}0&&(module.exports={ChartContainer});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useId as
|
|
1
|
+
"use client";import{useId as q,useState as F}from"react";import{cn as m}from"../../lib/cn.js";import{useUILabels as G}from"../../lib/i18n.js";import{CircularProgress as J}from"../circular-progress/CircularProgress.js";import{ChartExportContext as K}from"./exportSource.js";import{useChartSize as Q}from"./useChartSize.js";import{Fragment as _,jsx as e,jsxs as a}from"react/jsx-runtime";var X=a("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[e("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),e("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),Y={sm:"text-xs",md:"text-sm",lg:"text-base"};function de({title:s,description:i,height:h=240,width:R,size:S="md",legend:r,legendPosition:n="bottom",actions:p,exportSource:E,loading:o=!1,empty:b=!1,emptyState:P,error:l=!1,errorState:I,onRetry:x,errorLabel:T,errorHintLabel:z,retryLabel:A,table:d,tableView:g=!1,showTableLabel:j,hideTableLabel:H,noDataLabel:W,loadingLabel:B,ariaLabel:y,children:c,className:D,...M}){let t=G(),[u,O]=F(!1),f=q(),v=`${f}-table`,C=`${f}-title`,w=`${f}-description`,{ref:$,width:U,measured:V}=Q({width:R}),N=!!d&&g==="toggle",k=!!d&&(g===!0||N&&u),L=e("div",{ref:$,className:"relative w-full",style:{height:h},"aria-busy":o||void 0,children:o&&(b||l)?e("div",{className:"flex h-full w-full items-center justify-center",children:e(J,{indeterminate:!0,size:"md","aria-label":B??t.chartLoading})}):l&&!o?e("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:I??a(_,{children:[X,e("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:T??t.chartError}),e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:z??t.chartErrorHint}),x?e("button",{type:"button",onClick:x,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:A??t.chartRetry}):null]})}):b&&!o&&!l?e("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:P??W??t.chartNoData}):e("div",{className:m("h-full w-full transition-opacity duration-200",o&&"opacity-60"),children:typeof c=="function"?c({width:U,height:h,measured:V}):c})});return a("figure",{className:m("flex w-full flex-col gap-3",D),"aria-label":y,"aria-labelledby":!y&&s?C:void 0,"aria-describedby":i?w:void 0,...M,children:[s||i||p?a("figcaption",{className:"flex items-start justify-between gap-3",children:[a("div",{className:"flex flex-col gap-0.5",children:[s?e("span",{id:C,className:m("font-semibold text-gray-900 dark:text-gray-100",Y[S]),children:s}):null,i?e("span",{id:w,className:"text-xs text-gray-500 dark:text-gray-400",children:i}):null]}),e(K.Provider,{value:E??null,children:p})]}):null,r&&n==="top"?r:null,r&&n==="right"?a("div",{className:"flex items-start gap-4",children:[e("div",{className:"min-w-0 grow",children:L}),r]}):L,r&&n==="bottom"?r:null,N&&e("div",{className:"flex",children:e("button",{type:"button",onClick:()=>O(Z=>!Z),"aria-expanded":u,"aria-controls":k?v:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:text-gray-400 dark:hover:text-white",children:u?H??t.chartHideTable:j??t.chartShowTable})}),k&&e("div",{id:v,children:d})]})}export{de as ChartContainer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var m=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},W=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!R.call(e,n)&&n!==s&&m(e,n,{get:()=>t[n],enumerable:!(i=j(t,n))||i.enumerable});return e};var q=e=>W(m({},"__esModule",{value:!0}),e);var H={};U(H,{ChartExportButton:()=>G});module.exports=q(H);var L=require("react"),F=require("../../lib/cn.cjs"),S=require("../../lib/i18n.cjs"),B=require("../dropdown/Dropdown.cjs"),I=require("../dropdown/DropdownContent.cjs"),N=require("../dropdown/DropdownItem.cjs"),O=require("../dropdown/DropdownTrigger.cjs"),z=require("./exportSource.cjs"),P=require("./utils/export.cjs"),o=require("react/jsx-runtime"),A={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},D=(0,o.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,o.jsx)("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function G({data:e,series:t,xKey:s,xLabel:i,formatX:n,neutralizeFormulas:g,formats:c=["csv","json"],filename:x="chart",size:K="md",label:M,onExport:d,className:T,disabled:u}){let l=(0,S.useUILabels)(),a=(0,z.useChartExportSource)(),h=e??a?.data??[],f=t??a?.series??[],p=s??a?.xKey,b=i??a?.xLabel,C=n??a?.formatX,y=(0,L.useCallback)(r=>{if(p===void 0)return;let k={data:h,series:f,xKey:p,xLabel:b,formatX:C,neutralizeFormulas:g};d?d(r,k):(0,P.downloadChartData)(r,k,x)},[h,f,p,b,C,g,d,x]),w=h.length===0||p===void 0,E=M??l.chartExport,X=r=>r==="csv"?l.chartExportCsv:l.chartExportJson,v=(0,F.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",A[K],T);if(c.length<=1){let r=c[0]??"csv";return(0,o.jsxs)("button",{type:"button",onClick:()=>y(r),disabled:u||w,className:v,children:[D,(0,o.jsx)("span",{children:E})]})}return(0,o.jsxs)(B.Dropdown,{children:[(0,o.jsxs)(O.DropdownTrigger,{disabled:u||w,className:v,children:[D,(0,o.jsx)("span",{children:E})]}),(0,o.jsx)(I.DropdownContent,{children:c.map(r=>(0,o.jsx)(N.DropdownItem,{onSelect:()=>y(r),children:X(r)},r))})]})}0&&(module.exports={ChartExportButton});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as I}from"react";import{cn as N}from"../../lib/cn.js";import{useUILabels as O}from"../../lib/i18n.js";import{Dropdown as z}from"../dropdown/Dropdown.js";import{DropdownContent as P}from"../dropdown/DropdownContent.js";import{DropdownItem as K}from"../dropdown/DropdownItem.js";import{DropdownTrigger as M}from"../dropdown/DropdownTrigger.js";import{useChartExportSource as T}from"./exportSource.js";import{downloadChartData as X}from"./utils/export.js";import{jsx as o,jsxs as p}from"react/jsx-runtime";var j={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},y=o("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:o("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function V({data:w,series:E,xKey:v,xLabel:k,formatX:D,neutralizeFormulas:c,formats:n=["csv","json"],filename:d="chart",size:L="md",label:F,onExport:s,className:S,disabled:l}){let a=O(),r=T(),i=w??r?.data??[],h=E??r?.series??[],e=v??r?.xKey,m=k??r?.xLabel,g=D??r?.formatX,x=I(t=>{if(e===void 0)return;let C={data:i,series:h,xKey:e,xLabel:m,formatX:g,neutralizeFormulas:c};s?s(t,C):X(t,C,d)},[i,h,e,m,g,c,s,d]),u=i.length===0||e===void 0,f=F??a.chartExport,B=t=>t==="csv"?a.chartExportCsv:a.chartExportJson,b=N("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",j[L],S);if(n.length<=1){let t=n[0]??"csv";return p("button",{type:"button",onClick:()=>x(t),disabled:l||u,className:b,children:[y,o("span",{children:f})]})}return p(z,{children:[p(M,{disabled:l||u,className:b,children:[y,o("span",{children:f})]}),o(P,{children:n.map(t=>o(K,{onSelect:()=>x(t),children:B(t)},t))})]})}export{V as ChartExportButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var C=(t,r)=>{for(var n in r)f(t,n,{get:r[n],enumerable:!0})},P=(t,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of h(r))!m.call(t,o)&&o!==n&&f(t,o,{get:()=>r[o],enumerable:!(i=b(r,o))||i.enumerable});return t};var $=t=>P(f({},"__esModule",{value:!0}),t);var R={};C(R,{CHART_PATTERNS:()=>k,CHART_SURFACE_COLOR:()=>s.CHART_SURFACE_COLOR,ChartPatternDefs:()=>S,getPattern:()=>g,patternBackground:()=>w,patternFill:()=>y,patternId:()=>p});module.exports=$(R);var s=require("./palette.cjs"),a=require("react/jsx-runtime");var k=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],x={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(t){return!Number.isFinite(t)||t<0?"solid":k[Math.floor(t)%k.length]}function p(t,r){return`${t.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(r))}`}function y(t,r,n,i){return!t||g(n)==="solid"?i:`url(#${p(r,n)})`}function S({id:t,entries:r}){return(0,a.jsx)("defs",{children:r.map(({slot:n,color:i})=>{let o=x[g(n)];if(!o)return null;let{tile:e,rotate:c,stroke:l,crossed:d,dot:u}=o;return(0,a.jsxs)("pattern",{id:p(t,n),width:e,height:e,patternUnits:"userSpaceOnUse",patternTransform:c===0?void 0:`rotate(${c})`,children:[(0,a.jsx)("rect",{width:e,height:e,fill:i}),u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("circle",{cx:e/4,cy:e/4,r:u,fill:s.CHART_SURFACE_COLOR}),(0,a.jsx)("circle",{cx:e*3/4,cy:e*3/4,r:u,fill:s.CHART_SURFACE_COLOR})]}):null,l>0?(0,a.jsx)("line",{x1:e/2,y1:0,x2:e/2,y2:e,stroke:s.CHART_SURFACE_COLOR,strokeWidth:l}):null,d?(0,a.jsx)("line",{x1:0,y1:e/2,x2:e,y2:e/2,stroke:s.CHART_SURFACE_COLOR,strokeWidth:l}):null]},p(t,n))})})}function w(t,r){let n=x[g(t)];if(!n)return{backgroundColor:r};let{tile:i,rotate:o,stroke:e,crossed:c,dot:l}=n;if(l)return{backgroundColor:r,backgroundImage:`radial-gradient(${s.CHART_SURFACE_COLOR} ${l-.4}px, transparent ${l}px)`,backgroundSize:`${i/2}px ${i/2}px`};let d=u=>`repeating-linear-gradient(${u}deg, ${s.CHART_SURFACE_COLOR} 0 ${e}px, transparent ${e}px ${i}px)`;return{backgroundColor:r,backgroundImage:c?`${d(o)}, ${d(o+90)}`:d(o)}}0&&(module.exports={CHART_PATTERNS,CHART_SURFACE_COLOR,ChartPatternDefs,getPattern,patternBackground,patternFill,patternId});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import{CHART_SURFACE_COLOR as l}from"./palette.js";import{Fragment as b,jsx as s,jsxs as k}from"react/jsx-runtime";var f=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],x={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(r){return!Number.isFinite(r)||r<0?"solid":f[Math.floor(r)%f.length]}function p(r,e){return`${r.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(e))}`}function m(r,e,n,o){return!r||g(n)==="solid"?o:`url(#${p(e,n)})`}function C({id:r,entries:e}){return s("defs",{children:e.map(({slot:n,color:o})=>{let i=x[g(n)];if(!i)return null;let{tile:t,rotate:c,stroke:a,crossed:d,dot:u}=i;return k("pattern",{id:p(r,n),width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:c===0?void 0:`rotate(${c})`,children:[s("rect",{width:t,height:t,fill:o}),u?k(b,{children:[s("circle",{cx:t/4,cy:t/4,r:u,fill:l}),s("circle",{cx:t*3/4,cy:t*3/4,r:u,fill:l})]}):null,a>0?s("line",{x1:t/2,y1:0,x2:t/2,y2:t,stroke:l,strokeWidth:a}):null,d?s("line",{x1:0,y1:t/2,x2:t,y2:t/2,stroke:l,strokeWidth:a}):null]},p(r,n))})})}function P(r,e){let n=x[g(r)];if(!n)return{backgroundColor:e};let{tile:o,rotate:i,stroke:t,crossed:c,dot:a}=n;if(a)return{backgroundColor:e,backgroundImage:`radial-gradient(${l} ${a-.4}px, transparent ${a}px)`,backgroundSize:`${o/2}px ${o/2}px`};let d=u=>`repeating-linear-gradient(${u}deg, ${l} 0 ${t}px, transparent ${t}px ${o}px)`;return{backgroundColor:e,backgroundImage:c?`${d(i)}, ${d(i+90)}`:d(i)}}export{f as CHART_PATTERNS,l as CHART_SURFACE_COLOR,C as ChartPatternDefs,g as getPattern,P as patternBackground,m as patternFill,p as patternId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var D=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ae=(n,o)=>{for(var l in o)D(n,l,{get:o[l],enumerable:!0})},ne=(n,o,l,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of re(o))!oe.call(n,d)&&d!==l&&D(n,d,{get:()=>o[d],enumerable:!(p=te(o,d))||p.enumerable});return n};var ie=n=>ne(D({},"__esModule",{value:!0}),n);var ue={};ae(ue,{ChartPeriodPicker:()=>le});module.exports=ie(ue);var t=require("react"),N=require("react-dom"),z=require("../../lib/aria-hide.cjs"),g=require("../../lib/owner-document.cjs"),P=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),A=require("../calendar/Calendar.cjs"),F=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),se={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},de={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ce=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function le({value:n,defaultValue:o,onChange:l,presets:p=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:U,now:f,minDate:W,maxDate:H,numberOfMonths:_=1,weekStartsOn:B,locale:K,size:q="md",align:Y="start",disabled:$=!1,label:L,className:Q,...j}){let C=(0,v.useUILabels)(),E=(0,v.useUILocale)(K),c=(0,t.useRef)(null),h=(0,t.useRef)(null),R=(0,t.useRef)(null),[i,w]=(0,t.useState)(!1),[M,S]=(0,t.useState)(!1),[G,O]=(0,t.useState)(null),[J,V]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,f):o||(0,a.createPeriod)(p[0]??"30d",f)),s=n??J,k=(0,F.usePositioning)({triggerRef:c,contentRef:h,isOpen:i,side:"bottom",align:Y}),u=(0,t.useCallback)((e=!0)=>{w(!1),S(!1),O(null),e&&c.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=b=>{let I=b.target;h.current?.contains(I)||c.current?.contains(I)||u(!1)},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("mousedown",e),m.addEventListener("touchstart",e,{passive:!0}),()=>{m.removeEventListener("mousedown",e),m.removeEventListener("touchstart",e)}},[i,u]),(0,t.useEffect)(()=>{if(!i)return;let e=b=>{b.key==="Escape"&&(b.stopPropagation(),u())},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("keydown",e),()=>m.removeEventListener("keydown",e)},[i,u]),(0,t.useEffect)(()=>{let e=h.current;if(e)return(0,z.registerFloatingLayer)(e,()=>c.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let y=(0,t.useCallback)(e=>{n===void 0&&V(e),l?.(e),u()},[n,l,u]),X=(0,t.useCallback)(e=>y((0,a.createPeriod)(e,f)),[y,f]),Z=(0,t.useCallback)(e=>{O(e),!(!e.from||!e.to)&&y({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[y]),x=e=>U?.[e]??C[se[e]],T=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,E):x(s.preset),ee=(0,r.jsxs)("div",{ref:h,role:"dialog","aria-label":L??C.chartPeriod,style:{position:"fixed",top:k.top,left:k.left,visibility:k.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[p.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>X(e),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x("custom")}):null]}),d&&M?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(A.Calendar,{mode:"range",value:G??{from:s.from,to:s.to},onChange:Z,numberOfMonths:_,weekStartsOn:B,locale:E,today:f,minDate:W,maxDate:H,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:c,type:"button",disabled:$,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${L??C.chartPeriod}: ${T}`,onClick:()=>i?u():w(!0),className:(0,P.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",de[q],Q),...j,children:[ce,(0,r.jsx)("span",{children:T})]}),i&&typeof document<"u"?(0,N.createPortal)(ee,(0,g.ownerDocumentOf)(c.current).body):null]})}0&&(module.exports={ChartPeriodPicker});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as m,useEffect as p,useRef as v,useState as f}from"react";import{createPortal as Z}from"react-dom";import{registerFloatingLayer as ee}from"../../lib/aria-hide.js";import{ownerDocumentOf as C}from"../../lib/owner-document.js";import{cn as k}from"../../lib/cn.js";import{useUILabels as te,useUILocale as re}from"../../lib/i18n.js";import{Calendar as oe}from"../calendar/Calendar.js";import{usePositioning as ae}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as ne,createPeriod as x,endOfDay as ie,formatPeriodRange as se,startOfDay as de}from"./utils/period.js";import{Fragment as me,jsx as i,jsxs as h}from"react/jsx-runtime";var ce={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},le={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ue=i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:i("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function ke({value:y,defaultValue:d,onChange:D,presets:L=ne,custom:E=!0,presetLabels:A,now:s,minDate:F,maxDate:U,numberOfMonths:W=1,weekStartsOn:H,locale:_,size:B="md",align:K="start",disabled:q=!1,label:R,className:Y,...$}){let b=te(),w=re(_),o=v(null),c=v(null),M=v(null),[t,S]=f(!1),[O,T]=f(!1),[Q,I]=f(null),[j,G]=f(()=>typeof d=="string"?x(d,s):d||x(L[0]??"30d",s)),r=y??j,g=ae({triggerRef:o,contentRef:c,isOpen:t,side:"bottom",align:K}),a=m((e=!0)=>{S(!1),T(!1),I(null),e&&o.current?.focus()},[]);p(()=>{if(!t)return;let e=u=>{let z=u.target;c.current?.contains(z)||o.current?.contains(z)||a(!1)},n=C(o.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[t,a]),p(()=>{if(!t)return;let e=u=>{u.key==="Escape"&&(u.stopPropagation(),a())},n=C(o.current);return n.addEventListener("keydown",e),()=>n.removeEventListener("keydown",e)},[t,a]),p(()=>{let e=c.current;if(e)return ee(e,()=>o.current)},[t]),p(()=>{if(!t)return;let e=requestAnimationFrame(()=>M.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let l=m(e=>{y===void 0&&G(e),D?.(e),a()},[y,D,a]),J=m(e=>l(x(e,s)),[l,s]),V=m(e=>{I(e),!(!e.from||!e.to)&&l({preset:"custom",from:de(e.from),to:ie(e.to)})},[l]),P=e=>A?.[e]??b[ce[e]],N=r.preset==="custom"?se(r.from,r.to,w):P(r.preset),X=h("div",{ref:c,role:"dialog","aria-label":R??b.chartPeriod,style:{position:"fixed",top:g.top,left:g.left,visibility:g.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[h("div",{ref:M,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[L.map(e=>i("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>J(e),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P(e)},e)),E?i("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":O,onClick:()=>T(!0),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P("custom")}):null]}),E&&O?i("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:i(oe,{mode:"range",value:Q??{from:r.from,to:r.to},onChange:V,numberOfMonths:W,weekStartsOn:H,locale:w,today:s,minDate:F,maxDate:U,size:"sm"})}):null]});return h(me,{children:[h("button",{ref:o,type:"button",disabled:q,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${R??b.chartPeriod}: ${N}`,onClick:()=>t?a():S(!0),className:k("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",le[B],Y),...$,children:[ue,i("span",{children:N})]}),t&&typeof document<"u"?Z(X,C(o.current).body):null]})}export{ke as ChartPeriodPicker};
|