@synertech/ui 0.50.0 → 0.51.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 +19 -10
- package/dist/components/accordion/Accordion.cjs +1 -1
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
- package/dist/components/chart/ChartPeriodPicker.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.js +1 -1
- package/dist/components/detachable/Detachable.cjs +1 -1
- package/dist/components/detachable/Detachable.js +1 -1
- package/dist/components/detachable/useMovableContent.cjs +1 -0
- package/dist/components/detachable/useMovableContent.js +1 -0
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
- package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
- package/dist/components/dropdown/hooks/usePositioning.js +1 -1
- package/dist/components/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 +4 -1
- package/dist/components/form/mention-input/MentionInput.js +4 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
- package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
- package/dist/components/schema-editor/utils/import.cjs +1 -0
- package/dist/components/schema-editor/utils/import.js +1 -0
- package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
- package/dist/components/schema-editor/utils/sql-export.js +7 -6
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/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/nodes/WorkflowNodeRenderer.cjs +1 -1
- package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/components/workflow-editor/utils/import.cjs +1 -0
- package/dist/components/workflow-editor/utils/import.js +1 -0
- package/dist/hooks/useDialogA11y.cjs +1 -1
- package/dist/hooks/useDialogA11y.js +1 -1
- package/dist/index.d.cts +93 -14
- package/dist/index.d.ts +93 -14
- package/dist/lib/canvas-events.cjs +1 -0
- package/dist/lib/canvas-events.js +1 -0
- package/dist/lib/dialog-stack.cjs +1 -1
- package/dist/lib/dialog-stack.js +1 -1
- package/dist/lib/layer-document.cjs +1 -0
- package/dist/lib/layer-document.js +1 -0
- package/dist/lib/owner-document.cjs +1 -0
- package/dist/lib/owner-document.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -1
- package/dist/lib/ui-labels.js +1 -1
- package/dist/styles.css +129 -462
- package/package.json +1 -1
|
@@ -269,7 +269,7 @@ import { cn } from "@synertech/ui";
|
|
|
269
269
|
| `Checkbox` | Case à cocher | Non |
|
|
270
270
|
| `RadioButton` | Bouton radio | Non |
|
|
271
271
|
| `Slider` | Curseur (range) accessible avec marques et tooltip | Non |
|
|
272
|
-
| `ImageUploader` | Upload d'image (
|
|
272
|
+
| `ImageUploader` | Upload d'image (bouton et URL, sans glisser-déposer : c'est `FileSelector`) | Non |
|
|
273
273
|
| `FileSelector` | Sélection de fichiers/dossiers (drag & drop, validation) | Non |
|
|
274
274
|
|
|
275
275
|
### Layout & Structure
|
|
@@ -729,6 +729,11 @@ import { ImageUploader } from "@synertech/ui";
|
|
|
729
729
|
/>
|
|
730
730
|
```
|
|
731
731
|
|
|
732
|
+
> Le champ URL transmet son adresse quand on le quitte ou sur Entrée, jamais à chaque frappe :
|
|
733
|
+
> `onChange` ne reçoit pas les adresses incomplètes. Une adresse relative (celle que renvoie
|
|
734
|
+
> souvent `onUpload`) est acceptée et ne bloque pas le formulaire. Pas de glisser-déposer :
|
|
735
|
+
> pour déposer des fichiers, prendre `FileSelector`.
|
|
736
|
+
|
|
732
737
|
### Charts
|
|
733
738
|
|
|
734
739
|
Tous les graphiques partagent la même forme de données : un tableau de lignes
|
|
@@ -1199,11 +1204,9 @@ import { Table, TableHeader, TableHeaderCell, TableBody, TableRow, TableCell } f
|
|
|
1199
1204
|
|
|
1200
1205
|
<Table>
|
|
1201
1206
|
<TableHeader>
|
|
1202
|
-
<
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
<TableHeaderCell>Role</TableHeaderCell>
|
|
1206
|
-
</TableRow>
|
|
1207
|
+
<TableHeaderCell>Nom</TableHeaderCell>
|
|
1208
|
+
<TableHeaderCell>Email</TableHeaderCell>
|
|
1209
|
+
<TableHeaderCell>Role</TableHeaderCell>
|
|
1207
1210
|
</TableHeader>
|
|
1208
1211
|
<TableBody>
|
|
1209
1212
|
{users.map((user) => (
|
|
@@ -1217,6 +1220,11 @@ import { Table, TableHeader, TableHeaderCell, TableBody, TableRow, TableCell } f
|
|
|
1217
1220
|
</Table>
|
|
1218
1221
|
```
|
|
1219
1222
|
|
|
1223
|
+
`TableHeader` dessine sa propre ligne : mettez-y les `TableHeaderCell` directement, **jamais un
|
|
1224
|
+
`TableRow`**. Ce serait un `<tr>` dans un `<tr>` : React signale une erreur d'hydratation, et
|
|
1225
|
+
rendus côté client les titres se tassent tous dans la première colonne. `TableRow` est une ligne
|
|
1226
|
+
du corps, dans `TableBody`.
|
|
1227
|
+
|
|
1220
1228
|
### Chip
|
|
1221
1229
|
|
|
1222
1230
|
```tsx
|
|
@@ -1558,6 +1566,9 @@ const ref = useRef<DetachableRef>(null);
|
|
|
1558
1566
|
<Button onClick={() => ref.current?.attach()}>Rattacher</Button>
|
|
1559
1567
|
```
|
|
1560
1568
|
|
|
1569
|
+
Ce que le contenu detache ouvre s'ouvre dans sa fenetre : liste de `Select`,
|
|
1570
|
+
menu de `Dropdown`, `ChartPeriodPicker`, `Modal`, `Drawer`. Rien a passer.
|
|
1571
|
+
|
|
1561
1572
|
### AdvanceDetachable
|
|
1562
1573
|
|
|
1563
1574
|
```tsx
|
|
@@ -2122,10 +2133,8 @@ export default function DashboardPage() {
|
|
|
2122
2133
|
<CardBody>
|
|
2123
2134
|
<Table>
|
|
2124
2135
|
<TableHeader>
|
|
2125
|
-
<
|
|
2126
|
-
|
|
2127
|
-
<TableHeaderCell>Statut</TableHeaderCell>
|
|
2128
|
-
</TableRow>
|
|
2136
|
+
<TableHeaderCell>Nom</TableHeaderCell>
|
|
2137
|
+
<TableHeaderCell>Statut</TableHeaderCell>
|
|
2129
2138
|
</TableHeader>
|
|
2130
2139
|
<TableBody>
|
|
2131
2140
|
<TableRow>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var A=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var c in r)A(e,c,{get:r[c],enumerable:!0})},M=(e,r,c,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!D.call(e,t)&&t!==c&&A(e,t,{get:()=>r[t],enumerable:!(n=z(r,t))||n.enumerable});return e};var S=e=>M(A({},"__esModule",{value:!0}),e);var G={};H(G,{Accordion:()=>$,AccordionContent:()=>F,AccordionItem:()=>q,AccordionTrigger:()=>B});module.exports=S(G);var o=require("react"),b=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),I=(0,o.createContext)(null),C=(0,o.createContext)(null);function v(){let e=(0,o.useContext)(I);if(!e)throw new Error("Accordion sub-components must be used within <Accordion>");return e}function N(){let e=(0,o.useContext)(C);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return e}var k={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:e})=>(0,d.jsx)("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,d.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"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function $({type:e="single",value:r,defaultValue:c,onValueChange:n,collapsible:t=!1,variant:s="default",size:l="md",disabled:u=!1,iconPosition:a="right",icon:g,hideIcon:i=!1,className:m,children:w}){let[R,P]=(0,o.useState)(()=>c?Array.isArray(c)?c:[c]:[]),y=r!==void 0,p=y?Array.isArray(r)?r:[r]:R,h=(0,o.useCallback)(f=>{let x;e==="single"?p.includes(f)?x=t?[]:[f]:x=[f]:x=p.includes(f)?p.filter(T=>T!==f):[...p,f],y||P(x),n?.(e==="single"?x[0]??"":x)},[e,p,t,y,n]),O=(0,o.useMemo)(()=>({openItems:p,toggle:h,variant:s,size:l,disabled:u,iconPosition:a,icon:g??null,hideIcon:i}),[p,h,s,l,u,a,g,i]);return(0,d.jsx)(I.Provider,{value:O,children:(0,d.jsx)("div",{className:(0,b.cn)(K[s],m),"data-testid":"accordion",children:w})})}function q({value:e,disabled:r,className:c,children:n}){let t=v(),s=t.openItems.includes(e),l=r??t.disabled,u=(0,o.useId)(),a=`accordion-trigger-${u}`,g=`accordion-content-${u}`,i=(0,o.useMemo)(()=>({value:e,isOpen:s,disabled:l,triggerId:a,contentId:g}),[e,s,l,a,g]);return(0,d.jsx)(C.Provider,{value:i,children:(0,d.jsx)("div",{className:(0,b.cn)(L[t.variant],c),"data-state":s?"open":"closed","data-testid":"accordion-item",children:n})})}function B({className:e,icon:r,children:c}){let n=v(),t=N(),s=k[n.size],l=()=>{t.disabled||n.toggle(t.value)},u=i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),l())},a=r??n.icon??(0,d.jsx)(V,{className:s.icon}),g=!n.hideIcon&&(0,d.jsx)("span",{className:(0,b.cn)("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",t.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:a});return(0,d.jsxs)("button",{type:"button",id:t.triggerId,"aria-expanded":t.isOpen,"aria-controls":t.contentId,disabled:t.disabled,onClick:l,onKeyDown:u,className:(0,b.cn)("flex items-center w-full text-left font-medium transition-colors cursor-pointer",s.trigger,s.text,"text-gray-900 dark:text-gray-100",!t.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",t.disabled&&"opacity-50 cursor-not-allowed",e),"data-testid":"accordion-trigger",children:[n.iconPosition==="left"&&g,(0,d.jsx)("span",{className:"flex-1",children:c}),n.iconPosition==="right"&&g]})}function F({className:e,children:r}){let c=v(),n=N(),t=k[c.size],s=(0,o.useRef)(null),l=(0,o.useRef)(null),[u,a]=(0,o.useState)(n.isOpen?void 0:0),g=(0,o.useRef)(!0);return(0,o.useEffect)(()=>{let i=l.current;i&&(n.isOpen?i.removeAttribute("inert"):i.setAttribute("inert",""))},[n.isOpen]),(0,o.useEffect)(()=>{if(g.current){g.current=!1,a(n.isOpen?void 0:0);return}if(n.isOpen){let i=s.current;if(i){a(i.scrollHeight);let m=setTimeout(()=>a(void 0),200);return()=>clearTimeout(m)}}else{let i=s.current;i&&(a(i.scrollHeight),requestAnimationFrame(()=>a(0)))}},[n.isOpen]),(0,d.jsx)("div",{ref:l,id:n.contentId,role:"region","aria-labelledby":n.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:u===void 0?"auto":u},"data-testid":"accordion-content","data-state":n.isOpen?"open":"closed",children:(0,d.jsx)("div",{ref:s,className:(0,b.cn)(t.content,"text-gray-600 dark:text-gray-400",t.text==="text-lg"?"text-base":"text-sm",e),children:r})})}0&&(module.exports={Accordion,AccordionContent,AccordionItem,AccordionTrigger});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as
|
|
1
|
+
"use client";import{createContext as I,useContext as C,useState as N,useCallback as M,useMemo as k,useRef as y,useEffect as h,useId as S}from"react";import{cn as x}from"../../lib/cn.js";import{jsx as d,jsxs as $}from"react/jsx-runtime";var w=I(null),R=I(null);function A(){let t=C(w);if(!t)throw new Error("Accordion sub-components must be used within <Accordion>");return t}function P(){let t=C(R);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within <AccordionItem>");return t}var O={sm:{trigger:"px-3 py-2",content:"px-3 pb-2",text:"text-sm",icon:"w-3.5 h-3.5"},md:{trigger:"px-4 py-3",content:"px-4 pb-3",text:"text-base",icon:"w-4 h-4"},lg:{trigger:"px-5 py-4",content:"px-5 pb-4",text:"text-lg",icon:"w-5 h-5"}},V=({className:t})=>d("svg",{className:t,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:d("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"})}),K={default:"border border-gray-200 dark:border-gray-700 rounded-lg divide-y divide-gray-200 dark:divide-gray-700",bordered:"border-2 border-gray-300 dark:border-gray-600 rounded-lg divide-y divide-gray-300 dark:divide-gray-600",separated:"space-y-2",ghost:""},L={default:"",bordered:"",separated:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",ghost:"border-b border-gray-200 dark:border-gray-700 last:border-b-0"};function F({type:t="single",value:a,defaultValue:l,onValueChange:e,collapsible:n=!1,variant:r="default",size:c="md",disabled:g=!1,iconPosition:i="right",icon:s,hideIcon:o=!1,className:b,children:T}){let[z,E]=N(()=>l?Array.isArray(l)?l:[l]:[]),m=a!==void 0,u=m?Array.isArray(a)?a:[a]:z,v=M(p=>{let f;t==="single"?u.includes(p)?f=n?[]:[p]:f=[p]:f=u.includes(p)?u.filter(H=>H!==p):[...u,p],m||E(f),e?.(t==="single"?f[0]??"":f)},[t,u,n,m,e]),D=k(()=>({openItems:u,toggle:v,variant:r,size:c,disabled:g,iconPosition:i,icon:s??null,hideIcon:o}),[u,v,r,c,g,i,s,o]);return d(w.Provider,{value:D,children:d("div",{className:x(K[r],b),"data-testid":"accordion",children:T})})}function G({value:t,disabled:a,className:l,children:e}){let n=A(),r=n.openItems.includes(t),c=a??n.disabled,g=S(),i=`accordion-trigger-${g}`,s=`accordion-content-${g}`,o=k(()=>({value:t,isOpen:r,disabled:c,triggerId:i,contentId:s}),[t,r,c,i,s]);return d(R.Provider,{value:o,children:d("div",{className:x(L[n.variant],l),"data-state":r?"open":"closed","data-testid":"accordion-item",children:e})})}function J({className:t,icon:a,children:l}){let e=A(),n=P(),r=O[e.size],c=()=>{n.disabled||e.toggle(n.value)},g=o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),c())},i=a??e.icon??d(V,{className:r.icon}),s=!e.hideIcon&&d("span",{className:x("shrink-0 text-gray-500 dark:text-gray-400 transition-transform duration-200",n.isOpen&&"rotate-180"),"data-testid":"accordion-icon",children:i});return $("button",{type:"button",id:n.triggerId,"aria-expanded":n.isOpen,"aria-controls":n.contentId,disabled:n.disabled,onClick:c,onKeyDown:g,className:x("flex items-center w-full text-left font-medium transition-colors cursor-pointer",r.trigger,r.text,"text-gray-900 dark:text-gray-100",!n.disabled&&"hover:bg-gray-50 dark:hover:bg-gray-800/50",n.disabled&&"opacity-50 cursor-not-allowed",t),"data-testid":"accordion-trigger",children:[e.iconPosition==="left"&&s,d("span",{className:"flex-1",children:l}),e.iconPosition==="right"&&s]})}function Q({className:t,children:a}){let l=A(),e=P(),n=O[l.size],r=y(null),c=y(null),[g,i]=N(e.isOpen?void 0:0),s=y(!0);return h(()=>{let o=c.current;o&&(e.isOpen?o.removeAttribute("inert"):o.setAttribute("inert",""))},[e.isOpen]),h(()=>{if(s.current){s.current=!1,i(e.isOpen?void 0:0);return}if(e.isOpen){let o=r.current;if(o){i(o.scrollHeight);let b=setTimeout(()=>i(void 0),200);return()=>clearTimeout(b)}}else{let o=r.current;o&&(i(o.scrollHeight),requestAnimationFrame(()=>i(0)))}},[e.isOpen]),d("div",{ref:c,id:e.contentId,role:"region","aria-labelledby":e.triggerId,className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:g===void 0?"auto":g},"data-testid":"accordion-content","data-state":e.isOpen?"open":"closed",children:d("div",{ref:r,className:x(n.content,"text-gray-600 dark:text-gray-400",n.text==="text-lg"?"text-base":"text-sm",t),children:a})})}export{F as Accordion,Q as AccordionContent,G as AccordionItem,J as AccordionTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var J=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var Be=(t,c)=>{for(var l in c)J(t,l,{get:c[l],enumerable:!0})},Ve=(t,c,l,s)=>{if(c&&typeof c=="object"||typeof c=="function")for(let a of xe(c))!Oe.call(t,a)&&a!==l&&J(t,a,{get:()=>c[a],enumerable:!(s=Pe(c,a))||s.enumerable});return t};var He=t=>Ve(J({},"__esModule",{value:!0}),t);var Ke={};Be(Ke,{AdvanceDetachable:()=>Te});module.exports=He(Ke);var e=require("react"),Ee=require("react-dom"),ke=require("../detachable/useMovableContent.cjs"),j=require("../../lib/layer-document.cjs"),m=require("react/jsx-runtime");function ze(...t){return t.filter(Boolean).join(" ")}var We="@synertech/ui/AdvanceDetachable",$e=300,Ue="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Re={clock:0,writer:""};function Fe(t,c){return t.clock>c.clock||t.clock===c.clock&&t.writer>c.writer}var _e=0;function qe(){return`${Date.now()}-${++_e}-${Math.random().toString(36).slice(2,8)}`}function De(t){try{return JSON.stringify(t)}catch{return String(t)}}function Ce(t){try{return JSON.parse(t)}catch{return t}}function Je(t,c){t.querySelectorAll("style").forEach(l=>{let s=c.createElement("style");s.textContent=l.textContent,c.head.appendChild(s)}),t.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{let s=l,a=c.createElement("link");a.rel="stylesheet",a.href=s.href,s.crossOrigin&&(a.crossOrigin=s.crossOrigin),c.head.appendChild(a)}),t.documentElement.className&&(c.documentElement.className=t.documentElement.className),t.body.className&&(c.body.className=t.body.className)}function je(t,c){let l=new MutationObserver(s=>{for(let a of s)for(let h of Array.from(a.addedNodes))if(h instanceof HTMLStyleElement){let i=c.createElement("style");i.textContent=h.textContent,c.head.appendChild(i)}else if(h instanceof HTMLLinkElement&&h.rel==="stylesheet"){let i=c.createElement("link");i.rel="stylesheet",i.href=h.href,c.head.appendChild(i)}});return l.observe(t.head,{childList:!0}),l}function Xe(){return typeof BroadcastChannel<"u"}function Ge({mode:t,id:c,title:l="",children:s,value:a,defaultValue:h,onValueChange:i,isDetached:X,defaultDetached:Ne=!1,onDetachedChange:G,onPopupBlocked:K,features:Q,target:Y,autoFocus:Z=!0,className:Se,detachedBodyClassName:ee,disabled:ne=!1,readOnly:te=!1,closeOnMainWindowUnload:re=!0,name:ce,serialize:oe,deserialize:le},Ae){let u=X!==void 0,[Me,E]=(0,e.useState)(Ne),k=u?X:Me,B=a!==void 0,[Le,Ie]=(0,e.useState)(h),y=B?a:Le,[b,se]=(0,e.useState)(null),o=(0,e.useRef)(null),w=(0,e.useRef)(null),S=(0,e.useRef)(null),A=(0,e.useRef)(null),M=(0,e.useRef)(!1),T=(0,e.useRef)(null),L=(0,e.useRef)(null),I=(0,e.useRef)(null),g=(0,e.useRef)(null),d=(0,e.useRef)(Re),ae=(0,e.useRef)(null),[R]=(0,e.useState)(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),f=(0,e.useRef)({title:l,features:Q,target:Y,autoFocus:Z,detachedBodyClassName:ee,closeOnMainWindowUnload:re,disabled:ne,readOnly:te,mode:t,id:c});f.current={title:l,features:Q,target:Y,autoFocus:Z,detachedBodyClassName:ee,closeOnMainWindowUnload:re,disabled:ne,readOnly:te,mode:t,id:c};let P=(0,e.useRef)(oe??De);P.current=oe??De;let ue=(0,e.useRef)(le??Ce);ue.current=le??Ce;let ie=(0,e.useRef)(i);ie.current=i;let D=(0,e.useRef)(G);D.current=G;let de=(0,e.useRef)(K);de.current=K;let N=(0,ke.useMovableContent)(t==="detach"?b:null),V=(0,e.useRef)(N.bringBack);V.current=N.bringBack;let H=(0,e.useRef)(k);H.current=k;let fe=(0,e.useRef)(y);fe.current=y;let p=`${We}/${c}`,x=(0,e.useCallback)(()=>{T.current?.(),T.current=null,S.current&&(clearInterval(S.current),S.current=null),A.current&&(A.current.disconnect(),A.current=null),se(null)},[]),O=(0,e.useCallback)(()=>{w.current&&(w.current.close(),w.current=null),L.current&&typeof window<"u"&&(window.removeEventListener("message",L.current),L.current=null)},[]),C=(0,e.useCallback)(n=>{let r={channel:p,instanceId:R,messageId:qe(),origin:"main",timestamp:Date.now(),...n};w.current?w.current.postMessage(r):o.current&&!o.current.closed&&o.current.postMessage(r,"*")},[p,R]),z=(0,e.useCallback)(n=>{if(!n||n.channel!==p||n.instanceId===R||f.current.readOnly)return;if(n.type==="hello"){if(d.current.clock===0||g.current===null)return;C({type:"value-sync",payload:g.current,...d.current});return}if(n.type!=="value-sync"||typeof n.payload!="string")return;let r=typeof n.clock=="number"?{clock:n.clock,writer:typeof n.writer=="string"?n.writer:n.instanceId}:{clock:d.current.clock+1,writer:n.instanceId};if(!Fe(r,d.current)||(d.current=r,n.payload===g.current)||(g.current=n.payload,n.payload===I.current))return;let v=ue.current(n.payload);B||Ie(v),ie.current?.(v)},[p,R,B,C]),pe=(0,e.useCallback)(()=>{if(O(),!(typeof window>"u")){if(ae.current!==p){ae.current=p,d.current=Re,g.current=null;let n=fe.current;I.current=n===void 0?null:P.current(n)}if(Xe()){let n=new BroadcastChannel(p),r=v=>z(v.data);n.addEventListener("message",r),w.current=n}else{let n=r=>{r.data?.channel===p&&z(r.data)};window.addEventListener("message",n),L.current=n}f.current.readOnly||C({type:"hello"})}},[p,O,z,C]),me=(0,e.useCallback)(n=>{let r=P.current(n);r!==I.current&&(I.current=r,!f.current.readOnly&&r!==g.current&&(g.current=r,d.current={clock:d.current.clock+1,writer:R},C({type:"value-sync",payload:r,...d.current})))},[R,C]),he=(0,e.useCallback)(()=>{if(typeof window>"u"||f.current.disabled||M.current||o.current&&!o.current.closed)return;M.current=!0;let n=f.current,r=window.open("",n.target||"",n.features||Ue);if(!r){M.current=!1,u||E(!1),D.current?.(!1),de.current?.();return}o.current=r,r.document.title=n.title||document.title,n.detachedBodyClassName&&(r.document.body.className=n.detachedBodyClassName);let v=r.document.createElement("div");r.document.body.appendChild(v),se(v),Je(document,r.document),A.current=je(document,r.document);let we=!1,q=()=>{we||(we=!0,V.current(),x(),o.current=null,u||E(!1),D.current?.(!1))};r.addEventListener("pagehide",q),T.current=()=>r.removeEventListener("pagehide",q),S.current=setInterval(()=>{r.closed&&q()},$e),n.autoFocus&&r.focus(),M.current=!1},[u,x]),ye=(0,e.useCallback)(()=>{V.current();let n=o.current;o.current=null,x(),n&&!n.closed&&n.close()},[x]),ge=(0,e.useRef)(he);ge.current=he;let W=(0,e.useRef)(ye);W.current=ye;let ve=(0,e.useRef)(me);ve.current=me;let $=(0,e.useCallback)(()=>{f.current.disabled||(u||E(!0),D.current?.(!0))},[u]),U=(0,e.useCallback)(()=>{u||E(!1),D.current?.(!1)},[u]),F=(0,e.useCallback)(()=>{let n=!H.current;n&&f.current.disabled||(u||E(n),D.current?.(n))},[u]);(0,e.useImperativeHandle)(Ae,()=>({open:$,close:U,toggle:F,get isDetached(){return H.current},get window(){return o.current}}),[$,U,F]),(0,e.useEffect)(()=>(pe(),()=>O()),[pe,O]),(0,e.useEffect)(()=>{if(k)return ge.current(),()=>W.current();W.current()},[k]),(0,e.useEffect)(()=>{y!==void 0&&ve.current(y)},[y]),(0,e.useEffect)(()=>{o.current&&!o.current.closed&&l&&(o.current.document.title=l)},[l]),(0,e.useEffect)(()=>{if(typeof window>"u")return;let n=()=>{f.current.closeOnMainWindowUnload&&o.current&&!o.current.closed&&o.current.close()};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n);let r=o.current;T.current?.(),T.current=null,o.current=null,r&&!r.closed&&r.close()}},[]);let _=typeof s=="function"?s({open:$,close:U,toggle:F,detached:k,windowRef:o.current}):s,be=t==="detach"&&b!==null;return(0,m.jsxs)(m.Fragment,{children:[ce&&y!==void 0&&(0,m.jsx)("input",{type:"hidden",name:ce,value:P.current(y)}),(0,m.jsx)("div",{ref:N.hostRef,className:ze(Se),hidden:be,children:N.inline(_)}),N.portal((0,m.jsx)(j.LayerDocumentProvider,{document:be?b.ownerDocument:null,children:_})),t==="clone"&&b&&(0,Ee.createPortal)((0,m.jsx)(j.LayerDocumentProvider,{document:b.ownerDocument,children:_}),b)]})}var Te=(0,e.forwardRef)(Ge);Te.displayName="AdvanceDetachable";0&&(module.exports={AdvanceDetachable});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as V,useRef as r,useEffect as S,useCallback as a,useImperativeHandle as Ie,forwardRef as Pe}from"react";import{createPortal as xe}from"react-dom";import{useMovableContent as Oe}from"../detachable/useMovableContent.js";import{LayerDocumentProvider as De}from"../../lib/layer-document.js";import{Fragment as Xe,jsx as H,jsxs as Ge}from"react/jsx-runtime";function Be(...t){return t.filter(Boolean).join(" ")}var Ve="@synertech/ui/AdvanceDetachable",He=300,ze="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Ce={clock:0,writer:""};function We(t,c){return t.clock>c.clock||t.clock===c.clock&&t.writer>c.writer}var $e=0;function Ue(){return`${Date.now()}-${++$e}-${Math.random().toString(36).slice(2,8)}`}function Ee(t){try{return JSON.stringify(t)}catch{return String(t)}}function ke(t){try{return JSON.parse(t)}catch{return t}}function Fe(t,c){t.querySelectorAll("style").forEach(l=>{let s=c.createElement("style");s.textContent=l.textContent,c.head.appendChild(s)}),t.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{let s=l,i=c.createElement("link");i.rel="stylesheet",i.href=s.href,s.crossOrigin&&(i.crossOrigin=s.crossOrigin),c.head.appendChild(i)}),t.documentElement.className&&(c.documentElement.className=t.documentElement.className),t.body.className&&(c.body.className=t.body.className)}function _e(t,c){let l=new MutationObserver(s=>{for(let i of s)for(let h of Array.from(i.addedNodes))if(h instanceof HTMLStyleElement){let d=c.createElement("style");d.textContent=h.textContent,c.head.appendChild(d)}else if(h instanceof HTMLLinkElement&&h.rel==="stylesheet"){let d=c.createElement("link");d.rel="stylesheet",d.href=h.href,c.head.appendChild(d)}});return l.observe(t.head,{childList:!0}),l}function qe(){return typeof BroadcastChannel<"u"}function Je({mode:t,id:c,title:l="",children:s,value:i,defaultValue:h,onValueChange:d,isDetached:G,defaultDetached:Te=!1,onDetachedChange:K,onPopupBlocked:Q,features:Y,target:Z,autoFocus:ee=!0,className:Ne,detachedBodyClassName:ne,disabled:te=!1,readOnly:re=!1,closeOnMainWindowUnload:ce=!0,name:oe,serialize:le,deserialize:se},Se){let u=G!==void 0,[Ae,E]=V(Te),k=u?G:Ae,z=i!==void 0,[Me,Le]=V(h),y=z?i:Me,[b,ae]=V(null),o=r(null),w=r(null),A=r(null),M=r(null),L=r(!1),T=r(null),I=r(null),P=r(null),g=r(null),f=r(Ce),ue=r(null),[R]=V(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),p=r({title:l,features:Y,target:Z,autoFocus:ee,detachedBodyClassName:ne,closeOnMainWindowUnload:ce,disabled:te,readOnly:re,mode:t,id:c});p.current={title:l,features:Y,target:Z,autoFocus:ee,detachedBodyClassName:ne,closeOnMainWindowUnload:ce,disabled:te,readOnly:re,mode:t,id:c};let x=r(le??Ee);x.current=le??Ee;let ie=r(se??ke);ie.current=se??ke;let de=r(d);de.current=d;let D=r(K);D.current=K;let fe=r(Q);fe.current=Q;let N=Oe(t==="detach"?b:null),W=r(N.bringBack);W.current=N.bringBack;let $=r(k);$.current=k;let pe=r(y);pe.current=y;let m=`${Ve}/${c}`,O=a(()=>{T.current?.(),T.current=null,A.current&&(clearInterval(A.current),A.current=null),M.current&&(M.current.disconnect(),M.current=null),ae(null)},[]),B=a(()=>{w.current&&(w.current.close(),w.current=null),I.current&&typeof window<"u"&&(window.removeEventListener("message",I.current),I.current=null)},[]),C=a(e=>{let n={channel:m,instanceId:R,messageId:Ue(),origin:"main",timestamp:Date.now(),...e};w.current?w.current.postMessage(n):o.current&&!o.current.closed&&o.current.postMessage(n,"*")},[m,R]),U=a(e=>{if(!e||e.channel!==m||e.instanceId===R||p.current.readOnly)return;if(e.type==="hello"){if(f.current.clock===0||g.current===null)return;C({type:"value-sync",payload:g.current,...f.current});return}if(e.type!=="value-sync"||typeof e.payload!="string")return;let n=typeof e.clock=="number"?{clock:e.clock,writer:typeof e.writer=="string"?e.writer:e.instanceId}:{clock:f.current.clock+1,writer:e.instanceId};if(!We(n,f.current)||(f.current=n,e.payload===g.current)||(g.current=e.payload,e.payload===P.current))return;let v=ie.current(e.payload);z||Le(v),de.current?.(v)},[m,R,z,C]),me=a(()=>{if(B(),!(typeof window>"u")){if(ue.current!==m){ue.current=m,f.current=Ce,g.current=null;let e=pe.current;P.current=e===void 0?null:x.current(e)}if(qe()){let e=new BroadcastChannel(m),n=v=>U(v.data);e.addEventListener("message",n),w.current=e}else{let e=n=>{n.data?.channel===m&&U(n.data)};window.addEventListener("message",e),I.current=e}p.current.readOnly||C({type:"hello"})}},[m,B,U,C]),he=a(e=>{let n=x.current(e);n!==P.current&&(P.current=n,!p.current.readOnly&&n!==g.current&&(g.current=n,f.current={clock:f.current.clock+1,writer:R},C({type:"value-sync",payload:n,...f.current})))},[R,C]),ye=a(()=>{if(typeof window>"u"||p.current.disabled||L.current||o.current&&!o.current.closed)return;L.current=!0;let e=p.current,n=window.open("",e.target||"",e.features||ze);if(!n){L.current=!1,u||E(!1),D.current?.(!1),fe.current?.();return}o.current=n,n.document.title=e.title||document.title,e.detachedBodyClassName&&(n.document.body.className=e.detachedBodyClassName);let v=n.document.createElement("div");n.document.body.appendChild(v),ae(v),Fe(document,n.document),M.current=_e(document,n.document);let Re=!1,X=()=>{Re||(Re=!0,W.current(),O(),o.current=null,u||E(!1),D.current?.(!1))};n.addEventListener("pagehide",X),T.current=()=>n.removeEventListener("pagehide",X),A.current=setInterval(()=>{n.closed&&X()},He),e.autoFocus&&n.focus(),L.current=!1},[u,O]),ge=a(()=>{W.current();let e=o.current;o.current=null,O(),e&&!e.closed&&e.close()},[O]),ve=r(ye);ve.current=ye;let F=r(ge);F.current=ge;let be=r(he);be.current=he;let _=a(()=>{p.current.disabled||(u||E(!0),D.current?.(!0))},[u]),q=a(()=>{u||E(!1),D.current?.(!1)},[u]),J=a(()=>{let e=!$.current;e&&p.current.disabled||(u||E(e),D.current?.(e))},[u]);Ie(Se,()=>({open:_,close:q,toggle:J,get isDetached(){return $.current},get window(){return o.current}}),[_,q,J]),S(()=>(me(),()=>B()),[me,B]),S(()=>{if(k)return ve.current(),()=>F.current();F.current()},[k]),S(()=>{y!==void 0&&be.current(y)},[y]),S(()=>{o.current&&!o.current.closed&&l&&(o.current.document.title=l)},[l]),S(()=>{if(typeof window>"u")return;let e=()=>{p.current.closeOnMainWindowUnload&&o.current&&!o.current.closed&&o.current.close()};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e);let n=o.current;T.current?.(),T.current=null,o.current=null,n&&!n.closed&&n.close()}},[]);let j=typeof s=="function"?s({open:_,close:q,toggle:J,detached:k,windowRef:o.current}):s,we=t==="detach"&&b!==null;return Ge(Xe,{children:[oe&&y!==void 0&&H("input",{type:"hidden",name:oe,value:x.current(y)}),H("div",{ref:N.hostRef,className:Be(Ne),hidden:we,children:N.inline(j)}),N.portal(H(De,{document:we?b.ownerDocument:null,children:j})),t==="clone"&&b&&xe(H(De,{document:b.ownerDocument,children:j}),b)]})}var je=Pe(Je);je.displayName="AdvanceDetachable";export{je as AdvanceDetachable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var D=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ae=(n,o)=>{for(var l in o)D(n,l,{get:o[l],enumerable:!0})},ne=(n,o,l,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of re(o))!oe.call(n,d)&&d!==l&&D(n,d,{get:()=>o[d],enumerable:!(p=te(o,d))||p.enumerable});return n};var ie=n=>ne(D({},"__esModule",{value:!0}),n);var ue={};ae(ue,{ChartPeriodPicker:()=>le});module.exports=ie(ue);var t=require("react"),N=require("react-dom"),z=require("../../lib/aria-hide.cjs"),g=require("../../lib/owner-document.cjs"),P=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),A=require("../calendar/Calendar.cjs"),F=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),se={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},de={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ce=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function le({value:n,defaultValue:o,onChange:l,presets:p=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:U,now:f,minDate:W,maxDate:H,numberOfMonths:_=1,weekStartsOn:B,locale:K,size:q="md",align:Y="start",disabled:$=!1,label:L,className:Q,...j}){let C=(0,v.useUILabels)(),E=(0,v.useUILocale)(K),c=(0,t.useRef)(null),h=(0,t.useRef)(null),R=(0,t.useRef)(null),[i,w]=(0,t.useState)(!1),[M,S]=(0,t.useState)(!1),[G,O]=(0,t.useState)(null),[J,V]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,f):o||(0,a.createPeriod)(p[0]??"30d",f)),s=n??J,k=(0,F.usePositioning)({triggerRef:c,contentRef:h,isOpen:i,side:"bottom",align:Y}),u=(0,t.useCallback)((e=!0)=>{w(!1),S(!1),O(null),e&&c.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=b=>{let I=b.target;h.current?.contains(I)||c.current?.contains(I)||u(!1)},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("mousedown",e),m.addEventListener("touchstart",e,{passive:!0}),()=>{m.removeEventListener("mousedown",e),m.removeEventListener("touchstart",e)}},[i,u]),(0,t.useEffect)(()=>{if(!i)return;let e=b=>{b.key==="Escape"&&(b.stopPropagation(),u())},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("keydown",e),()=>m.removeEventListener("keydown",e)},[i,u]),(0,t.useEffect)(()=>{let e=h.current;if(e)return(0,z.registerFloatingLayer)(e,()=>c.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let y=(0,t.useCallback)(e=>{n===void 0&&V(e),l?.(e),u()},[n,l,u]),X=(0,t.useCallback)(e=>y((0,a.createPeriod)(e,f)),[y,f]),Z=(0,t.useCallback)(e=>{O(e),!(!e.from||!e.to)&&y({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[y]),x=e=>U?.[e]??C[se[e]],T=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,E):x(s.preset),ee=(0,r.jsxs)("div",{ref:h,role:"dialog","aria-label":L??C.chartPeriod,style:{position:"fixed",top:k.top,left:k.left,visibility:k.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[p.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>X(e),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x("custom")}):null]}),d&&M?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(A.Calendar,{mode:"range",value:G??{from:s.from,to:s.to},onChange:Z,numberOfMonths:_,weekStartsOn:B,locale:E,today:f,minDate:W,maxDate:H,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:c,type:"button",disabled:$,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${L??C.chartPeriod}: ${T}`,onClick:()=>i?u():w(!0),className:(0,P.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",de[q],Q),...j,children:[ce,(0,r.jsx)("span",{children:T})]}),i&&typeof document<"u"?(0,N.createPortal)(ee,(0,g.ownerDocumentOf)(c.current).body):null]})}0&&(module.exports={ChartPeriodPicker});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as m,useEffect as p,useRef as v,useState as f}from"react";import{createPortal as Z}from"react-dom";import{registerFloatingLayer as ee}from"../../lib/aria-hide.js";import{ownerDocumentOf as C}from"../../lib/owner-document.js";import{cn as k}from"../../lib/cn.js";import{useUILabels as te,useUILocale as re}from"../../lib/i18n.js";import{Calendar as oe}from"../calendar/Calendar.js";import{usePositioning as ae}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as ne,createPeriod as x,endOfDay as ie,formatPeriodRange as se,startOfDay as de}from"./utils/period.js";import{Fragment as me,jsx as i,jsxs as h}from"react/jsx-runtime";var ce={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},le={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ue=i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:i("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function ke({value:y,defaultValue:d,onChange:D,presets:L=ne,custom:E=!0,presetLabels:A,now:s,minDate:F,maxDate:U,numberOfMonths:W=1,weekStartsOn:H,locale:_,size:B="md",align:K="start",disabled:q=!1,label:R,className:Y,...$}){let b=te(),w=re(_),o=v(null),c=v(null),M=v(null),[t,S]=f(!1),[O,T]=f(!1),[Q,I]=f(null),[j,G]=f(()=>typeof d=="string"?x(d,s):d||x(L[0]??"30d",s)),r=y??j,g=ae({triggerRef:o,contentRef:c,isOpen:t,side:"bottom",align:K}),a=m((e=!0)=>{S(!1),T(!1),I(null),e&&o.current?.focus()},[]);p(()=>{if(!t)return;let e=u=>{let z=u.target;c.current?.contains(z)||o.current?.contains(z)||a(!1)},n=C(o.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[t,a]),p(()=>{if(!t)return;let e=u=>{u.key==="Escape"&&(u.stopPropagation(),a())},n=C(o.current);return n.addEventListener("keydown",e),()=>n.removeEventListener("keydown",e)},[t,a]),p(()=>{let e=c.current;if(e)return ee(e,()=>o.current)},[t]),p(()=>{if(!t)return;let e=requestAnimationFrame(()=>M.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let l=m(e=>{y===void 0&&G(e),D?.(e),a()},[y,D,a]),J=m(e=>l(x(e,s)),[l,s]),V=m(e=>{I(e),!(!e.from||!e.to)&&l({preset:"custom",from:de(e.from),to:ie(e.to)})},[l]),P=e=>A?.[e]??b[ce[e]],N=r.preset==="custom"?se(r.from,r.to,w):P(r.preset),X=h("div",{ref:c,role:"dialog","aria-label":R??b.chartPeriod,style:{position:"fixed",top:g.top,left:g.left,visibility:g.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[h("div",{ref:M,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[L.map(e=>i("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>J(e),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P(e)},e)),E?i("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":O,onClick:()=>T(!0),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P("custom")}):null]}),E&&O?i("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:i(oe,{mode:"range",value:Q??{from:r.from,to:r.to},onChange:V,numberOfMonths:W,weekStartsOn:H,locale:w,today:s,minDate:F,maxDate:U,size:"sm"})}):null]});return h(me,{children:[h("button",{ref:o,type:"button",disabled:q,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${R??b.chartPeriod}: ${N}`,onClick:()=>t?a():S(!0),className:k("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",le[B],Y),...$,children:[ue,i("span",{children:N})]}),t&&typeof document<"u"?Z(X,C(o.current).body):null]})}export{ke as ChartPeriodPicker};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var kr=Object.create;var Ce=Object.defineProperty;var Cr=Object.getOwnPropertyDescriptor;var Nr=Object.getOwnPropertyNames;var Sr=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var Tr=(o,i)=>{for(var d in i)Ce(o,d,{get:i[d],enumerable:!0})},wt=(o,i,d,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of Nr(i))!Rr.call(o,c)&&c!==d&&Ce(o,c,{get:()=>i[c],enumerable:!(g=Cr(i,c))||g.enumerable});return o};var Dr=(o,i,d)=>(d=o!=null?kr(Sr(o)):{},wt(i||!o||!o.__esModule?Ce(d,"default",{value:o,enumerable:!0}):d,o)),Er=o=>wt(Ce({},"__esModule",{value:!0}),o);var Xr={};Tr(Xr,{DataGrid:()=>$r,resetRowKeyWarning:()=>Lr});module.exports=Er(Xr);var n=Dr(require("react"),1),f=require("../../lib/cn.cjs"),Nt=require("../../lib/csv.cjs"),T=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"},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"})}),Mr=()=>(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"})}),Fr=()=>(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"})}),Pr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark: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"})}),zr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark: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"})}),Ir=()=>(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"})}),Or=()=>(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"})]}),Ar=()=>(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 Lr(){$e=!1}function Hr(){$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 Vr(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 Kr(o,i){let d=String(o??"").toLowerCase(),g=i.value.toLowerCase();switch(i.operator){case"contains":return d.includes(g);case"equals":return d===g;case"startsWith":return d.startsWith(g);case"endsWith":return d.endsWith(g);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 g=[];for(let c of o){let y=Number(F(c,i));isNaN(y)||g.push(y)}if(g.length===0)return 0;switch(d){case"sum":return g.reduce((c,y)=>c+y,0);case"avg":return g.reduce((c,y)=>c+y,0)/g.length;case"count":return g.length;case"min":return Math.min(...g);case"max":return Math.max(...g)}}function Wr(o,i,d){if(o==="count")return i;let g=o==="avg"?d.dataGridAggregateAvg:o==="sum"?d.dataGridAggregateSum:o==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return(0,T.formatUILabel)(g,{value:i})}function Br({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,g)=>(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"})},g))})}function Ur({column:o,value:i,onApply:d,onClear:g,labels:c}){let y=o.filterType??"text",L=String(o.header),P=y==="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=u=>u&&P.some(R=>R.value===u.operator)?u.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 u=R=>{ae.current&&!ae.current.contains(R.target)&&w(!1)};return E&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[E]),(0,t.jsxs)("div",{className:"relative inline-block",ref:ae,onClick:u=>u.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-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":(0,T.formatUILabel)(c.dataGridFilterColumn,{column:L}),children:(0,t.jsx)(Ir,{})}),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:y==="select"&&o.filterOptions?(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(u=>(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:u,checked:$===u,onChange:()=>H(u),className:"cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:u})]},u)),(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-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),g(),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:u=>re(u.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(u=>(0,t.jsx)("option",{value:u.value,children:u.label},u.value))}),G!=="isEmpty"&&G!=="isNotEmpty"&&(0,t.jsx)("input",{type:y==="number"?"number":y==="date"?"date":"text",value:$,onChange:u=>H(u.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,T.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-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),g(),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 jr({value:o,onSave:i,density:d,labels:g}){let[c,y]=(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??"")),y(!0)},className:"cursor-text min-h-[1.5em]",title:g.dataGridEditHint,children:String(o??"")});let E=()=>{y(!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":g.dataGridEditCell,onKeyDown:w=>{w.key==="Enter"&&E(),w.key==="Escape"&&y(!1)},className:(0,f.cn)("w-full border border-synertech-primary-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 qr(o,i){let{columns:d,data:g,rowKey:c,mode:y="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:u="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,locale:Pt,showFooter:zt=!1,onRowClick:Ee,onRowDoubleClick:lt,onRowContextMenu:dt,className:It,rowClassName:Ge,cellClassName:Ot,headerClassName:At}=o,b=(0,T.useUILabels)(Ft),Lt=(0,T.useUILocale)(Pt),[Ht,ct]=(0,n.useState)(E??[]),[Vt,Kt]=(0,n.useState)(1),ie=typeof G=="object"?G.pageSize:void 0,[Wt,gt]=(0,n.useState)(ie??10),[Bt,Ut]=(0,n.useState)(ie);ie!==Bt&&(Ut(ie),ie!==void 0&>(ie));let[jt,ve]=(0,n.useState)([]),[qt,ut]=(0,n.useState)(""),[$t,Me]=(0,n.useState)([]),[Xt,_t]=(0,n.useState)([]),[Jt,Qt]=(0,n.useState)(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[Fe,Yt]=(0,n.useState)({}),[xe,Zt]=(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),[er,tr]=(0,n.useState)(new Set),ze=(0,n.useRef)(null),[yt,rr]=(0,n.useState)(0),Ie=(0,n.useRef)(null),Oe=(0,n.useRef)(!1),B=S??Ht,bt=re??Vt,C=R??jt,ke=me??qt,U=X??$t,ye=Se??Xt,Y=Re??Jt,de=G?typeof G=="object"?G:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,be=Wt;!c&&(z||oe||Qe||se)&&Hr();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=g.map((r,a)=>({row:r,sourceIndex:a}));if(y==="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=>Kr(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):Vr(F(a.row,l.key),F(s.row,l.key));if(v!==0)return l.direction==="asc"?v:-v}return 0})}return e},[g,y,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/be)),O=y==="server"&&ae===void 0?bt:Math.min(Math.max(1,bt),ee),vt=de!==null,A=(0,n.useMemo)(()=>{if(!vt||y==="server")return Z;let e=(O-1)*be;return Z.slice(e,e+be)},[Z,vt,O,be,y]),j=(0,n.useMemo)(()=>A.map(e=>e.row),[A]),ge=(0,n.useMemo)(()=>{if(!_)return{start:0,end:j.length};let e=Math.floor(yt/J),r=Math.ceil(Te/J),a=5;return{start:Math.max(0,e-a),end:Math.min(j.length,e+r+a)}},[_,yt,J,Te,j.length]),Le=(0,n.useCallback)(e=>{S||ct(e),w?.(e)},[S,w]),ar=(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||Kt(r),$?.(r)},[re,$,ee]),nr=(0,n.useCallback)(e=>{gt(e),N(1),H?.(e)},[N,H]),or=(0,n.useCallback)(e=>{let r;u==="single"?r=C.includes(e)?[]:[e]:r=C.includes(e)?C.filter(a=>a!==e):[...C,e],R||ve(r),V?.(r)},[u,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]),sr=(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)),ir=!We&&Ke.some(e=>He.has(e)),lr=(0,n.useCallback)(e=>{let r=ye.includes(e)?ye.filter(a=>a!==e):[...ye,e];Se||_t(r),Je?.(r)},[ye,Se,Je]),dr=(0,n.useCallback)(e=>{let r=e.target.value;me||ut(r),fe?.(r),N(1)},[me,fe,N]),cr=(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]),gr=(0,n.useCallback)(e=>{let r=U.filter(a=>a.column!==e);X||Me(r),ne?.(r),N(1)},[U,X,ne,N]),ur=(0,n.useCallback)(e=>{let r=Y.includes(e)?Y.filter(a=>a!==e):[...Y,e];Re||Qt(r),tt?.(r)},[Y,Re,tt]),pr=(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));Yt(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]),D=se&&!(y==="client"&&B.some(e=>e.direction)),mr=(0,n.useCallback)((e,r)=>{D&&Pe({key:e,sourceIndex:r})},[D]),yr=(0,n.useCallback)(e=>{!D||Q===null||e.preventDefault()},[D,Q]),br=(0,n.useCallback)((e,r)=>{!D||Q===null||(Pe(null),Q.key!==e&&Ye?.(Q.sourceIndex,r))},[D,Q,Ye]),fr=(0,n.useCallback)(e=>{K&&pt(e)},[K]),hr=(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),Zt(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||ut(""),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},ue=I.length+(z?1:0)+(oe?1:0)+(se?1:0),vr=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,At),style:Ue(e),onClick:r?()=>{Oe.current||ar(e.key)}:void 0,draggable:K,onDragStart:K?()=>fr(e.key):void 0,onDragOver:K?l=>l.preventDefault():void 0,onDrop:K?()=>hr(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)(Mr,{}):(0,t.jsx)(Fr,{})}),s&&(0,t.jsx)(Ur,{column:e,value:U.find(l=>l.column===e.key),onApply:cr,onClear:()=>gr(e.key),labels:b})]}),e.resizable!==!1&&(0,t.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:l=>pr(l,e.key)})]},e.key)},je=(e,r)=>{let{row:a,sourceIndex:s}=e,l=ft(e),m=He.has(l),v=ye.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-synertech-primary-50 dark:bg-synertech-primary-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:D,onDragStart:D?()=>mr(l,s):void 0,onDragOver:D?yr:void 0,onDrop:D?()=>br(l,s):void 0,onDragEnd:D?()=>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],D?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,t.jsx)(zr,{})}),z&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],"w-10"),children:(0,t.jsx)("input",{type:"checkbox",checked:m,onChange:()=>or(l),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,T.formatUILabel)(b.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(),lr(l)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":v?b.dataGridCollapseRow:b.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-synertech-primary-50 dark:bg-synertech-primary-900/20":st&&r%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,Ot),style:Ue(p),colSpan:q,children:M?(0,t.jsx)(jr,{value:x,onSave:pe=>Rt?.(l,p.key,pe),density:h,labels:b}):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:ue,className:(0,f.cn)(k[h]),children:_e(a,r)})})]},l)},xr=()=>{if(Et)return Array.from({length:Gt}).map((e,r)=>(0,t.jsx)(Br,{cols:ue,density:h},r));if(j.length===0)return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ue,className:(0,f.cn)("text-center text-gray-500 dark:text-gray-400",k[h]),children:Mt??b.dataGridNoData})});if(ht){let e=[],r=0;for(let[a,s]of ht){let l=er.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:ue,className:(0,f.cn)(k[h],"cursor-pointer"),onClick:()=>{tr(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=ge.start;r<ge.end;r++)e.push(je(A[r],r));return(0,t.jsxs)(t.Fragment,{children:[ge.start>0&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ue,style:{height:ge.start*J,padding:0}})}),e,ge.end<j.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ue,style:{height:(j.length-ge.end)*J,padding:0}})})]})}return A.map((e,r)=>je(e,r))},wr=()=>!zt||!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):Wr(r.aggregate,Ct(ce,r.key,r.aggregate).toLocaleString(Lt),b):""},r.key))]})});return(0,t.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-3",It),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)(Pr,{})}),(0,t.jsx)("input",{type:"text",value:ke,onChange:dr,placeholder:St??b.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-synertech-primary-500 focus:border-synertech-primary-500","aria-label":b.dataGridSearch})]}),C.length>0&&(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,T.formatUILabel)(b.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":b.dataGridToggleColumns,title:b.dataGridToggleColumns,children:(0,t.jsx)(Ar,{})}),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:()=>ur(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,T.formatUILabel)(b.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,t.jsx)(Or,{}),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=>rr(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:u==="multiple"&&(0,t.jsx)("input",{type:"checkbox",checked:We,ref:e=>{e&&(e.indeterminate=ir)},onChange:We?sr:Ve,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":b.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(vr)]})}),(0,t.jsx)("tbody",{children:xr()}),wr()]})}),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,T.formatUILabel)(Ae===1?b.dataGridItemCount:b.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:b.dataGridRowsPerPage}),(0,t.jsx)("select",{value:be,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: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,T.formatUILabel)(b.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":b.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":b.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":b.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":b.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var $r=(0,n.forwardRef)(qr);0&&(module.exports={DataGrid,resetRowKeyWarning});
|
|
1
|
+
"use strict";"use client";var Or=Object.create;var Re=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Hr=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var Kr=(o,l)=>{for(var d in l)Re(o,d,{get:l[d],enumerable:!0})},It=(o,l,d,u)=>{if(l&&typeof l=="object"||typeof l=="function")for(let c of Hr(l))!Vr.call(o,c)&&c!==d&&Re(o,c,{get:()=>l[c],enumerable:!(u=Ar(l,c))||u.enumerable});return o};var Wr=(o,l,d)=>(d=o!=null?Or(Lr(o)):{},It(l||!o||!o.__esModule?Re(d,"default",{value:o,enumerable:!0}):d,o)),Br=o=>It(Re({},"__esModule",{value:!0}),o);var un={};Kr(un,{DataGrid:()=>cn,resetRowKeyWarning:()=>Zr});module.exports=Br(un);var a=Wr(require("react"),1),y=require("../../lib/cn.cjs"),zt=require("../../lib/csv.cjs"),E=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),I={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ur={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Te={compact:"text-xs",default:"text-sm",comfortable:"text-base"},jr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),qr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),$r=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Pt=({className:o})=>(0,r.jsx)("svg",{className:(0,y.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.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"})}),Xr=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.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"})}),_r=()=>(0,r.jsx)("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.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"})}),Jr=()=>(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.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"})}),Qr=()=>(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,r.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,r.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"})]}),Yr=()=>(0,r.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,r.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 Ye(o,l,d){return typeof d=="function"?d(o,l):String(typeof d=="string"?o[d]:l)}var Ze=!1;function Zr(){Ze=!1}function en(){Ze||(Ze=!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 O(o,l){return o[l]}function Ft(o,l){return l.map(d=>String(O(o,d)??"")).join(" / ")}function et(o){return o==null||typeof o=="string"&&o.trim()===""||typeof o=="number"&&Number.isNaN(o)||o instanceof Date&&Number.isNaN(o.getTime())}function tn(o,l,d){let u=et(o),c=et(l);return u||c?u===c?0:u?-1:1:o instanceof Date&&l instanceof Date?o.getTime()-l.getTime():typeof o=="number"&&typeof l=="number"?o-l:d.compare(String(o),String(l))}function rn(o,l){let d=String(o??"").toLowerCase(),u=l.value.toLowerCase();switch(l.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(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 d==="";case"isNotEmpty":return d!=="";default:return!0}}function nn(o,l,d){let u=0,c=0,f=0,D=1/0,S=-1/0;for(let w of o){let N=O(w,l);if(et(N))continue;u++;let m=Number(N);Number.isNaN(m)||(c++,f+=m,m<D&&(D=m),m>S&&(S=m))}switch(d){case"count":return u;case"sum":return f;case"avg":return c===0?null:f/c;case"min":return c===0?null:D;case"max":return c===0?null:S}}function an(o,l,d){if(o==="count")return l;let u=o==="avg"?d.dataGridAggregateAvg:o==="sum"?d.dataGridAggregateSum:o==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return(0,E.formatUILabel)(u,{value:l})}function on({cols:o,density:l}){return(0,r.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((d,u)=>(0,r.jsx)("td",{className:I[l],children:(0,r.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},u))})}function sn({column:o,value:l,onApply:d,onClear:u,labels:c}){let f=o.filterType??"text",D=String(o.header),S=f==="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}],w=g=>g&&S.some(R=>R.value===g.operator)?g.operator:S[0].value,[N,m]=(0,a.useState)(!1),[P,Z]=(0,a.useState)(()=>w(l)),[$,K]=(0,a.useState)(l?.value??""),ee=(0,a.useRef)(null),A=()=>{N||(Z(w(l)),K(l?.value??"")),m(!N)};return(0,a.useEffect)(()=>{let g=R=>{ee.current&&!ee.current.contains(R.target)&&m(!1)};return N&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[N]),(0,r.jsxs)("div",{className:"relative inline-block",ref:ee,onClick:g=>g.stopPropagation(),children:[(0,r.jsx)("button",{type:"button",onClick:A,className:(0,y.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":(0,E.formatUILabel)(c.dataGridFilterColumn,{column:D}),children:(0,r.jsx)(Jr,{})}),N&&(0,r.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:f==="select"&&o.filterOptions?(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(g=>(0,r.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:g,checked:$===g,onChange:()=>K(g),className:"cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),(0,r.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:"equals",value:$}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{K(""),u(),m(!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,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("select",{value:P,onChange:g=>Z(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:S.map(g=>(0,r.jsx)("option",{value:g.value,children:g.label},g.value))}),P!=="isEmpty"&&P!=="isNotEmpty"&&(0,r.jsx)("input",{type:f==="number"?"number":f==="date"?"date":"text",value:$,onChange:g=>K(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,E.formatUILabel)(c.dataGridFilterValue,{column:D})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:P,value:$}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:c.dataGridFilterApply}),(0,r.jsx)("button",{type:"button",onClick:()=>{K(""),u(),m(!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 ln({value:o,onSave:l,density:d,labels:u}){let[c,f]=(0,a.useState)(!1),[D,S]=(0,a.useState)(String(o??"")),w=(0,a.useRef)(null);if((0,a.useEffect)(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]),!c)return(0,r.jsx)("div",{onDoubleClick:()=>{S(String(o??"")),f(!0)},className:"cursor-text min-h-[1.5em]",title:u.dataGridEditHint,children:String(o??"")});let N=()=>{f(!1),D!==String(o??"")&&l(D)};return(0,r.jsx)("input",{ref:w,type:"text",value:D,onChange:m=>S(m.target.value),onBlur:N,"aria-label":u.dataGridEditCell,onKeyDown:m=>{m.key==="Enter"&&N(),m.key==="Escape"&&f(!1)},className:(0,y.cn)("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Te[d])})}function dn(o,l){let{columns:d,data:u,rowKey:c,mode:f="client",sortable:D=!1,multiSort:S=!1,sort:w,defaultSort:N,onSort:m,pagination:P=!1,page:Z,onPageChange:$,onPageSizeChange:K,totalItems:ee,selectable:A=!1,selectionMode:g="multiple",selectedRows:R,onSelectionChange:W,searchable:tt=!1,searchPlaceholder:Ot,searchValue:ye,onSearch:xe,filters:X,onFilterChange:te,expandable:re=!1,expandedContent:rt,expandedRows:Ee,onExpandChange:nt,editable:at=!1,onCellEdit:At,reorderable:ne=!1,onReorder:ot,columnReorderable:B=!1,onColumnReorder:st,columnToggle:it=!1,hiddenColumns:De,onColumnVisibilityChange:lt,groupBy:we,renderGroupHeader:dt,exportable:ct=!1,exportFormats:Ht=["csv","json"],exportFilename:ut="export",exportNeutralizeFormulas:gt,virtualized:T=!1,rowHeight:U=40,virtualHeight:pt=400,density:v="default",striped:mt=!1,bordered:Ge=!1,borderless:Lt=!1,stickyHeader:yt=!1,maxHeight:ae,loading:Vt=!1,loadingRows:Kt=5,emptyState:Wt,labels:Bt,locale:Ut,showFooter:jt=!1,onRowClick:Me,onRowDoubleClick:bt,onRowContextMenu:ft,className:qt,rowClassName:Ie,cellClassName:$t,headerClassName:Xt}=o,b=(0,E.useUILabels)(Bt),Pe=(0,E.useUILocale)(Ut),ht=(0,a.useMemo)(()=>new Intl.Collator(Pe,{numeric:!0}),[Pe]),[_t,vt]=(0,a.useState)(N??[]),[Jt,Qt]=(0,a.useState)(1),oe=typeof P=="object"?P.pageSize:void 0,[Yt,xt]=(0,a.useState)(oe??10),[Zt,er]=(0,a.useState)(oe);oe!==Zt&&(er(oe),oe!==void 0&&xt(oe));let[tr,ke]=(0,a.useState)([]),[rr,wt]=(0,a.useState)(""),[nr,Fe]=(0,a.useState)([]),[ar,or]=(0,a.useState)([]),[sr,ir]=(0,a.useState)(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[ze,lr]=(0,a.useState)({}),[Ce,dr]=(0,a.useState)(()=>d.map(e=>e.key)),[_,Oe]=(0,a.useState)(null),[se,kt]=(0,a.useState)(null),[Se,Ct]=(0,a.useState)(!1),[Ae,cr]=(0,a.useState)(new Set),He=(0,a.useRef)(null),[St,ur]=(0,a.useState)(0),[gr,Nt]=(0,a.useState)(null),Le=(0,a.useRef)(null),Ve=(0,a.useRef)(!1),F=w??_t,Rt=Z??Jt,k=R??tr,Ne=ye??rr,j=X??nr,be=Ee??ar,J=De??sr,ie=P?typeof P=="object"?P:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,fe=Yt;!c&&(A||re||at||ne)&&en();let Tt=e=>Ye(e.row,e.sourceIndex,c),H=(0,a.useMemo)(()=>{let e=new Map(d.map(s=>[s.key,s])),t=Ce.flatMap(s=>{let i=e.get(s);return i?[i]:[]}),n=new Set(t.map(s=>s.key));for(let s of d)n.has(s.key)||(t.push(s),n.add(s.key));return t.filter(s=>!J.includes(s.key))},[d,Ce,J]),le=(0,a.useMemo)(()=>{let e=u.map((t,n)=>({row:t,sourceIndex:n}));if(f==="server")return e;if(Ne){let t=Ne.toLowerCase();e=e.filter(({row:n})=>H.some(s=>{let i=O(n,s.key);return String(i??"").toLowerCase().includes(t)}))}if(j.length>0&&(e=e.filter(({row:t})=>j.every(n=>rn(O(t,n.column),n)))),F.length>0){let t=new Map(d.map(n=>[n.key,n]));e.sort((n,s)=>{for(let i of F){if(!i.direction)continue;let h=t.get(i.key),M=h?.sortComparator?h.sortComparator(n.row,s.row):tn(O(n.row,i.key),O(s.row,i.key),ht);if(M!==0)return i.direction==="asc"?M:-M}return 0})}return e},[u,f,Ne,j,F,H,d,ht]),he=(0,a.useMemo)(()=>le.map(e=>e.row),[le]),Ke=we?(Array.isArray(we)?we:[we]).join("\0"):"",de=(0,a.useMemo)(()=>Ke?Ke.split("\0"):[],[Ke]),ce=(0,a.useMemo)(()=>{if(de.length===0)return null;let e=new Map;for(let t of le){let n=Ft(t.row,de),s=e.get(n);s?s.push(t):e.set(n,[t])}return e},[le,de]),We=(0,a.useMemo)(()=>ce?Array.from(ce.values()).flat():le,[ce,le]),Be=ee??he.length,Q=Math.max(1,Math.ceil(Be/fe)),L=f==="server"&&ee===void 0?Rt:Math.min(Math.max(1,Rt),Q),Et=ie!==null,V=(0,a.useMemo)(()=>{if(!Et||f==="server")return We;let e=(L-1)*fe;return We.slice(e,e+fe)},[We,Et,L,fe,f]),Ue=(0,a.useMemo)(()=>V.map(e=>e.row),[V]),ue=(0,a.useMemo)(()=>{let e=[],t=null;return V.forEach((n,s)=>{if(ce){let i=Ft(n.row,de);if(i!==t&&(t=i,e.push({kind:"group",key:i,rows:ce.get(i)??[n]})),Ae.has(i))return}e.push({kind:"row",entry:n,index:s})}),e},[V,ce,de,Ae]),Dt=gr??(typeof ae=="number"?ae:pt),ge=ue.length,pr=(0,a.useMemo)(()=>{if(!T)return{start:0,end:ge};let e=Math.max(1,Math.ceil(Dt/U)),t=Math.min(St,Math.max(0,ge-e)),n=5;return{start:Math.max(0,t-n),end:Math.min(ge,t+e+n)}},[T,St,U,Dt,ge]);(0,a.useEffect)(()=>{if(!T)return;let e=He.current;if(!e)return;let t=()=>{e.clientHeight>0&&Nt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);let je=(0,a.useCallback)(e=>{w||vt(e),m?.(e)},[w,m]),mr=(0,a.useCallback)(e=>{let t=F.find(s=>s.key===e),n;if(!t||!t.direction?n="asc":t.direction==="asc"?n="desc":n=null,S){let s;n?t?s=F.map(i=>i.key===e?{key:e,direction:n}:i):s=[...F,{key:e,direction:n}]:s=F.filter(i=>i.key!==e),je(s)}else je(n?[{key:e,direction:n}]:[])},[F,S,je]),C=(0,a.useCallback)(e=>{let t=Math.max(1,Math.min(e,Q));Z||Qt(t),$?.(t)},[Z,$,Q]),yr=(0,a.useCallback)(e=>{xt(e),C(1),K?.(e)},[C,K]),br=(0,a.useCallback)(e=>{let t;g==="single"?t=k.includes(e)?[]:[e]:t=k.includes(e)?k.filter(n=>n!==e):[...k,e],R||ke(t),W?.(t)},[g,k,R,W]),qe=(0,a.useMemo)(()=>new Set(k),[k]),$e=(0,a.useCallback)(()=>{let e=new Set(k),t=[...k];for(let n of V){let s=Ye(n.row,n.sourceIndex,c);e.has(s)||(e.add(s),t.push(s))}R||ke(t),W?.(t)},[V,c,k,R,W]),Gt=(0,a.useCallback)(()=>{R||ke([]),W?.([])},[R,W]),fr=(0,a.useCallback)(()=>{let e=new Set(V.map(n=>Ye(n.row,n.sourceIndex,c))),t=k.filter(n=>!e.has(n));R||ke(t),W?.(t)},[V,c,k,R,W]),Xe=A?V.map(Tt):[],_e=Xe.length>0&&Xe.every(e=>qe.has(e)),hr=!_e&&Xe.some(e=>qe.has(e)),vr=(0,a.useCallback)(e=>{let t=be.includes(e)?be.filter(n=>n!==e):[...be,e];Ee||or(t),nt?.(t)},[be,Ee,nt]),xr=(0,a.useCallback)(e=>{let t=e.target.value;ye||wt(t),xe?.(t),C(1)},[ye,xe,C]),wr=(0,a.useCallback)(e=>{let t=[...j.filter(n=>n.column!==e.column),e];X||Fe(t),te?.(t),C(1)},[j,X,te,C]),kr=(0,a.useCallback)(e=>{let t=j.filter(n=>n.column!==e);X||Fe(t),te?.(t),C(1)},[j,X,te,C]),Cr=(0,a.useCallback)(e=>{let t=J.includes(e)?J.filter(n=>n!==e):[...J,e];De||ir(t),lt?.(t)},[J,De,lt]),Sr=(0,a.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),Ve.current=!0;let n=e.clientX,s=ze[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,i=d.find(x=>x.key===t),h=i?.minWidth??50,M=i?.maxWidth??1/0,Y=x=>{let q=x.clientX-n,z=Math.min(M,Math.max(h,s+q));lr(me=>({...me,[t]:z}))},p=()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",p),setTimeout(()=>{Ve.current=!1},0)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",p)},[ze,d]),G=ne&&!(f==="client"&&F.some(e=>e.direction)),Nr=(0,a.useCallback)((e,t)=>{G&&Oe({key:e,sourceIndex:t})},[G]),Rr=(0,a.useCallback)(e=>{!G||_===null||e.preventDefault()},[G,_]),Tr=(0,a.useCallback)((e,t)=>{!G||_===null||(Oe(null),_.key!==e&&ot?.(_.sourceIndex,t))},[G,_,ot]),Er=(0,a.useCallback)(e=>{B&&kt(e)},[B]),Dr=(0,a.useCallback)(e=>{if(!B||!se||se===e)return;let t=[...Ce],n=t.indexOf(se),s=t.indexOf(e);n===-1||s===-1||(t.splice(n,1),t.splice(s,0,se),dr(t),st?.(se,e),kt(null))},[B,se,Ce,st]),Je=(0,a.useCallback)(e=>{let t=H.filter(x=>x.type!=="actions"&&x.type!=="selection"&&x.type!=="expand"),n=he,s,i,h;if(e==="csv")s=(0,zt.csvDocument)([t.map(x=>String(x.header)),...n.map(x=>t.map(q=>{let z=O(x,q.key);return typeof z=="number"?z:String(z??"")}))],{neutralizeFormulas:gt}),i="text/csv",h="csv";else{let x=n.map(q=>{let z={};for(let me of t)z[me.key]=O(q,me.key);return z});s=JSON.stringify(x,null,2),i="application/json",h="json"}let M=new Blob([s],{type:i}),Y=URL.createObjectURL(M),p=document.createElement("a");p.href=Y,p.download=`${ut}.${h}`,p.click(),URL.revokeObjectURL(Y)},[H,he,ut,gt]);(0,a.useEffect)(()=>{if(!Se)return;let e=t=>{Le.current&&!Le.current.contains(t.target)&&Ct(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Se]),(0,a.useImperativeHandle)(l,()=>({getVisibleData:()=>Ue,resetFilters:()=>{X||Fe([]),ye||wt(""),te?.([]),xe?.(""),C(1)},resetSort:()=>{w||vt([]),m?.([])},selectAll:$e,deselectAll:Gt,exportData:Je,scrollToRow:e=>{let t=He.current;if(!t||!T)return;let n=-1;for(let s=0;s<ue.length;s++){let i=ue[s];if(i.kind==="group")n=s;else if(i.index>=e){i.index===e&&(n=s);break}}n>=0&&(t.scrollTop=n*U)}}),[Ue,X,ye,w,te,xe,m,C,$e,Gt,Je,T,U,ue]);let Qe=e=>{let t={},n=ze[e.key]??e.width;return n&&(t.width=typeof n=="number"?`${n}px`:n,t.minWidth=typeof n=="number"?`${n}px`:n),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},pe=H.length+(A?1:0)+(re?1:0)+(ne?1:0),Gr=e=>{let t=D&&e.sortable!==!1&&e.type!=="actions",n=F.find(i=>i.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,r.jsxs)("th",{className:(0,y.cn)(I[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",Ge&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Xt),style:Qe(e),onClick:t?()=>{Ve.current||mr(e.key)}:void 0,draggable:B,onDragStart:B?()=>Er(e.key):void 0,onDragOver:B?i=>i.preventDefault():void 0,onDrop:B?()=>Dr(e.key):void 0,"aria-sort":n?.direction==="asc"?"ascending":n?.direction==="desc"?"descending":void 0,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&(0,r.jsx)("span",{className:"inline-flex ml-1",children:n?.direction==="asc"?(0,r.jsx)(jr,{}):n?.direction==="desc"?(0,r.jsx)(qr,{}):(0,r.jsx)($r,{})}),s&&(0,r.jsx)(sn,{column:e,value:j.find(i=>i.column===e.key),onApply:wr,onClear:()=>kr(e.key),labels:b})]}),e.resizable!==!1&&(0,r.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:i=>Sr(i,e.key)})]},e.key)},ve=T?Ur[v]:I[v],Mt=T?{height:U}:void 0,Mr=(e,t)=>{let{row:n,sourceIndex:s}=e,i=Tt(e),h=qe.has(i),M=be.includes(i),Y=typeof Ie=="function"?Ie(n,t):Ie;return(0,r.jsxs)(a.default.Fragment,{children:[(0,r.jsxs)("tr",{className:(0,y.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",T&&"whitespace-nowrap",mt&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",h&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",Me&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",_?.key===i&&"opacity-50",Y),onClick:Me?()=>Me(n,t):void 0,onDoubleClick:bt?()=>bt(n,t):void 0,onContextMenu:ft?p=>ft(n,t,p):void 0,draggable:G,onDragStart:G?()=>Nr(i,s):void 0,onDragOver:G?Rr:void 0,onDrop:G?()=>Tr(i,s):void 0,onDragEnd:G?()=>Oe(null):void 0,"data-row-key":i,"aria-selected":A?h:void 0,style:Mt,children:[ne&&(0,r.jsx)("td",{className:(0,y.cn)(ve,G?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,r.jsx)(_r,{})}),A&&(0,r.jsx)("td",{className:(0,y.cn)(ve,"w-10"),children:(0,r.jsx)("input",{type:"checkbox",checked:h,onChange:()=>br(i),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,E.formatUILabel)(b.dataGridSelectRow,{row:i})})}),re&&(0,r.jsx)("td",{className:(0,y.cn)(ve,"w-10"),children:(0,r.jsx)("button",{type:"button",onClick:p=>{p.stopPropagation(),vr(i)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":M?b.dataGridCollapseRow:b.dataGridExpandRow,"aria-expanded":M,children:(0,r.jsx)(Pt,{className:(0,y.cn)("transition-transform",M&&"rotate-180")})})}),H.map(p=>{let x=O(n,p.key),q=p.colSpan?.(n,t);if(q===0)return null;let z=at&&p.editable!==!1&&p.type!=="actions";return(0,r.jsx)("td",{className:(0,y.cn)(ve,Te[v],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",Ge&&"border border-gray-200 dark:border-gray-700",p.sticky&&(h?"bg-synertech-primary-50 dark:bg-synertech-primary-900/20":mt&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,$t),style:Qe(p),colSpan:q,children:z?(0,r.jsx)(ln,{value:x,onSave:me=>At?.(i,p.key,me),density:v,labels:b}):p.render?p.render(x,n,t):String(x??"")},p.key)})]}),re&&M&&rt&&(0,r.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)(I[v]),children:rt(n,t)})})]},i)},Ir=e=>{let{key:t,rows:n}=e,s=Ae.has(t);return(0,r.jsx)("tr",{className:(0,y.cn)("bg-gray-100 dark:bg-gray-800 font-medium",T&&"whitespace-nowrap"),style:Mt,children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)(ve,"cursor-pointer"),onClick:()=>{cr(i=>{let h=new Set(i);return h.has(t)?h.delete(t):h.add(t),h})},children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(Pt,{className:(0,y.cn)("transition-transform",s&&"-rotate-90")}),dt?dt(t,O(n[0].row,de[0]),n.map(i=>i.row)):`${t} (${n.length})`]})})},`group-${t}`)},Pr=()=>{if(Vt)return Array.from({length:Kt}).map((s,i)=>(0,r.jsx)(on,{cols:pe,density:v},i));if(Ue.length===0)return(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:pe,className:(0,y.cn)("text-center text-gray-500 dark:text-gray-400",I[v]),children:Wt??b.dataGridNoData})});let e=s=>s.kind==="row"?Mr(s.entry,s.index):Ir(s);if(!T)return ue.map(e);let{start:t,end:n}=pr;return(0,r.jsxs)(r.Fragment,{children:[t>0&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:t*U,padding:0}})}),ue.slice(t,n).map(e),n<ge&&(0,r.jsx)("tr",{"aria-hidden":"true",children:(0,r.jsx)("td",{colSpan:pe,style:{height:(ge-n)*U,padding:0}})})]})},Fr=(e,t)=>{let n=nn(he,e.key,t);return e.renderAggregate?e.renderAggregate(n??0,he):n===null?"":an(t,n.toLocaleString(Pe),b)},zr=()=>!jt||!H.some(t=>t.aggregate)?null:(0,r.jsx)("tfoot",{children:(0,r.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[ne&&(0,r.jsx)("td",{className:I[v]}),A&&(0,r.jsx)("td",{className:I[v]}),re&&(0,r.jsx)("td",{className:I[v]}),H.map(t=>(0,r.jsx)("td",{className:(0,y.cn)(I[v],Te[v],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Ge&&"border border-gray-200 dark:border-gray-700"),style:Qe(t),children:t.aggregate?Fr(t,t.aggregate):""},t.key))]})});return(0,r.jsxs)("div",{className:(0,y.cn)("flex flex-col gap-3",qt),children:[(tt||ct||it)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[tt&&(0,r.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,r.jsx)(Xr,{})}),(0,r.jsx)("input",{type:"text",value:Ne,onChange:xr,placeholder:Ot??b.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-synertech-primary-500 focus:border-synertech-primary-500","aria-label":b.dataGridSearch})]}),k.length>0&&(0,r.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,E.formatUILabel)(b.dataGridSelectedCount,{count:k.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[it&&(0,r.jsxs)("div",{className:"relative",ref:Le,children:[(0,r.jsx)("button",{type:"button",onClick:()=>Ct(!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":b.dataGridToggleColumns,title:b.dataGridToggleColumns,children:(0,r.jsx)(Yr,{})}),Se&&(0,r.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,r.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,r.jsx)("input",{type:"checkbox",checked:!J.includes(e.key),onChange:()=>Cr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,r.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),ct&&Ht.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>Je(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,E.formatUILabel)(b.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,r.jsx)(Qr,{}),e.toUpperCase()]},e))]})]}),(0,r.jsx)("div",{ref:He,className:(0,y.cn)("overflow-auto rounded-lg",!Lt&&"border border-gray-200 dark:border-gray-700",yt&&"relative"),style:ae?{maxHeight:typeof ae=="number"?`${ae}px`:ae}:T?{maxHeight:pt,overflow:"auto"}:void 0,onScroll:T?e=>{let t=e.currentTarget;ur(Math.floor(t.scrollTop/U)),t.clientHeight>0&&Nt(t.clientHeight)}:void 0,children:(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:(0,y.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",yt&&"sticky top-0 z-20"),children:(0,r.jsxs)("tr",{children:[ne&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),A&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10"),children:g==="multiple"&&(0,r.jsx)("input",{type:"checkbox",checked:_e,ref:e=>{e&&(e.indeterminate=hr)},onChange:_e?fr:$e,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":b.dataGridSelectAllRows})}),re&&(0,r.jsx)("th",{className:(0,y.cn)(I[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),H.map(Gr)]})}),(0,r.jsx)("tbody",{children:Pr()}),zr()]})}),ie&&(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[ie.showTotalItems!==!1&&(0,r.jsx)("span",{children:(0,E.formatUILabel)(Be===1?b.dataGridItemCount:b.dataGridItemsCount,{count:Be})}),ie.showPageSizeSelector!==!1&&ie.pageSizeOptions&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{children:b.dataGridRowsPerPage}),(0,r.jsx)("select",{value:fe,onChange:e=>yr(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:ie.pageSizeOptions.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"mr-2",children:(0,E.formatUILabel)(b.dataGridPageOf,{page:L,total:Q})}),(0,r.jsx)("button",{type:"button",onClick:()=>C(1),disabled:L<=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":b.dataGridFirstPage,children:"\xAB\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(L-1),disabled:L<=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":b.dataGridPreviousPage,children:"\xAB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(L+1),disabled:L>=Q,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":b.dataGridNextPage,children:"\xBB"}),(0,r.jsx)("button",{type:"button",onClick:()=>C(Q),disabled:L>=Q,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":b.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var cn=(0,a.forwardRef)(dn);0&&(module.exports={DataGrid,resetRowKeyWarning});
|