@synertech/ui 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +116 -18
- package/README.md +47 -5
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/bar-chart/BarChart.cjs +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/box-plot/BoxPlot.cjs +1 -1
- package/dist/components/box-plot/BoxPlot.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/bullet-chart/BulletChart.cjs +1 -1
- package/dist/components/bullet-chart/BulletChart.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
- package/dist/components/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/ChartSync.cjs +1 -1
- package/dist/components/chart/ChartSync.js +1 -1
- package/dist/components/chart/utils/cartesian.cjs +1 -1
- package/dist/components/chart/utils/cartesian.js +1 -1
- package/dist/components/chart/utils/export.cjs +1 -2
- package/dist/components/chart/utils/export.js +1 -2
- package/dist/components/chart/utils/keyboard.cjs +1 -0
- package/dist/components/chart/utils/keyboard.js +1 -0
- package/dist/components/chart/utils/path.cjs +1 -1
- package/dist/components/chart/utils/path.js +1 -1
- package/dist/components/chart/utils/time.cjs +1 -1
- package/dist/components/chart/utils/time.js +1 -1
- package/dist/components/chart/utils/timestamp.cjs +1 -0
- package/dist/components/chart/utils/timestamp.js +1 -0
- package/dist/components/chart/utils/touch.cjs +1 -0
- package/dist/components/chart/utils/touch.js +1 -0
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -2
- package/dist/components/datagrid/DataGrid.js +1 -2
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/dropdown/Dropdown.cjs +1 -1
- package/dist/components/dropdown/Dropdown.js +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownItem.cjs +1 -1
- package/dist/components/dropdown/DropdownItem.js +1 -1
- package/dist/components/dropdown/DropdownRadio.cjs +1 -1
- package/dist/components/dropdown/DropdownRadio.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/index.cjs +1 -1
- package/dist/components/dropdown/hooks/index.js +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.js +1 -1
- package/dist/components/dropdown/menu-navigation.cjs +1 -0
- package/dist/components/dropdown/menu-navigation.js +1 -0
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +1 -1
- package/dist/components/form/mention-input/MentionInput.js +1 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
- package/dist/components/funnel-chart/FunnelChart.js +1 -1
- package/dist/components/gantt-chart/GanttChart.cjs +1 -1
- package/dist/components/gantt-chart/GanttChart.js +1 -1
- package/dist/components/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/help-button/HelpButton.cjs +7 -7
- package/dist/components/help-button/HelpButton.js +7 -7
- package/dist/components/help-button/MarkdownEditor.cjs +1 -1
- package/dist/components/help-button/MarkdownEditor.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/label/Label.cjs +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/line-chart/LineChart.cjs +1 -1
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pie-chart/PieChart.cjs +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/tabs/Tabs.cjs +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/TabsContent.cjs +1 -1
- package/dist/components/tabs/TabsContent.js +1 -1
- package/dist/components/tabs/TabsContext.cjs +1 -1
- package/dist/components/tabs/TabsContext.js +1 -1
- package/dist/components/tabs/TabsList.cjs +1 -1
- package/dist/components/tabs/TabsList.js +1 -1
- package/dist/components/tabs/TabsTrigger.cjs +1 -1
- package/dist/components/tabs/TabsTrigger.js +1 -1
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
- package/dist/components/wizard/Wizard.cjs +1 -1
- package/dist/components/wizard/Wizard.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +830 -175
- package/dist/index.d.ts +830 -175
- package/dist/index.js +1 -1
- package/dist/lib/aria-hide.cjs +1 -1
- package/dist/lib/aria-hide.js +1 -1
- package/dist/lib/csv.cjs +2 -0
- package/dist/lib/csv.js +2 -0
- package/dist/lib/i18n.cjs +1 -1
- package/dist/lib/i18n.js +1 -1
- package/dist/lib/server-labels.cjs +1 -0
- package/dist/lib/server-labels.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -0
- package/dist/lib/ui-labels.js +1 -0
- package/dist/styles.css +3070 -264
- package/package.json +14 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(c,o)=>{for(var h in o)n(c,h,{get:o[h],enumerable:!0})},H=(c,o,h,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of T(o))!u.call(c,t)&&t!==h&&n(c,t,{get:()=>o[t],enumerable:!(p=C(o,t))||p.enumerable});return c};var R=c=>H(n({},"__esModule",{value:!0}),c);var a={};A(a,{CHART_TOUCH:()=>_,CHART_TOUCH_VERTICAL_DRAG:()=>x});module.exports=R(a);var _="touch-pan-y touch-pinch-zoom",x="touch-pan-x touch-pinch-zoom";0&&(module.exports={CHART_TOUCH,CHART_TOUCH_VERTICAL_DRAG});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="touch-pan-y touch-pinch-zoom",c="touch-pan-x touch-pinch-zoom";export{o as CHART_TOUCH,c as CHART_TOUCH_VERTICAL_DRAG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var g=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var A=(t,r)=>{for(var a in r)g(t,a,{get:r[a],enumerable:!0})},D=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of U(r))!q.call(t,s)&&s!==a&&g(t,s,{get:()=>r[s],enumerable:!(n=T(r,s))||n.enumerable});return t};var F=t=>D(g({},"__esModule",{value:!0}),t);var _={};A(_,{Chip:()=>f});module.exports=F(_);var o=require("../../lib/cn.cjs"),k=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function G({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var J={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},K={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Q={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},c={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},X={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Y={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Z={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function f({label:t,children:r,variant:a="solid",size:n="md",color:s="default",bgColor:b,textColor:p,borderColor:u,rounded:C="full",icon:h,endIcon:x,avatar:d,onClose:w,closable:m=!1,removeLabel:v,clickable:R=!1,selected:N=!1,disabled:l=!1,as:S="span",className:L,onClick:z,...M}){let P=(0,k.useUILabels)(),E=S,V=(0,o.cn)("inline-flex items-center justify-center font-medium transition-all",Q[n],Z[C],a==="outlined"&&"border"),W=(0,o.cn)(b||p||u?(0,o.cn)(b,p,u):J[s][a]),I=N?"ring-2 ring-offset-1 ring-blue-500":"",j=R&&!l?"cursor-pointer hover:opacity-80 active:scale-95":"",B=l?"opacity-50 cursor-not-allowed":"",H=i=>{i.stopPropagation(),w?.()},O=i=>{l||z?.(i)},y=r??t;return(0,e.jsxs)(E,{className:(0,o.cn)(V,W,I,j,B,L),onClick:O,"aria-disabled":l,...M,children:[a==="dot"&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full shrink-0",Y[n],K[s]),"aria-hidden":"true"}),d&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full overflow-hidden shrink-0",X[n]),children:d}),h&&!d&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:h}),y&&(0,e.jsx)("span",{className:"truncate",children:y}),x&&!m&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:x}),m&&(0,e.jsx)("button",{type:"button",onClick:H,disabled:l,className:(0,o.cn)("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",l&&"pointer-events-none"),"aria-label":v??P.chipRemove,children:(0,e.jsx)(G,{className:c[n]})})]})}f.displayName="Chip";0&&(module.exports={Chip});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../../lib/cn.js";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{cn as e}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{jsx as t,jsxs as G}from"react/jsx-runtime";function H({className:n}){return t("svg",{className:n,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var O={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},T={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},U={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},d={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},q={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},A={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},D={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function F({label:n,children:m,variant:a="solid",size:r="md",color:i="default",bgColor:g,textColor:c,borderColor:b,rounded:y="full",icon:p,endIcon:u,avatar:s,onClose:k,closable:h=!1,removeLabel:f,clickable:C=!1,selected:w=!1,disabled:o=!1,as:v="span",className:R,onClick:N,...S}){let L=B(),z=v,M=e("inline-flex items-center justify-center font-medium transition-all",U[r],D[y],a==="outlined"&&"border"),P=e(g||c||b?e(g,c,b):O[i][a]),E=w?"ring-2 ring-offset-1 ring-blue-500":"",V=C&&!o?"cursor-pointer hover:opacity-80 active:scale-95":"",W=o?"opacity-50 cursor-not-allowed":"",I=l=>{l.stopPropagation(),k?.()},j=l=>{o||N?.(l)},x=m??n;return G(z,{className:e(M,P,E,V,W,R),onClick:j,"aria-disabled":o,...S,children:[a==="dot"&&t("span",{className:e("rounded-full shrink-0",A[r],T[i]),"aria-hidden":"true"}),s&&t("span",{className:e("rounded-full overflow-hidden shrink-0",q[r]),children:s}),p&&!s&&t("span",{className:e("shrink-0",d[r]),children:p}),x&&t("span",{className:"truncate",children:x}),u&&!h&&t("span",{className:e("shrink-0",d[r]),children:u}),h&&t("button",{type:"button",onClick:I,disabled:o,className:e("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",o&&"pointer-events-none"),"aria-label":f??L.chipRemove,children:t(H,{className:d[r]})})]})}F.displayName="Chip";export{F as Chip};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";"use client";var ar=Object.create;var me=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var sr=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty;var ir=(o,l)=>{for(var i in l)me(o,i,{get:l[i],enumerable:!0})},ot=(o,l,i,c)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of or(l))!lr.call(o,u)&&u!==i&&me(o,u,{get:()=>l[u],enumerable:!(c=nr(l,u))||c.enumerable});return o};var dr=(o,l,i)=>(i=o!=null?ar(sr(o)):{},ot(l||!o||!o.__esModule?me(i,"default",{value:o,enumerable:!0}):i,o)),cr=o=>ot(me({},"__esModule",{value:!0}),o);var Rr={};ir(Rr,{DataGrid:()=>Sr});module.exports=cr(Rr);var n=dr(require("react"),1),m=require("../../lib/cn.cjs"),t=require("react/jsx-runtime"),h={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},ye={compact:"text-xs",default:"text-sm",comfortable:"text-base"},gr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),ur=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),pr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),st=({className:o})=>(0,t.jsx)("svg",{className:(0,m.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),mr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),br=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),yr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),fr=()=>(0,t.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,t.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),hr=()=>(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function be(o,l,i){return typeof i=="function"?i(o,l):String(typeof i=="string"?o[i]:l)}function E(o,l){return o[l]}function vr(o,l){return o==null&&l==null?0:o==null?-1:l==null?1:typeof o=="number"&&typeof l=="number"?o-l:String(o).localeCompare(String(l))}function xr(o,l){let i=String(o??"").toLowerCase(),c=l.value.toLowerCase();switch(l.operator){case"contains":return i.includes(c);case"equals":return i===c;case"startsWith":return i.startsWith(c);case"endsWith":return i.endsWith(c);case"gt":return Number(o)>Number(l.value);case"gte":return Number(o)>=Number(l.value);case"lt":return Number(o)<Number(l.value);case"lte":return Number(o)<=Number(l.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function lt(o,l,i){let c=[];for(let u of o){let p=Number(E(u,l));isNaN(p)||c.push(p)}if(c.length===0)return 0;switch(i){case"sum":return c.reduce((u,p)=>u+p,0);case"avg":return c.reduce((u,p)=>u+p,0)/c.length;case"count":return c.length;case"min":return Math.min(...c);case"max":return Math.max(...c)}}function kr({cols:o,density:l}){return(0,t.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((i,c)=>(0,t.jsx)("td",{className:h[l],children:(0,t.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},c))})}function wr({column:o,value:l,onApply:i,onClear:c}){let[u,p]=(0,n.useState)(!1),[F,z]=(0,n.useState)(l?.operator??"contains"),[C,S]=(0,n.useState)(l?.value??""),I=(0,n.useRef)(null),R=o.filterType??"text",re=R==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return(0,n.useEffect)(()=>{let b=ie=>{I.current&&!I.current.contains(ie.target)&&p(!1)};return u&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[u]),(0,t.jsxs)("div",{className:"relative inline-block",ref:I,children:[(0,t.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),p(!u)},className:(0,m.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(o.header)}`,children:(0,t.jsx)(yr,{})}),u&&(0,t.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:R==="select"&&o.filterOptions?(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(b=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:b,checked:C===b,onChange:()=>S(b),className:"cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:b})]},b)),(0,t.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{i({column:o.key,operator:"equals",value:C}),p(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),(0,t.jsx)("button",{type:"button",onClick:()=>{S(""),c(),p(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("select",{value:F,onChange:b=>z(b.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:re.map(b=>(0,t.jsx)("option",{value:b.value,children:b.label},b.value))}),F!=="isEmpty"&&F!=="isNotEmpty"&&(0,t.jsx)("input",{type:R==="number"?"number":R==="date"?"date":"text",value:C,onChange:b=>S(b.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":`Filter ${String(o.header)} value`}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{i({column:o.key,operator:F,value:C}),p(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),(0,t.jsx)("button",{type:"button",onClick:()=>{S(""),c(),p(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Cr({value:o,onSave:l,density:i}){let[c,u]=(0,n.useState)(!1),[p,F]=(0,n.useState)(String(o??"")),z=(0,n.useRef)(null);if((0,n.useEffect)(()=>{c&&z.current&&(z.current.focus(),z.current.select())},[c]),!c)return(0,t.jsx)("div",{onDoubleClick:()=>{F(String(o??"")),u(!0)},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(o??"")});let C=()=>{u(!1),p!==String(o??"")&&l(p)};return(0,t.jsx)("input",{ref:z,type:"text",value:p,onChange:S=>F(S.target.value),onBlur:C,"aria-label":"Edit cell value",onKeyDown:S=>{S.key==="Enter"&&C(),S.key==="Escape"&&u(!1)},className:(0,m.cn)("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",ye[i])})}function Nr(o,l){let{columns:i,data:c,rowKey:u,mode:p="client",sortable:F=!1,multiSort:z=!1,sort:C,defaultSort:S,onSort:I,pagination:R=!1,page:re,onPageChange:b,onPageSizeChange:ie,totalItems:it,selectable:ae=!1,selectionMode:fe="multiple",selectedRows:G,onSelectionChange:_,searchable:Ve=!1,searchPlaceholder:dt="Search...",searchValue:ne,onSearch:de,filters:B,onFilterChange:J,expandable:oe=!1,expandedContent:Oe,expandedRows:he,onExpandChange:We,editable:ct=!1,onCellEdit:gt,reorderable:x=!1,onReorder:Ge,columnReorderable:L=!1,onColumnReorder:Be,columnToggle:Ke=!1,hiddenColumns:ve,onColumnVisibilityChange:je,groupBy:V,renderGroupHeader:$e,exportable:qe=!1,exportFormats:ut=["csv","json"],exportFilename:Ue="export",virtualized:K=!1,rowHeight:j=40,virtualHeight:xe=400,density:f="default",striped:Xe=!1,bordered:ke=!1,borderless:pt=!1,stickyHeader:_e=!1,maxHeight:ce,loading:mt=!1,loadingRows:bt=5,emptyState:yt,showFooter:ft=!1,onRowClick:we,onRowDoubleClick:Je,onRowContextMenu:Qe,className:ht,rowClassName:Ce,cellClassName:vt,headerClassName:xt}=o,[kt,Ye]=(0,n.useState)(S??[]),[wt,Ct]=(0,n.useState)(1),[Nt,St]=(0,n.useState)(typeof R=="object"?R.pageSize??10:10),[Rt,Ne]=(0,n.useState)([]),[Tt,Ze]=(0,n.useState)(""),[Dt,Se]=(0,n.useState)([]),[Mt,Et]=(0,n.useState)([]),[Ft,zt]=(0,n.useState)(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Re,Pt]=(0,n.useState)({}),[ge,At]=(0,n.useState)(()=>i.map(e=>e.key)),[$,et]=(0,n.useState)(null),[Q,tt]=(0,n.useState)(null),[ue,rt]=(0,n.useState)(!1),[Ht,It]=(0,n.useState)(new Set),Te=(0,n.useRef)(null),[at,Lt]=(0,n.useState)(0),De=(0,n.useRef)(null),q=C??kt,P=re??wt,T=G??Rt,pe=ne??Tt,O=B??Dt,se=he??Mt,U=ve??Ft,A=R?typeof R=="object"?R:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,le=A?.pageSize??Nt,H=(0,n.useMemo)(()=>{let e=new Map(i.map(s=>[s.key,s])),r=ge.flatMap(s=>{let d=e.get(s);return d?[d]:[]}),a=new Set(r.map(s=>s.key));for(let s of i)a.has(s.key)||(r.push(s),a.add(s.key));return r.filter(s=>!U.includes(s.key))},[i,ge,U]),N=(0,n.useMemo)(()=>{if(p==="server")return c;let e=[...c];if(pe){let r=pe.toLowerCase();e=e.filter(a=>H.some(s=>{let d=E(a,s.key);return String(d??"").toLowerCase().includes(r)}))}if(O.length>0&&(e=e.filter(r=>O.every(a=>xr(E(r,a.column),a)))),q.length>0){let r=new Map(i.map(a=>[a.key,a]));e.sort((a,s)=>{for(let d of q){if(!d.direction)continue;let y=r.get(d.key),k=y?.sortComparator?y.sortComparator(a,s):vr(E(a,d.key),E(s,d.key));if(k!==0)return d.direction==="asc"?k:-k}return 0})}return e},[c,p,pe,O,q,H,i]),nt=(0,n.useMemo)(()=>{if(!V)return null;let e=Array.isArray(V)?V:[V],r=new Map;for(let a of N){let s=e.map(y=>String(E(a,y)??"")).join(" / "),d=r.get(s)??[];d.push(a),r.set(s,d)}return r},[N,V]),Me=it??N.length,Y=Math.max(1,Math.ceil(Me/le)),Vt=(0,n.useMemo)(()=>{if(!A||p==="server")return N;let e=(P-1)*le;return N.slice(e,e+le)},[N,A,P,le,p]),v=A?Vt:N,Z=(0,n.useMemo)(()=>{if(!K)return{start:0,end:v.length};let e=Math.floor(at/j),r=Math.ceil(xe/j),a=5;return{start:Math.max(0,e-a),end:Math.min(v.length,e+r+a)}},[K,at,j,xe,v.length]),Ee=(0,n.useCallback)(e=>{C||Ye(e),I?.(e)},[C,I]),Ot=(0,n.useCallback)(e=>{let r=q.find(s=>s.key===e),a;if(!r||!r.direction?a="asc":r.direction==="asc"?a="desc":a=null,z){let s=q.filter(d=>d.key!==e);a&&s.push({key:e,direction:a}),Ee(s)}else Ee(a?[{key:e,direction:a}]:[])},[q,z,Ee]),W=(0,n.useCallback)(e=>{let r=Math.max(1,Math.min(e,Y));re||Ct(r),b?.(r)},[re,b,Y]),Wt=(0,n.useCallback)(e=>{St(e),W(1),ie?.(e)},[W,ie]),Gt=(0,n.useCallback)(e=>{let r;fe==="single"?r=T.includes(e)?[]:[e]:r=T.includes(e)?T.filter(a=>a!==e):[...T,e],G||Ne(r),_?.(r)},[fe,T,G,_]),Fe=(0,n.useCallback)(()=>{let e=v.map((r,a)=>be(r,a,u));G||Ne(e),_?.(e)},[v,u,G,_]),ze=(0,n.useCallback)(()=>{G||Ne([]),_?.([])},[G,_]),Pe=v.length>0&&v.every((e,r)=>T.includes(be(e,r,u))),Bt=!Pe&&v.some((e,r)=>T.includes(be(e,r,u))),Kt=(0,n.useCallback)(e=>{let r=se.includes(e)?se.filter(a=>a!==e):[...se,e];he||Et(r),We?.(r)},[se,he,We]),jt=(0,n.useCallback)(e=>{let r=e.target.value;ne||Ze(r),de?.(r),W(1)},[ne,de,W]),$t=(0,n.useCallback)(e=>{let r=[...O.filter(a=>a.column!==e.column),e];B||Se(r),J?.(r)},[O,B,J]),qt=(0,n.useCallback)(e=>{let r=O.filter(a=>a.column!==e);B||Se(r),J?.(r)},[O,B,J]),Ut=(0,n.useCallback)(e=>{let r=U.includes(e)?U.filter(a=>a!==e):[...U,e];ve||zt(r),je?.(r)},[U,ve,je]),Xt=(0,n.useCallback)((e,r)=>{e.preventDefault(),e.stopPropagation();let a=e.clientX,s=Re[r]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,d=i.find(w=>w.key===r),y=d?.minWidth??50,k=d?.maxWidth??1/0,g=w=>{let X=w.clientX-a,M=Math.min(k,Math.max(y,s+X));Pt(te=>({...te,[r]:M}))},D=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",D)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",D)},[Re,i]),_t=(0,n.useCallback)(e=>{x&&et(e)},[x]),Jt=(0,n.useCallback)((e,r)=>{!x||$===null||e.preventDefault()},[x,$]),Qt=(0,n.useCallback)(e=>{!x||$===null||$===e||(Ge?.($,e),et(null))},[x,$,Ge]),Yt=(0,n.useCallback)(e=>{L&&tt(e)},[L]),Zt=(0,n.useCallback)(e=>{if(!L||!Q||Q===e)return;let r=[...ge],a=r.indexOf(Q),s=r.indexOf(e);a===-1||s===-1||(r.splice(a,1),r.splice(s,0,Q),At(r),Be?.(Q,e),tt(null))},[L,Q,ge,Be]),Ae=(0,n.useCallback)(e=>{let r=H.filter(w=>w.type!=="actions"&&w.type!=="selection"&&w.type!=="expand"),a=N,s,d,y;if(e==="csv"){let w=r.map(M=>String(M.header)).join(","),X=a.map(M=>r.map(te=>{let Le=String(E(M,te.key)??"");return Le.includes(",")?`"${Le}"`:Le}).join(","));s=[w,...X].join(`
|
|
2
|
-
`),d="text/csv",y="csv"}else{let w=a.map(X=>{let M={};for(let te of r)M[te.key]=E(X,te.key);return M});s=JSON.stringify(w,null,2),d="application/json",y="json"}let k=new Blob([s],{type:d}),g=URL.createObjectURL(k),D=document.createElement("a");D.href=g,D.download=`${Ue}.${y}`,D.click(),URL.revokeObjectURL(g)},[H,N,Ue]);(0,n.useEffect)(()=>{if(!ue)return;let e=r=>{De.current&&!De.current.contains(r.target)&&rt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ue]),(0,n.useImperativeHandle)(l,()=>({getVisibleData:()=>v,resetFilters:()=>{B||Se([]),ne||Ze(""),J?.([]),de?.("")},resetSort:()=>{C||Ye([]),I?.([])},selectAll:Fe,deselectAll:ze,exportData:Ae,scrollToRow:e=>{Te.current&&K&&(Te.current.scrollTop=e*j)}}),[v,B,ne,C,J,de,I,Fe,ze,Ae,K,j]);let He=e=>{let r={},a=Re[e.key]??e.width;return a&&(r.width=typeof a=="number"?`${a}px`:a,r.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(r.position="sticky",r[e.sticky]=0,r.zIndex=10),r},ee=H.length+(ae?1:0)+(oe?1:0)+(x?1:0),er=e=>{let r=F&&e.sortable!==!1&&e.type!=="actions",a=q.find(d=>d.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,t.jsxs)("th",{className:(0,m.cn)(h[f],ye[f],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",r&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",ke&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,xt),style:He(e),onClick:r?()=>Ot(e.key):void 0,draggable:L,onDragStart:L?()=>Yt(e.key):void 0,onDragOver:L?d=>d.preventDefault():void 0,onDrop:L?()=>Zt(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,r&&(0,t.jsx)("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?(0,t.jsx)(gr,{}):a?.direction==="desc"?(0,t.jsx)(ur,{}):(0,t.jsx)(pr,{})}),s&&(0,t.jsx)(wr,{column:e,value:O.find(d=>d.column===e.key),onApply:$t,onClear:()=>qt(e.key)})]}),e.resizable!==!1&&(0,t.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:d=>Xt(d,e.key)})]},e.key)},Ie=(e,r,a)=>{let s=be(e,a,u),d=T.includes(s),y=se.includes(s),k=typeof Ce=="function"?Ce(e,a):Ce;return(0,t.jsxs)(n.default.Fragment,{children:[(0,t.jsxs)("tr",{className:(0,m.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",Xe&&a%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",d&&"bg-blue-50 dark:bg-blue-900/20",we&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",$===r&&"opacity-50",k),onClick:we?()=>we(e,a):void 0,onDoubleClick:Je?()=>Je(e,a):void 0,onContextMenu:Qe?g=>Qe(e,a,g):void 0,draggable:x,onDragStart:x?()=>_t(r):void 0,onDragOver:x?g=>Jt(g,r):void 0,onDrop:x?()=>Qt(r):void 0,"data-row-key":s,"aria-selected":ae?d:void 0,children:[x&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"cursor-grab active:cursor-grabbing"),children:(0,t.jsx)(br,{})}),ae&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"w-10"),children:(0,t.jsx)("input",{type:"checkbox",checked:d,onChange:()=>Gt(s),onClick:g=>g.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${s}`})}),oe&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"w-10"),children:(0,t.jsx)("button",{type:"button",onClick:g=>{g.stopPropagation(),Kt(s)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":y?"Collapse row":"Expand row","aria-expanded":y,children:(0,t.jsx)(st,{className:(0,m.cn)("transition-transform",y&&"rotate-180")})})}),H.map(g=>{let D=E(e,g.key),w=g.colSpan?.(e,a);if(w===0)return null;let X=ct&&g.editable!==!1&&g.type!=="actions";return(0,t.jsx)("td",{className:(0,m.cn)(h[f],ye[f],"text-gray-700 dark:text-gray-300",g.align==="center"&&"text-center",g.align==="right"&&"text-right",ke&&"border border-gray-200 dark:border-gray-700",g.sticky&&(d?"bg-blue-50 dark:bg-blue-900/20":Xe&&a%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),g.cellClassName,vt),style:He(g),colSpan:w,children:X?(0,t.jsx)(Cr,{value:D,onSave:M=>gt?.(s,g.key,M),density:f}):g.render?g.render(D,e,a):String(D??"")},g.key)})]}),oe&&y&&Oe&&(0,t.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)(h[f]),children:Oe(e,a)})})]},s)},tr=()=>{if(mt)return Array.from({length:bt}).map((e,r)=>(0,t.jsx)(kr,{cols:ee,density:f},r));if(v.length===0)return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)("text-center text-gray-400 dark:text-gray-500",h[f]),children:yt??"No data available"})});if(nt){let e=[],r=0;for(let[a,s]of nt){let d=Ht.has(a);if(e.push((0,t.jsx)("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)(h[f],"cursor-pointer"),onClick:()=>{It(y=>{let k=new Set(y);return k.has(a)?k.delete(a):k.add(a),k})},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(st,{className:(0,m.cn)("transition-transform",d&&"-rotate-90")}),$e?$e(a,E(s[0],Array.isArray(V)?V[0]:V),s):`${a} (${s.length})`]})})},`group-${a}`)),d)r+=s.length;else for(let y=0;y<s.length;y++)e.push(Ie(s[y],r,r)),r++}return e}if(K){let e=[];for(let r=Z.start;r<Z.end;r++)e.push(Ie(v[r],r,r));return(0,t.jsxs)(t.Fragment,{children:[Z.start>0&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,style:{height:Z.start*j,padding:0}})}),e,Z.end<v.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,style:{height:(v.length-Z.end)*j,padding:0}})})]})}return v.map((e,r)=>Ie(e,r,r))},rr=()=>!ft||!H.some(r=>r.aggregate)?null:(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[x&&(0,t.jsx)("td",{className:h[f]}),ae&&(0,t.jsx)("td",{className:h[f]}),oe&&(0,t.jsx)("td",{className:h[f]}),H.map(r=>(0,t.jsx)("td",{className:(0,m.cn)(h[f],ye[f],"text-gray-700 dark:text-gray-300",r.align==="center"&&"text-center",r.align==="right"&&"text-right",ke&&"border border-gray-200 dark:border-gray-700"),style:He(r),children:r.aggregate?r.renderAggregate?r.renderAggregate(lt(N,r.key,r.aggregate),N):`${r.aggregate==="count"?"":r.aggregate==="avg"?"Avg: ":r.aggregate==="sum"?"Total: ":r.aggregate==="min"?"Min: ":"Max: "}${lt(N,r.key,r.aggregate).toLocaleString()}`:""},r.key))]})});return(0,t.jsxs)("div",{className:(0,m.cn)("flex flex-col gap-3",ht),children:[(Ve||qe||Ke)&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[Ve&&(0,t.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,t.jsx)(mr,{})}),(0,t.jsx)("input",{type:"text",value:pe,onChange:jt,placeholder:dt,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),T.length>0&&(0,t.jsxs)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[T.length," selected"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ke&&(0,t.jsxs)("div",{className:"relative",ref:De,children:[(0,t.jsx)("button",{type:"button",onClick:()=>rt(!ue),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:(0,t.jsx)(hr,{})}),ue&&(0,t.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!U.includes(e.key),onChange:()=>Ut(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),qe&&ut.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>Ae(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${e.toUpperCase()}`,children:[(0,t.jsx)(fr,{}),e.toUpperCase()]},e))]})]}),(0,t.jsx)("div",{ref:Te,className:(0,m.cn)("overflow-auto rounded-lg",!pt&&"border border-gray-200 dark:border-gray-700",_e&&"relative"),style:ce?{maxHeight:typeof ce=="number"?`${ce}px`:ce}:K?{maxHeight:xe,overflow:"auto"}:void 0,onScroll:K?e=>Lt(e.target.scrollTop):void 0,children:(0,t.jsxs)("table",{className:"w-full text-left",children:[(0,t.jsx)("thead",{className:(0,m.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",_e&&"sticky top-0 z-20"),children:(0,t.jsxs)("tr",{children:[x&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),ae&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10"),children:fe==="multiple"&&(0,t.jsx)("input",{type:"checkbox",checked:Pe,ref:e=>{e&&(e.indeterminate=Bt)},onChange:Pe?ze:Fe,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),oe&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),H.map(er)]})}),(0,t.jsx)("tbody",{children:tr()}),rr()]})}),A&&(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[A.showTotalItems!==!1&&(0,t.jsxs)("span",{children:[Me," item",Me!==1?"s":""]}),A.showPageSizeSelector!==!1&&A.pageSizeOptions&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:"Rows per page:"}),(0,t.jsx)("select",{value:le,onChange:e=>Wt(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:A.pageSizeOptions.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("span",{className:"mr-2",children:["Page ",P," of ",Y]}),(0,t.jsx)("button",{type:"button",onClick:()=>W(1),disabled:P<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(P-1),disabled:P<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(P+1),disabled:P>=Y,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(Y),disabled:P>=Y,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Sr=(0,n.forwardRef)(Nr);0&&(module.exports={DataGrid});
|
|
1
|
+
"use strict";"use client";var xr=Object.create;var Ce=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var Cr=Object.getPrototypeOf,Nr=Object.prototype.hasOwnProperty;var Sr=(o,i)=>{for(var d in i)Ce(o,d,{get:i[d],enumerable:!0})},wt=(o,i,d,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of kr(i))!Nr.call(o,c)&&c!==d&&Ce(o,c,{get:()=>i[c],enumerable:!(u=wr(i,c))||u.enumerable});return o};var Rr=(o,i,d)=>(d=o!=null?xr(Cr(o)):{},wt(i||!o||!o.__esModule?Ce(d,"default",{value:o,enumerable:!0}):d,o)),Tr=o=>wt(Ce({},"__esModule",{value:!0}),o);var qr={};Sr(qr,{DataGrid:()=>jr,resetRowKeyWarning:()=>Or});module.exports=Tr(qr);var n=Rr(require("react"),1),f=require("../../lib/cn.cjs"),Nt=require("../../lib/csv.cjs"),D=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),k={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ne={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Dr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),Er=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),Gr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),kt=({className:o})=>(0,t.jsx)("svg",{className:(0,f.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Mr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),Fr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Pr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),zr=()=>(0,t.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,t.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Ir=()=>(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function qe(o,i,d){return typeof d=="function"?d(o,i):String(typeof d=="string"?o[d]:i)}var $e=!1;function Or(){$e=!1}function Ar(){$e||($e=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function F(o,i){return o[i]}function Lr(o,i){return o==null&&i==null?0:o==null?-1:i==null?1:typeof o=="number"&&typeof i=="number"?o-i:String(o).localeCompare(String(i))}function Hr(o,i){let d=String(o??"").toLowerCase(),u=i.value.toLowerCase();switch(i.operator){case"contains":return d.includes(u);case"equals":return d===u;case"startsWith":return d.startsWith(u);case"endsWith":return d.endsWith(u);case"gt":return Number(o)>Number(i.value);case"gte":return Number(o)>=Number(i.value);case"lt":return Number(o)<Number(i.value);case"lte":return Number(o)<=Number(i.value);case"isEmpty":return d==="";case"isNotEmpty":return d!=="";default:return!0}}function Ct(o,i,d){let u=[];for(let c of o){let b=Number(F(c,i));isNaN(b)||u.push(b)}if(u.length===0)return 0;switch(d){case"sum":return u.reduce((c,b)=>c+b,0);case"avg":return u.reduce((c,b)=>c+b,0)/u.length;case"count":return u.length;case"min":return Math.min(...u);case"max":return Math.max(...u)}}function Vr(o,i,d){if(o==="count")return i;let u=o==="avg"?d.dataGridAggregateAvg:o==="sum"?d.dataGridAggregateSum:o==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return(0,D.formatUILabel)(u,{value:i})}function Kr({cols:o,density:i}){return(0,t.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((d,u)=>(0,t.jsx)("td",{className:k[i],children:(0,t.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},u))})}function Wr({column:o,value:i,onApply:d,onClear:u,labels:c}){let b=o.filterType??"text",L=String(o.header),P=b==="number"?[{value:"equals",label:c.dataGridOperatorEquals},{value:"gt",label:c.dataGridOperatorGreaterThan},{value:"gte",label:c.dataGridOperatorGreaterOrEqual},{value:"lt",label:c.dataGridOperatorLessThan},{value:"lte",label:c.dataGridOperatorLessOrEqual}]:[{value:"contains",label:c.dataGridOperatorContains},{value:"equals",label:c.dataGridOperatorEquals},{value:"startsWith",label:c.dataGridOperatorStartsWith},{value:"endsWith",label:c.dataGridOperatorEndsWith},{value:"isEmpty",label:c.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:c.dataGridOperatorIsNotEmpty}],S=g=>g&&P.some(R=>R.value===g.operator)?g.operator:P[0].value,[E,w]=(0,n.useState)(!1),[G,re]=(0,n.useState)(()=>S(i)),[$,H]=(0,n.useState)(i?.value??""),ae=(0,n.useRef)(null),z=()=>{E||(re(S(i)),H(i?.value??"")),w(!E)};return(0,n.useEffect)(()=>{let g=R=>{ae.current&&!ae.current.contains(R.target)&&w(!1)};return E&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[E]),(0,t.jsxs)("div",{className:"relative inline-block",ref:ae,onClick:g=>g.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:z,className:(0,f.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",i&&"text-blue-600 dark:text-blue-400"),"aria-label":(0,D.formatUILabel)(c.dataGridFilterColumn,{column:L}),children:(0,t.jsx)(Pr,{})}),E&&(0,t.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:b==="select"&&o.filterOptions?(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(g=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:g,checked:$===g,onChange:()=>H(g),className:"cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),(0,t.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:"equals",value:$}),w(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),u(),w(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("select",{value:G,onChange:g=>re(g.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:P.map(g=>(0,t.jsx)("option",{value:g.value,children:g.label},g.value))}),G!=="isEmpty"&&G!=="isNotEmpty"&&(0,t.jsx)("input",{type:b==="number"?"number":b==="date"?"date":"text",value:$,onChange:g=>H(g.target.value),placeholder:c.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":(0,D.formatUILabel)(c.dataGridFilterValue,{column:L})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:G,value:$}),w(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),u(),w(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]})})]})}function Br({value:o,onSave:i,density:d,labels:u}){let[c,b]=(0,n.useState)(!1),[L,P]=(0,n.useState)(String(o??"")),S=(0,n.useRef)(null);if((0,n.useEffect)(()=>{c&&S.current&&(S.current.focus(),S.current.select())},[c]),!c)return(0,t.jsx)("div",{onDoubleClick:()=>{P(String(o??"")),b(!0)},className:"cursor-text min-h-[1.5em]",title:u.dataGridEditHint,children:String(o??"")});let E=()=>{b(!1),L!==String(o??"")&&i(L)};return(0,t.jsx)("input",{ref:S,type:"text",value:L,onChange:w=>P(w.target.value),onBlur:E,"aria-label":u.dataGridEditCell,onKeyDown:w=>{w.key==="Enter"&&E(),w.key==="Escape"&&b(!1)},className:(0,f.cn)("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ne[d])})}function Ur(o,i){let{columns:d,data:u,rowKey:c,mode:b="client",sortable:L=!1,multiSort:P=!1,sort:S,defaultSort:E,onSort:w,pagination:G=!1,page:re,onPageChange:$,onPageSizeChange:H,totalItems:ae,selectable:z=!1,selectionMode:g="multiple",selectedRows:R,onSelectionChange:V,searchable:Xe=!1,searchPlaceholder:St,searchValue:me,onSearch:fe,filters:X,onFilterChange:ne,expandable:oe=!1,expandedContent:_e,expandedRows:Se,onExpandChange:Je,editable:Qe=!1,onCellEdit:Rt,reorderable:se=!1,onReorder:Ye,columnReorderable:K=!1,onColumnReorder:Ze,columnToggle:et=!1,hiddenColumns:Re,onColumnVisibilityChange:tt,groupBy:W,renderGroupHeader:rt,exportable:at=!1,exportFormats:Tt=["csv","json"],exportFilename:nt="export",exportNeutralizeFormulas:ot,virtualized:_=!1,rowHeight:J=40,virtualHeight:Te=400,density:h="default",striped:st=!1,bordered:De=!1,borderless:Dt=!1,stickyHeader:it=!1,maxHeight:he,loading:Et=!1,loadingRows:Gt=5,emptyState:Mt,labels:Ft,showFooter:Pt=!1,onRowClick:Ee,onRowDoubleClick:lt,onRowContextMenu:dt,className:zt,rowClassName:Ge,cellClassName:It,headerClassName:Ot}=o,y=(0,D.useUILabels)(Ft),[At,ct]=(0,n.useState)(E??[]),[Lt,Ht]=(0,n.useState)(1),ie=typeof G=="object"?G.pageSize:void 0,[Vt,ut]=(0,n.useState)(ie??10),[Kt,Wt]=(0,n.useState)(ie);ie!==Kt&&(Wt(ie),ie!==void 0&&ut(ie));let[Bt,ve]=(0,n.useState)([]),[Ut,gt]=(0,n.useState)(""),[jt,Me]=(0,n.useState)([]),[qt,$t]=(0,n.useState)([]),[Xt,_t]=(0,n.useState)(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[Fe,Jt]=(0,n.useState)({}),[xe,Qt]=(0,n.useState)(()=>d.map(e=>e.key)),[Q,Pe]=(0,n.useState)(null),[le,pt]=(0,n.useState)(null),[we,mt]=(0,n.useState)(!1),[Yt,Zt]=(0,n.useState)(new Set),ze=(0,n.useRef)(null),[bt,er]=(0,n.useState)(0),Ie=(0,n.useRef)(null),Oe=(0,n.useRef)(!1),B=S??At,yt=re??Lt,C=R??Bt,ke=me??Ut,U=X??jt,be=Se??qt,Y=Re??Xt,de=G?typeof G=="object"?G:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,ye=Vt;!c&&(z||oe||Qe||se)&&Ar();let ft=e=>qe(e.row,e.sourceIndex,c),I=(0,n.useMemo)(()=>{let e=new Map(d.map(s=>[s.key,s])),r=xe.flatMap(s=>{let l=e.get(s);return l?[l]:[]}),a=new Set(r.map(s=>s.key));for(let s of d)a.has(s.key)||(r.push(s),a.add(s.key));return r.filter(s=>!Y.includes(s.key))},[d,xe,Y]),Z=(0,n.useMemo)(()=>{let e=u.map((r,a)=>({row:r,sourceIndex:a}));if(b==="server")return e;if(ke){let r=ke.toLowerCase();e=e.filter(({row:a})=>I.some(s=>{let l=F(a,s.key);return String(l??"").toLowerCase().includes(r)}))}if(U.length>0&&(e=e.filter(({row:r})=>U.every(a=>Hr(F(r,a.column),a)))),B.length>0){let r=new Map(d.map(a=>[a.key,a]));e.sort((a,s)=>{for(let l of B){if(!l.direction)continue;let m=r.get(l.key),v=m?.sortComparator?m.sortComparator(a.row,s.row):Lr(F(a.row,l.key),F(s.row,l.key));if(v!==0)return l.direction==="asc"?v:-v}return 0})}return e},[u,b,ke,U,B,I,d]),ce=(0,n.useMemo)(()=>Z.map(e=>e.row),[Z]),ht=(0,n.useMemo)(()=>{if(!W)return null;let e=Array.isArray(W)?W:[W],r=new Map;for(let a of Z){let s=e.map(m=>String(F(a.row,m)??"")).join(" / "),l=r.get(s)??[];l.push(a),r.set(s,l)}return r},[Z,W]),Ae=ae??ce.length,ee=Math.max(1,Math.ceil(Ae/ye)),O=b==="server"&&ae===void 0?yt:Math.min(Math.max(1,yt),ee),vt=de!==null,A=(0,n.useMemo)(()=>{if(!vt||b==="server")return Z;let e=(O-1)*ye;return Z.slice(e,e+ye)},[Z,vt,O,ye,b]),j=(0,n.useMemo)(()=>A.map(e=>e.row),[A]),ue=(0,n.useMemo)(()=>{if(!_)return{start:0,end:j.length};let e=Math.floor(bt/J),r=Math.ceil(Te/J),a=5;return{start:Math.max(0,e-a),end:Math.min(j.length,e+r+a)}},[_,bt,J,Te,j.length]),Le=(0,n.useCallback)(e=>{S||ct(e),w?.(e)},[S,w]),tr=(0,n.useCallback)(e=>{let r=B.find(s=>s.key===e),a;if(!r||!r.direction?a="asc":r.direction==="asc"?a="desc":a=null,P){let s=B.filter(l=>l.key!==e);a&&s.push({key:e,direction:a}),Le(s)}else Le(a?[{key:e,direction:a}]:[])},[B,P,Le]),N=(0,n.useCallback)(e=>{let r=Math.max(1,Math.min(e,ee));re||Ht(r),$?.(r)},[re,$,ee]),rr=(0,n.useCallback)(e=>{ut(e),N(1),H?.(e)},[N,H]),ar=(0,n.useCallback)(e=>{let r;g==="single"?r=C.includes(e)?[]:[e]:r=C.includes(e)?C.filter(a=>a!==e):[...C,e],R||ve(r),V?.(r)},[g,C,R,V]),He=(0,n.useMemo)(()=>new Set(C),[C]),Ve=(0,n.useCallback)(()=>{let e=new Set(C),r=[...C];for(let a of A){let s=qe(a.row,a.sourceIndex,c);e.has(s)||(e.add(s),r.push(s))}R||ve(r),V?.(r)},[A,c,C,R,V]),xt=(0,n.useCallback)(()=>{R||ve([]),V?.([])},[R,V]),nr=(0,n.useCallback)(()=>{let e=new Set(A.map(a=>qe(a.row,a.sourceIndex,c))),r=C.filter(a=>!e.has(a));R||ve(r),V?.(r)},[A,c,C,R,V]),Ke=z?A.map(ft):[],We=Ke.length>0&&Ke.every(e=>He.has(e)),or=!We&&Ke.some(e=>He.has(e)),sr=(0,n.useCallback)(e=>{let r=be.includes(e)?be.filter(a=>a!==e):[...be,e];Se||$t(r),Je?.(r)},[be,Se,Je]),ir=(0,n.useCallback)(e=>{let r=e.target.value;me||gt(r),fe?.(r),N(1)},[me,fe,N]),lr=(0,n.useCallback)(e=>{let r=[...U.filter(a=>a.column!==e.column),e];X||Me(r),ne?.(r),N(1)},[U,X,ne,N]),dr=(0,n.useCallback)(e=>{let r=U.filter(a=>a.column!==e);X||Me(r),ne?.(r),N(1)},[U,X,ne,N]),cr=(0,n.useCallback)(e=>{let r=Y.includes(e)?Y.filter(a=>a!==e):[...Y,e];Re||_t(r),tt?.(r)},[Y,Re,tt]),ur=(0,n.useCallback)((e,r)=>{e.preventDefault(),e.stopPropagation(),Oe.current=!0;let a=e.clientX,s=Fe[r]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,l=d.find(x=>x.key===r),m=l?.minWidth??50,v=l?.maxWidth??1/0,te=x=>{let q=x.clientX-a,M=Math.min(v,Math.max(m,s+q));Jt(pe=>({...pe,[r]:M}))},p=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",p),setTimeout(()=>{Oe.current=!1},0)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",p)},[Fe,d]),T=se&&!(b==="client"&&B.some(e=>e.direction)),gr=(0,n.useCallback)((e,r)=>{T&&Pe({key:e,sourceIndex:r})},[T]),pr=(0,n.useCallback)(e=>{!T||Q===null||e.preventDefault()},[T,Q]),mr=(0,n.useCallback)((e,r)=>{!T||Q===null||(Pe(null),Q.key!==e&&Ye?.(Q.sourceIndex,r))},[T,Q,Ye]),br=(0,n.useCallback)(e=>{K&&pt(e)},[K]),yr=(0,n.useCallback)(e=>{if(!K||!le||le===e)return;let r=[...xe],a=r.indexOf(le),s=r.indexOf(e);a===-1||s===-1||(r.splice(a,1),r.splice(s,0,le),Qt(r),Ze?.(le,e),pt(null))},[K,le,xe,Ze]),Be=(0,n.useCallback)(e=>{let r=I.filter(x=>x.type!=="actions"&&x.type!=="selection"&&x.type!=="expand"),a=ce,s,l,m;if(e==="csv")s=(0,Nt.csvDocument)([r.map(x=>String(x.header)),...a.map(x=>r.map(q=>{let M=F(x,q.key);return typeof M=="number"?M:String(M??"")}))],{neutralizeFormulas:ot}),l="text/csv",m="csv";else{let x=a.map(q=>{let M={};for(let pe of r)M[pe.key]=F(q,pe.key);return M});s=JSON.stringify(x,null,2),l="application/json",m="json"}let v=new Blob([s],{type:l}),te=URL.createObjectURL(v),p=document.createElement("a");p.href=te,p.download=`${nt}.${m}`,p.click(),URL.revokeObjectURL(te)},[I,ce,nt,ot]);(0,n.useEffect)(()=>{if(!we)return;let e=r=>{Ie.current&&!Ie.current.contains(r.target)&&mt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[we]),(0,n.useImperativeHandle)(i,()=>({getVisibleData:()=>j,resetFilters:()=>{X||Me([]),me||gt(""),ne?.([]),fe?.(""),N(1)},resetSort:()=>{S||ct([]),w?.([])},selectAll:Ve,deselectAll:xt,exportData:Be,scrollToRow:e=>{ze.current&&_&&(ze.current.scrollTop=e*J)}}),[j,X,me,S,ne,fe,w,N,Ve,xt,Be,_,J]);let Ue=e=>{let r={},a=Fe[e.key]??e.width;return a&&(r.width=typeof a=="number"?`${a}px`:a,r.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(r.position="sticky",r[e.sticky]=0,r.zIndex=10),r},ge=I.length+(z?1:0)+(oe?1:0)+(se?1:0),fr=e=>{let r=L&&e.sortable!==!1&&e.type!=="actions",a=B.find(l=>l.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,t.jsxs)("th",{className:(0,f.cn)(k[h],Ne[h],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",r&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",De&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Ot),style:Ue(e),onClick:r?()=>{Oe.current||tr(e.key)}:void 0,draggable:K,onDragStart:K?()=>br(e.key):void 0,onDragOver:K?l=>l.preventDefault():void 0,onDrop:K?()=>yr(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,r&&(0,t.jsx)("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?(0,t.jsx)(Dr,{}):a?.direction==="desc"?(0,t.jsx)(Er,{}):(0,t.jsx)(Gr,{})}),s&&(0,t.jsx)(Wr,{column:e,value:U.find(l=>l.column===e.key),onApply:lr,onClear:()=>dr(e.key),labels:y})]}),e.resizable!==!1&&(0,t.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:l=>ur(l,e.key)})]},e.key)},je=(e,r)=>{let{row:a,sourceIndex:s}=e,l=ft(e),m=He.has(l),v=be.includes(l),te=typeof Ge=="function"?Ge(a,r):Ge;return(0,t.jsxs)(n.default.Fragment,{children:[(0,t.jsxs)("tr",{className:(0,f.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",st&&r%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",m&&"bg-blue-50 dark:bg-blue-900/20",Ee&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Q?.key===l&&"opacity-50",te),onClick:Ee?()=>Ee(a,r):void 0,onDoubleClick:lt?()=>lt(a,r):void 0,onContextMenu:dt?p=>dt(a,r,p):void 0,draggable:T,onDragStart:T?()=>gr(l,s):void 0,onDragOver:T?pr:void 0,onDrop:T?()=>mr(l,s):void 0,onDragEnd:T?()=>Pe(null):void 0,"data-row-key":l,"aria-selected":z?m:void 0,children:[se&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],T?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,t.jsx)(Fr,{})}),z&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],"w-10"),children:(0,t.jsx)("input",{type:"checkbox",checked:m,onChange:()=>ar(l),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,D.formatUILabel)(y.dataGridSelectRow,{row:l})})}),oe&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],"w-10"),children:(0,t.jsx)("button",{type:"button",onClick:p=>{p.stopPropagation(),sr(l)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":v?y.dataGridCollapseRow:y.dataGridExpandRow,"aria-expanded":v,children:(0,t.jsx)(kt,{className:(0,f.cn)("transition-transform",v&&"rotate-180")})})}),I.map(p=>{let x=F(a,p.key),q=p.colSpan?.(a,r);if(q===0)return null;let M=Qe&&p.editable!==!1&&p.type!=="actions";return(0,t.jsx)("td",{className:(0,f.cn)(k[h],Ne[h],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",De&&"border border-gray-200 dark:border-gray-700",p.sticky&&(m?"bg-blue-50 dark:bg-blue-900/20":st&&r%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,It),style:Ue(p),colSpan:q,children:M?(0,t.jsx)(Br,{value:x,onSave:pe=>Rt?.(l,p.key,pe),density:h,labels:y}):p.render?p.render(x,a,r):String(x??"")},p.key)})]}),oe&&v&&_e&&(0,t.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)(k[h]),children:_e(a,r)})})]},l)},hr=()=>{if(Et)return Array.from({length:Gt}).map((e,r)=>(0,t.jsx)(Kr,{cols:ge,density:h},r));if(j.length===0)return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)("text-center text-gray-400 dark:text-gray-500",k[h]),children:Mt??y.dataGridNoData})});if(ht){let e=[],r=0;for(let[a,s]of ht){let l=Yt.has(a);if(e.push((0,t.jsx)("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)(k[h],"cursor-pointer"),onClick:()=>{Zt(m=>{let v=new Set(m);return v.has(a)?v.delete(a):v.add(a),v})},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(kt,{className:(0,f.cn)("transition-transform",l&&"-rotate-90")}),rt?rt(a,F(s[0].row,Array.isArray(W)?W[0]:W),s.map(m=>m.row)):`${a} (${s.length})`]})})},`group-${a}`)),l)r+=s.length;else for(let m=0;m<s.length;m++)e.push(je(s[m],r)),r++}return e}if(_){let e=[];for(let r=ue.start;r<ue.end;r++)e.push(je(A[r],r));return(0,t.jsxs)(t.Fragment,{children:[ue.start>0&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,style:{height:ue.start*J,padding:0}})}),e,ue.end<j.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,style:{height:(j.length-ue.end)*J,padding:0}})})]})}return A.map((e,r)=>je(e,r))},vr=()=>!Pt||!I.some(r=>r.aggregate)?null:(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[se&&(0,t.jsx)("td",{className:k[h]}),z&&(0,t.jsx)("td",{className:k[h]}),oe&&(0,t.jsx)("td",{className:k[h]}),I.map(r=>(0,t.jsx)("td",{className:(0,f.cn)(k[h],Ne[h],"text-gray-700 dark:text-gray-300",r.align==="center"&&"text-center",r.align==="right"&&"text-right",De&&"border border-gray-200 dark:border-gray-700"),style:Ue(r),children:r.aggregate?r.renderAggregate?r.renderAggregate(Ct(ce,r.key,r.aggregate),ce):Vr(r.aggregate,Ct(ce,r.key,r.aggregate).toLocaleString(),y):""},r.key))]})});return(0,t.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-3",zt),children:[(Xe||at||et)&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[Xe&&(0,t.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,t.jsx)(Mr,{})}),(0,t.jsx)("input",{type:"text",value:ke,onChange:ir,placeholder:St??y.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":y.dataGridSearch})]}),C.length>0&&(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,D.formatUILabel)(y.dataGridSelectedCount,{count:C.length})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[et&&(0,t.jsxs)("div",{className:"relative",ref:Ie,children:[(0,t.jsx)("button",{type:"button",onClick:()=>mt(!we),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridToggleColumns,title:y.dataGridToggleColumns,children:(0,t.jsx)(Ir,{})}),we&&(0,t.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:d.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!Y.includes(e.key),onChange:()=>cr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),at&&Tt.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>Be(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:(0,D.formatUILabel)(y.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,t.jsx)(zr,{}),e.toUpperCase()]},e))]})]}),(0,t.jsx)("div",{ref:ze,className:(0,f.cn)("overflow-auto rounded-lg",!Dt&&"border border-gray-200 dark:border-gray-700",it&&"relative"),style:he?{maxHeight:typeof he=="number"?`${he}px`:he}:_?{maxHeight:Te,overflow:"auto"}:void 0,onScroll:_?e=>er(e.target.scrollTop):void 0,children:(0,t.jsxs)("table",{className:"w-full text-left",children:[(0,t.jsx)("thead",{className:(0,f.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",it&&"sticky top-0 z-20"),children:(0,t.jsxs)("tr",{children:[se&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),z&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10"),children:g==="multiple"&&(0,t.jsx)("input",{type:"checkbox",checked:We,ref:e=>{e&&(e.indeterminate=or)},onChange:We?nr:Ve,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":y.dataGridSelectAllRows})}),oe&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),I.map(fr)]})}),(0,t.jsx)("tbody",{children:hr()}),vr()]})}),de&&(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[de.showTotalItems!==!1&&(0,t.jsx)("span",{children:(0,D.formatUILabel)(Ae===1?y.dataGridItemCount:y.dataGridItemsCount,{count:Ae})}),de.showPageSizeSelector!==!1&&de.pageSizeOptions&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:y.dataGridRowsPerPage}),(0,t.jsx)("select",{value:ye,onChange:e=>rr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:de.pageSizeOptions.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"mr-2",children:(0,D.formatUILabel)(y.dataGridPageOf,{page:O,total:ee})}),(0,t.jsx)("button",{type:"button",onClick:()=>N(1),disabled:O<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridFirstPage,children:"\xAB\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(O-1),disabled:O<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridPreviousPage,children:"\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(O+1),disabled:O>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridNextPage,children:"\xBB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(ee),disabled:O>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var jr=(0,n.forwardRef)(Ur);0&&(module.exports={DataGrid,resetRowKeyWarning});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";import sr,{useState as h,useRef as ve,useCallback as v,useEffect as Ge,useMemo as ce,forwardRef as lr,useImperativeHandle as ir}from"react";import{cn as b}from"../../lib/cn.js";import{Fragment as Cr,jsx as r,jsxs as l}from"react/jsx-runtime";var x={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},he={compact:"text-xs",default:"text-sm",comfortable:"text-base"},dr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l4 5H4l4-5z"})}),cr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 13l4-5H4l4 5z"})}),gr=()=>r("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),dt=({className:o})=>r("svg",{className:b("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),ur=()=>r("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),pr=()=>r("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),mr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),br=()=>l("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[r("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),r("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),yr=()=>r("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function fe(o,d,i){return typeof i=="function"?i(o,d):String(typeof i=="string"?o[i]:d)}function z(o,d){return o[d]}function fr(o,d){return o==null&&d==null?0:o==null?-1:d==null?1:typeof o=="number"&&typeof d=="number"?o-d:String(o).localeCompare(String(d))}function hr(o,d){let i=String(o??"").toLowerCase(),g=d.value.toLowerCase();switch(d.operator){case"contains":return i.includes(g);case"equals":return i===g;case"startsWith":return i.startsWith(g);case"endsWith":return i.endsWith(g);case"gt":return Number(o)>Number(d.value);case"gte":return Number(o)>=Number(d.value);case"lt":return Number(o)<Number(d.value);case"lte":return Number(o)<=Number(d.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function ct(o,d,i){let g=[];for(let y of o){let u=Number(z(y,d));isNaN(u)||g.push(u)}if(g.length===0)return 0;switch(i){case"sum":return g.reduce((y,u)=>y+u,0);case"avg":return g.reduce((y,u)=>y+u,0)/g.length;case"count":return g.length;case"min":return Math.min(...g);case"max":return Math.max(...g)}}function vr({cols:o,density:d}){return r("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((i,g)=>r("td",{className:x[d],children:r("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},g))})}function xr({column:o,value:d,onApply:i,onClear:g}){let[y,u]=h(!1),[P,A]=h(d?.operator??"contains"),[S,T]=h(d?.value??""),V=ve(null),D=o.filterType??"text",ne=D==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return Ge(()=>{let p=ge=>{V.current&&!V.current.contains(ge.target)&&u(!1)};return y&&document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[y]),l("div",{className:"relative inline-block",ref:V,children:[r("button",{type:"button",onClick:p=>{p.stopPropagation(),u(!y)},className:b("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",d&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(o.header)}`,children:r(mr,{})}),y&&r("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:D==="select"&&o.filterOptions?l("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(p=>l("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r("input",{type:"radio",name:`filter-${o.key}`,value:p,checked:S===p,onChange:()=>T(p),className:"cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:p})]},p)),l("div",{className:"flex gap-2 mt-2",children:[r("button",{type:"button",onClick:()=>{i({column:o.key,operator:"equals",value:S}),u(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),r("button",{type:"button",onClick:()=>{T(""),g(),u(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):l("div",{className:"flex flex-col gap-2",children:[r("select",{value:P,onChange:p=>A(p.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:ne.map(p=>r("option",{value:p.value,children:p.label},p.value))}),P!=="isEmpty"&&P!=="isNotEmpty"&&r("input",{type:D==="number"?"number":D==="date"?"date":"text",value:S,onChange:p=>T(p.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":`Filter ${String(o.header)} value`}),l("div",{className:"flex gap-2",children:[r("button",{type:"button",onClick:()=>{i({column:o.key,operator:P,value:S}),u(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),r("button",{type:"button",onClick:()=>{T(""),g(),u(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function kr({value:o,onSave:d,density:i}){let[g,y]=h(!1),[u,P]=h(String(o??"")),A=ve(null);if(Ge(()=>{g&&A.current&&(A.current.focus(),A.current.select())},[g]),!g)return r("div",{onDoubleClick:()=>{P(String(o??"")),y(!0)},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(o??"")});let S=()=>{y(!1),u!==String(o??"")&&d(u)};return r("input",{ref:A,type:"text",value:u,onChange:T=>P(T.target.value),onBlur:S,"aria-label":"Edit cell value",onKeyDown:T=>{T.key==="Enter"&&S(),T.key==="Escape"&&y(!1)},className:b("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",he[i])})}function wr(o,d){let{columns:i,data:g,rowKey:y,mode:u="client",sortable:P=!1,multiSort:A=!1,sort:S,defaultSort:T,onSort:V,pagination:D=!1,page:ne,onPageChange:p,onPageSizeChange:ge,totalItems:gt,selectable:oe=!1,selectionMode:xe="multiple",selectedRows:K,onSelectionChange:Q,searchable:Be=!1,searchPlaceholder:ut="Search...",searchValue:se,onSearch:ue,filters:j,onFilterChange:Y,expandable:le=!1,expandedContent:Ke,expandedRows:ke,onExpandChange:je,editable:pt=!1,onCellEdit:mt,reorderable:w=!1,onReorder:$e,columnReorderable:O=!1,onColumnReorder:qe,columnToggle:Ue=!1,hiddenColumns:we,onColumnVisibilityChange:Xe,groupBy:W,renderGroupHeader:_e,exportable:Je=!1,exportFormats:bt=["csv","json"],exportFilename:Qe="export",virtualized:$=!1,rowHeight:q=40,virtualHeight:Ce=400,density:f="default",striped:Ye=!1,bordered:Ne=!1,borderless:yt=!1,stickyHeader:Ze=!1,maxHeight:pe,loading:ft=!1,loadingRows:ht=5,emptyState:vt,showFooter:xt=!1,onRowClick:Se,onRowDoubleClick:et,onRowContextMenu:tt,className:kt,rowClassName:Re,cellClassName:wt,headerClassName:Ct}=o,[Nt,rt]=h(T??[]),[St,Rt]=h(1),[Tt,Dt]=h(typeof D=="object"?D.pageSize??10:10),[Mt,Te]=h([]),[Et,at]=h(""),[Ft,De]=h([]),[zt,Pt]=h([]),[At,Ht]=h(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Me,It]=h({}),[me,Lt]=h(()=>i.map(e=>e.key)),[U,nt]=h(null),[Z,ot]=h(null),[be,st]=h(!1),[Vt,Ot]=h(new Set),Ee=ve(null),[lt,Wt]=h(0),Fe=ve(null),X=S??Nt,H=ne??St,M=K??Mt,ye=se??Et,G=j??Ft,ie=ke??zt,_=we??At,I=D?typeof D=="object"?D:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,de=I?.pageSize??Tt,L=ce(()=>{let e=new Map(i.map(n=>[n.key,n])),t=me.flatMap(n=>{let s=e.get(n);return s?[s]:[]}),a=new Set(t.map(n=>n.key));for(let n of i)a.has(n.key)||(t.push(n),a.add(n.key));return t.filter(n=>!_.includes(n.key))},[i,me,_]),R=ce(()=>{if(u==="server")return g;let e=[...g];if(ye){let t=ye.toLowerCase();e=e.filter(a=>L.some(n=>{let s=z(a,n.key);return String(s??"").toLowerCase().includes(t)}))}if(G.length>0&&(e=e.filter(t=>G.every(a=>hr(z(t,a.column),a)))),X.length>0){let t=new Map(i.map(a=>[a.key,a]));e.sort((a,n)=>{for(let s of X){if(!s.direction)continue;let m=t.get(s.key),C=m?.sortComparator?m.sortComparator(a,n):fr(z(a,s.key),z(n,s.key));if(C!==0)return s.direction==="asc"?C:-C}return 0})}return e},[g,u,ye,G,X,L,i]),it=ce(()=>{if(!W)return null;let e=Array.isArray(W)?W:[W],t=new Map;for(let a of R){let n=e.map(m=>String(z(a,m)??"")).join(" / "),s=t.get(n)??[];s.push(a),t.set(n,s)}return t},[R,W]),ze=gt??R.length,ee=Math.max(1,Math.ceil(ze/de)),Gt=ce(()=>{if(!I||u==="server")return R;let e=(H-1)*de;return R.slice(e,e+de)},[R,I,H,de,u]),k=I?Gt:R,te=ce(()=>{if(!$)return{start:0,end:k.length};let e=Math.floor(lt/q),t=Math.ceil(Ce/q),a=5;return{start:Math.max(0,e-a),end:Math.min(k.length,e+t+a)}},[$,lt,q,Ce,k.length]),Pe=v(e=>{S||rt(e),V?.(e)},[S,V]),Bt=v(e=>{let t=X.find(n=>n.key===e),a;if(!t||!t.direction?a="asc":t.direction==="asc"?a="desc":a=null,A){let n=X.filter(s=>s.key!==e);a&&n.push({key:e,direction:a}),Pe(n)}else Pe(a?[{key:e,direction:a}]:[])},[X,A,Pe]),B=v(e=>{let t=Math.max(1,Math.min(e,ee));ne||Rt(t),p?.(t)},[ne,p,ee]),Kt=v(e=>{Dt(e),B(1),ge?.(e)},[B,ge]),jt=v(e=>{let t;xe==="single"?t=M.includes(e)?[]:[e]:t=M.includes(e)?M.filter(a=>a!==e):[...M,e],K||Te(t),Q?.(t)},[xe,M,K,Q]),Ae=v(()=>{let e=k.map((t,a)=>fe(t,a,y));K||Te(e),Q?.(e)},[k,y,K,Q]),He=v(()=>{K||Te([]),Q?.([])},[K,Q]),Ie=k.length>0&&k.every((e,t)=>M.includes(fe(e,t,y))),$t=!Ie&&k.some((e,t)=>M.includes(fe(e,t,y))),qt=v(e=>{let t=ie.includes(e)?ie.filter(a=>a!==e):[...ie,e];ke||Pt(t),je?.(t)},[ie,ke,je]),Ut=v(e=>{let t=e.target.value;se||at(t),ue?.(t),B(1)},[se,ue,B]),Xt=v(e=>{let t=[...G.filter(a=>a.column!==e.column),e];j||De(t),Y?.(t)},[G,j,Y]),_t=v(e=>{let t=G.filter(a=>a.column!==e);j||De(t),Y?.(t)},[G,j,Y]),Jt=v(e=>{let t=_.includes(e)?_.filter(a=>a!==e):[..._,e];we||Ht(t),Xe?.(t)},[_,we,Xe]),Qt=v((e,t)=>{e.preventDefault(),e.stopPropagation();let a=e.clientX,n=Me[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,s=i.find(N=>N.key===t),m=s?.minWidth??50,C=s?.maxWidth??1/0,c=N=>{let J=N.clientX-a,F=Math.min(C,Math.max(m,n+J));It(ae=>({...ae,[t]:F}))},E=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",E)},[Me,i]),Yt=v(e=>{w&&nt(e)},[w]),Zt=v((e,t)=>{!w||U===null||e.preventDefault()},[w,U]),er=v(e=>{!w||U===null||U===e||($e?.(U,e),nt(null))},[w,U,$e]),tr=v(e=>{O&&ot(e)},[O]),rr=v(e=>{if(!O||!Z||Z===e)return;let t=[...me],a=t.indexOf(Z),n=t.indexOf(e);a===-1||n===-1||(t.splice(a,1),t.splice(n,0,Z),Lt(t),qe?.(Z,e),ot(null))},[O,Z,me,qe]),Le=v(e=>{let t=L.filter(N=>N.type!=="actions"&&N.type!=="selection"&&N.type!=="expand"),a=R,n,s,m;if(e==="csv"){let N=t.map(F=>String(F.header)).join(","),J=a.map(F=>t.map(ae=>{let We=String(z(F,ae.key)??"");return We.includes(",")?`"${We}"`:We}).join(","));n=[N,...J].join(`
|
|
2
|
-
`),s="text/csv",m="csv"}else{let N=a.map(J=>{let F={};for(let ae of t)F[ae.key]=z(J,ae.key);return F});n=JSON.stringify(N,null,2),s="application/json",m="json"}let C=new Blob([n],{type:s}),c=URL.createObjectURL(C),E=document.createElement("a");E.href=c,E.download=`${Qe}.${m}`,E.click(),URL.revokeObjectURL(c)},[L,R,Qe]);Ge(()=>{if(!be)return;let e=t=>{Fe.current&&!Fe.current.contains(t.target)&&st(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[be]),ir(d,()=>({getVisibleData:()=>k,resetFilters:()=>{j||De([]),se||at(""),Y?.([]),ue?.("")},resetSort:()=>{S||rt([]),V?.([])},selectAll:Ae,deselectAll:He,exportData:Le,scrollToRow:e=>{Ee.current&&$&&(Ee.current.scrollTop=e*q)}}),[k,j,se,S,Y,ue,V,Ae,He,Le,$,q]);let Ve=e=>{let t={},a=Me[e.key]??e.width;return a&&(t.width=typeof a=="number"?`${a}px`:a,t.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},re=L.length+(oe?1:0)+(le?1:0)+(w?1:0),ar=e=>{let t=P&&e.sortable!==!1&&e.type!=="actions",a=X.find(s=>s.key===e.key),n=e.filterable&&(e.filterType||e.filterOptions);return l("th",{className:b(x[f],he[f],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Ne&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Ct),style:Ve(e),onClick:t?()=>Bt(e.key):void 0,draggable:O,onDragStart:O?()=>tr(e.key):void 0,onDragOver:O?s=>s.preventDefault():void 0,onDrop:O?()=>rr(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[l("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&r("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?r(dr,{}):a?.direction==="desc"?r(cr,{}):r(gr,{})}),n&&r(xr,{column:e,value:G.find(s=>s.column===e.key),onApply:Xt,onClear:()=>_t(e.key)})]}),e.resizable!==!1&&r("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:s=>Qt(s,e.key)})]},e.key)},Oe=(e,t,a)=>{let n=fe(e,a,y),s=M.includes(n),m=ie.includes(n),C=typeof Re=="function"?Re(e,a):Re;return l(sr.Fragment,{children:[l("tr",{className:b("border-b border-gray-200 dark:border-gray-700 transition-colors",Ye&&a%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",s&&"bg-blue-50 dark:bg-blue-900/20",Se&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",U===t&&"opacity-50",C),onClick:Se?()=>Se(e,a):void 0,onDoubleClick:et?()=>et(e,a):void 0,onContextMenu:tt?c=>tt(e,a,c):void 0,draggable:w,onDragStart:w?()=>Yt(t):void 0,onDragOver:w?c=>Zt(c,t):void 0,onDrop:w?()=>er(t):void 0,"data-row-key":n,"aria-selected":oe?s:void 0,children:[w&&r("td",{className:b(x[f],"cursor-grab active:cursor-grabbing"),children:r(pr,{})}),oe&&r("td",{className:b(x[f],"w-10"),children:r("input",{type:"checkbox",checked:s,onChange:()=>jt(n),onClick:c=>c.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${n}`})}),le&&r("td",{className:b(x[f],"w-10"),children:r("button",{type:"button",onClick:c=>{c.stopPropagation(),qt(n)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":m?"Collapse row":"Expand row","aria-expanded":m,children:r(dt,{className:b("transition-transform",m&&"rotate-180")})})}),L.map(c=>{let E=z(e,c.key),N=c.colSpan?.(e,a);if(N===0)return null;let J=pt&&c.editable!==!1&&c.type!=="actions";return r("td",{className:b(x[f],he[f],"text-gray-700 dark:text-gray-300",c.align==="center"&&"text-center",c.align==="right"&&"text-right",Ne&&"border border-gray-200 dark:border-gray-700",c.sticky&&(s?"bg-blue-50 dark:bg-blue-900/20":Ye&&a%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),c.cellClassName,wt),style:Ve(c),colSpan:N,children:J?r(kr,{value:E,onSave:F=>mt?.(n,c.key,F),density:f}):c.render?c.render(E,e,a):String(E??"")},c.key)})]}),le&&m&&Ke&&r("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:r("td",{colSpan:re,className:b(x[f]),children:Ke(e,a)})})]},n)},nr=()=>{if(ft)return Array.from({length:ht}).map((e,t)=>r(vr,{cols:re,density:f},t));if(k.length===0)return r("tr",{children:r("td",{colSpan:re,className:b("text-center text-gray-400 dark:text-gray-500",x[f]),children:vt??"No data available"})});if(it){let e=[],t=0;for(let[a,n]of it){let s=Vt.has(a);if(e.push(r("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:r("td",{colSpan:re,className:b(x[f],"cursor-pointer"),onClick:()=>{Ot(m=>{let C=new Set(m);return C.has(a)?C.delete(a):C.add(a),C})},children:l("div",{className:"flex items-center gap-2",children:[r(dt,{className:b("transition-transform",s&&"-rotate-90")}),_e?_e(a,z(n[0],Array.isArray(W)?W[0]:W),n):`${a} (${n.length})`]})})},`group-${a}`)),s)t+=n.length;else for(let m=0;m<n.length;m++)e.push(Oe(n[m],t,t)),t++}return e}if($){let e=[];for(let t=te.start;t<te.end;t++)e.push(Oe(k[t],t,t));return l(Cr,{children:[te.start>0&&r("tr",{children:r("td",{colSpan:re,style:{height:te.start*q,padding:0}})}),e,te.end<k.length&&r("tr",{children:r("td",{colSpan:re,style:{height:(k.length-te.end)*q,padding:0}})})]})}return k.map((e,t)=>Oe(e,t,t))},or=()=>!xt||!L.some(t=>t.aggregate)?null:r("tfoot",{children:l("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[w&&r("td",{className:x[f]}),oe&&r("td",{className:x[f]}),le&&r("td",{className:x[f]}),L.map(t=>r("td",{className:b(x[f],he[f],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Ne&&"border border-gray-200 dark:border-gray-700"),style:Ve(t),children:t.aggregate?t.renderAggregate?t.renderAggregate(ct(R,t.key,t.aggregate),R):`${t.aggregate==="count"?"":t.aggregate==="avg"?"Avg: ":t.aggregate==="sum"?"Total: ":t.aggregate==="min"?"Min: ":"Max: "}${ct(R,t.key,t.aggregate).toLocaleString()}`:""},t.key))]})});return l("div",{className:b("flex flex-col gap-3",kt),children:[(Be||Je||Ue)&&l("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[l("div",{className:"flex items-center gap-3 flex-1",children:[Be&&l("div",{className:"relative flex-1 max-w-xs",children:[r("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r(ur,{})}),r("input",{type:"text",value:ye,onChange:Ut,placeholder:ut,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),M.length>0&&l("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[M.length," selected"]})]}),l("div",{className:"flex items-center gap-2",children:[Ue&&l("div",{className:"relative",ref:Fe,children:[r("button",{type:"button",onClick:()=>st(!be),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:r(yr,{})}),be&&r("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>l("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[r("input",{type:"checkbox",checked:!_.includes(e.key),onChange:()=>Jt(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),Je&&bt.map(e=>l("button",{type:"button",onClick:()=>Le(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${e.toUpperCase()}`,children:[r(br,{}),e.toUpperCase()]},e))]})]}),r("div",{ref:Ee,className:b("overflow-auto rounded-lg",!yt&&"border border-gray-200 dark:border-gray-700",Ze&&"relative"),style:pe?{maxHeight:typeof pe=="number"?`${pe}px`:pe}:$?{maxHeight:Ce,overflow:"auto"}:void 0,onScroll:$?e=>Wt(e.target.scrollTop):void 0,children:l("table",{className:"w-full text-left",children:[r("thead",{className:b("bg-gray-50 dark:bg-gray-800 text-xs uppercase",Ze&&"sticky top-0 z-20"),children:l("tr",{children:[w&&r("th",{className:b(x[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),oe&&r("th",{className:b(x[f],"w-10"),children:xe==="multiple"&&r("input",{type:"checkbox",checked:Ie,ref:e=>{e&&(e.indeterminate=$t)},onChange:Ie?He:Ae,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),le&&r("th",{className:b(x[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),L.map(ar)]})}),r("tbody",{children:nr()}),or()]})}),I&&l("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[l("div",{className:"flex items-center gap-3",children:[I.showTotalItems!==!1&&l("span",{children:[ze," item",ze!==1?"s":""]}),I.showPageSizeSelector!==!1&&I.pageSizeOptions&&l("div",{className:"flex items-center gap-1.5",children:[r("span",{children:"Rows per page:"}),r("select",{value:de,onChange:e=>Kt(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:I.pageSizeOptions.map(e=>r("option",{value:e,children:e},e))})]})]}),l("div",{className:"flex items-center gap-1",children:[l("span",{className:"mr-2",children:["Page ",H," of ",ee]}),r("button",{type:"button",onClick:()=>B(1),disabled:H<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),r("button",{type:"button",onClick:()=>B(H-1),disabled:H<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),r("button",{type:"button",onClick:()=>B(H+1),disabled:H>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),r("button",{type:"button",onClick:()=>B(ee),disabled:H>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Rr=lr(wr);export{Rr as DataGrid};
|
|
1
|
+
"use client";import kr,{useState as h,useRef as xe,useCallback as x,useEffect as Qe,useMemo as X,forwardRef as Cr,useImperativeHandle as Nr}from"react";import{cn as f}from"../../lib/cn.js";import{csvDocument as Sr}from"../../lib/csv.js";import{formatUILabel as _,useUILabels as Rr}from"../../lib/i18n.js";import{Fragment as Br,jsx as r,jsxs as c}from"react/jsx-runtime";var N={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Te={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Tr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l4 5H4l4-5z"})}),Dr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 13l4-5H4l4 5z"})}),Er=()=>r("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),St=({className:s})=>r("svg",{className:f("w-4 h-4",s),viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Gr=()=>r("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),Mr=()=>r("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Fr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),Pr=()=>c("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[r("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),r("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),zr=()=>r("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function _e(s,d,i){return typeof i=="function"?i(s,d):String(typeof i=="string"?s[i]:d)}var Je=!1;function Xr(){Je=!1}function Ir(){Je||(Je=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function P(s,d){return s[d]}function Or(s,d){return s==null&&d==null?0:s==null?-1:d==null?1:typeof s=="number"&&typeof d=="number"?s-d:String(s).localeCompare(String(d))}function Ar(s,d){let i=String(s??"").toLowerCase(),u=d.value.toLowerCase();switch(d.operator){case"contains":return i.includes(u);case"equals":return i===u;case"startsWith":return i.startsWith(u);case"endsWith":return i.endsWith(u);case"gt":return Number(s)>Number(d.value);case"gte":return Number(s)>=Number(d.value);case"lt":return Number(s)<Number(d.value);case"lte":return Number(s)<=Number(d.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function Rt(s,d,i){let u=[];for(let l of s){let b=Number(P(l,d));isNaN(b)||u.push(b)}if(u.length===0)return 0;switch(i){case"sum":return u.reduce((l,b)=>l+b,0);case"avg":return u.reduce((l,b)=>l+b,0)/u.length;case"count":return u.length;case"min":return Math.min(...u);case"max":return Math.max(...u)}}function Lr(s,d,i){if(s==="count")return d;let u=s==="avg"?i.dataGridAggregateAvg:s==="sum"?i.dataGridAggregateSum:s==="min"?i.dataGridAggregateMin:i.dataGridAggregateMax;return _(u,{value:d})}function Hr({cols:s,density:d}){return r("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:s}).map((i,u)=>r("td",{className:N[d],children:r("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},u))})}function Vr({column:s,value:d,onApply:i,onClear:u,labels:l}){let b=s.filterType??"text",H=String(s.header),z=b==="number"?[{value:"equals",label:l.dataGridOperatorEquals},{value:"gt",label:l.dataGridOperatorGreaterThan},{value:"gte",label:l.dataGridOperatorGreaterOrEqual},{value:"lt",label:l.dataGridOperatorLessThan},{value:"lte",label:l.dataGridOperatorLessOrEqual}]:[{value:"contains",label:l.dataGridOperatorContains},{value:"equals",label:l.dataGridOperatorEquals},{value:"startsWith",label:l.dataGridOperatorStartsWith},{value:"endsWith",label:l.dataGridOperatorEndsWith},{value:"isEmpty",label:l.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:l.dataGridOperatorIsNotEmpty}],T=g=>g&&z.some(D=>D.value===g.operator)?g.operator:z[0].value,[G,C]=h(!1),[M,oe]=h(()=>T(d)),[J,V]=h(d?.value??""),se=xe(null),I=()=>{G||(oe(T(d)),V(d?.value??"")),C(!G)};return Qe(()=>{let g=D=>{se.current&&!se.current.contains(D.target)&&C(!1)};return G&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[G]),c("div",{className:"relative inline-block",ref:se,onClick:g=>g.stopPropagation(),children:[r("button",{type:"button",onClick:I,className:f("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",d&&"text-blue-600 dark:text-blue-400"),"aria-label":_(l.dataGridFilterColumn,{column:H}),children:r(Fr,{})}),G&&r("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:b==="select"&&s.filterOptions?c("div",{className:"flex flex-col gap-1.5",children:[s.filterOptions.map(g=>c("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r("input",{type:"radio",name:`filter-${s.key}`,value:g,checked:J===g,onChange:()=>V(g),className:"cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),c("div",{className:"flex gap-2 mt-2",children:[r("button",{type:"button",onClick:()=>{i({column:s.key,operator:"equals",value:J}),C(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:l.dataGridFilterApply}),r("button",{type:"button",onClick:()=>{V(""),u(),C(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]}):c("div",{className:"flex flex-col gap-2",children:[r("select",{value:M,onChange:g=>oe(g.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:z.map(g=>r("option",{value:g.value,children:g.label},g.value))}),M!=="isEmpty"&&M!=="isNotEmpty"&&r("input",{type:b==="number"?"number":b==="date"?"date":"text",value:J,onChange:g=>V(g.target.value),placeholder:l.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":_(l.dataGridFilterValue,{column:H})}),c("div",{className:"flex gap-2",children:[r("button",{type:"button",onClick:()=>{i({column:s.key,operator:M,value:J}),C(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:l.dataGridFilterApply}),r("button",{type:"button",onClick:()=>{V(""),u(),C(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]})})]})}function Kr({value:s,onSave:d,density:i,labels:u}){let[l,b]=h(!1),[H,z]=h(String(s??"")),T=xe(null);if(Qe(()=>{l&&T.current&&(T.current.focus(),T.current.select())},[l]),!l)return r("div",{onDoubleClick:()=>{z(String(s??"")),b(!0)},className:"cursor-text min-h-[1.5em]",title:u.dataGridEditHint,children:String(s??"")});let G=()=>{b(!1),H!==String(s??"")&&d(H)};return r("input",{ref:T,type:"text",value:H,onChange:C=>z(C.target.value),onBlur:G,"aria-label":u.dataGridEditCell,onKeyDown:C=>{C.key==="Enter"&&G(),C.key==="Escape"&&b(!1)},className:f("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Te[i])})}function Wr(s,d){let{columns:i,data:u,rowKey:l,mode:b="client",sortable:H=!1,multiSort:z=!1,sort:T,defaultSort:G,onSort:C,pagination:M=!1,page:oe,onPageChange:J,onPageSizeChange:V,totalItems:se,selectable:I=!1,selectionMode:g="multiple",selectedRows:D,onSelectionChange:K,searchable:Ye=!1,searchPlaceholder:Tt,searchValue:fe,onSearch:we,filters:Q,onFilterChange:ie,expandable:le=!1,expandedContent:Ze,expandedRows:De,onExpandChange:et,editable:tt=!1,onCellEdit:Dt,reorderable:de=!1,onReorder:rt,columnReorderable:W=!1,onColumnReorder:at,columnToggle:nt=!1,hiddenColumns:Ee,onColumnVisibilityChange:ot,groupBy:B,renderGroupHeader:st,exportable:it=!1,exportFormats:Et=["csv","json"],exportFilename:lt="export",exportNeutralizeFormulas:dt,virtualized:Y=!1,rowHeight:Z=40,virtualHeight:Ge=400,density:v="default",striped:ct=!1,bordered:Me=!1,borderless:Gt=!1,stickyHeader:ut=!1,maxHeight:ke,loading:Mt=!1,loadingRows:Ft=5,emptyState:Pt,labels:zt,showFooter:It=!1,onRowClick:Fe,onRowDoubleClick:gt,onRowContextMenu:pt,className:Ot,rowClassName:Pe,cellClassName:At,headerClassName:Lt}=s,y=Rr(zt),[Ht,mt]=h(G??[]),[Vt,Kt]=h(1),ce=typeof M=="object"?M.pageSize:void 0,[Wt,bt]=h(ce??10),[Bt,Ut]=h(ce);ce!==Bt&&(Ut(ce),ce!==void 0&&bt(ce));let[jt,Ce]=h([]),[qt,yt]=h(""),[$t,ze]=h([]),[Xt,_t]=h([]),[Jt,Qt]=h(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Ie,Yt]=h({}),[Ne,Zt]=h(()=>i.map(e=>e.key)),[ee,Oe]=h(null),[ue,ft]=h(null),[Se,ht]=h(!1),[er,tr]=h(new Set),Ae=xe(null),[vt,rr]=h(0),Le=xe(null),He=xe(!1),U=T??Ht,xt=oe??Vt,S=D??jt,Re=fe??qt,j=Q??$t,he=De??Xt,te=Ee??Jt,ge=M?typeof M=="object"?M:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,ve=Wt;!l&&(I||le||tt||de)&&Ir();let wt=e=>_e(e.row,e.sourceIndex,l),O=X(()=>{let e=new Map(i.map(n=>[n.key,n])),t=Ne.flatMap(n=>{let o=e.get(n);return o?[o]:[]}),a=new Set(t.map(n=>n.key));for(let n of i)a.has(n.key)||(t.push(n),a.add(n.key));return t.filter(n=>!te.includes(n.key))},[i,Ne,te]),re=X(()=>{let e=u.map((t,a)=>({row:t,sourceIndex:a}));if(b==="server")return e;if(Re){let t=Re.toLowerCase();e=e.filter(({row:a})=>O.some(n=>{let o=P(a,n.key);return String(o??"").toLowerCase().includes(t)}))}if(j.length>0&&(e=e.filter(({row:t})=>j.every(a=>Ar(P(t,a.column),a)))),U.length>0){let t=new Map(i.map(a=>[a.key,a]));e.sort((a,n)=>{for(let o of U){if(!o.direction)continue;let m=t.get(o.key),w=m?.sortComparator?m.sortComparator(a.row,n.row):Or(P(a.row,o.key),P(n.row,o.key));if(w!==0)return o.direction==="asc"?w:-w}return 0})}return e},[u,b,Re,j,U,O,i]),pe=X(()=>re.map(e=>e.row),[re]),kt=X(()=>{if(!B)return null;let e=Array.isArray(B)?B:[B],t=new Map;for(let a of re){let n=e.map(m=>String(P(a.row,m)??"")).join(" / "),o=t.get(n)??[];o.push(a),t.set(n,o)}return t},[re,B]),Ve=se??pe.length,ae=Math.max(1,Math.ceil(Ve/ve)),A=b==="server"&&se===void 0?xt:Math.min(Math.max(1,xt),ae),Ct=ge!==null,L=X(()=>{if(!Ct||b==="server")return re;let e=(A-1)*ve;return re.slice(e,e+ve)},[re,Ct,A,ve,b]),q=X(()=>L.map(e=>e.row),[L]),me=X(()=>{if(!Y)return{start:0,end:q.length};let e=Math.floor(vt/Z),t=Math.ceil(Ge/Z),a=5;return{start:Math.max(0,e-a),end:Math.min(q.length,e+t+a)}},[Y,vt,Z,Ge,q.length]),Ke=x(e=>{T||mt(e),C?.(e)},[T,C]),ar=x(e=>{let t=U.find(n=>n.key===e),a;if(!t||!t.direction?a="asc":t.direction==="asc"?a="desc":a=null,z){let n=U.filter(o=>o.key!==e);a&&n.push({key:e,direction:a}),Ke(n)}else Ke(a?[{key:e,direction:a}]:[])},[U,z,Ke]),R=x(e=>{let t=Math.max(1,Math.min(e,ae));oe||Kt(t),J?.(t)},[oe,J,ae]),nr=x(e=>{bt(e),R(1),V?.(e)},[R,V]),or=x(e=>{let t;g==="single"?t=S.includes(e)?[]:[e]:t=S.includes(e)?S.filter(a=>a!==e):[...S,e],D||Ce(t),K?.(t)},[g,S,D,K]),We=X(()=>new Set(S),[S]),Be=x(()=>{let e=new Set(S),t=[...S];for(let a of L){let n=_e(a.row,a.sourceIndex,l);e.has(n)||(e.add(n),t.push(n))}D||Ce(t),K?.(t)},[L,l,S,D,K]),Nt=x(()=>{D||Ce([]),K?.([])},[D,K]),sr=x(()=>{let e=new Set(L.map(a=>_e(a.row,a.sourceIndex,l))),t=S.filter(a=>!e.has(a));D||Ce(t),K?.(t)},[L,l,S,D,K]),Ue=I?L.map(wt):[],je=Ue.length>0&&Ue.every(e=>We.has(e)),ir=!je&&Ue.some(e=>We.has(e)),lr=x(e=>{let t=he.includes(e)?he.filter(a=>a!==e):[...he,e];De||_t(t),et?.(t)},[he,De,et]),dr=x(e=>{let t=e.target.value;fe||yt(t),we?.(t),R(1)},[fe,we,R]),cr=x(e=>{let t=[...j.filter(a=>a.column!==e.column),e];Q||ze(t),ie?.(t),R(1)},[j,Q,ie,R]),ur=x(e=>{let t=j.filter(a=>a.column!==e);Q||ze(t),ie?.(t),R(1)},[j,Q,ie,R]),gr=x(e=>{let t=te.includes(e)?te.filter(a=>a!==e):[...te,e];Ee||Qt(t),ot?.(t)},[te,Ee,ot]),pr=x((e,t)=>{e.preventDefault(),e.stopPropagation(),He.current=!0;let a=e.clientX,n=Ie[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,o=i.find(k=>k.key===t),m=o?.minWidth??50,w=o?.maxWidth??1/0,ne=k=>{let $=k.clientX-a,F=Math.min(w,Math.max(m,n+$));Yt(ye=>({...ye,[t]:F}))},p=()=>{document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",p),setTimeout(()=>{He.current=!1},0)};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",p)},[Ie,i]),E=de&&!(b==="client"&&U.some(e=>e.direction)),mr=x((e,t)=>{E&&Oe({key:e,sourceIndex:t})},[E]),br=x(e=>{!E||ee===null||e.preventDefault()},[E,ee]),yr=x((e,t)=>{!E||ee===null||(Oe(null),ee.key!==e&&rt?.(ee.sourceIndex,t))},[E,ee,rt]),fr=x(e=>{W&&ft(e)},[W]),hr=x(e=>{if(!W||!ue||ue===e)return;let t=[...Ne],a=t.indexOf(ue),n=t.indexOf(e);a===-1||n===-1||(t.splice(a,1),t.splice(n,0,ue),Zt(t),at?.(ue,e),ft(null))},[W,ue,Ne,at]),qe=x(e=>{let t=O.filter(k=>k.type!=="actions"&&k.type!=="selection"&&k.type!=="expand"),a=pe,n,o,m;if(e==="csv")n=Sr([t.map(k=>String(k.header)),...a.map(k=>t.map($=>{let F=P(k,$.key);return typeof F=="number"?F:String(F??"")}))],{neutralizeFormulas:dt}),o="text/csv",m="csv";else{let k=a.map($=>{let F={};for(let ye of t)F[ye.key]=P($,ye.key);return F});n=JSON.stringify(k,null,2),o="application/json",m="json"}let w=new Blob([n],{type:o}),ne=URL.createObjectURL(w),p=document.createElement("a");p.href=ne,p.download=`${lt}.${m}`,p.click(),URL.revokeObjectURL(ne)},[O,pe,lt,dt]);Qe(()=>{if(!Se)return;let e=t=>{Le.current&&!Le.current.contains(t.target)&&ht(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Se]),Nr(d,()=>({getVisibleData:()=>q,resetFilters:()=>{Q||ze([]),fe||yt(""),ie?.([]),we?.(""),R(1)},resetSort:()=>{T||mt([]),C?.([])},selectAll:Be,deselectAll:Nt,exportData:qe,scrollToRow:e=>{Ae.current&&Y&&(Ae.current.scrollTop=e*Z)}}),[q,Q,fe,T,ie,we,C,R,Be,Nt,qe,Y,Z]);let $e=e=>{let t={},a=Ie[e.key]??e.width;return a&&(t.width=typeof a=="number"?`${a}px`:a,t.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},be=O.length+(I?1:0)+(le?1:0)+(de?1:0),vr=e=>{let t=H&&e.sortable!==!1&&e.type!=="actions",a=U.find(o=>o.key===e.key),n=e.filterable&&(e.filterType||e.filterOptions);return c("th",{className:f(N[v],Te[v],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Me&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Lt),style:$e(e),onClick:t?()=>{He.current||ar(e.key)}:void 0,draggable:W,onDragStart:W?()=>fr(e.key):void 0,onDragOver:W?o=>o.preventDefault():void 0,onDrop:W?()=>hr(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[c("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&r("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?r(Tr,{}):a?.direction==="desc"?r(Dr,{}):r(Er,{})}),n&&r(Vr,{column:e,value:j.find(o=>o.column===e.key),onApply:cr,onClear:()=>ur(e.key),labels:y})]}),e.resizable!==!1&&r("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:o=>pr(o,e.key)})]},e.key)},Xe=(e,t)=>{let{row:a,sourceIndex:n}=e,o=wt(e),m=We.has(o),w=he.includes(o),ne=typeof Pe=="function"?Pe(a,t):Pe;return c(kr.Fragment,{children:[c("tr",{className:f("border-b border-gray-200 dark:border-gray-700 transition-colors",ct&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",m&&"bg-blue-50 dark:bg-blue-900/20",Fe&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",ee?.key===o&&"opacity-50",ne),onClick:Fe?()=>Fe(a,t):void 0,onDoubleClick:gt?()=>gt(a,t):void 0,onContextMenu:pt?p=>pt(a,t,p):void 0,draggable:E,onDragStart:E?()=>mr(o,n):void 0,onDragOver:E?br:void 0,onDrop:E?()=>yr(o,n):void 0,onDragEnd:E?()=>Oe(null):void 0,"data-row-key":o,"aria-selected":I?m:void 0,children:[de&&r("td",{className:f(N[v],E?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:r(Mr,{})}),I&&r("td",{className:f(N[v],"w-10"),children:r("input",{type:"checkbox",checked:m,onChange:()=>or(o),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":_(y.dataGridSelectRow,{row:o})})}),le&&r("td",{className:f(N[v],"w-10"),children:r("button",{type:"button",onClick:p=>{p.stopPropagation(),lr(o)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":w?y.dataGridCollapseRow:y.dataGridExpandRow,"aria-expanded":w,children:r(St,{className:f("transition-transform",w&&"rotate-180")})})}),O.map(p=>{let k=P(a,p.key),$=p.colSpan?.(a,t);if($===0)return null;let F=tt&&p.editable!==!1&&p.type!=="actions";return r("td",{className:f(N[v],Te[v],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",Me&&"border border-gray-200 dark:border-gray-700",p.sticky&&(m?"bg-blue-50 dark:bg-blue-900/20":ct&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,At),style:$e(p),colSpan:$,children:F?r(Kr,{value:k,onSave:ye=>Dt?.(o,p.key,ye),density:v,labels:y}):p.render?p.render(k,a,t):String(k??"")},p.key)})]}),le&&w&&Ze&&r("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:r("td",{colSpan:be,className:f(N[v]),children:Ze(a,t)})})]},o)},xr=()=>{if(Mt)return Array.from({length:Ft}).map((e,t)=>r(Hr,{cols:be,density:v},t));if(q.length===0)return r("tr",{children:r("td",{colSpan:be,className:f("text-center text-gray-400 dark:text-gray-500",N[v]),children:Pt??y.dataGridNoData})});if(kt){let e=[],t=0;for(let[a,n]of kt){let o=er.has(a);if(e.push(r("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:r("td",{colSpan:be,className:f(N[v],"cursor-pointer"),onClick:()=>{tr(m=>{let w=new Set(m);return w.has(a)?w.delete(a):w.add(a),w})},children:c("div",{className:"flex items-center gap-2",children:[r(St,{className:f("transition-transform",o&&"-rotate-90")}),st?st(a,P(n[0].row,Array.isArray(B)?B[0]:B),n.map(m=>m.row)):`${a} (${n.length})`]})})},`group-${a}`)),o)t+=n.length;else for(let m=0;m<n.length;m++)e.push(Xe(n[m],t)),t++}return e}if(Y){let e=[];for(let t=me.start;t<me.end;t++)e.push(Xe(L[t],t));return c(Br,{children:[me.start>0&&r("tr",{children:r("td",{colSpan:be,style:{height:me.start*Z,padding:0}})}),e,me.end<q.length&&r("tr",{children:r("td",{colSpan:be,style:{height:(q.length-me.end)*Z,padding:0}})})]})}return L.map((e,t)=>Xe(e,t))},wr=()=>!It||!O.some(t=>t.aggregate)?null:r("tfoot",{children:c("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[de&&r("td",{className:N[v]}),I&&r("td",{className:N[v]}),le&&r("td",{className:N[v]}),O.map(t=>r("td",{className:f(N[v],Te[v],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Me&&"border border-gray-200 dark:border-gray-700"),style:$e(t),children:t.aggregate?t.renderAggregate?t.renderAggregate(Rt(pe,t.key,t.aggregate),pe):Lr(t.aggregate,Rt(pe,t.key,t.aggregate).toLocaleString(),y):""},t.key))]})});return c("div",{className:f("flex flex-col gap-3",Ot),children:[(Ye||it||nt)&&c("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[c("div",{className:"flex items-center gap-3 flex-1",children:[Ye&&c("div",{className:"relative flex-1 max-w-xs",children:[r("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r(Gr,{})}),r("input",{type:"text",value:Re,onChange:dr,placeholder:Tt??y.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":y.dataGridSearch})]}),S.length>0&&r("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:_(y.dataGridSelectedCount,{count:S.length})})]}),c("div",{className:"flex items-center gap-2",children:[nt&&c("div",{className:"relative",ref:Le,children:[r("button",{type:"button",onClick:()=>ht(!Se),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridToggleColumns,title:y.dataGridToggleColumns,children:r(zr,{})}),Se&&r("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>c("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[r("input",{type:"checkbox",checked:!te.includes(e.key),onChange:()=>gr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),it&&Et.map(e=>c("button",{type:"button",onClick:()=>qe(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:_(y.dataGridExportAs,{format:e.toUpperCase()}),children:[r(Pr,{}),e.toUpperCase()]},e))]})]}),r("div",{ref:Ae,className:f("overflow-auto rounded-lg",!Gt&&"border border-gray-200 dark:border-gray-700",ut&&"relative"),style:ke?{maxHeight:typeof ke=="number"?`${ke}px`:ke}:Y?{maxHeight:Ge,overflow:"auto"}:void 0,onScroll:Y?e=>rr(e.target.scrollTop):void 0,children:c("table",{className:"w-full text-left",children:[r("thead",{className:f("bg-gray-50 dark:bg-gray-800 text-xs uppercase",ut&&"sticky top-0 z-20"),children:c("tr",{children:[de&&r("th",{className:f(N[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),I&&r("th",{className:f(N[v],"w-10"),children:g==="multiple"&&r("input",{type:"checkbox",checked:je,ref:e=>{e&&(e.indeterminate=ir)},onChange:je?sr:Be,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":y.dataGridSelectAllRows})}),le&&r("th",{className:f(N[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),O.map(vr)]})}),r("tbody",{children:xr()}),wr()]})}),ge&&c("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[c("div",{className:"flex items-center gap-3",children:[ge.showTotalItems!==!1&&r("span",{children:_(Ve===1?y.dataGridItemCount:y.dataGridItemsCount,{count:Ve})}),ge.showPageSizeSelector!==!1&&ge.pageSizeOptions&&c("div",{className:"flex items-center gap-1.5",children:[r("span",{children:y.dataGridRowsPerPage}),r("select",{value:ve,onChange:e=>nr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ge.pageSizeOptions.map(e=>r("option",{value:e,children:e},e))})]})]}),c("div",{className:"flex items-center gap-1",children:[r("span",{className:"mr-2",children:_(y.dataGridPageOf,{page:A,total:ae})}),r("button",{type:"button",onClick:()=>R(1),disabled:A<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridFirstPage,children:"\xAB\xAB"}),r("button",{type:"button",onClick:()=>R(A-1),disabled:A<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridPreviousPage,children:"\xAB"}),r("button",{type:"button",onClick:()=>R(A+1),disabled:A>=ae,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridNextPage,children:"\xBB"}),r("button",{type:"button",onClick:()=>R(ae),disabled:A>=ae,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var _r=Cr(Wr);export{_r as DataGrid,Xr as resetRowKeyWarning};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var R=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var A=(t,a)=>{for(var r in a)R(t,r,{get:a[r],enumerable:!0})},L=(t,a,r,s)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of W(a))!P.call(t,d)&&d!==r&&R(t,d,{get:()=>a[d],enumerable:!(s=S(a,d))||s.enumerable});return t};var V=t=>L(R({},"__esModule",{value:!0}),t);var _={};A(_,{DeviceMockup:()=>Z});module.exports=V(_);var p=require("react"),o=require("../../lib/cn.cjs"),e=require("react/jsx-runtime"),X={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}}},j=({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"})]}),I=({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"})]}),q=({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 s=r==="watch",d=a==="dark"?"text-white":"text-gray-900";return s?(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)(j,{className:d}),(0,e.jsx)(I,{className:d}),(0,e.jsx)(q,{className:d})]})]})}function E({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-400":"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 O({children:t,theme:a,screenW:r,screenH:s,showStatusBar:d,statusBarTime:i,frameColor:l,landscape:n=!1}){let h=a==="dark",c=l??(h?"#1a1a1a":"#e5e7eb");if(n){let m=Math.round(s*.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:s+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(s*.35)},"data-testid":"home-indicator"}),(0,e.jsxs)("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:r,height:s},children:[d&&(0,e.jsx)(f,{time:i,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:s},children:[d&&(0,e.jsx)(f,{time:i,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 Y({children:t,theme:a,screenW:r,screenH:s,showStatusBar:d,statusBarTime:i,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:s},children:[d&&(0,e.jsx)(f,{time:i,theme:a,device:"android"}),t]})]})}function G({children:t,theme:a,screenW:r,screenH:s,showStatusBar:d,statusBarTime:i,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:s},children:[d&&(0,e.jsx)(f,{time:i,theme:a,device:"tablet"}),t]})]})}function J({children:t,theme:a,screenW:r,screenH:s,frameColor:d}){let i=a==="dark",l=d??(i?"#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:s},children:t})]}),(0,e.jsx)("div",{className:(0,o.cn)(i?"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 K({children:t,theme:a,screenW:r,screenH:s,frameColor:d}){let i=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??(i?"#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:s},children:t})}),(0,e.jsx)("div",{className:(0,o.cn)(i?"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",i?"bg-gray-800":"bg-gray-400"),style:{width:Math.round(r*.4),height:6,borderRadius:"2px 2px 4px 4px"}})]})}function Q({children:t,theme:a,screenW:r,screenH:s,showStatusBar:d,statusBarTime:i,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:s},children:[d&&(0,e.jsx)(f,{time:i,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 U({children:t,theme:a,screenW:r,screenH:s,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)(E,{theme:a}),(0,e.jsx)("div",{className:"overflow-hidden bg-white",style:{width:r,height:s},children:t})]})}function Z({device:t="phone",src:a,alt:r="Device screen content",children:s,orientation:d="portrait",theme:i="dark",size:l="md",showStatusBar:n=!1,statusBarTime:h,animated:c=!1,scrollSpeed:w=30,frameColor:m,className:B,contentClassName:F}){let D=(0,p.useRef)(null),x=(0,p.useRef)(null),y=X[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 M=(T-k)/1e3;k=T,b.scrollTop+=w*M,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",F),style:c?{scrollBehavior:"auto"}:void 0,children:a?(0,e.jsx)("img",{src:a,alt:r,className:"w-full h-auto object-cover",draggable:!1}):s}),N={showStatusBar:n,statusBarTime:h},H=()=>{switch(t){case"phone":return(0,e.jsx)(O,{theme:i,screenW:g,screenH:u,frameColor:m,landscape:C,...N,children:v});case"android":return(0,e.jsx)(Y,{theme:i,screenW:g,screenH:u,frameColor:m,...N,children:v});case"tablet":return(0,e.jsx)(G,{theme:i,screenW:g,screenH:u,frameColor:m,...N,children:v});case"laptop":return(0,e.jsx)(J,{theme:i,screenW:g,screenH:u,frameColor:m,children:v});case"desktop":return(0,e.jsx)(K,{theme:i,screenW:g,screenH:u,frameColor:m,children:v});case"watch":return(0,e.jsx)(Q,{theme:i,screenW:g,screenH:u,frameColor:m,...N,children:v});case"browser":return(0,e.jsx)(U,{theme:i,screenW:g,screenH:u,frameColor:m,children:v})}};return(0,e.jsx)("div",{className:(0,o.cn)("inline-flex",B),"data-testid":"device-mockup","data-orientation":d,"data-theme":i,"data-size":l,children:H()})}0&&(module.exports={DeviceMockup});
|
|
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-400":"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 +1 @@
|
|
|
1
|
-
"use client";import{useRef as z,useEffect as S}from"react";import{cn as l}from"../../lib/cn.js";import{jsx as e,jsxs as s}from"react/jsx-runtime";var W={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}}},P=({className:a})=>s("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"})]}),A=({className:a})=>s("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"})]}),L=({className:a})=>s("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",i=r==="dark"?"text-white":"text-gray-900";return o?e("div",{className:l("flex items-center justify-center py-0.5",i),style:{fontSize:"8px"},children:e("span",{className:"font-medium",children:a})}):s("div",{className:l("flex items-center justify-between px-4 py-1",r==="dark"?"bg-black/20":"bg-white/20",i),style:{fontSize:"10px"},"data-testid":"status-bar",children:[e("span",{className:"font-semibold",children:a}),s("div",{className:"flex items-center gap-1",children:[e(P,{className:i}),e(A,{className:i}),e(L,{className:i})]})]})}function V({theme:a}){let r=a==="dark";return s("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:[s("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-400":"bg-white text-gray-500 border border-gray-200"),style:{fontSize:"11px"},children:s("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 X({children:a,theme:r,screenW:t,screenH:o,showStatusBar:i,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 s("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"}),s("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[i&&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 s("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"}),s("div",{className:"rounded-[2rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[i&&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 j({children:a,theme:r,screenW:t,screenH:o,showStatusBar:i,statusBarTime:d,frameColor:n}){return s("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"}),s("div",{className:"rounded-[1.5rem] overflow-hidden bg-black relative",style:{width:t,height:o},children:[i&&e(f,{time:d,theme:r,device:"android"}),a]})]})}function I({children:a,theme:r,screenW:t,screenH:o,showStatusBar:i,statusBarTime:d,frameColor:n}){return s("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%)"}}),s("div",{className:"rounded-lg overflow-hidden bg-black relative",style:{width:t,height:o},children:[i&&e(f,{time:d,theme:r,device:"tablet"}),a]})]})}function q({children:a,theme:r,screenW:t,screenH:o,frameColor:i}){let d=r==="dark",n=i??(d?"#1a1a1a":"#d1d5db"),c=t+60;return s("div",{className:"inline-flex flex-col items-center","data-testid":"device-frame","data-device":"laptop",children:[s("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 E({children:a,theme:r,screenW:t,screenH:o,frameColor:i}){let d=r==="dark";return s("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:i??(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 O({children:a,theme:r,screenW:t,screenH:o,showStatusBar:i,statusBarTime:d,frameColor:n}){let c=r==="dark",m=n??(c?"#1a1a1a":"#d1d5db"),h=Math.round(t*.7);return s("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"}),s("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"}),s("div",{className:"rounded-xl overflow-hidden bg-black",style:{width:t,height:o},children:[i&&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 Y({children:a,theme:r,screenW:t,screenH:o,frameColor:i}){return s("div",{className:"inline-flex flex-col rounded-lg shadow-xl overflow-hidden",style:{backgroundColor:i??(r==="dark"?"#1f2937":"#f3f4f6"),width:t},"data-testid":"device-frame","data-device":"browser",children:[e(V,{theme:r}),e("div",{className:"overflow-hidden bg-white",style:{width:t,height:o},children:a})]})}function K({device:a="phone",src:r,alt:t="Device screen content",children:o,orientation:i="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 D=z(null),x=z(null),y=W[a][n],C=i==="landscape"&&a!=="watch"&&a!=="browser",u=C?y.h:y.w,v=C?y.w:y.h;S(()=>{if(!h||!D.current)return;let p=D.current,k=null,R=T=>{k===null&&(k=T);let M=(T-k)/1e3;k=T,p.scrollTop+=w*M,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,className:"w-full h-auto object-cover",draggable:!1}):o}),N={showStatusBar:c,statusBarTime:m},H=()=>{switch(a){case"phone":return e(X,{theme:d,screenW:u,screenH:v,frameColor:g,landscape:C,...N,children:b});case"android":return e(j,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"tablet":return e(I,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"laptop":return e(q,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"desktop":return e(E,{theme:d,screenW:u,screenH:v,frameColor:g,children:b});case"watch":return e(O,{theme:d,screenW:u,screenH:v,frameColor:g,...N,children:b});case"browser":return e(Y,{theme:d,screenW:u,screenH:v,frameColor:g,children:b})}};return e("div",{className:l("inline-flex",B),"data-testid":"device-mockup","data-orientation":i,"data-theme":d,"data-size":n,children:H()})}export{K as DeviceMockup};
|
|
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-400":"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 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var c=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var T=(t,n)=>{for(var o in n)c(t,o,{get:n[o],enumerable:!0})},h=(t,n,o,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of L(n))!M.call(t,r)&&r!==o&&c(t,r,{get:()=>n[r],enumerable:!(l=H(n,r))||l.enumerable});return t};var N=t=>h(c({},"__esModule",{value:!0}),t);var P={};T(P,{Dropdown:()=>I,useDropdownContext:()=>k});module.exports=N(P);var e=require("react"),d=require("react/jsx-runtime"),m=(0,e.createContext)(null);function k(){let t=(0,e.useContext)(m);if(!t)throw new Error("Dropdown compound components must be used within a Dropdown");return t}var p=()=>{};function I({open:t,defaultOpen:n=!1,onOpenChange:o,closeOnSelect:l=!0,closeOnClickOutside:r=!0,closeOnEscape:x=!0,modal:b=!1,children:f}){let[g,w]=(0,e.useState)(n),s=t!==void 0,D=s?t:g,O=(0,e.useRef)(null),C=(0,e.useRef)(null),R=(0,e.useRef)([]),v=(0,e.useRef)(0),i=(0,e.useId)(),u={triggerId:`dropdown-trigger-${i}`,contentId:`dropdown-content-${i}`},E=(0,e.useCallback)(a=>{s||w(a),o?.(a)},[s,o]),S=(0,e.useCallback)(()=>v.current++,[]),y={isOpen:D,setIsOpen:E,triggerRef:O,contentRef:C,closeOnSelect:l,closeOnClickOutside:r,closeOnEscape:x,modal:b,focusedIndex:-1,setFocusedIndex:p,itemsRef:R,registerItem:p,getNextItemIndex:S,triggerId:u.triggerId,contentId:u.contentId};return(0,d.jsx)(m.Provider,{value:y,children:(0,d.jsx)("div",{className:"relative inline-block",children:f})})}I.displayName="Dropdown";0&&(module.exports={Dropdown,useDropdownContext});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as y,useContext as
|
|
1
|
+
"use client";import{createContext as y,useContext as H,useState as L,useRef as t,useCallback as c,useId as M}from"react";import{jsx as i}from"react/jsx-runtime";var u=y(null);function N(){let e=H(u);if(!e)throw new Error("Dropdown compound components must be used within a Dropdown");return e}var d=()=>{};function T({open:e,defaultOpen:a=!1,onOpenChange:o,closeOnSelect:p=!0,closeOnClickOutside:m=!0,closeOnEscape:I=!0,modal:x=!1,children:b}){let[f,g]=L(a),n=e!==void 0,w=n?e:f,D=t(null),O=t(null),C=t([]),R=t(0),r=M(),l={triggerId:`dropdown-trigger-${r}`,contentId:`dropdown-content-${r}`},v=c(s=>{n||g(s),o?.(s)},[n,o]),E=c(()=>R.current++,[]),S={isOpen:w,setIsOpen:v,triggerRef:D,contentRef:O,closeOnSelect:p,closeOnClickOutside:m,closeOnEscape:I,modal:x,focusedIndex:-1,setFocusedIndex:d,itemsRef:C,registerItem:d,getNextItemIndex:E,triggerId:l.triggerId,contentId:l.contentId};return i(u.Provider,{value:S,children:i("div",{className:"relative inline-block",children:b})})}T.displayName="Dropdown";export{T as Dropdown,N as useDropdownContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},I=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of w(e))!N.call(t,o)&&o!==r&&d(t,o,{get:()=>e[o],enumerable:!(s=y(e,o))||s.enumerable});return t};var M=t=>I(d({},"__esModule",{value:!0}),t);var D={};v(D,{DropdownCheckboxItem:()=>b});module.exports=M(D);var h=require("react"),k=require("./Dropdown.cjs"),i=require("../../lib/cn.cjs"),n=require("react/jsx-runtime");function b({checked:t,defaultChecked:e=!1,onCheckedChange:r,children:s,icon:o,description:u,disabled:a=!1,closeOnChange:m=!1,className:f}){let{setIsOpen:g}=(0,k.useDropdownContext)(),[x,C]=(0,h.useState)(e),p=t!==void 0,c=p?t:x;return(0,n.jsxs)("button",{role:"menuitemcheckbox",type:"button",tabIndex:-1,"aria-checked":c,disabled:a,"data-disabled":a||void 0,onClick:()=>{if(a)return;let l=!c;p||C(l),r?.(l),m&&g(!1)},onMouseEnter:l=>{a||l.currentTarget.focus({preventScroll:!0})},className:(0,i.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",a&&"opacity-50 cursor-not-allowed hover:bg-transparent",f),children:[(0,n.jsx)("span",{className:"mr-2 shrink-0 w-4 h-4",children:o||(0,n.jsx)("span",{className:(0,i.cn)("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",c?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:c&&(0,n.jsx)("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block truncate",children:s}),u&&(0,n.jsx)("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:u})]})]})}b.displayName="DropdownCheckboxItem";0&&(module.exports={DropdownCheckboxItem});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as g}from"react";import{useDropdownContext as x}from"./Dropdown.js";import{cn as c}from"../../lib/cn.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";function C({checked:r,defaultChecked:d=!1,onCheckedChange:i,children:u,icon:p,description:a,disabled:t=!1,closeOnChange:h=!1,className:k}){let{setIsOpen:b}=x(),[m,f]=g(d),s=r!==void 0,n=s?r:m;return l("button",{role:"menuitemcheckbox",type:"button",tabIndex:-1,"aria-checked":n,disabled:t,"data-disabled":t||void 0,onClick:()=>{if(t)return;let o=!n;s||f(o),i?.(o),h&&b(!1)},onMouseEnter:o=>{t||o.currentTarget.focus({preventScroll:!0})},className:c("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",t&&"opacity-50 cursor-not-allowed hover:bg-transparent",k),children:[e("span",{className:"mr-2 shrink-0 w-4 h-4",children:p||e("span",{className:c("flex items-center justify-center w-4 h-4 rounded border-2 transition-colors",n?"bg-blue-600 border-blue-600":"border-gray-300 dark:border-gray-600"),children:n&&e("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 16 16",fill:"none",children:e("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}),l("span",{className:"flex-1 min-w-0",children:[e("span",{className:"block truncate",children:u}),a&&e("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]})]})}C.displayName="DropdownCheckboxItem";export{C as DropdownCheckboxItem};
|