@synertech/ui 0.46.3 → 0.47.1
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 +102 -3
- package/README.md +50 -0
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/badge/Badge.cjs +1 -1
- package/dist/components/badge/Badge.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/button/Button.cjs +1 -1
- package/dist/components/button/Button.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/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/ChartLegend.cjs +1 -1
- package/dist/components/chart/ChartLegend.js +1 -1
- package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
- package/dist/components/chart/ChartPeriodPicker.js +1 -1
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox/CheckboxGroup.cjs +1 -1
- package/dist/components/checkbox/CheckboxGroup.js +1 -1
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.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/dropdown/DropdownCheckboxItem.cjs +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
- package/dist/components/dropdown/DropdownRadio.cjs +1 -1
- package/dist/components/dropdown/DropdownRadio.js +1 -1
- package/dist/components/dropdown/DropdownTrigger.cjs +1 -1
- package/dist/components/dropdown/DropdownTrigger.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/FooterLink.cjs +1 -1
- package/dist/components/footer/FooterLink.js +1 -1
- package/dist/components/footer/FooterSocial.cjs +1 -1
- package/dist/components/footer/FooterSocial.js +1 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.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/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/help-button/HelpButton.cjs +6 -6
- package/dist/components/help-button/HelpButton.js +7 -7
- package/dist/components/help-button/sanitize-html.cjs +1 -0
- package/dist/components/help-button/sanitize-html.js +1 -0
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/indicator/Indicator.cjs +1 -1
- package/dist/components/indicator/Indicator.js +1 -1
- package/dist/components/label/Label.cjs +1 -1
- package/dist/components/label/Label.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/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.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/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sidebar/Sidebar.cjs +1 -1
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/tabs/TabsContent.cjs +1 -1
- package/dist/components/tabs/TabsContent.js +1 -1
- package/dist/components/tabs/TabsTrigger.cjs +1 -1
- package/dist/components/tabs/TabsTrigger.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/edges/WorkflowEdgeRenderer.cjs +1 -1
- package/dist/components/workflow-editor/edges/WorkflowEdgeRenderer.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/index.d.cts +170 -12
- package/dist/index.d.ts +170 -12
- package/dist/lib/safe-href.cjs +1 -0
- package/dist/lib/safe-href.js +1 -0
- package/dist/styles.css +618 -249
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var q=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var Ae=(a,o)=>{for(var c in o)q(a,c,{get:o[c],enumerable:!0})},Pe=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Oe(o))!Te.call(a,i)&&i!==c&&q(a,i,{get:()=>o[i],enumerable:!(l=Me(o,i))||l.enumerable});return a};var Re=a=>Pe(q({},"__esModule",{value:!0}),a);var je={};Ae(je,{Select:()=>Ye});module.exports=Re(je);var r=require("react"),ue=require("react-dom"),de=require("../../lib/aria-hide.cjs"),pe=require("../../lib/i18n.cjs"),n=require("react/jsx-runtime"),F=()=>{},He=[],Ke=(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),$e=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),P={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ce={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function k(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function We(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var Ue=(0,r.memo)((0,r.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:B,optionId:g,onClick:m,onMouseEnter:I,index:w},R){let $=()=>{i||m(o.value)},E=()=>{i||I(w)};return(0,n.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:k(P[B].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-blue-50 dark:bg-blue-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:$,onMouseEnter:E,children:[o.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,n.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,n.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,n.jsx)("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:$e}):null]})}));function Ye({options:a=He,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:B=!1,disabled:g=!1,readOnly:m=!1,loading:I=!1,size:w="md",variant:R="default",placeholder:$,label:E,description:Q,helperText:X,error:D,required:Z=!1,noOptionsText:fe,clearLabel:ge,searchLabel:be,searchPlaceholder:me,onSearchChange:G,name:J,className:he,triggerClassName:xe,contentClassName:ve,maxHeight:W=256}){let C=(0,pe.useUILabels)(),ke=$??C.selectPlaceholder,we=fe??C.selectNoOptions,S=(0,r.useId)(),U=`${S}-label`,ee=`${S}-trigger`,te=`${S}-listbox`,x=(0,r.useRef)(null),Y=(0,r.useRef)(null),ne=(0,r.useRef)(null),re=(0,r.useRef)([]),M=o!==void 0,[ye,oe]=(0,r.useState)(c??""),L=M?o:ye,[p,j]=(0,r.useState)(!1),[z,O]=(0,r.useState)(""),[s,f]=(0,r.useState)(-1),[T,ae]=(0,r.useState)(null),d=(0,r.useMemo)(()=>i?We(a,z):a,[a,z,i]),H=(0,r.useMemo)(()=>a.find(e=>e.value===L)??null,[a,L]),v=(0,r.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),N=(0,r.useCallback)(e=>{M||oe(e),(l??F)(e),j(!1),O(""),f(-1),x.current?.focus()},[M,l]),Ee=(0,r.useCallback)(e=>{e.stopPropagation(),M||oe(""),(l??F)(""),O(""),x.current?.focus()},[M,l]),A=(0,r.useCallback)(()=>{g||m||(j(!0),O(""),f(-1))},[g,m]),b=(0,r.useCallback)(()=>{j(!1),O(""),f(-1),x.current?.focus()},[]),Le=(0,r.useCallback)(()=>{p?b():A()},[p,b,A]),h=(0,r.useCallback)((e,t)=>{let u=d.length;if(u===0)return-1;let y=e;for(let V=0;V<u;V++)if(y=((y+t)%u+u)%u,!v.has(d[y].value))return y;return-1},[d,v]),Ne=(0,r.useCallback)(e=>{if(!(g||m)){if(p){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(d.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<d.length){let t=d[s];v.has(t.value)||N(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<d.length){let t=d[s];v.has(t.value)||N(t.value)}else b();break;case"Escape":e.preventDefault(),b();break;case"Tab":b();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[g,m,p,A,b,s,d,v,h,N]),Ie=(0,r.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(d.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<d.length){let t=d[s];v.has(t.value)||N(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[s,d,v,h,N,b]),De=(0,r.useCallback)(e=>{let t=e.target.value;O(t),f(-1),(G??F)(t)},[G]);(0,r.useEffect)(()=>{if(!p)return;let e=t=>{let u=t.target;x.current?.contains(u)||Y.current?.contains(u)||b()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[p,b]),(0,r.useEffect)(()=>{if(!p||!x.current){ae(null);return}let e=()=>{let t=x.current;if(!t)return;let u=t.getBoundingClientRect(),y=window.innerHeight-u.bottom,V=u.top,le=W+8,ie=y<le&&V>y?"top":"bottom";ae({top:ie==="bottom"?u.bottom+window.scrollY+4:u.top+window.scrollY-le,left:u.left+window.scrollX,width:u.width,placement:ie})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[p,W]);let K=p&&T!==null;(0,r.useEffect)(()=>{K&&i&&ne.current?.focus()},[K,i]),(0,r.useEffect)(()=>{let e=Y.current;if(!(!K||!e))return(0,de.registerFloatingLayer)(e,()=>x.current)},[K]),(0,r.useEffect)(()=>{if(s>=0){let e=re.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let _=L!==""&&L!==void 0,Ce=B&&_&&!g&&!m&&!I,se=!g&&!m,Se=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",P[w].trigger,ce[R].trigger,!D&&se&&ce[R].focus,D&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",m&&"cursor-default",!g&&!m&&"cursor-pointer",xe);return(0,n.jsxs)("div",{className:k("flex flex-col gap-1",he),children:[E?(0,n.jsxs)("label",{id:U,htmlFor:ee,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[E,Z?(0,n.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Q?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Q}):null,(0,n.jsxs)("button",{ref:x,id:ee,type:"button",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-controls":p?te:void 0,"aria-labelledby":E?U:void 0,"aria-required":Z||void 0,"aria-invalid":D?!0:void 0,"aria-activedescendant":p&&s>=0?`${S}-option-${s}`:void 0,disabled:g,className:Se,onClick:se?Le:void 0,onKeyDown:Ne,children:[(0,n.jsxs)("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!_&&"text-gray-600 dark:text-gray-300"),children:[H?.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,n.jsx)("span",{className:"truncate",children:_&&H?H.label:ke})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[I?(0,n.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Be}):null,Ce?(0,n.jsx)("span",{role:"button",tabIndex:-1,"aria-label":ge??C.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ee,onMouseDown:e=>e.preventDefault(),children:Ve}):null,(0,n.jsx)("span",{className:k("text-gray-500 dark:text-gray-400 transition-transform duration-200",p&&"rotate-180"),children:Ke})]})]}),D?(0,n.jsx)("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:D}):X?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,J?(0,n.jsx)("input",{type:"hidden",name:J,value:L??""}):null,p&&T?(0,ue.createPortal)((0,n.jsxs)("div",{ref:Y,role:"listbox",id:te,"aria-labelledby":E?U:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",P[w].content,ve),style:{top:T.top,left:T.left,width:T.width,position:"absolute"},onKeyDown:Ie,children:[i?(0,n.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,n.jsx)("input",{ref:ne,type:"text",role:"searchbox","aria-label":be??C.selectSearch,className:k(P[w].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:me??C.selectSearchPlaceholder,value:z,onChange:De})}):null,(0,n.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:W},children:d.length===0?(0,n.jsx)("div",{className:k(P[w].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:we}):d.map((e,t)=>(0,n.jsx)(Ue,{option:e,isSelected:e.value===L,isHighlighted:t===s,isDisabled:I||v.has(e.value),sizeKey:w,optionId:`${S}-option-${t}`,onClick:N,onMouseEnter:f,index:t,ref:u=>{re.current[t]=u}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
|
|
1
|
+
"use strict";"use client";var q=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var Ae=(a,o)=>{for(var c in o)q(a,c,{get:o[c],enumerable:!0})},Pe=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Oe(o))!Te.call(a,i)&&i!==c&&q(a,i,{get:()=>o[i],enumerable:!(l=Me(o,i))||l.enumerable});return a};var Re=a=>Pe(q({},"__esModule",{value:!0}),a);var je={};Ae(je,{Select:()=>Ye});module.exports=Re(je);var n=require("react"),de=require("react-dom"),ue=require("../../lib/aria-hide.cjs"),pe=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),F=()=>{},He=[],Ke=(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,r.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),$e=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),P={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ce={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function v(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function We(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var Ue=(0,n.memo)((0,n.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:B,optionId:g,onClick:h,onMouseEnter:I,index:k},R){let $=()=>{i||h(o.value)},E=()=>{i||I(k)};return(0,r.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:v(P[B].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:$,onMouseEnter:E,children:[o.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,r.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,r.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:$e}):null]})}));function Ye({options:a=He,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:B=!1,disabled:g=!1,readOnly:h=!1,loading:I=!1,size:k="md",variant:R="default",placeholder:$,label:E,description:Q,helperText:X,error:D,required:Z=!1,noOptionsText:fe,clearLabel:ge,searchLabel:me,searchPlaceholder:he,onSearchChange:G,name:J,className:be,triggerClassName:ye,contentClassName:xe,maxHeight:W=256}){let C=(0,pe.useUILabels)(),ve=$??C.selectPlaceholder,ke=fe??C.selectNoOptions,S=(0,n.useId)(),U=`${S}-label`,ee=`${S}-trigger`,te=`${S}-listbox`,y=(0,n.useRef)(null),Y=(0,n.useRef)(null),re=(0,n.useRef)(null),ne=(0,n.useRef)([]),M=o!==void 0,[we,oe]=(0,n.useState)(c??""),L=M?o:we,[p,j]=(0,n.useState)(!1),[z,O]=(0,n.useState)(""),[s,f]=(0,n.useState)(-1),[T,ae]=(0,n.useState)(null),u=(0,n.useMemo)(()=>i?We(a,z):a,[a,z,i]),H=(0,n.useMemo)(()=>a.find(e=>e.value===L)??null,[a,L]),x=(0,n.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),N=(0,n.useCallback)(e=>{M||oe(e),(l??F)(e),j(!1),O(""),f(-1),y.current?.focus()},[M,l]),Ee=(0,n.useCallback)(e=>{e.stopPropagation(),M||oe(""),(l??F)(""),O(""),y.current?.focus()},[M,l]),A=(0,n.useCallback)(()=>{g||h||(j(!0),O(""),f(-1))},[g,h]),m=(0,n.useCallback)(()=>{j(!1),O(""),f(-1),y.current?.focus()},[]),Le=(0,n.useCallback)(()=>{p?m():A()},[p,m,A]),b=(0,n.useCallback)((e,t)=>{let d=u.length;if(d===0)return-1;let w=e;for(let V=0;V<d;V++)if(w=((w+t)%d+d)%d,!x.has(u[w].value))return w;return-1},[u,x]),Ne=(0,n.useCallback)(e=>{if(!(g||h)){if(p){switch(e.key){case"ArrowDown":{e.preventDefault();let t=b(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=b(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=b(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=b(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||N(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||N(t.value)}else m();break;case"Escape":e.preventDefault(),m();break;case"Tab":m();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[g,h,p,A,m,s,u,x,b,N]),Ie=(0,n.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=b(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=b(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=b(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=b(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||N(t.value)}break}case"Escape":e.preventDefault(),m();break;case"Tab":m();break}},[s,u,x,b,N,m]),De=(0,n.useCallback)(e=>{let t=e.target.value;O(t),f(-1),(G??F)(t)},[G]);(0,n.useEffect)(()=>{if(!p)return;let e=t=>{let d=t.target;y.current?.contains(d)||Y.current?.contains(d)||m()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[p,m]),(0,n.useEffect)(()=>{if(!p||!y.current){ae(null);return}let e=()=>{let t=y.current;if(!t)return;let d=t.getBoundingClientRect(),w=window.innerHeight-d.bottom,V=d.top,le=W+8,ie=w<le&&V>w?"top":"bottom";ae({top:ie==="bottom"?d.bottom+window.scrollY+4:d.top+window.scrollY-le,left:d.left+window.scrollX,width:d.width,placement:ie})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[p,W]);let K=p&&T!==null;(0,n.useEffect)(()=>{K&&i&&re.current?.focus()},[K,i]),(0,n.useEffect)(()=>{let e=Y.current;if(!(!K||!e))return(0,ue.registerFloatingLayer)(e,()=>y.current)},[K]),(0,n.useEffect)(()=>{if(s>=0){let e=ne.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let _=L!==""&&L!==void 0,Ce=B&&_&&!g&&!h&&!I,se=!g&&!h,Se=v("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",P[k].trigger,ce[R].trigger,!D&&se&&ce[R].focus,D&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",h&&"cursor-default",!g&&!h&&"cursor-pointer",ye);return(0,r.jsxs)("div",{className:v("flex flex-col gap-1",be),children:[E?(0,r.jsxs)("label",{id:U,htmlFor:ee,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[E,Z?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Q?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Q}):null,(0,r.jsxs)("button",{ref:y,id:ee,type:"button",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-controls":p?te:void 0,"aria-labelledby":E?U:void 0,"aria-required":Z||void 0,"aria-invalid":D?!0:void 0,"aria-activedescendant":p&&s>=0?`${S}-option-${s}`:void 0,disabled:g,className:Se,onClick:se?Le:void 0,onKeyDown:Ne,children:[(0,r.jsxs)("span",{className:v("flex items-center gap-2 min-w-0 flex-1 truncate",!_&&"text-gray-600 dark:text-gray-300"),children:[H?.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,r.jsx)("span",{className:"truncate",children:_&&H?H.label:ve})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[I?(0,r.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Be}):null,Ce?(0,r.jsx)("span",{role:"button",tabIndex:-1,"aria-label":ge??C.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ee,onMouseDown:e=>e.preventDefault(),children:Ve}):null,(0,r.jsx)("span",{className:v("text-gray-500 dark:text-gray-400 transition-transform duration-200",p&&"rotate-180"),children:Ke})]})]}),D?(0,r.jsx)("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:D}):X?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,J?(0,r.jsx)("input",{type:"hidden",name:J,value:L??""}):null,p&&T?(0,de.createPortal)((0,r.jsxs)("div",{ref:Y,role:"listbox",id:te,"aria-labelledby":E?U:void 0,className:v("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",P[k].content,xe),style:{top:T.top,left:T.left,width:T.width,position:"absolute"},onKeyDown:Ie,children:[i?(0,r.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,r.jsx)("input",{ref:re,type:"text",role:"searchbox","aria-label":me??C.selectSearch,className:v(P[k].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:he??C.selectSearchPlaceholder,value:z,onChange:De})}):null,(0,r.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:W},children:u.length===0?(0,r.jsx)("div",{className:v(P[k].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ke}):u.map((e,t)=>(0,r.jsx)(Ue,{option:e,isSelected:e.value===L,isHighlighted:t===s,isDisabled:I||x.has(e.value),sizeKey:k,optionId:`${S}-option-${t}`,onClick:N,onMouseEnter:f,index:t,ref:d=>{ne.current[t]=d}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as R,useRef as U,useEffect as H,useCallback as h,useMemo as Z,useId as Oe,memo as Te,forwardRef as Ae}from"react";import{createPortal as Pe}from"react-dom";import{registerFloatingLayer as Re}from"../../lib/aria-hide.js";import{useUILabels as He}from"../../lib/i18n.js";import{jsx as n,jsxs as x}from"react/jsx-runtime";var G=()=>{},Ke=[],Ve=n("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=x("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[n("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),n("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),We=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},fe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function w(...i){let o="";for(let u=0;u<i.length;u++){let s=i[u];s&&(o&&(o+=" "),o+=s)}return o}function Ue(i,o){if(!o)return i;let u=o.toLowerCase();return i.filter(s=>{if(s.label.toLowerCase().includes(u)||s.value.toLowerCase().includes(u))return!0;if(s.keywords){for(let d of s.keywords)if(d.toLowerCase().includes(u))return!0}return!1})}var Ye=Te(Ae(function({option:o,isSelected:u,isHighlighted:s,isDisabled:d,sizeKey:Y,optionId:f,onClick:b,onMouseEnter:D,index:y},V){let j=()=>{d||b(o.value)},L=()=>{d||D(y)};return x("div",{ref:V,id:f,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":s||void 0,className:w(K[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!d&&"bg-blue-50 dark:bg-blue-900/30",u&&!s&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:L,children:[o.icon?n("span",{className:"flex shrink-0 items-center",children:o.icon}):null,x("span",{className:"flex flex-col min-w-0 flex-1",children:[n("span",{className:"truncate",children:o.label}),o.description?n("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?n("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:We}):null]})}));function Fe({options:i=Ke,value:o,defaultValue:u,onValueChange:s,searchable:d=!1,clearable:Y=!1,disabled:f=!1,readOnly:b=!1,loading:D=!1,size:y="md",variant:V="default",placeholder:j,label:L,description:J,helperText:ee,error:C,required:te=!1,noOptionsText:ge,clearLabel:be,searchLabel:me,searchPlaceholder:he,onSearchChange:ne,name:re,className:xe,triggerClassName:ve,contentClassName:ke,maxHeight:z=256}){let S=He(),we=j??S.selectPlaceholder,ye=ge??S.selectNoOptions,M=Oe(),_=`${M}-label`,oe=`${M}-trigger`,ae=`${M}-listbox`,v=U(null),q=U(null),se=U(null),le=U([]),O=o!==void 0,[Ee,ie]=R(u??""),N=O?o:Ee,[c,F]=R(!1),[Q,T]=R(""),[r,p]=R(-1),[A,ce]=R(null),l=Z(()=>d?Ue(i,Q):i,[i,Q,d]),B=Z(()=>i.find(e=>e.value===N)??null,[i,N]),k=Z(()=>{let e=new Set;for(let t of i)t.disabled&&e.add(t.value);return e},[i]),I=h(e=>{O||ie(e),(s??G)(e),F(!1),T(""),p(-1),v.current?.focus()},[O,s]),Le=h(e=>{e.stopPropagation(),O||ie(""),(s??G)(""),T(""),v.current?.focus()},[O,s]),P=h(()=>{f||b||(F(!0),T(""),p(-1))},[f,b]),g=h(()=>{F(!1),T(""),p(-1),v.current?.focus()},[]),Ne=h(()=>{c?g():P()},[c,g,P]),m=h((e,t)=>{let a=l.length;if(a===0)return-1;let E=e;for(let W=0;W<a;W++)if(E=((E+t)%a+a)%a,!k.has(l[E].value))return E;return-1},[l,k]),Ie=h(e=>{if(!(f||b)){if(c){switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];k.has(t.value)||I(t.value)}break}case" ":if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];k.has(t.value)||I(t.value)}else g();break;case"Escape":e.preventDefault(),g();break;case"Tab":g();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),P();break;case"Enter":case" ":e.preventDefault(),P();break}}},[f,b,c,P,g,r,l,k,m,I]),De=h(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];k.has(t.value)||I(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[r,l,k,m,I,g]),Ce=h(e=>{let t=e.target.value;T(t),p(-1),(ne??G)(t)},[ne]);H(()=>{if(!c)return;let e=t=>{let a=t.target;v.current?.contains(a)||q.current?.contains(a)||g()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[c,g]),H(()=>{if(!c||!v.current){ce(null);return}let e=()=>{let t=v.current;if(!t)return;let a=t.getBoundingClientRect(),E=window.innerHeight-a.bottom,W=a.top,de=z+8,pe=E<de&&W>E?"top":"bottom";ce({top:pe==="bottom"?a.bottom+window.scrollY+4:a.top+window.scrollY-de,left:a.left+window.scrollX,width:a.width,placement:pe})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c,z]);let $=c&&A!==null;H(()=>{$&&d&&se.current?.focus()},[$,d]),H(()=>{let e=q.current;if(!(!$||!e))return Re(e,()=>v.current)},[$]),H(()=>{if(r>=0){let e=le.current[r];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[r]);let X=N!==""&&N!==void 0,Se=Y&&X&&!f&&!b&&!D,ue=!f&&!b,Me=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",K[y].trigger,fe[V].trigger,!C&&ue&&fe[V].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",f&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",b&&"cursor-default",!f&&!b&&"cursor-pointer",ve);return x("div",{className:w("flex flex-col gap-1",xe),children:[L?x("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[L,te?n("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,x("button",{ref:v,id:oe,type:"button",role:"combobox","aria-expanded":c,"aria-haspopup":"listbox","aria-controls":c?ae:void 0,"aria-labelledby":L?_:void 0,"aria-required":te||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":c&&r>=0?`${M}-option-${r}`:void 0,disabled:f,className:Me,onClick:ue?Ne:void 0,onKeyDown:Ie,children:[x("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-600 dark:text-gray-300"),children:[B?.icon?n("span",{className:"flex shrink-0 items-center",children:B.icon}):null,n("span",{className:"truncate",children:X&&B?B.label:we})]}),x("span",{className:"flex items-center gap-1 shrink-0",children:[D?n("span",{className:"text-gray-500 dark:text-gray-400",children:$e}):null,Se?n("span",{role:"button",tabIndex:-1,"aria-label":be??S.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Le,onMouseDown:e=>e.preventDefault(),children:Be}):null,n("span",{className:w("text-gray-500 dark:text-gray-400 transition-transform duration-200",c&&"rotate-180"),children:Ve})]})]}),C?n("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:C}):ee?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,re?n("input",{type:"hidden",name:re,value:N??""}):null,c&&A?Pe(x("div",{ref:q,role:"listbox",id:ae,"aria-labelledby":L?_:void 0,className:w("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",K[y].content,ke),style:{top:A.top,left:A.left,width:A.width,position:"absolute"},onKeyDown:De,children:[d?n("div",{className:"border-b border-gray-200 dark:border-gray-700",children:n("input",{ref:se,type:"text",role:"searchbox","aria-label":me??S.selectSearch,className:w(K[y].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:he??S.selectSearchPlaceholder,value:Q,onChange:Ce})}):null,n("div",{className:"overflow-y-auto",style:{maxHeight:z},children:l.length===0?n("div",{className:w(K[y].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ye}):l.map((e,t)=>n(Ye,{option:e,isSelected:e.value===N,isHighlighted:t===r,isDisabled:D||k.has(e.value),sizeKey:y,optionId:`${M}-option-${t}`,onClick:I,onMouseEnter:p,index:t,ref:a=>{le.current[t]=a}},e.value))})]}),document.body):null]})}export{Fe as Select};
|
|
1
|
+
"use client";import{useState as R,useRef as U,useEffect as H,useCallback as b,useMemo as Z,useId as Oe,memo as Te,forwardRef as Ae}from"react";import{createPortal as Pe}from"react-dom";import{registerFloatingLayer as Re}from"../../lib/aria-hide.js";import{useUILabels as He}from"../../lib/i18n.js";import{jsx as r,jsxs as y}from"react/jsx-runtime";var G=()=>{},Ke=[],Ve=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=y("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),We=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},fe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function k(...i){let o="";for(let d=0;d<i.length;d++){let s=i[d];s&&(o&&(o+=" "),o+=s)}return o}function Ue(i,o){if(!o)return i;let d=o.toLowerCase();return i.filter(s=>{if(s.label.toLowerCase().includes(d)||s.value.toLowerCase().includes(d))return!0;if(s.keywords){for(let u of s.keywords)if(u.toLowerCase().includes(d))return!0}return!1})}var Ye=Te(Ae(function({option:o,isSelected:d,isHighlighted:s,isDisabled:u,sizeKey:Y,optionId:f,onClick:m,onMouseEnter:D,index:w},V){let j=()=>{u||m(o.value)},L=()=>{u||D(w)};return y("div",{ref:V,id:f,role:"option","aria-selected":d,"aria-disabled":u||void 0,"data-highlighted":s||void 0,className:k(K[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!u&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",d&&!s&&"bg-gray-50 dark:bg-gray-700/50",u&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:L,children:[o.icon?r("span",{className:"flex shrink-0 items-center",children:o.icon}):null,y("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:o.label}),o.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),d?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:We}):null]})}));function Fe({options:i=Ke,value:o,defaultValue:d,onValueChange:s,searchable:u=!1,clearable:Y=!1,disabled:f=!1,readOnly:m=!1,loading:D=!1,size:w="md",variant:V="default",placeholder:j,label:L,description:J,helperText:ee,error:C,required:te=!1,noOptionsText:ge,clearLabel:me,searchLabel:he,searchPlaceholder:be,onSearchChange:re,name:ne,className:ye,triggerClassName:xe,contentClassName:ve,maxHeight:z=256}){let S=He(),ke=j??S.selectPlaceholder,we=ge??S.selectNoOptions,M=Oe(),_=`${M}-label`,oe=`${M}-trigger`,ae=`${M}-listbox`,x=U(null),q=U(null),se=U(null),le=U([]),O=o!==void 0,[Ee,ie]=R(d??""),N=O?o:Ee,[c,F]=R(!1),[Q,T]=R(""),[n,p]=R(-1),[A,ce]=R(null),l=Z(()=>u?Ue(i,Q):i,[i,Q,u]),B=Z(()=>i.find(e=>e.value===N)??null,[i,N]),v=Z(()=>{let e=new Set;for(let t of i)t.disabled&&e.add(t.value);return e},[i]),I=b(e=>{O||ie(e),(s??G)(e),F(!1),T(""),p(-1),x.current?.focus()},[O,s]),Le=b(e=>{e.stopPropagation(),O||ie(""),(s??G)(""),T(""),x.current?.focus()},[O,s]),P=b(()=>{f||m||(F(!0),T(""),p(-1))},[f,m]),g=b(()=>{F(!1),T(""),p(-1),x.current?.focus()},[]),Ne=b(()=>{c?g():P()},[c,g,P]),h=b((e,t)=>{let a=l.length;if(a===0)return-1;let E=e;for(let W=0;W<a;W++)if(E=((E+t)%a+a)%a,!v.has(l[E].value))return E;return-1},[l,v]),Ie=b(e=>{if(!(f||m)){if(c){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=h(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=h(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||I(t.value)}break}case" ":if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||I(t.value)}else g();break;case"Escape":e.preventDefault(),g();break;case"Tab":g();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),P();break;case"Enter":case" ":e.preventDefault(),P();break}}},[f,m,c,P,g,n,l,v,h,I]),De=b(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=h(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=h(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||I(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[n,l,v,h,I,g]),Ce=b(e=>{let t=e.target.value;T(t),p(-1),(re??G)(t)},[re]);H(()=>{if(!c)return;let e=t=>{let a=t.target;x.current?.contains(a)||q.current?.contains(a)||g()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[c,g]),H(()=>{if(!c||!x.current){ce(null);return}let e=()=>{let t=x.current;if(!t)return;let a=t.getBoundingClientRect(),E=window.innerHeight-a.bottom,W=a.top,ue=z+8,pe=E<ue&&W>E?"top":"bottom";ce({top:pe==="bottom"?a.bottom+window.scrollY+4:a.top+window.scrollY-ue,left:a.left+window.scrollX,width:a.width,placement:pe})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c,z]);let $=c&&A!==null;H(()=>{$&&u&&se.current?.focus()},[$,u]),H(()=>{let e=q.current;if(!(!$||!e))return Re(e,()=>x.current)},[$]),H(()=>{if(n>=0){let e=le.current[n];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[n]);let X=N!==""&&N!==void 0,Se=Y&&X&&!f&&!m&&!D,de=!f&&!m,Me=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",K[w].trigger,fe[V].trigger,!C&&de&&fe[V].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",f&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",m&&"cursor-default",!f&&!m&&"cursor-pointer",xe);return y("div",{className:k("flex flex-col gap-1",ye),children:[L?y("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[L,te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,y("button",{ref:x,id:oe,type:"button",role:"combobox","aria-expanded":c,"aria-haspopup":"listbox","aria-controls":c?ae:void 0,"aria-labelledby":L?_:void 0,"aria-required":te||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":c&&n>=0?`${M}-option-${n}`:void 0,disabled:f,className:Me,onClick:de?Ne:void 0,onKeyDown:Ie,children:[y("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-600 dark:text-gray-300"),children:[B?.icon?r("span",{className:"flex shrink-0 items-center",children:B.icon}):null,r("span",{className:"truncate",children:X&&B?B.label:ke})]}),y("span",{className:"flex items-center gap-1 shrink-0",children:[D?r("span",{className:"text-gray-500 dark:text-gray-400",children:$e}):null,Se?r("span",{role:"button",tabIndex:-1,"aria-label":me??S.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Le,onMouseDown:e=>e.preventDefault(),children:Be}):null,r("span",{className:k("text-gray-500 dark:text-gray-400 transition-transform duration-200",c&&"rotate-180"),children:Ve})]})]}),C?r("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:C}):ee?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,ne?r("input",{type:"hidden",name:ne,value:N??""}):null,c&&A?Pe(y("div",{ref:q,role:"listbox",id:ae,"aria-labelledby":L?_:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",K[w].content,ve),style:{top:A.top,left:A.left,width:A.width,position:"absolute"},onKeyDown:De,children:[u?r("div",{className:"border-b border-gray-200 dark:border-gray-700",children:r("input",{ref:se,type:"text",role:"searchbox","aria-label":he??S.selectSearch,className:k(K[w].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:be??S.selectSearchPlaceholder,value:Q,onChange:Ce})}):null,r("div",{className:"overflow-y-auto",style:{maxHeight:z},children:l.length===0?r("div",{className:k(K[w].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:we}):l.map((e,t)=>r(Ye,{option:e,isSelected:e.value===N,isHighlighted:t===n,isDisabled:D||v.has(e.value),sizeKey:w,optionId:`${M}-option-${t}`,onClick:I,onMouseEnter:p,index:t,ref:a=>{le.current[t]=a}},e.value))})]}),document.body):null]})}export{Fe as Select};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var T=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var ee=(t,r)=>{for(var a in r)T(t,a,{get:r[a],enumerable:!0})},te=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Z(r))!_.call(t,s)&&s!==a&&T(t,s,{get:()=>r[s],enumerable:!(n=K(r,s))||n.enumerable});return t};var re=t=>te(T({},"__esModule",{value:!0}),t);var ge={};ee(ge,{Sidebar:()=>se,SidebarContent:()=>de,SidebarFooter:()=>ce,SidebarGroup:()=>ue,SidebarHeader:()=>le,SidebarItem:()=>be,SidebarSubMenu:()=>pe,SidebarToggle:()=>fe,useSidebar:()=>ae});module.exports=re(ge);var o=require("react"),j=require("../../hooks/useDialogA11y.cjs"),i=require("../../lib/cn.cjs"),M=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),E=(0,o.createContext)(null);function y(){let t=(0,o.useContext)(E);if(!t)throw new Error("Sidebar sub-components must be used within <Sidebar>");return t}function ae(){return y()}var oe=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),ne=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),ie=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-5 h-5",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function B({text:t,position:r,children:a}){let[n,s]=(0,o.useState)(!1),[c,f]=(0,o.useState)({top:0,left:0}),u=(0,o.useRef)(null);return(0,e.jsxs)("div",{ref:u,onMouseEnter:()=>{if(u.current){let d=u.current.getBoundingClientRect();f({top:d.top+d.height/2,left:r==="left"?d.right+8:d.left-8})}s(!0)},onMouseLeave:()=>s(!1),className:"relative",children:[a,n&&(0,e.jsx)("div",{className:(0,i.cn)("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",r==="right"&&"-translate-x-full"),style:{top:c.top,left:c.left,transform:`translateY(-50%)${r==="right"?" translateX(-100%)":""}`},role:"tooltip",children:t})]})}function se({collapsed:t,defaultCollapsed:r=!1,onCollapsedChange:a,expandedWidth:n=260,collapsedWidth:s=64,position:c="left",variant:f="default",mobileBreakpoint:u=768,mobileOpen:x,onMobileOpenChange:d,className:m,"aria-label":b,closeLabel:N,trapFocus:g=!0,initialFocus:S,returnFocus:w,lockScroll:C=!0,children:O}){let G=(0,M.useUILabels)(),D=(0,o.useRef)(null),F=(0,o.useRef)(null),[q,Q]=(0,o.useState)(r),[W,R]=(0,o.useState)(!1),[p,$]=(0,o.useState)(!1),L=t!==void 0,k=L?t:q,v=x!==void 0,h=v?x:W;(0,o.useEffect)(()=>{let l=window.matchMedia(`(max-width: ${u}px)`),I=A=>{$(A.matches),A.matches||(v||R(!1),d?.(!1))};return I(l),l.addEventListener("change",I),()=>l.removeEventListener("change",I)},[u,v,d]);let U=(0,o.useCallback)(()=>{if(p){let l=!h;v||R(l),d?.(l)}else{let l=!k;L||Q(l),a?.(l)}},[p,h,k,v,L,d,a]),P=(0,o.useCallback)(()=>{v||R(!1),d?.(!1)},[v,d]);(0,o.useEffect)(()=>{let l=F.current;l&&(p&&!h?(l.setAttribute("inert",""),l.setAttribute("aria-hidden","true")):(l.removeAttribute("inert"),l.removeAttribute("aria-hidden")))},[p,h]);let{dialogRef:X,dialogProps:Y}=(0,j.useDialogA11y)({open:p&&h,onClose:P,trapFocus:g,initialFocus:S,returnFocus:w,lockScroll:C,keepInteractive:[D]}),J={default:"bg-white dark:bg-gray-900",bordered:(0,i.cn)("bg-white dark:bg-gray-900",c==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},H=k&&!p?s:n,V=(0,e.jsx)("aside",{className:(0,i.cn)("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",J[f],m),style:{width:p?n:H,minWidth:p?n:H},"data-testid":"sidebar","data-collapsed":k&&!p,"data-mobile":p,"data-position":c,children:O}),z={collapsed:k&&!p,isMobile:p,mobileOpen:h,position:c,variant:f,expandedWidth:n,collapsedWidth:s,toggle:U,closeMobile:P,closeLabel:N};return p?(0,e.jsxs)(E.Provider,{value:z,children:[h&&(0,e.jsx)("div",{ref:D,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:P,"aria-hidden":"true","data-testid":"sidebar-overlay"}),(0,e.jsx)("div",{ref:l=>{F.current=l,X.current=l},...Y,"aria-label":b??G.sidebar,className:(0,i.cn)("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",c==="left"?"left-0":"right-0",h?"translate-x-0":c==="left"?"-translate-x-full":"translate-x-full"),children:V})]}):(0,e.jsx)(E.Provider,{value:z,children:V})}function le({className:t,children:r}){let a=y(),n=(0,M.useUILabels)();return(0,e.jsxs)("div",{className:(0,i.cn)("flex items-center shrink-0 px-4 h-14 overflow-hidden",a.collapsed&&"justify-center px-2",t),"data-testid":"sidebar-header",children:[r,a.isMobile&&a.mobileOpen&&(0,e.jsx)("button",{type:"button",onClick:a.closeMobile,className:"ml-auto p-1 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":a.closeLabel??n.closeSidebar,children:(0,e.jsx)(ie,{})})]})}function de({className:t,children:r}){return(0,e.jsx)("div",{className:(0,i.cn)("flex-1 overflow-y-auto overflow-x-hidden py-2",t),"data-testid":"sidebar-content",children:r})}function ce({className:t,children:r}){let a=y();return(0,e.jsx)("div",{className:(0,i.cn)("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",a.collapsed&&"px-2 flex justify-center",t),"data-testid":"sidebar-footer",children:r})}function ue({label:t,className:r,children:a}){let n=y();return(0,e.jsxs)("div",{className:(0,i.cn)("py-2",r),"data-testid":"sidebar-group",children:[t&&!n.collapsed&&(0,e.jsx)("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:t}),t&&n.collapsed&&(0,e.jsx)("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),(0,e.jsx)("div",{className:"space-y-0.5 px-2",children:a})]})}function be({icon:t,label:r,badge:a,badgeColor:n="bg-blue-600 text-white",active:s=!1,disabled:c=!1,href:f,onClick:u,tooltip:x,className:d}){let m=y(),b=m.collapsed,N=x??r,g=(0,e.jsxs)(e.Fragment,{children:[t&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 w-5 h-5",b&&"w-5 h-5"),children:t}),!b&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"flex-1 truncate",children:r}),a!=null&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:a})]}),b&&a!==void 0&&a!==null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]}),S=(0,i.cn)("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",b?"justify-center px-2 py-2.5":"px-3 py-2",s?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",c&&"opacity-50 pointer-events-none",!c&&"cursor-pointer",d),w=()=>{c||(u?.(),m.isMobile&&m.closeMobile())},C=f?(0,e.jsx)("a",{href:c?void 0:f,className:S,onClick:w,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g}):(0,e.jsx)("button",{type:"button",className:S,onClick:w,disabled:c,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g});return b?(0,e.jsx)(B,{text:N,position:m.position,children:C}):C}function pe({icon:t,label:r,badge:a,defaultOpen:n=!1,className:s,children:c}){let f=y(),[u,x]=(0,o.useState)(n),d=(0,o.useRef)(null),[m,b]=(0,o.useState)(n?void 0:0),N=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{if(N.current){N.current=!1,b(u?void 0:0);return}if(u){let g=d.current;if(g){b(g.scrollHeight);let S=setTimeout(()=>b(void 0),200);return()=>clearTimeout(S)}}else{let g=d.current;g&&(b(g.scrollHeight),requestAnimationFrame(()=>b(0)))}},[u]),f.collapsed?(0,e.jsx)(B,{text:r,position:f.position,children:(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",s),onClick:()=>{f.toggle(),x(!0)},"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),a!=null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-blue-600"})]})}):(0,e.jsxs)("div",{className:s,"data-testid":"sidebar-submenu",children:[(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>x(!u),"aria-expanded":u,"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),(0,e.jsx)("span",{className:"flex-1 truncate text-left",children:r}),a!=null&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-blue-600 text-white",children:a}),(0,e.jsx)(ne,{className:(0,i.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180")})]}),(0,e.jsx)("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:m===void 0?"auto":m},children:(0,e.jsx)("div",{ref:d,className:"pl-4 py-0.5",children:c})})]})}function fe({className:t}){let r=y(),a=(0,M.useUILabels)(),n=r.isMobile?r.mobileOpen?r.closeLabel??a.closeSidebar:a.openSidebar:r.collapsed?a.expandSidebar:a.collapseSidebar;return(0,e.jsx)("button",{type:"button",onClick:r.toggle,className:(0,i.cn)("p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",t),"aria-label":n,"data-testid":"sidebar-toggle",children:(0,e.jsx)(oe,{className:(0,i.cn)("transition-transform duration-200",r.collapsed&&"rotate-180",r.position==="right"&&!r.collapsed&&"rotate-180",r.position==="right"&&r.collapsed&&"rotate-0")})})}0&&(module.exports={Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarHeader,SidebarItem,SidebarSubMenu,SidebarToggle,useSidebar});
|
|
1
|
+
"use strict";"use client";var E=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,r)=>{for(var a in r)E(t,a,{get:r[a],enumerable:!0})},re=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of _(r))!ee.call(t,s)&&s!==a&&E(t,s,{get:()=>r[s],enumerable:!(n=Z(r,s))||n.enumerable});return t};var ae=t=>re(E({},"__esModule",{value:!0}),t);var me={};te(me,{Sidebar:()=>le,SidebarContent:()=>ce,SidebarFooter:()=>ue,SidebarGroup:()=>pe,SidebarHeader:()=>de,SidebarItem:()=>be,SidebarSubMenu:()=>fe,SidebarToggle:()=>ge,useSidebar:()=>oe});module.exports=ae(me);var o=require("react"),B=require("../../hooks/useDialogA11y.cjs"),i=require("../../lib/cn.cjs"),O=require("../../lib/safe-href.cjs"),R=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),H=(0,o.createContext)(null);function v(){let t=(0,o.useContext)(H);if(!t)throw new Error("Sidebar sub-components must be used within <Sidebar>");return t}function oe(){return v()}var ne=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),ie=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),se=({className:t})=>(0,e.jsx)("svg",{className:(0,i.cn)("w-5 h-5",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function G({text:t,position:r,children:a}){let[n,s]=(0,o.useState)(!1),[c,f]=(0,o.useState)({top:0,left:0}),u=(0,o.useRef)(null);return(0,e.jsxs)("div",{ref:u,onMouseEnter:()=>{if(u.current){let d=u.current.getBoundingClientRect();f({top:d.top+d.height/2,left:r==="left"?d.right+8:d.left-8})}s(!0)},onMouseLeave:()=>s(!1),className:"relative",children:[a,n&&(0,e.jsx)("div",{className:(0,i.cn)("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",r==="right"&&"-translate-x-full"),style:{top:c.top,left:c.left,transform:`translateY(-50%)${r==="right"?" translateX(-100%)":""}`},role:"tooltip",children:t})]})}function le({collapsed:t,defaultCollapsed:r=!1,onCollapsedChange:a,expandedWidth:n=260,collapsedWidth:s=64,position:c="left",variant:f="default",mobileBreakpoint:u=768,mobileOpen:x,onMobileOpenChange:d,className:m,"aria-label":p,closeLabel:N,trapFocus:g=!0,initialFocus:S,returnFocus:w,lockScroll:C=!0,children:M}){let q=(0,R.useUILabels)(),D=(0,o.useRef)(null),F=(0,o.useRef)(null),[Q,W]=(0,o.useState)(r),[$,L]=(0,o.useState)(!1),[b,U]=(0,o.useState)(!1),P=t!==void 0,k=P?t:Q,y=x!==void 0,h=y?x:$;(0,o.useEffect)(()=>{if(typeof window.matchMedia!="function")return;let l=window.matchMedia(`(max-width: ${u}px)`),T=j=>{U(j.matches),j.matches||(y||L(!1),d?.(!1))};return T(l),l.addEventListener("change",T),()=>l.removeEventListener("change",T)},[u,y,d]);let X=(0,o.useCallback)(()=>{if(b){let l=!h;y||L(l),d?.(l)}else{let l=!k;P||W(l),a?.(l)}},[b,h,k,y,P,d,a]),I=(0,o.useCallback)(()=>{y||L(!1),d?.(!1)},[y,d]);(0,o.useEffect)(()=>{let l=F.current;l&&(b&&!h?(l.setAttribute("inert",""),l.setAttribute("aria-hidden","true")):(l.removeAttribute("inert"),l.removeAttribute("aria-hidden")))},[b,h]);let{dialogRef:Y,dialogProps:J}=(0,B.useDialogA11y)({open:b&&h,onClose:I,trapFocus:g,initialFocus:S,returnFocus:w,lockScroll:C,keepInteractive:[D]}),K={default:"bg-white dark:bg-gray-900",bordered:(0,i.cn)("bg-white dark:bg-gray-900",c==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},V=k&&!b?s:n,z=(0,e.jsx)("aside",{className:(0,i.cn)("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",K[f],m),style:{width:b?n:V,minWidth:b?n:V},"data-testid":"sidebar","data-collapsed":k&&!b,"data-mobile":b,"data-position":c,children:M}),A={collapsed:k&&!b,isMobile:b,mobileOpen:h,position:c,variant:f,expandedWidth:n,collapsedWidth:s,toggle:X,closeMobile:I,closeLabel:N};return b?(0,e.jsxs)(H.Provider,{value:A,children:[h&&(0,e.jsx)("div",{ref:D,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:I,"aria-hidden":"true","data-testid":"sidebar-overlay"}),(0,e.jsx)("div",{ref:l=>{F.current=l,Y.current=l},...J,"aria-label":p??q.sidebar,className:(0,i.cn)("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",c==="left"?"left-0":"right-0",h?"translate-x-0":c==="left"?"-translate-x-full":"translate-x-full"),children:z})]}):(0,e.jsx)(H.Provider,{value:A,children:z})}function de({className:t,children:r}){let a=v(),n=(0,R.useUILabels)();return(0,e.jsxs)("div",{className:(0,i.cn)("flex items-center shrink-0 px-4 h-14 overflow-hidden",a.collapsed&&"justify-center px-2",t),"data-testid":"sidebar-header",children:[r,a.isMobile&&a.mobileOpen&&(0,e.jsx)("button",{type:"button",onClick:a.closeMobile,className:"ml-auto p-1 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":a.closeLabel??n.closeSidebar,children:(0,e.jsx)(se,{})})]})}function ce({className:t,children:r}){return(0,e.jsx)("div",{className:(0,i.cn)("flex-1 overflow-y-auto overflow-x-hidden py-2",t),"data-testid":"sidebar-content",children:r})}function ue({className:t,children:r}){let a=v();return(0,e.jsx)("div",{className:(0,i.cn)("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",a.collapsed&&"px-2 flex justify-center",t),"data-testid":"sidebar-footer",children:r})}function pe({label:t,className:r,children:a}){let n=v();return(0,e.jsxs)("div",{className:(0,i.cn)("py-2",r),"data-testid":"sidebar-group",children:[t&&!n.collapsed&&(0,e.jsx)("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:t}),t&&n.collapsed&&(0,e.jsx)("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),(0,e.jsx)("div",{className:"space-y-0.5 px-2",children:a})]})}function be({icon:t,label:r,badge:a,badgeColor:n="bg-synertech-primary-600 text-synertech-on-primary",active:s=!1,disabled:c=!1,href:f,onClick:u,tooltip:x,className:d}){let m=v(),p=m.collapsed,N=x??r,g=(0,e.jsxs)(e.Fragment,{children:[t&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 w-5 h-5",p&&"w-5 h-5"),children:t}),!p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"flex-1 truncate",children:r}),a!=null&&(0,e.jsx)("span",{className:(0,i.cn)("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:a})]}),p&&a!==void 0&&a!==null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-synertech-primary-600"})]}),S=(0,i.cn)("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",p?"justify-center px-2 py-2.5":"px-3 py-2",s?"bg-synertech-primary-50 text-synertech-primary-700 dark:bg-synertech-primary-900/30 dark:text-synertech-primary-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",c&&"opacity-50 pointer-events-none",!c&&"cursor-pointer",d),w=()=>{c||(u?.(),m.isMobile&&m.closeMobile())},C=(0,O.componentHref)("SidebarItem",f),M=C?(0,e.jsx)("a",{href:c?void 0:C,className:S,onClick:w,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g}):(0,e.jsx)("button",{type:"button",className:S,onClick:w,disabled:c,"aria-current":s?"page":void 0,"data-testid":"sidebar-item",children:g});return p?(0,e.jsx)(G,{text:N,position:m.position,children:M}):M}function fe({icon:t,label:r,badge:a,defaultOpen:n=!1,className:s,children:c}){let f=v(),[u,x]=(0,o.useState)(n),d=(0,o.useRef)(null),[m,p]=(0,o.useState)(n?void 0:0),N=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{if(N.current){N.current=!1,p(u?void 0:0);return}if(u){let g=d.current;if(g){p(g.scrollHeight);let S=setTimeout(()=>p(void 0),200);return()=>clearTimeout(S)}}else{let g=d.current;g&&(p(g.scrollHeight),requestAnimationFrame(()=>p(0)))}},[u]),f.collapsed?(0,e.jsx)(G,{text:r,position:f.position,children:(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",s),onClick:()=>{f.toggle(),x(!0)},"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),a!=null&&(0,e.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-synertech-primary-600"})]})}):(0,e.jsxs)("div",{className:s,"data-testid":"sidebar-submenu",children:[(0,e.jsxs)("button",{type:"button",className:(0,i.cn)("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>x(!u),"aria-expanded":u,"data-testid":"sidebar-submenu-trigger",children:[t&&(0,e.jsx)("span",{className:"shrink-0 w-5 h-5",children:t}),(0,e.jsx)("span",{className:"flex-1 truncate text-left",children:r}),a!=null&&(0,e.jsx)("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-synertech-primary-600 text-synertech-on-primary",children:a}),(0,e.jsx)(ie,{className:(0,i.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180")})]}),(0,e.jsx)("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:m===void 0?"auto":m},children:(0,e.jsx)("div",{ref:d,className:"pl-4 py-0.5",children:c})})]})}function ge({className:t}){let r=v(),a=(0,R.useUILabels)(),n=r.isMobile?r.mobileOpen?r.closeLabel??a.closeSidebar:a.openSidebar:r.collapsed?a.expandSidebar:a.collapseSidebar;return(0,e.jsx)("button",{type:"button",onClick:r.toggle,className:(0,i.cn)("p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",t),"aria-label":n,"data-testid":"sidebar-toggle",children:(0,e.jsx)(ne,{className:(0,i.cn)("transition-transform duration-200",r.collapsed&&"rotate-180",r.position==="right"&&!r.collapsed&&"rotate-180",r.position==="right"&&r.collapsed&&"rotate-0")})})}0&&(module.exports={Sidebar,SidebarContent,SidebarFooter,SidebarGroup,SidebarHeader,SidebarItem,SidebarSubMenu,SidebarToggle,useSidebar});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as ee,useContext as te,useState as
|
|
1
|
+
"use client";import{createContext as ee,useContext as te,useState as v,useCallback as G,useEffect as H,useRef as C}from"react";import{useDialogA11y as re}from"../../hooks/useDialogA11y.js";import{cn as o}from"../../lib/cn.js";import{componentHref as ae}from"../../lib/safe-href.js";import{useUILabels as F}from"../../lib/i18n.js";import{Fragment as q,jsx as e,jsxs as m}from"react/jsx-runtime";var D=ee(null);function N(){let t=te(D);if(!t)throw new Error("Sidebar sub-components must be used within <Sidebar>");return t}function pe(){return N()}var oe=({className:t})=>e("svg",{className:o("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})}),ne=({className:t})=>e("svg",{className:o("w-4 h-4",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),ie=({className:t})=>e("svg",{className:o("w-5 h-5",t),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})});function Q({text:t,position:a,children:r}){let[n,p]=v(!1),[l,b]=v({top:0,left:0}),d=C(null);return m("div",{ref:d,onMouseEnter:()=>{if(d.current){let s=d.current.getBoundingClientRect();b({top:s.top+s.height/2,left:a==="left"?s.right+8:s.left-8})}p(!0)},onMouseLeave:()=>p(!1),className:"relative",children:[r,n&&e("div",{className:o("fixed z-[9999] px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900 dark:bg-gray-700 rounded-md shadow-lg whitespace-nowrap pointer-events-none",a==="right"&&"-translate-x-full"),style:{top:l.top,left:l.left,transform:`translateY(-50%)${a==="right"?" translateX(-100%)":""}`},role:"tooltip",children:t})]})}function be({collapsed:t,defaultCollapsed:a=!1,onCollapsedChange:r,expandedWidth:n=260,collapsedWidth:p=64,position:l="left",variant:b="default",mobileBreakpoint:d=768,mobileOpen:x,onMobileOpenChange:s,className:g,"aria-label":c,closeLabel:S,trapFocus:f=!0,initialFocus:k,returnFocus:M,lockScroll:R=!0,children:L}){let W=F(),V=C(null),z=C(null),[$,U]=v(a),[X,P]=v(!1),[u,Y]=v(!1),I=t!==void 0,w=I?t:$,y=x!==void 0,h=y?x:X;H(()=>{if(typeof window.matchMedia!="function")return;let i=window.matchMedia(`(max-width: ${d}px)`),E=O=>{Y(O.matches),O.matches||(y||P(!1),s?.(!1))};return E(i),i.addEventListener("change",E),()=>i.removeEventListener("change",E)},[d,y,s]);let J=G(()=>{if(u){let i=!h;y||P(i),s?.(i)}else{let i=!w;I||U(i),r?.(i)}},[u,h,w,y,I,s,r]),T=G(()=>{y||P(!1),s?.(!1)},[y,s]);H(()=>{let i=z.current;i&&(u&&!h?(i.setAttribute("inert",""),i.setAttribute("aria-hidden","true")):(i.removeAttribute("inert"),i.removeAttribute("aria-hidden")))},[u,h]);let{dialogRef:K,dialogProps:Z}=re({open:u&&h,onClose:T,trapFocus:f,initialFocus:k,returnFocus:M,lockScroll:R,keepInteractive:[V]}),_={default:"bg-white dark:bg-gray-900",bordered:o("bg-white dark:bg-gray-900",l==="left"?"border-r border-gray-200 dark:border-gray-700":"border-l border-gray-200 dark:border-gray-700"),floating:"bg-white dark:bg-gray-900 m-3 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700"},A=w&&!u?p:n,j=e("aside",{className:o("flex flex-col h-full overflow-hidden transition-[width] duration-200 ease-in-out",_[b],g),style:{width:u?n:A,minWidth:u?n:A},"data-testid":"sidebar","data-collapsed":w&&!u,"data-mobile":u,"data-position":l,children:L}),B={collapsed:w&&!u,isMobile:u,mobileOpen:h,position:l,variant:b,expandedWidth:n,collapsedWidth:p,toggle:J,closeMobile:T,closeLabel:S};return u?m(D.Provider,{value:B,children:[h&&e("div",{ref:V,className:"fixed inset-0 z-40 bg-black/50 transition-opacity",onClick:T,"aria-hidden":"true","data-testid":"sidebar-overlay"}),e("div",{ref:i=>{z.current=i,K.current=i},...Z,"aria-label":c??W.sidebar,className:o("fixed top-0 z-50 h-full transition-transform duration-200 ease-in-out focus:outline-none",l==="left"?"left-0":"right-0",h?"translate-x-0":l==="left"?"-translate-x-full":"translate-x-full"),children:j})]}):e(D.Provider,{value:B,children:j})}function fe({className:t,children:a}){let r=N(),n=F();return m("div",{className:o("flex items-center shrink-0 px-4 h-14 overflow-hidden",r.collapsed&&"justify-center px-2",t),"data-testid":"sidebar-header",children:[a,r.isMobile&&r.mobileOpen&&e("button",{type:"button",onClick:r.closeMobile,className:"ml-auto p-1 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer","aria-label":r.closeLabel??n.closeSidebar,children:e(ie,{})})]})}function ge({className:t,children:a}){return e("div",{className:o("flex-1 overflow-y-auto overflow-x-hidden py-2",t),"data-testid":"sidebar-content",children:a})}function me({className:t,children:a}){let r=N();return e("div",{className:o("shrink-0 border-t border-gray-200 dark:border-gray-700 px-4 py-3 overflow-hidden",r.collapsed&&"px-2 flex justify-center",t),"data-testid":"sidebar-footer",children:a})}function xe({label:t,className:a,children:r}){let n=N();return m("div",{className:o("py-2",a),"data-testid":"sidebar-group",children:[t&&!n.collapsed&&e("div",{className:"px-4 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:t}),t&&n.collapsed&&e("div",{className:"mx-auto my-1 w-6 border-t border-gray-200 dark:border-gray-700"}),e("div",{className:"space-y-0.5 px-2",children:r})]})}function he({icon:t,label:a,badge:r,badgeColor:n="bg-synertech-primary-600 text-synertech-on-primary",active:p=!1,disabled:l=!1,href:b,onClick:d,tooltip:x,className:s}){let g=N(),c=g.collapsed,S=x??a,f=m(q,{children:[t&&e("span",{className:o("shrink-0 w-5 h-5",c&&"w-5 h-5"),children:t}),!c&&m(q,{children:[e("span",{className:"flex-1 truncate",children:a}),r!=null&&e("span",{className:o("shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1",n),children:r})]}),c&&r!==void 0&&r!==null&&e("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-synertech-primary-600"})]}),k=o("relative flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full",c?"justify-center px-2 py-2.5":"px-3 py-2",p?"bg-synertech-primary-50 text-synertech-primary-700 dark:bg-synertech-primary-900/30 dark:text-synertech-primary-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",l&&"opacity-50 pointer-events-none",!l&&"cursor-pointer",s),M=()=>{l||(d?.(),g.isMobile&&g.closeMobile())},R=ae("SidebarItem",b),L=R?e("a",{href:l?void 0:R,className:k,onClick:M,"aria-current":p?"page":void 0,"data-testid":"sidebar-item",children:f}):e("button",{type:"button",className:k,onClick:M,disabled:l,"aria-current":p?"page":void 0,"data-testid":"sidebar-item",children:f});return c?e(Q,{text:S,position:g.position,children:L}):L}function ye({icon:t,label:a,badge:r,defaultOpen:n=!1,className:p,children:l}){let b=N(),[d,x]=v(n),s=C(null),[g,c]=v(n?void 0:0),S=C(!0);return H(()=>{if(S.current){S.current=!1,c(d?void 0:0);return}if(d){let f=s.current;if(f){c(f.scrollHeight);let k=setTimeout(()=>c(void 0),200);return()=>clearTimeout(k)}}else{let f=s.current;f&&(c(f.scrollHeight),requestAnimationFrame(()=>c(0)))}},[d]),b.collapsed?e(Q,{text:a,position:b.position,children:m("button",{type:"button",className:o("relative flex items-center justify-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-2 py-2.5","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer",p),onClick:()=>{b.toggle(),x(!0)},"data-testid":"sidebar-submenu-trigger",children:[t&&e("span",{className:"shrink-0 w-5 h-5",children:t}),r!=null&&e("span",{className:"absolute top-1 right-1 w-2 h-2 rounded-full bg-synertech-primary-600"})]})}):m("div",{className:p,"data-testid":"sidebar-submenu",children:[m("button",{type:"button",className:o("flex items-center gap-3 rounded-md text-sm font-medium transition-colors w-full px-3 py-2","text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"),onClick:()=>x(!d),"aria-expanded":d,"data-testid":"sidebar-submenu-trigger",children:[t&&e("span",{className:"shrink-0 w-5 h-5",children:t}),e("span",{className:"flex-1 truncate text-left",children:a}),r!=null&&e("span",{className:"shrink-0 inline-flex items-center justify-center rounded-full text-[10px] font-semibold min-w-[18px] h-[18px] px-1 bg-synertech-primary-600 text-synertech-on-primary",children:r}),e(ne,{className:o("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",d&&"rotate-180")})]}),e("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},children:e("div",{ref:s,className:"pl-4 py-0.5",children:l})})]})}function ve({className:t}){let a=N(),r=F(),n=a.isMobile?a.mobileOpen?a.closeLabel??r.closeSidebar:r.openSidebar:a.collapsed?r.expandSidebar:r.collapseSidebar;return e("button",{type:"button",onClick:a.toggle,className:o("p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer",t),"aria-label":n,"data-testid":"sidebar-toggle",children:e(oe,{className:o("transition-transform duration-200",a.collapsed&&"rotate-180",a.position==="right"&&!a.collapsed&&"rotate-180",a.position==="right"&&a.collapsed&&"rotate-0")})})}export{be as Sidebar,ge as SidebarContent,me as SidebarFooter,xe as SidebarGroup,fe as SidebarHeader,he as SidebarItem,ye as SidebarSubMenu,ve as SidebarToggle,pe as useSidebar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var R=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";"use client";var R=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var se=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},oe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ae(e))!ne.call(r,s)&&s!==t&&R(r,s,{get:()=>e[s],enumerable:!(n=te(e,s))||n.enumerable});return r};var le=r=>oe(R({},"__esModule",{value:!0}),r);var ve={};se(ve,{Slider:()=>O});module.exports=le(ve);var i=require("react"),l=require("../../lib/cn.cjs"),a=require("react/jsx-runtime"),ie={sm:"h-1",md:"h-1.5",lg:"h-2"},de={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ue={sm:14,md:16,lg:20},ce="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",be={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},me={sm:"h-4",md:"h-5",lg:"h-6"},ge={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},pe={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},ye={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},fe={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},B=(r,e,t)=>Math.min(t,Math.max(e,r)),P=(r,e,t)=>t>e?(B(r,e,t)-e)/(t-e)*100:0,w=(r,e)=>{let t=(.5-r/100)*e,n=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${n}px)`},he=(r,e,t,n)=>{if(!r)return[];if(Array.isArray(r))return r;let s=n>0?n:1,d=Math.floor((t-e)/s);return d<=0||d>20?[{value:e},{value:t}]:Array.from({length:d+1},(u,k)=>({value:e+k*s}))},O=(0,i.forwardRef)(({value:r,defaultValue:e,onValueChange:t,min:n=0,max:s=100,step:d=1,size:u="md",color:k="primary",disabled:m=!1,readOnly:S=!1,label:x,description:$,error:C=!1,showValue:V=!1,showTooltip:_=!1,valueFormat:I,marks:T,trackColor:E,fillColor:N,thumbColor:g,className:j,containerClassName:q,id:D,...G},J)=>{let[K,Q]=(0,i.useState)(e??n),A=r!==void 0,b=B(A?r:K,n,s),U=(0,i.useId)(),p=D??U,y=typeof C=="string"?C:void 0,H=!!C,f=!m&&!S,h=H?"error":k,L=P(b,n,s),v=ue[u],X=o=>{if(!f)return;let c=Number(o.target.value);A||Q(c),t?.(c)},z=(0,i.useMemo)(()=>he(T,n,s,d),[T,n,s,d]),Y=z.some(o=>o.label!=null),W=I?I(b):`${b}`,F={width:w(L,v)};N&&(F.backgroundColor=N);let M={left:w(L,v)};g&&(M.backgroundColor=g,M.borderColor=g);let Z=E?{backgroundColor:E}:{};return(0,a.jsxs)("div",{className:(0,l.cn)("w-full",q),children:[(x||V)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[x?(0,a.jsx)("label",{htmlFor:p,className:(0,l.cn)("text-sm font-medium text-gray-700 dark:text-gray-200",m&&"opacity-50"),children:x}):(0,a.jsx)("span",{}),V&&(0,a.jsx)("span",{className:(0,l.cn)("text-sm font-semibold tabular-nums",fe[h]),children:W})]}),(0,a.jsxs)("div",{className:(0,l.cn)("relative flex items-center",me[u],m&&"opacity-50"),children:[(0,a.jsx)("input",{ref:J,type:"range",id:p,min:n,max:s,step:d,value:b,onChange:X,disabled:m,readOnly:S,"aria-invalid":H,"aria-readonly":S||void 0,"aria-describedby":y?`${p}-error`:void 0,tabIndex:f?void 0:-1,className:(0,l.cn)("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",ce,be[u],!f&&"pointer-events-none cursor-default",j),...G}),(0,a.jsxs)("div",{className:(0,l.cn)("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ie[u]),style:Z,children:[(0,a.jsx)("div",{className:(0,l.cn)("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",N?"":ge[h]),style:F}),z.map((o,c)=>{let ee=P(o.value,n,s),re=o.value<=b;return(0,a.jsx)("span",{"data-slider-mark":"",className:(0,l.cn)("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",re?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:w(ee,v)}},`mark-${o.value}-${c}`)})]}),(0,a.jsx)("div",{"data-slider-thumb":"",className:(0,l.cn)("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",de[u],g?"":pe[h],f&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",ye[h]),style:M,children:_&&(0,a.jsx)("span",{"data-slider-tooltip":"",className:(0,l.cn)("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:W})})]}),Y&&(0,a.jsx)("div",{className:"relative mt-1.5 h-4",children:z.map((o,c)=>o.label!=null?(0,a.jsx)("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:w(P(o.value,n,s),v)},children:o.label},`mark-label-${o.value}-${c}`):null)}),$&&!y&&(0,a.jsx)("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:$}),y&&(0,a.jsx)("p",{id:`${p}-error`,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:y})]})});O.displayName="Slider";0&&(module.exports={Slider});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as ee,useId as re,useMemo as te,forwardRef as ae}from"react";import{cn as l}from"../../lib/cn.js";import{jsx as
|
|
1
|
+
"use client";import{useState as ee,useId as re,useMemo as te,forwardRef as ae}from"react";import{cn as l}from"../../lib/cn.js";import{jsx as s,jsxs as w}from"react/jsx-runtime";var ne={sm:"h-1",md:"h-1.5",lg:"h-2"},se={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},oe={sm:14,md:16,lg:20},le="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",ie={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},de={sm:"h-4",md:"h-5",lg:"h-6"},ue={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},ce={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},be={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},me={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},F=(r,e,t)=>Math.min(t,Math.max(e,r)),R=(r,e,t)=>t>e?(F(r,e,t)-e)/(t-e)*100:0,v=(r,e)=>{let t=(.5-r/100)*e,a=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${a}px)`},ge=(r,e,t,a)=>{if(!r)return[];if(Array.isArray(r))return r;let o=a>0?a:1,i=Math.floor((t-e)/o);return i<=0||i>20?[{value:e},{value:t}]:Array.from({length:i+1},(d,k)=>({value:e+k*o}))},pe=ae(({value:r,defaultValue:e,onValueChange:t,min:a=0,max:o=100,step:i=1,size:d="md",color:k="primary",disabled:b=!1,readOnly:S=!1,label:x,description:P,error:C=!1,showValue:$=!1,showTooltip:B=!1,valueFormat:V,marks:I,trackColor:T,fillColor:N,thumbColor:m,className:O,containerClassName:_,id:j,...q},D)=>{let[G,J]=ee(e??a),E=r!==void 0,c=F(E?r:G,a,o),K=re(),g=j??K,p=typeof C=="string"?C:void 0,A=!!C,y=!b&&!S,f=A?"error":k,H=R(c,a,o),h=oe[d],Q=n=>{if(!y)return;let u=Number(n.target.value);E||J(u),t?.(u)},z=te(()=>ge(I,a,o,i),[I,a,o,i]),U=z.some(n=>n.label!=null),L=V?V(c):`${c}`,W={width:v(H,h)};N&&(W.backgroundColor=N);let M={left:v(H,h)};m&&(M.backgroundColor=m,M.borderColor=m);let X=T?{backgroundColor:T}:{};return w("div",{className:l("w-full",_),children:[(x||$)&&w("div",{className:"flex items-center justify-between mb-1.5",children:[x?s("label",{htmlFor:g,className:l("text-sm font-medium text-gray-700 dark:text-gray-200",b&&"opacity-50"),children:x}):s("span",{}),$&&s("span",{className:l("text-sm font-semibold tabular-nums",me[f]),children:L})]}),w("div",{className:l("relative flex items-center",de[d],b&&"opacity-50"),children:[s("input",{ref:D,type:"range",id:g,min:a,max:o,step:i,value:c,onChange:Q,disabled:b,readOnly:S,"aria-invalid":A,"aria-readonly":S||void 0,"aria-describedby":p?`${g}-error`:void 0,tabIndex:y?void 0:-1,className:l("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",le,ie[d],!y&&"pointer-events-none cursor-default",O),...q}),w("div",{className:l("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ne[d]),style:X,children:[s("div",{className:l("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",N?"":ue[f]),style:W}),z.map((n,u)=>{let Y=R(n.value,a,o),Z=n.value<=c;return s("span",{"data-slider-mark":"",className:l("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",Z?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:v(Y,h)}},`mark-${n.value}-${u}`)})]}),s("div",{"data-slider-thumb":"",className:l("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",se[d],m?"":ce[f],y&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",be[f]),style:M,children:B&&s("span",{"data-slider-tooltip":"",className:l("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:L})})]}),U&&s("div",{className:"relative mt-1.5 h-4",children:z.map((n,u)=>n.label!=null?s("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:v(R(n.value,a,o),h)},children:n.label},`mark-label-${n.value}-${u}`):null)}),P&&!p&&s("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:P}),p&&s("p",{id:`${g}-error`,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:p})]})});pe.displayName="Slider";export{pe as Slider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";"use client";var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var s in t)r(e,s,{get:t[s],enumerable:!0})},g=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!u.call(e,n)&&n!==s&&r(e,n,{get:()=>t[n],enumerable:!(i=f(t,n))||i.enumerable});return e};var h=e=>g(r({},"__esModule",{value:!0}),e);var y={};m(y,{TabsContent:()=>d});module.exports=h(y);var c=require("../../lib/cn.cjs"),a=require("./TabsContext.cjs"),b=require("react/jsx-runtime");function d({value:e,children:t,className:s,forceMount:i=!1}){let{value:n,baseId:l}=(0,a.useTabsContext)(),o=n===e;return!o&&!i?null:(0,b.jsx)("div",{role:"tabpanel",id:(0,a.getTabsId)(l,"panel",e),"aria-labelledby":(0,a.getTabsId)(l,"tab",e),hidden:!o,tabIndex:0,className:(0,c.cn)("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-synertech-primary-500 rounded-md",!o&&"hidden",s),children:t})}d.displayName="TabsContent";0&&(module.exports={TabsContent});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{cn as l}from"../../lib/cn.js";import{getTabsId as s,useTabsContext as
|
|
1
|
+
"use client";import{cn as l}from"../../lib/cn.js";import{getTabsId as s,useTabsContext as c}from"./TabsContext.js";import{jsx as b}from"react/jsx-runtime";function d({value:e,children:a,className:i,forceMount:o=!1}){let{value:r,baseId:n}=c(),t=r===e;return!t&&!o?null:b("div",{role:"tabpanel",id:s(n,"panel",e),"aria-labelledby":s(n,"tab",e),hidden:!t,tabIndex:0,className:l("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-synertech-primary-500 rounded-md",!t&&"hidden",i),children:a})}d.displayName="TabsContent";export{d as TabsContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var x=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},A=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of B(r))!L.call(e,a)&&a!==t&&x(e,a,{get:()=>r[a],enumerable:!(i=D(r,a))||i.enumerable});return e};var H=e=>A(x({},"__esModule",{value:!0}),e);var W={};P(W,{TabsTrigger:()=>m});module.exports=H(W);var u=require("react"),o=require("../../lib/cn.cjs"),d=require("./TabsContext.cjs"),n=require("react/jsx-runtime"),M={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},h={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},k={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-synertech-primary-600 dark:text-synertech-primary-400 border-synertech-primary-600 dark:border-synertech-primary-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"},pills:{active:"bg-synertech-primary-600 text-synertech-on-primary",inactive:"text-gray-600 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"},enclosed:{active:"bg-synertech-primary-50 dark:bg-synertech-primary-900/20 text-synertech-primary-600 dark:text-synertech-primary-400 border-synertech-primary-200 dark:border-synertech-primary-800 border-b-synertech-primary-50 dark:border-b-synertech-primary-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400 border-transparent"},soft:{active:"bg-synertech-primary-100 dark:bg-synertech-primary-900/50 text-synertech-primary-700 dark:text-synertech-primary-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400 hover:bg-synertech-primary-50 dark:hover:bg-synertech-primary-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-700 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-700 dark:hover:text-green-400"},pills:{active:"bg-green-700 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-700 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-700 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-gray-900",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},O={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function m({value:e,children:r,disabled:t=!1,icon:i,endIcon:a,className:w,activeClassName:f,inactiveClassName:T}){let{value:C,onValueChange:N,variant:y,size:g,color:c,fullWidth:R,baseId:b}=(0,d.useTabsContext)(),{fallbackTabStopId:S}=(0,u.useContext)(d.TabsListContext),s=C===e,p=(0,d.getTabsId)(b,"tab",e),z=!t&&(s||S===p),v=()=>{t||N(e)},I=l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),v())},E=(0,o.cn)("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-synertech-primary-500",M[g],R&&"flex-1"),K=s?(0,o.cn)(k[c][y].active,f):(0,o.cn)(k[c][y].inactive,T),V=t?"opacity-50 cursor-not-allowed":"cursor-pointer";return(0,n.jsxs)("button",{type:"button",role:"tab",id:p,"aria-selected":s,"aria-controls":s?(0,d.getTabsId)(b,"panel",e):void 0,"aria-disabled":t,tabIndex:z?0:-1,onClick:v,onKeyDown:I,disabled:t,className:(0,o.cn)(E,O[y],K,V,w),children:[i&&(0,n.jsx)("span",{className:(0,o.cn)("shrink-0",h[g]),children:i}),(0,n.jsx)("span",{children:r}),a&&(0,n.jsx)("span",{className:(0,o.cn)("shrink-0",h[g]),children:a})]})}m.displayName="TabsTrigger";0&&(module.exports={TabsTrigger});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useContext as E}from"react";import{cn as e}from"../../lib/cn.js";import{getTabsId as
|
|
1
|
+
"use client";import{useContext as E}from"react";import{cn as e}from"../../lib/cn.js";import{getTabsId as b,TabsListContext as K,useTabsContext as V}from"./TabsContext.js";import{jsx as i,jsxs as P}from"react/jsx-runtime";var D={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},p={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},v={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-synertech-primary-600 dark:text-synertech-primary-400 border-synertech-primary-600 dark:border-synertech-primary-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"},pills:{active:"bg-synertech-primary-600 text-synertech-on-primary",inactive:"text-gray-600 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"},enclosed:{active:"bg-synertech-primary-50 dark:bg-synertech-primary-900/20 text-synertech-primary-600 dark:text-synertech-primary-400 border-synertech-primary-200 dark:border-synertech-primary-800 border-b-synertech-primary-50 dark:border-b-synertech-primary-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400 border-transparent"},soft:{active:"bg-synertech-primary-100 dark:bg-synertech-primary-900/50 text-synertech-primary-700 dark:text-synertech-primary-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400 hover:bg-synertech-primary-50 dark:hover:bg-synertech-primary-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-700 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-700 dark:hover:text-green-400"},pills:{active:"bg-green-700 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-700 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-700 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-700 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-gray-900",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-700 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-700 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},B={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function L({value:t,children:h,disabled:r=!1,icon:s,endIcon:y,className:k,activeClassName:u,inactiveClassName:m}){let{value:w,onValueChange:f,variant:o,size:d,color:g,fullWidth:T,baseId:l}=V(),{fallbackTabStopId:C}=E(K),a=w===t,x=b(l,"tab",t),N=!r&&(a||C===x),c=()=>{r||f(t)},R=n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),c())},S=e("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-synertech-primary-500",D[d],T&&"flex-1"),z=a?e(v[g][o].active,u):e(v[g][o].inactive,m),I=r?"opacity-50 cursor-not-allowed":"cursor-pointer";return P("button",{type:"button",role:"tab",id:x,"aria-selected":a,"aria-controls":a?b(l,"panel",t):void 0,"aria-disabled":r,tabIndex:N?0:-1,onClick:c,onKeyDown:R,disabled:r,className:e(S,B[o],z,I,k),children:[s&&i("span",{className:e("shrink-0",p[d]),children:s}),i("span",{children:h}),y&&i("span",{className:e("shrink-0",p[d]),children:y})]})}L.displayName="TabsTrigger";export{L as TabsTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var se=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Le=(c,a)=>{for(var
|
|
1
|
+
"use strict";"use client";var se=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Le=(c,a)=>{for(var i in a)se(c,i,{get:a[i],enumerable:!0})},Ee=(c,a,i,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of Se(a))!We.call(c,d)&&d!==i&&se(c,d,{get:()=>a[d],enumerable:!(r=Re(a,d))||r.enumerable});return c};var Pe=c=>Ee(se({},"__esModule",{value:!0}),c);var Be={};Le(Be,{WaterfallChart:()=>Me});module.exports=Pe(Be);var u=require("react"),me=require("../../lib/i18n.cjs"),ce=require("../chart/ChartAxis.cjs"),ue=require("../chart/ChartContainer.cjs"),ge=require("../chart/ChartGrid.cjs"),he=require("../chart/ChartLegend.cjs"),fe=require("../chart/ChartTableView.cjs"),ye=require("../chart/ChartTooltip.cjs"),V=require("../chart/palette.cjs"),be=require("../chart/utils/cartesian.cjs"),re=require("../chart/utils/data.cjs"),ne=require("../chart/utils/format.cjs"),Ce=require("../chart/utils/keyboard.cjs"),pe=require("../chart/utils/path.cjs"),ve=require("../chart/utils/scales.cjs"),ke=require("../chart/utils/text.cjs"),xe=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),Ve=24,Te=4,K=6,Ne=(0,V.rampColor)(V.CHART_DIVERGING_COLORS,1),we=(0,V.rampColor)(V.CHART_DIVERGING_COLORS,0),Ae=(0,u.memo)(function({bars:a,connectors:i}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:i.map(r=>(0,t.jsx)("line",{x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2},r.key))}),a.map(r=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r.d,fill:r.color}),r.label?(0,t.jsx)("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},r.key))]})});function Ie({width:c,height:a,steps:i,data:r,x:d,y:v,grid:I,size:F,orientation:O,connectors:J,showValues:T,barSize:H,palette:$,margin:M,tooltip:N,plotLabel:B,totalLabel:le,formatValue:G,formatX:_,onStepClick:w}){let[z,D]=(0,u.useState)(null),g=z!==null&&z<i.length?z:null,e=(0,u.useMemo)(()=>{let s=O==="vertical",S=i.flatMap(n=>[n.start,n.end]),C=(0,be.buildCartesianGeometry)({width:c,height:a,data:r,x:d,y:v,bounds:S.length===0?null:[Math.min(...S),Math.max(...S)],margin:M,orientation:O,placement:"band",formatValue:G,formatX:_,defaultIncludeZero:!0}),{valueScale:k,bandwidth:W,categoryPositions:Z,innerWidth:Q,innerHeight:ee}=C,L=k(0),m=Math.min(H??Ve,W),E=[],x=[];return i.forEach((n,b)=>{let P=Z[b]+(W-m)/2,te=k(n.start),ae=k(n.end),j=Math.min(te,ae),l=Math.abs(ae-te),h=n.end>=n.start,A=s?h?"top":"bottom":h?"right":"left",X=s?{x:P,y:j,width:m,height:l}:{x:j,y:P,width:l,height:m},f=null;if(T&&n.value!==null){let p=n.kind==="total"?n.formattedEnd:n.formattedValue,R=(0,ke.estimateTextWidth)(p,10),y=k(h?Math.max(n.start,n.end):Math.min(n.start,n.end));if(s){let q=h?y-K:y+K;R<=W&&q>8&&q<ee-4&&(f={x:P+m/2,y:q,anchor:"middle",text:p})}else{let q=h?Q-y-K:y-K;R<=q&&(f={x:h?y+K:y-K,y:P+m/2,anchor:h?"start":"end",text:p})}}E.push({key:`${b}`,color:$[n.kind],d:(0,pe.buildBarPath)({...X,radius:Te,round:A}),label:f});let de=i[b+1];if(J&&de){let p=k(n.end),R=Z[b+1]+(W-m)/2;x.push(s?{key:`${b}`,x1:P+m,y1:p,x2:R,y2:p}:{key:`${b}`,x1:p,y1:P+m,x2:p,y2:R})}}),{vertical:s,bars:E,rules:x,baseline:L,bandwidth:W,categoryPositions:Z,categoryCenters:C.categoryCenters,categoryTicks:C.categoryTicks,valueTicks:C.valueTicks,valueScale:k,innerWidth:Q,innerHeight:ee,margin:C.margin}},[i,r,d,v,c,a,M,O,J,T,H,$,G,_]),ie=(0,u.useCallback)(s=>{if(N===!1||i.length===0)return;let S=s.currentTarget.getBoundingClientRect(),C=e.vertical?s.clientX-S.left-e.margin.left:s.clientY-S.top-e.margin.top;D((0,ve.nearestIndex)(e.categoryCenters,C))},[N,i.length,e.vertical,e.margin,e.categoryCenters]),U=(0,u.useCallback)(()=>{!w||g===null||w(i[g])},[w,g,i]),oe=(0,u.useCallback)(s=>(0,Ce.handleChartKeyDown)(s,{count:i.length,current:g,axis:e.vertical?"x":"y",onMove:D,pick:w?U:null}),[i.length,g,e.vertical,w,U]),o=g===null?null:i[g],Y=g===null||o===void 0||o===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[g],y:e.margin.top+Math.min(e.valueScale(o.start),e.valueScale(o.end))}:{x:e.margin.left+Math.max(e.valueScale(o.start),e.valueScale(o.end)),y:e.margin.top+e.categoryCenters[g]};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:c,height:a,role:"img","aria-label":B??i.map(s=>s.label).join(", "),tabIndex:0,className:`${xe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ie,onPointerLeave:()=>D(null),onKeyDown:oe,onBlur:()=>D(null),onClick:U,children:[(0,t.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,t.jsx)(ge.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(I==="y"||I==="both")?e.valueTicks.map(s=>s.offset):void 0,vertical:!e.vertical&&(I==="y"||I==="both")?e.valueTicks.map(s=>s.offset):void 0}),g!==null?(0,t.jsx)("rect",{x:e.vertical?e.categoryPositions[g]:0,y:e.vertical?0:e.categoryPositions[g],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Ae,{bars:e.bars,connectors:e.rules}),(0,t.jsx)("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?d.hidden:v?.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?d.label:v?.label,size:F})}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?v?.hidden:d.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?v?.label:d.label,size:F})})]}),o&&Y&&N!==!1?(0,t.jsx)(ye.ChartTooltip,{x:Y.x,y:Y.y,containerWidth:c,children:typeof N=="function"?N(o):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:o.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[o.kind]},"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:o.kind==="total"?o.formattedEnd:o.formattedValue})]}),o.kind==="total"?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:le}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:o.formattedEnd})]})]})}):null]})}function Me({data:c,x:a,y:i,value:r,total:d,start:v=0,orientation:I="vertical",connectors:F=!0,showValues:O=!0,barSize:J,colors:T,height:H=280,width:$,size:M="md",grid:N="y",legend:B,tooltip:le=!0,tableView:G=!1,title:_,description:w,loading:z=!1,emptyState:D,error:g=!1,errorState:e,onRetry:ie,actions:U,margin:oe,locale:o,plotLabel:Y,valueLabel:s,totalLabel:S,increaseLabel:C,decreaseLabel:k,format:W,onStepClick:Z,className:Q,...ee}){let L=(0,me.useUILabels)(),m=(0,u.useMemo)(()=>W??(l=>(0,ne.formatAuto)(l,o)),[W,o]),E=(0,u.useMemo)(()=>a.format??(l=>(0,ne.formatXValue)(l,o)),[a.format,o]),x=(0,u.useMemo)(()=>{let l=v;return c.map((h,A)=>{let X=(0,re.readXValue)(h,a.key,A),f=(0,re.readNumber)(h,r);if(d?!!h[d]:!1){let y=f??l;return l=y,{index:A,x:X,label:E(X,A),value:y,start:0,end:y,kind:"total",formattedValue:m(y),formattedEnd:m(y),datum:h}}let p=l,R=f===null?l:l+f;return l=R,{index:A,x:X,label:E(X,A),value:f,start:p,end:R,kind:f!==null&&f<0?"decrease":"increase",formattedValue:f===null?"\u2014":`${f>0?"+":""}${m(f)}`,formattedEnd:m(R),datum:h}})},[c,a.key,r,d,v,m,E]),n=(0,u.useMemo)(()=>({increase:T?.increase??Ne,decrease:T?.decrease??we,total:T?.total??V.CHART_MUTED_COLOR}),[T]),b=S??L.chartRunningTotal,P=(0,u.useMemo)(()=>{let l=[{key:"increase",label:C??L.chartIncrease,color:n.increase,marker:"rect"},{key:"decrease",label:k??L.chartDecrease,color:n.decrease,marker:"rect"}];return x.some(h=>h.kind==="total")&&l.push({key:"total",label:b,color:n.total,marker:"rect"}),l},[n,x,C,k,b,L.chartIncrease,L.chartDecrease]),te=(0,u.useMemo)(()=>x.map(l=>({[a.key]:l.x,[r]:l.kind==="total"?null:l.value,__running:l.end})),[x,a.key,r]),ae=B===void 0?!0:B!==!1,j=typeof B=="string"?B:"bottom";return(0,t.jsx)(ue.ChartContainer,{title:_,description:w,height:H,width:$,size:M,loading:z,empty:x.length===0,emptyState:D,error:g,errorState:e,onRetry:ie,actions:U,tableView:G,legendPosition:j,legend:ae?(0,t.jsx)(he.ChartLegend,{items:P,position:j,marker:"rect",size:M}):void 0,table:G?(0,t.jsx)(fe.ChartTableView,{data:te,series:[{key:r,label:s??L.chartValue},{key:"__running",label:b}],xKey:a.key,xLabel:a.label??a.key,formatX:E,formatValue:m,caption:typeof _=="string"?_:void 0}):void 0,className:Q,...ee,children:({width:l})=>(0,t.jsx)(Ie,{width:l,height:H,steps:x,data:c,x:a,y:i,grid:N,size:M,orientation:I,connectors:F,showValues:O,barSize:J,palette:n,margin:oe,tooltip:le,plotLabel:Y,totalLabel:b,formatValue:m,formatX:E,onStepClick:Z})})}0&&(module.exports={WaterfallChart});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{memo as me,useCallback as
|
|
1
|
+
"use client";import{memo as me,useCallback as ie,useMemo as A,useState as ue}from"react";import{useUILabels as ge}from"../../lib/i18n.js";import{ChartAxis as se}from"../chart/ChartAxis.js";import{ChartContainer as he}from"../chart/ChartContainer.js";import{ChartGrid as fe}from"../chart/ChartGrid.js";import{ChartLegend as ye}from"../chart/ChartLegend.js";import{ChartTableView as be}from"../chart/ChartTableView.js";import{ChartTooltip as Ce}from"../chart/ChartTooltip.js";import{CHART_DIVERGING_COLORS as ce,CHART_MUTED_COLOR as pe,rampColor as de}from"../chart/palette.js";import{buildCartesianGeometry as ve}from"../chart/utils/cartesian.js";import{readNumber as ke,readXValue as xe}from"../chart/utils/data.js";import{formatAuto as Re,formatXValue as Se}from"../chart/utils/format.js";import{handleChartKeyDown as We}from"../chart/utils/keyboard.js";import{buildBarPath as Le}from"../chart/utils/path.js";import{nearestIndex as Ee}from"../chart/utils/scales.js";import{estimateTextWidth as Pe}from"../chart/utils/text.js";import{CHART_TOUCH as Ve}from"../chart/utils/touch.js";import{Fragment as Be,jsx as n,jsxs as P}from"react/jsx-runtime";var Te=24,Ne=4,K=6,we=de(ce,1),Ae=de(ce,0),Ie=me(function({bars:s,connectors:o}){return P("g",{children:[n("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:o.map(t=>n("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2},t.key))}),s.map(t=>P("g",{children:[n("path",{d:t.d,fill:t.color}),t.label?n("text",{x:t.label.x,y:t.label.y,textAnchor:t.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:t.label.text}):null]},t.key))]})});function Me({width:C,height:s,steps:o,data:t,x:f,y:p,grid:I,size:F,orientation:O,connectors:J,showValues:V,barSize:H,palette:$,margin:M,tooltip:T,plotLabel:B,totalLabel:re,formatValue:G,formatX:_,onStepClick:N}){let[z,D]=ue(null),d=z!==null&&z<o.length?z:null,e=A(()=>{let i=O==="vertical",R=o.flatMap(a=>[a.start,a.end]),y=ve({width:C,height:s,data:t,x:f,y:p,bounds:R.length===0?null:[Math.min(...R),Math.max(...R)],margin:M,orientation:O,placement:"band",formatValue:G,formatX:_,defaultIncludeZero:!0}),{valueScale:v,bandwidth:S,categoryPositions:Z,innerWidth:Q,innerHeight:ee}=y,W=v(0),c=Math.min(H??Te,S),L=[],k=[];return o.forEach((a,h)=>{let E=Z[h]+(S-c)/2,te=v(a.start),ae=v(a.end),j=Math.min(te,ae),r=Math.abs(ae-te),m=a.end>=a.start,w=i?m?"top":"bottom":m?"right":"left",X=i?{x:E,y:j,width:c,height:r}:{x:j,y:E,width:r,height:c},u=null;if(V&&a.value!==null){let b=a.kind==="total"?a.formattedEnd:a.formattedValue,x=Pe(b,10),g=v(m?Math.max(a.start,a.end):Math.min(a.start,a.end));if(i){let q=m?g-K:g+K;x<=S&&q>8&&q<ee-4&&(u={x:E+c/2,y:q,anchor:"middle",text:b})}else{let q=m?Q-g-K:g-K;x<=q&&(u={x:m?g+K:g-K,y:E+c/2,anchor:m?"start":"end",text:b})}}L.push({key:`${h}`,color:$[a.kind],d:Le({...X,radius:Ne,round:w}),label:u});let oe=o[h+1];if(J&&oe){let b=v(a.end),x=Z[h+1]+(S-c)/2;k.push(i?{key:`${h}`,x1:E+c,y1:b,x2:x,y2:b}:{key:`${h}`,x1:b,y1:E+c,x2:b,y2:x})}}),{vertical:i,bars:L,rules:k,baseline:W,bandwidth:S,categoryPositions:Z,categoryCenters:y.categoryCenters,categoryTicks:y.categoryTicks,valueTicks:y.valueTicks,valueScale:v,innerWidth:Q,innerHeight:ee,margin:y.margin}},[o,t,f,p,C,s,M,O,J,V,H,$,G,_]),ne=ie(i=>{if(T===!1||o.length===0)return;let R=i.currentTarget.getBoundingClientRect(),y=e.vertical?i.clientX-R.left-e.margin.left:i.clientY-R.top-e.margin.top;D(Ee(e.categoryCenters,y))},[T,o.length,e.vertical,e.margin,e.categoryCenters]),U=ie(()=>{!N||d===null||N(o[d])},[N,d,o]),le=ie(i=>We(i,{count:o.length,current:d,axis:e.vertical?"x":"y",onMove:D,pick:N?U:null}),[o.length,d,e.vertical,N,U]),l=d===null?null:o[d],Y=d===null||l===void 0||l===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[d],y:e.margin.top+Math.min(e.valueScale(l.start),e.valueScale(l.end))}:{x:e.margin.left+Math.max(e.valueScale(l.start),e.valueScale(l.end)),y:e.margin.top+e.categoryCenters[d]};return P(Be,{children:[P("svg",{width:C,height:s,role:"img","aria-label":B??o.map(i=>i.label).join(", "),tabIndex:0,className:`${Ve} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ne,onPointerLeave:()=>D(null),onKeyDown:le,onBlur:()=>D(null),onClick:U,children:[P("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[n(fe,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(I==="y"||I==="both")?e.valueTicks.map(i=>i.offset):void 0,vertical:!e.vertical&&(I==="y"||I==="both")?e.valueTicks.map(i=>i.offset):void 0}),d!==null?n("rect",{x:e.vertical?e.categoryPositions[d]:0,y:e.vertical?0:e.categoryPositions[d],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,n(Ie,{bars:e.bars,connectors:e.rules}),n("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?f.hidden:p?.hidden)?null:n(se,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?f.label:p?.label,size:F})}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?p?.hidden:f.hidden)?null:n(se,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?p?.label:f.label,size:F})})]}),l&&Y&&T!==!1?n(Ce,{x:Y.x,y:Y.y,containerWidth:C,children:typeof T=="function"?T(l):P("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),P("div",{className:"flex items-center gap-2",children:[n("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[l.kind]},"aria-hidden":"true"}),n("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:l.kind==="total"?l.formattedEnd:l.formattedValue})]}),l.kind==="total"?null:P("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[n("span",{children:re}),n("span",{className:"[font-variant-numeric:tabular-nums]",children:l.formattedEnd})]})]})}):null]})}function et({data:C,x:s,y:o,value:t,total:f,start:p=0,orientation:I="vertical",connectors:F=!0,showValues:O=!0,barSize:J,colors:V,height:H=280,width:$,size:M="md",grid:T="y",legend:B,tooltip:re=!0,tableView:G=!1,title:_,description:N,loading:z=!1,emptyState:D,error:d=!1,errorState:e,onRetry:ne,actions:U,margin:le,locale:l,plotLabel:Y,valueLabel:i,totalLabel:R,increaseLabel:y,decreaseLabel:v,format:S,onStepClick:Z,className:Q,...ee}){let W=ge(),c=A(()=>S??(r=>Re(r,l)),[S,l]),L=A(()=>s.format??(r=>Se(r,l)),[s.format,l]),k=A(()=>{let r=p;return C.map((m,w)=>{let X=xe(m,s.key,w),u=ke(m,t);if(f?!!m[f]:!1){let g=u??r;return r=g,{index:w,x:X,label:L(X,w),value:g,start:0,end:g,kind:"total",formattedValue:c(g),formattedEnd:c(g),datum:m}}let b=r,x=u===null?r:r+u;return r=x,{index:w,x:X,label:L(X,w),value:u,start:b,end:x,kind:u!==null&&u<0?"decrease":"increase",formattedValue:u===null?"\u2014":`${u>0?"+":""}${c(u)}`,formattedEnd:c(x),datum:m}})},[C,s.key,t,f,p,c,L]),a=A(()=>({increase:V?.increase??we,decrease:V?.decrease??Ae,total:V?.total??pe}),[V]),h=R??W.chartRunningTotal,E=A(()=>{let r=[{key:"increase",label:y??W.chartIncrease,color:a.increase,marker:"rect"},{key:"decrease",label:v??W.chartDecrease,color:a.decrease,marker:"rect"}];return k.some(m=>m.kind==="total")&&r.push({key:"total",label:h,color:a.total,marker:"rect"}),r},[a,k,y,v,h,W.chartIncrease,W.chartDecrease]),te=A(()=>k.map(r=>({[s.key]:r.x,[t]:r.kind==="total"?null:r.value,__running:r.end})),[k,s.key,t]),ae=B===void 0?!0:B!==!1,j=typeof B=="string"?B:"bottom";return n(he,{title:_,description:N,height:H,width:$,size:M,loading:z,empty:k.length===0,emptyState:D,error:d,errorState:e,onRetry:ne,actions:U,tableView:G,legendPosition:j,legend:ae?n(ye,{items:E,position:j,marker:"rect",size:M}):void 0,table:G?n(be,{data:te,series:[{key:t,label:i??W.chartValue},{key:"__running",label:h}],xKey:s.key,xLabel:s.label??s.key,formatX:L,formatValue:c,caption:typeof _=="string"?_:void 0}):void 0,className:Q,...ee,children:({width:r})=>n(Me,{width:r,height:H,steps:k,data:C,x:s,y:o,grid:T,size:M,orientation:I,connectors:F,showValues:O,barSize:J,palette:a,margin:le,tooltip:re,plotLabel:Y,totalLabel:h,formatValue:c,formatX:L,onStepClick:Z})})}export{et as WaterfallChart};
|