@object-ui/plugin-list 13.2.0 → 14.1.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.
@@ -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`}),chart:(0,a.jsx)(i.BarChart3,{className:`h-4 w-4`}),tree:(0,a.jsx)(i.ListTree,{className:`h-4 w-4`})},y={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`,tree:`Tree`},b=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:o,className:s,animated:c=!0})=>{let[l,u]=n.useState(!1),d=n.useCallback(t=>{u(!1),t!==e&&(c&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>o(t)):o(t))},[c,e,o]);return t.length>=2&&t.length<=4?(0,a.jsx)(`div`,{role:`tablist`,"data-testid":`view-switcher-segmented`,className:(0,r.cn)(`inline-flex items-center gap-0.5 rounded-lg bg-muted p-0.5 oui-view-switcher`,s),children:t.map(t=>{let n=t===e;return(0,a.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":y[t],title:y[t],"data-state":n?`on`:`off`,onClick:()=>d(t),className:(0,r.cn)(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[7px] text-xs font-medium transition-all duration-150`,n?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[v[t],(0,a.jsx)(`span`,{className:`hidden sm:inline-block`,children:y[t]})]},t)})}):(0,a.jsxs)(r.Popover,{open:l,onOpenChange:u,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":y[e],className:(0,r.cn)(`inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-xs font-medium transition-colors oui-view-switcher`,l?`text-foreground bg-muted`:`text-muted-foreground hover:text-foreground`,s),children:[v[e],(0,a.jsx)(`span`,{className:`hidden sm:inline-block`,children:y[e]}),(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,a.jsxs)(`button`,{type:`button`,onClick:()=>d(t),"data-state":t===e?`on`:`off`,className:(0,r.cn)(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors hover:bg-muted`,t===e?`text-foreground font-medium`:`text-muted-foreground`),children:[v[t],(0,a.jsx)(`span`,{className:`flex-1 text-left`,children:y[t]}),t===e&&(0,a.jsx)(i.Check,{className:`h-3.5 w-3.5`})]},t))})]})},x=({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 S({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 C(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:_,showInlineEdit:v,inlineEdit:y,setInlineEdit:b}=e,[x,C]=n.useState(!1),w=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0,!!y].filter(Boolean).length,ee=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,T=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,a.jsxs)(r.Popover,{open:x,onOpenChange:C,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":T,title:T,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,w>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:T}),w>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:w})]})}),(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:T}),(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)(S,{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)(S,{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)(S,{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)(ee,{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`})})]})}),v&&b&&(0,a.jsx)(S,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!y,children:(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:!!y,onChange:()=>b(!y),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,a.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),h&&g&&_&&(0,a.jsx)(S,{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 ee=new Set([`lookup`,`master_detail`,`user`,`owner`]);function T(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function te(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,T(e.operator),e.value]):[],default:e.default??e.isDefault}))}function E({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:o,initialSelections:s,onSelectionsChange:c}){switch(e.element){case`dropdown`:return(0,a.jsx)(O,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:o,initialSelections:s,onSelectionsChange:c});case`tabs`:return(0,a.jsx)(k,{tabs:te(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:o,initialTab:typeof s?._tab?.[0]==`string`?s._tab[0]:void 0,onSelectionsChange:c});default:return null}}function D(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 O({fields:e,objectDef:t,data:s,onFilterChange:c,maxVisible:l,className:u,initialSelections:d,onSelectionsChange:f}){let{fieldLabel:p,translateOptions:m}=(0,o.useSafeFieldLabel)(),h=w(),g=t?.name,[_,v]=n.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=d?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),y=n.useRef({}),b=n.useMemo(()=>D(e,t,s,{objectName:g,fieldLabel:p,translateOptions:m}).map(e=>{if(!e.showCount)return e;if((_[e.field]||[]).length===0)return y.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=y.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,s,g,p,m,_]),x=n.useCallback(e=>{c(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[c]),S=(e,t)=>{let n={..._,[e]:t};v(n),x(n),f?.(n)};n.useEffect(()=>{let e=_,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=b.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(v(t),e=t),Object.values(e).some(e=>e.length>0)&&x(e)},[]);let C=l!==void 0&&l<b.length?b.slice(0,l):b,T=l!==void 0&&l<b.length?b.slice(l):[],te=e=>{let t=_[e.field]||[],n=t.length>0,o=ee.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(),S(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];S(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];S(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:b.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:[C.map(te),T.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:h}),(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:T.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:T.map(te)})})]})]})})}function k({tabs:e,showAllRecords:t,allowAddTab:o,onFilterChange:s,className:c,initialTab:l,onSelectionsChange:u}){let[d,f]=n.useState(()=>l&&(l===`__all__`||e.some(e=>e.id===l))?l:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),p=n.useCallback(t=>{f(t),s(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),u?.({_tab:[t]})},[e,s,u]),m=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return n.useEffect(()=>{if(d&&d!==`__all__`){let t=e.find(e=>e.id===d);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:[m.map(e=>{let t=e.id??e.name??``;return(0,a.jsx)(`button`,{"data-testid":`filter-tab-${t}`,onClick:()=>p(t),className:(0,r.cn)(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,d===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},t)}),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 A(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`not_equals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`: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`:case`not_in`:case`nin`: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 ne(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function re(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 ie(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=re(e.conditions.filter(e=>{if(e.operator===`isEmpty`||e.operator===`isNotEmpty`)return!0;let t=e.value;return!(t==null||t===``||Array.isArray(t)&&t.length===0)}).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 N={"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.firstRunTitle":`Nothing here yet`,"list.firstRunMessage":`Create your first record to get started.`,"list.noMatches":`No matching records`,"list.noMatchesMessage":`No records match your current filters or search. Try adjusting or clearing them.`,"list.loading":`Loading records…`,"list.loadErrorTitle":`Couldn’t load records`,"list.loadErrorMessage":`Something went wrong while loading this data. Check your connection and try again.`,"list.retry":`Retry`,"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.`},ae=(e,t,n)=>n,P=(e,t)=>{let n=N[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function oe(){try{let e=(0,o.useObjectTranslation)();return e.t(`list.recordCount`)===`list.recordCount`?{t:P}:{t:e.t}}catch{return{t:P}}}function se(){try{let{fieldLabel:e,actionLabel:t}=(0,o.useObjectLabel)();return{fieldLabel:e,actionLabel:t}}catch{return{fieldLabel:ae,actionLabel:void 0}}}var F=n.forwardRef(({schema:e,className:u,onViewChange:d,onFilterChange:f,onSortChange:p,onSearchChange:m,onHiddenFieldsChange:h,onInlineEditChange:g,onColumnStateChange:_,onRowClick:v,showViewSwitcher:y,userFilterSelections:x,onUserFilterSelectionsChange:S,initialFilters:w,initialSearchTerm:ee,...T},te)=>{let D=y??e?.showViewSwitcher??!1,{t:O}=oe(),{fieldLabel:k,actionLabel:A}=se(),{translateOptions:j}=(0,o.useSafeFieldLabel)(),M=n.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),N=n.useCallback((e,t)=>M.objectName?k(M.objectName,e,t):t,[M.objectName,k]),ae=n.useCallback(e=>{let t=ne(e);return M.objectName&&typeof A==`function`?A(M.objectName,e,t):t},[M.objectName,A]),P=n.useMemo(()=>{let e=M.userActions,t=M.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?M.showSearch!==!1:e.search,showSort:e?.sort===void 0?M.showSort!==!1:e.sort,showFilters:e?.filter===void 0?M.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?M.showDensity!==!1:e.rowHeight,showHideFields:M.showHideFields===!0,showGroup:M.showGroup!==!1,showColor:M.showColor===!0,compactToolbar:M.compactToolbar===!0,showAddRecord:t,addRecordPosition:M.addRecord?.position===`bottom`?`bottom`:`top`}},[M.userActions,M.showSearch,M.showSort,M.showFilters,M.showDensity,M.showHideFields,M.showGroup,M.showColor,M.compactToolbar,M.addRecord,M.userActions?.addRecordForm]),[F,ce]=n.useState(M.viewType),[I,le]=n.useState(()=>ee??``),[ue,de]=n.useState(!1),[fe,pe]=n.useState(!1),[L,R]=n.useState(()=>M.sort&&M.sort.length>0?M.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`}}):[]),me=n.useMemo(()=>JSON.stringify(M.sort||[]),[M.sort]);n.useEffect(()=>{M.sort&&M.sort.length>0?R(M.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`}})):R([])},[me]);let[he,ge]=n.useState(!1),[z,_e]=n.useState(()=>w&&Array.isArray(w.conditions)?w:{id:`root`,logic:`and`,conditions:[]}),B=T.dataSource,[V,ve]=n.useState([]),[ye,be]=n.useState(null),[H,xe]=n.useState(()=>!(Array.isArray(M.data)||M.data&&typeof M.data==`object`&&M.data.provider===`value`&&Array.isArray(M.data.items))),[U,Se]=n.useState(null),[Ce,we]=n.useState(!1),[Te,Ee]=n.useState(0),[De,Oe]=n.useState(!1);n.useImperativeHandle(te,()=>({refresh:()=>Ee(e=>e+1)}),[]),n.useEffect(()=>{if(!(!B?.onMutation||!M.objectName))return B.onMutation(e=>{e.resource===M.objectName&&Ee(e=>e+1)})},[B,M.objectName]);let[ke,Ae]=n.useState(void 0),W=ke??M.pagination?.pageSize??100,[je,Me]=n.useState(1),[Ne,Pe]=n.useState(null),G=n.useMemo(()=>{if(M.grouping?.fields?.length)return M.grouping;let e=typeof M.groupBy==`string`?M.groupBy.trim():``,t=typeof M.groupBy2==`string`?M.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},[M.grouping,M.groupBy,M.groupBy2]),[K,Fe]=n.useState(G),[Ie,Le]=n.useState(!1),Re=n.useRef(G);n.useEffect(()=>{Re.current!==G&&(Re.current=G,Fe(G))},[G]);let[q,ze]=n.useState(M.rowColor),[Be,Ve]=n.useState(!1),[He,Ue]=n.useState([]),We=n.useRef(0),[J,Ge]=n.useState([]),Ke=n.useMemo(()=>{let e=M.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!U?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(U.fields)?U.fields.map(e=>[e.name,e]):Object.entries(U.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:N(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[M.userFilters,U,N]),[Y,qe]=n.useState(()=>new Set(M.hiddenFields||[])),Je=n.useMemo(()=>JSON.stringify(M.hiddenFields||[]),[M.hiddenFields]);n.useEffect(()=>{qe(new Set(M.hiddenFields||[]))},[Je]);let Ye=n.useCallback(e=>{qe(e),h?.(Array.from(e))},[h]),[Xe,Ze]=n.useState(!1),[Qe,$e]=n.useState(()=>!!M.inlineEdit);n.useEffect(()=>{$e(!!M.inlineEdit)},[M.inlineEdit]);let et=n.useCallback(e=>{$e(e),g?.(e)},[g]),[tt,nt]=n.useState(!1),[rt,it]=n.useState(!1),[at,ot]=n.useState(null),st=M.allowExport!==!1&&M.operations?.export!==!1,X=n.useMemo(()=>{if(M.exportOptions)return Array.isArray(M.exportOptions)?{formats:M.exportOptions}:M.exportOptions},[M.exportOptions]),Z=(0,s.useDensityMode)(n.useMemo(()=>M.densityMode?M.densityMode:M.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[M.rowHeight]||`comfortable`:`compact`,[M.densityMode,M.rowHeight]),{onChange:M.onDensityChange}),ct=n.useMemo(()=>`objectui:gallery:density:${M.objectName??`default`}`,[M.objectName]),[Q,lt]=n.useState(()=>{if(typeof window>`u`)return M.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(ct);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return M.gallery?.cardSize??`medium`}),ut=n.useCallback(()=>{lt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(ct,t)}catch{}return t})},[ct]),{ref:dt,isRefreshing:ft,pullDistance:pt}=(0,c.usePullToRefresh)({onRefresh:n.useCallback(async()=>{Ee(e=>e+1)},[]),enabled:!!B&&!!M.objectName}),mt=n.useMemo(()=>M.id?`listview-${M.objectName}-${M.id}-view`:`listview-${M.objectName}-view`,[M.objectName,M.id]);n.useEffect(()=>{let e=!0;return we(!1),Se(null),(async()=>{if(!B||!M.objectName){we(!0);return}if(typeof B.getObjectSchema!=`function`){we(!0);return}try{let t=await B.getObjectSchema(M.objectName);e&&Se(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&we(!0)}})(),()=>{e=!1}},[M.objectName,B]);let ht=n.useMemo(()=>{let e=Array.isArray(M.fields)?M.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(M.kanban),r(M.options?.kanban),r(M.calendar),r(M.options?.calendar),r(M.gallery),r(M.options?.gallery),r(M.timeline),r(M.options?.timeline),r(M.gantt),r(M.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(U?.fields,i)},[U?.fields,M.fields,M.kanban,M.calendar,M.gallery,M.timeline,M.gantt,M.options]),gt=(0,l.usePermissions)();n.useEffect(()=>{let e=!0,t=++We.current;if(M.data&&typeof M.data==`object`&&!Array.isArray(M.data)){let e=M.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(I){let e=I.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ve(t),xe(!1),Oe(!1);return}}if(Array.isArray(M.data)){let e=M.data;if(I){let t=I.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ve(e),xe(!1),Oe(!1);return}return Ce?((async()=>{if(!B||!M.objectName){xe(!1);return}xe(!0),be(null);try{let n=[],r=M.filters||[],i=ie(z),a=re(J),o=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a].filter(e=>Array.isArray(e)&&e.length>0);o.length>1?n=[`and`,...o]:o.length===1&&(n=o[0]);let s=L.length>0?L.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,c=(()=>{let e=Array.isArray(M.fields)?M.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=gt?.isLoaded&&M.objectName?e.filter(e=>gt.checkField(M.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 ht)n.add(e);let r=(()=>{let e=U?.fields;if(!e)return null;let t=Array.isArray(e)?e.map(e=>e?.name).filter(e=>typeof e==`string`):Object.keys(e),n=new Set(t);return n.add(`id`),n.add(`created_at`),n.add(`updated_at`),n})(),i=e=>{typeof e!=`string`||!e||(!r||r.has(e))&&n.add(e)},a=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)i(e)};a(M.kanban),a(M.options?.kanban),a(M.calendar),a(M.options?.calendar),a(M.gallery),a(M.options?.gallery),a(M.timeline),a(M.options?.timeline);{let e=M.timeline??M.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(M.gantt),a(M.options?.gantt),Array.from(n)})(),l=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,u=F===`grid`&&!K?.fields?.length,d=u?(je-1)*W:0,f=await B.find(M.objectName,{...l?{$filter:n}:{},$orderby:s,$top:W,...d>0?{$skip:d}:{},...c?{$select:c}:{},...ht.length>0?{$expand:ht}:{},...I?{$search:I,...M.searchableFields&&M.searchableFields.length>0?{$searchFields:M.searchableFields}:{}}:{}});if(!e||t!==We.current)return;let p=[];Array.isArray(f)?p=f:f&&typeof f==`object`&&(Array.isArray(f.data)?p=f.data:Array.isArray(f.records)?p=f.records:Array.isArray(f.value)&&(p=f.value)),ve(p);let m=f&&typeof f==`object`?f.total??f.count:void 0,h=typeof m==`number`?m:null;Pe(u?h:null),Oe(!(u&&h!=null)&&p.length>=W)}catch(e){t===We.current&&(console.error(`ListView data fetch error:`,e),ve([]),be(e?.message?String(e.message):String(e??`Unknown error`)))}finally{e&&t===We.current&&xe(!1)}})(),()=>{e=!1}):void 0},[M.objectName,M.data,B,M.filters,W,L,z,J,Te,I,M.searchableFields,ht,Ce,M.refreshTrigger,gt,je,F,K]);let _t=JSON.stringify([M.objectName,M.filters,W,L,z,J,I,F,K]),vt=n.useRef(_t);n.useEffect(()=>{vt.current!==_t&&(vt.current=_t,Me(1))},[_t]);let yt=n.useMemo(()=>{let e=[`grid`];(M.kanban?.groupByField||M.kanban?.groupField||M.options?.kanban?.groupField)&&e.push(`kanban`),(M.gallery?.coverField||M.gallery?.imageField||M.options?.gallery?.imageField)&&e.push(`gallery`),(M.calendar?.startDateField||M.options?.calendar?.startDateField)&&e.push(`calendar`),(M.timeline?.startDateField||M.options?.timeline?.startDateField||M.options?.timeline?.dateField||M.options?.calendar?.startDateField)&&e.push(`timeline`),(M.gantt?.startDateField||M.options?.gantt?.startDateField)&&e.push(`gantt`),(M.options?.map?.locationField||M.options?.map?.latitudeField&&M.options?.map?.longitudeField)&&e.push(`map`),(M.tree?.parentField||M.options?.tree?.parentField||M.viewType===`tree`)&&e.push(`tree`),M.viewType&&!e.includes(M.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(M.viewType)&&e.push(M.viewType);let t=M.appearance?.allowedVisualizations;if(Array.isArray(t)&&t.length>0){let n=t.filter(t=>e.includes(t));return n.length>0?n:[`grid`]}return e},[M.options,M.viewType,M.kanban,M.calendar,M.gantt,M.gallery,M.timeline,M.tree,M.appearance?.allowedVisualizations]);n.useEffect(()=>{M.viewType&&ce(M.viewType)},[M.viewType]);let bt=n.useCallback(e=>{ce(e);try{localStorage.setItem(mt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}d?.(e)},[mt,d]),xt=n.useCallback(e=>{le(e),m?.(e)},[m]),St=(0,s.useNavigationOverlay)({navigation:M.navigation,objectName:M.objectName,onNavigate:M.onNavigate,onRowClick:v}),$=n.useMemo(()=>{let e=M.fields||[];if(Array.isArray(e)||(e=[]),gt?.isLoaded&&M.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?gt.checkField(M.objectName,t,`read`):!0})),Y.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Y.has(t)})),M.fieldOrder&&M.fieldOrder.length>0){let t=new Map(M.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},[M.fields,M.objectName,Y,M.fieldOrder,gt]),Ct=n.useMemo(()=>{let e=Z.mode===`compact`?`compact`:Z.mode===`spacious`?`tall`:`medium`,t={objectName:M.objectName,fields:$,filters:M.filters,sort:L,className:`h-full w-full`,showSearch:!1,onRowClick:St.handleClick,rowHeight:e,hideRowHeightToggle:!0,...M.striped==null?{}:{striped:M.striped},...M.bordered==null?{}:{bordered:M.bordered},..._?{onColumnStateChange:_}:{},...M.columnState?{columnState:M.columnState}:{}};switch(F){default:case`grid`:return{type:`object-grid`,...t,columns:$,...M.conditionalFormatting?{conditionalFormatting:M.conditionalFormatting}:{},editable:Qe,...M.wrapHeaders==null?{}:{wrapHeaders:M.wrapHeaders},...M.virtualScroll==null?{}:{virtualScroll:M.virtualScroll},...M.resizable==null?{}:{resizable:M.resizable},...M.selection?{selection:M.selection}:{},...M.pagination?{pagination:M.pagination}:{},...K?{grouping:K}:{},...q?{rowColor:q}:{},...M.rowActions?{rowActions:M.rowActions}:{},...M.rowActionDefs?{rowActionDefs:M.rowActionDefs}:{},...M.bulkActions?{batchActions:M.bulkActions}:{},...M.bulkActionDefs?{bulkActionDefs:M.bulkActionDefs}:{},...M.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:M.kanban?.groupField||M.options?.kanban?.groupField||`status`,groupField:M.kanban?.groupField||M.options?.kanban?.groupField||`status`,...M.kanban?.titleField||M.options?.kanban?.titleField?{titleField:M.kanban?.titleField||M.options?.kanban?.titleField}:{},cardFields:M.kanban?.cardFields||$||[],...K?{grouping:K}:{},...M.options?.kanban||{},...M.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:M.calendar?.startDateField||M.options?.calendar?.startDateField||`start_date`,endDateField:M.calendar?.endDateField||M.options?.calendar?.endDateField||`end_date`,...M.calendar?.titleField||M.options?.calendar?.titleField?{titleField:M.calendar?.titleField||M.options?.calendar?.titleField}:{},...M.calendar?.defaultView?{defaultView:M.calendar.defaultView}:{},...M.options?.calendar||{},...M.calendar||{}};case`gallery`:{let e={...M.options?.gallery||{},...M.gallery||{},cardSize:Q};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:M.gallery?.coverField||M.gallery?.imageField||M.options?.gallery?.imageField,titleField:M.gallery?.titleField||M.options?.gallery?.titleField||`name`,subtitleField:M.gallery?.subtitleField||M.options?.gallery?.subtitleField,...K?{grouping:K}:{}}}case`timeline`:{let e={...M.options?.timeline||{},...M.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:M.timeline?.startDateField||M.options?.timeline?.startDateField||M.options?.timeline?.dateField||`created_at`,titleField:M.timeline?.titleField||M.options?.timeline?.titleField||`name`,...M.timeline?.endDateField?{endDateField:M.timeline.endDateField}:{},...M.timeline?.groupByField?{groupByField:M.timeline.groupByField}:{},...M.timeline?.colorField?{colorField:M.timeline.colorField}:{},...M.timeline?.scale?{scale:M.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:M.gantt?.startDateField||M.options?.gantt?.startDateField||`start_date`,endDateField:M.gantt?.endDateField||M.options?.gantt?.endDateField||`end_date`,progressField:M.gantt?.progressField||M.options?.gantt?.progressField||`progress`,dependenciesField:M.gantt?.dependenciesField||M.options?.gantt?.dependenciesField||`dependencies`,...M.gantt?.titleField?{titleField:M.gantt.titleField}:{},...M.options?.gantt||{},...M.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:M.options?.map?.locationField||`location`,...M.options?.map||{}};case`tree`:{let e=M.tree||M.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||$,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=M.chart||M.options?.chart||{};if(e.dataset){let t=Array.isArray(e.dimensions)?e.dimensions:[],n=Array.isArray(e.values)?e.values:[];return{type:`object-chart`,dataset:e.dataset,dimensions:t,values:n,chartType:e.chartType||`bar`,xAxisKey:t[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:M.objectName,chartType:e.chartType||`bar`,filters:M.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[F,M,L,$,K,q,St.handleClick,Z.mode,Q,Qe]),wt=z.conditions&&z.conditions.length>0,Tt=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 M.objectName?j(M.objectName,e,n):n};if(e=U?.fields?Object.entries(U.fields).map(([e,n])=>({value:e,label:N(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})):(M.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:N(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}}),M.filterableFields&&M.filterableFields.length>0){let t=new Set(M.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[U,M.fields,M.filterableFields,M.objectName,N,j]),Et=n.useCallback(e=>{if(!st)return;let t=X,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||M.objectName||`export`;if((e===`csv`||e===`xlsx`||e===`json`)&&typeof B?.exportDownload==`function`&&M.objectName&&t?.streaming!==!1){let t=$.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field).filter(Boolean),a=M.filters||[],o=ie(z),s=re(J),c=[...a.length>0?[a]:[],...o.length>0?[o]:[],...s].filter(e=>Array.isArray(e)&&e.length>0),l=c.length>1?[`and`,...c]:c.length===1?c[0]:void 0,u=L.length>0?L.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;ot(null),it(!0),(async()=>{try{let a=await B.exportDownload(M.objectName,{format:e,fields:t.length?t:void 0,filter:l,sort:u,includeHeaders:r,limit:n>0?n:void 0}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${i}.${e}`,s.rel=`noopener`,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),nt(!1)}catch(e){console.error(`ListView export failed:`,e),ot(e instanceof Error?e.message:String(e))}finally{it(!1)}})();return}let a=n>0?V.slice(0,n):V;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/types"),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/types`,`@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.ObjectUITypes,e.ObjectUIMobile,e._object_ui_permissions,e.ObjectUIFields))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y={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`}),chart:(0,a.jsx)(i.BarChart3,{className:`h-4 w-4`}),tree:(0,a.jsx)(i.ListTree,{className:`h-4 w-4`})},b={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`,tree:`Tree`},x=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:o,className:s,animated:c=!0})=>{let[l,u]=n.useState(!1),d=n.useCallback(t=>{u(!1),t!==e&&(c&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>o(t)):o(t))},[c,e,o]);return t.length>=2&&t.length<=4?(0,a.jsx)(`div`,{role:`tablist`,"data-testid":`view-switcher-segmented`,className:(0,r.cn)(`inline-flex items-center gap-0.5 rounded-lg bg-muted p-0.5 oui-view-switcher`,s),children:t.map(t=>{let n=t===e;return(0,a.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":b[t],title:b[t],"data-state":n?`on`:`off`,onClick:()=>d(t),className:(0,r.cn)(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[7px] text-xs font-medium transition-all duration-150`,n?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[y[t],(0,a.jsx)(`span`,{className:`hidden sm:inline-block`,children:b[t]})]},t)})}):(0,a.jsxs)(r.Popover,{open:l,onOpenChange:u,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":b[e],className:(0,r.cn)(`inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-xs font-medium transition-colors oui-view-switcher`,l?`text-foreground bg-muted`:`text-muted-foreground hover:text-foreground`,s),children:[y[e],(0,a.jsx)(`span`,{className:`hidden sm:inline-block`,children:b[e]}),(0,a.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,a.jsx)(r.PopoverContent,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,a.jsxs)(`button`,{type:`button`,onClick:()=>d(t),"data-state":t===e?`on`:`off`,className:(0,r.cn)(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors hover:bg-muted`,t===e?`text-foreground font-medium`:`text-muted-foreground`),children:[y[t],(0,a.jsx)(`span`,{className:`flex-1 text-left`,children:b[t]}),t===e&&(0,a.jsx)(i.Check,{className:`h-3.5 w-3.5`})]},t))})]})},S=({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":b[t],title:b[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:[y[t],(0,a.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:b[t]})]},t)})})};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 w(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:_,showInlineEdit:v,inlineEdit:y,setInlineEdit:b}=e,[x,S]=n.useState(!1),w=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0,!!y].filter(Boolean).length,T=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,E=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,a.jsxs)(r.Popover,{open:x,onOpenChange:S,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,"aria-label":E,title:E,className:(0,r.cn)(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,w>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:E}),w>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:w})]})}),(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:E}),(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)(T,{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`})})]})}),v&&b&&(0,a.jsx)(C,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!y,children:(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:!!y,onChange:()=>b(!y),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,a.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),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 T(){try{let{t:e}=(0,o.useObjectTranslation)(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var E=new Set([`lookup`,`master_detail`,`user`,`owner`]);function D(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function O(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,D(e.operator),e.value]):[],default:e.default??e.isDefault}))}function ee({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:o,initialSelections:s,onSelectionsChange:c}){switch(e.element){case`dropdown`:return(0,a.jsx)(A,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:o,initialSelections:s,onSelectionsChange:c});case`tabs`:return(0,a.jsx)(j,{tabs:O(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:o,initialTab:typeof s?._tab?.[0]==`string`?s._tab[0]:void 0,onSelectionsChange:c});default:return null}}function k(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c,l;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,l=n.label,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 u=e.label??l;if(r?.objectName){i=r.translateOptions(r.objectName,e.field,i);let t=e.label||l,n=r.fieldLabel(r.objectName,e.field,t||e.field);u=n===e.field&&t?t:n}return{...e,label:u,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function A({fields:e,objectDef:t,data:s,onFilterChange:c,maxVisible:l,className:u,initialSelections:d,onSelectionsChange:f}){let{fieldLabel:p,translateOptions:m}=(0,o.useSafeFieldLabel)(),h=T(),g=t?.name,[_,v]=n.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=d?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),y=n.useRef({}),b=n.useMemo(()=>k(e,t,s,{objectName:g,fieldLabel:p,translateOptions:m}).map(e=>{if(!e.showCount)return e;if((_[e.field]||[]).length===0)return y.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=y.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,s,g,p,m,_]),x=n.useCallback(e=>{c(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[c]),S=(e,t)=>{let n={..._,[e]:t};v(n),x(n),f?.(n)};n.useEffect(()=>{let e=_,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=b.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(v(t),e=t),Object.values(e).some(e=>e.length>0)&&x(e)},[]);let C=l!==void 0&&l<b.length?b.slice(0,l):b,w=l!==void 0&&l<b.length?b.slice(l):[],D=e=>{let t=_[e.field]||[],n=t.length>0,o=E.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(),S(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];S(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];S(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:b.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:[C.map(D),w.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:h}),(0,a.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:w.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:w.map(D)})})]})]})})}function j({tabs:e,showAllRecords:t,allowAddTab:o,onFilterChange:s,className:c,initialTab:l,onSelectionsChange:u}){let[d,f]=n.useState(()=>l&&(l===`__all__`||e.some(e=>e.id===l))?l:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),p=n.useCallback(t=>{f(t),s(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),u?.({_tab:[t]})},[e,s,u]),m=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return n.useEffect(()=>{if(d&&d!==`__all__`){let t=e.find(e=>e.id===d);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:[m.map(e=>{let t=e.id??e.name??``;return(0,a.jsx)(`button`,{"data-testid":`filter-tab-${t}`,onClick:()=>p(t),className:(0,r.cn)(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,d===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},t)}),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 te(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`not_equals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`: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`:case`not_in`:case`nin`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function M(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)?M(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 ne(e){let t=typeof e==`string`?[e]:Array.isArray(e)?e:[],n=[];for(let e of t)if(typeof e==`string`){let t=e.trim().split(/\s+/);if(!t[0])continue;n.push({id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`})}else e&&typeof e==`object`&&typeof e.field==`string`&&n.push({id:crypto.randomUUID(),field:e.field,order:e.order||`asc`});return n}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)?M(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.filter(e=>{if(e.operator===`isEmpty`||e.operator===`isNotEmpty`)return!0;let t=e.value;return!(t==null||t===``||Array.isArray(t)&&t.length===0)}).map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,te(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}function oe(e,n,r){return(0,t.resolveConditionalFormatting)(e,n,r)}var N={"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.firstRunTitle":`Nothing here yet`,"list.firstRunMessage":`Create your first record to get started.`,"list.noMatches":`No matching records`,"list.noMatchesMessage":`No records match your current filters or search. Try adjusting or clearing them.`,"list.loading":`Loading records…`,"list.loadErrorTitle":`Couldn’t load records`,"list.loadErrorMessage":`Something went wrong while loading this data. Check your connection and try again.`,"list.retry":`Retry`,"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.`},P=(e,t)=>{let n=N[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function se(){try{let e=(0,o.useObjectTranslation)();return e.t(`list.recordCount`)===`list.recordCount`?{t:P}:{t:e.t}}catch{return{t:P}}}function ce(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=(0,o.useObjectLabel)();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var le=n.forwardRef(({schema:e,className:d,onViewChange:f,onFilterChange:p,onSortChange:m,onSearchChange:h,onHiddenFieldsChange:g,onInlineEditChange:_,onColumnStateChange:v,onRowClick:y,showViewSwitcher:b,userFilterSelections:S,onUserFilterSelectionsChange:C,initialFilters:T,initialSearchTerm:E,...D},O)=>{let k=b??e?.showViewSwitcher??!1,{t:A}=se(),{fieldLabel:j,actionLabel:te,objectLabel:M}=ce(),{translateOptions:oe}=(0,o.useSafeFieldLabel)(),N=n.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),P=n.useCallback((e,t)=>N.objectName?j(N.objectName,e,t):t,[N.objectName,j]),le=n.useCallback(e=>{let t=re(e);return N.objectName&&typeof te==`function`?te(N.objectName,e,t):t},[N.objectName,te]),F=n.useMemo(()=>{let e=N.userActions,t=N.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?N.showSearch!==!1:e.search,showSort:e?.sort===void 0?N.showSort!==!1:e.sort,showFilters:e?.filter===void 0?N.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?N.showDensity!==!1:e.rowHeight,showHideFields:N.showHideFields===!0,showGroup:N.showGroup!==!1,showColor:N.showColor===!0,compactToolbar:N.compactToolbar===!0,showAddRecord:t,addRecordPosition:N.addRecord?.position===`bottom`?`bottom`:`top`}},[N.userActions,N.showSearch,N.showSort,N.showFilters,N.showDensity,N.showHideFields,N.showGroup,N.showColor,N.compactToolbar,N.addRecord,N.userActions?.addRecordForm]),[I,ue]=n.useState(N.viewType),[L,de]=n.useState(()=>E??``),[fe,pe]=n.useState(!1),[me,he]=n.useState(!1),[R,ge]=n.useState(()=>ne(N.sort)),_e=n.useMemo(()=>JSON.stringify(N.sort||[]),[N.sort]);n.useEffect(()=>{ge(ne(N.sort))},[_e]);let[ve,ye]=n.useState(!1),[z,be]=n.useState(()=>T&&Array.isArray(T.conditions)?T:{id:`root`,logic:`and`,conditions:[]}),B=D.dataSource,[V,xe]=n.useState([]),[Se,Ce]=n.useState(null),[H,we]=n.useState(()=>!(Array.isArray(N.data)||N.data&&typeof N.data==`object`&&N.data.provider===`value`&&Array.isArray(N.data.items)||N.viewType===`gantt`&&N.data&&typeof N.data==`object`&&!Array.isArray(N.data)&&N.data.provider===`api`)),[U,Te]=n.useState(null),[Ee,De]=n.useState(!1),[Oe,ke]=n.useState(0),[Ae,je]=n.useState(!1);n.useImperativeHandle(O,()=>({refresh:()=>ke(e=>e+1)}),[]),n.useEffect(()=>{if(!(!B?.onMutation||!N.objectName))return B.onMutation(e=>{e.resource===N.objectName&&ke(e=>e+1)})},[B,N.objectName]);let[Me,Ne]=n.useState(void 0),W=Me??N.pagination?.pageSize??100,[Pe,Fe]=n.useState(1),[Ie,Le]=n.useState(null),G=n.useMemo(()=>{if(N.grouping?.fields?.length)return N.grouping;let e=typeof N.groupBy==`string`?N.groupBy.trim():``,t=typeof N.groupBy2==`string`?N.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},[N.grouping,N.groupBy,N.groupBy2]),[K,Re]=n.useState(G),[ze,Be]=n.useState(!1),Ve=n.useRef(G);n.useEffect(()=>{Ve.current!==G&&(Ve.current=G,Re(G))},[G]);let[q,He]=n.useState(N.rowColor),[Ue,We]=n.useState(!1),[Ge,Ke]=n.useState([]),qe=n.useRef(0),[J,Je]=n.useState([]),Ye=n.useMemo(()=>{let e=N.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!U?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(U.fields)?U.fields.map(e=>[e.name,e]):Object.entries(U.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:P(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[N.userFilters,U,P]),[Y,Xe]=n.useState(()=>new Set(N.hiddenFields||[])),Ze=n.useMemo(()=>JSON.stringify(N.hiddenFields||[]),[N.hiddenFields]);n.useEffect(()=>{Xe(new Set(N.hiddenFields||[]))},[Ze]);let Qe=n.useCallback(e=>{Xe(e),g?.(Array.from(e))},[g]),[$e,et]=n.useState(!1),[tt,nt]=n.useState(()=>!!N.inlineEdit);n.useEffect(()=>{nt(!!N.inlineEdit)},[N.inlineEdit]);let rt=n.useCallback(e=>{nt(e),_?.(e)},[_]),[it,at]=n.useState(!1),[ot,st]=n.useState(!1),[ct,lt]=n.useState(null),ut=N.allowExport!==!1&&N.operations?.export!==!1,X=n.useMemo(()=>{if(N.exportOptions)return Array.isArray(N.exportOptions)?{formats:N.exportOptions}:N.exportOptions},[N.exportOptions]),Z=(0,s.useDensityMode)(n.useMemo(()=>N.densityMode?N.densityMode:N.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[N.rowHeight]||`comfortable`:`compact`,[N.densityMode,N.rowHeight]),{onChange:N.onDensityChange}),dt=n.useMemo(()=>`objectui:gallery:density:${N.objectName??`default`}`,[N.objectName]),[Q,ft]=n.useState(()=>{if(typeof window>`u`)return N.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(dt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return N.gallery?.cardSize??`medium`}),pt=n.useCallback(()=>{ft(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(dt,t)}catch{}return t})},[dt]),{ref:mt,isRefreshing:ht,pullDistance:gt}=(0,l.usePullToRefresh)({onRefresh:n.useCallback(async()=>{ke(e=>e+1)},[]),enabled:!!B&&!!N.objectName}),_t=n.useMemo(()=>N.id?`listview-${N.objectName}-${N.id}-view`:`listview-${N.objectName}-view`,[N.objectName,N.id]);n.useEffect(()=>{let e=!0;return De(!1),Te(null),(async()=>{if(!B||!N.objectName){De(!0);return}if(typeof B.getObjectSchema!=`function`){De(!0);return}try{let t=await B.getObjectSchema(N.objectName);e&&Te(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&De(!0)}})(),()=>{e=!1}},[N.objectName,B]);let vt=n.useMemo(()=>{let e=Array.isArray(N.fields)?N.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(N.kanban),r(N.options?.kanban),r(N.calendar),r(N.options?.calendar),r(N.gallery),r(N.options?.gallery),r(N.timeline),r(N.options?.timeline),r(N.gantt),r(N.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(U?.fields,i)},[U?.fields,N.fields,N.kanban,N.calendar,N.gallery,N.timeline,N.gantt,N.options]),yt=(0,u.usePermissions)(),bt=I===`gantt`&&!!N.data&&typeof N.data==`object`&&!Array.isArray(N.data)&&N.data.provider===`api`;n.useEffect(()=>{let e=!0,t=++qe.current;if(N.data&&typeof N.data==`object`&&!Array.isArray(N.data)){let e=N.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(L){let e=L.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}xe(t),we(!1),je(!1);return}}if(Array.isArray(N.data)){let e=N.data;if(L){let t=L.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}xe(e),we(!1),je(!1);return}if(bt){we(!1),je(!1);return}return Ee?((async()=>{if(!B||!N.objectName){we(!1);return}we(!0),Ce(null);try{let n=[],r=N.filters||[],i=ae(z),a=ie(J),o=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a].filter(e=>Array.isArray(e)&&e.length>0);o.length>1?n=[`and`,...o]:o.length===1&&(n=o[0]);let s=R.length>0?R.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,c=(()=>{let e=Array.isArray(N.fields)?N.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=yt?.isLoaded&&N.objectName?e.filter(e=>yt.checkField(N.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 vt)n.add(e);let r=(()=>{let e=U?.fields;if(!e)return null;let t=Array.isArray(e)?e.map(e=>e?.name).filter(e=>typeof e==`string`):Object.keys(e),n=new Set(t);return n.add(`id`),n.add(`created_at`),n.add(`updated_at`),n})(),i=e=>{typeof e!=`string`||!e||(!r||r.has(e))&&n.add(e)},a=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)i(e)};a(N.kanban),a(N.options?.kanban),a(N.calendar),a(N.options?.calendar),a(N.gallery),a(N.options?.gallery),a(N.timeline),a(N.options?.timeline);{let e=N.timeline??N.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(N.gantt),a(N.options?.gantt),Array.from(n)})(),l=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,u=I===`grid`&&!K?.fields?.length,d=u?(Pe-1)*W:0,f=await B.find(N.objectName,{...l?{$filter:n}:{},$orderby:s,$top:W,...d>0?{$skip:d}:{},...c?{$select:c}:{},...vt.length>0?{$expand:vt}:{},...L?{$search:L,...N.searchableFields&&N.searchableFields.length>0?{$searchFields:N.searchableFields}:{}}:{}});if(!e||t!==qe.current)return;let p=[];Array.isArray(f)?p=f:f&&typeof f==`object`&&(Array.isArray(f.data)?p=f.data:Array.isArray(f.records)?p=f.records:Array.isArray(f.value)&&(p=f.value)),xe(p);let m=f&&typeof f==`object`?f.total??f.count:void 0,h=typeof m==`number`?m:null;Le(u?h:null),je(!(u&&h!=null)&&p.length>=W)}catch(e){t===qe.current&&(console.error(`ListView data fetch error:`,e),xe([]),Ce(e?.message?String(e.message):String(e??`Unknown error`)))}finally{e&&t===qe.current&&we(!1)}})(),()=>{e=!1}):void 0},[N.objectName,N.data,B,N.filters,W,R,z,J,Oe,L,N.searchableFields,vt,Ee,N.refreshTrigger,yt,Pe,I,K,bt]);let xt=JSON.stringify([N.objectName,N.filters,W,R,z,J,L,I,K]),St=n.useRef(xt);n.useEffect(()=>{St.current!==xt&&(St.current=xt,Fe(1))},[xt]);let Ct=n.useMemo(()=>{let e=[`grid`];(N.kanban?.groupByField||N.kanban?.groupField||N.options?.kanban?.groupField)&&e.push(`kanban`),(N.gallery?.coverField||N.gallery?.imageField||N.options?.gallery?.imageField)&&e.push(`gallery`),(N.calendar?.startDateField||N.options?.calendar?.startDateField)&&e.push(`calendar`),(N.timeline?.startDateField||N.options?.timeline?.startDateField||N.options?.timeline?.dateField||N.options?.calendar?.startDateField)&&e.push(`timeline`),(N.gantt?.startDateField||N.options?.gantt?.startDateField)&&e.push(`gantt`),(N.options?.map?.locationField||N.options?.map?.latitudeField&&N.options?.map?.longitudeField)&&e.push(`map`),(N.tree?.parentField||N.options?.tree?.parentField||N.viewType===`tree`)&&e.push(`tree`),N.viewType&&!e.includes(N.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(N.viewType)&&e.push(N.viewType);let t=N.appearance?.allowedVisualizations;if(Array.isArray(t)&&t.length>0){let n=t.filter(t=>e.includes(t));return n.length>0?n:[`grid`]}return e},[N.options,N.viewType,N.kanban,N.calendar,N.gantt,N.gallery,N.timeline,N.tree,N.appearance?.allowedVisualizations]);n.useEffect(()=>{N.viewType&&ue(N.viewType)},[N.viewType]);let wt=n.useCallback(e=>{ue(e);try{localStorage.setItem(_t,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}f?.(e)},[_t,f]),Tt=n.useCallback(e=>{de(e),h?.(e)},[h]),Et=(0,s.useNavigationOverlay)({navigation:N.navigation,objectName:N.objectName,onNavigate:N.onNavigate,onRowClick:y}),$=n.useMemo(()=>{let e=N.fields||[];if(Array.isArray(e)||(e=[]),yt?.isLoaded&&N.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return!t||yt.checkField(N.objectName,t,`read`)})),Y.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Y.has(t)})),N.fieldOrder&&N.fieldOrder.length>0){let t=new Map(N.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},[N.fields,N.objectName,Y,N.fieldOrder,yt]),Dt=n.useMemo(()=>{let e=Z.mode===`compact`?`compact`:Z.mode===`spacious`?`tall`:`medium`,t={objectName:N.objectName,fields:$,filters:N.filters,sort:R,className:`h-full w-full`,showSearch:!1,onRowClick:Et.handleClick,rowHeight:e,hideRowHeightToggle:!0,...N.striped==null?{}:{striped:N.striped},...N.bordered==null?{}:{bordered:N.bordered},...v?{onColumnStateChange:v}:{},...N.columnState?{columnState:N.columnState}:{}};switch(I){default:case`grid`:return{type:`object-grid`,...t,columns:$,...N.conditionalFormatting?{conditionalFormatting:N.conditionalFormatting}:{},editable:tt,...N.wrapHeaders==null?{}:{wrapHeaders:N.wrapHeaders},...N.virtualScroll==null?{}:{virtualScroll:N.virtualScroll},...N.resizable==null?{}:{resizable:N.resizable},...N.selection?{selection:N.selection}:{},...N.pagination?{pagination:N.pagination}:{},...K?{grouping:K}:{},...q?{rowColor:q}:{},...N.rowActions?{rowActions:N.rowActions}:{},...N.rowActionDefs?{rowActionDefs:N.rowActionDefs}:{},...N.bulkActions?{batchActions:N.bulkActions}:{},...N.bulkActionDefs?{bulkActionDefs:N.bulkActionDefs}:{},...N.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:N.kanban?.groupField||N.options?.kanban?.groupField||(0,c.detectStatusField)(U)||void 0,groupField:N.kanban?.groupField||N.options?.kanban?.groupField||(0,c.detectStatusField)(U)||void 0,...N.kanban?.titleField||N.options?.kanban?.titleField?{titleField:N.kanban?.titleField||N.options?.kanban?.titleField}:{},cardFields:N.kanban?.cardFields||$||[],...K?{grouping:K}:{},...N.options?.kanban||{},...N.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:N.calendar?.startDateField||N.options?.calendar?.startDateField||`start_date`,endDateField:N.calendar?.endDateField||N.options?.calendar?.endDateField||`end_date`,...N.calendar?.titleField||N.options?.calendar?.titleField?{titleField:N.calendar?.titleField||N.options?.calendar?.titleField}:{},...N.calendar?.defaultView?{defaultView:N.calendar.defaultView}:{},...N.options?.calendar||{},...N.calendar||{}};case`gallery`:{let e={...N.options?.gallery||{},...N.gallery||{},cardSize:Q};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:N.gallery?.coverField||N.gallery?.imageField||N.options?.gallery?.imageField,titleField:N.gallery?.titleField||N.options?.gallery?.titleField||`name`,subtitleField:N.gallery?.subtitleField||N.options?.gallery?.subtitleField,...K?{grouping:K}:{}}}case`timeline`:{let e={...N.options?.timeline||{},...N.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:N.timeline?.startDateField||N.options?.timeline?.startDateField||N.options?.timeline?.dateField||`created_at`,titleField:N.timeline?.titleField||N.options?.timeline?.titleField||`name`,...N.timeline?.endDateField?{endDateField:N.timeline.endDateField}:{},...N.timeline?.groupByField?{groupByField:N.timeline.groupByField}:{},...N.timeline?.colorField?{colorField:N.timeline.colorField}:{},...N.timeline?.scale?{scale:N.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,...N.data?{data:N.data}:{},startDateField:N.gantt?.startDateField||N.options?.gantt?.startDateField||`start_date`,endDateField:N.gantt?.endDateField||N.options?.gantt?.endDateField||`end_date`,progressField:N.gantt?.progressField||N.options?.gantt?.progressField||`progress`,dependenciesField:N.gantt?.dependenciesField||N.options?.gantt?.dependenciesField||`dependencies`,...N.gantt?.titleField?{titleField:N.gantt.titleField}:{},...N.options?.gantt||{},...N.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:N.options?.map?.locationField||`location`,...N.options?.map||{}};case`tree`:{let e=N.tree||N.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||$,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=N.chart||N.options?.chart||{};if(e.dataset){let t=Array.isArray(e.dimensions)?e.dimensions:[],n=Array.isArray(e.values)?e.values:[];return{type:`object-chart`,dataset:e.dataset,dimensions:t,values:n,chartType:e.chartType||`bar`,xAxisKey:t[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:N.objectName,chartType:e.chartType||`bar`,filters:N.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[I,N,R,$,K,q,Et.handleClick,Z.mode,Q,tt,U]),Ot=z.conditions&&z.conditions.length>0,kt=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 N.objectName?oe(N.objectName,e,n):n};if(e=U?.fields?Object.entries(U.fields).map(([e,n])=>({value:e,label:P(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})):(N.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:P(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}}),N.filterableFields&&N.filterableFields.length>0){let t=new Set(N.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[U,N.fields,N.filterableFields,N.objectName,P,oe]),At=n.useCallback(e=>{if(!ut)return;let n=X,r=n?.maxRecords||0,i=n?.includeHeaders!==!1,a=U?.label&&U?.name&&typeof M==`function`?M(U):U?.label,o=e=>(0,t.buildExportFileName)(e,{prefix:n?.fileNamePrefix,label:a,objectName:N.objectName,viewLabel:N.label||N.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof B?.exportDownload==`function`&&N.objectName&&n?.streaming!==!1){let t=$.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field).filter(Boolean),n=N.filters||[],a=ae(z),s=ie(J),c=[...n.length>0?[n]:[],...a.length>0?[a]:[],...s].filter(e=>Array.isArray(e)&&e.length>0),l=c.length>1?[`and`,...c]:c.length===1?c[0]:void 0,u=R.length>0?R.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;lt(null),st(!0),(async()=>{try{let n=await B.exportDownload(N.objectName,{format:e,fields:t.length?t:void 0,filter:l,sort:u,includeHeaders:i,limit:r>0?r:void 0}),a=URL.createObjectURL(n),s=document.createElement(`a`);s.href=a,s.download=o(e),s.rel=`noopener`,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(a),at(!1)}catch(e){console.error(`ListView export failed:`,e),lt(e instanceof Error?e.message:String(e))}finally{st(!1)}})();return}let s=r>0?V.slice(0,r):V;if(e===`csv`){let e=$.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];i&&t.push(e.join(`,`)),s.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)}nt(!1)},[V,$,X,M.objectName,M.filters,st,B,z,J,L]),Dt=n.useMemo(()=>(M.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:N(e,e)};let t=e.name||e.fieldName||e.field,n=e.label||e.name||e.field;return{name:t,label:N(t,n)}}),[M.fields,N]);return(0,a.jsxs)(`div`,{ref:dt,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,u),...M.aria?.label?{"aria-label":M.aria.label}:{},...M.aria?.describedBy?{"aria-describedby":M.aria.describedBy}:{},...M.aria?.live?{"aria-live":M.aria.live}:{},role:`region`,"aria-busy":H||void 0,"data-state":H?`loading`:`idle`,children:[pt>0&&(0,a.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:pt},children:O(ft?`list.refreshing`:`list.pullToRefresh`)}),M.description&&M.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 M.description==`string`?M.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.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:Ke&&(0,a.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,a.jsx)(E,{config:Ke,objectDef:U,data:V,onFilterChange:Ge,maxVisible:3,initialSelections:x,onSelectionsChange:S})})}),(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&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b,{currentView:F,availableViews:yt,onViewChange:bt}),(0,a.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),F===`grid`&&g&&!P.compactToolbar&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>et(!Qe),className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Qe&&`text-primary`),title:O(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,a.jsx)(i.Pencil,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:O(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),P.showHideFields&&!P.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Xe,onOpenChange:Ze,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`,Y.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:O(`list.hideFields`)}),Y.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:Y.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:O(`list.hideFieldsTitle`)}),Y.size>0&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ye(new Set),children:O(`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:!Y.has(e.name),onChange:()=>{let t=new Set(Y);t.has(e.name)?t.delete(e.name):t.add(e.name),Ye(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),P.showHideFields&&!P.compactToolbar&&(P.showFilters||P.showSort||P.showGroup)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),P.showFilters&&(0,a.jsxs)(r.Popover,{open:he,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`,wt&&`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:O(`list.filter`)}),wt&&(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:z.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:O(`list.filterRecords`)})}),(0,a.jsx)(r.FilterBuilder,{fields:Tt,value:z,onChange:e=>{_e(e),f&&f(e)}})]})})]}),P.showGroup&&!P.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ie,onOpenChange:Le,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&&`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:O(`list.group`)}),K&&K.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:K.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:O(`list.groupBy`)}),K&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Fe(void 0),"data-testid":`clear-grouping`,children:O(`list.clear`)})]}),(0,a.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,a.jsx)(r.GroupingEditor,{value:K,fieldOptions:Dt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:O(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:O(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:O(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Fe(e)})})]})})]}),P.showSort&&(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)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L.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:O(`list.sort`)}),L.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:L.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:O(`list.sortRecords`)})}),(0,a.jsx)(r.SortBuilder,{fields:Tt,value:L,onChange:e=>{R(e),p&&p(e)}})]})})]}),!P.compactToolbar&&(P.showFilters||P.showSort||P.showGroup)&&(P.showColor||P.showDensity)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),P.showColor&&!P.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Be,onOpenChange:Ve,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`,q&&`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:O(`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:O(`list.rowColor`)}),q&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ze(void 0),"data-testid":`clear-row-color`,children:O(`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:O(`list.colorByField`)}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:q?.field||``,onChange:e=>{let t=e.target.value;ze(t?{field:t,colors:q?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:O(`list.none`)}),Dt.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),P.showDensity&&!P.compactToolbar&&F!==`gallery`&&(()=>{let e=Z.mode===`compact`?i.Rows4:Z.mode===`comfortable`?i.Rows3:i.Rows2,t=Z.mode===`compact`?O(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Z.mode===`comfortable`?O(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):O(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${O(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=O(`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`,Z.mode!==`compact`&&`text-foreground font-medium`),onClick:Z.cycle,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),P.showDensity&&!P.compactToolbar&&F===`gallery`&&(()=>{let e=Q===`small`?i.Rows4:Q===`medium`?i.Rows3:i.Rows2,t=Q===`small`?O(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Q===`medium`?O(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):O(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${O(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=O(`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`,Q!==`small`&&`text-foreground font-medium`),onClick:ut,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),P.compactToolbar&&(P.showGroup||P.showColor||P.showDensity||P.showHideFields)&&(0,a.jsx)(C,{t:O,allFields:Dt,showGroup:P.showGroup,groupingConfig:K,setGroupingConfig:Fe,showColor:P.showColor,rowColorConfig:q,setRowColorConfig:ze,showDensity:P.showDensity,density:Z,showHideFields:P.showHideFields,hiddenFields:Y,updateHiddenFields:Ye,showInlineEdit:F===`grid`,inlineEdit:Qe,setInlineEdit:et}),(P.showColor||P.showDensity||P.compactToolbar)&&X&&st&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),X&&st&&(0,a.jsxs)(r.Popover,{open:tt,onOpenChange:nt,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:O(`list.export`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(X.formats||[`csv`,`json`]).map(e=>(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:rt,onClick:()=>Et(e),children:[rt?(0,a.jsx)(i.Loader2,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),O(`list.exportAs`,{format:e.toUpperCase()})]},e)),at&&(0,a.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:at})]})})]}),(M.sharing?.enabled||M.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: ${M.sharing?.visibility||M.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:O(`list.share`)})]}),M.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:O(`list.print`)})]}),(()=>{let e=M.allowPrinting||M.sharing?.enabled||M.sharing?.type||X&&st;return P.showSearch&&e?(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),P.showSearch&&(0,a.jsxs)(r.Popover,{open:ue,onOpenChange:de,children:[(0,a.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:(0,r.cn)(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,I&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:O(`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:O(`list.search`)+`...`,value:I,onChange:e=>xt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),I&&(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:()=>xt(``),children:(0,a.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),P.showAddRecord&&P.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:()=>T.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:O(`list.addRecord`)})]})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,a.jsx)(r.RefreshIndicator,{active:H&&V.length>0}),ye&&V.length===0?(0,a.jsx)(r.DataEmptyState,{"data-testid":`list-error-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,a.jsx)(i.AlertTriangle,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:O(`list.loadErrorTitle`),description:O(`list.loadErrorMessage`),action:(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>Ee(e=>e+1),children:[(0,a.jsx)(i.RotateCw,{className:`h-4 w-4 mr-1.5`}),O(`list.retry`)]})}):H&&V.length===0?(0,a.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-2`,"data-testid":`list-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,a.jsx)(`span`,{className:`sr-only`,children:O(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,a.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!H&&V.length===0&&F===`grid`?(()=>{let e=M.emptyState?.icon,t=e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,n=!!(I&&I.trim())||Array.isArray(J)&&J.length>0||Array.isArray(z?.conditions)&&z.conditions.length>0,o=(typeof M.emptyState?.title==`string`?M.emptyState.title:void 0)??O(n?`list.noMatches`:`list.firstRunTitle`),s=(typeof M.emptyState?.message==`string`?M.emptyState.message:void 0)??O(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,a.jsx)(r.DataEmptyState,{"data-testid":`empty-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,a.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:o,description:s,action:P.showAddRecord?(0,a.jsxs)(r.Button,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>T.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),O(`list.addRecord`)]}):void 0})})():(0,a.jsx)(s.SchemaRenderer,{schema:Ct,...T,data:V,loading:H,onRowSelect:Ue,...F===`grid`&&!K?.fields?.length&&Ne!=null?{manualPagination:!0,rowCount:Ne,page:je,pageSize:W,onPageChange:e=>Me(e),onPageSizeChange:e=>{Ae(e),Me(1)}}:{}})]},F),P.showAddRecord&&P.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:()=>T.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:O(`list.addRecord`)})]})}),M.bulkActions&&M.bulkActions.length>0&&He.length>0&&F!==`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:[He.length,` `,He.length===1?`item`:`items`,` selected`]}),(0,a.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:M.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:()=>T.onBulkAction?.(e,He),"data-testid":`bulk-action-${e}`,children:[o&&(0,a.jsx)(o,{className:`h-3 w-3`}),ae(e)]},e)})}),(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Ue([]),children:[(0,a.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!H&&V.length>0&&M.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:V.length===1?O(`list.recordCountOne`,{count:V.length}):O(`list.recordCount`,{count:V.length})}),De&&(0,a.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:O(`list.dataLimitReached`,{limit:W})}),F!==`grid`&&M.pagination?.pageSizeOptions&&M.pagination.pageSizeOptions.length>0&&(0,a.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,a.jsx)(`span`,{children:O(`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(W),onChange:e=>{let t=Number(e.target.value);Ae(t),T.onPageSizeChange&&T.onPageSizeChange(t)},children:M.pagination.pageSizeOptions.map(e=>(0,a.jsx)(`option`,{value:String(e),children:e},e))})]})]}),St.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...St,title:M.label?`${M.label} Detail`:M.objectName?`${M.objectName.charAt(0).toUpperCase()+M.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))})})]})});F.displayName=`ListView`;var ce={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`},I={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},le=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),ue=[{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 de(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return ue[Math.abs(t)%ue.length]}var fe=({imageUrl:e,title:t,coverFit:i,aspectClass:o,placeholder:s,hidden:c})=>{let[l,u]=(0,n.useState)(!1),d=!!e&&!l;return(0,a.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,o),hidden:c,children:d?i===`contain`?(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br`,s.bg),children:(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>u(!0),className:`h-1/2 w-1/2 max-h-24 max-w-24 object-contain transition-transform duration-300 ease-out group-hover:scale-[1.08]`})}):(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>u(!0),className:`h-full w-full object-cover transition-transform duration-300 ease-out group-hover:scale-[1.04]`}):(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`,s.bg,s.ring),children:(0,a.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,s.text),children:t[0]?.toUpperCase()})})})},pe=({imageUrl:e,title:t,placeholder:i})=>{let[o,s]=(0,n.useState)(!1),c=!!e&&!o;return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:c?(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-6 w-6 object-contain transition-transform duration-300 ease-out group-hover:scale-110`}):(0,a.jsx)(`span`,{className:(0,r.cn)(`text-base font-semibold`,i.text),children:t[0]?.toUpperCase()})})},L=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`,C=y?.titleField??o.titleField,w=y?.visibleFields,{fieldLabel:ee,fieldOptionLabel:T}=(0,s.useSafeFieldLabel)(),te=(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)}if(o.objectName){let t=String(n.label??e);n.label=ee(o.objectName,e,t)}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:T(o.objectName,e,n,r)}})),n},[g,o.objectName,ee,T]);(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 E=e.data||d||o.data||f||[],D=(0,n.useMemo)(()=>E.some(e=>typeof e[b]==`string`&&!!e[b]),[E,b]),O=o.grouping?.fields,k=!!(O&&O.length>0),[A,j]=(0,n.useState)({}),ne=(0,n.useMemo)(()=>O?O.some(e=>e.collapsed):!1,[O]),re=(0,n.useCallback)(e=>{j(t=>({...t,[e]:t[e]===void 0?!ne:!t[e]}))},[ne]),ie=(0,n.useMemo)(()=>{if(!k||!O)return[];let e=new Map,t=[];for(let n of E){let r=O.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=O.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=O[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 A?A[t]:ne;return{key:t,label:n.label,items:n.items,collapsed:r}})},[E,O,k,A,ne]);if(m&&!E.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!E.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let M=e=>!w||w.length===0?null:(0,a.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:w.map(t=>{let n=e[t];if(n==null||n===``)return null;let i=te(t),o=(0,u.resolveCellRendererType)(i)||i.type||`text`,s=(0,u.getCellRenderer)(o),c=i?.label&&String(i.label).trim()?String(i.label):void 0,l=c!=null&&le.has(o);return(0,a.jsxs)(`div`,{className:(0,r.cn)(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,l&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[l&&(0,a.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:c}),(0,a.jsx)(s,{value:n,field:i})]},t)})}),N=(n,i)=>{let s=n.id??n._id??i,c=(C!=null&&n[C]!=null&&n[C]!==``?String(n[C]):void 0)??(0,t.getRecordDisplayName)(g,n),l=n[b],u=de(String(s)+`|`+c),d=(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`);return D&&x===`contain`?(0,a.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,a.jsx)(r.CardContent,{className:`p-4`,children:(0,a.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,a.jsx)(pe,{imageUrl:l,title:c,placeholder:u}),(0,a.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),M(n)]})]})})]},s):(0,a.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[!D&&(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,a.jsx)(fe,{imageUrl:l,title:c,coverFit:x,aspectClass:I[S],placeholder:u,hidden:!D}),(0,a.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,D&&`border-t border-border/60`),children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),M(n)]})]},s)},ae=e=>(0,a.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,ce[S],o.className),role:`list`,children:e.map((e,t)=>N(e,t))});return(0,a.jsxs)(a.Fragment,{children:[k?(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&&ae(e.items)]},e.key))}):ae(E),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`,L,{namespace:`plugin-list`,label:`Gallery View`,category:`view`});function R(e){return e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function me(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}t.ComponentRegistry.register(`list-view`,F,{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`,F,{namespace:`view`,skipFallback:!0,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=F,e.ObjectGallery=L,e.TabBar=({tabs:e,activeTab:t,onTabChange:i,className:o})=>{let s=n.useMemo(()=>me(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=R(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)})})},e.TabBarSelect=({tabs:e,activeTab:t,onTabChange:o,className:s})=>{let c=n.useMemo(()=>me(e),[e]),l=n.useMemo(()=>c.find(e=>e.isDefault)?.name??c[0]?.name,[c]),[u,d]=n.useState(l),f=t??u,p=n.useMemo(()=>c.find(e=>e.name===f)??c[0],[c,f]),m=n.useCallback(e=>{d(e.name),o?.(e)},[o]);if(c.length===0)return null;let h=R(p?.icon);return(0,a.jsx)(`div`,{className:(0,r.cn)(`px-2 py-1`,s),"data-testid":`view-tabs-select`,children:(0,a.jsxs)(r.DropdownMenu,{children:[(0,a.jsx)(r.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs font-medium text-foreground gap-1.5 max-w-[60vw] truncate`,"aria-label":`Switch view`,children:[h&&(0,a.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),(0,a.jsx)(`span`,{className:`truncate`,children:p?.label??``}),(0,a.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,a.jsx)(r.DropdownMenuContent,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:c.map(e=>{let t=R(e.icon);return(0,a.jsxs)(r.DropdownMenuItem,{onClick:()=>m(e),className:(0,r.cn)(`text-sm`,f===e.name&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,a.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})},e.UserFilters=E,e.ViewSwitcher=x,e.ViewSwitcherDropdown=b,e.evaluateConditionalFormatting=M,e.normalizeFilterCondition=j,e.normalizeFilters=re});
3
+ `)],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=o(`csv`),a.click(),URL.revokeObjectURL(r)}else if(e===`json`){let e=new Blob([JSON.stringify(s,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=o(`json`),n.click(),URL.revokeObjectURL(t)}at(!1)},[V,$,X,N.objectName,N.filters,ut,B,z,J,R,U,M]),jt=n.useMemo(()=>(N.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:P(e,e)};let t=e.name||e.fieldName||e.field,n=e.label||e.name||e.field;return{name:t,label:P(t,n)}}),[N.fields,P]);return(0,a.jsxs)(`div`,{ref:mt,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,d),...N.aria?.label?{"aria-label":N.aria.label}:{},...N.aria?.describedBy?{"aria-describedby":N.aria.describedBy}:{},...N.aria?.live?{"aria-live":N.aria.live}:{},role:`region`,"aria-busy":H||void 0,"data-state":H?`loading`:`idle`,children:[gt>0&&(0,a.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:gt},children:A(ht?`list.refreshing`:`list.pullToRefresh`)}),N.description&&N.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 N.description==`string`?N.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.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:Ye&&(0,a.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,a.jsx)(ee,{config:Ye,objectDef:U,data:V,onFilterChange:Je,maxVisible:3,initialSelections:S,onSelectionsChange:C})})}),(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:[k&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x,{currentView:I,availableViews:Ct,onViewChange:wt}),(0,a.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),I===`grid`&&_&&!F.compactToolbar&&(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>rt(!tt),className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,tt&&`text-primary`),title:A(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,a.jsx)(i.Pencil,{className:`h-3.5 w-3.5 mr-1.5`}),(0,a.jsx)(`span`,{className:`hidden sm:inline`,children:A(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),F.showHideFields&&!F.compactToolbar&&(0,a.jsxs)(r.Popover,{open:$e,onOpenChange:et,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`,Y.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:A(`list.hideFields`)}),Y.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:Y.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:A(`list.hideFieldsTitle`)}),Y.size>0&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Qe(new Set),children:A(`list.showAll`)})]}),(0,a.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:jt.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:!Y.has(e.name),onChange:()=>{let t=new Set(Y);t.has(e.name)?t.delete(e.name):t.add(e.name),Qe(t)},className:`rounded border-input`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),F.showHideFields&&!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showFilters&&(0,a.jsxs)(r.Popover,{open:ve,onOpenChange:ye,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`,Ot&&`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:A(`list.filter`)}),Ot&&(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:z.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:A(`list.filterRecords`)})}),(0,a.jsx)(r.FilterBuilder,{fields:kt,value:z,onChange:e=>{be(e),p&&p(e)}})]})})]}),F.showGroup&&!F.compactToolbar&&(0,a.jsxs)(r.Popover,{open:ze,onOpenChange:Be,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&&`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:A(`list.group`)}),K&&K.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:K.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:A(`list.groupBy`)}),K&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Re(void 0),"data-testid":`clear-grouping`,children:A(`list.clear`)})]}),(0,a.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,a.jsx)(r.GroupingEditor,{value:K,fieldOptions:jt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:A(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:A(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:A(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Re(e)})})]})})]}),F.showSort&&(0,a.jsxs)(r.Popover,{open:me,onOpenChange:he,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`,R.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:A(`list.sort`)}),R.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:R.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:A(`list.sortRecords`)})}),(0,a.jsx)(r.SortBuilder,{fields:kt,value:R,onChange:e=>{ge(e),m&&m(e)}})]})})]}),!F.compactToolbar&&(F.showFilters||F.showSort||F.showGroup)&&(F.showColor||F.showDensity)&&(0,a.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),F.showColor&&!F.compactToolbar&&(0,a.jsxs)(r.Popover,{open:Ue,onOpenChange:We,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`,q&&`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:A(`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:A(`list.rowColor`)}),q&&(0,a.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>He(void 0),"data-testid":`clear-row-color`,children:A(`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:A(`list.colorByField`)}),(0,a.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:q?.field||``,onChange:e=>{let t=e.target.value;He(t?{field:t,colors:q?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,a.jsx)(`option`,{value:``,children:A(`list.none`)}),jt.map(e=>(0,a.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),F.showDensity&&!F.compactToolbar&&I!==`gallery`&&(()=>{let e=Z.mode===`compact`?i.Rows4:Z.mode===`comfortable`?i.Rows3:i.Rows2,t=Z.mode===`compact`?A(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Z.mode===`comfortable`?A(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):A(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${A(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=A(`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`,Z.mode!==`compact`&&`text-foreground font-medium`),onClick:Z.cycle,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.showDensity&&!F.compactToolbar&&I===`gallery`&&(()=>{let e=Q===`small`?i.Rows4:Q===`medium`?i.Rows3:i.Rows2,t=Q===`small`?A(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Q===`medium`?A(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):A(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${A(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,o=A(`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`,Q!==`small`&&`text-foreground font-medium`),onClick:pt,title:o,children:(0,a.jsx)(e,{className:`h-3.5 w-3.5`})})})(),F.compactToolbar&&(F.showGroup||F.showColor||F.showDensity||F.showHideFields)&&(0,a.jsx)(w,{t:A,allFields:jt,showGroup:F.showGroup,groupingConfig:K,setGroupingConfig:Re,showColor:F.showColor,rowColorConfig:q,setRowColorConfig:He,showDensity:F.showDensity,density:Z,showHideFields:F.showHideFields,hiddenFields:Y,updateHiddenFields:Qe,showInlineEdit:I===`grid`,inlineEdit:tt,setInlineEdit:rt}),(F.showColor||F.showDensity||F.compactToolbar)&&X&&ut&&(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),X&&ut&&(0,a.jsxs)(r.Popover,{open:it,onOpenChange:at,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:A(`list.export`)})]})}),(0,a.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(X.formats||[`csv`,`json`]).map(e=>(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:ot,onClick:()=>At(e),children:[ot?(0,a.jsx)(i.Loader2,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,a.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),A(`list.exportAs`,{format:e.toUpperCase()})]},e)),ct&&(0,a.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:ct})]})})]}),(N.sharing?.enabled||N.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: ${N.sharing?.visibility||N.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:A(`list.share`)})]}),N.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:A(`list.print`)})]}),(()=>{let e=N.allowPrinting||N.sharing?.enabled||N.sharing?.type||X&&ut;return F.showSearch&&e?(0,a.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),F.showSearch&&(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)(`hidden sm:inline-flex h-7 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L?`px-2 text-foreground font-medium`:`w-7 p-0`),"data-testid":`search-icon-button`,title:L?`${A(`list.search`)}: ${L}`:A(`list.search`),children:[(0,a.jsx)(i.Search,{className:`h-3.5 w-3.5`}),L&&(0,a.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:L})]})}),(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:A(`list.search`)+`...`,value:L,onChange:e=>Tt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),L&&(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:()=>Tt(``),children:(0,a.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),F.showAddRecord&&F.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:()=>D.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:A(`list.addRecord`)})]})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,a.jsx)(r.RefreshIndicator,{active:H&&V.length>0}),Se&&V.length===0?(0,a.jsx)(r.DataEmptyState,{"data-testid":`list-error-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,a.jsx)(i.AlertTriangle,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:A(`list.loadErrorTitle`),description:A(`list.loadErrorMessage`),action:(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>ke(e=>e+1),children:[(0,a.jsx)(i.RotateCw,{className:`h-4 w-4 mr-1.5`}),A(`list.retry`)]})}):H&&V.length===0?(0,a.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-2`,"data-testid":`list-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,a.jsx)(`span`,{className:`sr-only`,children:A(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,a.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!H&&V.length===0&&I===`grid`?(()=>{let e=N.emptyState?.icon,t=e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,n=!!(L&&L.trim())||Array.isArray(J)&&J.length>0||Array.isArray(z?.conditions)&&z.conditions.length>0,o=(typeof N.emptyState?.title==`string`?N.emptyState.title:void 0)??A(n?`list.noMatches`:`list.firstRunTitle`),s=(typeof N.emptyState?.message==`string`?N.emptyState.message:void 0)??A(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,a.jsx)(r.DataEmptyState,{"data-testid":`empty-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,a.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:o,description:s,action:F.showAddRecord?(0,a.jsxs)(r.Button,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>D.onAddRecord?.(),children:[(0,a.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),A(`list.addRecord`)]}):void 0})})():(0,a.jsx)(s.SchemaRenderer,{schema:Dt,...D,...bt?{}:{data:V},loading:H,onRowSelect:Ke,...I===`grid`&&!K?.fields?.length&&Ie!=null?{manualPagination:!0,rowCount:Ie,page:Pe,pageSize:W,onPageChange:e=>Fe(e),onPageSizeChange:e=>{Ne(e),Fe(1)}}:{}})]},I),F.showAddRecord&&F.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:()=>D.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:A(`list.addRecord`)})]})}),N.bulkActions&&N.bulkActions.length>0&&Ge.length>0&&I!==`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:[Ge.length,` `,Ge.length===1?`item`:`items`,` selected`]}),(0,a.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:N.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:()=>D.onBulkAction?.(e,Ge),"data-testid":`bulk-action-${e}`,children:[o&&(0,a.jsx)(o,{className:`h-3 w-3`}),le(e)]},e)})}),(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Ke([]),children:[(0,a.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!H&&V.length>0&&N.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:V.length===1?A(`list.recordCountOne`,{count:V.length}):A(`list.recordCount`,{count:V.length})}),Ae&&(0,a.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:A(`list.dataLimitReached`,{limit:W})}),I!==`grid`&&N.pagination?.pageSizeOptions&&N.pagination.pageSizeOptions.length>0&&(0,a.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,a.jsx)(`span`,{children:A(`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(W),onChange:e=>{let t=Number(e.target.value);Ne(t),D.onPageSizeChange&&D.onPageSizeChange(t)},children:N.pagination.pageSizeOptions.map(e=>(0,a.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Et.isOverlay&&(0,a.jsx)(r.NavigationOverlay,{...Et,title:N.label?`${N.label} Detail`:N.objectName?`${N.objectName.charAt(0).toUpperCase()+N.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))})})]})});le.displayName=`ListView`;var F={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`},I={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},ue=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),L=[{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 de(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return L[Math.abs(t)%L.length]}var fe=({imageUrl:e,title:t,coverFit:i,aspectClass:o,placeholder:s,hidden:c})=>{let[l,u]=(0,n.useState)(!1),d=!!e&&!l;return(0,a.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,o),hidden:c,children:d?i===`contain`?(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br`,s.bg),children:(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>u(!0),className:`h-1/2 w-1/2 max-h-24 max-w-24 object-contain transition-transform duration-300 ease-out group-hover:scale-[1.08]`})}):(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>u(!0),className:`h-full w-full object-cover transition-transform duration-300 ease-out group-hover:scale-[1.04]`}):(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`,s.bg,s.ring),children:(0,a.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,s.text),children:t[0]?.toUpperCase()})})})},pe=({imageUrl:e,title:t,placeholder:i})=>{let[o,s]=(0,n.useState)(!1),c=!!e&&!o;return(0,a.jsx)(`div`,{className:(0,r.cn)(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:c?(0,a.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-6 w-6 object-contain transition-transform duration-300 ease-out group-hover:scale-110`}):(0,a.jsx)(`span`,{className:(0,r.cn)(`text-base font-semibold`,i.text),children:t[0]?.toUpperCase()})})},me=e=>{let{schema:o}=e,c=(0,n.useContext)(s.SchemaRendererContext),l=e.dataSource||c?.dataSource,u=(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`,C=y?.titleField??o.titleField,w=y?.visibleFields,{fieldLabel:T,fieldOptionLabel:E}=(0,s.useSafeFieldLabel)(),D=(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)}if(o.objectName){let t=String(n.label??e);n.label=T(o.objectName,e,t)}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:E(o.objectName,e,n,r)}})),n},[g,o.objectName,T,E]);(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&&!u&&!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,u,o.data,o.filter,e.data,g]);let O=e.data||u||o.data||f||[],ee=(0,n.useMemo)(()=>O.some(e=>typeof e[b]==`string`&&!!e[b]),[O,b]),k=o.grouping?.fields,A=!!(k&&k.length>0),[j,te]=(0,n.useState)({}),M=(0,n.useMemo)(()=>k?k.some(e=>e.collapsed):!1,[k]),ne=(0,n.useCallback)(e=>{te(t=>({...t,[e]:t[e]===void 0?!M:!t[e]}))},[M]),re=(0,n.useMemo)(()=>{if(!A||!k)return[];let e=new Map,t=[];for(let n of O){let r=k.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=k.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=k[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 j?j[t]:M;return{key:t,label:n.label,items:n.items,collapsed:r}})},[O,k,A,j,M]);if(m&&!O.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!O.length)return(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let ie=e=>!w||w.length===0?null:(0,a.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:w.map(t=>{let n=e[t];if(n==null||n===``)return null;let i=D(t),o=(0,d.resolveCellRendererType)(i)||i.type||`text`,s=(0,d.getCellRenderer)(o),c=i?.label&&String(i.label).trim()?String(i.label):void 0,l=c!=null&&ue.has(o);return(0,a.jsxs)(`div`,{className:(0,r.cn)(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,l&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[l&&(0,a.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:c}),(0,a.jsx)(s,{value:n,field:i})]},t)})}),ae=(n,i)=>{let s=n.id??n._id??i,c=(C!=null&&n[C]!=null&&n[C]!==``?String(n[C]):void 0)??(0,t.getRecordDisplayName)(g,n),l=n[b],u=de(String(s)+`|`+c),d=(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`);return ee&&x===`contain`?(0,a.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,a.jsx)(r.CardContent,{className:`p-4`,children:(0,a.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,a.jsx)(pe,{imageUrl:l,title:c,placeholder:u}),(0,a.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),ie(n)]})]})})]},s):(0,a.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[!ee&&(0,a.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,a.jsx)(fe,{imageUrl:l,title:c,coverFit:x,aspectClass:I[S],placeholder:u,hidden:!ee}),(0,a.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,ee&&`border-t border-border/60`),children:[(0,a.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),ie(n)]})]},s)},oe=e=>(0,a.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,F[S],o.className),role:`list`,children:e.map((e,t)=>ae(e,t))});return(0,a.jsxs)(a.Fragment,{children:[A?(0,a.jsx)(`div`,{className:`space-y-2`,children:re.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:()=>ne(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&&oe(e.items)]},e.key))}):oe(O),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`,me,{namespace:`plugin-list`,label:`Gallery View`,category:`view`});function he(e){return e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function R(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}t.ComponentRegistry.register(`list-view`,le,{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`,le,{namespace:`view`,skipFallback:!0,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=le,e.ObjectGallery=me,e.TabBar=({tabs:e,activeTab:t,onTabChange:i,className:o})=>{let s=n.useMemo(()=>R(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=he(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)})})},e.TabBarSelect=({tabs:e,activeTab:t,onTabChange:o,className:s})=>{let c=n.useMemo(()=>R(e),[e]),l=n.useMemo(()=>c.find(e=>e.isDefault)?.name??c[0]?.name,[c]),[u,d]=n.useState(l),f=t??u,p=n.useMemo(()=>c.find(e=>e.name===f)??c[0],[c,f]),m=n.useCallback(e=>{d(e.name),o?.(e)},[o]);if(c.length===0)return null;let h=he(p?.icon);return(0,a.jsx)(`div`,{className:(0,r.cn)(`px-2 py-1`,s),"data-testid":`view-tabs-select`,children:(0,a.jsxs)(r.DropdownMenu,{children:[(0,a.jsx)(r.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs font-medium text-foreground gap-1.5 max-w-[60vw] truncate`,"aria-label":`Switch view`,children:[h&&(0,a.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),(0,a.jsx)(`span`,{className:`truncate`,children:p?.label??``}),(0,a.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,a.jsx)(r.DropdownMenuContent,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:c.map(e=>{let t=he(e.icon);return(0,a.jsxs)(r.DropdownMenuItem,{onClick:()=>m(e),className:(0,r.cn)(`text-sm`,f===e.name&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,a.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})},e.UserFilters=ee,e.ViewSwitcher=S,e.ViewSwitcherDropdown=x,e.evaluateConditionalFormatting=oe,e.normalizeFilterCondition=M,e.normalizeFilters=ie});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-list",
3
- "version": "13.2.0",
3
+ "version": "14.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "ListView plugin for Object UI - unified view component with view type switching",
@@ -24,35 +24,35 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "lucide-react": "^1.22.0"
27
+ "lucide-react": "^1.24.0"
28
28
  },
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": "^13.2.0",
33
- "@object-ui/core": "^13.2.0",
34
- "@object-ui/fields": "^13.2.0",
35
- "@object-ui/i18n": "^13.2.0",
36
- "@object-ui/mobile": "^13.2.0",
37
- "@object-ui/permissions": "^13.2.0",
38
- "@object-ui/react": "^13.2.0",
39
- "@object-ui/types": "^13.2.0"
32
+ "@object-ui/components": "^14.1.0",
33
+ "@object-ui/core": "^14.1.0",
34
+ "@object-ui/fields": "^14.1.0",
35
+ "@object-ui/i18n": "^14.1.0",
36
+ "@object-ui/mobile": "^14.1.0",
37
+ "@object-ui/permissions": "^14.1.0",
38
+ "@object-ui/react": "^14.1.0",
39
+ "@object-ui/types": "^14.1.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "19.2.17",
43
43
  "@types/react-dom": "19.2.3",
44
44
  "@vitejs/plugin-react": "^6.0.3",
45
45
  "typescript": "^6.0.3",
46
- "vite": "^8.1.3",
46
+ "vite": "^8.1.4",
47
47
  "vite-plugin-dts": "^5.0.3",
48
48
  "vitest": "^4.1.10",
49
- "@object-ui/components": "13.2.0",
50
- "@object-ui/core": "13.2.0",
51
- "@object-ui/fields": "13.2.0",
52
- "@object-ui/i18n": "13.2.0",
53
- "@object-ui/mobile": "13.2.0",
54
- "@object-ui/react": "13.2.0",
55
- "@object-ui/types": "13.2.0"
49
+ "@object-ui/components": "14.1.0",
50
+ "@object-ui/core": "14.1.0",
51
+ "@object-ui/fields": "14.1.0",
52
+ "@object-ui/i18n": "14.1.0",
53
+ "@object-ui/mobile": "14.1.0",
54
+ "@object-ui/react": "14.1.0",
55
+ "@object-ui/types": "14.1.0"
56
56
  },
57
57
  "keywords": [
58
58
  "objectui",