@synertech/ui 0.50.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +190 -146
  2. package/README.md +27 -19
  3. package/dist/components/accordion/Accordion.cjs +1 -1
  4. package/dist/components/accordion/Accordion.js +1 -1
  5. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  6. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  7. package/dist/components/area-chart/AreaChart.cjs +1 -1
  8. package/dist/components/area-chart/AreaChart.js +1 -1
  9. package/dist/components/avatar/Avatar.cjs +1 -1
  10. package/dist/components/avatar/Avatar.js +1 -1
  11. package/dist/components/avatar/AvatarImage.cjs +1 -0
  12. package/dist/components/avatar/AvatarImage.js +1 -0
  13. package/dist/components/banner/Banner.cjs +1 -1
  14. package/dist/components/banner/Banner.js +1 -1
  15. package/dist/components/bar-chart/BarChart.cjs +1 -1
  16. package/dist/components/bar-chart/BarChart.js +1 -1
  17. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  18. package/dist/components/box-plot/BoxPlot.js +1 -1
  19. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  20. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  21. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  22. package/dist/components/bullet-chart/BulletChart.js +1 -1
  23. package/dist/components/calendar/Calendar.cjs +1 -1
  24. package/dist/components/calendar/Calendar.js +1 -1
  25. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  26. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  27. package/dist/components/card/Card.cjs +1 -1
  28. package/dist/components/card/Card.js +1 -1
  29. package/dist/components/chart/ChartAnnotations.cjs +1 -1
  30. package/dist/components/chart/ChartAnnotations.js +1 -1
  31. package/dist/components/chart/ChartBrush.cjs +1 -1
  32. package/dist/components/chart/ChartBrush.js +1 -1
  33. package/dist/components/chart/ChartContainer.cjs +1 -1
  34. package/dist/components/chart/ChartContainer.js +1 -1
  35. package/dist/components/chart/ChartExportButton.cjs +1 -1
  36. package/dist/components/chart/ChartExportButton.js +1 -1
  37. package/dist/components/chart/ChartPatterns.cjs +1 -1
  38. package/dist/components/chart/ChartPatterns.js +1 -1
  39. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  40. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  41. package/dist/components/chart/ChartPlotClip.cjs +1 -0
  42. package/dist/components/chart/ChartPlotClip.js +1 -0
  43. package/dist/components/chart/ChartSync.cjs +1 -1
  44. package/dist/components/chart/ChartSync.js +1 -1
  45. package/dist/components/chart/ChartTableView.cjs +1 -1
  46. package/dist/components/chart/ChartTableView.js +1 -1
  47. package/dist/components/chart/exportSource.cjs +1 -0
  48. package/dist/components/chart/exportSource.js +1 -0
  49. package/dist/components/chart/palette.cjs +1 -1
  50. package/dist/components/chart/palette.js +1 -1
  51. package/dist/components/chart/useChartSize.cjs +1 -1
  52. package/dist/components/chart/useChartSize.js +1 -1
  53. package/dist/components/chart/utils/bins.cjs +1 -1
  54. package/dist/components/chart/utils/bins.js +1 -1
  55. package/dist/components/chart/utils/cartesian.cjs +1 -1
  56. package/dist/components/chart/utils/cartesian.js +1 -1
  57. package/dist/components/chart/utils/export.cjs +7 -1
  58. package/dist/components/chart/utils/export.js +7 -1
  59. package/dist/components/chart/utils/format.cjs +1 -1
  60. package/dist/components/chart/utils/format.js +1 -1
  61. package/dist/components/chart/utils/keyboard.cjs +1 -1
  62. package/dist/components/chart/utils/keyboard.js +1 -1
  63. package/dist/components/chart/utils/period.cjs +1 -1
  64. package/dist/components/chart/utils/period.js +1 -1
  65. package/dist/components/chart/utils/regression.cjs +1 -0
  66. package/dist/components/chart/utils/regression.js +1 -0
  67. package/dist/components/chart/utils/stack.cjs +1 -1
  68. package/dist/components/chart/utils/stack.js +1 -1
  69. package/dist/components/chart/utils/ticks.cjs +1 -1
  70. package/dist/components/chart/utils/ticks.js +1 -1
  71. package/dist/components/checkbox/Checkbox.cjs +1 -1
  72. package/dist/components/checkbox/Checkbox.js +1 -1
  73. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  74. package/dist/components/circular-progress/CircularProgress.js +1 -1
  75. package/dist/components/datagrid/DataGrid.cjs +1 -1
  76. package/dist/components/datagrid/DataGrid.js +1 -1
  77. package/dist/components/detachable/Detachable.cjs +1 -1
  78. package/dist/components/detachable/Detachable.js +1 -1
  79. package/dist/components/detachable/popup-window.cjs +1 -0
  80. package/dist/components/detachable/popup-window.js +1 -0
  81. package/dist/components/detachable/useMovableContent.cjs +1 -0
  82. package/dist/components/detachable/useMovableContent.js +1 -0
  83. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  84. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  85. package/dist/components/divider/Divider.cjs +1 -1
  86. package/dist/components/divider/Divider.js +1 -1
  87. package/dist/components/drawer/Drawer.cjs +1 -1
  88. package/dist/components/drawer/Drawer.js +1 -1
  89. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  90. package/dist/components/dropdown/DropdownContent.js +1 -1
  91. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  92. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  93. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  94. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  95. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  96. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  97. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  98. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  99. package/dist/components/file-selector/FileSelector.cjs +1 -1
  100. package/dist/components/file-selector/FileSelector.js +1 -1
  101. package/dist/components/footer/FooterBottom.cjs +1 -1
  102. package/dist/components/footer/FooterBottom.js +1 -1
  103. package/dist/components/form/input/Input.cjs +1 -1
  104. package/dist/components/form/input/Input.js +1 -1
  105. package/dist/components/form/mention-input/MentionInput.cjs +5 -1
  106. package/dist/components/form/mention-input/MentionInput.js +5 -1
  107. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  108. package/dist/components/form/number-input/NumberInput.js +1 -1
  109. package/dist/components/form/shared/InputWrapper.cjs +1 -1
  110. package/dist/components/form/shared/InputWrapper.js +1 -1
  111. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  112. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  113. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  114. package/dist/components/gantt-chart/GanttChart.js +1 -1
  115. package/dist/components/heat-map/Heatmap.cjs +1 -1
  116. package/dist/components/heat-map/Heatmap.js +1 -1
  117. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  118. package/dist/components/image-uploader/ImageUploader.js +1 -1
  119. package/dist/components/line-chart/LineChart.cjs +1 -1
  120. package/dist/components/line-chart/LineChart.js +1 -1
  121. package/dist/components/modal/Modal.cjs +1 -1
  122. package/dist/components/modal/Modal.js +1 -1
  123. package/dist/components/pagination/Pagination.cjs +1 -1
  124. package/dist/components/pagination/Pagination.js +1 -1
  125. package/dist/components/pie-chart/PieChart.cjs +1 -1
  126. package/dist/components/pie-chart/PieChart.js +1 -1
  127. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  128. package/dist/components/progress-bar/ProgressBar.js +1 -1
  129. package/dist/components/radio-button/RadioButton.cjs +1 -1
  130. package/dist/components/radio-button/RadioButton.js +1 -1
  131. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  132. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  133. package/dist/components/scatter-chart/index.cjs +1 -1
  134. package/dist/components/scatter-chart/index.js +1 -1
  135. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  136. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  137. package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
  138. package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
  139. package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
  140. package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
  141. package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
  142. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  143. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  144. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  145. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  146. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  147. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  148. package/dist/components/schema-editor/utils/import.cjs +1 -0
  149. package/dist/components/schema-editor/utils/import.js +1 -0
  150. package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
  151. package/dist/components/schema-editor/utils/sql-export.js +7 -6
  152. package/dist/components/select/Select.cjs +1 -1
  153. package/dist/components/select/Select.js +1 -1
  154. package/dist/components/slider/Slider.cjs +1 -1
  155. package/dist/components/slider/Slider.js +1 -1
  156. package/dist/components/sparkline/Sparkline.cjs +1 -1
  157. package/dist/components/sparkline/Sparkline.js +1 -1
  158. package/dist/components/table/TableRow.cjs +1 -1
  159. package/dist/components/table/TableRow.js +1 -1
  160. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  161. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  162. package/dist/components/wizard/Wizard.cjs +1 -1
  163. package/dist/components/wizard/Wizard.js +1 -1
  164. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  165. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  166. package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
  167. package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
  168. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  169. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  170. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  171. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  172. package/dist/components/workflow-editor/utils/import.cjs +1 -0
  173. package/dist/components/workflow-editor/utils/import.js +1 -0
  174. package/dist/hooks/useDialogA11y.cjs +1 -1
  175. package/dist/hooks/useDialogA11y.js +1 -1
  176. package/dist/index.d.cts +522 -184
  177. package/dist/index.d.ts +522 -184
  178. package/dist/lib/accept.cjs +1 -0
  179. package/dist/lib/accept.js +1 -0
  180. package/dist/lib/canvas-events.cjs +1 -0
  181. package/dist/lib/canvas-events.js +1 -0
  182. package/dist/lib/css-value.cjs +1 -0
  183. package/dist/lib/css-value.js +1 -0
  184. package/dist/lib/dialog-stack.cjs +1 -1
  185. package/dist/lib/dialog-stack.js +1 -1
  186. package/dist/lib/layer-document.cjs +1 -0
  187. package/dist/lib/layer-document.js +1 -0
  188. package/dist/lib/owner-document.cjs +1 -0
  189. package/dist/lib/owner-document.js +1 -0
  190. package/dist/lib/ui-labels.cjs +1 -1
  191. package/dist/lib/ui-labels.js +1 -1
  192. package/dist/styles-no-preflight.css +10270 -0
  193. package/dist/styles.css +390 -450
  194. package/package.json +9 -4
