@synertech/ui 0.51.0 → 0.53.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 (193) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +304 -153
  2. package/README.md +27 -19
  3. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  4. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  5. package/dist/components/area-chart/AreaChart.cjs +1 -1
  6. package/dist/components/area-chart/AreaChart.js +1 -1
  7. package/dist/components/avatar/Avatar.cjs +1 -1
  8. package/dist/components/avatar/Avatar.js +1 -1
  9. package/dist/components/avatar/AvatarImage.cjs +1 -0
  10. package/dist/components/avatar/AvatarImage.js +1 -0
  11. package/dist/components/banner/Banner.cjs +1 -1
  12. package/dist/components/banner/Banner.js +1 -1
  13. package/dist/components/bar-chart/BarChart.cjs +1 -1
  14. package/dist/components/bar-chart/BarChart.js +1 -1
  15. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  16. package/dist/components/box-plot/BoxPlot.js +1 -1
  17. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  18. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  19. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  20. package/dist/components/bullet-chart/BulletChart.js +1 -1
  21. package/dist/components/calendar/Calendar.cjs +1 -1
  22. package/dist/components/calendar/Calendar.js +1 -1
  23. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  24. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  25. package/dist/components/card/Card.cjs +1 -1
  26. package/dist/components/card/Card.js +1 -1
  27. package/dist/components/chart/ChartAnnotations.cjs +1 -1
  28. package/dist/components/chart/ChartAnnotations.js +1 -1
  29. package/dist/components/chart/ChartBrush.cjs +1 -1
  30. package/dist/components/chart/ChartBrush.js +1 -1
  31. package/dist/components/chart/ChartContainer.cjs +1 -1
  32. package/dist/components/chart/ChartContainer.js +1 -1
  33. package/dist/components/chart/ChartExportButton.cjs +1 -1
  34. package/dist/components/chart/ChartExportButton.js +1 -1
  35. package/dist/components/chart/ChartPatterns.cjs +1 -1
  36. package/dist/components/chart/ChartPatterns.js +1 -1
  37. package/dist/components/chart/ChartPlotClip.cjs +1 -0
  38. package/dist/components/chart/ChartPlotClip.js +1 -0
  39. package/dist/components/chart/ChartSync.cjs +1 -1
  40. package/dist/components/chart/ChartSync.js +1 -1
  41. package/dist/components/chart/ChartTableView.cjs +1 -1
  42. package/dist/components/chart/ChartTableView.js +1 -1
  43. package/dist/components/chart/exportSource.cjs +1 -0
  44. package/dist/components/chart/exportSource.js +1 -0
  45. package/dist/components/chart/palette.cjs +1 -1
  46. package/dist/components/chart/palette.js +1 -1
  47. package/dist/components/chart/useChartSize.cjs +1 -1
  48. package/dist/components/chart/useChartSize.js +1 -1
  49. package/dist/components/chart/utils/bins.cjs +1 -1
  50. package/dist/components/chart/utils/bins.js +1 -1
  51. package/dist/components/chart/utils/cartesian.cjs +1 -1
  52. package/dist/components/chart/utils/cartesian.js +1 -1
  53. package/dist/components/chart/utils/export.cjs +7 -1
  54. package/dist/components/chart/utils/export.js +7 -1
  55. package/dist/components/chart/utils/format.cjs +1 -1
  56. package/dist/components/chart/utils/format.js +1 -1
  57. package/dist/components/chart/utils/keyboard.cjs +1 -1
  58. package/dist/components/chart/utils/keyboard.js +1 -1
  59. package/dist/components/chart/utils/period.cjs +1 -1
  60. package/dist/components/chart/utils/period.js +1 -1
  61. package/dist/components/chart/utils/regression.cjs +1 -0
  62. package/dist/components/chart/utils/regression.js +1 -0
  63. package/dist/components/chart/utils/stack.cjs +1 -1
  64. package/dist/components/chart/utils/stack.js +1 -1
  65. package/dist/components/chart/utils/ticks.cjs +1 -1
  66. package/dist/components/chart/utils/ticks.js +1 -1
  67. package/dist/components/checkbox/Checkbox.cjs +1 -1
  68. package/dist/components/checkbox/Checkbox.js +1 -1
  69. package/dist/components/checkbox/CheckboxGroup.cjs +1 -1
  70. package/dist/components/checkbox/CheckboxGroup.js +1 -1
  71. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  72. package/dist/components/circular-progress/CircularProgress.js +1 -1
  73. package/dist/components/datagrid/DataGrid.cjs +1 -1
  74. package/dist/components/datagrid/DataGrid.js +1 -1
  75. package/dist/components/date-picker/DatePicker.cjs +1 -0
  76. package/dist/components/date-picker/DatePicker.js +1 -0
  77. package/dist/components/date-picker/DateRangePicker.cjs +1 -0
  78. package/dist/components/date-picker/DateRangePicker.js +1 -0
  79. package/dist/components/date-picker/date-field.cjs +1 -0
  80. package/dist/components/date-picker/date-field.js +1 -0
  81. package/dist/components/date-picker/date-input.cjs +1 -0
  82. package/dist/components/date-picker/date-input.js +1 -0
  83. package/dist/components/date-picker/index.cjs +1 -0
  84. package/dist/components/date-picker/index.js +1 -0
  85. package/dist/components/detachable/Detachable.cjs +1 -1
  86. package/dist/components/detachable/Detachable.js +1 -1
  87. package/dist/components/detachable/popup-window.cjs +1 -0
  88. package/dist/components/detachable/popup-window.js +1 -0
  89. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  90. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  91. package/dist/components/divider/Divider.cjs +1 -1
  92. package/dist/components/divider/Divider.js +1 -1
  93. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  94. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  95. package/dist/components/file-selector/FileSelector.cjs +1 -1
  96. package/dist/components/file-selector/FileSelector.js +1 -1
  97. package/dist/components/footer/FooterBottom.cjs +1 -1
  98. package/dist/components/footer/FooterBottom.js +1 -1
  99. package/dist/components/form/form-field/FormField.cjs +1 -0
  100. package/dist/components/form/form-field/FormField.js +1 -0
  101. package/dist/components/form/form-field/index.cjs +1 -0
  102. package/dist/components/form/form-field/index.js +1 -0
  103. package/dist/components/form/index.cjs +1 -1
  104. package/dist/components/form/index.js +1 -1
  105. package/dist/components/form/input/Input.cjs +1 -1
  106. package/dist/components/form/input/Input.js +1 -1
  107. package/dist/components/form/mention-input/MentionInput.cjs +5 -4
  108. package/dist/components/form/mention-input/MentionInput.js +5 -4
  109. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  110. package/dist/components/form/number-input/NumberInput.js +1 -1
  111. package/dist/components/form/shared/InputWrapper.cjs +1 -1
  112. package/dist/components/form/shared/InputWrapper.js +1 -1
  113. package/dist/components/form/shared/field-error.cjs +1 -0
  114. package/dist/components/form/shared/field-error.js +1 -0
  115. package/dist/components/form/shared/inputStyles.cjs +1 -1
  116. package/dist/components/form/shared/inputStyles.js +1 -1
  117. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  118. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  119. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  120. package/dist/components/gantt-chart/GanttChart.js +1 -1
  121. package/dist/components/header/Header.cjs +1 -1
  122. package/dist/components/header/Header.js +1 -1
  123. package/dist/components/heat-map/Heatmap.cjs +1 -1
  124. package/dist/components/heat-map/Heatmap.js +1 -1
  125. package/dist/components/help-button/HelpButton.cjs +4 -12
  126. package/dist/components/help-button/HelpButton.js +4 -12
  127. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  128. package/dist/components/help-button/MarkdownEditor.js +1 -1
  129. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  130. package/dist/components/image-uploader/ImageUploader.js +1 -1
  131. package/dist/components/index.cjs +1 -1
  132. package/dist/components/index.js +1 -1
  133. package/dist/components/line-chart/LineChart.cjs +1 -1
  134. package/dist/components/line-chart/LineChart.js +1 -1
  135. package/dist/components/pagination/Pagination.cjs +1 -1
  136. package/dist/components/pagination/Pagination.js +1 -1
  137. package/dist/components/pie-chart/PieChart.cjs +1 -1
  138. package/dist/components/pie-chart/PieChart.js +1 -1
  139. package/dist/components/popover/Popover.cjs +1 -0
  140. package/dist/components/popover/Popover.js +1 -0
  141. package/dist/components/popover/PopoverClose.cjs +1 -0
  142. package/dist/components/popover/PopoverClose.js +1 -0
  143. package/dist/components/popover/PopoverContent.cjs +1 -0
  144. package/dist/components/popover/PopoverContent.js +1 -0
  145. package/dist/components/popover/PopoverTrigger.cjs +1 -0
  146. package/dist/components/popover/PopoverTrigger.js +1 -0
  147. package/dist/components/popover/index.cjs +1 -0
  148. package/dist/components/popover/index.js +1 -0
  149. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  150. package/dist/components/progress-bar/ProgressBar.js +1 -1
  151. package/dist/components/radio-button/RadioButton.cjs +1 -1
  152. package/dist/components/radio-button/RadioButton.js +1 -1
  153. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  154. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  155. package/dist/components/scatter-chart/index.cjs +1 -1
  156. package/dist/components/scatter-chart/index.js +1 -1
  157. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  158. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  159. package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
  160. package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
  161. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  162. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  163. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  164. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  165. package/dist/components/schema-editor/utils/sql-export.cjs +4 -4
  166. package/dist/components/schema-editor/utils/sql-export.js +7 -7
  167. package/dist/components/select/Select.cjs +1 -1
  168. package/dist/components/select/Select.js +1 -1
  169. package/dist/components/slider/Slider.cjs +1 -1
  170. package/dist/components/slider/Slider.js +1 -1
  171. package/dist/components/sparkline/Sparkline.cjs +1 -1
  172. package/dist/components/sparkline/Sparkline.js +1 -1
  173. package/dist/components/table/TableRow.cjs +1 -1
  174. package/dist/components/table/TableRow.js +1 -1
  175. package/dist/components/tooltip/Tooltip.cjs +1 -1
  176. package/dist/components/tooltip/Tooltip.js +1 -1
  177. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  178. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  179. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  180. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  181. package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
  182. package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
  183. package/dist/index.d.cts +2961 -2272
  184. package/dist/index.d.ts +2961 -2272
  185. package/dist/lib/accept.cjs +1 -0
  186. package/dist/lib/accept.js +1 -0
  187. package/dist/lib/css-value.cjs +1 -0
  188. package/dist/lib/css-value.js +1 -0
  189. package/dist/lib/ui-labels.cjs +1 -1
  190. package/dist/lib/ui-labels.js +1 -1
  191. package/dist/styles-no-preflight.css +10419 -0
  192. package/dist/styles.css +463 -41
  193. package/package.json +9 -4
