@object-ui/plugin-list 4.6.0 → 4.7.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/CHANGELOG.md +8 -0
- package/dist/index.js +25 -7
- package/dist/index.umd.cjs +2 -2
- package/dist/packages/plugin-list/src/ListView.d.ts.map +1 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @object-ui/plugin-list
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 186fb2b: Mobile UI optimization: declutter list & kanban on small screens.
|
|
8
|
+
- **ListView toolbar** now auto-collapses HideFields / Group / Color / Density into a single settings gear at `<sm` breakpoints, even when `compactToolbar` is not enabled. Desktop behavior unchanged.
|
|
9
|
+
- **Kanban board** replaces the verbose "← Swipe to navigate →" caption with a compact dot indicator that tracks which column is currently snapped into view. Hidden when there is only one column.
|
|
10
|
+
|
|
3
11
|
## 4.6.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1414,7 +1414,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1414
1414
|
children: /* @__PURE__ */ F(d, {
|
|
1415
1415
|
variant: "ghost",
|
|
1416
1416
|
size: "sm",
|
|
1417
|
-
className: C("h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", q.size > 0 && "text-primary"),
|
|
1417
|
+
className: C("hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", q.size > 0 && "text-primary"),
|
|
1418
1418
|
children: [
|
|
1419
1419
|
/* @__PURE__ */ P(ie, { className: "h-3.5 w-3.5 mr-1.5" }),
|
|
1420
1420
|
/* @__PURE__ */ P("span", {
|
|
@@ -1465,7 +1465,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1465
1465
|
})
|
|
1466
1466
|
})]
|
|
1467
1467
|
}),
|
|
1468
|
-
A.showHideFields && !A.compactToolbar && (A.showFilters || A.showSort || A.showGroup) && /* @__PURE__ */ P("div", { className: "h-5 w-px bg-border/50 mx-1 shrink-0" }),
|
|
1468
|
+
A.showHideFields && !A.compactToolbar && (A.showFilters || A.showSort || A.showGroup) && /* @__PURE__ */ P("div", { className: "hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0" }),
|
|
1469
1469
|
A.showFilters && /* @__PURE__ */ F(y, {
|
|
1470
1470
|
open: Me,
|
|
1471
1471
|
onOpenChange: Pe,
|
|
@@ -1516,7 +1516,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1516
1516
|
children: /* @__PURE__ */ F(d, {
|
|
1517
1517
|
variant: "ghost",
|
|
1518
1518
|
size: "sm",
|
|
1519
|
-
className: C("h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", G && "text-foreground font-medium"),
|
|
1519
|
+
className: C("hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", G && "text-foreground font-medium"),
|
|
1520
1520
|
children: [
|
|
1521
1521
|
/* @__PURE__ */ P(ae, { className: "h-3.5 w-3.5 mr-1.5" }),
|
|
1522
1522
|
/* @__PURE__ */ P("span", {
|
|
@@ -1609,7 +1609,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1609
1609
|
})
|
|
1610
1610
|
})]
|
|
1611
1611
|
}),
|
|
1612
|
-
!A.compactToolbar && (A.showFilters || A.showSort || A.showGroup) && (A.showColor || A.showDensity) && /* @__PURE__ */ P("div", { className: "h-5 w-px bg-border/50 mx-1 shrink-0" }),
|
|
1612
|
+
!A.compactToolbar && (A.showFilters || A.showSort || A.showGroup) && (A.showColor || A.showDensity) && /* @__PURE__ */ P("div", { className: "hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0" }),
|
|
1613
1613
|
A.showColor && !A.compactToolbar && /* @__PURE__ */ F(y, {
|
|
1614
1614
|
open: ct,
|
|
1615
1615
|
onOpenChange: lt,
|
|
@@ -1618,7 +1618,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1618
1618
|
children: /* @__PURE__ */ F(d, {
|
|
1619
1619
|
variant: "ghost",
|
|
1620
1620
|
size: "sm",
|
|
1621
|
-
className: C("h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", K && "text-foreground font-medium"),
|
|
1621
|
+
className: C("hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150", K && "text-foreground font-medium"),
|
|
1622
1622
|
children: [/* @__PURE__ */ P(se, { className: "h-3.5 w-3.5 mr-1.5" }), /* @__PURE__ */ P("span", {
|
|
1623
1623
|
className: "hidden sm:inline",
|
|
1624
1624
|
children: E("list.color")
|
|
@@ -1680,7 +1680,7 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1680
1680
|
variant: "ghost",
|
|
1681
1681
|
size: "sm",
|
|
1682
1682
|
"aria-label": n,
|
|
1683
|
-
className: C("h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150", X.mode !== "compact" && "text-foreground font-medium"),
|
|
1683
|
+
className: C("hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150", X.mode !== "compact" && "text-foreground font-medium"),
|
|
1684
1684
|
onClick: X.cycle,
|
|
1685
1685
|
title: r,
|
|
1686
1686
|
children: /* @__PURE__ */ P(e, { className: "h-3.5 w-3.5" })
|
|
@@ -1695,12 +1695,30 @@ var Xe = a.forwardRef(({ schema: e, className: n, onViewChange: o, onFilterChang
|
|
|
1695
1695
|
variant: "ghost",
|
|
1696
1696
|
size: "sm",
|
|
1697
1697
|
"aria-label": n,
|
|
1698
|
-
className: C("h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150", Z !== "small" && "text-foreground font-medium"),
|
|
1698
|
+
className: C("hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150", Z !== "small" && "text-foreground font-medium"),
|
|
1699
1699
|
onClick: Dt,
|
|
1700
1700
|
title: r,
|
|
1701
1701
|
children: /* @__PURE__ */ P(e, { className: "h-3.5 w-3.5" })
|
|
1702
1702
|
});
|
|
1703
1703
|
})(),
|
|
1704
|
+
!A.compactToolbar && (A.showGroup || A.showColor || A.showDensity || A.showHideFields) && /* @__PURE__ */ P("div", {
|
|
1705
|
+
className: "sm:hidden",
|
|
1706
|
+
children: /* @__PURE__ */ P(Ie, {
|
|
1707
|
+
t: E,
|
|
1708
|
+
allFields: Ht,
|
|
1709
|
+
showGroup: A.showGroup,
|
|
1710
|
+
groupingConfig: G,
|
|
1711
|
+
setGroupingConfig: rt,
|
|
1712
|
+
showColor: A.showColor,
|
|
1713
|
+
rowColorConfig: K,
|
|
1714
|
+
setRowColorConfig: st,
|
|
1715
|
+
showDensity: A.showDensity,
|
|
1716
|
+
density: X,
|
|
1717
|
+
showHideFields: A.showHideFields,
|
|
1718
|
+
hiddenFields: q,
|
|
1719
|
+
updateHiddenFields: bt
|
|
1720
|
+
})
|
|
1721
|
+
}),
|
|
1704
1722
|
A.compactToolbar && (A.showGroup || A.showColor || A.showDensity || A.showHideFields) && /* @__PURE__ */ P(Ie, {
|
|
1705
1723
|
t: E,
|
|
1706
1724
|
allFields: Ht,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@object-ui/i18n`),require(`@object-ui/react`),require(`@object-ui/mobile`),require(`@object-ui/permissions`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@object-ui/i18n`,`@object-ui/react`,`@object-ui/mobile`,`@object-ui/permissions`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginList={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.jsxRuntime,e.ObjectUIi18n,e.ObjectUIReact,e.ObjectUIMobile,e._object_ui_permissions,e.ObjectUIFields))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var v={grid:(0,a.jsx)(i.Grid,{className:`h-4 w-4`}),kanban:(0,a.jsx)(i.LayoutGrid,{className:`h-4 w-4`}),gallery:(0,a.jsx)(i.Images,{className:`h-4 w-4`}),calendar:(0,a.jsx)(i.Calendar,{className:`h-4 w-4`}),timeline:(0,a.jsx)(i.Activity,{className:`h-4 w-4`}),gantt:(0,a.jsx)(i.GanttChartSquare,{className:`h-4 w-4`}),map:(0,a.jsx)(i.Map,{className:`h-4 w-4`})},y={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`},b=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:i,className:o,animated:s=!0})=>{let c=n.useCallback(t=>{if(!s||t===e){i(t);return}typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>i(t)):i(t)},[s,e,i]);return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 bg-transparent oui-view-switcher`,o),children:t.map(t=>{let n=e===t;return(0,a.jsxs)(`button`,{type:`button`,onClick:()=>c(t),"aria-label":y[t],title:y[t],"aria-pressed":n,"data-state":n?`on`:`off`,className:(0,r.cn)(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`hover:bg-muted hover:text-muted-foreground`,`gap-2 px-3 py-2`,`data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50`),children:[v[t],(0,a.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:y[t]})]},t)})})};function x(e){return e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function S(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var ee=({tabs:e,activeTab:t,onTabChange:i,className:o})=>{let s=n.useMemo(()=>S(e),[e]),c=n.useMemo(()=>s.find(e=>e.isDefault)?.name??s[0]?.name,[s]),[l,u]=n.useState(c),d=t??l,f=n.useCallback(e=>{u(e.name),i?.(e)},[i]);return s.length===0?null:(0,a.jsx)(`div`,{className:(0,r.cn)(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,o),"data-testid":`view-tabs`,role:`tablist`,children:s.map(e=>{let t=x(e.icon),n=d===e.name;return(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2.5 py-1 text-xs rounded-md transition-colors duration-150`,n?`font-medium text-foreground bg-muted`:`text-muted-foreground hover:text-foreground hover:bg-transparent`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>f(e),children:[t&&(0,a.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})};function C({title:e,badge:t,onClear:o,clearLabel:s,defaultOpen:c=!0,children:l}){let[u,d]=n.useState(c);return(0,a.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,a.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,a.jsx)(i.ChevronDown,{className:(0,r.cn)(`h-3.5 w-3.5 transition-transform`,!u&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,a.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),o&&(0,a.jsx)(`button`,{type:`button`,onClick:o,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:s})]}),u&&(0,a.jsx)(`div`,{className:`px-3 pb-3`,children:l})]})}function te(e){let{t,allFields:o,showGroup:s,groupingConfig:c,setGroupingConfig:l,showColor:u,rowColorConfig:d,setRowColorConfig:f,showDensity:p,density:m,showHideFields:h,hiddenFields:g,updateHiddenFields:_}=e,[v,y]=n.useState(!1),b=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0].filter(Boolean).length,x=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,S=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,a.jsxs)(r.Popover,{open:v,onOpenChange:y,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":S,title:S,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,b>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,a.jsx)(i.Settings2,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S}),b>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:b})]})}),(0,a.jsxs)(r.PopoverContent,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,a.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,a.jsx)(`div`,{className:`text-sm font-semibold`,children:S}),(0,a.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),s&&l&&(0,a.jsx)(C,{title:t(`list.group`,{defaultValue:`Group`}),badge:c?.fields?.length||0,onClear:c?()=>l(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,a.jsx)(r.GroupingEditor,{value:c,fieldOptions:o.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>l(e)})}),u&&f&&(0,a.jsxs)(C,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:d?()=>f(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!d,children:[(0,a.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:d?.field||``,onChange:e=>{let t=e.target.value;f(t?{field:t,colors:d?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),o.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),p&&m&&(0,a.jsx)(C,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:m.mode!==`compact`,children:(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:m.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,a.jsx)(x,{className:`h-3.5 w-3.5`}),(0,a.jsx)(`span`,{className:`text-xs`,children:m.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):m.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,a.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),h&&g&&_&&(0,a.jsx)(C,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:g.size,onClear:g.size>0?()=>_(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:g.size>0,children:(0,a.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:o.map(e=>(0,a.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:!g.has(e.name),onChange:()=>{let t=new Set(g);t.has(e.name)?t.delete(e.name):t.add(e.name),_(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function ne(){try{let{t:e}=(0,o.useObjectTranslation)(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var w=new Set([`lookup`,`master_detail`,`user`,`owner`]);function re({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:o}){switch(e.element){case`dropdown`:return(0,a.jsx)(E,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:o});case`tabs`:return(0,a.jsx)(D,{tabs:e.tabs||[],showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:o});case`toggle`:return(0,a.jsx)(O,{fields:e.fields||[],onFilterChange:r,className:o});default:return null}}function T(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function E({fields:e,objectDef:t,data:s,onFilterChange:c,maxVisible:l,className:u}){let{fieldLabel:d,translateOptions:f}=(0,o.useSafeFieldLabel)(),p=ne(),m=t?.name,[h,g]=n.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues)}),t}),_=n.useMemo(()=>T(e,t,s,{objectName:m,fieldLabel:d,translateOptions:f}),[e,t,s,m,d,f]),v=n.useCallback(e=>{c(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[c]),y=(e,t)=>{let n={...h,[e]:t};g(n),v(n)};n.useEffect(()=>{Object.values(h).some(e=>e.length>0)&&v(h)},[]);let b=l!==void 0&&l<_.length?_.slice(0,l):_,x=l!==void 0&&l<_.length?_.slice(l):[],S=e=>{let t=h[e.field]||[],n=t.length>0,o=w.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),s=o?`w-72`:`w-56`;return(0,a.jsxs)(r.Popover,{children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:(0,r.cn)(`inline-flex items-center gap-1 h-7 px-2 text-xs transition-colors shrink-0 rounded-md`,n?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,a.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:t.length}),n?(0,a.jsx)(i.X,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),y(e.field,[])}}):(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:(0,r.cn)(s,`p-2`),children:o?(0,a.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,a.jsx)(r.LookupValuePicker,{field:{value:e.field,label:e.label||e.field,type:e.type,referenceTo:e.referenceTo,displayField:e.displayField,idField:e.idField},value:t,multiple:!0,onChange:t=>{let n=Array.isArray(t)?t:t==null||t===``?[]:[t];y(e.field,n)}})}):(0,a.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.length===0?(0,a.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,a.jsxs)(`label`,{className:(0,r.cn)(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:t.includes(n.value),onChange:()=>{let r=t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];y(e.field,r)},className:`rounded border-input`}),n.color&&(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,a.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,u),"data-testid":`user-filters-dropdown`,children:_.length===0?(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,a.jsxs)(a.Fragment,{children:[b.map(S),x.length>0&&(0,a.jsxs)(r.Popover,{children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 h-7 px-2 text-xs text-muted-foreground hover:text-foreground transition-colors shrink-0 rounded-md`,children:[(0,a.jsx)(`span`,{children:p}),(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:x.length}),(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,a.jsx)(`div`,{className:`space-y-1`,children:x.map(S)})})]})]})})}function D({tabs:e,showAllRecords:t,allowAddTab:o,onFilterChange:s,className:c}){let[l,u]=n.useState(()=>e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),d=n.useCallback(t=>{u(t),s(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[])},[e,s]),f=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return n.useEffect(()=>{let t=e.find(e=>e.default);t&&s(t.filters||[])},[]),(0,a.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,c),"data-testid":`user-filters-tabs`,children:[f.map(e=>(0,a.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>d(e.id),className:(0,r.cn)(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,l===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),o&&(0,a.jsx)(`button`,{className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5`})})]})}function O({fields:e,onFilterChange:t,className:i}){let[o,s]=n.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),c=n.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),c(n),n})};return n.useEffect(()=>{o.size>0&&c(o)},[]),(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 overflow-x-auto`,i),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,a.jsx)(r.Button,{variant:o.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>l(e.field),children:e.label||e.field},e.field))})}function k(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`:return`notcontains`;case`greaterThan`:case`gt`:return`>`;case`greaterOrEqual`:case`gte`:return`>=`;case`lessThan`:case`lt`:return`<`;case`lessOrEqual`:case`lte`:return`<=`;case`in`:return`in`;case`notIn`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function A(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?A(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:n===`not in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function ie(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function j(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?A(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function ae(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=j(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,k(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}function M(e,n){if(!n||n.length===0)return{};for(let r of n){let n=!1,i=(`condition`in r?r.condition:void 0)||(`expression`in r?r.expression:void 0)||void 0;if(i)n=(0,t.evaluatePlainCondition)(i,e);else if(`field`in r&&`operator`in r&&r.field&&r.operator){let t=e[r.field];switch(r.operator){case`equals`:n=t===r.value;break;case`not_equals`:n=t!==r.value;break;case`contains`:n=typeof t==`string`&&typeof r.value==`string`&&t.includes(r.value);break;case`greater_than`:n=typeof t==`number`&&typeof r.value==`number`&&t>r.value;break;case`less_than`:n=typeof t==`number`&&typeof r.value==`number`&&t<r.value;break;case`in`:n=Array.isArray(r.value)&&r.value.includes(t);break}}if(n){let e={};return`style`in r&&r.style&&Object.assign(e,r.style),`backgroundColor`in r&&r.backgroundColor&&(e.backgroundColor=r.backgroundColor),`textColor`in r&&r.textColor&&(e.color=r.textColor),`borderColor`in r&&r.borderColor&&(e.borderColor=r.borderColor),e}}return{}}var oe={"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},se=(e,t,n)=>n,ce=(e,t)=>{let n=oe[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function le(){try{let e=(0,o.useObjectTranslation)();return e.t(`list.recordCount`)===`list.recordCount`?{t:ce}:{t:e.t}}catch{return{t:ce}}}function ue(){try{let{fieldLabel:e}=(0,o.useObjectLabel)();return{fieldLabel:e}}catch{return{fieldLabel:se}}}var N=n.forwardRef(({schema:e,className:u,onViewChange:d,onFilterChange:f,onSortChange:p,onSearchChange:m,onHiddenFieldsChange:h,onColumnStateChange:g,onRowClick:_,showViewSwitcher:v=!1,...y},x)=>{let{t:S}=le(),{fieldLabel:C}=ue(),{translateOptions:ne}=(0,o.useSafeFieldLabel)(),w=n.useMemo(()=>e.viewType?e:{...e,viewType:`grid`},[e]),T=n.useCallback((e,t)=>w.objectName?C(w.objectName,e,t):t,[w.objectName,C]),E=n.useMemo(()=>{let e=w.userActions,t=w.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?w.showSearch!==!1:e.search,showSort:e?.sort===void 0?w.showSort!==!1:e.sort,showFilters:e?.filter===void 0?w.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?w.showDensity!==!1:e.rowHeight,showHideFields:w.showHideFields===!0,showGroup:w.showGroup!==!1,showColor:w.showColor===!0,compactToolbar:w.compactToolbar===!0,showAddRecord:t,addRecordPosition:w.addRecord?.position===`bottom`?`bottom`:`top`}},[w.userActions,w.showSearch,w.showSort,w.showFilters,w.showDensity,w.showHideFields,w.showGroup,w.showColor,w.compactToolbar,w.addRecord,w.userActions?.addRecordForm]),[D,O]=n.useState(w.viewType),[k,A]=n.useState(``),[M,oe]=n.useState(!1),[se,ce]=n.useState(!1),[N,P]=n.useState(()=>w.sort&&w.sort.length>0?w.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),de=n.useMemo(()=>JSON.stringify(w.sort||[]),[w.sort]);n.useEffect(()=>{w.sort&&w.sort.length>0?P(w.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):P([])},[de]);let[fe,pe]=n.useState(!1),[F,me]=n.useState({id:`root`,logic:`and`,conditions:[]}),[he,ge]=n.useState(()=>{if(!(!w.tabs||w.tabs.length===0))return w.tabs.find(e=>e.isDefault)?.name??w.tabs[0]?.name}),_e=n.useCallback(e=>{if(ge(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};me(t),f?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};me(e),f?.(e)}},[f]),I=y.dataSource,[L,ve]=n.useState([]),[ye,be]=n.useState(!1),[R,xe]=n.useState(null),[Se,Ce]=n.useState(!1),[we,Te]=n.useState(0),[Ee,De]=n.useState(!1);n.useImperativeHandle(x,()=>({refresh:()=>Te(e=>e+1)}),[]),n.useEffect(()=>{if(!(!I?.onMutation||!w.objectName||w.refreshTrigger))return I.onMutation(e=>{e.resource===w.objectName&&Te(e=>e+1)})},[I,w.objectName,w.refreshTrigger]);let[Oe,ke]=n.useState(void 0),z=Oe??w.pagination?.pageSize??100,B=n.useMemo(()=>{if(w.grouping?.fields?.length)return w.grouping;let e=typeof w.groupBy==`string`?w.groupBy.trim():``,t=typeof w.groupBy2==`string`?w.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[w.grouping,w.groupBy,w.groupBy2]),[V,H]=n.useState(B),[Ae,je]=n.useState(!1),Me=n.useRef(B);n.useEffect(()=>{Me.current!==B&&(Me.current=B,H(B))},[B]);let[U,Ne]=n.useState(w.rowColor),[Pe,Fe]=n.useState(!1),[W,Ie]=n.useState([]),G=n.useRef(0),[K,Le]=n.useState(()=>{let e=new Set;return w.quickFilters?.forEach(n=>{let r=(0,t.normalizeQuickFilter)(n);r.defaultActive&&e.add(r.id)}),e}),[Re,ze]=n.useState([]),Be=n.useMemo(()=>{if(w.userFilters)return w.userFilters;if(!R?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(R.fields)?R.fields.map(e=>[e.name,e]):Object.entries(R.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:T(r,i.label||r),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});if(t.length!==0)return{element:`dropdown`,fields:t}},[w.userFilters,R]),[q,Ve]=n.useState(()=>new Set(w.hiddenFields||[])),He=n.useMemo(()=>JSON.stringify(w.hiddenFields||[]),[w.hiddenFields]);n.useEffect(()=>{Ve(new Set(w.hiddenFields||[]))},[He]);let Ue=n.useCallback(e=>{Ve(e),h?.(Array.from(e))},[h]),[We,Ge]=n.useState(!1),[Ke,qe]=n.useState(!1),J=n.useMemo(()=>(0,t.normalizeQuickFilters)(w.quickFilters),[w.quickFilters]),Y=n.useMemo(()=>{if(w.exportOptions)return Array.isArray(w.exportOptions)?{formats:w.exportOptions}:w.exportOptions},[w.exportOptions]),X=(0,s.useDensityMode)(n.useMemo(()=>w.densityMode?w.densityMode:w.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[w.rowHeight]||`comfortable`:`compact`,[w.densityMode,w.rowHeight]),{onChange:w.onDensityChange}),Je=n.useMemo(()=>`objectui:gallery:density:${w.objectName??`default`}`,[w.objectName]),[Z,Ye]=n.useState(()=>{if(typeof window>`u`)return w.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(Je);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return w.gallery?.cardSize??`medium`}),Xe=n.useCallback(()=>{Ye(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(Je,t)}catch{}return t})},[Je]),{ref:Ze,isRefreshing:Qe,pullDistance:$e}=(0,c.usePullToRefresh)({onRefresh:n.useCallback(async()=>{Te(e=>e+1)},[]),enabled:!!I&&!!w.objectName}),et=n.useMemo(()=>w.id?`listview-${w.objectName}-${w.id}-view`:`listview-${w.objectName}-view`,[w.objectName,w.id]);n.useEffect(()=>{let e=!0;return Ce(!1),xe(null),(async()=>{if(!I||!w.objectName){Ce(!0);return}if(typeof I.getObjectSchema!=`function`){Ce(!0);return}try{let t=await I.getObjectSchema(w.objectName);e&&xe(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Ce(!0)}})(),()=>{e=!1}},[w.objectName,I]);let tt=n.useMemo(()=>{let e=Array.isArray(w.fields)?w.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],n=new Set(e),r=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)typeof e==`string`&&e&&n.add(e)};r(w.kanban),r(w.options?.kanban),r(w.calendar),r(w.options?.calendar),r(w.gallery),r(w.options?.gallery),r(w.timeline),r(w.options?.timeline),r(w.gantt),r(w.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(R?.fields,i)},[R?.fields,w.fields,w.kanban,w.calendar,w.gallery,w.timeline,w.gantt,w.options]),Q=(0,l.usePermissions)();n.useEffect(()=>{let e=!0,t=++G.current;if(w.data&&typeof w.data==`object`&&!Array.isArray(w.data)){let e=w.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(k){let e=k.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ve(t),be(!1),De(!1);return}}if(Array.isArray(w.data)){let e=w.data;if(k){let t=k.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ve(e),be(!1),De(!1);return}return Se?((async()=>{if(!(!I||!w.objectName)){be(!0);try{let n=[],r=w.filters||[],i=ae(F),a=[];J&&K.size>0&&J.forEach(e=>{K.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=j(Re),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=N.length>0?N.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(w.fields)?w.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Q?.isLoaded&&w.objectName?e.filter(e=>Q.checkField(w.objectName,e,`read`)):e;if(t.length===0)return;let n=new Set([`id`]);for(let e of t)n.add(e);for(let e of tt)n.add(e);let r=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)typeof e==`string`&&e&&n.add(e)};r(w.kanban),r(w.options?.kanban),r(w.calendar),r(w.options?.calendar),r(w.gallery),r(w.options?.gallery),r(w.timeline),r(w.options?.timeline);{let e=w.timeline??w.options?.timeline;e&&!Array.isArray(e.metaFields)&&(n.add(`status`),n.add(`priority`))}return r(w.gantt),r(w.options?.gantt),Array.from(n)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await I.find(w.objectName,{...u?{$filter:n}:{},$orderby:c,$top:z,...l?{$select:l}:{},...tt.length>0?{$expand:tt}:{},...k?{$search:k,...w.searchableFields&&w.searchableFields.length>0?{$searchFields:w.searchableFields}:{}}:{}});if(!e||t!==G.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),ve(f),De(f.length>=z)}catch(e){t===G.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===G.current&&be(!1)}}})(),()=>{e=!1}):void 0},[w.objectName,w.data,I,w.filters,z,N,F,K,J,Re,we,k,w.searchableFields,tt,Se,w.refreshTrigger,Q]);let nt=n.useMemo(()=>{if(w.appearance?.allowedVisualizations&&w.appearance.allowedVisualizations.length>0)return w.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(w.kanban?.groupField||w.options?.kanban?.groupField)&&e.push(`kanban`),(w.gallery?.coverField||w.gallery?.imageField||w.options?.gallery?.imageField)&&e.push(`gallery`),(w.calendar?.startDateField||w.options?.calendar?.startDateField)&&e.push(`calendar`),(w.timeline?.startDateField||w.options?.timeline?.startDateField||w.options?.timeline?.dateField||w.options?.calendar?.startDateField)&&e.push(`timeline`),(w.gantt?.startDateField||w.options?.gantt?.startDateField)&&e.push(`gantt`),(w.options?.map?.locationField||w.options?.map?.latitudeField&&w.options?.map?.longitudeField)&&e.push(`map`),w.viewType&&!e.includes(w.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(w.viewType)&&e.push(w.viewType),e},[w.options,w.viewType,w.kanban,w.calendar,w.gantt,w.gallery,w.timeline,w.appearance?.allowedVisualizations]);n.useEffect(()=>{w.viewType&&O(w.viewType)},[w.viewType]);let rt=n.useCallback(e=>{O(e);try{localStorage.setItem(et,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}d?.(e)},[et,d]),it=n.useCallback(e=>{A(e),m?.(e)},[m]),at=(0,s.useNavigationOverlay)({navigation:w.navigation,objectName:w.objectName,onNavigate:w.onNavigate,onRowClick:_}),$=n.useMemo(()=>{let e=w.fields||[];if(Array.isArray(e)||(e=[]),Q?.isLoaded&&w.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?Q.checkField(w.objectName,t,`read`):!0})),q.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!q.has(t)})),w.fieldOrder&&w.fieldOrder.length>0){let t=new Map(w.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>{let r=typeof e==`string`?e:e?.name||e?.fieldName||e?.field,i=typeof n==`string`?n:n?.name||n?.fieldName||n?.field;return(t.get(r)??1/0)-(t.get(i)??1/0)})}return e},[w.fields,w.objectName,q,w.fieldOrder,Q]),ot=n.useMemo(()=>{let e=X.mode===`compact`?`compact`:X.mode===`spacious`?`tall`:`medium`,t={objectName:w.objectName,fields:$,filters:w.filters,sort:N,className:`h-full w-full`,showSearch:!1,onRowClick:at.handleClick,rowHeight:e,hideRowHeightToggle:!0,...w.striped==null?{}:{striped:w.striped},...w.bordered==null?{}:{bordered:w.bordered},...g?{onColumnStateChange:g}:{},...w.columnState?{columnState:w.columnState}:{}};switch(D){case`grid`:return{type:`object-grid`,...t,columns:$,...w.conditionalFormatting?{conditionalFormatting:w.conditionalFormatting}:{},...w.inlineEdit==null?{}:{editable:w.inlineEdit},...w.wrapHeaders==null?{}:{wrapHeaders:w.wrapHeaders},...w.virtualScroll==null?{}:{virtualScroll:w.virtualScroll},...w.resizable==null?{}:{resizable:w.resizable},...w.selection?{selection:w.selection}:{},...w.pagination?{pagination:w.pagination}:{},...V?{grouping:V}:{},...U?{rowColor:U}:{},...w.rowActions?{rowActions:w.rowActions}:{},...w.rowActionDefs?{rowActionDefs:w.rowActionDefs}:{},...w.bulkActions?{batchActions:w.bulkActions}:{},...w.bulkActionDefs?{bulkActionDefs:w.bulkActionDefs}:{},...w.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:w.kanban?.groupField||w.options?.kanban?.groupField||`status`,groupField:w.kanban?.groupField||w.options?.kanban?.groupField||`status`,...w.kanban?.titleField||w.options?.kanban?.titleField?{titleField:w.kanban?.titleField||w.options?.kanban?.titleField}:{},cardFields:w.kanban?.cardFields||$||[],...V?{grouping:V}:{},...w.options?.kanban||{},...w.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:w.calendar?.startDateField||w.options?.calendar?.startDateField||`start_date`,endDateField:w.calendar?.endDateField||w.options?.calendar?.endDateField||`end_date`,...w.calendar?.titleField||w.options?.calendar?.titleField?{titleField:w.calendar?.titleField||w.options?.calendar?.titleField}:{},...w.calendar?.defaultView?{defaultView:w.calendar.defaultView}:{},...w.options?.calendar||{},...w.calendar||{}};case`gallery`:{let e={...w.options?.gallery||{},...w.gallery||{},cardSize:Z};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:w.gallery?.coverField||w.gallery?.imageField||w.options?.gallery?.imageField,titleField:w.gallery?.titleField||w.options?.gallery?.titleField||`name`,subtitleField:w.gallery?.subtitleField||w.options?.gallery?.subtitleField,...V?{grouping:V}:{}}}case`timeline`:{let e={...w.options?.timeline||{},...w.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:w.timeline?.startDateField||w.options?.timeline?.startDateField||w.options?.timeline?.dateField||`created_at`,titleField:w.timeline?.titleField||w.options?.timeline?.titleField||`name`,...w.timeline?.endDateField?{endDateField:w.timeline.endDateField}:{},...w.timeline?.groupByField?{groupByField:w.timeline.groupByField}:{},...w.timeline?.colorField?{colorField:w.timeline.colorField}:{},...w.timeline?.scale?{scale:w.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:w.gantt?.startDateField||w.options?.gantt?.startDateField||`start_date`,endDateField:w.gantt?.endDateField||w.options?.gantt?.endDateField||`end_date`,progressField:w.gantt?.progressField||w.options?.gantt?.progressField||`progress`,dependenciesField:w.gantt?.dependenciesField||w.options?.gantt?.dependenciesField||`dependencies`,...w.gantt?.titleField?{titleField:w.gantt.titleField}:{},...w.options?.gantt||{},...w.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:w.options?.map?.locationField||`location`,...w.options?.map||{}};default:return t}},[D,w,N,$,V,U,at.handleClick,X.mode,Z]),st=F.conditions&&F.conditions.length>0,ct=n.useMemo(()=>{let e,t=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t.map(e=>({value:e?.value??e,label:e?.label??String(e?.value??e),...e&&typeof e==`object`?e:{}})):Object.entries(t).map(([e,t])=>({value:e,label:t?.label||e,...t}));return w.objectName?ne(w.objectName,e,n):n};if(e=R?.fields?Object.entries(R.fields).map(([e,n])=>({value:e,label:T(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference_to||n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(w.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:T(n,e.label||e.name),type:e.type||`text`,options:t(n,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}}),w.filterableFields&&w.filterableFields.length>0){let t=new Set(w.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[R,w.fields,w.filterableFields,w.objectName,T,ne]),lt=n.useCallback(e=>{Le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ut=n.useCallback(e=>{let t=Y,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||w.objectName||`export`,a=n>0?L.slice(0,n):L;if(e===`csv`){let e=$.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`@object-ui/i18n`),require(`@object-ui/react`),require(`@object-ui/mobile`),require(`@object-ui/permissions`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`@object-ui/i18n`,`@object-ui/react`,`@object-ui/mobile`,`@object-ui/permissions`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginList={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.jsxRuntime,e.ObjectUIi18n,e.ObjectUIReact,e.ObjectUIMobile,e._object_ui_permissions,e.ObjectUIFields))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var v={grid:(0,a.jsx)(i.Grid,{className:`h-4 w-4`}),kanban:(0,a.jsx)(i.LayoutGrid,{className:`h-4 w-4`}),gallery:(0,a.jsx)(i.Images,{className:`h-4 w-4`}),calendar:(0,a.jsx)(i.Calendar,{className:`h-4 w-4`}),timeline:(0,a.jsx)(i.Activity,{className:`h-4 w-4`}),gantt:(0,a.jsx)(i.GanttChartSquare,{className:`h-4 w-4`}),map:(0,a.jsx)(i.Map,{className:`h-4 w-4`})},y={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`},b=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:i,className:o,animated:s=!0})=>{let c=n.useCallback(t=>{if(!s||t===e){i(t);return}typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>i(t)):i(t)},[s,e,i]);return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 bg-transparent oui-view-switcher`,o),children:t.map(t=>{let n=e===t;return(0,a.jsxs)(`button`,{type:`button`,onClick:()=>c(t),"aria-label":y[t],title:y[t],"aria-pressed":n,"data-state":n?`on`:`off`,className:(0,r.cn)(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`hover:bg-muted hover:text-muted-foreground`,`gap-2 px-3 py-2`,`data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50`),children:[v[t],(0,a.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:y[t]})]},t)})})};function x(e){return e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function S(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var ee=({tabs:e,activeTab:t,onTabChange:i,className:o})=>{let s=n.useMemo(()=>S(e),[e]),c=n.useMemo(()=>s.find(e=>e.isDefault)?.name??s[0]?.name,[s]),[l,u]=n.useState(c),d=t??l,f=n.useCallback(e=>{u(e.name),i?.(e)},[i]);return s.length===0?null:(0,a.jsx)(`div`,{className:(0,r.cn)(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,o),"data-testid":`view-tabs`,role:`tablist`,children:s.map(e=>{let t=x(e.icon),n=d===e.name;return(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2.5 py-1 text-xs rounded-md transition-colors duration-150`,n?`font-medium text-foreground bg-muted`:`text-muted-foreground hover:text-foreground hover:bg-transparent`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>f(e),children:[t&&(0,a.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})};function C({title:e,badge:t,onClear:o,clearLabel:s,defaultOpen:c=!0,children:l}){let[u,d]=n.useState(c);return(0,a.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,a.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,a.jsx)(i.ChevronDown,{className:(0,r.cn)(`h-3.5 w-3.5 transition-transform`,!u&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,a.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),o&&(0,a.jsx)(`button`,{type:`button`,onClick:o,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:s})]}),u&&(0,a.jsx)(`div`,{className:`px-3 pb-3`,children:l})]})}function te(e){let{t,allFields:o,showGroup:s,groupingConfig:c,setGroupingConfig:l,showColor:u,rowColorConfig:d,setRowColorConfig:f,showDensity:p,density:m,showHideFields:h,hiddenFields:g,updateHiddenFields:_}=e,[v,y]=n.useState(!1),b=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0].filter(Boolean).length,x=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,S=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,a.jsxs)(r.Popover,{open:v,onOpenChange:y,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":S,title:S,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,b>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,a.jsx)(i.Settings2,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S}),b>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:b})]})}),(0,a.jsxs)(r.PopoverContent,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,a.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,a.jsx)(`div`,{className:`text-sm font-semibold`,children:S}),(0,a.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),s&&l&&(0,a.jsx)(C,{title:t(`list.group`,{defaultValue:`Group`}),badge:c?.fields?.length||0,onClear:c?()=>l(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,a.jsx)(r.GroupingEditor,{value:c,fieldOptions:o.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>l(e)})}),u&&f&&(0,a.jsxs)(C,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:d?()=>f(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!d,children:[(0,a.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:d?.field||``,onChange:e=>{let t=e.target.value;f(t?{field:t,colors:d?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),o.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),p&&m&&(0,a.jsx)(C,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:m.mode!==`compact`,children:(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:m.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,a.jsx)(x,{className:`h-3.5 w-3.5`}),(0,a.jsx)(`span`,{className:`text-xs`,children:m.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):m.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,a.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),h&&g&&_&&(0,a.jsx)(C,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:g.size,onClear:g.size>0?()=>_(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:g.size>0,children:(0,a.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:o.map(e=>(0,a.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:!g.has(e.name),onChange:()=>{let t=new Set(g);t.has(e.name)?t.delete(e.name):t.add(e.name),_(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function w(){try{let{t:e}=(0,o.useObjectTranslation)(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var T=new Set([`lookup`,`master_detail`,`user`,`owner`]);function ne({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:o}){switch(e.element){case`dropdown`:return(0,a.jsx)(D,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:o});case`tabs`:return(0,a.jsx)(O,{tabs:e.tabs||[],showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:o});case`toggle`:return(0,a.jsx)(k,{fields:e.fields||[],onFilterChange:r,className:o});default:return null}}function E(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function D({fields:e,objectDef:t,data:s,onFilterChange:c,maxVisible:l,className:u}){let{fieldLabel:d,translateOptions:f}=(0,o.useSafeFieldLabel)(),p=w(),m=t?.name,[h,g]=n.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues)}),t}),_=n.useMemo(()=>E(e,t,s,{objectName:m,fieldLabel:d,translateOptions:f}),[e,t,s,m,d,f]),v=n.useCallback(e=>{c(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[c]),y=(e,t)=>{let n={...h,[e]:t};g(n),v(n)};n.useEffect(()=>{Object.values(h).some(e=>e.length>0)&&v(h)},[]);let b=l!==void 0&&l<_.length?_.slice(0,l):_,x=l!==void 0&&l<_.length?_.slice(l):[],S=e=>{let t=h[e.field]||[],n=t.length>0,o=T.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),s=o?`w-72`:`w-56`;return(0,a.jsxs)(r.Popover,{children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:(0,r.cn)(`inline-flex items-center gap-1 h-7 px-2 text-xs transition-colors shrink-0 rounded-md`,n?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,a.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:t.length}),n?(0,a.jsx)(i.X,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),y(e.field,[])}}):(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:(0,r.cn)(s,`p-2`),children:o?(0,a.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,a.jsx)(r.LookupValuePicker,{field:{value:e.field,label:e.label||e.field,type:e.type,referenceTo:e.referenceTo,displayField:e.displayField,idField:e.idField},value:t,multiple:!0,onChange:t=>{let n=Array.isArray(t)?t:t==null||t===``?[]:[t];y(e.field,n)}})}):(0,a.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.length===0?(0,a.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,a.jsxs)(`label`,{className:(0,r.cn)(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:t.includes(n.value),onChange:()=>{let r=t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];y(e.field,r)},className:`rounded border-input`}),n.color&&(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,a.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,u),"data-testid":`user-filters-dropdown`,children:_.length===0?(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,a.jsxs)(a.Fragment,{children:[b.map(S),x.length>0&&(0,a.jsxs)(r.Popover,{children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 h-7 px-2 text-xs text-muted-foreground hover:text-foreground transition-colors shrink-0 rounded-md`,children:[(0,a.jsx)(`span`,{children:p}),(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:x.length}),(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,a.jsx)(`div`,{className:`space-y-1`,children:x.map(S)})})]})]})})}function O({tabs:e,showAllRecords:t,allowAddTab:o,onFilterChange:s,className:c}){let[l,u]=n.useState(()=>e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),d=n.useCallback(t=>{u(t),s(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[])},[e,s]),f=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return n.useEffect(()=>{let t=e.find(e=>e.default);t&&s(t.filters||[])},[]),(0,a.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,c),"data-testid":`user-filters-tabs`,children:[f.map(e=>(0,a.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>d(e.id),className:(0,r.cn)(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,l===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),o&&(0,a.jsx)(`button`,{className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5`})})]})}function k({fields:e,onFilterChange:t,className:i}){let[o,s]=n.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),c=n.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),c(n),n})};return n.useEffect(()=>{o.size>0&&c(o)},[]),(0,a.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 overflow-x-auto`,i),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,a.jsx)(r.Button,{variant:o.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>l(e.field),children:e.label||e.field},e.field))})}function A(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`:return`notcontains`;case`greaterThan`:case`gt`:return`>`;case`greaterOrEqual`:case`gte`:return`>=`;case`lessThan`:case`lt`:return`<`;case`lessOrEqual`:case`lte`:return`<=`;case`in`:return`in`;case`notIn`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function j(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?j(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:n===`not in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function re(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ie(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?j(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function ae(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=ie(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,A(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}function M(e,n){if(!n||n.length===0)return{};for(let r of n){let n=!1,i=(`condition`in r?r.condition:void 0)||(`expression`in r?r.expression:void 0)||void 0;if(i)n=(0,t.evaluatePlainCondition)(i,e);else if(`field`in r&&`operator`in r&&r.field&&r.operator){let t=e[r.field];switch(r.operator){case`equals`:n=t===r.value;break;case`not_equals`:n=t!==r.value;break;case`contains`:n=typeof t==`string`&&typeof r.value==`string`&&t.includes(r.value);break;case`greater_than`:n=typeof t==`number`&&typeof r.value==`number`&&t>r.value;break;case`less_than`:n=typeof t==`number`&&typeof r.value==`number`&&t<r.value;break;case`in`:n=Array.isArray(r.value)&&r.value.includes(t);break}}if(n){let e={};return`style`in r&&r.style&&Object.assign(e,r.style),`backgroundColor`in r&&r.backgroundColor&&(e.backgroundColor=r.backgroundColor),`textColor`in r&&r.textColor&&(e.color=r.textColor),`borderColor`in r&&r.borderColor&&(e.borderColor=r.borderColor),e}}return{}}var oe={"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},se=(e,t,n)=>n,ce=(e,t)=>{let n=oe[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function le(){try{let e=(0,o.useObjectTranslation)();return e.t(`list.recordCount`)===`list.recordCount`?{t:ce}:{t:e.t}}catch{return{t:ce}}}function ue(){try{let{fieldLabel:e}=(0,o.useObjectLabel)();return{fieldLabel:e}}catch{return{fieldLabel:se}}}var N=n.forwardRef(({schema:e,className:u,onViewChange:d,onFilterChange:f,onSortChange:p,onSearchChange:m,onHiddenFieldsChange:h,onColumnStateChange:g,onRowClick:_,showViewSwitcher:v=!1,...y},x)=>{let{t:S}=le(),{fieldLabel:C}=ue(),{translateOptions:w}=(0,o.useSafeFieldLabel)(),T=n.useMemo(()=>e.viewType?e:{...e,viewType:`grid`},[e]),E=n.useCallback((e,t)=>T.objectName?C(T.objectName,e,t):t,[T.objectName,C]),D=n.useMemo(()=>{let e=T.userActions,t=T.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?T.showSearch!==!1:e.search,showSort:e?.sort===void 0?T.showSort!==!1:e.sort,showFilters:e?.filter===void 0?T.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?T.showDensity!==!1:e.rowHeight,showHideFields:T.showHideFields===!0,showGroup:T.showGroup!==!1,showColor:T.showColor===!0,compactToolbar:T.compactToolbar===!0,showAddRecord:t,addRecordPosition:T.addRecord?.position===`bottom`?`bottom`:`top`}},[T.userActions,T.showSearch,T.showSort,T.showFilters,T.showDensity,T.showHideFields,T.showGroup,T.showColor,T.compactToolbar,T.addRecord,T.userActions?.addRecordForm]),[O,k]=n.useState(T.viewType),[A,j]=n.useState(``),[M,oe]=n.useState(!1),[se,ce]=n.useState(!1),[N,de]=n.useState(()=>T.sort&&T.sort.length>0?T.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),fe=n.useMemo(()=>JSON.stringify(T.sort||[]),[T.sort]);n.useEffect(()=>{T.sort&&T.sort.length>0?de(T.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):de([])},[fe]);let[pe,me]=n.useState(!1),[P,he]=n.useState({id:`root`,logic:`and`,conditions:[]}),[ge,_e]=n.useState(()=>{if(!(!T.tabs||T.tabs.length===0))return T.tabs.find(e=>e.isDefault)?.name??T.tabs[0]?.name}),ve=n.useCallback(e=>{if(_e(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};he(t),f?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};he(e),f?.(e)}},[f]),F=y.dataSource,[I,ye]=n.useState([]),[be,xe]=n.useState(!1),[L,Se]=n.useState(null),[Ce,R]=n.useState(!1),[we,Te]=n.useState(0),[Ee,De]=n.useState(!1);n.useImperativeHandle(x,()=>({refresh:()=>Te(e=>e+1)}),[]),n.useEffect(()=>{if(!(!F?.onMutation||!T.objectName||T.refreshTrigger))return F.onMutation(e=>{e.resource===T.objectName&&Te(e=>e+1)})},[F,T.objectName,T.refreshTrigger]);let[Oe,ke]=n.useState(void 0),z=Oe??T.pagination?.pageSize??100,B=n.useMemo(()=>{if(T.grouping?.fields?.length)return T.grouping;let e=typeof T.groupBy==`string`?T.groupBy.trim():``,t=typeof T.groupBy2==`string`?T.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[T.grouping,T.groupBy,T.groupBy2]),[V,H]=n.useState(B),[Ae,je]=n.useState(!1),Me=n.useRef(B);n.useEffect(()=>{Me.current!==B&&(Me.current=B,H(B))},[B]);let[U,W]=n.useState(T.rowColor),[Ne,Pe]=n.useState(!1),[G,Fe]=n.useState([]),Ie=n.useRef(0),[Le,Re]=n.useState(()=>{let e=new Set;return T.quickFilters?.forEach(n=>{let r=(0,t.normalizeQuickFilter)(n);r.defaultActive&&e.add(r.id)}),e}),[ze,Be]=n.useState([]),Ve=n.useMemo(()=>{if(T.userFilters)return T.userFilters;if(!L?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(L.fields)?L.fields.map(e=>[e.name,e]):Object.entries(L.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:E(r,i.label||r),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});if(t.length!==0)return{element:`dropdown`,fields:t}},[T.userFilters,L]),[K,He]=n.useState(()=>new Set(T.hiddenFields||[])),Ue=n.useMemo(()=>JSON.stringify(T.hiddenFields||[]),[T.hiddenFields]);n.useEffect(()=>{He(new Set(T.hiddenFields||[]))},[Ue]);let We=n.useCallback(e=>{He(e),h?.(Array.from(e))},[h]),[Ge,Ke]=n.useState(!1),[qe,Je]=n.useState(!1),q=n.useMemo(()=>(0,t.normalizeQuickFilters)(T.quickFilters),[T.quickFilters]),J=n.useMemo(()=>{if(T.exportOptions)return Array.isArray(T.exportOptions)?{formats:T.exportOptions}:T.exportOptions},[T.exportOptions]),Y=(0,s.useDensityMode)(n.useMemo(()=>T.densityMode?T.densityMode:T.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[T.rowHeight]||`comfortable`:`compact`,[T.densityMode,T.rowHeight]),{onChange:T.onDensityChange}),Ye=n.useMemo(()=>`objectui:gallery:density:${T.objectName??`default`}`,[T.objectName]),[X,Xe]=n.useState(()=>{if(typeof window>`u`)return T.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(Ye);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return T.gallery?.cardSize??`medium`}),Ze=n.useCallback(()=>{Xe(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(Ye,t)}catch{}return t})},[Ye]),{ref:Qe,isRefreshing:$e,pullDistance:et}=(0,c.usePullToRefresh)({onRefresh:n.useCallback(async()=>{Te(e=>e+1)},[]),enabled:!!F&&!!T.objectName}),tt=n.useMemo(()=>T.id?`listview-${T.objectName}-${T.id}-view`:`listview-${T.objectName}-view`,[T.objectName,T.id]);n.useEffect(()=>{let e=!0;return R(!1),Se(null),(async()=>{if(!F||!T.objectName){R(!0);return}if(typeof F.getObjectSchema!=`function`){R(!0);return}try{let t=await F.getObjectSchema(T.objectName);e&&Se(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&R(!0)}})(),()=>{e=!1}},[T.objectName,F]);let nt=n.useMemo(()=>{let e=Array.isArray(T.fields)?T.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],n=new Set(e),r=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)typeof e==`string`&&e&&n.add(e)};r(T.kanban),r(T.options?.kanban),r(T.calendar),r(T.options?.calendar),r(T.gallery),r(T.options?.gallery),r(T.timeline),r(T.options?.timeline),r(T.gantt),r(T.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(L?.fields,i)},[L?.fields,T.fields,T.kanban,T.calendar,T.gallery,T.timeline,T.gantt,T.options]),Z=(0,l.usePermissions)();n.useEffect(()=>{let e=!0,t=++Ie.current;if(T.data&&typeof T.data==`object`&&!Array.isArray(T.data)){let e=T.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(A){let e=A.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ye(t),xe(!1),De(!1);return}}if(Array.isArray(T.data)){let e=T.data;if(A){let t=A.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ye(e),xe(!1),De(!1);return}return Ce?((async()=>{if(!(!F||!T.objectName)){xe(!0);try{let n=[],r=T.filters||[],i=ae(P),a=[];q&&Le.size>0&&q.forEach(e=>{Le.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=ie(ze),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=N.length>0?N.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(T.fields)?T.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Z?.isLoaded&&T.objectName?e.filter(e=>Z.checkField(T.objectName,e,`read`)):e;if(t.length===0)return;let n=new Set([`id`]);for(let e of t)n.add(e);for(let e of nt)n.add(e);let r=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)typeof e==`string`&&e&&n.add(e)};r(T.kanban),r(T.options?.kanban),r(T.calendar),r(T.options?.calendar),r(T.gallery),r(T.options?.gallery),r(T.timeline),r(T.options?.timeline);{let e=T.timeline??T.options?.timeline;e&&!Array.isArray(e.metaFields)&&(n.add(`status`),n.add(`priority`))}return r(T.gantt),r(T.options?.gantt),Array.from(n)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await F.find(T.objectName,{...u?{$filter:n}:{},$orderby:c,$top:z,...l?{$select:l}:{},...nt.length>0?{$expand:nt}:{},...A?{$search:A,...T.searchableFields&&T.searchableFields.length>0?{$searchFields:T.searchableFields}:{}}:{}});if(!e||t!==Ie.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),ye(f),De(f.length>=z)}catch(e){t===Ie.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Ie.current&&xe(!1)}}})(),()=>{e=!1}):void 0},[T.objectName,T.data,F,T.filters,z,N,P,Le,q,ze,we,A,T.searchableFields,nt,Ce,T.refreshTrigger,Z]);let rt=n.useMemo(()=>{if(T.appearance?.allowedVisualizations&&T.appearance.allowedVisualizations.length>0)return T.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(T.kanban?.groupField||T.options?.kanban?.groupField)&&e.push(`kanban`),(T.gallery?.coverField||T.gallery?.imageField||T.options?.gallery?.imageField)&&e.push(`gallery`),(T.calendar?.startDateField||T.options?.calendar?.startDateField)&&e.push(`calendar`),(T.timeline?.startDateField||T.options?.timeline?.startDateField||T.options?.timeline?.dateField||T.options?.calendar?.startDateField)&&e.push(`timeline`),(T.gantt?.startDateField||T.options?.gantt?.startDateField)&&e.push(`gantt`),(T.options?.map?.locationField||T.options?.map?.latitudeField&&T.options?.map?.longitudeField)&&e.push(`map`),T.viewType&&!e.includes(T.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(T.viewType)&&e.push(T.viewType),e},[T.options,T.viewType,T.kanban,T.calendar,T.gantt,T.gallery,T.timeline,T.appearance?.allowedVisualizations]);n.useEffect(()=>{T.viewType&&k(T.viewType)},[T.viewType]);let it=n.useCallback(e=>{k(e);try{localStorage.setItem(tt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}d?.(e)},[tt,d]),at=n.useCallback(e=>{j(e),m?.(e)},[m]),ot=(0,s.useNavigationOverlay)({navigation:T.navigation,objectName:T.objectName,onNavigate:T.onNavigate,onRowClick:_}),Q=n.useMemo(()=>{let e=T.fields||[];if(Array.isArray(e)||(e=[]),Z?.isLoaded&&T.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?Z.checkField(T.objectName,t,`read`):!0})),K.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!K.has(t)})),T.fieldOrder&&T.fieldOrder.length>0){let t=new Map(T.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>{let r=typeof e==`string`?e:e?.name||e?.fieldName||e?.field,i=typeof n==`string`?n:n?.name||n?.fieldName||n?.field;return(t.get(r)??1/0)-(t.get(i)??1/0)})}return e},[T.fields,T.objectName,K,T.fieldOrder,Z]),st=n.useMemo(()=>{let e=Y.mode===`compact`?`compact`:Y.mode===`spacious`?`tall`:`medium`,t={objectName:T.objectName,fields:Q,filters:T.filters,sort:N,className:`h-full w-full`,showSearch:!1,onRowClick:ot.handleClick,rowHeight:e,hideRowHeightToggle:!0,...T.striped==null?{}:{striped:T.striped},...T.bordered==null?{}:{bordered:T.bordered},...g?{onColumnStateChange:g}:{},...T.columnState?{columnState:T.columnState}:{}};switch(O){case`grid`:return{type:`object-grid`,...t,columns:Q,...T.conditionalFormatting?{conditionalFormatting:T.conditionalFormatting}:{},...T.inlineEdit==null?{}:{editable:T.inlineEdit},...T.wrapHeaders==null?{}:{wrapHeaders:T.wrapHeaders},...T.virtualScroll==null?{}:{virtualScroll:T.virtualScroll},...T.resizable==null?{}:{resizable:T.resizable},...T.selection?{selection:T.selection}:{},...T.pagination?{pagination:T.pagination}:{},...V?{grouping:V}:{},...U?{rowColor:U}:{},...T.rowActions?{rowActions:T.rowActions}:{},...T.rowActionDefs?{rowActionDefs:T.rowActionDefs}:{},...T.bulkActions?{batchActions:T.bulkActions}:{},...T.bulkActionDefs?{bulkActionDefs:T.bulkActionDefs}:{},...T.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:T.kanban?.groupField||T.options?.kanban?.groupField||`status`,groupField:T.kanban?.groupField||T.options?.kanban?.groupField||`status`,...T.kanban?.titleField||T.options?.kanban?.titleField?{titleField:T.kanban?.titleField||T.options?.kanban?.titleField}:{},cardFields:T.kanban?.cardFields||Q||[],...V?{grouping:V}:{},...T.options?.kanban||{},...T.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:T.calendar?.startDateField||T.options?.calendar?.startDateField||`start_date`,endDateField:T.calendar?.endDateField||T.options?.calendar?.endDateField||`end_date`,...T.calendar?.titleField||T.options?.calendar?.titleField?{titleField:T.calendar?.titleField||T.options?.calendar?.titleField}:{},...T.calendar?.defaultView?{defaultView:T.calendar.defaultView}:{},...T.options?.calendar||{},...T.calendar||{}};case`gallery`:{let e={...T.options?.gallery||{},...T.gallery||{},cardSize:X};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:T.gallery?.coverField||T.gallery?.imageField||T.options?.gallery?.imageField,titleField:T.gallery?.titleField||T.options?.gallery?.titleField||`name`,subtitleField:T.gallery?.subtitleField||T.options?.gallery?.subtitleField,...V?{grouping:V}:{}}}case`timeline`:{let e={...T.options?.timeline||{},...T.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:T.timeline?.startDateField||T.options?.timeline?.startDateField||T.options?.timeline?.dateField||`created_at`,titleField:T.timeline?.titleField||T.options?.timeline?.titleField||`name`,...T.timeline?.endDateField?{endDateField:T.timeline.endDateField}:{},...T.timeline?.groupByField?{groupByField:T.timeline.groupByField}:{},...T.timeline?.colorField?{colorField:T.timeline.colorField}:{},...T.timeline?.scale?{scale:T.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:T.gantt?.startDateField||T.options?.gantt?.startDateField||`start_date`,endDateField:T.gantt?.endDateField||T.options?.gantt?.endDateField||`end_date`,progressField:T.gantt?.progressField||T.options?.gantt?.progressField||`progress`,dependenciesField:T.gantt?.dependenciesField||T.options?.gantt?.dependenciesField||`dependencies`,...T.gantt?.titleField?{titleField:T.gantt.titleField}:{},...T.options?.gantt||{},...T.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:T.options?.map?.locationField||`location`,...T.options?.map||{}};default:return t}},[O,T,N,Q,V,U,ot.handleClick,Y.mode,X]),ct=P.conditions&&P.conditions.length>0,lt=n.useMemo(()=>{let e,t=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t.map(e=>({value:e?.value??e,label:e?.label??String(e?.value??e),...e&&typeof e==`object`?e:{}})):Object.entries(t).map(([e,t])=>({value:e,label:t?.label||e,...t}));return T.objectName?w(T.objectName,e,n):n};if(e=L?.fields?Object.entries(L.fields).map(([e,n])=>({value:e,label:E(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference_to||n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(T.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:E(n,e.label||e.name),type:e.type||`text`,options:t(n,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}}),T.filterableFields&&T.filterableFields.length>0){let t=new Set(T.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[L,T.fields,T.filterableFields,T.objectName,E,w]),ut=n.useCallback(e=>{Re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),dt=n.useCallback(e=>{let t=J,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||T.objectName||`export`,a=n>0?I.slice(0,n):I;if(e===`csv`){let e=Q.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
2
|
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
|
|
3
|
-
`)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}qe(!1)},[L,$,Y,w.objectName]),dt=n.useMemo(()=>(w.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:T(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:T(t,e.label||e.name||e.field)}}),[w.fields,T]);return(0,a.jsxs)(`div`,{ref:Ze,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,u),...w.aria?.label?{"aria-label":w.aria.label}:{},...w.aria?.describedBy?{"aria-describedby":w.aria.describedBy}:{},...w.aria?.live?{"aria-live":w.aria.live}:{},role:`region`,children:[$e>0&&(0,a.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:$e},children:S(Qe?`list.refreshing`:`list.pullToRefresh`)}),v&&(0,a.jsx)(`div`,{className:`px-4 py-1 flex items-center bg-background`,children:(0,a.jsx)(b,{currentView:D,availableViews:nt,onViewChange:rt})}),w.description&&w.appearance?.showDescription!==!1&&(0,a.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof w.description==`string`?w.description:``}),(0,a.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1.5 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:[w.tabs&&w.tabs.length>0&&(0,a.jsx)(ee,{tabs:w.tabs,activeTab:he,onTabChange:_e,className:`!px-0 !py-0 shrink-0`}),w.tabs&&w.tabs.length>0&&Be&&(0,a.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-1 shrink-0`}),Be&&(0,a.jsx)(`div`,{className:`shrink-0 min-w-0`,"data-testid":`user-filters`,children:(0,a.jsx)(re,{config:Be,objectDef:R,data:L,onFilterChange:ze,maxVisible:3})})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,children:[E.showHideFields&&!E.compactToolbar&&(0,a.jsxs)(r.Popover,{open:We,onOpenChange:Ge,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,q.size>0&&`text-primary`),children:[(0,a.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.hideFields`)}),q.size>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:q.size})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.hideFieldsTitle`)}),q.size>0&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ue(new Set),children:S(`list.showAll`)})]}),(0,a.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:dt.map(e=>(0,a.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:!q.has(e.name),onChange:()=>{let t=new Set(q);t.has(e.name)?t.delete(e.name):t.add(e.name),Ue(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),E.showHideFields&&!E.compactToolbar&&(E.showFilters||E.showSort||E.showGroup)&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),E.showFilters&&(0,a.jsxs)(r.Popover,{open:fe,onOpenChange:pe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,st&&`text-foreground font-medium`),children:[(0,a.jsx)(i.SlidersHorizontal,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.filter`)}),st&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:F.conditions?.length||0})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,a.jsxs)(`div`,{className:`space-y-4`,children:[(0,a.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.filterRecords`)})}),(0,a.jsx)(r.FilterBuilder,{fields:ct,value:F,onChange:e=>{me(e),f&&f(e)}})]})})]}),E.showGroup&&!E.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ae,onOpenChange:je,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,V&&`text-foreground font-medium`),children:[(0,a.jsx)(i.Group,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.group`)}),V&&V.fields?.length>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:V.fields.length})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-72 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.groupBy`)}),V&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>H(void 0),"data-testid":`clear-grouping`,children:S(`list.clear`)})]}),(0,a.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,a.jsx)(r.GroupingEditor,{value:V,fieldOptions:dt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:S(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:S(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:S(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>H(e)})})]})})]}),E.showSort&&(0,a.jsxs)(r.Popover,{open:se,onOpenChange:ce,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,N.length>0&&`text-foreground font-medium`),children:[(0,a.jsx)(i.ArrowUpDown,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.sort`)}),N.length>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:N.length})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,a.jsxs)(`div`,{className:`space-y-4`,children:[(0,a.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.sortRecords`)})}),(0,a.jsx)(r.SortBuilder,{fields:ct,value:N,onChange:e=>{P(e),p&&p(e)}})]})})]}),!E.compactToolbar&&(E.showFilters||E.showSort||E.showGroup)&&(E.showColor||E.showDensity)&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),E.showColor&&!E.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Pe,onOpenChange:Fe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,U&&`text-foreground font-medium`),children:[(0,a.jsx)(i.Paintbrush,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.color`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.rowColor`)}),U&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ne(void 0),"data-testid":`clear-row-color`,children:S(`list.clear`)})]}),(0,a.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,a.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:S(`list.colorByField`)}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:U?.field||``,onChange:e=>{let t=e.target.value;Ne(t?{field:t,colors:U?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:S(`list.none`)}),dt.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),E.showDensity&&!E.compactToolbar&&D!==`gallery`&&(()=>{let e=X.mode===`compact`?i.Rows4:X.mode===`comfortable`?i.Rows3:i.Rows2,t=X.mode===`compact`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):X.mode===`comfortable`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":n,className:(0,r.cn)(`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,X.mode!==`compact`&&`text-foreground font-medium`),onClick:X.cycle,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),E.showDensity&&!E.compactToolbar&&D===`gallery`&&(()=>{let e=Z===`small`?i.Rows4:Z===`medium`?i.Rows3:i.Rows2,t=Z===`small`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Z===`medium`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":n,className:(0,r.cn)(`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Z!==`small`&&`text-foreground font-medium`),onClick:Xe,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),E.compactToolbar&&(E.showGroup||E.showColor||E.showDensity||E.showHideFields)&&(0,a.jsx)(te,{t:S,allFields:dt,showGroup:E.showGroup,groupingConfig:V,setGroupingConfig:H,showColor:E.showColor,rowColorConfig:U,setRowColorConfig:Ne,showDensity:E.showDensity,density:X,showHideFields:E.showHideFields,hiddenFields:q,updateHiddenFields:Ue}),(E.showColor||E.showDensity||E.compactToolbar)&&Y&&w.allowExport!==!1&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),Y&&w.allowExport!==!1&&(0,a.jsxs)(r.Popover,{open:Ke,onOpenChange:qe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.export`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,a.jsx)(`div`,{className:`space-y-1`,children:(Y.formats||[`csv`,`json`]).map(e=>(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>ut(e),children:[(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),S(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(w.sharing?.enabled||w.sharing?.type)&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${w.sharing?.visibility||w.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,a.jsx)(i.Share2,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.share`)})]}),w.allowPrinting&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"data-testid":`print-button`,children:[(0,a.jsx)(i.Printer,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.print`)})]}),(()=>{let e=w.allowPrinting||w.sharing?.enabled||w.sharing?.type||Y&&w.allowExport!==!1;return E.showSearch&&e?(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),E.showSearch&&(0,a.jsxs)(r.Popover,{open:M,onOpenChange:oe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,k&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:S(`list.search`),children:(0,a.jsx)(i.Search,{className:`h-3.5 w-3.5`})})}),(0,a.jsx)(r.PopoverContent,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(i.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,a.jsx)(r.Input,{placeholder:S(`list.search`)+`...`,value:k,onChange:e=>it(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),k&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>it(``),children:(0,a.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),E.showAddRecord&&E.addRecordPosition===`top`&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})]})]}),J&&J.length>0&&(0,a.jsx)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:J.map(e=>{let t=K.has(e.id),n=e.icon?i.icons[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,a.jsxs)(r.Button,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>lt(e.id),children:[n&&(0,a.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(0,a.jsx)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:!ye&&L.length===0&&D===`grid`?(()=>{let e=w.emptyState?.icon;return(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[200px] text-center p-8`,"data-testid":`empty-state`,children:[(0,a.jsx)(e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,{className:`h-12 w-12 text-muted-foreground/50 mb-4`}),(0,a.jsx)(`h3`,{className:`text-lg font-medium text-foreground mb-1`,children:(typeof w.emptyState?.title==`string`?w.emptyState.title:void 0)??S(`list.noItems`)}),(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:(typeof w.emptyState?.message==`string`?w.emptyState.message:void 0)??S(`list.noItemsMessage`)}),E.showAddRecord&&(0,a.jsxs)(r.Button,{variant:`default`,size:`sm`,className:`mt-4`,"data-testid":`empty-state-add-record`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),S(`list.addRecord`)]})]})})():(0,a.jsx)(s.SchemaRenderer,{schema:ot,...y,data:L,loading:ye,onRowSelect:Ie})},D),E.showAddRecord&&E.addRecordPosition===`bottom`&&(0,a.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})}),w.bulkActions&&w.bulkActions.length>0&&W.length>0&&D!==`grid`&&(0,a.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex items-center gap-2 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(0,a.jsx)(i.CheckSquare,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,a.jsxs)(`span`,{className:`font-medium`,children:[W.length,` `,W.length===1?`item`:`items`,` selected`]}),(0,a.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:w.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),o=n?i.Trash2:null;return(0,a.jsxs)(r.Button,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>y.onBulkAction?.(e,W),"data-testid":`bulk-action-${e}`,children:[o&&(0,a.jsx)(o,{className:`h-3 w-3`}),ie(e)]},e)})}),(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Ie([]),children:[(0,a.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!ye&&L.length>0&&w.showRecordCount!==!1&&(0,a.jsxs)(`div`,{className:`border-t px-4 py-2 flex items-center gap-3 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,a.jsx)(`span`,{className:`font-medium text-foreground/80`,children:L.length===1?S(`list.recordCountOne`,{count:L.length}):S(`list.recordCount`,{count:L.length})}),Ee&&(0,a.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:S(`list.dataLimitReached`,{limit:z})}),w.pagination?.pageSizeOptions&&w.pagination.pageSizeOptions.length>0&&(0,a.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,a.jsx)(`span`,{children:S(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,a.jsx)(`select`,{"data-testid":`page-size-selector`,className:`h-7 w-[72px] px-2 py-1 text-xs rounded-md border border-input bg-background`,value:String(z),onChange:e=>{let t=Number(e.target.value);ke(t),y.onPageSizeChange&&y.onPageSizeChange(t)},children:w.pagination.pageSizeOptions.map(e=>(0,a.jsx)(`option`,{value:String(e),children:e},e))})]})]}),at.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...at,title:w.label?`${w.label} Detail`:w.objectName?`${w.objectName.charAt(0).toUpperCase()+w.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,a.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,a.jsxs)(`div`,{className:`flex flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,a.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});N.displayName=`ListView`;var P={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},de={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},fe=[{bg:`from-indigo-500/15 via-indigo-500/5 to-purple-500/10`,ring:`ring-indigo-500/15`,text:`text-indigo-600/70 dark:text-indigo-300/70`},{bg:`from-sky-500/15 via-sky-500/5 to-cyan-500/10`,ring:`ring-sky-500/15`,text:`text-sky-600/70 dark:text-sky-300/70`},{bg:`from-emerald-500/15 via-emerald-500/5 to-teal-500/10`,ring:`ring-emerald-500/15`,text:`text-emerald-600/70 dark:text-emerald-300/70`},{bg:`from-amber-500/15 via-amber-500/5 to-orange-500/10`,ring:`ring-amber-500/15`,text:`text-amber-600/70 dark:text-amber-300/70`},{bg:`from-rose-500/15 via-rose-500/5 to-pink-500/10`,ring:`ring-rose-500/15`,text:`text-rose-600/70 dark:text-rose-300/70`},{bg:`from-violet-500/15 via-violet-500/5 to-fuchsia-500/10`,ring:`ring-violet-500/15`,text:`text-violet-600/70 dark:text-violet-300/70`}];function pe(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return fe[Math.abs(t)%fe.length]}var F=e=>{let{schema:o}=e,c=(0,n.useContext)(s.SchemaRendererContext),l=e.dataSource||c?.dataSource,d=(0,s.useDataScope)(o.bind),[f,p]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(null),v=(0,s.useNavigationOverlay)({navigation:o.navigation,objectName:o.objectName,onRowClick:e.onRowClick??e.onCardClick}),y=o.gallery,b=y?.coverField??o.imageField??`image`,x=y?.coverFit??`cover`,S=y?.cardSize??`medium`,ee=y?.titleField??o.titleField??`name`,C=y?.visibleFields,{fieldOptionLabel:te}=(0,s.useSafeFieldLabel)(),ne=(0,n.useCallback)(e=>{let t=g?.fields?.[e],n={name:e};if(t){t.type&&(n.type=t.type),t.label&&(n.label=t.label),t.options&&(n.options=t.options),t.currency&&(n.currency=t.currency),t.precision!==void 0&&(n.precision=t.precision),t.format&&(n.format=t.format);let e=t.reference_to||t.reference;e&&(n.reference_to=e),t.reference_field&&(n.reference_field=t.reference_field)}return o.objectName&&Array.isArray(n.options)&&(n.options=n.options.map(t=>{let n=String(t?.value??t),r=String(t?.label??n);return{...t,value:n,label:te(o.objectName,e,n,r)}})),n},[g,o.objectName,te]);(0,n.useEffect)(()=>{let e=!0;return(async()=>{if(!(!l||typeof l.getObjectSchema!=`function`||!o.objectName))try{let t=await l.getObjectSchema(o.objectName);e&&_(t)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[o.objectName,l]),(0,n.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){p(e.data);return}return o.objectName&&!d&&!o.data&&!e.data&&(async()=>{if(!(!l||typeof l.find!=`function`||!o.objectName)){n&&h(!0);try{let e=(0,t.buildExpandFields)(g?.fields),r=await l.find(o.objectName,{$filter:o.filter,...e.length>0?{$expand:e}:{}}),i=[];if(Array.isArray(r))i=r;else if(r&&typeof r==`object`){let e=r;Array.isArray(e.records)?i=e.records:Array.isArray(e.data)&&(i=e.data)}n&&p(i)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&h(!1)}}})(),()=>{n=!1}},[o.objectName,l,d,o.data,o.filter,e.data,g]);let w=e.data||d||o.data||f||[],re=(0,n.useMemo)(()=>w.some(e=>typeof e[b]==`string`&&!!e[b]),[w,b]),T=!!y?.coverField||re,E=o.grouping?.fields,D=!!(E&&E.length>0),[O,k]=(0,n.useState)({}),A=(0,n.useMemo)(()=>E?E.some(e=>e.collapsed):!1,[E]),ie=(0,n.useCallback)(e=>{k(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),j=(0,n.useMemo)(()=>{if(!D||!E)return[];let e=new Map,t=[];for(let n of w){let r=E.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=E.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=E[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in O?O[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[w,E,D,O,A]);if(m&&!w.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!w.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let ae=(t,n)=>{let i=t.id??t._id??n,s=String(t[ee]??`Untitled`),c=t[b],l=pe(String(i)+`|`+s);return(0,a.jsxs)(r.Card,{role:`listitem`,className:(0,r.cn)(`group relative overflow-hidden border-border/60 bg-card`,`transition-all duration-200 ease-out`,`hover:shadow-lg hover:border-border hover:-translate-y-0.5`,(e.onCardClick||e.onRowClick||o.navigation)&&`cursor-pointer`),onClick:e=>v.handleClick(t,e),children:[!T&&(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,l.bg)}),(0,a.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,de[S]),hidden:!T,children:c?(0,a.jsx)(`img`,{src:c,alt:s,className:(0,r.cn)(`h-full w-full transition-transform duration-300 ease-out group-hover:scale-[1.04]`,x===`cover`&&`object-cover`,x===`contain`&&`object-contain`)}):(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,l.bg,l.ring),children:(0,a.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,l.text),children:s[0]?.toUpperCase()})})}),(0,a.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,T&&`border-t border-border/60`),children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:s,children:s}),C&&C.length>0&&(0,a.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:C.map(e=>{let n=t[e];if(n==null||n===``)return null;let r=ne(e);return(0,a.jsx)(`div`,{className:`text-xs text-muted-foreground truncate [&_*]:!text-xs`,onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:(0,a.jsx)((0,u.getCellRenderer)((0,u.resolveCellRendererType)(r)||r.type||`text`),{value:n,field:r})},e)})})]})]},i)},M=e=>(0,a.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,P[S],o.className),role:`list`,children:e.map((e,t)=>ae(e,t))});return(0,a.jsxs)(a.Fragment,{children:[D?(0,a.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,a.jsxs)(`div`,{className:`border rounded-md`,children:[(0,a.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>ie(e.key),children:[e.collapsed?(0,a.jsx)(i.ChevronRight,{className:`h-4 w-4 shrink-0`}):(0,a.jsx)(i.ChevronDown,{className:`h-4 w-4 shrink-0`}),(0,a.jsx)(`span`,{children:e.label}),(0,a.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&M(e.items)]},e.key))}):M(w),v.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...v,title:`Gallery Item`,children:e=>(0,a.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,a.jsxs)(`div`,{className:`flex flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,a.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})};t.ComponentRegistry.register(`object-gallery`,F,{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),t.ComponentRegistry.register(`list-view`,N,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,fields:[],filters:[],sort:[],options:{}}}),t.ComponentRegistry.register(`list`,N,{namespace:`view`,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]}),e.ListView=N,e.ObjectGallery=F,e.TabBar=ee,e.UserFilters=re,e.ViewSwitcher=b,e.evaluateConditionalFormatting=M,e.normalizeFilterCondition=A,e.normalizeFilters=j});
|
|
3
|
+
`)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}Je(!1)},[I,Q,J,T.objectName]),$=n.useMemo(()=>(T.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:E(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:E(t,e.label||e.name||e.field)}}),[T.fields,E]);return(0,a.jsxs)(`div`,{ref:Qe,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,u),...T.aria?.label?{"aria-label":T.aria.label}:{},...T.aria?.describedBy?{"aria-describedby":T.aria.describedBy}:{},...T.aria?.live?{"aria-live":T.aria.live}:{},role:`region`,children:[et>0&&(0,a.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:et},children:S($e?`list.refreshing`:`list.pullToRefresh`)}),v&&(0,a.jsx)(`div`,{className:`px-4 py-1 flex items-center bg-background`,children:(0,a.jsx)(b,{currentView:O,availableViews:rt,onViewChange:it})}),T.description&&T.appearance?.showDescription!==!1&&(0,a.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof T.description==`string`?T.description:``}),(0,a.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1.5 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:[T.tabs&&T.tabs.length>0&&(0,a.jsx)(ee,{tabs:T.tabs,activeTab:ge,onTabChange:ve,className:`!px-0 !py-0 shrink-0`}),T.tabs&&T.tabs.length>0&&Ve&&(0,a.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-1 shrink-0`}),Ve&&(0,a.jsx)(`div`,{className:`shrink-0 min-w-0`,"data-testid":`user-filters`,children:(0,a.jsx)(ne,{config:Ve,objectDef:L,data:I,onFilterChange:Be,maxVisible:3})})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,children:[D.showHideFields&&!D.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ge,onOpenChange:Ke,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,K.size>0&&`text-primary`),children:[(0,a.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.hideFields`)}),K.size>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:K.size})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.hideFieldsTitle`)}),K.size>0&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>We(new Set),children:S(`list.showAll`)})]}),(0,a.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:$.map(e=>(0,a.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:!K.has(e.name),onChange:()=>{let t=new Set(K);t.has(e.name)?t.delete(e.name):t.add(e.name),We(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),D.showHideFields&&!D.compactToolbar&&(D.showFilters||D.showSort||D.showGroup)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),D.showFilters&&(0,a.jsxs)(r.Popover,{open:pe,onOpenChange:me,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,ct&&`text-foreground font-medium`),children:[(0,a.jsx)(i.SlidersHorizontal,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.filter`)}),ct&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:P.conditions?.length||0})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,a.jsxs)(`div`,{className:`space-y-4`,children:[(0,a.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.filterRecords`)})}),(0,a.jsx)(r.FilterBuilder,{fields:lt,value:P,onChange:e=>{he(e),f&&f(e)}})]})})]}),D.showGroup&&!D.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ae,onOpenChange:je,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,V&&`text-foreground font-medium`),children:[(0,a.jsx)(i.Group,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.group`)}),V&&V.fields?.length>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:V.fields.length})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-72 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.groupBy`)}),V&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>H(void 0),"data-testid":`clear-grouping`,children:S(`list.clear`)})]}),(0,a.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,a.jsx)(r.GroupingEditor,{value:V,fieldOptions:$.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:S(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:S(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:S(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>H(e)})})]})})]}),D.showSort&&(0,a.jsxs)(r.Popover,{open:se,onOpenChange:ce,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,N.length>0&&`text-foreground font-medium`),children:[(0,a.jsx)(i.ArrowUpDown,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.sort`)}),N.length>0&&(0,a.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:N.length})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,a.jsxs)(`div`,{className:`space-y-4`,children:[(0,a.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.sortRecords`)})}),(0,a.jsx)(r.SortBuilder,{fields:lt,value:N,onChange:e=>{de(e),p&&p(e)}})]})})]}),!D.compactToolbar&&(D.showFilters||D.showSort||D.showGroup)&&(D.showColor||D.showDensity)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),D.showColor&&!D.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ne,onOpenChange:Pe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,U&&`text-foreground font-medium`),children:[(0,a.jsx)(i.Paintbrush,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.color`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,a.jsx)(`h4`,{className:`font-medium text-sm`,children:S(`list.rowColor`)}),U&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>W(void 0),"data-testid":`clear-row-color`,children:S(`list.clear`)})]}),(0,a.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,a.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:S(`list.colorByField`)}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:U?.field||``,onChange:e=>{let t=e.target.value;W(t?{field:t,colors:U?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:S(`list.none`)}),$.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),D.showDensity&&!D.compactToolbar&&O!==`gallery`&&(()=>{let e=Y.mode===`compact`?i.Rows4:Y.mode===`comfortable`?i.Rows3:i.Rows2,t=Y.mode===`compact`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Y.mode===`comfortable`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":n,className:(0,r.cn)(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Y.mode!==`compact`&&`text-foreground font-medium`),onClick:Y.cycle,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),D.showDensity&&!D.compactToolbar&&O===`gallery`&&(()=>{let e=X===`small`?i.Rows4:X===`medium`?i.Rows3:i.Rows2,t=X===`small`?S(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):X===`medium`?S(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):S(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${S(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=S(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":n,className:(0,r.cn)(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,X!==`small`&&`text-foreground font-medium`),onClick:Ze,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),!D.compactToolbar&&(D.showGroup||D.showColor||D.showDensity||D.showHideFields)&&(0,a.jsx)(`div`,{className:`sm:hidden`,children:(0,a.jsx)(te,{t:S,allFields:$,showGroup:D.showGroup,groupingConfig:V,setGroupingConfig:H,showColor:D.showColor,rowColorConfig:U,setRowColorConfig:W,showDensity:D.showDensity,density:Y,showHideFields:D.showHideFields,hiddenFields:K,updateHiddenFields:We})}),D.compactToolbar&&(D.showGroup||D.showColor||D.showDensity||D.showHideFields)&&(0,a.jsx)(te,{t:S,allFields:$,showGroup:D.showGroup,groupingConfig:V,setGroupingConfig:H,showColor:D.showColor,rowColorConfig:U,setRowColorConfig:W,showDensity:D.showDensity,density:Y,showHideFields:D.showHideFields,hiddenFields:K,updateHiddenFields:We}),(D.showColor||D.showDensity||D.compactToolbar)&&J&&T.allowExport!==!1&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),J&&T.allowExport!==!1&&(0,a.jsxs)(r.Popover,{open:qe,onOpenChange:Je,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.export`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,a.jsx)(`div`,{className:`space-y-1`,children:(J.formats||[`csv`,`json`]).map(e=>(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>dt(e),children:[(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),S(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(T.sharing?.enabled||T.sharing?.type)&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${T.sharing?.visibility||T.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,a.jsx)(i.Share2,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.share`)})]}),T.allowPrinting&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"data-testid":`print-button`,children:[(0,a.jsx)(i.Printer,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.print`)})]}),(()=>{let e=T.allowPrinting||T.sharing?.enabled||T.sharing?.type||J&&T.allowExport!==!1;return D.showSearch&&e?(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),D.showSearch&&(0,a.jsxs)(r.Popover,{open:M,onOpenChange:oe,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,A&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:S(`list.search`),children:(0,a.jsx)(i.Search,{className:`h-3.5 w-3.5`})})}),(0,a.jsx)(r.PopoverContent,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(i.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,a.jsx)(r.Input,{placeholder:S(`list.search`)+`...`,value:A,onChange:e=>at(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),A&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>at(``),children:(0,a.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),D.showAddRecord&&D.addRecordPosition===`top`&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})]})]}),q&&q.length>0&&(0,a.jsx)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:q.map(e=>{let t=Le.has(e.id),n=e.icon?i.icons[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,a.jsxs)(r.Button,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>ut(e.id),children:[n&&(0,a.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(0,a.jsx)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:!be&&I.length===0&&O===`grid`?(()=>{let e=T.emptyState?.icon;return(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[200px] text-center p-8`,"data-testid":`empty-state`,children:[(0,a.jsx)(e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,{className:`h-12 w-12 text-muted-foreground/50 mb-4`}),(0,a.jsx)(`h3`,{className:`text-lg font-medium text-foreground mb-1`,children:(typeof T.emptyState?.title==`string`?T.emptyState.title:void 0)??S(`list.noItems`)}),(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:(typeof T.emptyState?.message==`string`?T.emptyState.message:void 0)??S(`list.noItemsMessage`)}),D.showAddRecord&&(0,a.jsxs)(r.Button,{variant:`default`,size:`sm`,className:`mt-4`,"data-testid":`empty-state-add-record`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),S(`list.addRecord`)]})]})})():(0,a.jsx)(s.SchemaRenderer,{schema:st,...y,data:I,loading:be,onRowSelect:Fe})},O),D.showAddRecord&&D.addRecordPosition===`bottom`&&(0,a.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>y.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:S(`list.addRecord`)})]})}),T.bulkActions&&T.bulkActions.length>0&&G.length>0&&O!==`grid`&&(0,a.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex items-center gap-2 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(0,a.jsx)(i.CheckSquare,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,a.jsxs)(`span`,{className:`font-medium`,children:[G.length,` `,G.length===1?`item`:`items`,` selected`]}),(0,a.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:T.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),o=n?i.Trash2:null;return(0,a.jsxs)(r.Button,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>y.onBulkAction?.(e,G),"data-testid":`bulk-action-${e}`,children:[o&&(0,a.jsx)(o,{className:`h-3 w-3`}),re(e)]},e)})}),(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Fe([]),children:[(0,a.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!be&&I.length>0&&T.showRecordCount!==!1&&(0,a.jsxs)(`div`,{className:`border-t px-4 py-2 flex items-center gap-3 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,a.jsx)(`span`,{className:`font-medium text-foreground/80`,children:I.length===1?S(`list.recordCountOne`,{count:I.length}):S(`list.recordCount`,{count:I.length})}),Ee&&(0,a.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:S(`list.dataLimitReached`,{limit:z})}),T.pagination?.pageSizeOptions&&T.pagination.pageSizeOptions.length>0&&(0,a.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,a.jsx)(`span`,{children:S(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,a.jsx)(`select`,{"data-testid":`page-size-selector`,className:`h-7 w-[72px] px-2 py-1 text-xs rounded-md border border-input bg-background`,value:String(z),onChange:e=>{let t=Number(e.target.value);ke(t),y.onPageSizeChange&&y.onPageSizeChange(t)},children:T.pagination.pageSizeOptions.map(e=>(0,a.jsx)(`option`,{value:String(e),children:e},e))})]})]}),ot.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...ot,title:T.label?`${T.label} Detail`:T.objectName?`${T.objectName.charAt(0).toUpperCase()+T.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,a.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,a.jsxs)(`div`,{className:`flex flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,a.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});N.displayName=`ListView`;var de={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},fe={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},pe=[{bg:`from-indigo-500/15 via-indigo-500/5 to-purple-500/10`,ring:`ring-indigo-500/15`,text:`text-indigo-600/70 dark:text-indigo-300/70`},{bg:`from-sky-500/15 via-sky-500/5 to-cyan-500/10`,ring:`ring-sky-500/15`,text:`text-sky-600/70 dark:text-sky-300/70`},{bg:`from-emerald-500/15 via-emerald-500/5 to-teal-500/10`,ring:`ring-emerald-500/15`,text:`text-emerald-600/70 dark:text-emerald-300/70`},{bg:`from-amber-500/15 via-amber-500/5 to-orange-500/10`,ring:`ring-amber-500/15`,text:`text-amber-600/70 dark:text-amber-300/70`},{bg:`from-rose-500/15 via-rose-500/5 to-pink-500/10`,ring:`ring-rose-500/15`,text:`text-rose-600/70 dark:text-rose-300/70`},{bg:`from-violet-500/15 via-violet-500/5 to-fuchsia-500/10`,ring:`ring-violet-500/15`,text:`text-violet-600/70 dark:text-violet-300/70`}];function me(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return pe[Math.abs(t)%pe.length]}var P=e=>{let{schema:o}=e,c=(0,n.useContext)(s.SchemaRendererContext),l=e.dataSource||c?.dataSource,d=(0,s.useDataScope)(o.bind),[f,p]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(null),v=(0,s.useNavigationOverlay)({navigation:o.navigation,objectName:o.objectName,onRowClick:e.onRowClick??e.onCardClick}),y=o.gallery,b=y?.coverField??o.imageField??`image`,x=y?.coverFit??`cover`,S=y?.cardSize??`medium`,ee=y?.titleField??o.titleField??`name`,C=y?.visibleFields,{fieldOptionLabel:te}=(0,s.useSafeFieldLabel)(),w=(0,n.useCallback)(e=>{let t=g?.fields?.[e],n={name:e};if(t){t.type&&(n.type=t.type),t.label&&(n.label=t.label),t.options&&(n.options=t.options),t.currency&&(n.currency=t.currency),t.precision!==void 0&&(n.precision=t.precision),t.format&&(n.format=t.format);let e=t.reference_to||t.reference;e&&(n.reference_to=e),t.reference_field&&(n.reference_field=t.reference_field)}return o.objectName&&Array.isArray(n.options)&&(n.options=n.options.map(t=>{let n=String(t?.value??t),r=String(t?.label??n);return{...t,value:n,label:te(o.objectName,e,n,r)}})),n},[g,o.objectName,te]);(0,n.useEffect)(()=>{let e=!0;return(async()=>{if(!(!l||typeof l.getObjectSchema!=`function`||!o.objectName))try{let t=await l.getObjectSchema(o.objectName);e&&_(t)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[o.objectName,l]),(0,n.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){p(e.data);return}return o.objectName&&!d&&!o.data&&!e.data&&(async()=>{if(!(!l||typeof l.find!=`function`||!o.objectName)){n&&h(!0);try{let e=(0,t.buildExpandFields)(g?.fields),r=await l.find(o.objectName,{$filter:o.filter,...e.length>0?{$expand:e}:{}}),i=[];if(Array.isArray(r))i=r;else if(r&&typeof r==`object`){let e=r;Array.isArray(e.records)?i=e.records:Array.isArray(e.data)&&(i=e.data)}n&&p(i)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&h(!1)}}})(),()=>{n=!1}},[o.objectName,l,d,o.data,o.filter,e.data,g]);let T=e.data||d||o.data||f||[],ne=(0,n.useMemo)(()=>T.some(e=>typeof e[b]==`string`&&!!e[b]),[T,b]),E=!!y?.coverField||ne,D=o.grouping?.fields,O=!!(D&&D.length>0),[k,A]=(0,n.useState)({}),j=(0,n.useMemo)(()=>D?D.some(e=>e.collapsed):!1,[D]),re=(0,n.useCallback)(e=>{A(t=>({...t,[e]:t[e]===void 0?!j:!t[e]}))},[j]),ie=(0,n.useMemo)(()=>{if(!O||!D)return[];let e=new Map,t=[];for(let n of T){let r=D.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=D.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=D[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in k?k[t]:j;return{key:t,label:n.label,items:n.items,collapsed:r}})},[T,D,O,k,j]);if(m&&!T.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!T.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let ae=(t,n)=>{let i=t.id??t._id??n,s=String(t[ee]??`Untitled`),c=t[b],l=me(String(i)+`|`+s);return(0,a.jsxs)(r.Card,{role:`listitem`,className:(0,r.cn)(`group relative overflow-hidden border-border/60 bg-card`,`transition-all duration-200 ease-out`,`hover:shadow-lg hover:border-border hover:-translate-y-0.5`,(e.onCardClick||e.onRowClick||o.navigation)&&`cursor-pointer`),onClick:e=>v.handleClick(t,e),children:[!E&&(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,l.bg)}),(0,a.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,fe[S]),hidden:!E,children:c?(0,a.jsx)(`img`,{src:c,alt:s,className:(0,r.cn)(`h-full w-full transition-transform duration-300 ease-out group-hover:scale-[1.04]`,x===`cover`&&`object-cover`,x===`contain`&&`object-contain`)}):(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,l.bg,l.ring),children:(0,a.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,l.text),children:s[0]?.toUpperCase()})})}),(0,a.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,E&&`border-t border-border/60`),children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:s,children:s}),C&&C.length>0&&(0,a.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:C.map(e=>{let n=t[e];if(n==null||n===``)return null;let r=w(e);return(0,a.jsx)(`div`,{className:`text-xs text-muted-foreground truncate [&_*]:!text-xs`,onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:(0,a.jsx)((0,u.getCellRenderer)((0,u.resolveCellRendererType)(r)||r.type||`text`),{value:n,field:r})},e)})})]})]},i)},M=e=>(0,a.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,de[S],o.className),role:`list`,children:e.map((e,t)=>ae(e,t))});return(0,a.jsxs)(a.Fragment,{children:[O?(0,a.jsx)(`div`,{className:`space-y-2`,children:ie.map(e=>(0,a.jsxs)(`div`,{className:`border rounded-md`,children:[(0,a.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>re(e.key),children:[e.collapsed?(0,a.jsx)(i.ChevronRight,{className:`h-4 w-4 shrink-0`}):(0,a.jsx)(i.ChevronDown,{className:`h-4 w-4 shrink-0`}),(0,a.jsx)(`span`,{children:e.label}),(0,a.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&M(e.items)]},e.key))}):M(T),v.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...v,title:`Gallery Item`,children:e=>(0,a.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,a.jsxs)(`div`,{className:`flex flex-col`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,a.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})};t.ComponentRegistry.register(`object-gallery`,P,{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),t.ComponentRegistry.register(`list-view`,N,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,fields:[],filters:[],sort:[],options:{}}}),t.ComponentRegistry.register(`list`,N,{namespace:`view`,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]}),e.ListView=N,e.ObjectGallery=P,e.TabBar=ee,e.UserFilters=ne,e.ViewSwitcher=b,e.evaluateConditionalFormatting=M,e.normalizeFilterCondition=j,e.normalizeFilters=ie});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/ListView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAOxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,uEAAuE;IACvE,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAClD,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7F,uEAAuE;IACvE,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACvD,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAqBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAyBhE;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAKtD;AAmBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,KAAK,CAAC,EAAE,cAAc,CAAC,uBAAuB,CAAC,GAC9C,KAAK,CAAC,aAAa,CAoDrB;AA0FD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../../src/ListView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAOxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,uEAAuE;IACvE,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAClD,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7F,uEAAuE;IACvE,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACvD,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAqBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAyBhE;AAUD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAKtD;AAmBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,KAAK,CAAC,EAAE,cAAc,CAAC,uBAAuB,CAAC,GAC9C,KAAK,CAAC,aAAa,CAoDrB;AA0FD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,eAAO,MAAM,QAAQ,mGA21DnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-list",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "ListView plugin for Object UI - unified view component with view type switching",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^18.0.0 || ^19.0.0",
|
|
31
31
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
32
|
-
"@object-ui/components": "^4.
|
|
33
|
-
"@object-ui/core": "^4.
|
|
34
|
-
"@object-ui/fields": "^4.
|
|
35
|
-
"@object-ui/i18n": "^4.
|
|
36
|
-
"@object-ui/mobile": "^4.
|
|
37
|
-
"@object-ui/permissions": "^4.
|
|
38
|
-
"@object-ui/react": "^4.
|
|
39
|
-
"@object-ui/types": "^4.
|
|
32
|
+
"@object-ui/components": "^4.7.0",
|
|
33
|
+
"@object-ui/core": "^4.7.0",
|
|
34
|
+
"@object-ui/fields": "^4.7.0",
|
|
35
|
+
"@object-ui/i18n": "^4.7.0",
|
|
36
|
+
"@object-ui/mobile": "^4.7.0",
|
|
37
|
+
"@object-ui/permissions": "^4.7.0",
|
|
38
|
+
"@object-ui/react": "^4.7.0",
|
|
39
|
+
"@object-ui/types": "^4.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/react": "19.2.14",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"vite": "^8.0.13",
|
|
47
47
|
"vite-plugin-dts": "^5.0.0",
|
|
48
48
|
"vitest": "^4.1.6",
|
|
49
|
-
"@object-ui/components": "4.
|
|
50
|
-
"@object-ui/core": "4.
|
|
51
|
-
"@object-ui/fields": "4.
|
|
52
|
-
"@object-ui/i18n": "4.
|
|
53
|
-
"@object-ui/mobile": "4.
|
|
54
|
-
"@object-ui/react": "4.
|
|
55
|
-
"@object-ui/types": "4.
|
|
49
|
+
"@object-ui/components": "4.7.0",
|
|
50
|
+
"@object-ui/core": "4.7.0",
|
|
51
|
+
"@object-ui/fields": "4.7.0",
|
|
52
|
+
"@object-ui/i18n": "4.7.0",
|
|
53
|
+
"@object-ui/mobile": "4.7.0",
|
|
54
|
+
"@object-ui/react": "4.7.0",
|
|
55
|
+
"@object-ui/types": "4.7.0"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"objectui",
|