@@ -1 +1 @@
1
- "use client";import{useRef as z,useEffect as W}from"react";import{cn as l}from"../../lib/cn.js";import{useUILabels as A}from"../../lib/i18n.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";var P={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},L=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 16 16",fill:"currentColor",children:[e("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),e("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),e("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),e("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),I=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 20 20",fill:"currentColor",children:[e("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),e("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),e("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),V=({className:a})=>i("svg",{className:l("w-4 h-3",a),viewBox:"0 0 24 14",fill:"currentColor",children:[e("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),e("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),e("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function f({time:a="9:41",theme:r,device:t}){let o=t==="watch",s=r==="dark"?"text-white":"text-gray-900";return o?e("div",{className:l("flex items-center justify-center py-0.5",s),style:{fontSize:"8px"},children:e("span",{className:"font-medium",children:a})}):i("div",{className:l("flex items-center justify-between px-4 py-1",r==="dark"?"bg-black/20":"bg-white/20",s),style:{fontSize:"10px"},"data-testid":"status-bar",children:[e("span",{className:"font-semibold",children:a}),i("div",{className:"flex items-center gap-1",children:[e(L,{className:s}),e(I,{className:s}),e(V,{className:s})]})]})}function X({theme:a}){let r=a==="dark";return i("div",{className:l("flex items-center gap-2 px-3 py-2 border-b",r?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[i("div",{className:"flex items-center gap-1.5",children:[e("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),e("div",{className:l("flex-1 rounded-md px-3 py-1 text-center",r?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:i("span",{className:"flex items-center justify-center gap-1",children:[e("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:e("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function j({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n,landscape:c=!1}){let m=r==="dark",h=n??(m?"#1a1a1a":"#e5e7eb");if(c){let g=Math.round(o*.35);return i("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"8px 12px",height:o+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:l("rounded-full mr-2",m?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(o*.35)},"data-testid":"home-indicator"}),i("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:g,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(t*.35);return i("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"12px 8px",width:t+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),i("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:l("rounded-full mt-2",m?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(t*.35),height:4},"data-testid":"home-indicator"})]})}function q({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:t+12},"data-testid":"device-frame","data-device":"android",children:[e("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),i("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"android"}),a]})]})}function E({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:t+24},"data-testid":"device-frame","data-device":"tablet",children:[e("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),i("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"tablet"}),a]})]})}function O({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){let d=r==="dark",n=s??(d?"#1a1a1a":"#d1d5db"),c=t+60;return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[i("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:n,padding:"8px 8px 0",width:t+16},children:[e("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),e("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:t,height:o},children:a})]}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:t+16,height:3}}),e("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:n,width:c,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function U({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){let d=r==="dark";return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[e("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:s??(d?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:t+16},children:e("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:t,height:o},children:a})}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),e("div",{className:l("rounded-t-sm",d?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(t*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function Y({children:a,theme:r,screenW:t,screenH:o,showStatusBar:s,statusBarTime:d,frameColor:n}){let c=r==="dark",m=n??(c?"#1a1a1a":"#d1d5db"),h=Math.round(t*.7);return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[e("div",{className:l("rounded-t-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30},"data-testid":"watch-band"}),i("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:m,padding:"8px 6px",width:t+12},children:[e("div",{className:l("absolute rounded-sm",c?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),i("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:t,height:o},children:[s&&e(f,{time:d,theme:r,device:"watch"}),a]})]}),e("div",{className:l("rounded-b-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30}})]})}function G({children:a,theme:r,screenW:t,screenH:o,frameColor:s}){return i("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:s??(r==="dark"?"#1f2937":"#f3f4f6"),width:t},"data-testid":"device-frame","data-device":"browser",children:[e(X,{theme:r}),e("div",{className:"overflow-hidden bg-white",style:{width:t,height:o},children:a})]})}function Z({device:a="phone",src:r,alt:t,children:o,orientation:s="portrait",theme:d="dark",size:n="md",showStatusBar:c=!1,statusBarTime:m,animated:h=!1,scrollSpeed:w=30,frameColor:g,className:B,contentClassName:F}){let H=A(),D=z(null),x=z(null),y=P[a][n],C=s==="landscape"&&a!=="watch"&&a!=="browser",u=C?y.h:y.w,v=C?y.w:y.h;W(()=>{if(!h||!D.current)return;let p=D.current,k=null,R=T=>{k===null&&(k=T);let S=(T-k)/1e3;k=T,p.scrollTop+=w*S,p.scrollTop>=p.scrollHeight-p.clientHeight&&(p.scrollTop=0),x.current=requestAnimationFrame(R)};return x.current=requestAnimationFrame(R),()=>{x.current!==null&&cancelAnimationFrame(x.current)}},[h,w]);let b=e("div",{ref:h?D:void 0,className:l("w-full h-full overflow-hidden",h&&"overflow-y-auto scrollbar-hide",F),style:h?{scrollBehavior:"auto"}:void 0,children:r?e("img",{src:r,alt:t??H.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):o}),N={showStatusBar:c,statusBarTime:m},M=()=>{switch(a){case"phone":return e(j,{theme:d,screenW:u,screenH:v,frameColor:g,landscape:C,...N,children:b});case"android":return e(q,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"tablet":return e(E,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"laptop":return e(O,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"desktop":return e(U,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"watch":return e(Y,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"browser":return e(G,{theme:d,screenW:u,screenH:v,frameColor:g,children:b})}};return e("div",{className:l("inline-flex",B),"data-testid":"device-mockup","data-orientation":s,"data-theme":d,"data-size":n,children:M()})}export{Z as DeviceMockup};
1
+ "use client";import{useEffect as S,useState as W}from"react";import{cn as l}from"../../lib/cn.js";import{safeCssColor as V}from"../../lib/css-value.js";import{useUILabels as X}from"../../lib/i18n.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";var j={phone:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},android:{sm:{w:180,h:320},md:{w:240,h:480},lg:{w:300,h:600}},tablet:{sm:{w:320,h:420},md:{w:420,h:560},lg:{w:540,h:720}},laptop:{sm:{w:400,h:250},md:{w:560,h:350},lg:{w:720,h:450}},desktop:{sm:{w:400,h:300},md:{w:560,h:400},lg:{w:720,h:520}},watch:{sm:{w:80,h:96},md:{w:120,h:144},lg:{w:160,h:192}},browser:{sm:{w:400,h:280},md:{w:560,h:380},lg:{w:720,h:480}}},q=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 16 16",fill:"currentColor",children:[e("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),e("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),e("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),e("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),U=({className:a})=>i("svg",{className:l("w-3 h-3",a),viewBox:"0 0 20 20",fill:"currentColor",children:[e("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),e("path",{fillRule:"evenodd",d:"M6.05 11.95a5.5 5.5 0 017.9 0 .75.75 0 001.08-1.04 7 7 0 00-10.06 0 .75.75 0 001.08 1.04z",clipRule:"evenodd"}),e("path",{fillRule:"evenodd",d:"M2.81 8.72a10 10 0 0114.38 0 .75.75 0 001.06-1.06 11.5 11.5 0 00-16.5 0 .75.75 0 001.06 1.06z",clipRule:"evenodd"})]}),Q=({className:a})=>i("svg",{className:l("w-4 h-3",a),viewBox:"0 0 24 14",fill:"currentColor",children:[e("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),e("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),e("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function x({time:a="9:41",theme:r,device:t}){let s=t==="watch",o=r==="dark"?"text-white":"text-gray-900";return s?e("div",{className:l("flex shrink-0 items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:e("span",{className:"font-medium",children:a})}):i("div",{className:l("flex shrink-0 items-center justify-between px-4 py-1",r==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[e("span",{className:"font-semibold",children:a}),i("div",{className:"flex items-center gap-1",children:[e(q,{className:o}),e(U,{className:o}),e(Q,{className:o})]})]})}function Y({theme:a}){let r=a==="dark";return i("div",{className:l("flex items-center gap-2 px-3 py-2 border-b",r?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[i("div",{className:"flex items-center gap-1.5",children:[e("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),e("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),e("div",{className:l("flex-1 rounded-md px-3 py-1 text-center",r?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:i("span",{className:"flex items-center justify-center gap-1",children:[e("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:e("path",{fillRule:"evenodd",d:"M8 1a4 4 0 00-4 4v3.5H3a1 1 0 00-1 1V14a1 1 0 001 1h10a1 1 0 001-1V9.5a1 1 0 00-1-1h-1V5a4 4 0 00-4-4zm2.5 7.5V5a2.5 2.5 0 00-5 0v3.5h5z",clipRule:"evenodd"})}),"example.com"]})})]})}function _({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n,landscape:c=!1}){let m=r==="dark",h=n??(m?"#1a1a1a":"#e5e7eb");if(c){let k=Math.round(s*.35);return i("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"8px 12px",height:s+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:l("rounded-full mr-2",m?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(s*.35)},"data-testid":"home-indicator"}),i("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:k,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(t*.35);return i("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:h,padding:"12px 8px",width:t+16},"data-testid":"device-frame","data-device":"phone",children:[e("div",{className:"absolute top-[10px] rounded-full bg-black z-10",style:{width:w,height:20,left:"50%",transform:"translateX(-50%)"},"data-testid":"phone-notch"}),i("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"phone"}),a]}),e("div",{className:l("rounded-full mt-2",m?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(t*.35),height:4},"data-testid":"home-indicator"})]})}function G({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:t+12},"data-testid":"device-frame","data-device":"android",children:[e("div",{className:"absolute top-[6px] rounded-full bg-gray-800 z-10 border border-gray-700",style:{width:8,height:8,left:"50%",transform:"translateX(-50%)"},"data-testid":"camera-dot"}),i("div",{className:"flex flex-col rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"android"}),a]})]})}function J({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){return i("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:n??(r==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:t+24},"data-testid":"device-frame","data-device":"tablet",children:[e("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),i("div",{className:"flex flex-col rounded-lg overflow-hidden bg-black relative",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"tablet"}),a]})]})}function K({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){let d=r==="dark",n=o??(d?"#1a1a1a":"#d1d5db"),c=t+60;return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[i("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:n,padding:"8px 8px 0",width:t+16},children:[e("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),e("div",{className:"flex flex-col rounded-t-sm overflow-hidden bg-black",style:{width:t,height:s},children:a})]}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:t+16,height:3}}),e("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:n,width:c,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function Z({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){let d=r==="dark";return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[e("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(d?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:t+16},children:e("div",{className:"flex flex-col rounded-sm overflow-hidden bg-black",style:{width:t,height:s},children:a})}),e("div",{className:l(d?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),e("div",{className:l("rounded-t-sm",d?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(t*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function $({children:a,theme:r,screenW:t,screenH:s,showStatusBar:o,statusBarTime:d,frameColor:n}){let c=r==="dark",m=n??(c?"#1a1a1a":"#d1d5db"),h=Math.round(t*.7);return i("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[e("div",{className:l("rounded-t-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30},"data-testid":"watch-band"}),i("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:m,padding:"8px 6px",width:t+12},children:[e("div",{className:l("absolute rounded-sm",c?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),i("div",{className:"flex flex-col rounded-xl overflow-hidden bg-black",style:{width:t,height:s},children:[o&&e(x,{time:d,theme:r,device:"watch"}),a]})]}),e("div",{className:l("rounded-b-lg",c?"bg-gray-800":"bg-gray-400"),style:{width:h,height:30}})]})}function ee({children:a,theme:r,screenW:t,screenH:s,frameColor:o}){return i("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(r==="dark"?"#1f2937":"#f3f4f6"),width:t},"data-testid":"device-frame","data-device":"browser",children:[e(Y,{theme:r}),e("div",{className:"flex flex-col overflow-hidden bg-white",style:{width:t,height:s},children:a})]})}var F="(prefers-reduced-motion: reduce)",H=()=>typeof window<"u"&&typeof window.matchMedia=="function";function te(){let[a,r]=W(()=>H()&&window.matchMedia(F).matches);return S(()=>{if(!H())return;let t=window.matchMedia(F);r(t.matches);let s=o=>r(o.matches);return t.addEventListener?.("change",s),()=>t.removeEventListener?.("change",s)},[]),a}function se({device:a="phone",src:r,alt:t,children:s,orientation:o="portrait",theme:d="dark",size:n="md",showStatusBar:c=!1,statusBarTime:m,animated:h=!1,scrollSpeed:w=30,frameColor:k,className:L,contentClassName:A}){let E=X(),u=V(k),[g,P]=W(null),T=te(),y=j[a][n],C=o==="landscape"&&(a==="phone"||a==="android"||a==="tablet"),v=C?y.h:y.w,f=C?y.w:y.h;S(()=>{if(!h||T||!g)return;let p=g.scrollTop,D=null,M=requestAnimationFrame(function O(R){let z=D===null?0:Math.min(R-D,250)/1e3;D=R,Math.abs(g.scrollTop-p)>1&&(p=g.scrollTop);let B=g.scrollHeight-g.clientHeight;p=B>0&&p+w*z<B?p+w*z:0,g.scrollTop=p,M=requestAnimationFrame(O)});return()=>cancelAnimationFrame(M)},[h,T,g,w]);let b=e("div",{ref:h?P:void 0,className:l("w-full flex-1 min-h-0 overflow-hidden",h&&"overflow-y-auto scrollbar-hide",A),style:h?{scrollBehavior:"auto"}:void 0,children:r?e("img",{src:r,alt:t??E.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):s}),N={showStatusBar:c,statusBarTime:m},I=()=>{switch(a){case"phone":return e(_,{theme:d,screenW:v,screenH:f,frameColor:u,landscape:C,...N,children:b});case"android":return e(G,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"tablet":return e(J,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"laptop":return e(K,{theme:d,screenW:v,screenH:f,frameColor:u,children:b});case"desktop":return e(Z,{theme:d,screenW:v,screenH:f,frameColor:u,children:b});case"watch":return e($,{theme:d,screenW:v,screenH:f,frameColor:u,...N,children:b});case"browser":return e(ee,{theme:d,screenW:v,screenH:f,frameColor:u,children:b})}};return e("div",{className:l("inline-flex",L),"data-testid":"device-mockup","data-orientation":o,"data-theme":d,"data-size":n,children:I()})}export{se as DeviceMockup};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!m.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(d=g(e,r))||d.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var W={};c(W,{Divider:()=>h});module.exports=D(W);var a=require("../../lib/cn.cjs"),i=require("react/jsx-runtime"),s={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},u={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:t="horizontal",variant:e="solid",label:o,textAlign:d="center",thickness:r=1,color:n="border-gray-300 dark:border-gray-700",spacing:l,className:f,...x}){if(t==="vertical")return(0,i.jsx)("hr",{"aria-orientation":"vertical",className:(0,a.cn)("h-full border-l-0 border-r",s[e],n,l||"mx-2",f),style:{borderRightWidth:`${r}px`},...x});if(o){let b=u[d];return(0,i.jsxs)("div",{role:"separator","aria-orientation":"horizontal",className:(0,a.cn)("flex items-center text-sm text-gray-500 dark:text-gray-400",l||"my-4",f),...x,children:[(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.before),style:{borderTopWidth:`${r}px`}}),(0,i.jsx)("span",{className:"px-3 whitespace-nowrap",children:o}),(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.after),style:{borderTopWidth:`${r}px`}})]})}return(0,i.jsx)("hr",{"aria-orientation":"horizontal",className:(0,a.cn)("border-t-0 border-b",s[e],n,l||"my-4",f),style:{borderBottomWidth:`${r}px`},...x})}h.displayName="Divider";0&&(module.exports={Divider});
1
+ "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!v.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(d=g(e,r))||d.enumerable});return t};var D=t=>y(p({},"__esModule",{value:!0}),t);var W={};c(W,{Divider:()=>h});module.exports=D(W);var a=require("../../lib/cn.cjs"),i=require("react/jsx-runtime"),s={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},u={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:t="horizontal",variant:e="solid",label:o,textAlign:d="center",thickness:r=1,color:n="border-gray-300 dark:border-gray-700",spacing:l,className:f,...x}){if(t==="vertical")return(0,i.jsx)("hr",{"aria-orientation":"vertical",className:(0,a.cn)("h-auto min-h-4 self-stretch border-t-0 border-l-0 border-r",s[e],n,l||"mx-2",f),style:{borderRightWidth:`${r}px`},...x});if(o){let b=u[d];return(0,i.jsxs)("div",{role:"separator","aria-orientation":"horizontal",className:(0,a.cn)("flex items-center text-sm text-gray-500 dark:text-gray-400",l||"my-4",f),...x,children:[(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.before),style:{borderTopWidth:`${r}px`}}),(0,i.jsx)("span",{className:"px-3 whitespace-nowrap",children:o}),(0,i.jsx)("div",{className:(0,a.cn)("border-t",s[e],n,b.after),style:{borderTopWidth:`${r}px`}})]})}return(0,i.jsx)("hr",{"aria-orientation":"horizontal",className:(0,a.cn)("border-t-0 border-b",s[e],n,l||"my-4",f),style:{borderBottomWidth:`${r}px`},...x})}h.displayName="Divider";0&&(module.exports={Divider});
@@ -1 +1 @@
1
- import{cn as e}from"../../lib/cn.js";import{jsx as r,jsxs as g}from"react/jsx-runtime";var a={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},b={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:x="horizontal",variant:t="solid",label:l,textAlign:p="center",thickness:i=1,color:o="border-gray-300 dark:border-gray-700",spacing:d,className:n,...s}){if(x==="vertical")return r("hr",{"aria-orientation":"vertical",className:e("h-full border-l-0 border-r",a[t],o,d||"mx-2",n),style:{borderRightWidth:`${i}px`},...s});if(l){let f=b[p];return g("div",{role:"separator","aria-orientation":"horizontal",className:e("flex items-center text-sm text-gray-500 dark:text-gray-400",d||"my-4",n),...s,children:[r("div",{className:e("border-t",a[t],o,f.before),style:{borderTopWidth:`${i}px`}}),r("span",{className:"px-3 whitespace-nowrap",children:l}),r("div",{className:e("border-t",a[t],o,f.after),style:{borderTopWidth:`${i}px`}})]})}return r("hr",{"aria-orientation":"horizontal",className:e("border-t-0 border-b",a[t],o,d||"my-4",n),style:{borderBottomWidth:`${i}px`},...s})}h.displayName="Divider";export{h as Divider};
1
+ import{cn as e}from"../../lib/cn.js";import{jsx as r,jsxs as g}from"react/jsx-runtime";var a={solid:"border-solid",dashed:"border-dashed",dotted:"border-dotted"},b={left:{before:"flex-[0.1]",after:"flex-1"},center:{before:"flex-1",after:"flex-1"},right:{before:"flex-1",after:"flex-[0.1]"}};function h({orientation:x="horizontal",variant:t="solid",label:l,textAlign:p="center",thickness:i=1,color:o="border-gray-300 dark:border-gray-700",spacing:d,className:n,...s}){if(x==="vertical")return r("hr",{"aria-orientation":"vertical",className:e("h-auto min-h-4 self-stretch border-t-0 border-l-0 border-r",a[t],o,d||"mx-2",n),style:{borderRightWidth:`${i}px`},...s});if(l){let f=b[p];return g("div",{role:"separator","aria-orientation":"horizontal",className:e("flex items-center text-sm text-gray-500 dark:text-gray-400",d||"my-4",n),...s,children:[r("div",{className:e("border-t",a[t],o,f.before),style:{borderTopWidth:`${i}px`}}),r("span",{className:"px-3 whitespace-nowrap",children:l}),r("div",{className:e("border-t",a[t],o,f.after),style:{borderTopWidth:`${i}px`}})]})}return r("hr",{"aria-orientation":"horizontal",className:e("border-t-0 border-b",a[t],o,d||"my-4",n),style:{borderBottomWidth:`${i}px`},...s})}h.displayName="Divider";export{h as Divider};
@@ -1 +1 @@
1
- "use strict";"use client";var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var a in e)u(t,a,{get:e[a],enumerable:!0})},H=(t,e,a,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!A.call(t,o)&&o!==a&&u(t,o,{get:()=>e[o],enumerable:!(l=T(e,o))||l.enumerable});return t};var U=t=>H(u({},"__esModule",{value:!0}),t);var K={};B(K,{Drawer:()=>v});module.exports=U(K);var i=require("react"),p=require("react-dom"),w=require("../../hooks/useDialogA11y.cjs"),s=require("../../lib/cn.cjs"),y=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),$={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},q={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},G={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},J=(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function v({open:t,onClose:e,children:a,position:l="right",size:o="md",customWidth:d,customHeight:f,showOverlay:x=!0,closeOnOverlayClick:c=!0,closeOnEscape:D=!0,title:n,footer:m,className:k,overlayClassName:N,closeLabel:R,"aria-label":C,trapFocus:I=!0,initialFocus:P,returnFocus:z,lockScroll:F=!0}){let L=!!(d||f),g=(0,i.useRef)(null),M=(0,y.useUILabels)(),h=`${(0,i.useId)()}-drawer-title`,{dialogRef:S,dialogProps:E}=(0,w.useDialogA11y)({open:t,onClose:e,closeOnEscape:D,trapFocus:I,initialFocus:P,returnFocus:z,lockScroll:F,keepInteractive:[g]}),O=(0,i.useCallback)(()=>{c&&e()},[c,e]);if(!t)return null;let b=(0,r.jsxs)(r.Fragment,{children:[x&&(0,r.jsx)("div",{ref:g,className:(0,s.cn)("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",N),onClick:O,"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:S,...E,"aria-labelledby":n?h:void 0,"aria-label":n?void 0:C,className:(0,s.cn)("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",q[l],!L&&$[l][o],G[l],k),style:{...d?{width:d}:{},...f?{height:f}:{}},children:[n&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsx)("h2",{id:h,className:"text-lg font-semibold text-gray-900 dark:text-white",children:n}),(0,r.jsx)("button",{type:"button",onClick:e,className:(0,s.cn)("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":R??M.closeDrawer,children:J})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:a}),m&&(0,r.jsx)("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:m})]})]});return typeof document<"u"?(0,p.createPortal)(b,document.body):b}v.displayName="Drawer";0&&(module.exports={Drawer});
1
+ "use strict";"use client";var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(t,r)=>{for(var a in r)c(t,a,{get:r[a],enumerable:!0})},H=(t,r,a,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!A.call(t,o)&&o!==a&&c(t,o,{get:()=>r[o],enumerable:!(l=T(r,o))||l.enumerable});return t};var U=t=>H(c({},"__esModule",{value:!0}),t);var K={};B(K,{Drawer:()=>y});module.exports=U(K);var i=require("react"),b=require("../../hooks/useDialogA11y.cjs"),s=require("../../lib/cn.cjs"),p=require("../../lib/i18n.cjs"),w=require("../../lib/layer-document.cjs"),e=require("react/jsx-runtime"),$={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},q={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},G={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},J=(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function y({open:t,onClose:r,children:a,position:l="right",size:o="md",customWidth:d,customHeight:f,showOverlay:v=!0,closeOnOverlayClick:u=!0,closeOnEscape:x=!0,title:n,footer:g,className:D,overlayClassName:k,closeLabel:N,"aria-label":R,trapFocus:P=!0,initialFocus:C,returnFocus:I,lockScroll:L=!0}){let z=!!(d||f),m=(0,i.useRef)(null),F=(0,p.useUILabels)(),h=`${(0,i.useId)()}-drawer-title`,{dialogRef:M,dialogProps:S}=(0,b.useDialogA11y)({open:t,onClose:r,closeOnEscape:x,trapFocus:P,initialFocus:C,returnFocus:I,lockScroll:L,keepInteractive:[m]}),E=(0,i.useCallback)(()=>{u&&r()},[u,r]);if(!t)return null;let O=(0,e.jsxs)(e.Fragment,{children:[v&&(0,e.jsx)("div",{ref:m,className:(0,s.cn)("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",k),onClick:E,"aria-hidden":"true"}),(0,e.jsxs)("div",{ref:M,...S,"aria-labelledby":n?h:void 0,"aria-label":n?void 0:R,className:(0,s.cn)("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",q[l],!z&&$[l][o],G[l],D),style:{...d?{width:d}:{},...f?{height:f}:{}},children:[n&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[(0,e.jsx)("h2",{id:h,className:"text-lg font-semibold text-gray-900 dark:text-white",children:n}),(0,e.jsx)("button",{type:"button",onClick:r,className:(0,s.cn)("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":N??F.closeDrawer,children:J})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:a}),g&&(0,e.jsx)("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:g})]})]});return(0,e.jsx)(w.LayerPortal,{children:O})}y.displayName="Drawer";0&&(module.exports={Drawer});
@@ -1 +1 @@
1
- "use client";import{useCallback as L,useId as M,useRef as S}from"react";import{createPortal as E}from"react-dom";import{useDialogA11y as O}from"../../hooks/useDialogA11y.js";import{cn as i}from"../../lib/cn.js";import{useUILabels as T}from"../../lib/i18n.js";import{Fragment as $,jsx as e,jsxs as n}from"react/jsx-runtime";var j={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},A={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},B={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:s,onClose:r,children:g,position:o="right",size:h="md",customWidth:a,customHeight:l,showOverlay:b=!0,closeOnOverlayClick:d=!0,closeOnEscape:p=!0,title:t,footer:f,className:w,overlayClassName:y,closeLabel:v,"aria-label":x,trapFocus:D=!0,initialFocus:k,returnFocus:N,lockScroll:R=!0}){let C=!!(a||l),u=S(null),I=T(),c=`${M()}-drawer-title`,{dialogRef:P,dialogProps:z}=O({open:s,onClose:r,closeOnEscape:p,trapFocus:D,initialFocus:k,returnFocus:N,lockScroll:R,keepInteractive:[u]}),F=L(()=>{d&&r()},[d,r]);if(!s)return null;let m=n($,{children:[b&&e("div",{ref:u,className:i("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",y),onClick:F,"aria-hidden":"true"}),n("div",{ref:P,...z,"aria-labelledby":t?c:void 0,"aria-label":t?void 0:x,className:i("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",A[o],!C&&j[o][h],B[o],w),style:{...a?{width:a}:{},...l?{height:l}:{}},children:[t&&n("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e("h2",{id:c,className:"text-lg font-semibold text-gray-900 dark:text-white",children:t}),e("button",{type:"button",onClick:r,className:i("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":v??I.closeDrawer,children:H})]}),e("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:g}),f&&e("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:f})]})]});return typeof document<"u"?E(m,document.body):m}U.displayName="Drawer";export{U as Drawer};
1
+ "use client";import{useCallback as F,useId as M,useRef as S}from"react";import{useDialogA11y as E}from"../../hooks/useDialogA11y.js";import{cn as i}from"../../lib/cn.js";import{useUILabels as O}from"../../lib/i18n.js";import{LayerPortal as T}from"../../lib/layer-document.js";import{Fragment as $,jsx as e,jsxs as n}from"react/jsx-runtime";var j={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},A={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},B={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:s,onClose:r,children:g,position:o="right",size:m="md",customWidth:a,customHeight:l,showOverlay:h=!0,closeOnOverlayClick:d=!0,closeOnEscape:b=!0,title:t,footer:f,className:p,overlayClassName:w,closeLabel:y,"aria-label":v,trapFocus:x=!0,initialFocus:D,returnFocus:k,lockScroll:N=!0}){let R=!!(a||l),c=S(null),P=O(),u=`${M()}-drawer-title`,{dialogRef:C,dialogProps:I}=E({open:s,onClose:r,closeOnEscape:b,trapFocus:x,initialFocus:D,returnFocus:k,lockScroll:N,keepInteractive:[c]}),L=F(()=>{d&&r()},[d,r]);if(!s)return null;let z=n($,{children:[h&&e("div",{ref:c,className:i("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",w),onClick:L,"aria-hidden":"true"}),n("div",{ref:C,...I,"aria-labelledby":t?u:void 0,"aria-label":t?void 0:v,className:i("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",A[o],!R&&j[o][m],B[o],p),style:{...a?{width:a}:{},...l?{height:l}:{}},children:[t&&n("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e("h2",{id:u,className:"text-lg font-semibold text-gray-900 dark:text-white",children:t}),e("button",{type:"button",onClick:r,className:i("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":y??P.closeDrawer,children:H})]}),e("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:g}),f&&e("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:f})]})]});return e(T,{children:z})}U.displayName="Drawer";export{U as Drawer};
@@ -1 +1 @@
1
- "use strict";"use client";var C=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(u,s)=>{for(var y in s)C(u,y,{get:s[y],enumerable:!0})},j=(u,s,y,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of X(s))!Y.call(u,l)&&l!==y&&C(u,l,{get:()=>s[l],enumerable:!(h=V(s,l))||h.enumerable});return u};var ee=u=>j(C({},"__esModule",{value:!0}),u);var te={};Z(te,{DropdownContent:()=>B});module.exports=ee(te);var a=require("react"),L=require("react-dom"),P=require("./Dropdown.cjs"),S=require("./hooks/useClickOutside.cjs"),D=require("./hooks/useLatest.cjs"),T=require("./hooks/usePositioning.cjs"),t=require("./menu-navigation.cjs"),W=require("../../lib/aria-hide.cjs"),M=require("../../lib/cn.cjs"),f=require("react/jsx-runtime"),ne={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function B({side:u="bottom",align:s="start",sideOffset:y=4,alignOffset:h=0,avoidCollisions:l=!0,collisionPadding:H=8,minWidth:z,maxWidth:q,maxHeight:w=300,animation:K="scale",portal:U=!0,children:_,className:$}){let{isOpen:n,setIsOpen:k,triggerRef:o,contentRef:i,closeOnClickOutside:G,closeOnEscape:J,modal:Q,contentId:c}=(0,P.useDropdownContext)(),[g,E]=(0,a.useState)(!1),m=(0,T.usePositioning)({triggerRef:o,contentRef:i,isOpen:n,side:u,align:s,sideOffset:y,alignOffset:h,avoidCollisions:l,collisionPadding:H});(0,S.useClickOutside)(i,()=>{G&&k(!1)},n,{isInside:e=>!!o.current?.contains(e)||e instanceof Element&&e.closest((0,t.ownedBy)(c))!==null});let R=(0,D.useLatest)(k),O=(0,D.useLatest)(J);(0,a.useEffect)(()=>{if(!n)return;let e=r=>{if(r.defaultPrevented)return;let p=i.current;if(!p)return;let d=p.ownerDocument,b=d.activeElement,A=(0,t.hasFocusWithin)(c,d)||!!o.current?.contains(b);if(r.key==="Escape"){if(!O.current)return;r.preventDefault(),R.current(!1),o.current?.focus();return}if(r.key==="Tab"){R.current(!1),A&&o.current?.focus();return}if(!A&&b!==null&&b!==d.body)return;let F=(0,t.getActiveMenu)(c,d)??p,x=(0,t.isTyping)(r.target);if(!((r.key==="Home"||r.key==="End")&&x)){if((0,t.moveFocus)(F,r.key)){r.preventDefault();return}if(r.key==="Enter"||r.key===" "){if(x)return;let v=b;if(!v||!(0,t.getMenuItems)(F).includes(v))return;r.preventDefault(),v.click()}}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,c,i,o,R,O]),(0,a.useEffect)(()=>{let e=i.current;if(e)return(0,W.registerFloatingLayer)(e,()=>o.current)},[i,o]),(0,a.useEffect)(()=>{if(!n||!g)return;let e=i.current;if(e)return(0,t.focusFirstItem)(e,()=>!(0,t.hasFocusWithin)(c,e.ownerDocument))},[n,g,c,i]);let I=(0,a.useRef)(n);(0,a.useLayoutEffect)(()=>{if(I.current&&!n){let e=i.current?.ownerDocument;e&&(0,t.hasFocusWithin)(c,e)&&o.current?.focus({preventScroll:!0})}I.current=n},[n,c,i,o]),(0,a.useLayoutEffect)(()=>{let e=0;if(!n){E(!1);return}let r=()=>{let p=o.current?.getBoundingClientRect(),d=i.current?.getBoundingClientRect();if(m.isReady&&!!p&&!!d&&p.width>0&&p.height>0&&d.width>0&&d.height>0){E(!0);return}e=requestAnimationFrame(r)};return E(!1),e=requestAnimationFrame(r),()=>{e&&cancelAnimationFrame(e)}},[n,m.isReady,o,i]);let N=(0,f.jsxs)(f.Fragment,{children:[Q&&n&&(0,f.jsx)("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>k(!1)}),(0,f.jsx)("div",{ref:i,id:c,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[t.MENU_OWNER_ATTRIBUTE]:c,style:{position:"fixed",top:m.top,left:m.left,minWidth:z??o.current?.offsetWidth,maxWidth:q,maxHeight:m.availableHeight===void 0?w:typeof w=="number"?Math.min(w,m.availableHeight):`min(${w}, ${m.availableHeight}px)`,visibility:n&&g?"visible":"hidden",opacity:n&&g?1:0,pointerEvents:n&&g?"auto":"none"},className:(0,M.cn)("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&g&&ne[K],$),children:(0,f.jsx)("div",{className:"py-1",children:_})})]});return U&&typeof document<"u"?(0,L.createPortal)(N,document.body):N}B.displayName="DropdownContent";0&&(module.exports={DropdownContent});
1
+ "use strict";"use client";var D=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var ee=(u,s)=>{for(var p in s)D(u,p,{get:s[p],enumerable:!0})},ne=(u,s,p,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of Z(s))!j.call(u,f)&&f!==p&&D(u,f,{get:()=>s[f],enumerable:!(h=Y(s,f))||h.enumerable});return u};var te=u=>ne(D({},"__esModule",{value:!0}),u);var oe={};ee(oe,{DropdownContent:()=>z});module.exports=te(oe);var a=require("react"),S=require("react-dom"),T=require("./Dropdown.cjs"),W=require("./hooks/useClickOutside.cjs"),O=require("./hooks/useLatest.cjs"),M=require("./hooks/usePositioning.cjs"),t=require("./menu-navigation.cjs"),B=require("../../lib/aria-hide.cjs"),I=require("../../lib/owner-document.cjs"),H=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),re={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function z({side:u="bottom",align:s="start",sideOffset:p=4,alignOffset:h=0,avoidCollisions:f=!0,collisionPadding:q=8,minWidth:K,maxWidth:U,maxHeight:w=300,animation:_="scale",portal:$=!0,children:G,className:J}){let{isOpen:n,setIsOpen:E,triggerRef:o,contentRef:i,closeOnClickOutside:Q,closeOnEscape:V,modal:X,contentId:c}=(0,T.useDropdownContext)(),[y,R]=(0,a.useState)(!1),l=(0,M.usePositioning)({triggerRef:o,contentRef:i,isOpen:n,side:u,align:s,sideOffset:p,alignOffset:h,avoidCollisions:f,collisionPadding:q});(0,W.useClickOutside)(i,()=>{Q&&E(!1)},n,{isInside:e=>!!o.current?.contains(e)||e instanceof Element&&e.closest((0,t.ownedBy)(c))!==null});let v=(0,O.useLatest)(E),N=(0,O.useLatest)(V);(0,a.useEffect)(()=>{if(!n)return;let e=r=>{if(r.defaultPrevented)return;let m=i.current;if(!m)return;let b=m.ownerDocument,k=b.activeElement,x=(0,t.hasFocusWithin)(c,b)||!!o.current?.contains(k);if(r.key==="Escape"){if(!N.current)return;r.preventDefault(),v.current(!1),o.current?.focus();return}if(r.key==="Tab"){v.current(!1),x&&o.current?.focus();return}if(!x&&k!==null&&k!==b.body)return;let L=(0,t.getActiveMenu)(c,b)??m,P=(0,t.isTyping)(r.target);if(!((r.key==="Home"||r.key==="End")&&P)){if((0,t.moveFocus)(L,r.key)){r.preventDefault();return}if(r.key==="Enter"||r.key===" "){if(P)return;let C=k;if(!C||!(0,t.getMenuItems)(L).includes(C))return;r.preventDefault(),C.click()}}},g=(0,I.ownerDocumentOf)(o.current);return g.addEventListener("keydown",e),()=>g.removeEventListener("keydown",e)},[n,c,i,o,v,N]),(0,a.useEffect)(()=>{let e=i.current;if(e)return(0,B.registerFloatingLayer)(e,()=>o.current)},[i,o]),(0,a.useEffect)(()=>{if(!n||!y)return;let e=i.current;if(e)return(0,t.focusFirstItem)(e,()=>!(0,t.hasFocusWithin)(c,e.ownerDocument))},[n,y,c,i]);let A=(0,a.useRef)(n);(0,a.useLayoutEffect)(()=>{if(A.current&&!n){let e=i.current?.ownerDocument;e&&(0,t.hasFocusWithin)(c,e)&&o.current?.focus({preventScroll:!0})}A.current=n},[n,c,i,o]),(0,a.useLayoutEffect)(()=>{let e=0;if(!n){R(!1);return}let g=()=>{let r=o.current?.getBoundingClientRect(),m=i.current?.getBoundingClientRect();if(l.isReady&&!!r&&!!m&&r.width>0&&r.height>0&&m.width>0&&m.height>0){R(!0);return}e=requestAnimationFrame(g)};return R(!1),e=requestAnimationFrame(g),()=>{e&&cancelAnimationFrame(e)}},[n,l.isReady,o,i]);let F=(0,d.jsxs)(d.Fragment,{children:[X&&n&&(0,d.jsx)("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>E(!1)}),(0,d.jsx)("div",{ref:i,id:c,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[t.MENU_OWNER_ATTRIBUTE]:c,style:{position:"fixed",top:l.top,left:l.left,minWidth:K??o.current?.offsetWidth,maxWidth:U,maxHeight:l.availableHeight===void 0?w:typeof w=="number"?Math.min(w,l.availableHeight):`min(${w}, ${l.availableHeight}px)`,visibility:n&&y?"visible":"hidden",opacity:n&&y?1:0,pointerEvents:n&&y?"auto":"none"},className:(0,H.cn)("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&y&&re[_],J),children:(0,d.jsx)("div",{className:"py-1",children:G})})]});return $&&typeof document<"u"?(0,S.createPortal)(F,(0,I.ownerDocumentOf)(o.current).body):F}z.displayName="DropdownContent";0&&(module.exports={DropdownContent});
@@ -1 +1 @@
1
- "use client";import{useEffect as g,useLayoutEffect as D,useRef as K,useState as U}from"react";import{createPortal as _}from"react-dom";import{useDropdownContext as $}from"./Dropdown.js";import{useClickOutside as G}from"./hooks/useClickOutside.js";import{useLatest as O}from"./hooks/useLatest.js";import{usePositioning as J}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as Q,focusFirstItem as V,getActiveMenu as X,getMenuItems as Y,hasFocusWithin as b,isTyping as Z,moveFocus as j,ownedBy as ee}from"./menu-navigation.js";import{registerFloatingLayer as ne}from"../../lib/aria-hide.js";import{cn as te}from"../../lib/cn.js";import{Fragment as ie,jsx as h,jsxs as se}from"react/jsx-runtime";var re={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function oe({side:I="bottom",align:N="start",sideOffset:A=4,alignOffset:F=0,avoidCollisions:x=!0,collisionPadding:L=8,minWidth:P,maxWidth:S,maxHeight:f=300,animation:T="scale",portal:W=!0,children:M,className:B}){let{isOpen:n,setIsOpen:l,triggerRef:r,contentRef:o,closeOnClickOutside:H,closeOnEscape:z,modal:q,contentId:i}=$(),[u,m]=U(!1),a=J({triggerRef:r,contentRef:o,isOpen:n,side:I,align:N,sideOffset:A,alignOffset:F,avoidCollisions:x,collisionPadding:L});G(o,()=>{H&&l(!1)},n,{isInside:e=>!!r.current?.contains(e)||e instanceof Element&&e.closest(ee(i))!==null});let p=O(l),w=O(z);g(()=>{if(!n)return;let e=t=>{if(t.defaultPrevented)return;let c=o.current;if(!c)return;let s=c.ownerDocument,d=s.activeElement,R=b(i,s)||!!r.current?.contains(d);if(t.key==="Escape"){if(!w.current)return;t.preventDefault(),p.current(!1),r.current?.focus();return}if(t.key==="Tab"){p.current(!1),R&&r.current?.focus();return}if(!R&&d!==null&&d!==s.body)return;let v=X(i,s)??c,C=Z(t.target);if(!((t.key==="Home"||t.key==="End")&&C)){if(j(v,t.key)){t.preventDefault();return}if(t.key==="Enter"||t.key===" "){if(C)return;let y=d;if(!y||!Y(v).includes(y))return;t.preventDefault(),y.click()}}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,i,o,r,p,w]),g(()=>{let e=o.current;if(e)return ne(e,()=>r.current)},[o,r]),g(()=>{if(!n||!u)return;let e=o.current;if(e)return V(e,()=>!b(i,e.ownerDocument))},[n,u,i,o]);let k=K(n);D(()=>{if(k.current&&!n){let e=o.current?.ownerDocument;e&&b(i,e)&&r.current?.focus({preventScroll:!0})}k.current=n},[n,i,o,r]),D(()=>{let e=0;if(!n){m(!1);return}let t=()=>{let c=r.current?.getBoundingClientRect(),s=o.current?.getBoundingClientRect();if(a.isReady&&!!c&&!!s&&c.width>0&&c.height>0&&s.width>0&&s.height>0){m(!0);return}e=requestAnimationFrame(t)};return m(!1),e=requestAnimationFrame(t),()=>{e&&cancelAnimationFrame(e)}},[n,a.isReady,r,o]);let E=se(ie,{children:[q&&n&&h("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>l(!1)}),h("div",{ref:o,id:i,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[Q]:i,style:{position:"fixed",top:a.top,left:a.left,minWidth:P??r.current?.offsetWidth,maxWidth:S,maxHeight:a.availableHeight===void 0?f:typeof f=="number"?Math.min(f,a.availableHeight):`min(${f}, ${a.availableHeight}px)`,visibility:n&&u?"visible":"hidden",opacity:n&&u?1:0,pointerEvents:n&&u?"auto":"none"},className:te("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&u&&re[T],B),children:h("div",{className:"py-1",children:M})})]});return W&&typeof document<"u"?_(E,document.body):E}oe.displayName="DropdownContent";export{oe as DropdownContent};
1
+ "use client";import{useEffect as b,useLayoutEffect as O,useRef as _,useState as $}from"react";import{createPortal as G}from"react-dom";import{useDropdownContext as J}from"./Dropdown.js";import{useClickOutside as Q}from"./hooks/useClickOutside.js";import{useLatest as I}from"./hooks/useLatest.js";import{usePositioning as V}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as X,focusFirstItem as Y,getActiveMenu as Z,getMenuItems as j,hasFocusWithin as h,isTyping as ee,moveFocus as ne,ownedBy as te}from"./menu-navigation.js";import{registerFloatingLayer as re}from"../../lib/aria-hide.js";import{ownerDocumentOf as N}from"../../lib/owner-document.js";import{cn as oe}from"../../lib/cn.js";import{Fragment as ae,jsx as w,jsxs as ce}from"react/jsx-runtime";var ie={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function se({side:A="bottom",align:F="start",sideOffset:x=4,alignOffset:L=0,avoidCollisions:P=!0,collisionPadding:S=8,minWidth:T,maxWidth:W,maxHeight:f=300,animation:M="scale",portal:B=!0,children:H,className:z}){let{isOpen:n,setIsOpen:m,triggerRef:r,contentRef:o,closeOnClickOutside:q,closeOnEscape:K,modal:U,contentId:i}=J(),[c,p]=$(!1),s=V({triggerRef:r,contentRef:o,isOpen:n,side:A,align:F,sideOffset:x,alignOffset:L,avoidCollisions:P,collisionPadding:S});Q(o,()=>{q&&m(!1)},n,{isInside:e=>!!r.current?.contains(e)||e instanceof Element&&e.closest(te(i))!==null});let y=I(m),k=I(K);b(()=>{if(!n)return;let e=t=>{if(t.defaultPrevented)return;let a=o.current;if(!a)return;let d=a.ownerDocument,l=d.activeElement,v=h(i,d)||!!r.current?.contains(l);if(t.key==="Escape"){if(!k.current)return;t.preventDefault(),y.current(!1),r.current?.focus();return}if(t.key==="Tab"){y.current(!1),v&&r.current?.focus();return}if(!v&&l!==null&&l!==d.body)return;let C=Z(i,d)??a,D=ee(t.target);if(!((t.key==="Home"||t.key==="End")&&D)){if(ne(C,t.key)){t.preventDefault();return}if(t.key==="Enter"||t.key===" "){if(D)return;let g=l;if(!g||!j(C).includes(g))return;t.preventDefault(),g.click()}}},u=N(r.current);return u.addEventListener("keydown",e),()=>u.removeEventListener("keydown",e)},[n,i,o,r,y,k]),b(()=>{let e=o.current;if(e)return re(e,()=>r.current)},[o,r]),b(()=>{if(!n||!c)return;let e=o.current;if(e)return Y(e,()=>!h(i,e.ownerDocument))},[n,c,i,o]);let E=_(n);O(()=>{if(E.current&&!n){let e=o.current?.ownerDocument;e&&h(i,e)&&r.current?.focus({preventScroll:!0})}E.current=n},[n,i,o,r]),O(()=>{let e=0;if(!n){p(!1);return}let u=()=>{let t=r.current?.getBoundingClientRect(),a=o.current?.getBoundingClientRect();if(s.isReady&&!!t&&!!a&&t.width>0&&t.height>0&&a.width>0&&a.height>0){p(!0);return}e=requestAnimationFrame(u)};return p(!1),e=requestAnimationFrame(u),()=>{e&&cancelAnimationFrame(e)}},[n,s.isReady,r,o]);let R=ce(ae,{children:[U&&n&&w("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>m(!1)}),w("div",{ref:o,id:i,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[X]:i,style:{position:"fixed",top:s.top,left:s.left,minWidth:T??r.current?.offsetWidth,maxWidth:W,maxHeight:s.availableHeight===void 0?f:typeof f=="number"?Math.min(f,s.availableHeight):`min(${f}, ${s.availableHeight}px)`,visibility:n&&c?"visible":"hidden",opacity:n&&c?1:0,pointerEvents:n&&c?"auto":"none"},className:oe("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&c&&ie[M],z),children:w("div",{className:"py-1",children:H})})]});return B&&typeof document<"u"?G(R,N(r.current).body):R}se.displayName="DropdownContent";export{se as DropdownContent};
@@ -1 +1 @@
1
- "use strict";"use client";var M=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var H=(r,n)=>{for(var a in n)M(r,a,{get:n[a],enumerable:!0})},K=(r,n,a,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of q(n))!B.call(r,t)&&t!==a&&M(r,t,{get:()=>n[t],enumerable:!(l=A(n,t))||l.enumerable});return r};var W=r=>K(M({},"__esModule",{value:!0}),r);var V={};H(V,{DropdownSubMenu:()=>L,DropdownSubMenuContent:()=>I,DropdownSubMenuTrigger:()=>F});module.exports=W(V);var e=require("react"),S=require("react-dom"),R=require("./Dropdown.cjs"),k=require("./hooks/useClickOutside.cjs"),E=require("./hooks/usePositioning.cjs"),h=require("./menu-navigation.cjs"),N=require("../../lib/aria-hide.cjs"),x=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),j=100,O=(0,e.createContext)(null);function T(){let r=(0,e.useContext)(O);if(!r)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return r}function L({children:r}){let{isOpen:n}=(0,R.useDropdownContext)(),[a,l]=(0,e.useState)(!1),t=(0,e.useRef)(null),p=(0,e.useRef)(null),i=(0,e.useRef)(null),u=(0,e.useRef)(!1),g=n&&a,o=(0,e.useCallback)(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),b=(0,e.useCallback)(()=>{o(),i.current=setTimeout(()=>{i.current=null,l(!1)},j)},[o]),f=(0,e.useCallback)(()=>{o(),u.current=!0,l(!0)},[o]),c=(0,e.useCallback)(()=>{let y=u.current;return u.current=!1,y},[]);(0,e.useEffect)(()=>{n||(o(),u.current=!1,l(!1))},[n,o]),(0,e.useEffect)(()=>o,[o]);let m=(0,e.useMemo)(()=>({isOpen:g,setIsOpen:l,triggerRef:t,contentRef:p,scheduleClose:b,cancelClose:o,openWithFocus:f,takeFocusRequest:c}),[g,b,o,f,c]);return(0,d.jsx)(O.Provider,{value:m,children:(0,d.jsx)("div",{className:"relative",children:r})})}L.displayName="DropdownSubMenu";function F({children:r,icon:n,disabled:a=!1,className:l}){let{isOpen:t,setIsOpen:p,triggerRef:i,scheduleClose:u,cancelClose:g,openWithFocus:o}=T();return(0,d.jsxs)("button",{ref:i,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:a,"data-disabled":a||void 0,onMouseEnter:c=>{a||(g(),c.currentTarget.focus({preventScroll:!0}),p(!0))},onMouseLeave:u,onClick:a?void 0:o,onKeyDown:c=>{a||(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:(0,x.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",a&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[n&&(0,d.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:n}),(0,d.jsx)("span",{className:"flex-1",children:r}),(0,d.jsx)("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}F.displayName="DropdownSubMenuTrigger";function I({children:r,sideOffset:n=0,className:a}){let{contentId:l}=(0,R.useDropdownContext)(),{isOpen:t,setIsOpen:p,triggerRef:i,contentRef:u,scheduleClose:g,cancelClose:o,takeFocusRequest:b}=T(),[f,c]=(0,e.useState)(!1),m=(0,E.usePositioning)({triggerRef:i,contentRef:u,isOpen:t,side:"right",align:"start",sideOffset:n,avoidCollisions:!0});(0,k.useClickOutside)(u,()=>p(!1),t,{isInside:s=>!!i.current?.contains(s)}),(0,e.useEffect)(()=>{let s=u.current;if(s)return(0,N.registerFloatingLayer)(s,()=>i.current)},[u,i]);let y=(0,e.useCallback)(()=>{o(),p(!0)},[o,p]),P=s=>{(s.key==="ArrowLeft"||s.key==="Escape")&&(s.preventDefault(),o(),p(!1),i.current?.focus())};(0,e.useEffect)(()=>{if(!t||!f||!b())return;let s=u.current;if(s)return(0,h.focusFirstItem)(s)},[t,f,u,b]),(0,e.useLayoutEffect)(()=>{let s=0;if(!t){c(!1);return}let D=()=>{let v=i.current?.getBoundingClientRect(),w=u.current?.getBoundingClientRect();if(m.isReady&&!!v&&!!w&&v.width>0&&v.height>0&&w.width>0&&w.height>0){c(!0);return}s=requestAnimationFrame(D)};return c(!1),s=requestAnimationFrame(D),()=>{s&&cancelAnimationFrame(s)}},[t,m.isReady,i,u]);let C=(0,d.jsx)("div",{ref:u,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[h.MENU_OWNER_ATTRIBUTE]:l,onMouseEnter:y,onMouseLeave:g,onKeyDown:P,style:{position:"fixed",top:m.top,left:m.left,maxHeight:m.availableHeight,visibility:t&&f?"visible":"hidden",opacity:t&&f?1:0,pointerEvents:t&&f?"auto":"none"},className:(0,x.cn)("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&f&&"animate-in fade-in-0 zoom-in-95 duration-150",a),children:(0,d.jsx)("div",{className:"py-1",children:r})});return typeof document<"u"?(0,S.createPortal)(C,document.body):C}I.displayName="DropdownSubMenuContent";0&&(module.exports={DropdownSubMenu,DropdownSubMenuContent,DropdownSubMenuTrigger});
1
+ "use strict";"use client";var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var K=(r,n)=>{for(var i in n)M(r,i,{get:n[i],enumerable:!0})},W=(r,n,i,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of B(n))!H.call(r,t)&&t!==i&&M(r,t,{get:()=>n[t],enumerable:!(l=q(n,t))||l.enumerable});return r};var j=r=>W(M({},"__esModule",{value:!0}),r);var _={};K(_,{DropdownSubMenu:()=>F,DropdownSubMenuContent:()=>P,DropdownSubMenuTrigger:()=>I});module.exports=j(_);var e=require("react"),S=require("react-dom"),R=require("./Dropdown.cjs"),k=require("./hooks/useClickOutside.cjs"),E=require("./hooks/usePositioning.cjs"),h=require("./menu-navigation.cjs"),N=require("../../lib/aria-hide.cjs"),O=require("../../lib/owner-document.cjs"),x=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),V=100,T=(0,e.createContext)(null);function L(){let r=(0,e.useContext)(T);if(!r)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return r}function F({children:r}){let{isOpen:n}=(0,R.useDropdownContext)(),[i,l]=(0,e.useState)(!1),t=(0,e.useRef)(null),p=(0,e.useRef)(null),u=(0,e.useRef)(null),s=(0,e.useRef)(!1),g=n&&i,o=(0,e.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),b=(0,e.useCallback)(()=>{o(),u.current=setTimeout(()=>{u.current=null,l(!1)},V)},[o]),f=(0,e.useCallback)(()=>{o(),s.current=!0,l(!0)},[o]),c=(0,e.useCallback)(()=>{let y=s.current;return s.current=!1,y},[]);(0,e.useEffect)(()=>{n||(o(),s.current=!1,l(!1))},[n,o]),(0,e.useEffect)(()=>o,[o]);let m=(0,e.useMemo)(()=>({isOpen:g,setIsOpen:l,triggerRef:t,contentRef:p,scheduleClose:b,cancelClose:o,openWithFocus:f,takeFocusRequest:c}),[g,b,o,f,c]);return(0,d.jsx)(T.Provider,{value:m,children:(0,d.jsx)("div",{className:"relative",children:r})})}F.displayName="DropdownSubMenu";function I({children:r,icon:n,disabled:i=!1,className:l}){let{isOpen:t,setIsOpen:p,triggerRef:u,scheduleClose:s,cancelClose:g,openWithFocus:o}=L();return(0,d.jsxs)("button",{ref:u,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:i,"data-disabled":i||void 0,onMouseEnter:c=>{i||(g(),c.currentTarget.focus({preventScroll:!0}),p(!0))},onMouseLeave:s,onClick:i?void 0:o,onKeyDown:c=>{i||(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:(0,x.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",i&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[n&&(0,d.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:n}),(0,d.jsx)("span",{className:"flex-1",children:r}),(0,d.jsx)("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}I.displayName="DropdownSubMenuTrigger";function P({children:r,sideOffset:n=0,className:i}){let{contentId:l}=(0,R.useDropdownContext)(),{isOpen:t,setIsOpen:p,triggerRef:u,contentRef:s,scheduleClose:g,cancelClose:o,takeFocusRequest:b}=L(),[f,c]=(0,e.useState)(!1),m=(0,E.usePositioning)({triggerRef:u,contentRef:s,isOpen:t,side:"right",align:"start",sideOffset:n,avoidCollisions:!0});(0,k.useClickOutside)(s,()=>p(!1),t,{isInside:a=>!!u.current?.contains(a)}),(0,e.useEffect)(()=>{let a=s.current;if(a)return(0,N.registerFloatingLayer)(a,()=>u.current)},[s,u]);let y=(0,e.useCallback)(()=>{o(),p(!0)},[o,p]),A=a=>{(a.key==="ArrowLeft"||a.key==="Escape")&&(a.preventDefault(),o(),p(!1),u.current?.focus())};(0,e.useEffect)(()=>{if(!t||!f||!b())return;let a=s.current;if(a)return(0,h.focusFirstItem)(a)},[t,f,s,b]),(0,e.useLayoutEffect)(()=>{let a=0;if(!t){c(!1);return}let D=()=>{let w=u.current?.getBoundingClientRect(),v=s.current?.getBoundingClientRect();if(m.isReady&&!!w&&!!v&&w.width>0&&w.height>0&&v.width>0&&v.height>0){c(!0);return}a=requestAnimationFrame(D)};return c(!1),a=requestAnimationFrame(D),()=>{a&&cancelAnimationFrame(a)}},[t,m.isReady,u,s]);let C=(0,d.jsx)("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[h.MENU_OWNER_ATTRIBUTE]:l,onMouseEnter:y,onMouseLeave:g,onKeyDown:A,style:{position:"fixed",top:m.top,left:m.left,maxHeight:m.availableHeight,visibility:t&&f?"visible":"hidden",opacity:t&&f?1:0,pointerEvents:t&&f?"auto":"none"},className:(0,x.cn)("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&f&&"animate-in fade-in-0 zoom-in-95 duration-150",i),children:(0,d.jsx)("div",{className:"py-1",children:r})});return typeof document<"u"?(0,S.createPortal)(C,(0,O.ownerDocumentOf)(u.current).body):C}P.displayName="DropdownSubMenuContent";0&&(module.exports={DropdownSubMenu,DropdownSubMenuContent,DropdownSubMenuTrigger});
@@ -1 +1 @@
1
- "use client";import{createContext as O,useContext as T,useState as C,useRef as h,useEffect as y,useLayoutEffect as L,useCallback as b,useMemo as F}from"react";import{createPortal as I}from"react-dom";import{useDropdownContext as D}from"./Dropdown.js";import{useClickOutside as P}from"./hooks/useClickOutside.js";import{usePositioning as A}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as q,focusFirstItem as B}from"./menu-navigation.js";import{registerFloatingLayer as H}from"../../lib/aria-hide.js";import{cn as S}from"../../lib/cn.js";import{jsx as f,jsxs as _}from"react/jsx-runtime";var K=100,k=O(null);function E(){let i=T(k);if(!i)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return i}function W({children:i}){let{isOpen:c}=D(),[s,l]=C(!1),t=h(null),d=h(null),r=h(null),n=h(!1),m=c&&s,e=b(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),g=b(()=>{e(),r.current=setTimeout(()=>{r.current=null,l(!1)},K)},[e]),a=b(()=>{e(),n.current=!0,l(!0)},[e]),u=b(()=>{let v=n.current;return n.current=!1,v},[]);y(()=>{c||(e(),n.current=!1,l(!1))},[c,e]),y(()=>e,[e]);let p=F(()=>({isOpen:m,setIsOpen:l,triggerRef:t,contentRef:d,scheduleClose:g,cancelClose:e,openWithFocus:a,takeFocusRequest:u}),[m,g,e,a,u]);return f(k.Provider,{value:p,children:f("div",{className:"relative",children:i})})}W.displayName="DropdownSubMenu";function j({children:i,icon:c,disabled:s=!1,className:l}){let{isOpen:t,setIsOpen:d,triggerRef:r,scheduleClose:n,cancelClose:m,openWithFocus:e}=E();return _("button",{ref:r,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:s,"data-disabled":s||void 0,onMouseEnter:u=>{s||(m(),u.currentTarget.focus({preventScroll:!0}),d(!0))},onMouseLeave:n,onClick:s?void 0:e,onKeyDown:u=>{s||(u.key==="ArrowRight"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},className:S("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[c&&f("span",{className:"mr-2 shrink-0 w-5 h-5",children:c}),f("span",{className:"flex-1",children:i}),f("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:f("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}j.displayName="DropdownSubMenuTrigger";function V({children:i,sideOffset:c=0,className:s}){let{contentId:l}=D(),{isOpen:t,setIsOpen:d,triggerRef:r,contentRef:n,scheduleClose:m,cancelClose:e,takeFocusRequest:g}=E(),[a,u]=C(!1),p=A({triggerRef:r,contentRef:n,isOpen:t,side:"right",align:"start",sideOffset:c,avoidCollisions:!0});P(n,()=>d(!1),t,{isInside:o=>!!r.current?.contains(o)}),y(()=>{let o=n.current;if(o)return H(o,()=>r.current)},[n,r]);let v=b(()=>{e(),d(!0)},[e,d]),N=o=>{(o.key==="ArrowLeft"||o.key==="Escape")&&(o.preventDefault(),e(),d(!1),r.current?.focus())};y(()=>{if(!t||!a||!g())return;let o=n.current;if(o)return B(o)},[t,a,n,g]),L(()=>{let o=0;if(!t){u(!1);return}let x=()=>{let w=r.current?.getBoundingClientRect(),M=n.current?.getBoundingClientRect();if(p.isReady&&!!w&&!!M&&w.width>0&&w.height>0&&M.width>0&&M.height>0){u(!0);return}o=requestAnimationFrame(x)};return u(!1),o=requestAnimationFrame(x),()=>{o&&cancelAnimationFrame(o)}},[t,p.isReady,r,n]);let R=f("div",{ref:n,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[q]:l,onMouseEnter:v,onMouseLeave:m,onKeyDown:N,style:{position:"fixed",top:p.top,left:p.left,maxHeight:p.availableHeight,visibility:t&&a?"visible":"hidden",opacity:t&&a?1:0,pointerEvents:t&&a?"auto":"none"},className:S("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&a&&"animate-in fade-in-0 zoom-in-95 duration-150",s),children:f("div",{className:"py-1",children:i})});return typeof document<"u"?I(R,document.body):R}V.displayName="DropdownSubMenuContent";export{W as DropdownSubMenu,V as DropdownSubMenuContent,j as DropdownSubMenuTrigger};
1
+ "use client";import{createContext as O,useContext as T,useState as C,useRef as h,useEffect as y,useLayoutEffect as L,useCallback as b,useMemo as F}from"react";import{createPortal as I}from"react-dom";import{useDropdownContext as D}from"./Dropdown.js";import{useClickOutside as P}from"./hooks/useClickOutside.js";import{usePositioning as A}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as q,focusFirstItem as B}from"./menu-navigation.js";import{registerFloatingLayer as H}from"../../lib/aria-hide.js";import{ownerDocumentOf as K}from"../../lib/owner-document.js";import{cn as S}from"../../lib/cn.js";import{jsx as f,jsxs as z}from"react/jsx-runtime";var W=100,k=O(null);function E(){let i=T(k);if(!i)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return i}function j({children:i}){let{isOpen:c}=D(),[s,l]=C(!1),t=h(null),d=h(null),n=h(null),o=h(!1),m=c&&s,e=b(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null)},[]),g=b(()=>{e(),n.current=setTimeout(()=>{n.current=null,l(!1)},W)},[e]),a=b(()=>{e(),o.current=!0,l(!0)},[e]),u=b(()=>{let w=o.current;return o.current=!1,w},[]);y(()=>{c||(e(),o.current=!1,l(!1))},[c,e]),y(()=>e,[e]);let p=F(()=>({isOpen:m,setIsOpen:l,triggerRef:t,contentRef:d,scheduleClose:g,cancelClose:e,openWithFocus:a,takeFocusRequest:u}),[m,g,e,a,u]);return f(k.Provider,{value:p,children:f("div",{className:"relative",children:i})})}j.displayName="DropdownSubMenu";function V({children:i,icon:c,disabled:s=!1,className:l}){let{isOpen:t,setIsOpen:d,triggerRef:n,scheduleClose:o,cancelClose:m,openWithFocus:e}=E();return z("button",{ref:n,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:s,"data-disabled":s||void 0,onMouseEnter:u=>{s||(m(),u.currentTarget.focus({preventScroll:!0}),d(!0))},onMouseLeave:o,onClick:s?void 0:e,onKeyDown:u=>{s||(u.key==="ArrowRight"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},className:S("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[c&&f("span",{className:"mr-2 shrink-0 w-5 h-5",children:c}),f("span",{className:"flex-1",children:i}),f("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:f("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}V.displayName="DropdownSubMenuTrigger";function _({children:i,sideOffset:c=0,className:s}){let{contentId:l}=D(),{isOpen:t,setIsOpen:d,triggerRef:n,contentRef:o,scheduleClose:m,cancelClose:e,takeFocusRequest:g}=E(),[a,u]=C(!1),p=A({triggerRef:n,contentRef:o,isOpen:t,side:"right",align:"start",sideOffset:c,avoidCollisions:!0});P(o,()=>d(!1),t,{isInside:r=>!!n.current?.contains(r)}),y(()=>{let r=o.current;if(r)return H(r,()=>n.current)},[o,n]);let w=b(()=>{e(),d(!0)},[e,d]),N=r=>{(r.key==="ArrowLeft"||r.key==="Escape")&&(r.preventDefault(),e(),d(!1),n.current?.focus())};y(()=>{if(!t||!a||!g())return;let r=o.current;if(r)return B(r)},[t,a,o,g]),L(()=>{let r=0;if(!t){u(!1);return}let x=()=>{let v=n.current?.getBoundingClientRect(),M=o.current?.getBoundingClientRect();if(p.isReady&&!!v&&!!M&&v.width>0&&v.height>0&&M.width>0&&M.height>0){u(!0);return}r=requestAnimationFrame(x)};return u(!1),r=requestAnimationFrame(x),()=>{r&&cancelAnimationFrame(r)}},[t,p.isReady,n,o]);let R=f("div",{ref:o,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[q]:l,onMouseEnter:w,onMouseLeave:m,onKeyDown:N,style:{position:"fixed",top:p.top,left:p.left,maxHeight:p.availableHeight,visibility:t&&a?"visible":"hidden",opacity:t&&a?1:0,pointerEvents:t&&a?"auto":"none"},className:S("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&a&&"animate-in fade-in-0 zoom-in-95 duration-150",s),children:f("div",{className:"py-1",children:i})});return typeof document<"u"?I(R,K(n.current).body):R}_.displayName="DropdownSubMenuContent";export{j as DropdownSubMenu,_ as DropdownSubMenuContent,V as DropdownSubMenuTrigger};
@@ -1 +1 @@
1
- "use strict";"use client";var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},E=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!v.call(e,n)&&n!==r&&i(e,n,{get:()=>t[n],enumerable:!(s=f(t,n))||s.enumerable});return e};var O=e=>E(i({},"__esModule",{value:!0}),e);var h={};p(h,{useClickOutside:()=>L});module.exports=O(h);var a=require("react"),u=require("./useLatest.cjs");function L(e,t,r=!0,s={}){let n=(0,u.useLatest)(t),c=(0,u.useLatest)(s.isInside);(0,a.useEffect)(()=>{if(!r)return;let o=m=>{let d=m.target;!e.current||e.current.contains(d)||c.current?.(d)||n.current()};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o,{passive:!0}),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}},[r,n,c,e])}0&&(module.exports={useClickOutside});
1
+ "use strict";"use client";var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!E.call(e,n)&&n!==r&&u(e,n,{get:()=>t[n],enumerable:!(o=v(t,n))||o.enumerable});return e};var h=e=>L(u({},"__esModule",{value:!0}),e);var b={};O(b,{useClickOutside:()=>R});module.exports=h(b);var f=require("react"),c=require("./useLatest.cjs"),m=require("../../../lib/owner-document.cjs");function R(e,t,r=!0,o={}){let n=(0,c.useLatest)(t),d=(0,c.useLatest)(o.isInside);(0,f.useEffect)(()=>{if(!r)return;let s=l=>{let a=l.target;!e.current||e.current.contains(a)||d.current?.(a)||n.current()},i=(0,m.ownerDocumentOf)(e.current);return i.addEventListener("mousedown",s),i.addEventListener("touchstart",s,{passive:!0}),()=>{i.removeEventListener("mousedown",s),i.removeEventListener("touchstart",s)}},[r,n,d,e])}0&&(module.exports={useClickOutside});
@@ -1 +1 @@
1
- "use client";import{useEffect as a}from"react";import{useLatest as i}from"./useLatest.js";function l(t,u,n=!0,c={}){let r=i(u),s=i(c.isInside);a(()=>{if(!n)return;let e=d=>{let o=d.target;!t.current||t.current.contains(o)||s.current?.(o)||r.current()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[n,r,s,t])}export{l as useClickOutside};
1
+ "use client";import{useEffect as f}from"react";import{useLatest as u}from"./useLatest.js";import{ownerDocumentOf as m}from"../../../lib/owner-document.js";function E(e,c,r=!0,d={}){let o=u(c),s=u(d.isInside);f(()=>{if(!r)return;let t=a=>{let i=a.target;!e.current||e.current.contains(i)||s.current?.(i)||o.current()},n=m(e.current);return n.addEventListener("mousedown",t),n.addEventListener("touchstart",t,{passive:!0}),()=>{n.removeEventListener("mousedown",t),n.removeEventListener("touchstart",t)}},[r,o,s,e])}export{E as useClickOutside};
@@ -1 +1 @@
1
- "use strict";"use client";var v=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var k=(i,o)=>{for(var f in o)v(i,f,{get:o[f],enumerable:!0})},q=(i,o,f,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of F(o))!M.call(i,a)&&a!==f&&v(i,a,{get:()=>o[a],enumerable:!(c=C(o,a))||c.enumerable});return i};var z=i=>q(v({},"__esModule",{value:!0}),i);var V={};k(V,{usePositioning:()=>U});module.exports=z(V);var m=require("react"),I={top:"bottom",bottom:"top",left:"right",right:"left"};function U({triggerRef:i,contentRef:o,isOpen:f,side:c="bottom",align:a="start",sideOffset:u=4,alignOffset:b=0,avoidCollisions:x=!0,collisionPadding:n=8}){let[B,E]=(0,m.useState)({top:0,left:0,actualSide:c,actualAlign:a,isReady:!1}),g=(0,m.useRef)(!1),y=(0,m.useCallback)(()=>{if(!i.current||!o.current)return;let t=i.current.getBoundingClientRect(),e=o.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){g.current=!1;return}let l={width:window.innerWidth,height:window.innerHeight},s=c,w=a,L=p=>{switch(p){case"bottom":return{top:t.bottom+u,left:t.left};case"top":return{top:t.top-e.height-u,left:t.left};case"right":return{top:t.top,left:t.right+u};case"left":return{top:t.top,left:t.left-e.width-u}}},H=(p,R,h)=>{if(p==="top"||p==="bottom")switch(R){case"start":return{...h,left:t.left+b};case"center":return{...h,left:t.left+t.width/2-e.width/2+b};case"end":return{...h,left:t.right-e.width+b}}else switch(R){case"start":return{...h,top:t.top+b};case"center":return{...h,top:t.top+t.height/2-e.height/2+b};case"end":return{...h,top:t.bottom-e.height+b}}},r=L(s);r=H(s,w,r);let T;if(x){let p={top:t.top-u-n,bottom:l.height-t.bottom-u-n,left:t.left-u-n,right:l.width-t.right-u-n},R=c==="top"||c==="bottom"?e.height:e.width,h=I[c];R>p[c]&&p[h]>p[c]&&(s=h,r=L(s),r=H(s,w,r));let A=l.width-e.width-n,j=l.height-e.height-n,S=s==="top"||s==="bottom";r.left>A&&(r.left=A,S&&(w="end")),r.left<n&&(r.left=n,S&&(w="start")),r.top>j&&(r.top=j,S||(w="end")),r.top<n&&(r.top=n,S||(w="start")),T=Math.max(0,l.height-2*n)}g.current=!0,E({top:r.top,left:r.left,actualSide:s,actualAlign:w,isReady:!0,availableHeight:T})},[i,o,c,a,u,b,x,n]);return(0,m.useLayoutEffect)(()=>{if(!f)return;let t=0;g.current=!1,E(l=>l.isReady?{...l,isReady:!1}:l);let e=()=>{y(),g.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let d=()=>y();return window.addEventListener("resize",d),window.addEventListener("scroll",d,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,{capture:!0})}},[y,f]),B}0&&(module.exports={usePositioning});
1
+ "use strict";"use client";var x=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var z=(o,n)=>{for(var f in n)x(o,f,{get:n[f],enumerable:!0})},I=(o,n,f,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of k(n))!q.call(o,a)&&a!==f&&x(o,a,{get:()=>n[a],enumerable:!(c=M(n,a))||c.enumerable});return o};var U=o=>I(x({},"__esModule",{value:!0}),o);var P={};z(P,{usePositioning:()=>W});module.exports=U(P);var m=require("react"),E=require("../../../lib/owner-document.cjs"),V={top:"bottom",bottom:"top",left:"right",right:"left"};function W({triggerRef:o,contentRef:n,isOpen:f,side:c="bottom",align:a="start",sideOffset:u=4,alignOffset:b=0,avoidCollisions:L=!0,collisionPadding:i=8}){let[F,H]=(0,m.useState)({top:0,left:0,actualSide:c,actualAlign:a,isReady:!1}),R=(0,m.useRef)(!1),v=(0,m.useCallback)(()=>{if(!o.current||!n.current)return;let t=o.current.getBoundingClientRect(),e=n.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){R.current=!1;return}let w=(0,E.ownerWindowOf)(o.current),l={width:w.innerWidth,height:w.innerHeight},s=c,d=a,T=p=>{switch(p){case"bottom":return{top:t.bottom+u,left:t.left};case"top":return{top:t.top-e.height-u,left:t.left};case"right":return{top:t.top,left:t.right+u};case"left":return{top:t.top,left:t.left-e.width-u}}},j=(p,S,h)=>{if(p==="top"||p==="bottom")switch(S){case"start":return{...h,left:t.left+b};case"center":return{...h,left:t.left+t.width/2-e.width/2+b};case"end":return{...h,left:t.right-e.width+b}}else switch(S){case"start":return{...h,top:t.top+b};case"center":return{...h,top:t.top+t.height/2-e.height/2+b};case"end":return{...h,top:t.bottom-e.height+b}}},r=T(s);r=j(s,d,r);let B;if(L){let p={top:t.top-u-i,bottom:l.height-t.bottom-u-i,left:t.left-u-i,right:l.width-t.right-u-i},S=c==="top"||c==="bottom"?e.height:e.width,h=V[c];S>p[c]&&p[h]>p[c]&&(s=h,r=T(s),r=j(s,d,r));let A=l.width-e.width-i,C=l.height-e.height-i,y=s==="top"||s==="bottom";r.left>A&&(r.left=A,y&&(d="end")),r.left<i&&(r.left=i,y&&(d="start")),r.top>C&&(r.top=C,y||(d="end")),r.top<i&&(r.top=i,y||(d="start")),B=Math.max(0,l.height-2*i)}R.current=!0,H({top:r.top,left:r.left,actualSide:s,actualAlign:d,isReady:!0,availableHeight:B})},[o,n,c,a,u,b,L,i]);return(0,m.useLayoutEffect)(()=>{if(!f)return;let t=0;R.current=!1,H(l=>l.isReady?{...l,isReady:!1}:l);let e=()=>{v(),R.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let g=()=>v(),w=(0,E.ownerWindowOf)(o.current);return w.addEventListener("resize",g),w.addEventListener("scroll",g,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),w.removeEventListener("resize",g),w.removeEventListener("scroll",g,{capture:!0})}},[v,f]),F}0&&(module.exports={usePositioning});
@@ -1 +1 @@
1
- "use client";import{useState as j,useLayoutEffect as B,useCallback as C,useRef as F}from"react";var M={top:"bottom",bottom:"top",left:"right",right:"left"};function q({triggerRef:w,contentRef:d,isOpen:y,side:a="bottom",align:g="start",sideOffset:n=4,alignOffset:h=0,avoidCollisions:A=!0,collisionPadding:o=8}){let[T,v]=j({top:0,left:0,actualSide:a,actualAlign:g,isReady:!1}),m=F(!1),R=C(()=>{if(!w.current||!d.current)return;let t=w.current.getBoundingClientRect(),e=d.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){m.current=!1;return}let i={width:window.innerWidth,height:window.innerHeight},u=a,s=g,x=l=>{switch(l){case"bottom":return{top:t.bottom+n,left:t.left};case"top":return{top:t.top-e.height-n,left:t.left};case"right":return{top:t.top,left:t.right+n};case"left":return{top:t.top,left:t.left-e.width-n}}},E=(l,f,c)=>{if(l==="top"||l==="bottom")switch(f){case"start":return{...c,left:t.left+h};case"center":return{...c,left:t.left+t.width/2-e.width/2+h};case"end":return{...c,left:t.right-e.width+h}}else switch(f){case"start":return{...c,top:t.top+h};case"center":return{...c,top:t.top+t.height/2-e.height/2+h};case"end":return{...c,top:t.bottom-e.height+h}}},r=x(u);r=E(u,s,r);let L;if(A){let l={top:t.top-n-o,bottom:i.height-t.bottom-n-o,left:t.left-n-o,right:i.width-t.right-n-o},f=a==="top"||a==="bottom"?e.height:e.width,c=M[a];f>l[a]&&l[c]>l[a]&&(u=c,r=x(u),r=E(u,s,r));let S=i.width-e.width-o,H=i.height-e.height-o,b=u==="top"||u==="bottom";r.left>S&&(r.left=S,b&&(s="end")),r.left<o&&(r.left=o,b&&(s="start")),r.top>H&&(r.top=H,b||(s="end")),r.top<o&&(r.top=o,b||(s="start")),L=Math.max(0,i.height-2*o)}m.current=!0,v({top:r.top,left:r.left,actualSide:u,actualAlign:s,isReady:!0,availableHeight:L})},[w,d,a,g,n,h,A,o]);return B(()=>{if(!y)return;let t=0;m.current=!1,v(i=>i.isReady?{...i,isReady:!1}:i);let e=()=>{R(),m.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let p=()=>R();return window.addEventListener("resize",p),window.addEventListener("scroll",p,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),window.removeEventListener("resize",p),window.removeEventListener("scroll",p,{capture:!0})}},[R,y]),T}export{q as usePositioning};
1
+ "use client";import{useState as C,useLayoutEffect as F,useCallback as M,useRef as k}from"react";import{ownerWindowOf as j}from"../../../lib/owner-document.js";var q={top:"bottom",bottom:"top",left:"right",right:"left"};function U({triggerRef:m,contentRef:g,isOpen:v,side:a="bottom",align:R="start",sideOffset:n=4,alignOffset:h=0,avoidCollisions:A=!0,collisionPadding:o=8}){let[B,x]=C({top:0,left:0,actualSide:a,actualAlign:R,isReady:!1}),b=k(!1),S=M(()=>{if(!m.current||!g.current)return;let t=m.current.getBoundingClientRect(),e=g.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){b.current=!1;return}let s=j(m.current),i={width:s.innerWidth,height:s.innerHeight},u=a,p=R,E=l=>{switch(l){case"bottom":return{top:t.bottom+n,left:t.left};case"top":return{top:t.top-e.height-n,left:t.left};case"right":return{top:t.top,left:t.right+n};case"left":return{top:t.top,left:t.left-e.width-n}}},L=(l,w,c)=>{if(l==="top"||l==="bottom")switch(w){case"start":return{...c,left:t.left+h};case"center":return{...c,left:t.left+t.width/2-e.width/2+h};case"end":return{...c,left:t.right-e.width+h}}else switch(w){case"start":return{...c,top:t.top+h};case"center":return{...c,top:t.top+t.height/2-e.height/2+h};case"end":return{...c,top:t.bottom-e.height+h}}},r=E(u);r=L(u,p,r);let H;if(A){let l={top:t.top-n-o,bottom:i.height-t.bottom-n-o,left:t.left-n-o,right:i.width-t.right-n-o},w=a==="top"||a==="bottom"?e.height:e.width,c=q[a];w>l[a]&&l[c]>l[a]&&(u=c,r=E(u),r=L(u,p,r));let y=i.width-e.width-o,T=i.height-e.height-o,d=u==="top"||u==="bottom";r.left>y&&(r.left=y,d&&(p="end")),r.left<o&&(r.left=o,d&&(p="start")),r.top>T&&(r.top=T,d||(p="end")),r.top<o&&(r.top=o,d||(p="start")),H=Math.max(0,i.height-2*o)}b.current=!0,x({top:r.top,left:r.left,actualSide:u,actualAlign:p,isReady:!0,availableHeight:H})},[m,g,a,R,n,h,A,o]);return F(()=>{if(!v)return;let t=0;b.current=!1,x(i=>i.isReady?{...i,isReady:!1}:i);let e=()=>{S(),b.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let f=()=>S(),s=j(m.current);return s.addEventListener("resize",f),s.addEventListener("scroll",f,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),s.removeEventListener("resize",f),s.removeEventListener("scroll",f,{capture:!0})}},[S,v]),B}export{U as usePositioning};
@@ -1 +1 @@
1
- "use strict";"use client";var le=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Te=(u,l)=>{for(var c in l)le(u,c,{get:l[c],enumerable:!0})},we=(u,l,c,t)=>{if(l&&typeof l=="object"||typeof l=="function")for(let i of Le(l))!Pe.call(u,i)&&i!==c&&le(u,i,{get:()=>l[i],enumerable:!(t=De(l,i))||t.enumerable});return u};var Ve=u=>we(le({},"__esModule",{value:!0}),u);var Ke={};Te(Ke,{DumbbellChart:()=>He,resetDumbbellWarnings:()=>We});module.exports=Ve(Ke);var s=require("react"),j=require("../../lib/i18n.cjs"),ae=require("../chart/ChartAxis.cjs"),he=require("../chart/ChartContainer.cjs"),de=require("../chart/ChartGrid.cjs"),ge=require("../chart/ChartLegend.cjs"),be=require("../chart/ChartTableView.cjs"),q=require("../chart/ChartTooltip.cjs"),y=require("../chart/palette.cjs"),fe=require("../chart/utils/cartesian.cjs"),z=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ye=require("../chart/utils/keyboard.cjs"),pe=require("../chart/utils/scales.cjs"),Ce=require("../chart/utils/text.cjs"),ve=require("../chart/utils/ticks.cjs"),xe=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Ae=5,Ne=3,me=10,oe=!1;function We(){oe=!1}var Ie=(0,s.memo)(function({rows:l,radius:c}){return(0,n.jsx)("g",{children:l.map(t=>(0,n.jsxs)("g",{children:[t.connector?(0,n.jsx)("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:Ne,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(i=>(0,n.jsx)("circle",{cx:i.cx,cy:i.cy,r:c,fill:i.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},i.key)),t.label?(0,n.jsx)("text",{x:t.label.x,y:t.label.y,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 ze({width:u,height:l,data:c,rows:t,resolvedSeries:i,x:S,y:w,grid:U,size:O,showValues:Y,dotSize:J,referenceLines:H,margin:B,tooltip:g,plotLabel:Q,formatValue:K,formatX:X,onRowClick:D}){let[L,V]=(0,s.useState)(null),h=L!==null&&L<t.length?L:null,e=(0,s.useMemo)(()=>{let E=i.filter(m=>!m.hidden).map(m=>m.key),p=(0,fe.buildCartesianGeometry)({width:u,height:l,data:c,x:S,y:w,bounds:(0,ve.extent)((0,z.collectAllValues)(c,E)),margin:B,orientation:"horizontal",placement:"band",formatValue:K,formatX:X,defaultIncludeZero:!1}),{valueScale:P,bandwidth:A,categoryPositions:M,innerWidth:Z,innerHeight:ne}=p;return{rendered:t.map((m,N)=>{let G=M[N]+A/2,v=m.points.map((a,x)=>({key:a.seriesKey,value:a.value,cx:a.value===null?Number.NaN:P(a.value),cy:G,color:a.color,order:x})).filter(a=>a.value!==null),W=m.from===null||m.to===null||v.length<2?null:{x1:P(m.from),x2:P(m.to),y:G},T=null;if(Y&&m.to!==null){let a=K(m.to),x=P(m.to);(0,Ce.estimateTextWidth)(a,10)<=Z-x-me&&(T={x:x+me,y:G,text:a})}return{key:`${N}`,connector:W,dots:v.map(a=>({key:a.key,cx:a.cx,cy:a.cy,color:a.color})),label:T,top:M[N],height:A}}),categoryPositions:M,categoryCenters:p.categoryCenters,bandwidth:A,categoryTicks:p.categoryTicks,valueTicks:p.valueTicks,valueScale:P,innerWidth:Z,innerHeight:ne,margin:p.margin}},[c,t,i,S,w,u,l,B,Y,K,X]),ee=(0,s.useCallback)(o=>{if(g===!1||t.length===0)return;let E=o.currentTarget.getBoundingClientRect(),p=o.clientY-E.top-e.margin.top;V((0,pe.nearestIndex)(e.categoryCenters,p))},[g,t.length,e.margin.top,e.categoryCenters]),$=(0,s.useCallback)(()=>{!D||h===null||D(t[h])},[D,h,t]),te=(0,s.useCallback)(o=>(0,ye.handleChartKeyDown)(o,{count:t.length,current:h,axis:"y",onMove:V,pick:D?$:null}),[t.length,h,D,$]),C=h===null?null:t[h];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:l,role:"img","aria-label":Q??i.map(o=>(0,y.getSeriesLabel)(o)).join(", "),tabIndex:0,className:`${xe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ee,onPointerLeave:()=>V(null),onKeyDown:te,onBlur:()=>V(null),onClick:$,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(de.ChartGrid,{width:e.innerWidth,height:e.innerHeight,vertical:U==="y"||U==="both"?e.valueTicks.map(o=>o.offset):void 0}),h!==null?(0,n.jsx)("rect",{x:0,y:e.categoryPositions[h],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,H?.map(o=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:e.valueScale(o.value),y1:0,x2:e.valueScale(o.value),y2:e.innerHeight,stroke:o.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:o.dashed===!1?void 0:"4 4"}),o.label?(0,n.jsx)("text",{x:e.valueScale(o.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:o.label}):null]},`${o.value}-${o.label??""}`)),(0,n.jsx)(Ie,{rows:e.rendered,radius:J})]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:w?.hidden?null:(0,n.jsx)(ae.ChartAxis,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:w?.label,size:O})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:S.hidden?null:(0,n.jsx)(ae.ChartAxis,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:S.label,size:O})})]}),C&&h!==null&&g!==!1?(0,n.jsx)(q.ChartTooltip,{x:e.margin.left+(C.to===null?e.innerWidth/2:e.valueScale(C.to)),y:e.margin.top+e.categoryCenters[h],containerWidth:u,children:typeof g=="function"?g(C):(0,n.jsx)(q.ChartTooltipContent,{title:C.label,points:C.points})}):null]})}function He({data:u,x:l,y:c,series:t,sort:i="none",sortBy:S,showValues:w=!1,dotSize:U=Ae,referenceLines:O,height:Y,width:J,size:H="md",grid:B="y",legend:g,legendToggle:Q=!0,tooltip:K=!0,tableView:X=!1,showChange:D=!0,title:L,description:V,loading:h=!1,emptyState:e,error:ee=!1,errorState:$,onRetry:te,actions:C,margin:o,locale:E,plotLabel:p,changeLabel:P,format:A,onRowClick:M,className:Z,...ne}){let _=(0,j.useUILocale)(E),m=(0,j.useUILabels)(),[N,G]=(0,s.useState)(()=>new Set);t.length>y.CHART_ALL_PAIRS_LIMIT&&!oe&&(oe=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${y.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let v=(0,s.useMemo)(()=>t.map((r,d)=>({...r,hidden:r.hidden||N.has(r.key),color:(0,y.resolveSeriesColor)(r,d)})),[t,N]),W=(0,s.useMemo)(()=>c?.format??A??(r=>(0,F.formatAuto)(r,_)),[c?.format,A,_]),T=(0,s.useMemo)(()=>l.format??(r=>(0,F.formatXValue)(r,_)),[l.format,_]),a=(0,s.useMemo)(()=>v.filter(r=>!r.hidden),[v]),x=(0,s.useMemo)(()=>u.map((r,d)=>{let b=(0,z.readXValue)(r,l.key,d),f=a.map(R=>{let re=(0,z.readNumber)(r,R.key);return{seriesKey:R.key,seriesLabel:(0,y.getSeriesLabel)(R),color:R.color,value:re,formattedValue:re===null?"\u2014":W(re),datum:r}}),k=f.map(R=>R.value).filter(R=>R!==null),ue=f[0]?.value??null,ce=f[f.length-1]?.value??null;return{index:d,x:b,label:T(b,d),points:f,from:k.length>0?Math.min(...k):null,to:k.length>0?Math.max(...k):null,change:ue===null||ce===null?null:ce-ue,datum:r}}),[u,l.key,a,W,T]),I=(0,s.useMemo)(()=>{if(i==="none")return x;let r=S??a[a.length-1]?.key,d=f=>i==="gap"?Math.abs(f.change??0):f.points.find(k=>k.seriesKey===r)?.value??0,b=[...x].sort((f,k)=>d(f)-d(k));return i==="asc"?b:b.reverse()},[x,i,S,a]),ke=(0,s.useCallback)(r=>{G(d=>{let b=new Set(d);return b.has(r)?b.delete(r):b.add(r),b})},[]),ie=Y??Math.max(96,I.length*30+44),Re=(0,s.useMemo)(()=>I.map(r=>({...r.datum,__change:r.change})),[I]),Se=g===void 0?t.length>=2:g!==!1,se=typeof g=="string"?g:"bottom";return(0,n.jsx)(he.ChartContainer,{title:L,description:V,height:ie,width:J,size:H,loading:h,empty:I.length===0||a.length===0,emptyState:e,error:ee,errorState:$,onRetry:te,actions:C,tableView:X,legendPosition:se,legend:Se?(0,n.jsx)(ge.ChartLegend,{items:(0,y.toLegendItems)(v),position:se,marker:"dot",size:H,onToggle:Q?ke:void 0}):void 0,table:X?(0,n.jsx)(be.ChartTableView,{data:Re,series:[...v,...D?[{key:"__change",label:P??m.chartChange}]:[]],xKey:l.key,xLabel:l.label??l.key,formatX:T,formatValue:W,caption:typeof L=="string"?L:void 0}):void 0,className:Z,...ne,children:({width:r})=>(0,n.jsx)(ze,{width:r,height:ie,data:I.map(d=>d.datum),rows:I,resolvedSeries:v,x:l,y:c,grid:B,size:H,showValues:w,dotSize:U,referenceLines:O,margin:o,tooltip:K,plotLabel:p,formatValue:W,formatX:T,onRowClick:M})})}0&&(module.exports={DumbbellChart,resetDumbbellWarnings});
1
+ "use strict";"use client";var ue=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Ae=(u,n)=>{for(var m in n)ue(u,m,{get:n[m],enumerable:!0})},we=(u,n,m,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of Te(n))!Ve.call(u,l)&&l!==m&&ue(u,l,{get:()=>n[l],enumerable:!(a=Pe(n,l))||a.enumerable});return u};var Ie=u=>we(ue({},"__esModule",{value:!0}),u);var $e={};Ae($e,{DumbbellChart:()=>_e,resetDumbbellWarnings:()=>He});module.exports=Ie($e);var i=require("react"),ee=require("../../lib/i18n.cjs"),ce=require("../chart/ChartAxis.cjs"),pe=require("../chart/ChartContainer.cjs"),ye=require("../chart/ChartGrid.cjs"),Ce=require("../chart/ChartLegend.cjs"),$=require("../chart/ChartPlotClip.cjs"),ve=require("../chart/ChartTableView.cjs"),te=require("../chart/ChartTooltip.cjs"),f=require("../chart/palette.cjs"),E=require("../chart/utils/cartesian.cjs"),z=require("../chart/utils/data.cjs"),ne=require("../chart/utils/format.cjs"),ke=require("../chart/utils/keyboard.cjs"),xe=require("../chart/utils/scales.cjs"),Re=require("../chart/utils/text.cjs"),Se=require("../chart/utils/ticks.cjs"),De=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),Ne=5,We=3,fe=10,me=!1;function He(){me=!1}var Ke=(0,i.memo)(function({rows:n,radius:m,clipId:a}){return(0,t.jsx)("g",{clipPath:`url(#${a})`,children:n.map(l=>(0,t.jsxs)("g",{children:[l.connector?(0,t.jsx)("line",{x1:l.connector.x1,y1:l.connector.y,x2:l.connector.x2,y2:l.connector.y,strokeWidth:We,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,l.dots.map(d=>(0,t.jsx)("circle",{cx:d.cx,cy:d.cy,r:m,fill:d.color,strokeWidth:2,stroke:f.CHART_SURFACE_COLOR},d.key)),l.label?(0,t.jsx)("text",{x:l.label.x,y:l.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:l.label.text}):null]},l.key))})});function Xe({width:u,height:n,data:m,rows:a,resolvedSeries:l,x:d,y:N,grid:F,size:Z,showValues:j,dotSize:q,referenceLines:T,margin:J,tooltip:y,plotLabel:le,formatValue:G,formatX:M,onRowClick:V,locale:W}){let[O,H]=(0,i.useState)(null),g=O!==null&&O<a.length?O:null,Q=(0,$.plotClipId)((0,i.useId)()),e=(0,i.useMemo)(()=>{let C=l.filter(h=>!h.hidden).map(h=>h.key),v=(0,E.buildCartesianGeometry)({locale:W,width:u,height:n,data:m,x:d,y:N,bounds:(0,E.widenBounds)((0,Se.extent)((0,z.collectAllValues)(m,C)),(0,E.annotationValues)(m,d.key,T,void 0)),margin:J,orientation:"horizontal",placement:"band",formatValue:G,formatX:M,defaultIncludeZero:!1}),{valueScale:A,bandwidth:B,categoryPositions:Y,innerWidth:S,innerHeight:ae}=v;return{rendered:a.map((h,k)=>{let D=Y[k]+B/2,w=h.points.map((o,X)=>({key:o.seriesKey,value:o.value,cx:o.value===null?Number.NaN:A(o.value),cy:D,color:o.color,order:X})).filter(o=>o.value!==null),L=h.from===null||h.to===null||w.length<2?null:{x1:A(h.from),x2:A(h.to),y:D},K=null;if(j&&h.to!==null){let o=G(h.to),X=A(h.to);(0,Re.estimateTextWidth)(o,10)<=S-X-fe&&(K={x:X+fe,y:D,text:o})}return{key:`${k}`,connector:L,dots:w.map(o=>({key:o.key,cx:o.cx,cy:o.cy,color:o.color})),label:K,top:Y[k],height:B}}),categoryPositions:Y,categoryCenters:v.categoryCenters,bandwidth:B,categoryTicks:v.categoryTicks,valueTicks:v.valueTicks,valueScale:A,innerWidth:S,innerHeight:ae,margin:v.margin}},[W,m,a,l,d,N,u,n,J,j,T,G,M]),re=(0,i.useCallback)(s=>{if(y===!1||a.length===0)return;let C=s.currentTarget.getBoundingClientRect(),v=s.clientY-C.top-e.margin.top;H((0,xe.nearestIndex)(e.categoryCenters,v))},[y,a.length,e.margin.top,e.categoryCenters]),U=(0,i.useCallback)(()=>{!V||g===null||V(a[g])},[V,g,a]),oe=(0,i.useCallback)(s=>(0,ke.handleChartKeyDown)(s,{count:a.length,current:g,axis:"y",onMove:H,pick:V?U:null}),[a.length,g,V,U]),R=g===null?null:a[g];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:u,height:n,role:"img","aria-label":le??l.map(s=>(0,f.getSeriesLabel)(s)).join(", "),tabIndex:0,className:`${De.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:re,onPointerLeave:()=>H(null),onKeyDown:oe,onBlur:()=>H(null),onClick:U,children:[(0,t.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,t.jsx)($.ChartPlotClip,{id:Q,width:e.innerWidth,height:e.innerHeight,bleed:q+2}),(0,t.jsx)(ye.ChartGrid,{width:e.innerWidth,height:e.innerHeight,vertical:F==="y"||F==="both"?e.valueTicks.map(s=>s.offset):void 0}),g!==null?(0,t.jsx)("rect",{x:0,y:e.categoryPositions[g],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,T?.map(s=>{let C=e.valueScale(s.value);return(0,$.isOnPlot)(C,e.innerWidth)?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:C,y1:0,x2:C,y2:e.innerHeight,stroke:s.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:s.dashed===!1?void 0:"4 4"}),s.label?(0,t.jsx)("text",{x:C+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:s.label}):null]},`${s.value}-${s.label??""}`):null}),(0,t.jsx)(Ke,{rows:e.rendered,radius:q,clipId:Q})]}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:N?.hidden?null:(0,t.jsx)(ce.ChartAxis,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:N?.label,size:Z})}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:d.hidden?null:(0,t.jsx)(ce.ChartAxis,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:d.label,size:Z})})]}),R&&g!==null&&y!==!1?(0,t.jsx)(te.ChartTooltip,{x:e.margin.left+(R.to===null?e.innerWidth/2:e.valueScale(R.to)),y:e.margin.top+e.categoryCenters[g],containerWidth:u,children:typeof y=="function"?y(R):(0,t.jsx)(te.ChartTooltipContent,{title:R.label,points:R.points})}):null]})}function _e({data:u,x:n,y:m,series:a,sort:l="none",sortBy:d,showValues:N=!1,dotSize:F=Ne,referenceLines:Z,height:j,width:q,size:T="md",grid:J="y",legend:y,legendToggle:le=!0,tooltip:G=!0,tableView:M=!1,showChange:V=!0,title:W,description:O,loading:H=!1,emptyState:g,error:Q=!1,errorState:e,onRetry:re,actions:U,margin:oe,locale:R,plotLabel:s,changeLabel:C,format:v,onRowClick:A,className:B,...Y}){let S=(0,ee.useUILocale)(R),ae=(0,ee.useUILabels)(),[ie,h]=(0,i.useState)(()=>new Set);a.length>f.CHART_ALL_PAIRS_LIMIT&&!me&&(me=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${a.length} series. Any two dots of a row can sit side by side, and only the first ${f.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let k=(0,i.useMemo)(()=>a.map((r,b)=>({...r,hidden:r.hidden||ie.has(r.key),color:(0,f.resolveSeriesColor)(r,b)})),[a,ie]),D=(0,i.useMemo)(()=>m?.format??v??(r=>(0,ne.formatAuto)(r,S)),[m?.format,v,S]),w=(0,i.useMemo)(()=>n.format??(r=>(0,ne.formatXValue)(r,S)),[n.format,S]),L=(0,i.useMemo)(()=>k.filter(r=>!r.hidden),[k]),K=(0,i.useMemo)(()=>u.map((r,b)=>{let x=(0,z.readXValue)(r,n.key,b),c=L.map(P=>{let se=(0,z.readNumber)(r,P.key);return{seriesKey:P.key,seriesLabel:(0,f.getSeriesLabel)(P),color:P.color,value:se,formattedValue:se===null?"\u2014":D(se),datum:r}}),I=c.map(P=>P.value).filter(P=>P!==null),p=c.length<2?null:c[0]?.value??null,_=c.length<2?null:c[c.length-1]?.value??null;return{index:b,x,label:w(x,b),points:c,from:I.length>0?Math.min(...I):null,to:I.length>0?Math.max(...I):null,change:p===null||_===null?null:_-p,datum:r}}),[u,n.key,L,D,w]),o=(0,i.useMemo)(()=>{if(l==="none")return K;let r=d??L[L.length-1]?.key,b=c=>l!=="gap"?c.points.find(p=>p.seriesKey===r)?.value??null:c.points.filter(p=>p.value!==null).length<2||c.from===null||c.to===null?null:c.to-c.from,x=l==="asc"?1:-1;return[...K].sort((c,I)=>{let p=b(c),_=b(I);return p===null||_===null?p===_?0:p===null?1:-1:(p-_)*x})},[K,l,d,L]),X=(0,i.useCallback)(r=>{h(b=>{let x=new Set(b);return x.has(r)?x.delete(r):x.add(r),x})},[]),he=j??Math.max(96,o.length*30+44),de=[...k,...V?[{key:"__change",label:C??ae.chartChange}]:[]],ge=(0,i.useMemo)(()=>o.map(r=>({...r.datum,__change:r.change})),[o]),Le=y===void 0?a.length>=2:y!==!1,be=typeof y=="string"?y:"bottom";return(0,t.jsx)(pe.ChartContainer,{title:W,description:O,height:he,width:q,size:T,loading:H,empty:o.length===0||L.length===0,emptyState:g,error:Q,errorState:e,onRetry:re,actions:U,exportSource:{data:ge,series:de,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:M,legendPosition:be,legend:Le?(0,t.jsx)(Ce.ChartLegend,{items:(0,f.toLegendItems)(k),position:be,marker:"dot",size:T,onToggle:le?X:void 0}):void 0,table:M?(0,t.jsx)(ve.ChartTableView,{data:ge,series:de,xKey:n.key,xLabel:n.label??n.key,formatX:w,formatValue:D,caption:typeof W=="string"?W:void 0}):void 0,className:B,...Y,children:({width:r})=>(0,t.jsx)(Xe,{locale:S,width:r,height:he,data:o.map(b=>b.datum),rows:o,resolvedSeries:k,x:n,y:m,grid:J,size:T,showValues:N,dotSize:F,referenceLines:Z,margin:oe,tooltip:G,plotLabel:s,formatValue:D,formatX:w,onRowClick:A})})}0&&(module.exports={DumbbellChart,resetDumbbellWarnings});
@@ -1 +1 @@
1
- "use client";import{memo as ge,useCallback as Z,useMemo as k,useState as ue}from"react";import{useUILabels as be,useUILocale as fe}from"../../lib/i18n.js";import{ChartAxis as oe}from"../chart/ChartAxis.js";import{ChartContainer as ye}from"../chart/ChartContainer.js";import{ChartGrid as pe}from"../chart/ChartGrid.js";import{ChartLegend as Ce}from"../chart/ChartLegend.js";import{ChartTableView as ve}from"../chart/ChartTableView.js";import{ChartTooltip as xe,ChartTooltipContent as ke}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as ie,getSeriesLabel as ce,resolveSeriesColor as Re,toLegendItems as Se}from"../chart/palette.js";import{buildCartesianGeometry as De}from"../chart/utils/cartesian.js";import{collectAllValues as Le,readNumber as Pe,readXValue as Te}from"../chart/utils/data.js";import{formatAuto as we,formatXValue as Ve}from"../chart/utils/format.js";import{handleChartKeyDown as Ae}from"../chart/utils/keyboard.js";import{nearestIndex as Ne}from"../chart/utils/scales.js";import{estimateTextWidth as We}from"../chart/utils/text.js";import{extent as Ie}from"../chart/utils/ticks.js";import{CHART_TOUCH as ze}from"../chart/utils/touch.js";import{Fragment as Ee,jsx as a,jsxs as _}from"react/jsx-runtime";var He=5,Ke=3,se=10,te=!1;function lt(){te=!1}var Xe=ge(function({rows:o,radius:g}){return a("g",{children:o.map(t=>_("g",{children:[t.connector?a("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:Ke,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(s=>a("circle",{cx:s.cx,cy:s.cy,r:g,fill:s.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},s.key)),t.label?a("text",{x:t.label.x,y:t.label.y,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 $e({width:f,height:o,data:g,rows:t,resolvedSeries:s,x:R,y:T,grid:G,size:U,showValues:O,dotSize:j,referenceLines:I,margin:Y,tooltip:m,plotLabel:q,formatValue:z,formatX:H,onRowClick:S}){let[D,w]=ue(null),u=D!==null&&D<t.length?D:null,e=k(()=>{let X=s.filter(i=>!i.hidden).map(i=>i.key),b=De({width:f,height:o,data:g,x:R,y:T,bounds:Ie(Le(g,X)),margin:Y,orientation:"horizontal",placement:"band",formatValue:z,formatX:H,defaultIncludeZero:!1}),{valueScale:L,bandwidth:V,categoryPositions:$,innerWidth:B,innerHeight:Q}=b;return{rendered:t.map((i,A)=>{let M=$[A]+V/2,p=i.points.map((r,C)=>({key:r.seriesKey,value:r.value,cx:r.value===null?Number.NaN:L(r.value),cy:M,color:r.color,order:C})).filter(r=>r.value!==null),N=i.from===null||i.to===null||p.length<2?null:{x1:L(i.from),x2:L(i.to),y:M},P=null;if(O&&i.to!==null){let r=z(i.to),C=L(i.to);We(r,10)<=B-C-se&&(P={x:C+se,y:M,text:r})}return{key:`${A}`,connector:N,dots:p.map(r=>({key:r.key,cx:r.cx,cy:r.cy,color:r.color})),label:P,top:$[A],height:V}}),categoryPositions:$,categoryCenters:b.categoryCenters,bandwidth:V,categoryTicks:b.categoryTicks,valueTicks:b.valueTicks,valueScale:L,innerWidth:B,innerHeight:Q,margin:b.margin}},[g,t,s,R,T,f,o,Y,O,z,H]),F=Z(l=>{if(m===!1||t.length===0)return;let X=l.currentTarget.getBoundingClientRect(),b=l.clientY-X.top-e.margin.top;w(Ne(e.categoryCenters,b))},[m,t.length,e.margin.top,e.categoryCenters]),K=Z(()=>{!S||u===null||S(t[u])},[S,u,t]),J=Z(l=>Ae(l,{count:t.length,current:u,axis:"y",onMove:w,pick:S?K:null}),[t.length,u,S,K]),y=u===null?null:t[u];return _(Ee,{children:[_("svg",{width:f,height:o,role:"img","aria-label":q??s.map(l=>ce(l)).join(", "),tabIndex:0,className:`${ze} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:F,onPointerLeave:()=>w(null),onKeyDown:J,onBlur:()=>w(null),onClick:K,children:[_("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[a(pe,{width:e.innerWidth,height:e.innerHeight,vertical:G==="y"||G==="both"?e.valueTicks.map(l=>l.offset):void 0}),u!==null?a("rect",{x:0,y:e.categoryPositions[u],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,I?.map(l=>_("g",{children:[a("line",{x1:e.valueScale(l.value),y1:0,x2:e.valueScale(l.value),y2:e.innerHeight,stroke:l.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:l.dashed===!1?void 0:"4 4"}),l.label?a("text",{x:e.valueScale(l.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:l.label}):null]},`${l.value}-${l.label??""}`)),a(Xe,{rows:e.rendered,radius:j})]}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:T?.hidden?null:a(oe,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:T?.label,size:U})}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:R.hidden?null:a(oe,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:R.label,size:U})})]}),y&&u!==null&&m!==!1?a(xe,{x:e.margin.left+(y.to===null?e.innerWidth/2:e.valueScale(y.to)),y:e.margin.top+e.categoryCenters[u],containerWidth:f,children:typeof m=="function"?m(y):a(ke,{title:y.label,points:y.points})}):null]})}function at({data:f,x:o,y:g,series:t,sort:s="none",sortBy:R,showValues:T=!1,dotSize:G=He,referenceLines:U,height:O,width:j,size:I="md",grid:Y="y",legend:m,legendToggle:q=!0,tooltip:z=!0,tableView:H=!1,showChange:S=!0,title:D,description:w,loading:u=!1,emptyState:e,error:F=!1,errorState:K,onRetry:J,actions:y,margin:l,locale:X,plotLabel:b,changeLabel:L,format:V,onRowClick:$,className:B,...Q}){let E=fe(X),i=be(),[A,M]=ue(()=>new Set);t.length>ie&&!te&&(te=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${ie} palette slots stay tellable apart under that test: facet the chart instead.`));let p=k(()=>t.map((n,c)=>({...n,hidden:n.hidden||A.has(n.key),color:Re(n,c)})),[t,A]),N=k(()=>g?.format??V??(n=>we(n,E)),[g?.format,V,E]),P=k(()=>o.format??(n=>Ve(n,E)),[o.format,E]),r=k(()=>p.filter(n=>!n.hidden),[p]),C=k(()=>f.map((n,c)=>{let h=Te(n,o.key,c),d=r.map(x=>{let ee=Pe(n,x.key);return{seriesKey:x.key,seriesLabel:ce(x),color:x.color,value:ee,formattedValue:ee===null?"\u2014":N(ee),datum:n}}),v=d.map(x=>x.value).filter(x=>x!==null),le=d[0]?.value??null,ae=d[d.length-1]?.value??null;return{index:c,x:h,label:P(h,c),points:d,from:v.length>0?Math.min(...v):null,to:v.length>0?Math.max(...v):null,change:le===null||ae===null?null:ae-le,datum:n}}),[f,o.key,r,N,P]),W=k(()=>{if(s==="none")return C;let n=R??r[r.length-1]?.key,c=d=>s==="gap"?Math.abs(d.change??0):d.points.find(v=>v.seriesKey===n)?.value??0,h=[...C].sort((d,v)=>c(d)-c(v));return s==="asc"?h:h.reverse()},[C,s,R,r]),me=Z(n=>{M(c=>{let h=new Set(c);return h.has(n)?h.delete(n):h.add(n),h})},[]),ne=O??Math.max(96,W.length*30+44),he=k(()=>W.map(n=>({...n.datum,__change:n.change})),[W]),de=m===void 0?t.length>=2:m!==!1,re=typeof m=="string"?m:"bottom";return a(ye,{title:D,description:w,height:ne,width:j,size:I,loading:u,empty:W.length===0||r.length===0,emptyState:e,error:F,errorState:K,onRetry:J,actions:y,tableView:H,legendPosition:re,legend:de?a(Ce,{items:Se(p),position:re,marker:"dot",size:I,onToggle:q?me:void 0}):void 0,table:H?a(ve,{data:he,series:[...p,...S?[{key:"__change",label:L??i.chartChange}]:[]],xKey:o.key,xLabel:o.label??o.key,formatX:P,formatValue:N,caption:typeof D=="string"?D:void 0}):void 0,className:B,...Q,children:({width:n})=>a($e,{width:n,height:ne,data:W.map(c=>c.datum),rows:W,resolvedSeries:p,x:o,y:g,grid:Y,size:I,showValues:T,dotSize:G,referenceLines:U,margin:l,tooltip:z,plotLabel:b,formatValue:N,formatX:P,onRowClick:$})})}export{at as DumbbellChart,lt as resetDumbbellWarnings};
1
+ "use client";import{memo as be,useCallback as q,useId as fe,useMemo as L,useState as he}from"react";import{useUILabels as pe,useUILocale as ye}from"../../lib/i18n.js";import{ChartAxis as ue}from"../chart/ChartAxis.js";import{ChartContainer as Ce}from"../chart/ChartContainer.js";import{ChartGrid as ve}from"../chart/ChartGrid.js";import{ChartLegend as ke}from"../chart/ChartLegend.js";import{ChartPlotClip as xe,isOnPlot as Re,plotClipId as Se}from"../chart/ChartPlotClip.js";import{ChartTableView as De}from"../chart/ChartTableView.js";import{ChartTooltip as Le,ChartTooltipContent as Pe}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as ce,CHART_SURFACE_COLOR as Te,getSeriesLabel as de,resolveSeriesColor as Ve,toLegendItems as Ae}from"../chart/palette.js";import{annotationValues as we,buildCartesianGeometry as Ie,widenBounds as Ne}from"../chart/utils/cartesian.js";import{collectAllValues as We,readNumber as He,readXValue as Ke}from"../chart/utils/data.js";import{formatAuto as Xe,formatXValue as _e}from"../chart/utils/format.js";import{handleChartKeyDown as $e}from"../chart/utils/keyboard.js";import{nearestIndex as Ee}from"../chart/utils/scales.js";import{estimateTextWidth as ze}from"../chart/utils/text.js";import{extent as Ge}from"../chart/utils/ticks.js";import{CHART_TOUCH as Me}from"../chart/utils/touch.js";import{Fragment as Fe,jsx as r,jsxs as O}from"react/jsx-runtime";var Oe=5,Ue=3,me=10,re=!1;function dt(){re=!1}var Be=be(function({rows:a,radius:g,clipId:i}){return r("g",{clipPath:`url(#${i})`,children:a.map(l=>O("g",{children:[l.connector?r("line",{x1:l.connector.x1,y1:l.connector.y,x2:l.connector.x2,y2:l.connector.y,strokeWidth:Ue,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,l.dots.map(c=>r("circle",{cx:c.cx,cy:c.cy,r:g,fill:c.color,strokeWidth:2,stroke:Te},c.key)),l.label?r("text",{x:l.label.x,y:l.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:l.label.text}):null]},l.key))})});function Ye({width:v,height:a,data:g,rows:i,resolvedSeries:l,x:c,y:I,grid:U,size:B,showValues:Y,dotSize:F,referenceLines:P,margin:Z,tooltip:b,plotLabel:J,formatValue:_,formatX:$,onRowClick:T,locale:N}){let[E,W]=he(null),m=E!==null&&E<i.length?E:null,j=Se(fe()),e=L(()=>{let f=l.filter(u=>!u.hidden).map(u=>u.key),p=Ie({locale:N,width:v,height:a,data:g,x:c,y:I,bounds:Ne(Ge(We(g,f)),we(g,c.key,P,void 0)),margin:Z,orientation:"horizontal",placement:"band",formatValue:_,formatX:$,defaultIncludeZero:!1}),{valueScale:V,bandwidth:G,categoryPositions:M,innerWidth:x,innerHeight:te}=p;return{rendered:i.map((u,y)=>{let R=M[y]+G/2,A=u.points.map((n,K)=>({key:n.seriesKey,value:n.value,cx:n.value===null?Number.NaN:V(n.value),cy:R,color:n.color,order:K})).filter(n=>n.value!==null),S=u.from===null||u.to===null||A.length<2?null:{x1:V(u.from),x2:V(u.to),y:R},H=null;if(Y&&u.to!==null){let n=_(u.to),K=V(u.to);ze(n,10)<=x-K-me&&(H={x:K+me,y:R,text:n})}return{key:`${y}`,connector:S,dots:A.map(n=>({key:n.key,cx:n.cx,cy:n.cy,color:n.color})),label:H,top:M[y],height:G}}),categoryPositions:M,categoryCenters:p.categoryCenters,bandwidth:G,categoryTicks:p.categoryTicks,valueTicks:p.valueTicks,valueScale:V,innerWidth:x,innerHeight:te,margin:p.margin}},[N,g,i,l,c,I,v,a,Z,Y,P,_,$]),Q=q(o=>{if(b===!1||i.length===0)return;let f=o.currentTarget.getBoundingClientRect(),p=o.clientY-f.top-e.margin.top;W(Ee(e.categoryCenters,p))},[b,i.length,e.margin.top,e.categoryCenters]),z=q(()=>{!T||m===null||T(i[m])},[T,m,i]),ee=q(o=>$e(o,{count:i.length,current:m,axis:"y",onMove:W,pick:T?z:null}),[i.length,m,T,z]),k=m===null?null:i[m];return O(Fe,{children:[O("svg",{width:v,height:a,role:"img","aria-label":J??l.map(o=>de(o)).join(", "),tabIndex:0,className:`${Me} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Q,onPointerLeave:()=>W(null),onKeyDown:ee,onBlur:()=>W(null),onClick:z,children:[O("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[r(xe,{id:j,width:e.innerWidth,height:e.innerHeight,bleed:F+2}),r(ve,{width:e.innerWidth,height:e.innerHeight,vertical:U==="y"||U==="both"?e.valueTicks.map(o=>o.offset):void 0}),m!==null?r("rect",{x:0,y:e.categoryPositions[m],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,P?.map(o=>{let f=e.valueScale(o.value);return Re(f,e.innerWidth)?O("g",{children:[r("line",{x1:f,y1:0,x2:f,y2:e.innerHeight,stroke:o.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:o.dashed===!1?void 0:"4 4"}),o.label?r("text",{x:f+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:o.label}):null]},`${o.value}-${o.label??""}`):null}),r(Be,{rows:e.rendered,radius:F,clipId:j})]}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:I?.hidden?null:r(ue,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:I?.label,size:B})}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:c.hidden?null:r(ue,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:c.label,size:B})})]}),k&&m!==null&&b!==!1?r(Le,{x:e.margin.left+(k.to===null?e.innerWidth/2:e.valueScale(k.to)),y:e.margin.top+e.categoryCenters[m],containerWidth:v,children:typeof b=="function"?b(k):r(Pe,{title:k.label,points:k.points})}):null]})}function gt({data:v,x:a,y:g,series:i,sort:l="none",sortBy:c,showValues:I=!1,dotSize:U=Oe,referenceLines:B,height:Y,width:F,size:P="md",grid:Z="y",legend:b,legendToggle:J=!0,tooltip:_=!0,tableView:$=!1,showChange:T=!0,title:N,description:E,loading:W=!1,emptyState:m,error:j=!1,errorState:e,onRetry:Q,actions:z,margin:ee,locale:k,plotLabel:o,changeLabel:f,format:p,onRowClick:V,className:G,...M}){let x=ye(k),te=pe(),[ne,u]=he(()=>new Set);i.length>ce&&!re&&(re=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${i.length} series. Any two dots of a row can sit side by side, and only the first ${ce} palette slots stay tellable apart under that test: facet the chart instead.`));let y=L(()=>i.map((t,h)=>({...t,hidden:t.hidden||ne.has(t.key),color:Ve(t,h)})),[i,ne]),R=L(()=>g?.format??p??(t=>Xe(t,x)),[g?.format,p,x]),A=L(()=>a.format??(t=>_e(t,x)),[a.format,x]),S=L(()=>y.filter(t=>!t.hidden),[y]),H=L(()=>v.map((t,h)=>{let C=Ke(t,a.key,h),s=S.map(D=>{let le=He(t,D.key);return{seriesKey:D.key,seriesLabel:de(D),color:D.color,value:le,formattedValue:le===null?"\u2014":R(le),datum:t}}),w=s.map(D=>D.value).filter(D=>D!==null),d=s.length<2?null:s[0]?.value??null,X=s.length<2?null:s[s.length-1]?.value??null;return{index:h,x:C,label:A(C,h),points:s,from:w.length>0?Math.min(...w):null,to:w.length>0?Math.max(...w):null,change:d===null||X===null?null:X-d,datum:t}}),[v,a.key,S,R,A]),n=L(()=>{if(l==="none")return H;let t=c??S[S.length-1]?.key,h=s=>l!=="gap"?s.points.find(d=>d.seriesKey===t)?.value??null:s.points.filter(d=>d.value!==null).length<2||s.from===null||s.to===null?null:s.to-s.from,C=l==="asc"?1:-1;return[...H].sort((s,w)=>{let d=h(s),X=h(w);return d===null||X===null?d===X?0:d===null?1:-1:(d-X)*C})},[H,l,c,S]),K=q(t=>{u(h=>{let C=new Set(h);return C.has(t)?C.delete(t):C.add(t),C})},[]),oe=Y??Math.max(96,n.length*30+44),ae=[...y,...T?[{key:"__change",label:f??te.chartChange}]:[]],ie=L(()=>n.map(t=>({...t.datum,__change:t.change})),[n]),ge=b===void 0?i.length>=2:b!==!1,se=typeof b=="string"?b:"bottom";return r(Ce,{title:N,description:E,height:oe,width:F,size:P,loading:W,empty:n.length===0||S.length===0,emptyState:m,error:j,errorState:e,onRetry:Q,actions:z,exportSource:{data:ie,series:ae,xKey:a.key,xLabel:a.label??a.key,formatX:a.format},tableView:$,legendPosition:se,legend:ge?r(ke,{items:Ae(y),position:se,marker:"dot",size:P,onToggle:J?K:void 0}):void 0,table:$?r(De,{data:ie,series:ae,xKey:a.key,xLabel:a.label??a.key,formatX:A,formatValue:R,caption:typeof N=="string"?N:void 0}):void 0,className:G,...M,children:({width:t})=>r(Ye,{locale:x,width:t,height:oe,data:n.map(h=>h.datum),rows:n,resolvedSeries:y,x:a,y:g,grid:Z,size:P,showValues:I,dotSize:U,referenceLines:B,margin:ee,tooltip:_,plotLabel:o,formatValue:R,formatX:A,onRowClick:V})})}export{gt as DumbbellChart,dt as resetDumbbellWarnings};
@@ -1 +1 @@
1
- "use strict";"use client";var H=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var ve=(c,l)=>{for(var f in l)H(c,f,{get:l[f],enumerable:!0})},ke=(c,l,f,h)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of xe(l))!be.call(c,m)&&m!==f&&H(c,m,{get:()=>l[m],enumerable:!(h=ye(l,m))||h.enumerable});return c};var Fe=c=>ke(H({},"__esModule",{value:!0}),c);var Ee={};ve(Ee,{FileSelector:()=>Le});module.exports=Fe(Ee);var a=require("react"),g=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},te=c=>{if(c===0)return"0 B";let l=["B","KB","MB","GB"],f=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,f)).toFixed(f===0?0:1)} ${l[f]}`},j=c=>c.webkitRelativePath||c.name,Se=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(c){let l=[],f=async h=>{if(h.isFile){let m=await new Promise((x,r)=>h.file(x,r));l.push(m)}else if(h.isDirectory){let m=h.createReader(),x=()=>new Promise((L,A)=>m.readEntries(L,A)),r=await x();for(;r.length>0;){for(let L of r)await f(L);r=await x()}}};for(let h of c)await f(h);return l}function Le({value:c,onChange:l,accept:f,multiple:h=!1,maxSize:m=10*1024*1024,maxFiles:x,mode:r="file",variant:L="dropzone",size:A="md",disabled:o=!1,readOnly:s=!1,label:U,helperText:z,error:F,showFileList:V=!0,placeholder:G,browseLabel:B,browseFolderLabel:K,labels:re,icon:oe,onReject:_,className:se}){let i=(0,v.useUILabels)(re),[ie,P]=(0,a.useState)([]),[Z,R]=(0,a.useState)(!1),k=(0,a.useRef)(null),M=(0,a.useRef)(null),S=(0,a.useId)(),w=c!==void 0,N=w?c.map((e,u)=>({file:e,id:`ctrl-${u}`})):ie,d=we[A],D=h||r!=="file";(0,a.useEffect)(()=>{r==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let T=(0,a.useMemo)(()=>te(m),[m]),W=(0,a.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):i.fileSelectorAllFiles,[f,i.fileSelectorAllFiles]),q=r==="directory"?i.fileSelectorDropFolder:r==="both"?i.fileSelectorDropFilesOrFolders:h?i.fileSelectorDropFiles:i.fileSelectorDropFile,ne=r==="directory"?i.fileSelectorBrowseFolder:i.fileSelectorBrowse,le=i.fileSelectorBrowseFolder,J=(0,v.formatUILabel)(i.fileSelectorTooLarge,{maxSize:T}),Q=(0,v.formatUILabel)(i.fileSelectorTypeNotAccepted,{accept:W}),X=(0,a.useCallback)(e=>{if(e.size>m)return J;if(f){let u=f.split(",").map(n=>n.trim()),p=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!u.some(n=>n.startsWith(".")?p===n.toLowerCase():n.endsWith("/*")?e.type.startsWith(n.replace("/*","/")):e.type===n))return Q}return null},[f,m,J,Q]),E=(0,a.useCallback)(e=>{if(o||s)return;let u=Array.from(e),p=[];for(let y of u){let n=X(y);n?_?.(y,n):p.push(y)}if(p.length!==0)if(w)if(D){let n=[...c??[],...p],b=x?n.slice(0,x):n;l?.(b)}else l?.([p[0]]);else P(y=>{let n=p.map(b=>({file:b,id:`file-${++De}`}));if(D){let b=[...y,...n],ee=x?b.slice(0,x):b,me=ee.map(he=>he.file);return l?.(me),ee}return l?.([p[0]]),[n[0]]})},[o,s,w,D,x,c,l,_,X]),ae=(0,a.useCallback)(e=>{if(!(o||s)){if(w){let u=(c??[]).filter((p,y)=>y!==e);l?.(u)}else P(u=>{let p=u.filter((y,n)=>n!==e);return l?.(p.map(y=>y.file)),p});k.current&&(k.current.value="")}},[o,s,w,c,l]),ce=(0,a.useCallback)(()=>{o||s||(w?l?.([]):(P([]),l?.([])),k.current&&(k.current.value=""))},[o,s,w,l]),Y=(0,a.useCallback)(e=>{e.target.files&&e.target.files.length>0&&E(e.target.files)},[E]),fe=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&R(!0)},[o,s]),ue=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!1)},[]),pe=(0,a.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),R(!1),o||s)return;let u=e.dataTransfer.items;if(u&&u.length>0&&(r==="directory"||r==="both")){let p=[];for(let n=0;n<u.length;n++){let b=u[n].webkitGetAsEntry?.();b&&p.push(b)}if(p.some(n=>n.isDirectory)){Ce(p).then(n=>{n.length>0&&E(n)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)},[o,s,r,E]),I=(0,a.useCallback)(()=>{!o&&!s&&k.current?.click()},[o,s]),O=(0,a.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),C=N.length>0,ge=oe||(r==="directory"?Ne:Se),de=V&&C&&(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap),children:[N.map((e,u)=>(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",d.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",te(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ae(u),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,v.formatUILabel)(i.fileSelectorRemove,{name:j(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:ce,className:(0,g.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",d.subtext),children:i.fileSelectorRemoveAll})]}),$=(0,g.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",d.button,F&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap,se),children:[U&&(0,t.jsx)("label",{htmlFor:S,className:(0,g.cn)("block font-medium text-gray-700 dark:text-gray-300",d.text),children:U}),(0,t.jsx)("input",{ref:k,id:S,type:"file",accept:r!=="directory"?f:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:o||s,"aria-describedby":F?`${S}-error`:z?`${S}-helper`:void 0,"aria-invalid":!!F}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:Y,className:"sr-only",disabled:o||s,tabIndex:-1,"aria-hidden":"true"}),L==="dropzone"?(0,t.jsxs)("div",{role:r==="both"?"group":"button",tabIndex:r==="both"?void 0:o||s?-1:0,onClick:r==="both"?void 0:I,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),I())},onDragOver:fe,onDragLeave:ue,onDrop:pe,className:(0,g.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d.dropzone,Z&&!o&&!s?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!o&&!s&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",r!=="both"&&!o&&!s&&"cursor-pointer",o&&"opacity-50 cursor-not-allowed",s&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?i.fileSelectorDropZone:G||q,children:[(0,t.jsx)("div",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mb-2",d.icon,Z&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ge}),(0,t.jsxs)("p",{className:(0,g.cn)("text-gray-600 dark:text-gray-400",d.text),children:[G||q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:B||ne})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center gap-3 mt-1",d.text),children:[(0,t.jsx)("button",{type:"button",onClick:I,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:B||i.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:O,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:K||le})]}),(0,t.jsx)("p",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mt-1",d.subtext),children:D&&x?(0,v.formatUILabel)(i.fileSelectorConstraintsMaxFiles,{accept:W,maxSize:T,maxFiles:x}):(0,v.formatUILabel)(i.fileSelectorConstraints,{accept:W,maxSize:T})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(C?i.fileSelectorChangeFiles:i.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:O,disabled:o||s,className:$,children:K||i.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(r==="directory"?C?i.fileSelectorChangeFolder:i.fileSelectorChooseFolder:C?i.fileSelectorChangeFile:i.fileSelectorChooseFile)}),!C&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.text),children:r==="directory"?i.fileSelectorNoFolder:r==="both"?i.fileSelectorNoFileOrFolder:i.fileSelectorNoFile}),C&&!V&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-600 dark:text-gray-400 truncate",d.text),children:N.length===1?j(N[0].file):(0,v.formatUILabel)(i.fileSelectorFilesSelected,{count:N.length})})]}),de,F&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,g.cn)("text-red-600 dark:text-red-400",d.subtext),role:"alert",children:F}),z&&!F&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.subtext),children:z})]})}0&&(module.exports={FileSelector});
1
+ "use strict";"use client";var K=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var Se=(n,a)=>{for(var f in a)K(n,f,{get:a[f],enumerable:!0})},Ne=(n,a,f,b)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of Fe(a))!we.call(n,h)&&h!==f&&K(n,h,{get:()=>a[h],enumerable:!(b=ve(a,h))||b.enumerable});return n};var Ie=n=>Ne(K({},"__esModule",{value:!0}),n);var Ae={};Se(Ae,{DIRECTORY_ENTRY_LIMIT:()=>se,FileSelector:()=>Me,readDirectoryEntries:()=>le});module.exports=Ie(Ae);var l=require("react"),p=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),ie=require("../../lib/accept.cjs"),t=require("react/jsx-runtime"),De={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},ne=n=>{if(n===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(n)/Math.log(1024));return`${(n/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},U=n=>n.webkitRelativePath||n.name,Y=n=>`${U(n)}\0${n.size}\0${n.lastModified}`,Ce=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ee=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Le=0,se=1e4;async function le(n,{keep:a=()=>!0,wanted:f=1/0}={}){let b=[],h=0,y=0,s=()=>h>=f||y>=se,R=async F=>{if(!s()){if(y++,F.isFile){let r=await new Promise((o,w)=>F.file(o,w));b.push(r),a(r)&&h++}else if(F.isDirectory){let r=F.createReader(),o=()=>new Promise((I,k)=>r.readEntries(I,k)),w=await o();for(;w.length>0&&!s();){for(let I of w)await R(I);s()||(w=await o())}}}};for(let F of n)await R(F);return b}function Me({value:n,onChange:a,accept:f,multiple:b=!1,maxSize:h=10*1024*1024,maxFiles:y,mode:s="file",variant:R="dropzone",size:F="md",disabled:r=!1,readOnly:o=!1,label:w,helperText:I,error:k,showFileList:Z=!0,placeholder:q,browseLabel:T,browseFolderLabel:J,labels:ae,icon:ce,onReject:W,className:fe}){let i=(0,v.useUILabels)(ae),[Q,ue]=(0,l.useState)([]),A=(0,l.useRef)(Q),[X,j]=(0,l.useState)(!1),S=(0,l.useRef)(null),$=(0,l.useRef)(null),C=(0,l.useId)(),x=n!==void 0,E=x?n.map((e,g)=>({file:e,id:`ctrl-${g}`})):Q,d=De[F],D=(0,l.useCallback)(e=>{A.current=e,ue(e),a?.(e.map(g=>g.file))},[a]),N=b||s!=="file";(0,l.useEffect)(()=>{s==="directory"&&S.current&&S.current.setAttribute("webkitdirectory",""),s==="both"&&$.current&&$.current.setAttribute("webkitdirectory","")},[s]);let _=(0,l.useMemo)(()=>ne(h),[h]),V=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):i.fileSelectorAllFiles,[f,i.fileSelectorAllFiles]),O=s==="directory"?i.fileSelectorDropFolder:s==="both"?i.fileSelectorDropFilesOrFolders:b?i.fileSelectorDropFiles:i.fileSelectorDropFile,pe=s==="directory"?i.fileSelectorBrowseFolder:i.fileSelectorBrowse,de=i.fileSelectorBrowseFolder,ee=(0,v.formatUILabel)(i.fileSelectorTooLarge,{maxSize:_}),te=(0,v.formatUILabel)(i.fileSelectorTypeNotAccepted,{accept:V}),H=(0,l.useCallback)(e=>e.size>h?ee:(0,ie.matchesAccept)(e,f)?null:te,[f,h,ee,te]),B=(0,l.useCallback)(e=>{if(r||o)return;let g=Array.from(e),m=[],P=new Set(N?(x?n??[]:A.current.map(c=>c.file)).map(Y):[]);for(let c of g){let u=H(c);u?W?.(c,u):P.has(Y(c))?W?.(c,i.fileSelectorAlreadyAdded):(N&&P.add(Y(c)),m.push(c))}if(m.length!==0)if(x)if(N){let u=[...n??[],...m],M=y?u.slice(0,y):u;a?.(M)}else a?.([m[0]]);else{let c=m.map(u=>({file:u,id:`file-${++Le}`}));if(N){let u=[...A.current,...c];D(y?u.slice(0,y):u)}else D([c[0]])}},[r,o,x,N,y,n,a,W,H,D,i.fileSelectorAlreadyAdded]),ge=(0,l.useCallback)(e=>{if(!(r||o)){if(x){let g=(n??[]).filter((m,P)=>P!==e);a?.(g)}else D(A.current.filter((g,m)=>m!==e));S.current&&(S.current.value="")}},[r,o,x,n,a,D]),he=(0,l.useCallback)(()=>{r||o||(x?a?.([]):D([]),S.current&&(S.current.value=""))},[r,o,x,a,D]),re=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&B(e.target.files)},[B]),ye=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&j(!0)},[r,o]),me=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),xe=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),j(!1),r||o)return;let g=e.dataTransfer.items;if(g&&g.length>0&&(s==="directory"||s==="both")){let m=[];for(let c=0;c<g.length;c++){let u=g[c].webkitGetAsEntry?.();u&&m.push(u)}if(m.some(c=>c.isDirectory)){let c=x?(n??[]).length:A.current.length,u=y?Math.max(0,y-c):1/0;if(u===0)return;le(m,{keep:M=>H(M)===null,wanted:u}).then(M=>{M.length>0&&B(M)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&B(e.dataTransfer.files)},[r,o,s,B,x,n,y,H]),z=(0,l.useCallback)(()=>{!r&&!o&&S.current?.click()},[r,o]),oe=(0,l.useCallback)(()=>{!r&&!o&&$.current?.click()},[r,o]),L=E.length>0,be=ce||(s==="directory"?Ee:Ce),ke=Z&&L&&(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",d.gap),children:[E.map((e,g)=>(0,t.jsxs)("div",{className:(0,p.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",d.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:U(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",ne(e.file.size),")"]})]}),!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:()=>ge(g),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,v.formatUILabel)(i.fileSelectorRemove,{name:U(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),N&&E.length>1&&!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:he,className:(0,p.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",d.subtext),children:i.fileSelectorRemoveAll})]}),G=(0,p.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",d.button,k&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",d.gap,fe),children:[w&&(0,t.jsx)("label",{htmlFor:C,className:(0,p.cn)("block font-medium text-gray-700 dark:text-gray-300",d.text),children:w}),(0,t.jsx)("input",{ref:S,id:C,type:"file",accept:s!=="directory"?f:void 0,multiple:N,onChange:re,className:"sr-only",tabIndex:-1,disabled:r||o,"aria-describedby":k?`${C}-error`:I?`${C}-helper`:void 0,"aria-invalid":!!k}),s==="both"&&(0,t.jsx)("input",{ref:$,type:"file",onChange:re,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),R==="dropzone"?(0,t.jsxs)("div",{role:s==="both"?"group":"button",tabIndex:s==="both"?void 0:r||o?-1:0,onClick:s==="both"?void 0:z,onKeyDown:s==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),z())},onDragOver:ye,onDragLeave:me,onDrop:xe,className:(0,p.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d.dropzone,X&&!r&&!o?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!r&&!o&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",s!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",k&&"border-red-300 dark:border-red-600"),"aria-label":s==="both"?i.fileSelectorDropZone:q||O,children:[(0,t.jsx)("div",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mb-2",d.icon,X&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:be}),(0,t.jsxs)("p",{className:(0,p.cn)("text-gray-600 dark:text-gray-400",d.text),children:[q||O," ",!r&&!o&&s!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:T||pe})]}),s==="both"&&!r&&!o&&(0,t.jsxs)("div",{className:(0,p.cn)("flex items-center gap-3 mt-1",d.text),children:[(0,t.jsx)("button",{type:"button",onClick:z,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:T||i.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:oe,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:J||de})]}),(0,t.jsx)("p",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mt-1",d.subtext),children:N&&y?(0,v.formatUILabel)(i.fileSelectorConstraintsMaxFiles,{accept:V,maxSize:_,maxFiles:y}):(0,v.formatUILabel)(i.fileSelectorConstraints,{accept:V,maxSize:_})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[s==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:z,disabled:r||o,className:G,children:T||(L?i.fileSelectorChangeFiles:i.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:oe,disabled:r||o,className:G,children:J||i.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:z,disabled:r||o,className:G,children:T||(s==="directory"?L?i.fileSelectorChangeFolder:i.fileSelectorChooseFolder:L?i.fileSelectorChangeFile:i.fileSelectorChooseFile)}),!L&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-500 dark:text-gray-400",d.text),children:s==="directory"?i.fileSelectorNoFolder:s==="both"?i.fileSelectorNoFileOrFolder:i.fileSelectorNoFile}),L&&!Z&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-600 dark:text-gray-400 truncate",d.text),children:E.length===1?U(E[0].file):(0,v.formatUILabel)(i.fileSelectorFilesSelected,{count:E.length})})]}),ke,k&&(0,t.jsx)("p",{id:`${C}-error`,className:(0,p.cn)("text-red-600 dark:text-red-400",d.subtext),role:"alert",children:k}),I&&!k&&(0,t.jsx)("p",{id:`${C}-helper`,className:(0,p.cn)("text-gray-500 dark:text-gray-400",d.subtext),children:I})]})}0&&(module.exports={DIRECTORY_ENTRY_LIMIT,FileSelector,readDirectoryEntries});