@@ -1 +1 @@
1
- "use strict";"use client";var R=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var I=(t,a)=>{for(var r in a)R(t,r,{get:a[r],enumerable:!0})},V=(t,a,r,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of P(a))!L.call(t,d)&&d!==r&&R(t,d,{get:()=>a[d],enumerable:!(i=A(a,d))||i.enumerable});return t};var X=t=>V(R({},"__esModule",{value:!0}),t);var ee={};I(ee,{DeviceMockup:()=>$});module.exports=X(ee);var p=require("react"),o=require("../../lib/cn.cjs"),B=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),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:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-3 h-3",t),viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),(0,e.jsx)("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),(0,e.jsx)("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),(0,e.jsx)("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),E=({className:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-3 h-3",t),viewBox:"0 0 20 20",fill:"currentColor",children:[(0,e.jsx)("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),(0,e.jsx)("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"}),(0,e.jsx)("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"})]}),O=({className:t})=>(0,e.jsxs)("svg",{className:(0,o.cn)("w-4 h-3",t),viewBox:"0 0 24 14",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),(0,e.jsx)("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),(0,e.jsx)("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function f({time:t="9:41",theme:a,device:r}){let i=r==="watch",d=a==="dark"?"text-white":"text-gray-900";return i?(0,e.jsx)("div",{className:(0,o.cn)("flex items-center justify-center py-0.5",d),style:{fontSize:"8px"},children:(0,e.jsx)("span",{className:"font-medium",children:t})}):(0,e.jsxs)("div",{className:(0,o.cn)("flex items-center justify-between px-4 py-1",a==="dark"?"bg-black/20":"bg-white/20",d),style:{fontSize:"10px"},"data-testid":"status-bar",children:[(0,e.jsx)("span",{className:"font-semibold",children:t}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(q,{className:d}),(0,e.jsx)(E,{className:d}),(0,e.jsx)(O,{className:d})]})]})}function U({theme:t}){let a=t==="dark";return(0,e.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 px-3 py-2 border-b",a?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),(0,e.jsx)("div",{className:(0,o.cn)("flex-1 rounded-md px-3 py-1 text-center",a?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:(0,e.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("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 Y({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l,landscape:n=!1}){let h=a==="dark",c=l??(h?"#1a1a1a":"#e5e7eb");if(n){let m=Math.round(i*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:i+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:(0,o.cn)("rounded-full mr-2",h?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(i*.35)},"data-testid":"home-indicator"}),(0,e.jsxs)("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:"absolute rounded-full bg-black z-10",style:{width:20,height:m,right:10,top:"50%",transform:"translateY(-50%)"},"data-testid":"phone-notch"})]})}let w=Math.round(r*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("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"}),(0,e.jsxs)("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-full mt-2",h?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function G({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[(0,e.jsx)("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"}),(0,e.jsxs)("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"android"}),t]})]})}function J({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[(0,e.jsx)("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsxs)("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"tablet"}),t]})]})}function K({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){let s=a==="dark",l=d??(s?"#1a1a1a":"#d1d5db"),n=r+60;return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[(0,e.jsxs)("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:l,padding:"8px 8px 0",width:r+16},children:[(0,e.jsx)("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsx)("div",{className:"rounded-t-sm overflow-hidden bg-black",style:{width:r,height:i},children:t})]}),(0,e.jsx)("div",{className:(0,o.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),(0,e.jsx)("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:l,width:n,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function Q({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){let s=a==="dark";return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[(0,e.jsx)("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:d??(s?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:(0,e.jsx)("div",{className:"rounded-sm overflow-hidden bg-black",style:{width:r,height:i},children:t})}),(0,e.jsx)("div",{className:(0,o.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-t-sm",s?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function Z({children:t,theme:a,screenW:r,screenH:i,showStatusBar:d,statusBarTime:s,frameColor:l}){let n=a==="dark",h=l??(n?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[(0,e.jsx)("div",{className:(0,o.cn)("rounded-t-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),(0,e.jsxs)("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:h,padding:"8px 6px",width:r+12},children:[(0,e.jsx)("div",{className:(0,o.cn)("absolute rounded-sm",n?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),(0,e.jsxs)("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:r,height:i},children:[d&&(0,e.jsx)(f,{time:s,theme:a,device:"watch"}),t]})]}),(0,e.jsx)("div",{className:(0,o.cn)("rounded-b-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function _({children:t,theme:a,screenW:r,screenH:i,frameColor:d}){return(0,e.jsxs)("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:d??(a==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[(0,e.jsx)(U,{theme:a}),(0,e.jsx)("div",{className:"overflow-hidden bg-white",style:{width:r,height:i},children:t})]})}function $({device:t="phone",src:a,alt:r,children:i,orientation:d="portrait",theme:s="dark",size:l="md",showStatusBar:n=!1,statusBarTime:h,animated:c=!1,scrollSpeed:w=30,frameColor:m,className:F,contentClassName:H}){let M=(0,B.useUILabels)(),D=(0,p.useRef)(null),x=(0,p.useRef)(null),y=j[t][l],C=d==="landscape"&&t!=="watch"&&t!=="browser",g=C?y.h:y.w,u=C?y.w:y.h;(0,p.useEffect)(()=>{if(!c||!D.current)return;let b=D.current,k=null,z=T=>{k===null&&(k=T);let W=(T-k)/1e3;k=T,b.scrollTop+=w*W,b.scrollTop>=b.scrollHeight-b.clientHeight&&(b.scrollTop=0),x.current=requestAnimationFrame(z)};return x.current=requestAnimationFrame(z),()=>{x.current!==null&&cancelAnimationFrame(x.current)}},[c,w]);let v=(0,e.jsx)("div",{ref:c?D:void 0,className:(0,o.cn)("w-full h-full overflow-hidden",c&&"overflow-y-auto scrollbar-hide",H),style:c?{scrollBehavior:"auto"}:void 0,children:a?(0,e.jsx)("img",{src:a,alt:r??M.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):i}),N={showStatusBar:n,statusBarTime:h},S=()=>{switch(t){case"phone":return(0,e.jsx)(Y,{theme:s,screenW:g,screenH:u,frameColor:m,landscape:C,...N,children:v});case"android":return(0,e.jsx)(G,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"tablet":return(0,e.jsx)(J,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"laptop":return(0,e.jsx)(K,{theme:s,screenW:g,screenH:u,frameColor:m,children:v});case"desktop":return(0,e.jsx)(Q,{theme:s,screenW:g,screenH:u,frameColor:m,children:v});case"watch":return(0,e.jsx)(Z,{theme:s,screenW:g,screenH:u,frameColor:m,...N,children:v});case"browser":return(0,e.jsx)(_,{theme:s,screenW:g,screenH:u,frameColor:m,children:v})}};return(0,e.jsx)("div",{className:(0,o.cn)("inline-flex",F),"data-testid":"device-mockup","data-orientation":d,"data-theme":s,"data-size":l,children:S()})}0&&(module.exports={DeviceMockup});
1
+ "use strict";"use client";var T=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var U=(t,a)=>{for(var r in a)T(t,r,{get:a[r],enumerable:!0})},Q=(t,a,r,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of j(a))!q.call(t,o)&&o!==r&&T(t,o,{get:()=>a[o],enumerable:!(d=X(a,o))||d.enumerable});return t};var Y=t=>Q(T({},"__esModule",{value:!0}),t);var le={};U(le,{DeviceMockup:()=>ie});module.exports=Y(le);var p=require("react"),i=require("../../lib/cn.cjs"),W=require("../../lib/css-value.cjs"),L=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),_={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}}},G=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-3 h-3",t),viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"1",y:"11",width:"2.5",height:"4",rx:"0.5"}),(0,e.jsx)("rect",{x:"5",y:"8",width:"2.5",height:"7",rx:"0.5"}),(0,e.jsx)("rect",{x:"9",y:"5",width:"2.5",height:"10",rx:"0.5"}),(0,e.jsx)("rect",{x:"13",y:"1",width:"2.5",height:"14",rx:"0.5"})]}),J=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-3 h-3",t),viewBox:"0 0 20 20",fill:"currentColor",children:[(0,e.jsx)("path",{d:"M10 14.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"}),(0,e.jsx)("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"}),(0,e.jsx)("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"})]}),K=({className:t})=>(0,e.jsxs)("svg",{className:(0,i.cn)("w-4 h-3",t),viewBox:"0 0 24 14",fill:"currentColor",children:[(0,e.jsx)("rect",{x:"0.5",y:"0.5",width:"20",height:"13",rx:"2",stroke:"currentColor",fill:"none",strokeWidth:"1"}),(0,e.jsx)("rect",{x:"22",y:"4",width:"2",height:"6",rx:"0.5"}),(0,e.jsx)("rect",{x:"2.5",y:"2.5",width:"14",height:"9",rx:"1"})]});function x({time:t="9:41",theme:a,device:r}){let d=r==="watch",o=a==="dark"?"text-white":"text-gray-900";return d?(0,e.jsx)("div",{className:(0,i.cn)("flex shrink-0 items-center justify-center py-0.5",o),style:{fontSize:"8px"},children:(0,e.jsx)("span",{className:"font-medium",children:t})}):(0,e.jsxs)("div",{className:(0,i.cn)("flex shrink-0 items-center justify-between px-4 py-1",a==="dark"?"bg-black/20":"bg-white/20",o),style:{fontSize:"10px"},"data-testid":"status-bar",children:[(0,e.jsx)("span",{className:"font-semibold",children:t}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(G,{className:o}),(0,e.jsx)(J,{className:o}),(0,e.jsx)(K,{className:o})]})]})}function Z({theme:t}){let a=t==="dark";return(0,e.jsxs)("div",{className:(0,i.cn)("flex items-center gap-2 px-3 py-2 border-b",a?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),"data-testid":"browser-chrome",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-red-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-yellow-400"}),(0,e.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-green-400"})]}),(0,e.jsx)("div",{className:(0,i.cn)("flex-1 rounded-md px-3 py-1 text-center",a?"bg-gray-700 text-gray-300":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:(0,e.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,e.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,e.jsx)("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:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l,landscape:n=!1}){let h=a==="dark",c=l??(h?"#1a1a1a":"#e5e7eb");if(n){let k=Math.round(d*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-row items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"8px 12px",height:d+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("div",{className:(0,i.cn)("rounded-full mr-2",h?"bg-gray-600":"bg-gray-400"),style:{width:4,height:Math.round(d*.35)},"data-testid":"home-indicator"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("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(r*.35);return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2.5rem] shadow-xl",style:{backgroundColor:c,padding:"12px 8px",width:r+16},"data-testid":"device-frame","data-device":"phone",children:[(0,e.jsx)("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"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"phone"}),t]}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-full mt-2",h?"bg-gray-600":"bg-gray-400"),style:{width:Math.round(r*.35),height:4},"data-testid":"home-indicator"})]})}function ee({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[2rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"10px 6px",width:r+12},"data-testid":"device-frame","data-device":"android",children:[(0,e.jsx)("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"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"android"}),t]})]})}function te({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){return(0,e.jsxs)("div",{className:"relative inline-flex flex-col items-center rounded-[1.5rem] shadow-xl",style:{backgroundColor:l??(a==="dark"?"#1a1a1a":"#e5e7eb"),padding:"16px 12px",width:r+24},"data-testid":"device-frame","data-device":"tablet",children:[(0,e.jsx)("div",{className:"absolute top-[8px] rounded-full bg-gray-700 z-10",style:{width:6,height:6,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsxs)("div",{className:"flex flex-col rounded-lg overflow-hidden bg-black relative",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"tablet"}),t]})]})}function ae({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){let s=a==="dark",l=o??(s?"#1a1a1a":"#d1d5db"),n=r+60;return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[(0,e.jsxs)("div",{className:"rounded-t-xl shadow-xl relative",style:{backgroundColor:l,padding:"8px 8px 0",width:r+16},children:[(0,e.jsx)("div",{className:"absolute top-[3px] rounded-full bg-gray-700 z-10",style:{width:4,height:4,left:"50%",transform:"translateX(-50%)"}}),(0,e.jsx)("div",{className:"flex flex-col rounded-t-sm overflow-hidden bg-black",style:{width:r,height:d},children:t})]}),(0,e.jsx)("div",{className:(0,i.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:r+16,height:3}}),(0,e.jsx)("div",{className:"rounded-b-xl shadow-lg",style:{backgroundColor:l,width:n,height:12,clipPath:"polygon(3% 0%, 97% 0%, 100% 100%, 0% 100%)"},"data-testid":"laptop-base"})]})}function re({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){let s=a==="dark";return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"desktop",children:[(0,e.jsx)("div",{className:"rounded-lg shadow-xl",style:{backgroundColor:o??(s?"#1a1a1a":"#d1d5db"),padding:"8px 8px 20px",width:r+16},children:(0,e.jsx)("div",{className:"flex flex-col rounded-sm overflow-hidden bg-black",style:{width:r,height:d},children:t})}),(0,e.jsx)("div",{className:(0,i.cn)(s?"bg-gray-800":"bg-gray-400"),style:{width:40,height:24},"data-testid":"monitor-stand"}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-t-sm",s?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function oe({children:t,theme:a,screenW:r,screenH:d,showStatusBar:o,statusBarTime:s,frameColor:l}){let n=a==="dark",h=l??(n?"#1a1a1a":"#d1d5db"),c=Math.round(r*.7);return(0,e.jsxs)("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"watch",children:[(0,e.jsx)("div",{className:(0,i.cn)("rounded-t-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30},"data-testid":"watch-band"}),(0,e.jsxs)("div",{className:"relative rounded-[1.2rem] shadow-xl",style:{backgroundColor:h,padding:"8px 6px",width:r+12},children:[(0,e.jsx)("div",{className:(0,i.cn)("absolute rounded-sm",n?"bg-gray-600":"bg-gray-400"),style:{width:4,height:16,right:-4,top:"30%"},"data-testid":"watch-crown"}),(0,e.jsxs)("div",{className:"flex flex-col rounded-xl overflow-hidden bg-black",style:{width:r,height:d},children:[o&&(0,e.jsx)(x,{time:s,theme:a,device:"watch"}),t]})]}),(0,e.jsx)("div",{className:(0,i.cn)("rounded-b-lg",n?"bg-gray-800":"bg-gray-400"),style:{width:c,height:30}})]})}function de({children:t,theme:a,screenW:r,screenH:d,frameColor:o}){return(0,e.jsxs)("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:o??(a==="dark"?"#1f2937":"#f3f4f6"),width:r},"data-testid":"device-frame","data-device":"browser",children:[(0,e.jsx)(Z,{theme:a}),(0,e.jsx)("div",{className:"flex flex-col overflow-hidden bg-white",style:{width:r,height:d},children:t})]})}var H="(prefers-reduced-motion: reduce)",S=()=>typeof window<"u"&&typeof window.matchMedia=="function";function se(){let[t,a]=(0,p.useState)(()=>S()&&window.matchMedia(H).matches);return(0,p.useEffect)(()=>{if(!S())return;let r=window.matchMedia(H);a(r.matches);let d=o=>a(o.matches);return r.addEventListener?.("change",d),()=>r.removeEventListener?.("change",d)},[]),t}function ie({device:t="phone",src:a,alt:r,children:d,orientation:o="portrait",theme:s="dark",size:l="md",showStatusBar:n=!1,statusBarTime:h,animated:c=!1,scrollSpeed:w=30,frameColor:k,className:A,contentClassName:E}){let P=(0,L.useUILabels)(),g=(0,W.safeCssColor)(k),[m,I]=(0,p.useState)(null),M=se(),y=_[t][l],C=o==="landscape"&&(t==="phone"||t==="android"||t==="tablet"),u=C?y.h:y.w,v=C?y.w:y.h;(0,p.useEffect)(()=>{if(!c||M||!m)return;let b=m.scrollTop,D=null,R=requestAnimationFrame(function V(z){let B=D===null?0:Math.min(z-D,250)/1e3;D=z,Math.abs(m.scrollTop-b)>1&&(b=m.scrollTop);let F=m.scrollHeight-m.clientHeight;b=F>0&&b+w*B<F?b+w*B:0,m.scrollTop=b,R=requestAnimationFrame(V)});return()=>cancelAnimationFrame(R)},[c,M,m,w]);let f=(0,e.jsx)("div",{ref:c?I:void 0,className:(0,i.cn)("w-full flex-1 min-h-0 overflow-hidden",c&&"overflow-y-auto scrollbar-hide",E),style:c?{scrollBehavior:"auto"}:void 0,children:a?(0,e.jsx)("img",{src:a,alt:r??P.deviceMockupAlt,className:"w-full h-auto object-cover",draggable:!1}):d}),N={showStatusBar:n,statusBarTime:h},O=()=>{switch(t){case"phone":return(0,e.jsx)($,{theme:s,screenW:u,screenH:v,frameColor:g,landscape:C,...N,children:f});case"android":return(0,e.jsx)(ee,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"tablet":return(0,e.jsx)(te,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"laptop":return(0,e.jsx)(ae,{theme:s,screenW:u,screenH:v,frameColor:g,children:f});case"desktop":return(0,e.jsx)(re,{theme:s,screenW:u,screenH:v,frameColor:g,children:f});case"watch":return(0,e.jsx)(oe,{theme:s,screenW:u,screenH:v,frameColor:g,...N,children:f});case"browser":return(0,e.jsx)(de,{theme:s,screenW:u,screenH:v,frameColor:g,children:f})}};return(0,e.jsx)("div",{className:(0,i.cn)("inline-flex",A),"data-testid":"device-mockup","data-orientation":o,"data-theme":s,"data-size":l,children:O()})}0&&(module.exports={DeviceMockup});
@@ -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 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 j=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var be=(c,a)=>{for(var f in a)j(c,f,{get:a[f],enumerable:!0})},ve=(c,a,f,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of ye(a))!xe.call(c,d)&&d!==f&&j(c,d,{get:()=>a[d],enumerable:!(m=me(a,d))||m.enumerable});return c};var ke=c=>ve(j({},"__esModule",{value:!0}),c);var Le={};be(Le,{FileSelector:()=>De});module.exports=ke(Le);var l=require("react"),p=require("../../lib/cn.cjs"),b=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),Fe={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"}},re=c=>{if(c===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},U=c=>c.webkitRelativePath||c.name,we=(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"})}),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.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"})}),Ne=0;async function Ce(c){let a=[],f=async m=>{if(m.isFile){let d=await new Promise((y,r)=>m.file(y,r));a.push(d)}else if(m.isDirectory){let d=m.createReader(),y=()=>new Promise((L,z)=>d.readEntries(L,z)),r=await y();for(;r.length>0;){for(let L of r)await f(L);r=await y()}}};for(let m of c)await f(m);return a}function De({value:c,onChange:a,accept:f,multiple:m=!1,maxSize:d=10*1024*1024,maxFiles:y,mode:r="file",variant:L="dropzone",size:z="md",disabled:o=!1,readOnly:s=!1,label:V,helperText:P,error:k,showFileList:G=!0,placeholder:K,browseLabel:B,browseFolderLabel:_,labels:oe,icon:se,onReject:Z,className:ne}){let n=(0,b.useUILabels)(oe),[q,ie]=(0,l.useState)([]),R=(0,l.useRef)(q),[J,T]=(0,l.useState)(!1),v=(0,l.useRef)(null),M=(0,l.useRef)(null),S=(0,l.useId)(),F=c!==void 0,N=F?c.map((e,u)=>({file:e,id:`ctrl-${u}`})):q,g=Fe[z],w=(0,l.useCallback)(e=>{R.current=e,ie(e),a?.(e.map(u=>u.file))},[a]),C=m||r!=="file";(0,l.useEffect)(()=>{r==="directory"&&v.current&&v.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let W=(0,l.useMemo)(()=>re(d),[d]),$=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):n.fileSelectorAllFiles,[f,n.fileSelectorAllFiles]),Q=r==="directory"?n.fileSelectorDropFolder:r==="both"?n.fileSelectorDropFilesOrFolders:m?n.fileSelectorDropFiles:n.fileSelectorDropFile,le=r==="directory"?n.fileSelectorBrowseFolder:n.fileSelectorBrowse,ae=n.fileSelectorBrowseFolder,X=(0,b.formatUILabel)(n.fileSelectorTooLarge,{maxSize:W}),Y=(0,b.formatUILabel)(n.fileSelectorTypeNotAccepted,{accept:$}),O=(0,l.useCallback)(e=>{if(e.size>d)return X;if(f){let u=f.split(",").map(i=>i.trim()),h=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!u.some(i=>i.startsWith(".")?h===i.toLowerCase():i.endsWith("/*")?e.type.startsWith(i.replace("/*","/")):e.type===i))return Y}return null},[f,d,X,Y]),I=(0,l.useCallback)(e=>{if(o||s)return;let u=Array.from(e),h=[];for(let x of u){let i=O(x);i?Z?.(x,i):h.push(x)}if(h.length!==0)if(F)if(C){let i=[...c??[],...h],A=y?i.slice(0,y):i;a?.(A)}else a?.([h[0]]);else{let x=h.map(i=>({file:i,id:`file-${++Ne}`}));if(C){let i=[...R.current,...x];w(y?i.slice(0,y):i)}else w([x[0]])}},[o,s,F,C,y,c,a,Z,O,w]),ce=(0,l.useCallback)(e=>{if(!(o||s)){if(F){let u=(c??[]).filter((h,x)=>x!==e);a?.(u)}else w(R.current.filter((u,h)=>h!==e));v.current&&(v.current.value="")}},[o,s,F,c,a,w]),fe=(0,l.useCallback)(()=>{o||s||(F?a?.([]):w([]),v.current&&(v.current.value=""))},[o,s,F,a,w]),ee=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&I(e.target.files)},[I]),ue=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&T(!0)},[o,s]),pe=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),T(!1)},[]),ge=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),T(!1),o||s)return;let u=e.dataTransfer.items;if(u&&u.length>0&&(r==="directory"||r==="both")){let h=[];for(let i=0;i<u.length;i++){let A=u[i].webkitGetAsEntry?.();A&&h.push(A)}if(h.some(i=>i.isDirectory)){Ce(h).then(i=>{i.length>0&&I(i)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&I(e.dataTransfer.files)},[o,s,r,I]),E=(0,l.useCallback)(()=>{!o&&!s&&v.current?.click()},[o,s]),te=(0,l.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),D=N.length>0,de=se||(r==="directory"?Se:we),he=G&&D&&(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",g.gap),children:[N.map((e,u)=>(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",g.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:["(",re(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ce(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,b.formatUILabel)(n.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)),C&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:fe,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",g.subtext),children:n.fileSelectorRemoveAll})]}),H=(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",g.button,k&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",g.gap,ne),children:[V&&(0,t.jsx)("label",{htmlFor:S,className:(0,p.cn)("block font-medium text-gray-700 dark:text-gray-300",g.text),children:V}),(0,t.jsx)("input",{ref:v,id:S,type:"file",accept:r!=="directory"?f:void 0,multiple:C,onChange:ee,className:"sr-only",disabled:o||s,"aria-describedby":k?`${S}-error`:P?`${S}-helper`:void 0,"aria-invalid":!!k}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:ee,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:E,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E())},onDragOver:ue,onDragLeave:pe,onDrop:ge,className:(0,p.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",g.dropzone,J&&!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",k&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?n.fileSelectorDropZone:K||Q,children:[(0,t.jsx)("div",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mb-2",g.icon,J&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:de}),(0,t.jsxs)("p",{className:(0,p.cn)("text-gray-600 dark:text-gray-400",g.text),children:[K||Q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:B||le})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,p.cn)("flex items-center gap-3 mt-1",g.text),children:[(0,t.jsx)("button",{type:"button",onClick:E,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||n.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:te,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:_||ae})]}),(0,t.jsx)("p",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mt-1",g.subtext),children:C&&y?(0,b.formatUILabel)(n.fileSelectorConstraintsMaxFiles,{accept:$,maxSize:W,maxFiles:y}):(0,b.formatUILabel)(n.fileSelectorConstraints,{accept:$,maxSize:W})})]}):(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:E,disabled:o||s,className:H,children:B||(D?n.fileSelectorChangeFiles:n.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:te,disabled:o||s,className:H,children:_||n.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:E,disabled:o||s,className:H,children:B||(r==="directory"?D?n.fileSelectorChangeFolder:n.fileSelectorChooseFolder:D?n.fileSelectorChangeFile:n.fileSelectorChooseFile)}),!D&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-500 dark:text-gray-400",g.text),children:r==="directory"?n.fileSelectorNoFolder:r==="both"?n.fileSelectorNoFileOrFolder:n.fileSelectorNoFile}),D&&!G&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-600 dark:text-gray-400 truncate",g.text),children:N.length===1?U(N[0].file):(0,b.formatUILabel)(n.fileSelectorFilesSelected,{count:N.length})})]}),he,k&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,p.cn)("text-red-600 dark:text-red-400",g.subtext),role:"alert",children:k}),P&&!k&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,p.cn)("text-gray-500 dark:text-gray-400",g.subtext),children:P})]})}0&&(module.exports={FileSelector});
1
+ "use strict";"use client";var Y=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ie=(i,a)=>{for(var f in a)Y(i,f,{get:a[f],enumerable:!0})},De=(i,a,f,v)=>{if(a&&typeof a=="object"||typeof a=="function")for(let y of Se(a))!Ne.call(i,y)&&y!==f&&Y(i,y,{get:()=>a[y],enumerable:!(v=we(a,y))||v.enumerable});return i};var Ce=i=>De(Y({},"__esModule",{value:!0}),i);var ze={};Ie(ze,{DIRECTORY_ENTRY_LIMIT:()=>ae,FileSelector:()=>Ae,readDirectoryEntries:()=>ce});module.exports=Ce(ze);var l=require("react"),u=require("../../lib/cn.cjs"),k=require("../../lib/i18n.cjs"),ne=require("../../lib/accept.cjs"),le=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),Ee={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"}},se=i=>{if(i===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(i)/Math.log(1024));return`${(i/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},$=i=>i.webkitRelativePath||i.name,Z=i=>`${$(i)}\0${i.size}\0${i.lastModified}`,Le=(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"})}),Be=(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"})}),Me=0,ae=1e4;async function ce(i,{keep:a=()=>!0,wanted:f=1/0}={}){let v=[],y=0,m=0,n=()=>y>=f||m>=ae,T=async F=>{if(!n()){if(m++,F.isFile){let r=await new Promise((o,w)=>F.file(o,w));v.push(r),a(r)&&y++}else if(F.isDirectory){let r=F.createReader(),o=()=>new Promise((D,U)=>r.readEntries(D,U)),w=await o();for(;w.length>0&&!n();){for(let D of w)await T(D);n()||(w=await o())}}}};for(let F of i)await T(F);return v}function Ae({value:i,onChange:a,accept:f,multiple:v=!1,maxSize:y=10*1024*1024,maxFiles:m,mode:n="file",variant:T="dropzone",size:F="md",disabled:r=!1,readOnly:o=!1,label:w,helperText:D,error:U,showFileList:q=!0,placeholder:J,browseLabel:P,browseFolderLabel:Q,labels:fe,icon:de,onReject:W,className:ue}){let s=(0,k.useUILabels)(fe),[X,pe]=(0,l.useState)([]),B=(0,l.useRef)(X),[O,j]=(0,l.useState)(!1),S=(0,l.useRef)(null),R=(0,l.useRef)(null),_=(0,l.useId)(),h=(0,le.describeField)(_,{helperText:D,error:U}),x=i!==void 0,C=x?i.map((e,g)=>({file:e,id:`ctrl-${g}`})):X,p=Ee[F],I=(0,l.useCallback)(e=>{B.current=e,pe(e),a?.(e.map(g=>g.file))},[a]),N=v||n!=="file";(0,l.useEffect)(()=>{n==="directory"&&S.current&&S.current.setAttribute("webkitdirectory",""),n==="both"&&R.current&&R.current.setAttribute("webkitdirectory","")},[n]);let V=(0,l.useMemo)(()=>se(y),[y]),G=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[f,s.fileSelectorAllFiles]),ee=n==="directory"?s.fileSelectorDropFolder:n==="both"?s.fileSelectorDropFilesOrFolders:v?s.fileSelectorDropFiles:s.fileSelectorDropFile,ge=n==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,he=s.fileSelectorBrowseFolder,te=(0,k.formatUILabel)(s.fileSelectorTooLarge,{maxSize:V}),re=(0,k.formatUILabel)(s.fileSelectorTypeNotAccepted,{accept:G}),H=(0,l.useCallback)(e=>e.size>y?te:(0,ne.matchesAccept)(e,f)?null:re,[f,y,te,re]),M=(0,l.useCallback)(e=>{if(r||o)return;let g=Array.from(e),b=[],z=new Set(N?(x?i??[]:B.current.map(c=>c.file)).map(Z):[]);for(let c of g){let d=H(c);d?W?.(c,d):z.has(Z(c))?W?.(c,s.fileSelectorAlreadyAdded):(N&&z.add(Z(c)),b.push(c))}if(b.length!==0)if(x)if(N){let d=[...i??[],...b],L=m?d.slice(0,m):d;a?.(L)}else a?.([b[0]]);else{let c=b.map(d=>({file:d,id:`file-${++Me}`}));if(N){let d=[...B.current,...c];I(m?d.slice(0,m):d)}else I([c[0]])}},[r,o,x,N,m,i,a,W,H,I,s.fileSelectorAlreadyAdded]),ye=(0,l.useCallback)(e=>{if(!(r||o)){if(x){let g=(i??[]).filter((b,z)=>z!==e);a?.(g)}else I(B.current.filter((g,b)=>b!==e));S.current&&(S.current.value="")}},[r,o,x,i,a,I]),me=(0,l.useCallback)(()=>{r||o||(x?a?.([]):I([]),S.current&&(S.current.value=""))},[r,o,x,a,I]),oe=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&M(e.target.files)},[M]),be=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&j(!0)},[r,o]),xe=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),ve=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),j(!1),r||o)return;let g=e.dataTransfer.items;if(g&&g.length>0&&(n==="directory"||n==="both")){let b=[];for(let c=0;c<g.length;c++){let d=g[c].webkitGetAsEntry?.();d&&b.push(d)}if(b.some(c=>c.isDirectory)){let c=x?(i??[]).length:B.current.length,d=m?Math.max(0,m-c):1/0;if(d===0)return;ce(b,{keep:L=>H(L)===null,wanted:d}).then(L=>{L.length>0&&M(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&M(e.dataTransfer.files)},[r,o,n,M,x,i,m,H]),A=(0,l.useCallback)(()=>{!r&&!o&&S.current?.click()},[r,o]),ie=(0,l.useCallback)(()=>{!r&&!o&&R.current?.click()},[r,o]),E=C.length>0,ke=de||(n==="directory"?Be:Le),Fe=q&&E&&(0,t.jsxs)("div",{className:(0,u.cn)("flex flex-col",p.gap),children:[C.map((e,g)=>(0,t.jsxs)("div",{className:(0,u.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",p.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:$(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",se(e.file.size),")"]})]}),!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:()=>ye(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,k.formatUILabel)(s.fileSelectorRemove,{name:$(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&&C.length>1&&!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:me,className:(0,u.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",p.subtext),children:s.fileSelectorRemoveAll})]}),K=(0,u.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",p.button,h.invalid&&"border-red-500 dark:border-red-500");return(0,t.jsxs)("div",{className:(0,u.cn)("flex flex-col",p.gap,ue),children:[w&&(0,t.jsx)("label",{htmlFor:_,className:(0,u.cn)("block font-medium text-gray-700 dark:text-gray-300",p.text),children:w}),(0,t.jsx)("input",{ref:S,id:_,type:"file",accept:n!=="directory"?f:void 0,multiple:N,onChange:oe,className:"sr-only",tabIndex:-1,disabled:r||o,"aria-describedby":h.describedBy,"aria-invalid":h.invalid||void 0}),n==="both"&&(0,t.jsx)("input",{ref:R,type:"file",onChange:oe,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),T==="dropzone"?(0,t.jsxs)("div",{role:n==="both"?"group":"button",tabIndex:n==="both"?void 0:r||o?-1:0,onClick:n==="both"?void 0:A,onKeyDown:n==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),A())},onDragOver:be,onDragLeave:xe,onDrop:ve,className:(0,u.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",p.dropzone,O&&!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",n!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",h.invalid&&"border-red-500 dark:border-red-500"),"aria-label":n==="both"?s.fileSelectorDropZone:J||ee,"aria-describedby":h.describedBy,children:[(0,t.jsx)("div",{className:(0,u.cn)("text-gray-500 dark:text-gray-400 mb-2",p.icon,O&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ke}),(0,t.jsxs)("p",{className:(0,u.cn)("text-gray-600 dark:text-gray-400",p.text),children:[J||ee," ",!r&&!o&&n!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:P||ge})]}),n==="both"&&!r&&!o&&(0,t.jsxs)("div",{className:(0,u.cn)("flex items-center gap-3 mt-1",p.text),children:[(0,t.jsx)("button",{type:"button",onClick:A,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:P||s.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:ie,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:Q||he})]}),(0,t.jsx)("p",{className:(0,u.cn)("text-gray-500 dark:text-gray-400 mt-1",p.subtext),children:N&&m?(0,k.formatUILabel)(s.fileSelectorConstraintsMaxFiles,{accept:G,maxSize:V,maxFiles:m}):(0,k.formatUILabel)(s.fileSelectorConstraints,{accept:G,maxSize:V})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(E?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:ie,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:Q||s.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(n==="directory"?E?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:E?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!E&&(0,t.jsx)("span",{className:(0,u.cn)("text-gray-500 dark:text-gray-400",p.text),children:n==="directory"?s.fileSelectorNoFolder:n==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),E&&!q&&(0,t.jsx)("span",{className:(0,u.cn)("text-gray-600 dark:text-gray-400 truncate",p.text),children:C.length===1?$(C[0].file):(0,k.formatUILabel)(s.fileSelectorFilesSelected,{count:C.length})})]}),Fe,h.message!==void 0&&(0,t.jsx)("p",{id:h.ids.error,className:(0,u.cn)("text-red-600 dark:text-red-400",p.subtext),children:h.message}),h.showHelper&&(0,t.jsx)("p",{id:h.ids.helper,className:(0,u.cn)(h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",p.subtext),children:D})]})}0&&(module.exports={DIRECTORY_ENTRY_LIMIT,FileSelector,readDirectoryEntries});
@@ -1 +1 @@
1
- "use client";import{useState as oe,useRef as U,useCallback as m,useEffect as be,useMemo as se,useId as ve}from"react";import{cn as f}from"../../lib/cn.js";import{formatUILabel as L,useUILabels as ke}from"../../lib/i18n.js";import{Fragment as De,jsx as i,jsxs as x}from"react/jsx-runtime";var Fe={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=a=>{if(a===0)return"0 B";let u=["B","KB","MB","GB"],p=Math.floor(Math.log(a)/Math.log(1024));return`${(a/Math.pow(1024,p)).toFixed(p===0?0:1)} ${u[p]}`},V=a=>a.webkitRelativePath||a.name,we=i("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:i("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"})}),Se=i("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:i("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"})}),Ne=0;async function Ce(a){let u=[],p=async y=>{if(y.isFile){let b=await new Promise((d,t)=>y.file(d,t));u.push(b)}else if(y.isDirectory){let b=y.createReader(),d=()=>new Promise((I,P)=>b.readEntries(I,P)),t=await d();for(;t.length>0;){for(let I of t)await p(I);t=await d()}}};for(let y of a)await p(y);return u}function Be({value:a,onChange:u,accept:p,multiple:y=!1,maxSize:b=10*1024*1024,maxFiles:d,mode:t="file",variant:I="dropzone",size:P="md",disabled:r=!1,readOnly:o=!1,label:G,helperText:R,error:k,showFileList:K=!0,placeholder:_,browseLabel:M,browseFolderLabel:Z,labels:ie,icon:le,onReject:q,className:ae}){let s=ke(ie),[J,ce]=oe([]),T=U(J),[Q,W]=oe(!1),v=U(null),A=U(null),S=ve(),F=a!==void 0,N=F?a.map((e,l)=>({file:e,id:`ctrl-${l}`})):J,c=Fe[P],w=m(e=>{T.current=e,ce(e),u?.(e.map(l=>l.file))},[u]),C=y||t!=="file";be(()=>{t==="directory"&&v.current&&v.current.setAttribute("webkitdirectory",""),t==="both"&&A.current&&A.current.setAttribute("webkitdirectory","")},[t]);let $=se(()=>ne(b),[b]),H=se(()=>p?p.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[p,s.fileSelectorAllFiles]),X=t==="directory"?s.fileSelectorDropFolder:t==="both"?s.fileSelectorDropFilesOrFolders:y?s.fileSelectorDropFiles:s.fileSelectorDropFile,fe=t==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,ue=s.fileSelectorBrowseFolder,Y=L(s.fileSelectorTooLarge,{maxSize:$}),O=L(s.fileSelectorTypeNotAccepted,{accept:H}),ee=m(e=>{if(e.size>b)return Y;if(p){let l=p.split(",").map(n=>n.trim()),g=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!l.some(n=>n.startsWith(".")?g===n.toLowerCase():n.endsWith("/*")?e.type.startsWith(n.replace("/*","/")):e.type===n))return O}return null},[p,b,Y,O]),E=m(e=>{if(r||o)return;let l=Array.from(e),g=[];for(let h of l){let n=ee(h);n?q?.(h,n):g.push(h)}if(g.length!==0)if(F)if(C){let n=[...a??[],...g],z=d?n.slice(0,d):n;u?.(z)}else u?.([g[0]]);else{let h=g.map(n=>({file:n,id:`file-${++Ne}`}));if(C){let n=[...T.current,...h];w(d?n.slice(0,d):n)}else w([h[0]])}},[r,o,F,C,d,a,u,q,ee,w]),pe=m(e=>{if(!(r||o)){if(F){let l=(a??[]).filter((g,h)=>h!==e);u?.(l)}else w(T.current.filter((l,g)=>g!==e));v.current&&(v.current.value="")}},[r,o,F,a,u,w]),ge=m(()=>{r||o||(F?u?.([]):w([]),v.current&&(v.current.value=""))},[r,o,F,u,w]),te=m(e=>{e.target.files&&e.target.files.length>0&&E(e.target.files)},[E]),de=m(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&W(!0)},[r,o]),he=m(e=>{e.preventDefault(),e.stopPropagation(),W(!1)},[]),me=m(e=>{if(e.preventDefault(),e.stopPropagation(),W(!1),r||o)return;let l=e.dataTransfer.items;if(l&&l.length>0&&(t==="directory"||t==="both")){let g=[];for(let n=0;n<l.length;n++){let z=l[n].webkitGetAsEntry?.();z&&g.push(z)}if(g.some(n=>n.isDirectory)){Ce(g).then(n=>{n.length>0&&E(n)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)},[r,o,t,E]),B=m(()=>{!r&&!o&&v.current?.click()},[r,o]),re=m(()=>{!r&&!o&&A.current?.click()},[r,o]),D=N.length>0,ye=le||(t==="directory"?Se:we),xe=K&&D&&x("div",{className:f("flex flex-col",c.gap),children:[N.map((e,l)=>x("div",{className:f("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",c.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i("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:i("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"})}),i("span",{className:"truncate text-gray-700 dark:text-gray-300",children:V(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",ne(e.file.size),")"]})]}),!r&&!o&&i("button",{type:"button",onClick:()=>pe(l),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":L(s.fileSelectorRemove,{name:V(e.file)}),children:i("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:i("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),C&&N.length>1&&!r&&!o&&i("button",{type:"button",onClick:ge,className:f("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",c.subtext),children:s.fileSelectorRemoveAll})]}),j=f("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",c.button,k&&"border-red-300 dark:border-red-600");return x("div",{className:f("flex flex-col",c.gap,ae),children:[G&&i("label",{htmlFor:S,className:f("block font-medium text-gray-700 dark:text-gray-300",c.text),children:G}),i("input",{ref:v,id:S,type:"file",accept:t!=="directory"?p:void 0,multiple:C,onChange:te,className:"sr-only",disabled:r||o,"aria-describedby":k?`${S}-error`:R?`${S}-helper`:void 0,"aria-invalid":!!k}),t==="both"&&i("input",{ref:A,type:"file",onChange:te,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),I==="dropzone"?x("div",{role:t==="both"?"group":"button",tabIndex:t==="both"?void 0:r||o?-1:0,onClick:t==="both"?void 0:B,onKeyDown:t==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),B())},onDragOver:de,onDragLeave:he,onDrop:me,className:f("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c.dropzone,Q&&!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",t!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",k&&"border-red-300 dark:border-red-600"),"aria-label":t==="both"?s.fileSelectorDropZone:_||X,children:[i("div",{className:f("text-gray-500 dark:text-gray-400 mb-2",c.icon,Q&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ye}),x("p",{className:f("text-gray-600 dark:text-gray-400",c.text),children:[_||X," ",!r&&!o&&t!=="both"&&i("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:M||fe})]}),t==="both"&&!r&&!o&&x("div",{className:f("flex items-center gap-3 mt-1",c.text),children:[i("button",{type:"button",onClick:B,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:M||s.fileSelectorBrowseFiles}),i("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),i("button",{type:"button",onClick:re,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:Z||ue})]}),i("p",{className:f("text-gray-500 dark:text-gray-400 mt-1",c.subtext),children:C&&d?L(s.fileSelectorConstraintsMaxFiles,{accept:H,maxSize:$,maxFiles:d}):L(s.fileSelectorConstraints,{accept:H,maxSize:$})})]}):x("div",{className:"flex items-center gap-2",children:[t==="both"?x(De,{children:[i("button",{type:"button",onClick:B,disabled:r||o,className:j,children:M||(D?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),i("button",{type:"button",onClick:re,disabled:r||o,className:j,children:Z||s.fileSelectorChooseFolder})]}):i("button",{type:"button",onClick:B,disabled:r||o,className:j,children:M||(t==="directory"?D?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:D?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!D&&i("span",{className:f("text-gray-500 dark:text-gray-400",c.text),children:t==="directory"?s.fileSelectorNoFolder:t==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),D&&!K&&i("span",{className:f("text-gray-600 dark:text-gray-400 truncate",c.text),children:N.length===1?V(N[0].file):L(s.fileSelectorFilesSelected,{count:N.length})})]}),xe,k&&i("p",{id:`${S}-error`,className:f("text-red-600 dark:text-red-400",c.subtext),role:"alert",children:k}),R&&!k&&i("p",{id:`${S}-helper`,className:f("text-gray-500 dark:text-gray-400",c.subtext),children:R})]})}export{Be as FileSelector};
1
+ "use client";import{useState as ne,useRef as Z,useCallback as m,useEffect as Fe,useMemo as le,useId as we}from"react";import{cn as d}from"../../lib/cn.js";import{formatUILabel as B,useUILabels as Se}from"../../lib/i18n.js";import{matchesAccept as Ne}from"../../lib/accept.js";import{describeField as Ie}from"../form/shared/field-error.js";import{Fragment as Ae,jsx as s,jsxs as x}from"react/jsx-runtime";var 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"}},ae=n=>{if(n===0)return"0 B";let p=["B","KB","MB","GB"],h=Math.floor(Math.log(n)/Math.log(1024));return`${(n/Math.pow(1024,h)).toFixed(h===0?0:1)} ${p[h]}`},U=n=>n.webkitRelativePath||n.name,q=n=>`${U(n)}\0${n.size}\0${n.lastModified}`,Ce=s("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:s("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=s("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:s("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,Be=1e4;async function Me(n,{keep:p=()=>!0,wanted:h=1/0}={}){let I=[],S=0,g=0,i=()=>S>=h||g>=Be,P=async v=>{if(!i()){if(g++,v.isFile){let t=await new Promise((r,k)=>v.file(r,k));I.push(t),p(t)&&S++}else if(v.isDirectory){let t=v.createReader(),r=()=>new Promise((D,W)=>t.readEntries(D,W)),k=await r();for(;k.length>0&&!i();){for(let D of k)await P(D);i()||(k=await r())}}}};for(let v of n)await P(v);return I}function $e({value:n,onChange:p,accept:h,multiple:I=!1,maxSize:S=10*1024*1024,maxFiles:g,mode:i="file",variant:P="dropzone",size:v="md",disabled:t=!1,readOnly:r=!1,label:k,helperText:D,error:W,showFileList:J=!0,placeholder:Q,browseLabel:R,browseFolderLabel:X,labels:ce,icon:fe,onReject:j,className:de}){let o=Se(ce),[O,ue]=ne([]),M=Z(O),[ee,_]=ne(!1),F=Z(null),H=Z(null),V=we(),u=Ie(V,{helperText:D,error:W}),b=n!==void 0,C=b?n.map((e,f)=>({file:e,id:`ctrl-${f}`})):O,c=De[v],N=m(e=>{M.current=e,ue(e),p?.(e.map(f=>f.file))},[p]),w=I||i!=="file";Fe(()=>{i==="directory"&&F.current&&F.current.setAttribute("webkitdirectory",""),i==="both"&&H.current&&H.current.setAttribute("webkitdirectory","")},[i]);let G=le(()=>ae(S),[S]),K=le(()=>h?h.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):o.fileSelectorAllFiles,[h,o.fileSelectorAllFiles]),te=i==="directory"?o.fileSelectorDropFolder:i==="both"?o.fileSelectorDropFilesOrFolders:I?o.fileSelectorDropFiles:o.fileSelectorDropFile,pe=i==="directory"?o.fileSelectorBrowseFolder:o.fileSelectorBrowse,ge=o.fileSelectorBrowseFolder,re=B(o.fileSelectorTooLarge,{maxSize:G}),oe=B(o.fileSelectorTypeNotAccepted,{accept:K}),$=m(e=>e.size>S?re:Ne(e,h)?null:oe,[h,S,re,oe]),A=m(e=>{if(t||r)return;let f=Array.from(e),y=[],T=new Set(w?(b?n??[]:M.current.map(l=>l.file)).map(q):[]);for(let l of f){let a=$(l);a?j?.(l,a):T.has(q(l))?j?.(l,o.fileSelectorAlreadyAdded):(w&&T.add(q(l)),y.push(l))}if(y.length!==0)if(b)if(w){let a=[...n??[],...y],L=g?a.slice(0,g):a;p?.(L)}else p?.([y[0]]);else{let l=y.map(a=>({file:a,id:`file-${++Le}`}));if(w){let a=[...M.current,...l];N(g?a.slice(0,g):a)}else N([l[0]])}},[t,r,b,w,g,n,p,j,$,N,o.fileSelectorAlreadyAdded]),he=m(e=>{if(!(t||r)){if(b){let f=(n??[]).filter((y,T)=>T!==e);p?.(f)}else N(M.current.filter((f,y)=>y!==e));F.current&&(F.current.value="")}},[t,r,b,n,p,N]),ye=m(()=>{t||r||(b?p?.([]):N([]),F.current&&(F.current.value=""))},[t,r,b,p,N]),ie=m(e=>{e.target.files&&e.target.files.length>0&&A(e.target.files)},[A]),me=m(e=>{e.preventDefault(),e.stopPropagation(),!t&&!r&&_(!0)},[t,r]),be=m(e=>{e.preventDefault(),e.stopPropagation(),_(!1)},[]),xe=m(e=>{if(e.preventDefault(),e.stopPropagation(),_(!1),t||r)return;let f=e.dataTransfer.items;if(f&&f.length>0&&(i==="directory"||i==="both")){let y=[];for(let l=0;l<f.length;l++){let a=f[l].webkitGetAsEntry?.();a&&y.push(a)}if(y.some(l=>l.isDirectory)){let l=b?(n??[]).length:M.current.length,a=g?Math.max(0,g-l):1/0;if(a===0)return;Me(y,{keep:L=>$(L)===null,wanted:a}).then(L=>{L.length>0&&A(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&A(e.dataTransfer.files)},[t,r,i,A,b,n,g,$]),z=m(()=>{!t&&!r&&F.current?.click()},[t,r]),se=m(()=>{!t&&!r&&H.current?.click()},[t,r]),E=C.length>0,ve=fe||(i==="directory"?Ee:Ce),ke=J&&E&&x("div",{className:d("flex flex-col",c.gap),children:[C.map((e,f)=>x("div",{className:d("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",c.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s("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:s("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"})}),s("span",{className:"truncate text-gray-700 dark:text-gray-300",children:U(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",ae(e.file.size),")"]})]}),!t&&!r&&s("button",{type:"button",onClick:()=>he(f),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":B(o.fileSelectorRemove,{name:U(e.file)}),children:s("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:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),w&&C.length>1&&!t&&!r&&s("button",{type:"button",onClick:ye,className:d("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",c.subtext),children:o.fileSelectorRemoveAll})]}),Y=d("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",c.button,u.invalid&&"border-red-500 dark:border-red-500");return x("div",{className:d("flex flex-col",c.gap,de),children:[k&&s("label",{htmlFor:V,className:d("block font-medium text-gray-700 dark:text-gray-300",c.text),children:k}),s("input",{ref:F,id:V,type:"file",accept:i!=="directory"?h:void 0,multiple:w,onChange:ie,className:"sr-only",tabIndex:-1,disabled:t||r,"aria-describedby":u.describedBy,"aria-invalid":u.invalid||void 0}),i==="both"&&s("input",{ref:H,type:"file",onChange:ie,className:"sr-only",disabled:t||r,tabIndex:-1,"aria-hidden":"true"}),P==="dropzone"?x("div",{role:i==="both"?"group":"button",tabIndex:i==="both"?void 0:t||r?-1:0,onClick:i==="both"?void 0:z,onKeyDown:i==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),z())},onDragOver:me,onDragLeave:be,onDrop:xe,className:d("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c.dropzone,ee&&!t&&!r?"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",!t&&!r&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",i!=="both"&&!t&&!r&&"cursor-pointer",t&&"opacity-50 cursor-not-allowed",r&&"cursor-default",u.invalid&&"border-red-500 dark:border-red-500"),"aria-label":i==="both"?o.fileSelectorDropZone:Q||te,"aria-describedby":u.describedBy,children:[s("div",{className:d("text-gray-500 dark:text-gray-400 mb-2",c.icon,ee&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ve}),x("p",{className:d("text-gray-600 dark:text-gray-400",c.text),children:[Q||te," ",!t&&!r&&i!=="both"&&s("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:R||pe})]}),i==="both"&&!t&&!r&&x("div",{className:d("flex items-center gap-3 mt-1",c.text),children:[s("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:R||o.fileSelectorBrowseFiles}),s("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),s("button",{type:"button",onClick:se,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:X||ge})]}),s("p",{className:d("text-gray-500 dark:text-gray-400 mt-1",c.subtext),children:w&&g?B(o.fileSelectorConstraintsMaxFiles,{accept:K,maxSize:G,maxFiles:g}):B(o.fileSelectorConstraints,{accept:K,maxSize:G})})]}):x("div",{className:"flex items-center gap-2",children:[i==="both"?x(Ae,{children:[s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(E?o.fileSelectorChangeFiles:o.fileSelectorChooseFiles)}),s("button",{type:"button",onClick:se,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:X||o.fileSelectorChooseFolder})]}):s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(i==="directory"?E?o.fileSelectorChangeFolder:o.fileSelectorChooseFolder:E?o.fileSelectorChangeFile:o.fileSelectorChooseFile)}),!E&&s("span",{className:d("text-gray-500 dark:text-gray-400",c.text),children:i==="directory"?o.fileSelectorNoFolder:i==="both"?o.fileSelectorNoFileOrFolder:o.fileSelectorNoFile}),E&&!J&&s("span",{className:d("text-gray-600 dark:text-gray-400 truncate",c.text),children:C.length===1?U(C[0].file):B(o.fileSelectorFilesSelected,{count:C.length})})]}),ke,u.message!==void 0&&s("p",{id:u.ids.error,className:d("text-red-600 dark:text-red-400",c.subtext),children:u.message}),u.showHelper&&s("p",{id:u.ids.helper,className:d(u.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",c.subtext),children:D})]})}export{Be as DIRECTORY_ENTRY_LIMIT,$e as FileSelector,Me as readDirectoryEntries};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})},l=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of n(t))!c.call(o,r)&&r!==e&&p(o,r,{get:()=>t[r],enumerable:!(a=i(t,r))||a.enumerable});return o};var x=o=>l(p({},"__esModule",{value:!0}),o);var y={};f(y,{FooterBottom:()=>d});module.exports=x(y);var s=require("../../lib/cn.cjs"),m=require("react/jsx-runtime");function d({copyright:o,className:t,children:e,...a}){return(0,m.jsxs)("div",{className:(0,s.cn)("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...a,children:[o&&(0,m.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:o}),e]})}d.displayName="FooterBottom";0&&(module.exports={FooterBottom});
1
+ "use strict";var m=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var e in t)m(o,e,{get:t[e],enumerable:!0})},l=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!c.call(o,r)&&r!==e&&m(o,r,{get:()=>t[r],enumerable:!(a=n(t,r))||a.enumerable});return o};var x=o=>l(m({},"__esModule",{value:!0}),o);var y={};f(y,{FooterBottom:()=>p});module.exports=x(y);var i=require("../../lib/cn.cjs"),d=require("react/jsx-runtime");function p({copyright:o,className:t,children:e,...a}){return(0,d.jsxs)("div",{className:(0,i.cn)("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...a,children:[o?(0,d.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:o}):null,e]})}p.displayName="FooterBottom";0&&(module.exports={FooterBottom});
@@ -1 +1 @@
1
- import{cn as a}from"../../lib/cn.js";import{jsx as p,jsxs as s}from"react/jsx-runtime";function m({copyright:t,className:o,children:e,...r}){return s("div",{className:a("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",o),...r,children:[t&&p("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t}),e]})}m.displayName="FooterBottom";export{m as FooterBottom};
1
+ import{cn as a}from"../../lib/cn.js";import{jsx as m,jsxs as i}from"react/jsx-runtime";function d({copyright:t,className:o,children:e,...r}){return i("div",{className:a("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",o),...r,children:[t?m("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t}):null,e]})}d.displayName="FooterBottom";export{d as FooterBottom};
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(e,r)=>{for(var o in r)l(e,o,{get:r[o],enumerable:!0})},P=(e,r,o,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of y(r))!I.call(e,i)&&i!==o&&l(e,i,{get:()=>r[i],enumerable:!(d=v(r,i))||d.enumerable});return e};var R=e=>P(l({},"__esModule",{value:!0}),e);var q={};N(q,{FormField:()=>x});module.exports=R(q);var c=require("react"),p=require("../shared/field-error.cjs"),f=require("../shared/InputWrapper.cjs"),F=require("react/jsx-runtime");function x({label:e,hideLabel:r=!1,description:o,helperText:d,error:i,required:s=!1,inline:b=!1,id:u,children:m}){let g=(0,c.useId)(),a=u||g,n=(0,p.describeField)(a,{description:o,helperText:d,error:i}),h=e!=null&&e!==""&&typeof e!="boolean",t={id:a};return n.describedBy&&(t["aria-describedby"]=n.describedBy),n.invalid&&(t["aria-invalid"]=!0),s&&(t["aria-required"]=!0),(0,F.jsx)(f.InputWrapper,{label:e,hideLabel:r,description:o,helperText:d,error:i,required:s,inline:b,htmlFor:a,children:m(t,{labelId:h?n.ids.label:void 0,invalid:n.invalid})})}0&&(module.exports={FormField});
@@ -0,0 +1 @@
1
+ import{useId as b}from"react";import{describeField as u}from"../shared/field-error.js";import{InputWrapper as m}from"../shared/InputWrapper.js";import{jsx as g}from"react/jsx-runtime";function I({label:e,hideLabel:l=!1,description:d,helperText:n,error:t,required:a=!1,inline:s=!1,id:c,children:p}){let f=b(),o=c||f,r=u(o,{description:d,helperText:n,error:t}),F=e!=null&&e!==""&&typeof e!="boolean",i={id:o};return r.describedBy&&(i["aria-describedby"]=r.describedBy),r.invalid&&(i["aria-invalid"]=!0),a&&(i["aria-required"]=!0),g(m,{label:e,hideLabel:l,description:d,helperText:n,error:t,required:a,inline:s,htmlFor:o,children:p(i,{labelId:F?r.ids.label:void 0,invalid:r.invalid})})}export{I as FormField};
@@ -0,0 +1 @@
1
+ "use strict";var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(r,o)=>{for(var e in o)m(r,e,{get:o[e],enumerable:!0})},s=(r,o,e,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let F of i(o))!p.call(r,F)&&F!==e&&m(r,F,{get:()=>o[F],enumerable:!(l=d(o,F))||l.enumerable});return r};var x=r=>s(m({},"__esModule",{value:!0}),r);var P={};f(P,{FormField:()=>t.FormField});module.exports=x(P);var t=require("./FormField.cjs");0&&(module.exports={FormField});
@@ -0,0 +1 @@
1
+ import{FormField as F}from"./FormField.js";export{F as FormField};
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var s=(n,t)=>{for(var p in t)e(n,p,{get:t[p],enumerable:!0})},y=(n,t,p,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of x(t))!I.call(n,o)&&o!==p&&e(n,o,{get:()=>t[o],enumerable:!(r=f(t,o))||r.enumerable});return n};var M=n=>y(e({},"__esModule",{value:!0}),n);var a={};s(a,{Input:()=>u.Input,MentionInput:()=>m.MentionInput,NumberInput:()=>i.NumberInput});module.exports=M(a);var u=require("./input/index.cjs"),m=require("./mention-input/index.cjs"),i=require("./number-input/index.cjs");0&&(module.exports={Input,MentionInput,NumberInput});
1
+ "use strict";var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var s=(t,o)=>{for(var r in o)p(t,r,{get:o[r],enumerable:!0})},I=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of F(o))!l.call(t,e)&&e!==r&&p(t,e,{get:()=>o[e],enumerable:!(n=x(o,e))||n.enumerable});return t};var y=t=>I(p({},"__esModule",{value:!0}),t);var d={};s(d,{FormField:()=>m.FormField,Input:()=>i.Input,MentionInput:()=>u.MentionInput,NumberInput:()=>f.NumberInput});module.exports=y(d);var m=require("./form-field/index.cjs"),i=require("./input/index.cjs"),u=require("./mention-input/index.cjs"),f=require("./number-input/index.cjs");0&&(module.exports={FormField,Input,MentionInput,NumberInput});
@@ -1 +1 @@
1
- import{Input as o}from"./input/index.js";import{MentionInput as e}from"./mention-input/index.js";import{NumberInput as u}from"./number-input/index.js";export{o as Input,e as MentionInput,u as NumberInput};
1
+ import{FormField as e}from"./form-field/index.js";import{Input as p}from"./input/index.js";import{MentionInput as m}from"./mention-input/index.js";import{NumberInput as u}from"./number-input/index.js";export{e as FormField,p as Input,m as MentionInput,u as NumberInput};
@@ -1 +1 @@
1
- "use strict";"use client";var T=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var a in e)T(t,a,{get:e[a],enumerable:!0})},j=(t,e,a,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w(e))!D.call(t,n)&&n!==a&&T(t,n,{get:()=>e[n],enumerable:!(p=O(e,n))||p.enumerable});return t};var k=t=>j(T({},"__esModule",{value:!0}),t);var B={};z(B,{Input:()=>A});module.exports=k(B);var l=require("react"),g=require("../../../lib/cn.cjs"),i=require("../shared/inputStyles.cjs"),x=require("../shared/InputWrapper.cjs"),s=require("react/jsx-runtime"),A=(0,l.forwardRef)(({label:t,inline:e=!1,size:a="md",labelColor:p,borderColor:n,textColor:f,disabled:r=!1,readOnly:o=!1,error:d=!1,helperText:y,hideLabel:P=!1,icon:m,iconPosition:E="left",multiline:M=!1,rows:W=3,focused:b=!1,id:S,className:v,...H},u)=>{let L=(0,l.useRef)(null),R=I=>{L.current=I,typeof u=="function"?u(I):u&&(u.current=I)};(0,l.useEffect)(()=>{b&&L.current?.focus()},[b]);let F=(0,l.useId)(),c=S||F,h=(0,g.cn)((0,i.getBaseInputClasses)({size:a,error:d,disabled:r,readOnly:o,icon:m,iconPosition:E}),M&&"resize-y",v),N={...n&&{borderColor:n},...f&&{color:f}},C=n||f?N:void 0;return(0,s.jsx)(x.InputWrapper,{label:t,hideLabel:P,labelColor:p,error:d,helperText:y,inline:e,htmlFor:c,children:(0,s.jsxs)("div",{className:"relative w-full",children:[m&&(0,s.jsx)("span",{className:(0,i.getIconClasses)(E),children:m}),M?(0,s.jsx)("textarea",{ref:R,id:c,disabled:r,readOnly:o,rows:W,tabIndex:o||r?-1:void 0,className:h,style:C,...H}):(0,s.jsx)("input",{ref:R,id:c,disabled:r,readOnly:o,tabIndex:o||r?-1:void 0,className:h,style:C,...H})]})})});A.displayName="Input";0&&(module.exports={Input});
1
+ "use strict";"use client";var C=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var o in e)C(t,o,{get:e[o],enumerable:!0})},K=(t,e,o,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of q(e))!G.call(t,r)&&r!==o&&C(t,r,{get:()=>e[r],enumerable:!(p=k(e,r))||p.enumerable});return t};var Q=t=>K(C({},"__esModule",{value:!0}),t);var U={};J(U,{Input:()=>F});module.exports=Q(U);var n=require("react"),A=require("../../../lib/cn.cjs"),T=require("../../../lib/css-value.cjs"),P=require("../shared/field-error.cjs"),f=require("../shared/inputStyles.cjs"),W=require("../shared/InputWrapper.cjs"),l=require("react/jsx-runtime"),F=(0,n.forwardRef)(({label:t,inline:e=!1,size:o="md",labelColor:p,borderColor:r,textColor:S,disabled:a=!1,readOnly:s=!1,error:E,helperText:M,hideLabel:w=!1,icon:m,iconPosition:H="left",multiline:L=!1,rows:N=3,focused:x=!1,id:O,className:B,"aria-describedby":D,...R},u)=>{let c=(0,T.safeCssColor)(r),b=(0,T.safeCssColor)(S),y=(0,n.useRef)(null),g=I=>{y.current=I,typeof u=="function"?u(I):u&&(u.current=I)};(0,n.useEffect)(()=>{x&&y.current?.focus()},[x]);let z=(0,n.useId)(),d=O||z,i=(0,P.describeField)(d,{helperText:M,error:E,own:D}),h=(0,A.cn)((0,f.getBaseInputClasses)({size:o,error:i.invalid,disabled:a,readOnly:s,icon:m,iconPosition:H}),L&&"resize-y",B),j={...c&&{borderColor:c},...b&&{color:b}},v=c||b?j:void 0;return(0,l.jsx)(W.InputWrapper,{label:t,hideLabel:w,labelColor:p,error:E,helperText:M,inline:e,htmlFor:d,children:(0,l.jsxs)("div",{className:"relative w-full",children:[m&&(0,l.jsx)("span",{className:(0,f.getIconClasses)(H),children:m}),L?(0,l.jsx)("textarea",{ref:g,id:d,disabled:a,readOnly:s,rows:N,tabIndex:s||a?-1:void 0,className:h,style:v,"aria-invalid":i.invalid||void 0,"aria-describedby":i.describedBy,...R}):(0,l.jsx)("input",{ref:g,id:d,disabled:a,readOnly:s,tabIndex:s||a?-1:void 0,className:h,style:v,"aria-invalid":i.invalid||void 0,"aria-describedby":i.describedBy,...R})]})})});F.displayName="Input";0&&(module.exports={Input});
@@ -1 +1 @@
1
- "use client";import{forwardRef as P,useEffect as W,useId as S,useRef as v}from"react";import{cn as F}from"../../../lib/cn.js";import{getBaseInputClasses as N,getIconClasses as O}from"../shared/inputStyles.js";import{InputWrapper as w}from"../shared/InputWrapper.js";import{jsx as l,jsxs as z}from"react/jsx-runtime";var D=P(({label:M,inline:b=!1,size:H="md",labelColor:L,borderColor:s,textColor:a,disabled:e=!1,readOnly:t=!1,error:u=!1,helperText:R,hideLabel:h=!1,icon:r,iconPosition:i="left",multiline:f=!1,rows:C=3,focused:m=!1,id:g,className:x,...c},n)=>{let I=v(null),T=p=>{I.current=p,typeof n=="function"?n(p):n&&(n.current=p)};W(()=>{m&&I.current?.focus()},[m]);let A=S(),o=g||A,d=F(N({size:H,error:u,disabled:e,readOnly:t,icon:r,iconPosition:i}),f&&"resize-y",x),y={...s&&{borderColor:s},...a&&{color:a}},E=s||a?y:void 0;return l(w,{label:M,hideLabel:h,labelColor:L,error:u,helperText:R,inline:b,htmlFor:o,children:z("div",{className:"relative w-full",children:[r&&l("span",{className:O(i),children:r}),f?l("textarea",{ref:T,id:o,disabled:e,readOnly:t,rows:C,tabIndex:t||e?-1:void 0,className:d,style:E,...c}):l("input",{ref:T,id:o,disabled:e,readOnly:t,tabIndex:t||e?-1:void 0,className:d,style:E,...c})]})})});D.displayName="Input";export{D as Input};
1
+ "use client";import{forwardRef as w,useEffect as N,useId as O,useRef as B}from"react";import{cn as D}from"../../../lib/cn.js";import{safeCssColor as M}from"../../../lib/css-value.js";import{describeField as z}from"../shared/field-error.js";import{getBaseInputClasses as j,getIconClasses as k}from"../shared/inputStyles.js";import{InputWrapper as q}from"../shared/InputWrapper.js";import{jsx as o,jsxs as J}from"react/jsx-runtime";var G=w(({label:H,inline:L=!1,size:x="md",labelColor:R,borderColor:y,textColor:g,disabled:e=!1,readOnly:t=!1,error:u,helperText:d,hideLabel:h=!1,icon:a,iconPosition:f="left",multiline:m=!1,rows:v=3,focused:c=!1,id:A,className:P,"aria-describedby":W,...b},r)=>{let s=M(y),i=M(g),I=B(null),C=p=>{I.current=p,typeof r=="function"?r(p):r&&(r.current=p)};N(()=>{c&&I.current?.focus()},[c]);let F=O(),l=A||F,n=z(l,{helperText:d,error:u,own:W}),T=D(j({size:x,error:n.invalid,disabled:e,readOnly:t,icon:a,iconPosition:f}),m&&"resize-y",P),S={...s&&{borderColor:s},...i&&{color:i}},E=s||i?S:void 0;return o(q,{label:H,hideLabel:h,labelColor:R,error:u,helperText:d,inline:L,htmlFor:l,children:J("div",{className:"relative w-full",children:[a&&o("span",{className:k(f),children:a}),m?o("textarea",{ref:C,id:l,disabled:e,readOnly:t,rows:v,tabIndex:t||e?-1:void 0,className:T,style:E,"aria-invalid":n.invalid||void 0,"aria-describedby":n.describedBy,...b}):o("input",{ref:C,id:l,disabled:e,readOnly:t,tabIndex:t||e?-1:void 0,className:T,style:E,"aria-invalid":n.invalid||void 0,"aria-describedby":n.describedBy,...b})]})})});G.displayName="Input";export{G as Input};