@object-ui/plugin-list 17.5.0 → 17.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +413 -0
- package/README.md +12 -3
- package/dist/ListView.d.ts +53 -0
- package/dist/ListView.d.ts.map +1 -1
- package/dist/UserFilters.d.ts.map +1 -1
- package/dist/ViewSwitcher.d.ts.map +1 -1
- package/dist/index.js +920 -905
- package/dist/index.umd.cjs +2 -2
- package/package.json +20 -20
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/i18n"),require("react/jsx-runtime"),require("@objectstack/spec/ui"),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`,`@object-ui/i18n`,`react/jsx-runtime`,`@objectstack/spec/ui`,`@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.ObjectUIi18n,e.jsxRuntime,e._objectstack_spec_ui,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,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var b={grid:(0,o.jsx)(i.Grid,{className:`h-4 w-4`}),kanban:(0,o.jsx)(i.LayoutGrid,{className:`h-4 w-4`}),gallery:(0,o.jsx)(i.Images,{className:`h-4 w-4`}),calendar:(0,o.jsx)(i.Calendar,{className:`h-4 w-4`}),timeline:(0,o.jsx)(i.Activity,{className:`h-4 w-4`}),gantt:(0,o.jsx)(i.GanttChartSquare,{className:`h-4 w-4`}),map:(0,o.jsx)(i.Map,{className:`h-4 w-4`}),chart:(0,o.jsx)(i.BarChart3,{className:`h-4 w-4`}),tree:(0,o.jsx)(i.ListTree,{className:`h-4 w-4`})},x={grid:`console.objectView.viewTypeGrid`,kanban:`console.objectView.viewTypeKanban`,gallery:`console.objectView.viewTypeGallery`,calendar:`console.objectView.viewTypeCalendar`,timeline:`console.objectView.viewTypeTimeline`,gantt:`console.objectView.viewTypeGantt`,map:`console.objectView.viewTypeMap`,chart:`console.objectView.viewTypeChart`,tree:`console.objectView.viewTypeTree`},S=(0,a.createSafeTranslation)({"console.objectView.viewTypeGrid":`Grid`,"console.objectView.viewTypeKanban":`Kanban`,"console.objectView.viewTypeGallery":`Gallery`,"console.objectView.viewTypeCalendar":`Calendar`,"console.objectView.viewTypeTimeline":`Timeline`,"console.objectView.viewTypeGantt":`Gantt`,"console.objectView.viewTypeMap":`Map`,"console.objectView.viewTypeChart":`Chart`,"console.objectView.viewTypeTree":`Tree`},`console.objectView.viewTypeGrid`);function C(){let{t:e}=S();return n.useMemo(()=>{let t={};for(let[n,r]of Object.entries(x))t[n]=e(r);return t},[e])}var w=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:a,className:s,animated:c=!0})=>{let[l,u]=n.useState(!1),d=C(),f=n.useCallback(t=>{u(!1),t!==e&&(c&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>a(t)):a(t))},[c,e,a]);return t.length>=2&&t.length<=4?(0,o.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,o.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":d[t],title:d[t],"data-state":n?`on`:`off`,onClick:()=>f(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:[b[t],(0,o.jsx)(`span`,{className:`hidden sm:inline-block`,children:d[t]})]},t)})}):(0,o.jsxs)(r.Popover,{open:l,onOpenChange:u,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":d[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:[b[e],(0,o.jsx)(`span`,{className:`hidden sm:inline-block`,children:d[e]}),(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>f(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:[b[t],(0,o.jsx)(`span`,{className:`flex-1 text-left`,children:d[t]}),t===e&&(0,o.jsx)(i.Check,{className:`h-3.5 w-3.5`})]},t))})]})},T=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:i,className:a,animated:s=!0})=>{let c=C(),l=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,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 bg-transparent oui-view-switcher`,a),children:t.map(t=>{let n=e===t;return(0,o.jsxs)(`button`,{type:`button`,onClick:()=>l(t),"aria-label":c[t],title:c[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:[b[t],(0,o.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:c[t]})]},t)})})};function E({title:e,badge:t,onClear:a,clearLabel:s,defaultOpen:c=!0,children:l}){let[u,d]=n.useState(c);return(0,o.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,o.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,o.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,o.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})]}),a&&(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:s})]}),u&&(0,o.jsx)(`div`,{className:`px-3 pb-3`,children:l})]})}function ee(e){let{t,allFields:a,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),C=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0,!!y].filter(Boolean).length,w=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,T=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,o.jsxs)(r.Popover,{open:x,onOpenChange:S,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,C>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,o.jsx)(i.Settings2,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:T}),C>0&&(0,o.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:C})]})}),(0,o.jsxs)(r.PopoverContent,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,o.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,o.jsx)(`div`,{className:`text-sm font-semibold`,children:T}),(0,o.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),s&&l&&(0,o.jsx)(E,{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,o.jsx)(r.GroupingEditor,{value:c,fieldOptions:a.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,o.jsxs)(E,{title:t(`list.rowColor`,{defaultValue:`Row Color`}),onClear:d?()=>f(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!d,children:[(0,o.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,o.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,o.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),a.map(e=>(0,o.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),p&&m&&(0,o.jsx)(E,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:m.mode!==`compact`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:m.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,o.jsx)(w,{className:`h-3.5 w-3.5`}),(0,o.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,o.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),v&&b&&(0,o.jsx)(E,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!y,children:(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!!y,onChange:()=>b(!y),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,o.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),h&&g&&_&&(0,o.jsx)(E,{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,o.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:a.map(e=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.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,o.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function D(){let{t:e}=(0,a.useObjectTranslation)(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}var O=new Set([`lookup`,`master_detail`,`user`,`owner`]),k={select:`single-choice`,"multi-select":`multi-choice`,boolean:`multi-choice`,"date-range":`range`,text:`text`};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,(0,s.normalizeFilterOperator)(e.operator),e.value]):[],default:e.default??e.isDefault}))}function ne({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:s,onSelectionsChange:c}){switch(e.element){case`dropdown`:return(0,o.jsx)(A,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:s,onSelectionsChange:c});case`tabs`:return(0,o.jsx)(ie,{tabs:te(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof s?._tab?.[0]==`string`?s._tab[0]:void 0,onSelectionsChange:c});case`toggle`:return(0,o.jsx)(j,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function re(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,a.useSafeFieldLabel)(),h=D(),g=t?.name,_=n.useMemo(()=>new Map(e.map(e=>[e.field,k[e.type??``]])),[e]),[v,y]=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),_.get(e.field)===`single-choice`&&(t[e.field]?.length??0)>1&&(t[e.field]=t[e.field].slice(0,1))}),t}),b=n.useRef({}),x=n.useMemo(()=>re(e,t,s,{objectName:g,fieldLabel:p,translateOptions:m}).map(e=>{if(!e.showCount)return e;if((v[e.field]||[]).length===0)return b.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=b.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,v]),S=n.useCallback(e=>{c(Object.entries(e).flatMap(([e,t])=>{if(t.length===0)return[];switch(_.get(e)){case`range`:{let[n,r]=t,i=[];return n!==void 0&&n!==``&&i.push([e,`>=`,n]),r!==void 0&&r!==``&&i.push([e,`<=`,r]),i}case`text`:{let n=String(t[0]??``).trim();return n?[[e,`contains`,n]]:[]}default:return[[e,`in`,t]]}}))},[c,_]),C=(e,t)=>{let n={...v,[e]:t};y(n),S(n),f?.(n)};n.useEffect(()=>{let e=v,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=x.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&&(y(t),e=t),Object.values(e).some(e=>e.length>0)&&S(e)},[]);let w=l!==void 0&&l<x.length?x.slice(0,l):x,T=l!==void 0&&l<x.length?x.slice(l):[],E=e=>{let t=v[e.field]||[],n=_.get(e.field),a=t.filter(e=>e!==``&&e!=null).length,s=a>0,c=n===`single-choice`,l=O.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),u=l?`w-72`:`w-56`;return(0,o.jsxs)(r.Popover,{children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`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`,s?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,o.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),s&&(0,o.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:a}),s?(0,o.jsx)(i.X,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),C(e.field,[])}}):(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:(0,r.cn)(u,`p-2`),children:l?(0,o.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,o.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];C(e.field,n)}})}):n===`range`?(0,o.jsx)(`div`,{className:`space-y-2 p-1`,"data-testid":`filter-range-${e.field}`,children:[0,1].map(n=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,o.jsx)(`span`,{className:`w-8 shrink-0`,children:n===0?`From`:`To`}),(0,o.jsx)(`input`,{type:`date`,"data-testid":`filter-range-${e.field}-${n===0?`from`:`to`}`,value:String(t[n]??``),onChange:r=>{let i=[String(t[0]??``),String(t[1]??``)];i[n]=r.target.value,C(e.field,i[0]===``&&i[1]===``?[]:i)},className:`h-7 flex-1 rounded border border-input bg-background px-2 text-xs text-foreground`})]},n))}):n===`text`?(0,o.jsx)(`input`,{type:`search`,"data-testid":`filter-text-${e.field}`,defaultValue:String(t[0]??``),placeholder:e.label||e.field,onBlur:t=>{let n=t.target.value.trim();C(e.field,n?[n]:[])},onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value.trim();C(e.field,n?[n]:[])}},className:`h-8 w-full rounded border border-input bg-background px-2 text-xs text-foreground`}):(0,o.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,o.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,o.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,o.jsx)(`input`,{type:c?`radio`:`checkbox`,name:c?`user-filter-${e.field}`:void 0,checked:t.includes(n.value),onChange:()=>{let r=c?[n.value]:t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];C(e.field,r)},className:c?`border-input`:`rounded border-input`}),n.color&&(0,o.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,o.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,u),"data-testid":`user-filters-dropdown`,children:x.length===0?(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,o.jsxs)(o.Fragment,{children:[w.map(E),T.length>0&&(0,o.jsxs)(r.Popover,{children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`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,o.jsx)(`span`,{children:h}),(0,o.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:T.length}),(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,o.jsx)(`div`,{className:`space-y-1`,children:T.map(E)})})]})]})})}function ie({tabs:e,showAllRecords:t,allowAddTab:a,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,m]=n.useState([]),[h,g]=n.useState(!1),[_,v]=n.useState(``),y=n.useCallback(t=>{if(t===`__all__`)return[];let n=e.find(e=>e.id===t);return n?n.filters||[]:p.find(e=>e.id===t)?.filters||[]},[e,p]),b=n.useCallback(e=>{f(e),s(y(e)),u?.({_tab:[e]})},[y,s,u]),x=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]),S=n.useCallback(()=>{let t=_.trim();if(!t)return;let n=new Set([...e.map(e=>e.id??e.name??``),...p.map(e=>e.id)]),r=p.length+1;for(;n.has(`__session_${r}__`);)r+=1;let i=`__session_${r}__`,a=y(d).map(e=>Array.isArray(e)?[...e]:e);m(e=>[...e,{id:i,label:t,filters:a}]),f(i),v(``),g(!1),s(a),u?.({_tab:[i]})},[_,e,p,y,d,s,u]),C=n.useCallback(n=>{if(m(e=>e.filter(e=>e.id!==n)),d!==n)return;let r=e.find(e=>e.default);b(r?.id||(t?`__all__`:e[0]?.id||``))},[d,e,t,b]);return n.useEffect(()=>{if(d&&d!==`__all__`){let t=e.find(e=>e.id===d);t&&s(t.filters||[])}},[]),(0,o.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,c),"data-testid":`user-filters-tabs`,children:[x.map(e=>{let t=e.id??e.name??``;return(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${t}`,onClick:()=>b(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)}),p.map(e=>{let t=d===e.id;return(0,o.jsxs)(`span`,{className:(0,r.cn)(`inline-flex items-center h-7 rounded-md transition-colors shrink-0`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),children:[(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${e.id}`,onClick:()=>b(e.id),className:`inline-flex items-center h-7 pl-3 pr-1 text-xs font-medium rounded-l-md`,children:e.label}),(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-remove-${e.id}`,onClick:()=>C(e.id),title:`Remove tab`,"aria-label":`Remove tab ${e.label}`,className:`inline-flex items-center h-7 pl-0.5 pr-2 rounded-r-md opacity-60 hover:opacity-100`,children:(0,o.jsx)(i.X,{className:`h-3 w-3`})})]},e.id)}),a&&(0,o.jsxs)(r.Popover,{open:h,onOpenChange:e=>{g(e),e||v(``)},children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsx)(`button`,{type:`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,o.jsx)(i.Plus,{className:`h-3.5 w-3.5`})})}),(0,o.jsxs)(r.PopoverContent,{align:`start`,className:`w-64 p-2 space-y-2`,"data-testid":`filter-tab-add-content`,children:[(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Name this tab. It keeps the filters applied right now, and lives in this session only.`}),(0,o.jsx)(r.Input,{autoFocus:!0,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:`Tab name`,className:`h-7 text-xs`,"data-testid":`filter-tab-add-input`}),(0,o.jsx)(`div`,{className:`flex justify-end`,children:(0,o.jsx)(r.Button,{size:`sm`,className:`h-7 px-2 text-xs`,disabled:!_.trim(),"data-testid":`filter-tab-add-confirm`,onClick:S,children:`Add tab`})})]})]})]})}function j({fields:e,onFilterChange:t,className:i}){let[a,s]=n.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),c=n.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),c(n),n})};return n.useEffect(()=>{a.size>0&&c(a)},[]),(0,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 overflow-x-auto`,i),"data-testid":`user-filters-toggle`,children:e.map(e=>{let t=a.has(e.field);return(0,o.jsx)(r.Button,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>l(e.field),children:e.label||e.field},e.field)})})}function M(e){switch(e.toLowerCase().replace(/[_\s]/g,``)){case`equals`:case`eq`:return`=`;case`notequals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notcontains`:return`notcontains`;case`startswith`:return`startswith`;case`endswith`:return`endswith`;case`greaterthan`:case`gt`:return`>`;case`greaterorequal`:case`greaterthanorequal`:case`gte`:return`>=`;case`lessthan`:case`lt`:return`<`;case`lessorequal`:case`lessthanorequal`:case`lte`:return`<=`;case`in`:return`in`;case`notin`:case`nin`:return`nin`;case`before`:return`<`;case`after`:return`>`;case`between`:return`between`;case`isnull`:return`isnull`;case`isnotnull`:return`isnotnull`;default:return e}}var ae=new Set([`nin`,`not_in`,`notIn`,`notin`,`not in`]);function N(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)?N(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:ae.has(n)&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}var oe=new Set([`formula`]);function se(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 ce(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function le(e){switch(e){case`bottom`:return{top:!1,bottom:!0};case`both`:return{top:!0,bottom:!0};default:return{top:!0,bottom:!1}}}function ue(e){let t=[e?.timeline,e?.options?.timeline,e?.calendar,e?.options?.calendar],n=e=>{for(let n of t){if(!n)continue;let t=e(n);if(typeof t==`string`&&t)return t}};return{startDateField:n(e=>e.startDateField??e.dateField),endDateField:n(e=>e.endDateField),titleField:n(e=>e.titleField)}}function P(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?N(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function de(e,n,r){let i=fe(n);return(0,t.mergeFilterNodes)(e,i.length>0?i:void 0,...P(r))}function fe(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=P(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,M(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}function F(e,n,r,i){return(0,t.resolveConditionalFormatting)(e,n,r,i)}function pe(e){let t=e,n=[t?.httpStatus,t?.status,t?.statusCode].find(e=>typeof e==`number`);if(n===void 0){let e=/HTTP (\d{3})\b/.exec(String(t?.message??``));e&&(n=Number(e[1]))}let r=typeof t?.code==`string`?t.code.toUpperCase():``;return he.has(r)?`api-disabled`:n===403||r===`PERMISSION_DENIED`||r===`FORBIDDEN`?`forbidden`:n===401||r===`UNAUTHORIZED`||r===`UNAUTHENTICATED`?`unauthorized`:n===400||me.has(r)?`rejected`:`network`}var me=new Set([`INVALID_FILTER`,`UNSUPPORTED_QUERY_PARAM`,`INVALID_QUERY`]),he=new Set([`OBJECT_API_DISABLED`,`OBJECT_API_METHOD_NOT_ALLOWED`]),ge={"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.loadErrorForbiddenTitle":`You don’t have access`,"list.loadErrorForbiddenMessage":`You don’t have permission to view these records. Contact your administrator if you think you should have access.`,"list.loadErrorUnauthorizedTitle":`Sign in required`,"list.loadErrorUnauthorizedMessage":`Your session has expired or you are signed out. Sign in again to view these records.`,"list.loadErrorRejectedTitle":`This view’s query was rejected`,"list.loadErrorRejectedMessage":`The server could not process this view’s filter or query options. Clearing the filters usually fixes it; if the view is saved this way, an administrator needs to correct it.`,"list.loadErrorApiDisabledTitle":`This object isn’t available through the API`,"list.loadErrorApiDisabledMessage":`This page can’t load its records because the object is not exposed through the API. That is a setting on the object itself, not a permission — an administrator has to enable API access for it before this page can work.`,"list.retry":`Retry`,"list.search":`Search`,"table.search":`Search…`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.sortByIdSuffix":`(by ID)`,"list.sortRelationalHint":`Columns that link to another record are not listed: they can only be sorted by the stored ID, not by the name shown in the cell. To sort by that name, denormalize it onto this object as a stored field, written when the source changes, and sort by that. Not a formula field: it is virtual, so no column is stored for it and the server refuses to sort by one.`,"list.resetSortToDefault":`Reset to view default`,"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.refresh":`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`,"common.printDialogHint":`Opens your browser’s print dialog (not a PDF export)`,"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.`,"detail.recordDetail":`Record Detail`,"detail.recordDetailWithLabel":`{{label}} Detail`},_e=(0,a.createSafeTranslation)(ge,`list.recordCount`);function ve(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=(0,a.useObjectLabel)();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var ye=n.forwardRef(({schema:e,className:s,onViewChange:f,onFilterChange:p,onSortChange:m,onSearchChange:h,onHiddenFieldsChange:g,onInlineEditChange:_,onColumnStateChange:v,onRowClick:y,showViewSwitcher:b,userFilterSelections:x,onUserFilterSelectionsChange:S,initialFilters:C,initialSearchTerm:T,...E},D)=>{let O=b??e?.showViewSwitcher??!1,{t:k}=_e(),{fieldLabel:te,actionLabel:re,objectLabel:A}=ve(),{translateOptions:ie}=(0,a.useSafeFieldLabel)(),j=n.useMemo(()=>(0,t.normalizeListViewSchema)(e),[e]),M=n.useCallback((e,t)=>j.objectName?te(j.objectName,e,t):t,[j.objectName,te]),ae=n.useCallback(e=>{let t=ce(e);return j.objectName&&typeof re==`function`?re(j.objectName,e,t):t},[j.objectName,re]),N=n.useMemo(()=>{let e=j.userActions,t=j.addRecord?.enabled===!0&&e?.addRecordForm!==!1,n=le(j.addRecord?.position);return{showSearch:e?.search!==!1,showSort:e?.sort!==!1,showFilters:e?.filter!==!1,showRefresh:e?.refresh!==!1,showDensity:e?.rowHeight!==!1,showGroup:e?.group!==!1,showHideFields:e?.hideFields===!0,showColor:e?.rowColor===!0,compactToolbar:j.compactToolbar===!0,showAddRecord:t,showAddRecordTop:t&&n.top,showAddRecordBottom:t&&n.bottom}},[j.userActions,j.compactToolbar,j.addRecord]),[P,fe]=n.useState(j.viewType),[F,me]=n.useState(()=>T??``),[he,ge]=n.useState(!1),[ye,be]=n.useState(!1),[I,xe]=n.useState(()=>se(j.sort)),Se=n.useMemo(()=>JSON.stringify(j.sort||[]),[j.sort]);n.useEffect(()=>{xe(se(j.sort))},[Se]);let Ce=n.useMemo(()=>se(j.sort),[Se]),we=n.useMemo(()=>I.length!==Ce.length||I.some((e,t)=>e.field!==Ce[t].field||e.order!==Ce[t].order),[I,Ce]),[Te,Ee]=n.useState(!1),[L,De]=n.useState(()=>C&&Array.isArray(C.conditions)?C:{id:`root`,logic:`and`,conditions:[]}),R=E.dataSource,[z,Oe]=n.useState([]),[ke,Ae]=n.useState(null),[B,je]=n.useState(`network`),[V,H]=n.useState(()=>!(Array.isArray(j.data)||j.data&&typeof j.data==`object`&&j.data.provider===`value`&&Array.isArray(j.data.items)||j.viewType===`gantt`&&j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`)),[U,Me]=n.useState(null),[Ne,Pe]=n.useState(!1),[Fe,Ie]=n.useState(0),[Le,Re]=n.useState(!1);n.useImperativeHandle(D,()=>({refresh:()=>Ie(e=>e+1)}),[]),n.useEffect(()=>{if(!(!R?.onMutation||!j.objectName))return R.onMutation(e=>{e.resource===j.objectName&&Ie(e=>e+1)})},[R,j.objectName]);let[ze,Be]=n.useState(void 0),W=ze??j.pagination?.pageSize??100,[Ve,He]=n.useState(1),[Ue,We]=n.useState(null),[Ge,Ke]=n.useState(null),G=n.useMemo(()=>{if(j.grouping?.fields?.length)return j.grouping;let e=typeof j.groupBy==`string`?j.groupBy.trim():``,t=typeof j.groupBy2==`string`?j.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},[j.grouping,j.groupBy,j.groupBy2]),[K,qe]=n.useState(G),[Je,Ye]=n.useState(!1),Xe=n.useRef(G);n.useEffect(()=>{Xe.current!==G&&(Xe.current=G,qe(G))},[G]);let[q,Ze]=n.useState(j.rowColor),[Qe,$e]=n.useState(!1),[et,tt]=n.useState([]),nt=n.useRef(0),[J,rt]=n.useState([]),it=n.useMemo(()=>{let e=j.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:M(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[j.userFilters,U,M]),[Y,at]=n.useState(()=>new Set(j.hiddenFields||[])),ot=n.useMemo(()=>JSON.stringify(j.hiddenFields||[]),[j.hiddenFields]);n.useEffect(()=>{at(new Set(j.hiddenFields||[]))},[ot]);let st=n.useCallback(e=>{at(e),g?.(Array.from(e))},[g]),[ct,lt]=n.useState(!1),[ut,dt]=n.useState(()=>!!j.inlineEdit);n.useEffect(()=>{dt(!!j.inlineEdit)},[j.inlineEdit]);let ft=n.useCallback(e=>{dt(e),_?.(e)},[_]),[pt,mt]=n.useState(!1),[ht,gt]=n.useState(!1),[_t,vt]=n.useState(null),{getObjectApiOperations:yt,can:bt}=(0,d.usePermissions)(),xt=j.objectName?yt(j.objectName):void 0,St=j.allowExport!==!1&&j.operations?.export!==!1&&(!xt||xt.includes(`export`)),Ct=n.useMemo(()=>{let e=j.bulkActions;return!e||e.length===0||(0,t.resolveEffectiveCrudAffordances)(U,xt).delete&&(!j.objectName||bt(j.objectName,`delete`))?e:e.filter(e=>String(e).toLowerCase()!==`delete`)},[j.bulkActions,j.objectName,U,xt,bt]),X=n.useMemo(()=>{if(j.exportOptions)return Array.isArray(j.exportOptions)?{formats:j.exportOptions}:j.exportOptions},[j.exportOptions]),wt=n.useMemo(()=>{let e=X?.formats||[`csv`,`json`],t=typeof R?.exportDownload==`function`&&j.objectName&&X?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return e.filter(e=>t.includes(e))},[X,R,j.objectName]);n.useEffect(()=>{let e=X?.formats;if(!e)return;let t=e.filter(e=>!wt.includes(e));t.length>0&&console.warn(`[ObjectUI] ListView export: unsupported format(s) hidden from the menu: ${t.join(`, `)}`)},[X,wt]);let Tt=n.useMemo(()=>(0,t.rowHeightToDensityMode)(j.rowHeight)??`compact`,[j.rowHeight]),Z=(0,c.useDensityMode)(Tt,{onChange:j.onDensityChange}),Et=n.useMemo(()=>`objectui:gallery:density:${j.objectName??`default`}`,[j.objectName]),[Q,Dt]=n.useState(()=>{if(typeof window>`u`)return j.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(Et);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return j.gallery?.cardSize??`medium`}),Ot=n.useCallback(()=>{Dt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(Et,t)}catch{}return t})},[Et]),kt=n.useCallback(async()=>{Ie(e=>e+1)},[]),{ref:At,isRefreshing:jt,pullDistance:Mt}=(0,u.usePullToRefresh)({onRefresh:kt,enabled:!!R&&!!j.objectName}),Nt=n.useMemo(()=>j.id?`listview-${j.objectName}-${j.id}-view`:`listview-${j.objectName}-view`,[j.objectName,j.id]);n.useEffect(()=>{let e=!0;return Pe(!1),Me(null),(async()=>{if(!R||!j.objectName){Pe(!0);return}if(typeof R.getObjectSchema!=`function`){Pe(!0);return}try{let t=await R.getObjectSchema(j.objectName);e&&Me(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Pe(!0)}})(),()=>{e=!1}},[j.objectName,R]);let Pt=n.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>(0,t.columnIdentity)(e)).filter(e=>typeof e==`string`&&e.length>0):[],n=new Set(e),r=e=>{if(!e)return;let t=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...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(j.kanban),r(j.options?.kanban),r(j.calendar),r(j.options?.calendar),r(j.gallery),r(j.options?.gallery),r(j.timeline),r(j.options?.timeline),r(j.gantt),r(j.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(U?.fields,i)},[U?.fields,j.columns,j.kanban,j.calendar,j.gallery,j.timeline,j.gantt,j.options]),Ft=(0,d.usePermissions)(),It=P===`gantt`&&!!j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`;n.useEffect(()=>{let e=!0,n=++nt.current;if(j.data&&typeof j.data==`object`&&!Array.isArray(j.data)){let e=j.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(F){let e=F.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}Oe(t),H(!1),Re(!1);return}}if(Array.isArray(j.data)){let e=j.data;if(F){let t=F.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}Oe(e),H(!1),Re(!1);return}if(It){H(!1),Re(!1);return}return Ne?((async()=>{if(!R||!j.objectName){H(!1);return}H(!0),Ae(null);try{let r=de(j.filter,L,J),i=I.length>0?I.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,a=(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>(0,t.columnIdentity)(e)).filter(e=>typeof e==`string`&&e.length>0):[],n=Ft?.isLoaded&&j.objectName?e.filter(e=>Ft.checkField(j.objectName,e,`read`)):e;if(n.length===0)return;let r=new Set([`id`]);for(let e of n)r.add(e);for(let e of Pt)r.add(e);let i=(()=>{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})(),a=e=>{typeof e!=`string`||!e||(!i||i.has(e))&&r.add(e)},o=e=>{t.PLATFORM_RECORD_COLUMNS.has(e)?r.add(e):a(e)},s=e=>{if(!e)return;let t=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)a(e)};s(j.kanban),s(j.options?.kanban),s(j.calendar),s(j.options?.calendar),s(j.gallery),s(j.options?.gallery),s(j.timeline),s(j.options?.timeline);{let e=j.timeline??j.options?.timeline;e&&!Array.isArray(e.metaFields)&&(a(`status`),a(`priority`))}s(j.gantt),s(j.options?.gantt);for(let e of(0,t.collectPredicateFieldRefs)((0,t.listViewPredicates)({conditionalFormatting:j.conditionalFormatting,rowActionDefs:j.rowActionDefs,bulkActionDefs:j.bulkActionDefs,objectActions:U?.actions,userActions:j.userActions??U?.userActions})))o(e);return Array.from(r)})(),o=r!==void 0,s=P===`grid`&&!K?.fields?.length,c=s?(Ve-1)*W:0,l={...o?{$filter:r}:{},$orderby:i,$top:W,...c>0?{$skip:c}:{},...a?{$select:a}:{},...Pt.length>0?{$expand:Pt}:{},...F?{$search:F,...j.searchableFields&&j.searchableFields.length>0?{$searchFields:j.searchableFields}:{}}:{}},u=await R.find(j.objectName,l);if(!e||n!==nt.current)return;let d=[];Array.isArray(u)?d=u:u&&typeof u==`object`&&(Array.isArray(u.data)?d=u.data:Array.isArray(u.records)?d=u.records:Array.isArray(u.value)&&(d=u.value)),Oe(d);let f=u&&typeof u==`object`?u.total??u.count:void 0,p=typeof f==`number`?f:null;We(s?p:null),Ke(l),Re(!(s&&p!=null)&&d.length>=W)}catch(e){n===nt.current&&(console.error(`ListView data fetch error:`,e),Oe([]),Ae(e?.message?String(e.message):String(e??`Unknown error`)),je(pe(e)))}finally{e&&n===nt.current&&H(!1)}})(),()=>{e=!1}):void 0},[j.objectName,j.data,R,j.filter,W,I,L,J,Fe,F,j.searchableFields,Pt,Ne,j.refreshTrigger,Ft,Ve,P,K,It]);let Lt=JSON.stringify([j.objectName,j.filter,W,I,L,J,F,P,K]),Rt=n.useRef(Lt);n.useEffect(()=>{Rt.current!==Lt&&(Rt.current=Lt,He(1))},[Lt]);let zt=n.useMemo(()=>{let e=[`grid`];(j.kanban?.groupByField||j.kanban?.groupField||j.options?.kanban?.groupField)&&e.push(`kanban`),(j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField)&&e.push(`gallery`),(j.calendar?.startDateField||j.options?.calendar?.startDateField)&&e.push(`calendar`),ue(j).startDateField&&e.push(`timeline`),(j.gantt?.startDateField||j.options?.gantt?.startDateField)&&e.push(`gantt`),(j.options?.map?.locationField||j.options?.map?.latitudeField&&j.options?.map?.longitudeField)&&e.push(`map`),(j.tree?.parentField||j.options?.tree?.parentField||j.viewType===`tree`)&&e.push(`tree`),j.viewType&&!e.includes(j.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(j.viewType)&&e.push(j.viewType);let t=j.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},[j.options,j.viewType,j.kanban,j.calendar,j.gantt,j.gallery,j.timeline,j.tree,j.appearance?.allowedVisualizations]);n.useEffect(()=>{j.viewType&&fe(j.viewType)},[j.viewType]);let Bt=n.useCallback(e=>{fe(e);try{localStorage.setItem(Nt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}f?.(e)},[Nt,f]),Vt=n.useCallback(e=>{me(e),h?.(e)},[h]),Ht=(0,c.useNavigationOverlay)({navigation:j.navigation,objectName:j.objectName,onNavigate:j.onNavigate,onRowClick:y}),Ut=j.label?k(`detail.recordDetailWithLabel`,{label:j.label}):j.objectName?k(`detail.recordDetailWithLabel`,{label:j.objectName.charAt(0).toUpperCase()+j.objectName.slice(1)}):k(`detail.recordDetail`),$=n.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns:[];if(Ft?.isLoaded&&j.objectName&&(e=e.filter(e=>{let n=(0,t.columnIdentity)(e);return!n||Ft.checkField(j.objectName,n,`read`)})),Y.size>0&&(e=e.filter(e=>{let n=(0,t.columnIdentity)(e);return n!=null&&!Y.has(n)})),j.fieldOrder&&j.fieldOrder.length>0){let n=new Map(j.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,r)=>(n.get((0,t.columnIdentity)(e))??1/0)-(n.get((0,t.columnIdentity)(r))??1/0))}return e},[j.columns,j.objectName,Y,j.fieldOrder,Ft]),Wt=n.useMemo(()=>{let e=Z.mode===`compact`?`compact`:Z.mode===`spacious`?`tall`:`medium`,t={objectName:j.objectName,fields:$,filter:j.filter,sort:I,className:`h-full w-full`,showSearch:!1,onRowClick:Ht.handleClick,rowHeight:e,hideRowHeightToggle:!0,...j.striped==null?{}:{striped:j.striped},...j.bordered==null?{}:{bordered:j.bordered},...v?{onColumnStateChange:v}:{},...j.columnState?{columnState:j.columnState}:{}};switch(P){default:case`grid`:return{type:`object-grid`,...t,columns:$,...j.conditionalFormatting?{conditionalFormatting:j.conditionalFormatting}:{},editable:ut,...j.wrapHeaders==null?{}:{wrapHeaders:j.wrapHeaders},...j.virtualScroll==null?{}:{virtualScroll:j.virtualScroll},...j.resizable==null?{}:{resizable:j.resizable},...j.selection?{selection:j.selection}:{},...j.pagination?{pagination:j.pagination}:{},...K?{grouping:K}:{},...q?{rowColor:q}:{},...j.rowActions?{rowActions:j.rowActions}:{},...j.rowActionDefs?{rowActionDefs:j.rowActionDefs}:{},...j.bulkActions?{batchActions:j.bulkActions}:{},...j.bulkActionDefs?{bulkActionDefs:j.bulkActionDefs}:{},...j.options?.grid||{}};case`kanban`:{let{columns:e,groupByField:n,groupField:r,cardFields:i,titleField:a,...o}={...j.options?.kanban||{},...j.kanban||{}},s=n||r||(0,l.detectStatusField)(U)||void 0;return{type:`object-kanban`,...t,groupBy:s,groupField:s,...a?{titleField:a}:{},cardFields:i||e||$||[],...K?{grouping:K}:{},...o}}case`calendar`:return{type:`object-calendar`,...t,startDateField:j.calendar?.startDateField||j.options?.calendar?.startDateField||`start_date`,endDateField:j.calendar?.endDateField||j.options?.calendar?.endDateField||`end_date`,...j.calendar?.titleField||j.options?.calendar?.titleField?{titleField:j.calendar?.titleField||j.options?.calendar?.titleField}:{},...j.calendar?.defaultView?{defaultView:j.calendar.defaultView}:{},...j.options?.calendar||{},...j.calendar||{}};case`gallery`:{let e={...j.options?.gallery||{},...j.gallery||{},cardSize:Q};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField,titleField:j.gallery?.titleField||j.options?.gallery?.titleField||`name`,...K?{grouping:K}:{}}}case`timeline`:{let e={...j.options?.timeline||{},...j.timeline||{}},n=ue(j),r={...e,...n.startDateField?{startDateField:n.startDateField}:{},...n.endDateField?{endDateField:n.endDateField}:{}};return{type:`object-timeline`,...t,timeline:Object.keys(r).length>0?r:void 0,startDateField:n.startDateField||`created_at`,titleField:n.titleField||`name`,...n.endDateField?{endDateField:n.endDateField}:{},...j.timeline?.groupByField?{groupByField:j.timeline.groupByField}:{},...j.timeline?.colorField?{colorField:j.timeline.colorField}:{},...j.timeline?.scale?{scale:j.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,...j.data?{data:j.data}:{},startDateField:j.gantt?.startDateField||j.options?.gantt?.startDateField||`start_date`,endDateField:j.gantt?.endDateField||j.options?.gantt?.endDateField||`end_date`,progressField:j.gantt?.progressField||j.options?.gantt?.progressField||`progress`,dependenciesField:j.gantt?.dependenciesField||j.options?.gantt?.dependenciesField||`dependencies`,...j.gantt?.titleField?{titleField:j.gantt.titleField}:{},...j.options?.gantt||{},...j.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:j.options?.map?.locationField||`location`,...j.options?.map||{}};case`tree`:{let e=j.tree||j.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=j.chart||j.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:j.objectName,chartType:e.chartType||`bar`,filter:j.filter,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[P,j,I,$,K,q,Ht.handleClick,Z.mode,Q,ut,U]),Gt=L.conditions&&L.conditions.length>0,Kt=n.useMemo(()=>{let e,n=(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 j.objectName?ie(j.objectName,e,n):n};return e=U?.fields?Object.entries(U.fields).map(([e,t])=>({value:e,label:M(e,t.label||e),type:t.type||`text`,options:n(e,t.options),referenceTo:t.reference_to||t.reference,displayField:t.display_field||t.reference_field,idField:t.id_field})):(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{value:e,label:e,type:`text`}];let r=(0,t.columnIdentity)(e);return r?[{value:r,label:M(r,e.label||r),type:e.type||`text`,options:n(r,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}]:[]}),e},[U,j.columns,j.objectName,M,ie]),qt=n.useMemo(()=>{if(!j.filterableFields||j.filterableFields.length===0)return Kt;let e=new Set(j.filterableFields);return Kt.filter(t=>e.has(t.value))},[Kt,j.filterableFields]),{sortFields:Jt,sortHasRelationalField:Yt}=n.useMemo(()=>{let e=new Set(I.map(e=>e.field).filter(Boolean)),n=!1,r=[];for(let i of Kt){let a=t.EXPANDABLE_FIELD_TYPES.has(i.type);if(!a&&!oe.has(i.type)){r.push({value:i.value,label:i.label});continue}if(e.has(i.value)){r.push({value:i.value,label:a?`${i.label} ${k(`list.sortByIdSuffix`)}`:i.label});continue}a&&(n=!0)}return{sortFields:r,sortHasRelationalField:n}},[Kt,I,k]),Xt=n.useCallback(e=>{let t=e.map(e=>({id:crypto.randomUUID(),field:e.field,order:e.order}));xe(t),He(1),m?.(t)},[m]),Zt=n.useCallback(()=>{let e=se(j.sort);xe(e),He(1),m?.(e)},[Se,m]),Qt=n.useCallback(e=>{if(!St)return;let n=X,r=n?.maxRecords||0,i=n?.includeHeaders!==!1,a=U?.label&&U?.name&&typeof A==`function`?A(U):U?.label,o=e=>(0,t.buildExportFileName)(e,{prefix:n?.fileNamePrefix,label:a,objectName:j.objectName,viewLabel:j.label||j.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof R?.exportDownload==`function`&&j.objectName&&n?.streaming!==!1){let n=$.map(e=>(0,t.columnIdentity)(e)).filter(Boolean),a=de(j.filter,L,J),s=I.length>0?I.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;vt(null),gt(!0),(async()=>{try{let t=await R.exportDownload(j.objectName,{format:e,fields:n.length?n:void 0,filter:a,...F?{search:F,...j.searchableFields&&j.searchableFields.length>0?{searchFields:j.searchableFields}:{}}:{},sort:s,includeHeaders:i,limit:r>0?r:void 0}),c=URL.createObjectURL(t),l=document.createElement(`a`);l.href=c,l.download=o(e),l.rel=`noopener`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(c),mt(!1)}catch(e){console.error(`ListView export failed:`,e),vt(e instanceof Error?e.message:String(e))}finally{gt(!1)}})();return}let s=r>0?z.slice(0,r):z;if(e===`csv`){let e=$.map(e=>(0,t.columnIdentity)(e)).filter(Boolean),n=[];i&&n.push(e.join(`,`)),s.forEach(t=>{n.push(e.map(e=>{let n=t[e],r;return r=n==null?``:Array.isArray(n)?n.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof n==`object`?JSON.stringify(n):String(n),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("@object-ui/i18n"),require("react/jsx-runtime"),require("@objectstack/spec/ui"),require("@object-ui/fields"),require("@object-ui/react"),require("@object-ui/types"),require("@object-ui/mobile"),require("@object-ui/permissions")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/i18n`,`react/jsx-runtime`,`@objectstack/spec/ui`,`@object-ui/fields`,`@object-ui/react`,`@object-ui/types`,`@object-ui/mobile`,`@object-ui/permissions`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginList={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.ObjectUIi18n,e.jsxRuntime,e._objectstack_spec_ui,e.ObjectUIFields,e.ObjectUIReact,e.ObjectUITypes,e.ObjectUIMobile,e._object_ui_permissions))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var b={grid:(0,o.jsx)(i.Grid3x3,{className:`h-4 w-4`}),kanban:(0,o.jsx)(i.LayoutGrid,{className:`h-4 w-4`}),gallery:(0,o.jsx)(i.Images,{className:`h-4 w-4`}),calendar:(0,o.jsx)(i.Calendar,{className:`h-4 w-4`}),timeline:(0,o.jsx)(i.Activity,{className:`h-4 w-4`}),gantt:(0,o.jsx)(i.ChartGantt,{className:`h-4 w-4`}),map:(0,o.jsx)(i.Map,{className:`h-4 w-4`}),chart:(0,o.jsx)(i.ChartColumn,{className:`h-4 w-4`}),tree:(0,o.jsx)(i.ListTree,{className:`h-4 w-4`})},x={grid:`console.objectView.viewTypeGrid`,kanban:`console.objectView.viewTypeKanban`,gallery:`console.objectView.viewTypeGallery`,calendar:`console.objectView.viewTypeCalendar`,timeline:`console.objectView.viewTypeTimeline`,gantt:`console.objectView.viewTypeGantt`,map:`console.objectView.viewTypeMap`,chart:`console.objectView.viewTypeChart`,tree:`console.objectView.viewTypeTree`},S=(0,a.createSafeTranslation)({"console.objectView.viewTypeGrid":`Grid`,"console.objectView.viewTypeKanban":`Kanban`,"console.objectView.viewTypeGallery":`Gallery`,"console.objectView.viewTypeCalendar":`Calendar`,"console.objectView.viewTypeTimeline":`Timeline`,"console.objectView.viewTypeGantt":`Gantt`,"console.objectView.viewTypeMap":`Map`,"console.objectView.viewTypeChart":`Chart`,"console.objectView.viewTypeTree":`Tree`},`console.objectView.viewTypeGrid`);function C(){let{t:e}=S();return n.useMemo(()=>{let t={};for(let[n,r]of Object.entries(x))t[n]=e(r);return t},[e])}var w=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:a,className:s,animated:c=!0})=>{let[l,u]=n.useState(!1),d=C(),f=n.useCallback(t=>{u(!1),t!==e&&(c&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>a(t)):a(t))},[c,e,a]);return t.length>=2&&t.length<=4?(0,o.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,o.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":d[t],title:d[t],"data-state":n?`on`:`off`,onClick:()=>f(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:[b[t],(0,o.jsx)(`span`,{className:`hidden sm:inline-block`,children:d[t]})]},t)})}):(0,o.jsxs)(r.Popover,{open:l,onOpenChange:u,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":d[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:[b[e],(0,o.jsx)(`span`,{className:`hidden sm:inline-block`,children:d[e]}),(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>f(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:[b[t],(0,o.jsx)(`span`,{className:`flex-1 text-left`,children:d[t]}),t===e&&(0,o.jsx)(i.Check,{className:`h-3.5 w-3.5`})]},t))})]})},T=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:i,className:a,animated:s=!0})=>{let c=C(),l=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,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 bg-transparent oui-view-switcher`,a),children:t.map(t=>{let n=e===t;return(0,o.jsxs)(`button`,{type:`button`,onClick:()=>l(t),"aria-label":c[t],title:c[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:[b[t],(0,o.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:c[t]})]},t)})})};function E({title:e,badge:t,onClear:a,clearLabel:s,defaultOpen:c=!0,children:l}){let[u,d]=n.useState(c);return(0,o.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,o.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,o.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,o.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})]}),a&&(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:s})]}),u&&(0,o.jsx)(`div`,{className:`px-3 pb-3`,children:l})]})}function ee(e){let{t,allFields:a,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),C=[!!c?.fields?.length,!!d?.field,m&&m.mode!==`compact`,(g?.size??0)>0,!!y].filter(Boolean).length,w=m?.mode===`compact`?i.Rows4:m?.mode===`comfortable`?i.Rows3:i.Rows2,T=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,o.jsxs)(r.Popover,{open:x,onOpenChange:S,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,C>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,o.jsx)(i.Settings2,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:T}),C>0&&(0,o.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:C})]})}),(0,o.jsxs)(r.PopoverContent,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,o.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,o.jsx)(`div`,{className:`text-sm font-semibold`,children:T}),(0,o.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),s&&l&&(0,o.jsx)(E,{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,o.jsx)(r.GroupingEditor,{value:c,fieldOptions:a.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,o.jsxs)(E,{title:t(`list.rowColor`,{defaultValue:`Row Color`}),onClear:d?()=>f(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!d,children:[(0,o.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,o.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,o.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),a.map(e=>(0,o.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),p&&m&&(0,o.jsx)(E,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:m.mode!==`compact`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:m.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,o.jsx)(w,{className:`h-3.5 w-3.5`}),(0,o.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,o.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),v&&b&&(0,o.jsx)(E,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!y,children:(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!!y,onChange:()=>b(!y),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,o.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),h&&g&&_&&(0,o.jsx)(E,{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,o.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:a.map(e=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.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,o.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function D(){let{t:e}=(0,a.useObjectTranslation)(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}var te=new Set([`lookup`,`master_detail`,`user`]),O={select:`single-choice`,"multi-select":`multi-choice`,boolean:`multi-choice`,"date-range":`range`,text:`text`};function k(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,(0,s.normalizeFilterOperator)(e.operator),e.value]):[],default:e.default??e.isDefault}))}function ne({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:s,onSelectionsChange:c}){switch(e.element){case`dropdown`:return(0,o.jsx)(A,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:s,onSelectionsChange:c});case`tabs`:return(0,o.jsx)(ie,{tabs:k(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof s?._tab?.[0]==`string`?s._tab[0]:void 0,onSelectionsChange:c});case`toggle`:return(0,o.jsx)(ae,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function re(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:l,maxVisible:u,className:d,initialSelections:f,onSelectionsChange:p}){let{fieldLabel:m,translateOptions:h}=(0,a.useSafeFieldLabel)(),g=D(),_=t?.name,v=n.useMemo(()=>new Map(e.map(e=>[e.field,O[e.type??``]])),[e]),[y,b]=n.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=f?.[e.field];n&&n.length>0&&(t[e.field]=n),v.get(e.field)===`single-choice`&&(t[e.field]?.length??0)>1&&(t[e.field]=t[e.field].slice(0,1))}),t}),x=n.useRef({}),S=n.useMemo(()=>re(e,t,s,{objectName:_,fieldLabel:m,translateOptions:h}).map(e=>{if(!e.showCount)return e;if((y[e.field]||[]).length===0)return x.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=x.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,s,_,m,h,y]),C=n.useCallback(e=>{l(Object.entries(e).flatMap(([e,t])=>{if(t.length===0)return[];switch(v.get(e)){case`range`:{let[n,r]=t,i=[];return n!==void 0&&n!==``&&i.push([e,`>=`,n]),r!==void 0&&r!==``&&i.push([e,`<=`,r]),i}case`text`:{let n=String(t[0]??``).trim();return n?[[e,`contains`,n]]:[]}default:return[[e,`in`,t]]}}))},[l,v]),w=(e,t)=>{let n={...y,[e]:t};b(n),C(n),p?.(n)};n.useEffect(()=>{let e=y,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=S.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&&(b(t),e=t),Object.values(e).some(e=>e.length>0)&&C(e)},[]);let T=u!==void 0&&u<S.length?S.slice(0,u):S,E=u!==void 0&&u<S.length?S.slice(u):[],ee=e=>{let t=y[e.field]||[],n=v.get(e.field),a=t.filter(e=>e!==``&&e!=null).length,s=a>0,l=n===`single-choice`,u=(0,c.isRetiredFieldType)(e.type);u&&(0,c.reportRetiredFieldType)(e.type);let d=!u&&te.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`),f=d?`w-72`:`w-56`;return(0,o.jsxs)(r.Popover,{children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`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`,s?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,o.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),s&&(0,o.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:a}),s?(0,o.jsx)(i.X,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),w(e.field,[])}}):(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:(0,r.cn)(f,`p-2`),children:d?(0,o.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,o.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];w(e.field,n)}})}):n===`range`?(0,o.jsx)(`div`,{className:`space-y-2 p-1`,"data-testid":`filter-range-${e.field}`,children:[0,1].map(n=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,o.jsx)(`span`,{className:`w-8 shrink-0`,children:n===0?`From`:`To`}),(0,o.jsx)(`input`,{type:`date`,"data-testid":`filter-range-${e.field}-${n===0?`from`:`to`}`,value:String(t[n]??``),onChange:r=>{let i=[String(t[0]??``),String(t[1]??``)];i[n]=r.target.value,w(e.field,i[0]===``&&i[1]===``?[]:i)},className:`h-7 flex-1 rounded border border-input bg-background px-2 text-xs text-foreground`})]},n))}):n===`text`?(0,o.jsx)(`input`,{type:`search`,"data-testid":`filter-text-${e.field}`,defaultValue:String(t[0]??``),placeholder:e.label||e.field,onBlur:t=>{let n=t.target.value.trim();w(e.field,n?[n]:[])},onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value.trim();w(e.field,n?[n]:[])}},className:`h-8 w-full rounded border border-input bg-background px-2 text-xs text-foreground`}):(0,o.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,o.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,o.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,o.jsx)(`input`,{type:l?`radio`:`checkbox`,name:l?`user-filter-${e.field}`:void 0,checked:t.includes(n.value),onChange:()=>{let r=l?[n.value]:t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];w(e.field,r)},className:l?`border-input`:`rounded border-input`}),n.color&&(0,o.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,o.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,d),"data-testid":`user-filters-dropdown`,children:S.length===0?(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,o.jsxs)(o.Fragment,{children:[T.map(ee),E.length>0&&(0,o.jsxs)(r.Popover,{children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsxs)(`button`,{type:`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,o.jsx)(`span`,{children:g}),(0,o.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:E.length}),(0,o.jsx)(i.ChevronDown,{className:`h-3 w-3 opacity-60`})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,o.jsx)(`div`,{className:`space-y-1`,children:E.map(ee)})})]})]})})}function ie({tabs:e,showAllRecords:t,allowAddTab:a,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,m]=n.useState([]),[h,g]=n.useState(!1),[_,v]=n.useState(``),y=n.useCallback(t=>{if(t===`__all__`)return[];let n=e.find(e=>e.id===t);return n?n.filters||[]:p.find(e=>e.id===t)?.filters||[]},[e,p]),b=n.useCallback(e=>{f(e),s(y(e)),u?.({_tab:[e]})},[y,s,u]),x=n.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]),S=n.useCallback(()=>{let t=_.trim();if(!t)return;let n=new Set([...e.map(e=>e.id??e.name??``),...p.map(e=>e.id)]),r=p.length+1;for(;n.has(`__session_${r}__`);)r+=1;let i=`__session_${r}__`,a=y(d).map(e=>Array.isArray(e)?[...e]:e);m(e=>[...e,{id:i,label:t,filters:a}]),f(i),v(``),g(!1),s(a),u?.({_tab:[i]})},[_,e,p,y,d,s,u]),C=n.useCallback(n=>{if(m(e=>e.filter(e=>e.id!==n)),d!==n)return;let r=e.find(e=>e.default);b(r?.id||(t?`__all__`:e[0]?.id||``))},[d,e,t,b]);return n.useEffect(()=>{if(d&&d!==`__all__`){let t=e.find(e=>e.id===d);t&&s(t.filters||[])}},[]),(0,o.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-0.5 overflow-x-auto`,c),"data-testid":`user-filters-tabs`,children:[x.map(e=>{let t=e.id??e.name??``;return(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${t}`,onClick:()=>b(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)}),p.map(e=>{let t=d===e.id;return(0,o.jsxs)(`span`,{className:(0,r.cn)(`inline-flex items-center h-7 rounded-md transition-colors shrink-0`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),children:[(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-${e.id}`,onClick:()=>b(e.id),className:`inline-flex items-center h-7 pl-3 pr-1 text-xs font-medium rounded-l-md`,children:e.label}),(0,o.jsx)(`button`,{type:`button`,"data-testid":`filter-tab-remove-${e.id}`,onClick:()=>C(e.id),title:`Remove tab`,"aria-label":`Remove tab ${e.label}`,className:`inline-flex items-center h-7 pl-0.5 pr-2 rounded-r-md opacity-60 hover:opacity-100`,children:(0,o.jsx)(i.X,{className:`h-3 w-3`})})]},e.id)}),a&&(0,o.jsxs)(r.Popover,{open:h,onOpenChange:e=>{g(e),e||v(``)},children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.jsx)(`button`,{type:`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,o.jsx)(i.Plus,{className:`h-3.5 w-3.5`})})}),(0,o.jsxs)(r.PopoverContent,{align:`start`,className:`w-64 p-2 space-y-2`,"data-testid":`filter-tab-add-content`,children:[(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Name this tab. It keeps the filters applied right now, and lives in this session only.`}),(0,o.jsx)(r.Input,{autoFocus:!0,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:`Tab name`,className:`h-7 text-xs`,"data-testid":`filter-tab-add-input`}),(0,o.jsx)(`div`,{className:`flex justify-end`,children:(0,o.jsx)(r.Button,{size:`sm`,className:`h-7 px-2 text-xs`,disabled:!_.trim(),"data-testid":`filter-tab-add-confirm`,onClick:S,children:`Add tab`})})]})]})]})}function ae({fields:e,onFilterChange:t,className:i}){let[a,s]=n.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),c=n.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),c(n),n})};return n.useEffect(()=>{a.size>0&&c(a)},[]),(0,o.jsx)(`div`,{className:(0,r.cn)(`flex items-center gap-1 overflow-x-auto`,i),"data-testid":`user-filters-toggle`,children:e.map(e=>{let t=a.has(e.field);return(0,o.jsx)(r.Button,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>l(e.field),children:e.label||e.field},e.field)})})}var oe=[`latitudeField`,`longitudeField`,`locationField`,`titleField`,`descriptionField`,`zoom`,`center`];function j(e){if(!e||typeof e!=`object`)return{};let t=e;return Object.fromEntries(oe.filter(e=>e in t).map(e=>[e,t[e]]))}function se(e){return{...j(e.options?.map),...j(e.map)}}function M(e){switch(e.toLowerCase().replace(/[_\s]/g,``)){case`equals`:case`eq`:return`=`;case`notequals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`icontains`:return`icontains`;case`notcontains`:return`notcontains`;case`startswith`:return`startswith`;case`endswith`:return`endswith`;case`greaterthan`:case`gt`:return`>`;case`greaterorequal`:case`greaterthanorequal`:case`gte`:return`>=`;case`lessthan`:case`lt`:return`<`;case`lessorequal`:case`lessthanorequal`:case`lte`:return`<=`;case`in`:return`in`;case`notin`:case`nin`:return`nin`;case`before`:return`<`;case`after`:return`>`;case`between`:return`between`;case`isnull`:return`isnull`;case`isnotnull`:return`isnotnull`;default:return e}}var ce=[],le=new Set([`nin`,`not_in`,`notIn`,`notin`,`not in`]);function N(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)?N(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:le.has(n)&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function ue(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 de(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fe(e){switch(e){case`bottom`:return{top:!1,bottom:!0};case`both`:return{top:!0,bottom:!0};default:return{top:!0,bottom:!1}}}function pe(e){let t=[e?.timeline,e?.options?.timeline,e?.calendar,e?.options?.calendar],n=e=>{for(let n of t){if(!n)continue;let t=e(n);if(typeof t==`string`&&t)return t}};return{startDateField:n(e=>e.startDateField??e.dateField),endDateField:n(e=>e.endDateField),titleField:n(e=>e.titleField)}}function P(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?N(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function me(e,n,r){let i=he(n);return(0,t.mergeFilterNodes)(e,i.length>0?i:void 0,...P(r))}function he(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=P(e.conditions.filter(e=>r.VALUELESS_FILTER_BUILDER_OPERATORS.has(e.operator)?!0:(0,r.isFilterValueComplete)(e.operator,e.value)).map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:r.VALUELESS_FILTER_BUILDER_OPERATORS.has(e.operator)?[e.field,M(e.operator),null]:[e.field,M(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}function F(e,n,r,i){return(0,t.resolveConditionalFormatting)(e,n,r,i)}var ge={"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.loadErrorForbiddenTitle":`You don’t have access`,"list.loadErrorForbiddenMessage":`You don’t have permission to view these records. Contact your administrator if you think you should have access.`,"list.loadErrorUnauthorizedTitle":`Sign in required`,"list.loadErrorUnauthorizedMessage":`Your session has expired or you are signed out. Sign in again to view these records.`,"list.loadErrorRejectedTitle":`This view’s query was rejected`,"list.loadErrorRejectedMessage":`The server could not process this view’s filter or query options. Clearing the filters usually fixes it; if the view is saved this way, an administrator needs to correct it.`,"list.loadErrorApiDisabledTitle":`This object isn’t available through the API`,"list.loadErrorApiDisabledMessage":`This page can’t load its records because the object is not exposed through the API. That is a setting on the object itself, not a permission — an administrator has to enable API access for it before this page can work.`,"list.retry":`Retry`,"list.search":`Search`,"table.search":`Search…`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.sortByIdSuffix":`(by ID)`,"list.sortRelationalHint":`Columns that link to another record are not listed: they can only be sorted by the stored ID, not by the name shown in the cell. To sort by that name, denormalize it onto this object as a stored field, written when the source changes, and sort by that. Not a formula field: it is virtual, so no column is stored for it and the server refuses to sort by one.`,"list.resetSortToDefault":`Reset to view default`,"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.refresh":`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`,"common.printDialogHint":`Opens your browser’s print dialog (not a PDF export)`,"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.`,"detail.recordDetail":`Record Detail`,"detail.recordDetailWithLabel":`{{label}} Detail`},_e=(0,a.createSafeTranslation)(ge,`list.recordCount`);function ve(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=(0,a.useObjectLabel)();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var ye=n.forwardRef(({schema:e,className:c,onViewChange:p,onFilterChange:m,onSortChange:h,onSearchChange:g,onHiddenFieldsChange:_,onInlineEditChange:v,onColumnStateChange:y,onRowClick:b,showViewSwitcher:x,userFilterSelections:S,onUserFilterSelectionsChange:C,initialFilters:T,initialSearchTerm:E,...D},te)=>{let O=x??e?.showViewSwitcher??!1,{t:k}=_e(),{fieldLabel:re,actionLabel:A,objectLabel:ie}=ve(),{translateOptions:ae}=(0,a.useSafeFieldLabel)(),oe=(0,a.useDisplayLocale)(),j=n.useMemo(()=>(0,t.normalizeListViewSchema)(e),[e]),M=n.useCallback((e,t)=>j.objectName?re(j.objectName,e,t):t,[j.objectName,re]),le=n.useCallback(e=>{let t=de(e);return j.objectName&&typeof A==`function`?A(j.objectName,e,t):t},[j.objectName,A]),N=n.useMemo(()=>{let e=j.userActions,t=j.addRecord?.enabled===!0&&e?.addRecordForm!==!1,n=fe(j.addRecord?.position);return{showSearch:e?.search!==!1,showSort:e?.sort!==!1,showFilters:e?.filter!==!1,showRefresh:e?.refresh!==!1,showDensity:e?.rowHeight!==!1,showGroup:e?.group!==!1,showHideFields:e?.hideFields===!0,showColor:e?.rowColor===!0,compactToolbar:j.compactToolbar===!0,showAddRecord:t,showAddRecordTop:t&&n.top,showAddRecordBottom:t&&n.bottom}},[j.userActions,j.compactToolbar,j.addRecord]),[P,he]=n.useState(j.viewType),[F,ge]=n.useState(()=>E??``),[ye,be]=n.useState(!1),[xe,Se]=n.useState(!1),[I,Ce]=n.useState(()=>ue(j.sort)),we=n.useMemo(()=>JSON.stringify(j.sort||[]),[j.sort]);n.useEffect(()=>{Ce(ue(j.sort))},[we]);let Te=n.useMemo(()=>ue(j.sort),[we]),Ee=n.useMemo(()=>I.length!==Te.length||I.some((e,t)=>e.field!==Te[t].field||e.order!==Te[t].order),[I,Te]),[De,Oe]=n.useState(!1),[L,ke]=n.useState(()=>T&&Array.isArray(T.conditions)?T:{id:`root`,logic:`and`,conditions:[]}),R=D.dataSource,[z,Ae]=n.useState([]),[je,Me]=n.useState(null),[B,Ne]=n.useState(`network`),[V,Pe]=n.useState(()=>!(Array.isArray(j.data)||j.data&&typeof j.data==`object`&&j.data.provider===`value`&&Array.isArray(j.data.items)||j.viewType===`gantt`&&j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`)),[H,Fe]=n.useState(null),[Ie,Le]=n.useState(!1),[Re,ze]=n.useState(0),[Be,Ve]=n.useState(!1);n.useImperativeHandle(te,()=>({refresh:()=>ze(e=>e+1)}),[]),n.useEffect(()=>{if(!(!R?.onMutation||!j.objectName))return R.onMutation(e=>{e.resource===j.objectName&&ze(e=>e+1)})},[R,j.objectName]);let[He,Ue]=n.useState(void 0),U=He??j.pagination?.pageSize??100,[We,Ge]=n.useState(1),[Ke,qe]=n.useState(null),[Je,Ye]=n.useState(null),W=n.useMemo(()=>{if(j.grouping?.fields?.length)return j.grouping;let e=typeof j.groupBy==`string`?j.groupBy.trim():``,t=typeof j.groupBy2==`string`?j.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},[j.grouping,j.groupBy,j.groupBy2]),[G,Xe]=n.useState(W),[Ze,Qe]=n.useState(!1),$e=n.useRef(W);n.useEffect(()=>{$e.current!==W&&($e.current=W,Xe(W))},[W]);let[K,et]=n.useState(j.rowColor),[tt,nt]=n.useState(!1),[rt,it]=n.useState([]),at=n.useRef(0),[q,ot]=n.useState([]),st=n.useMemo(()=>{let e=j.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!H?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(H.fields)?H.fields.map(e=>[e.name,e]):Object.entries(H.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:M(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[j.userFilters,H,M]),[J,ct]=n.useState(()=>new Set(j.hiddenFields||[])),lt=n.useMemo(()=>JSON.stringify(j.hiddenFields||[]),[j.hiddenFields]);n.useEffect(()=>{ct(new Set(j.hiddenFields||[]))},[lt]);let ut=n.useCallback(e=>{ct(e),_?.(Array.from(e))},[_]),[dt,ft]=n.useState(!1),[pt,mt]=n.useState(()=>!!j.inlineEdit);n.useEffect(()=>{mt(!!j.inlineEdit)},[j.inlineEdit]);let ht=n.useCallback(e=>{mt(e),v?.(e)},[v]),[gt,_t]=n.useState(!1),[vt,yt]=n.useState(!1),[bt,xt]=n.useState(null),{getObjectApiOperations:St,can:Ct}=(0,f.usePermissions)(),wt=j.objectName?St(j.objectName):void 0,Tt=j.allowExport!==!1&&j.operations?.export!==!1&&(!wt||wt.includes(`export`)),Et=n.useMemo(()=>{let e=j.bulkActions;return!e||e.length===0||(0,t.resolveEffectiveCrudAffordances)(H,wt).delete&&(!j.objectName||Ct(j.objectName,`delete`))?e:e.filter(e=>String(e).toLowerCase()!==`delete`)},[j.bulkActions,j.objectName,H,wt,Ct]),Dt=n.useMemo(()=>j.userActions?.editInline!==!1&&(0,t.isObjectInlineEditable)(H,wt)&&(!j.objectName||Ct(j.objectName,`update`)),[j.userActions,j.objectName,H,wt,Ct]),Y=n.useMemo(()=>{if(j.exportOptions)return Array.isArray(j.exportOptions)?{formats:j.exportOptions}:j.exportOptions},[j.exportOptions]),X=n.useMemo(()=>{let e=Y?.formats||[`csv`,`json`],t=typeof R?.exportDownload==`function`&&j.objectName&&Y?.streaming!==!1?[`csv`,`xlsx`,`json`]:[`csv`,`json`];return e.filter(e=>t.includes(e))},[Y,R,j.objectName]);n.useEffect(()=>{let e=Y?.formats;if(!e)return;let t=e.filter(e=>!X.includes(e));t.length>0&&console.warn(`[ObjectUI] ListView export: unsupported format(s) hidden from the menu: ${t.join(`, `)}`)},[Y,X]);let Ot=n.useMemo(()=>(0,t.rowHeightToDensityMode)(j.rowHeight)??`compact`,[j.rowHeight]),Z=(0,l.useDensityMode)(Ot,{onChange:j.onDensityChange}),kt=n.useMemo(()=>`objectui:gallery:density:${j.objectName??`default`}`,[j.objectName]),[Q,At]=n.useState(()=>{if(typeof window>`u`)return j.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(kt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return j.gallery?.cardSize??`medium`}),jt=n.useCallback(()=>{At(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(kt,t)}catch{}return t})},[kt]),Mt=n.useCallback(async()=>{ze(e=>e+1)},[]),{ref:Nt,isRefreshing:Pt,pullDistance:Ft}=(0,d.usePullToRefresh)({onRefresh:Mt,enabled:!!R&&!!j.objectName}),It=n.useMemo(()=>j.id?`listview-${j.objectName}-${j.id}-view`:`listview-${j.objectName}-view`,[j.objectName,j.id]);n.useEffect(()=>{let e=!0;return Le(!1),Fe(null),(async()=>{if(!R||!j.objectName){Le(!0);return}if(typeof R.getObjectSchema!=`function`){Le(!0);return}try{let t=await R.getObjectSchema(j.objectName);e&&Fe(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Le(!0)}})(),()=>{e=!1}},[j.objectName,R]);let Lt=n.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>(0,t.columnIdentity)(e)).filter(e=>typeof e==`string`&&e.length>0):[],n=new Set(e),r=e=>{if(!e)return;let t=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...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(j.kanban),r(j.options?.kanban),r(j.calendar),r(j.options?.calendar),r(j.gallery),r(j.options?.gallery),r(j.timeline),r(j.options?.timeline),r(j.gantt),r(j.options?.gantt);let i=n.size>0?Array.from(n):void 0;return(0,t.buildExpandFields)(H?.fields,i)},[H?.fields,j.columns,j.kanban,j.calendar,j.gallery,j.timeline,j.gantt,j.options]),Rt=(0,f.usePermissions)(),zt=P===`gantt`&&!!j.data&&typeof j.data==`object`&&!Array.isArray(j.data)&&j.data.provider===`api`;n.useEffect(()=>{let e=!0,n=++at.current;if(j.data&&typeof j.data==`object`&&!Array.isArray(j.data)){let e=j.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(F){let e=F.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}Ae(t),Pe(!1),Ve(!1);return}}if(Array.isArray(j.data)){let e=j.data;if(F){let t=F.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}Ae(e),Pe(!1),Ve(!1);return}if(zt){Pe(!1),Ve(!1);return}return Ie?((async()=>{if(!R||!j.objectName){Pe(!1);return}Pe(!0),Me(null);try{let r=me(j.filter,L,q),i=I.length>0?I.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,a=(()=>{let e=Array.isArray(j.columns)?j.columns.map(e=>(0,t.columnIdentity)(e)).filter(e=>typeof e==`string`&&e.length>0):[],n=Rt?.isLoaded&&j.objectName?e.filter(e=>Rt.checkField(j.objectName,e,`read`)):e;if(n.length===0)return;let r=new Set([`id`]);for(let e of n)r.add(e);for(let e of Lt)r.add(e);let i=(()=>{let e=H?.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})(),a=e=>{typeof e!=`string`||!e||(!i||i.has(e))&&r.add(e)},o=e=>{t.PLATFORM_RECORD_COLUMNS.has(e)?r.add(e):a(e)},s=e=>{if(!e)return;let t=[e.groupByField,e.groupField,e.groupBy,e.summarizeField,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.swimlaneField,e.valueField,...Array.isArray(e.columns)?e.columns:[],...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)a(e)};s(j.kanban),s(j.options?.kanban),s(j.calendar),s(j.options?.calendar),s(j.gallery),s(j.options?.gallery),s(j.timeline),s(j.options?.timeline);{let e=j.timeline??j.options?.timeline;e&&!Array.isArray(e.metaFields)&&(a(`status`),a(`priority`))}s(j.gantt),s(j.options?.gantt);for(let e of(0,t.collectPredicateFieldRefs)((0,t.listViewPredicates)({conditionalFormatting:j.conditionalFormatting,rowActionDefs:j.rowActionDefs,bulkActionDefs:j.bulkActionDefs,objectActions:H?.actions,userActions:H?.userActions})))o(e);return Array.from(r)})(),o=r!==void 0,s=P===`grid`&&!G?.fields?.length,c=s?(We-1)*U:0,l={...o?{$filter:r}:{},$orderby:i,$top:U,...c>0?{$skip:c}:{},...a?{$select:a}:{},...Lt.length>0?{$expand:Lt}:{},...F?{$search:F,...j.searchableFields&&j.searchableFields.length>0?{$searchFields:j.searchableFields}:{}}:{}},u=await R.find(j.objectName,l);if(!e||n!==at.current)return;let d=[];Array.isArray(u)?d=u:u&&typeof u==`object`&&(Array.isArray(u.data)?d=u.data:Array.isArray(u.records)?d=u.records:Array.isArray(u.value)&&(d=u.value)),Ae(d);let f=u&&typeof u==`object`?u.total??u.count:void 0,p=typeof f==`number`?f:null;qe(s?p:null),Ye(l),Ve(!(s&&p!=null)&&d.length>=U)}catch(e){n===at.current&&(console.error(`ListView data fetch error:`,e),Ae([]),Me(e?.message?String(e.message):String(e??`Unknown error`)),Ne((0,l.classifyLoadError)(e)))}finally{e&&n===at.current&&Pe(!1)}})(),()=>{e=!1}):void 0},[j.objectName,j.data,R,j.filter,U,I,L,q,Re,F,j.searchableFields,Lt,Ie,j.refreshTrigger,Rt,We,P,G,zt]);let Bt=JSON.stringify([j.objectName,j.filter,U,I,L,q,F,P,G]),Vt=n.useRef(Bt);n.useEffect(()=>{Vt.current!==Bt&&(Vt.current=Bt,Ge(1))},[Bt]);let Ht=n.useMemo(()=>{let e=[`grid`];(j.kanban?.groupByField||j.kanban?.groupField||j.options?.kanban?.groupField)&&e.push(`kanban`),(j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField)&&e.push(`gallery`),(j.calendar?.startDateField||j.options?.calendar?.startDateField)&&e.push(`calendar`),pe(j).startDateField&&e.push(`timeline`),(j.gantt?.startDateField||j.options?.gantt?.startDateField)&&e.push(`gantt`);let t=se(j);(t.locationField||t.latitudeField&&t.longitudeField)&&e.push(`map`),(j.tree?.parentField||j.options?.tree?.parentField||j.viewType===`tree`)&&e.push(`tree`),j.viewType&&!e.includes(j.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(j.viewType)&&e.push(j.viewType);let n=j.appearance?.allowedVisualizations;if(Array.isArray(n)&&n.length>0){let t=n.filter(t=>e.includes(t));return t.length>0?t:[`grid`]}return e},[j.options,j.viewType,j.kanban,j.calendar,j.gantt,j.gallery,j.timeline,j.map,j.tree,j.appearance?.allowedVisualizations]);n.useEffect(()=>{j.viewType&&he(j.viewType)},[j.viewType]);let Ut=n.useCallback(e=>{he(e);try{localStorage.setItem(It,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}p?.(e)},[It,p]),Wt=n.useCallback(e=>{ge(e),g?.(e)},[g]),Gt=(0,l.useNavigationOverlay)({navigation:j.navigation,objectName:j.objectName,onNavigate:j.onNavigate,onRowClick:b}),Kt=j.label?k(`detail.recordDetailWithLabel`,{label:j.label}):j.objectName?k(`detail.recordDetailWithLabel`,{label:j.objectName.charAt(0).toUpperCase()+j.objectName.slice(1)}):k(`detail.recordDetail`),$=n.useMemo(()=>{let e=Array.isArray(j.columns)?j.columns:[];if(Rt?.isLoaded&&j.objectName&&(e=e.filter(e=>{let n=(0,t.columnIdentity)(e);return!n||Rt.checkField(j.objectName,n,`read`)})),J.size>0&&(e=e.filter(e=>{let n=(0,t.columnIdentity)(e);return n!=null&&!J.has(n)})),j.fieldOrder&&j.fieldOrder.length>0){let n=new Map(j.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,r)=>(n.get((0,t.columnIdentity)(e))??1/0)-(n.get((0,t.columnIdentity)(r))??1/0))}return e},[j.columns,j.objectName,J,j.fieldOrder,Rt]),qt=n.useMemo(()=>{let e=Z.mode===`compact`?`compact`:Z.mode===`spacious`?`tall`:`medium`,t={objectName:j.objectName,fields:$,filter:j.filter,sort:I,className:`h-full w-full`,showSearch:!1,onRowClick:Gt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...y?{onColumnStateChange:y}:{},...j.columnState?{columnState:j.columnState}:{}};switch(P){default:case`grid`:return{type:`object-grid`,...t,columns:$,...j.conditionalFormatting?{conditionalFormatting:j.conditionalFormatting}:{},editable:pt&&Dt,...j.wrapHeaders==null?{}:{wrapHeaders:j.wrapHeaders},...j.resizable==null?{}:{resizable:j.resizable},...j.selection?{selection:j.selection}:{},...j.pagination?{pagination:j.pagination}:{},...G?{grouping:G}:{},...K?{rowColor:K}:{},...j.rowActions?{rowActions:j.rowActions}:{},...j.rowActionDefs?{rowActionDefs:j.rowActionDefs}:{},...j.bulkActions?{batchActions:j.bulkActions}:{},...j.bulkActionDefs?{bulkActionDefs:j.bulkActionDefs}:{},...j.options?.grid||{}};case`kanban`:{let{columns:e,groupByField:n,groupField:r,cardFields:i,titleField:a,...o}={...j.options?.kanban||{},...j.kanban||{}},s=n||r||(0,u.detectStatusField)(H)||void 0;return{type:`object-kanban`,...t,groupBy:s,groupField:s,...a?{titleField:a}:{},cardFields:i||e||$||[],...G?{grouping:G}:{},...o}}case`calendar`:return{type:`object-calendar`,...t,startDateField:j.calendar?.startDateField||j.options?.calendar?.startDateField||`start_date`,endDateField:j.calendar?.endDateField||j.options?.calendar?.endDateField||`end_date`,...j.calendar?.titleField||j.options?.calendar?.titleField?{titleField:j.calendar?.titleField||j.options?.calendar?.titleField}:{},...j.calendar?.defaultView?{defaultView:j.calendar.defaultView}:{},...j.options?.calendar||{},...j.calendar||{}};case`gallery`:{let e={...j.options?.gallery||{},...j.gallery||{},cardSize:Q};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:j.gallery?.coverField||j.gallery?.imageField||j.options?.gallery?.imageField,titleField:j.gallery?.titleField||j.options?.gallery?.titleField||`name`,...G?{grouping:G}:{}}}case`timeline`:{let e={...j.options?.timeline||{},...j.timeline||{}},n=pe(j),r={...e,...n.startDateField?{startDateField:n.startDateField}:{},...n.endDateField?{endDateField:n.endDateField}:{}};return{type:`object-timeline`,...t,timeline:Object.keys(r).length>0?r:void 0,startDateField:n.startDateField||`created_at`,titleField:n.titleField||`name`,...n.endDateField?{endDateField:n.endDateField}:{},...j.timeline?.groupByField?{groupByField:j.timeline.groupByField}:{},...j.timeline?.colorField?{colorField:j.timeline.colorField}:{},...j.timeline?.scale?{scale:j.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,...j.data?{data:j.data}:{},startDateField:j.gantt?.startDateField||j.options?.gantt?.startDateField||`start_date`,endDateField:j.gantt?.endDateField||j.options?.gantt?.endDateField||`end_date`,progressField:j.gantt?.progressField||j.options?.gantt?.progressField||`progress`,dependenciesField:j.gantt?.dependenciesField||j.options?.gantt?.dependenciesField||`dependencies`,...j.gantt?.titleField?{titleField:j.gantt.titleField}:{},...j.options?.gantt||{},...j.gantt||{}};case`map`:{let e=se(j);return{type:`object-map`,...t,locationField:e.locationField||`location`,...e}}case`tree`:{let e=j.tree||j.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=j.chart||j.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:j.objectName,chartType:e.chartType||`bar`,filter:j.filter,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[P,j,I,$,G,K,Gt.handleClick,Z.mode,Q,pt,Dt,H]),Jt=L.conditions&&L.conditions.length>0,Yt=n.useMemo(()=>{let e,n=(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 j.objectName?ae(j.objectName,e,n):n};return e=H?.fields?Object.entries(H.fields).map(([e,t])=>({value:e,label:M(e,t.label||e),type:t.type||`text`,options:n(e,t.options),referenceTo:t.reference_to||t.reference,displayField:t.display_field||t.reference_field,idField:t.id_field})):(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{value:e,label:e,type:`text`}];let r=(0,t.columnIdentity)(e);return r?[{value:r,label:M(r,e.label||r),type:e.type||`text`,options:n(r,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}]:[]}),e},[H,j.columns,j.objectName,M,ae]),Xt=n.useMemo(()=>{if(!j.filterableFields||j.filterableFields.length===0)return Yt;let e=new Set(j.filterableFields);return Yt.filter(t=>e.has(t.value))},[Yt,j.filterableFields]),{sortFields:Zt,sortHasRelationalField:Qt}=n.useMemo(()=>{let e=new Set(I.map(e=>e.field).filter(Boolean)),n=!1,r=[];for(let i of Yt){let a=t.EXPANDABLE_FIELD_TYPES.has(i.type);if(!a&&!t.UNMATERIALIZED_FIELD_TYPES.has(i.type)){r.push({value:i.value,label:i.label});continue}if(e.has(i.value)){r.push({value:i.value,label:a?`${i.label} ${k(`list.sortByIdSuffix`)}`:i.label});continue}a&&(n=!0)}return{sortFields:r,sortHasRelationalField:n}},[Yt,I,k]),$t=n.useCallback(e=>{let t=e.map(e=>({id:crypto.randomUUID(),field:e.field,order:e.order}));Ce(t),Ge(1),h?.(t)},[h]),en=n.useCallback(()=>{let e=ue(j.sort);Ce(e),Ge(1),h?.(e)},[we,h]),tn=n.useCallback(e=>{if(!Tt)return;let n=Y,r=n?.maxRecords||0,i=n?.includeHeaders!==!1,a=H?.label&&H?.name&&typeof ie==`function`?ie(H):H?.label,o=e=>(0,t.buildExportFileName)(e,{prefix:n?.fileNamePrefix,label:a,objectName:j.objectName,viewLabel:j.label||j.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof R?.exportDownload==`function`&&j.objectName&&n?.streaming!==!1){let n=$.map(e=>(0,t.columnIdentity)(e)).filter(Boolean),a=me(j.filter,L,q),s=I.length>0?I.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;xt(null),yt(!0),(async()=>{try{let t=await R.exportDownload(j.objectName,{format:e,fields:n.length?n:void 0,filter:a,...F?{search:F,...j.searchableFields&&j.searchableFields.length>0?{searchFields:j.searchableFields}:{}}:{},sort:s,includeHeaders:i,limit:r>0?r:void 0}),c=URL.createObjectURL(t),l=document.createElement(`a`);l.href=c,l.download=o(e),l.rel=`noopener`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(c),_t(!1)}catch(e){console.error(`ListView export failed:`,e),xt(e instanceof Error?e.message:String(e))}finally{yt(!1)}})();return}let s=r>0?z.slice(0,r):z;if(e===`csv`){let e=$.map(e=>(0,t.columnIdentity)(e)).filter(Boolean),n=[];i&&n.push(e.join(`,`)),s.forEach(t=>{n.push(e.map(e=>{let n=t[e],r;return r=n==null?``:Array.isArray(n)?n.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof n==`object`?JSON.stringify(n):String(n),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
2
|
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let r=new Blob([n.join(`
|
|
3
|
-
`)],{type:`text/csv;charset=utf-8;`}),a=URL.createObjectURL(r),c=document.createElement(`a`);c.href=a,c.download=o(`csv`),c.click(),URL.revokeObjectURL(a)}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)}mt(!1)},[z,$,X,j.objectName,j.filter,j.searchableFields,St,R,L,J,I,F,U,A]),$t=n.useMemo(()=>(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{name:e,label:M(e,e)}];let n=(0,t.columnIdentity)(e);return n?[{name:n,label:M(n,e.label||n)}]:[]}),[j.columns,M]);return(0,o.jsxs)(`div`,{ref:At,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,s),...j.aria?.ariaLabel?{"aria-label":j.aria.ariaLabel}:{},...j.aria?.ariaDescribedBy?{"aria-describedby":j.aria.ariaDescribedBy}:{},...j.aria?.live?{"aria-live":j.aria.live}:{},role:j.aria?.role??`region`,"aria-busy":V||void 0,"data-state":V?`loading`:`idle`,children:[Mt>0&&(0,o.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Mt},children:k(jt?`list.refreshing`:`list.pullToRefresh`)}),j.description&&j.appearance?.showDescription!==!1&&(0,o.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof j.description==`string`?j.description:``}),(0,o.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,o.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:it&&(0,o.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,o.jsx)(ne,{config:it,objectDef:U,data:z,onFilterChange:rt,maxVisible:3,initialSelections:x,onSelectionsChange:S})})}),(0,o.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,"data-print-hide":!0,children:[O&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w,{currentView:P,availableViews:zt,onViewChange:Bt}),(0,o.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),P===`grid`&&_&&!N.compactToolbar&&(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>ft(!ut),className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,ut&&`text-primary`),title:k(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,o.jsx)(i.Pencil,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),N.showHideFields&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:ct,onOpenChange:lt,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.hideFields`)}),Y.size>0&&(0,o.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,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.hideFieldsTitle`)}),Y.size>0&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>st(new Set),children:k(`list.showAll`)})]}),(0,o.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:$t.map(e=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.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),st(t)},className:`rounded border-input`}),(0,o.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),N.showHideFields&&!N.compactToolbar&&(N.showFilters||N.showSort||N.showGroup)&&(0,o.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showFilters&&(0,o.jsxs)(r.Popover,{open:Te,onOpenChange:Ee,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,Gt&&`text-foreground font-medium`),children:[(0,o.jsx)(i.SlidersHorizontal,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.filter`)}),Gt&&(0,o.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.conditions?.length||0})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.filterRecords`)})}),(0,o.jsx)(r.FilterBuilder,{fields:qt,value:L,onChange:e=>{De(e),p&&p(e)}})]})})]}),N.showGroup&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:Je,onOpenChange:Ye,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.Group,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.group`)}),K&&K.fields?.length>0&&(0,o.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,o.jsx)(r.PopoverContent,{align:`start`,className:`w-72 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.groupBy`)}),K&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>qe(void 0),"data-testid":`clear-grouping`,children:k(`list.clear`)})]}),(0,o.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,o.jsx)(r.GroupingEditor,{value:K,fieldOptions:$t.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:k(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:k(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:k(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>qe(e)})})]})})]}),N.showSort&&(0,o.jsxs)(r.Popover,{open:ye,onOpenChange:be,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,I.length>0&&`text-foreground font-medium`),children:[(0,o.jsx)(i.ArrowUpDown,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.sort`)}),I.length>0&&(0,o.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:I.length})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.sortRecords`)}),Ce.length>0&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-primary`,disabled:!we,onClick:Zt,"data-testid":`sort-reset-default`,children:k(`list.resetSortToDefault`)})]}),(0,o.jsx)(r.SortBuilder,{fields:Jt,value:I,onChange:e=>{xe(e),m&&m(e)}}),Yt&&(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sort-relational-hint`,children:k(`list.sortRelationalHint`)})]})})]}),!N.compactToolbar&&(N.showFilters||N.showSort||N.showGroup)&&(N.showColor||N.showDensity)&&(0,o.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showColor&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:Qe,onOpenChange:$e,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.Paintbrush,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.color`)})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.rowColor`)}),q&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ze(void 0),"data-testid":`clear-row-color`,children:k(`list.clear`)})]}),(0,o.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,o.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:k(`list.colorByField`)}),(0,o.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,o.jsx)(`option`,{value:``,children:k(`list.none`)}),$t.map(e=>(0,o.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),N.showDensity&&!N.compactToolbar&&P!==`gallery`&&(()=>{let e=Z.mode===`compact`?i.Rows4:Z.mode===`comfortable`?i.Rows3:i.Rows2,t=Z.mode===`compact`?k(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Z.mode===`comfortable`?k(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):k(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${k(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,a=k(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,o.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:a,children:(0,o.jsx)(e,{className:`h-3.5 w-3.5`})})})(),N.showDensity&&!N.compactToolbar&&P===`gallery`&&(()=>{let e=Q===`small`?i.Rows4:Q===`medium`?i.Rows3:i.Rows2,t=Q===`small`?k(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Q===`medium`?k(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):k(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${k(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,a=k(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,o.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:Ot,title:a,children:(0,o.jsx)(e,{className:`h-3.5 w-3.5`})})})(),N.compactToolbar&&(N.showGroup||N.showColor||N.showDensity||N.showHideFields)&&(0,o.jsx)(ee,{t:k,allFields:$t,showGroup:N.showGroup,groupingConfig:K,setGroupingConfig:qe,showColor:N.showColor,rowColorConfig:q,setRowColorConfig:Ze,showDensity:N.showDensity,density:Z,showHideFields:N.showHideFields,hiddenFields:Y,updateHiddenFields:st,showInlineEdit:P===`grid`,inlineEdit:ut,setInlineEdit:ft}),(N.showColor||N.showDensity||N.compactToolbar)&&X&&St&&wt.length>0&&(0,o.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showRefresh&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,onClick:()=>Ie(e=>e+1),disabled:V,title:k(`list.refresh`),"aria-label":k(`list.refresh`),"data-testid":`refresh-button`,children:(0,o.jsx)(i.RotateCw,{className:(0,r.cn)(`h-3.5 w-3.5`,V&&`animate-spin`)})}),X&&St&&wt.length>0&&(0,o.jsxs)(r.Popover,{open:pt,onOpenChange:mt,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.export`)})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,o.jsxs)(`div`,{className:`space-y-1`,children:[wt.map(e=>(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:ht,onClick:()=>Qt(e),children:[ht?(0,o.jsx)(i.Loader2,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,o.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),k(`list.exportAs`,{format:e.toUpperCase()})]},e)),_t&&(0,o.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:_t})]})})]}),j.sharing?.type&&(0,o.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: ${j.sharing.type}`,"data-testid":`share-button`,children:[(0,o.jsx)(i.Share2,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.share`)})]}),j.allowPrinting&&(()=>{let e=k(`common.printDialogHint`);return(0,o.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(),"aria-label":`${k(`list.print`)}: ${e}`,title:e,"data-testid":`print-button`,children:[(0,o.jsx)(i.Printer,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.print`)})]})})(),(()=>{let e=j.allowPrinting||!!j.sharing?.type||X&&St&&wt.length>0;return N.showSearch&&e?(0,o.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),N.showSearch&&(0,o.jsxs)(r.Popover,{open:he,onOpenChange:ge,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,F?`px-2 text-foreground font-medium`:`w-7 p-0`),"data-testid":`search-icon-button`,title:F?`${k(`list.search`)}: ${F}`:k(`list.search`),children:[(0,o.jsx)(i.Search,{className:`h-3.5 w-3.5`}),F&&(0,o.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:F})]})}),(0,o.jsx)(r.PopoverContent,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,o.jsx)(r.Input,{placeholder:k(`table.search`),value:F,onChange:e=>Vt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),F&&(0,o.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:()=>Vt(``),children:(0,o.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),N.showAddRecordTop&&(0,o.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:()=>E.onAddRecord?.(),children:[(0,o.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.addRecord`)})]})]})]}),(0,o.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,o.jsx)(r.RefreshIndicator,{active:V&&z.length>0}),ke&&z.length===0?(0,o.jsx)(r.DataEmptyState,{"data-testid":`list-error-state`,"data-error-kind":B,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:B===`network`?(0,o.jsx)(i.AlertTriangle,{className:`h-12 w-12 text-destructive/60`}):(0,o.jsx)(i.ShieldAlert,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:k(B===`api-disabled`?`list.loadErrorApiDisabledTitle`:B===`forbidden`?`list.loadErrorForbiddenTitle`:B===`unauthorized`?`list.loadErrorUnauthorizedTitle`:B===`rejected`?`list.loadErrorRejectedTitle`:`list.loadErrorTitle`),description:k(B===`api-disabled`?`list.loadErrorApiDisabledMessage`:B===`forbidden`?`list.loadErrorForbiddenMessage`:B===`unauthorized`?`list.loadErrorUnauthorizedMessage`:B===`rejected`?`list.loadErrorRejectedMessage`:`list.loadErrorMessage`),action:B===`api-disabled`?void 0:(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>Ie(e=>e+1),children:[(0,o.jsx)(i.RotateCw,{className:`h-4 w-4 mr-1.5`}),k(`list.retry`)]})}):V&&z.length===0?(0,o.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,o.jsx)(`span`,{className:`sr-only`,children:k(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,o.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!V&&z.length===0&&P===`grid`?(()=>{let e=j.emptyState?.icon,t=e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,n=Array.isArray(j.filter)?j.filter.length>0:j.filter&&typeof j.filter==`object`?Object.keys(j.filter).length>0:!1,a=!!(F&&F.trim())||n||Array.isArray(J)&&J.length>0||Array.isArray(L?.conditions)&&L.conditions.length>0,s=(typeof j.emptyState?.title==`string`?j.emptyState.title:void 0)??k(a?`list.noMatches`:`list.firstRunTitle`),c=(typeof j.emptyState?.message==`string`?j.emptyState.message:void 0)??k(a?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,o.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,o.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:s,description:c,action:N.showAddRecord?(0,o.jsxs)(r.Button,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>E.onAddRecord?.(),children:[(0,o.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),k(`list.addRecord`)]}):void 0})})():(0,o.jsx)(c.SchemaRenderer,{schema:Wt,...E,...It?{}:{data:z},loading:V,onRowSelect:tt,...P===`grid`&&!K?.fields?.length&&Ue!=null?{manualPagination:!0,rowCount:Ue,page:Ve,pageSize:W,onPageChange:e=>He(e),onPageSizeChange:e=>{Be(e),He(1)},sort:I,onSortChange:Xt,findParams:Ge}:{}})]},P),N.showAddRecordBottom&&(0,o.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,o.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:()=>E.onAddRecord?.(),children:[(0,o.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.addRecord`)})]})}),Ct&&Ct.length>0&&et.length>0&&P!==`grid`&&(0,o.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,o.jsx)(i.CheckSquare,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,o.jsxs)(`span`,{className:`font-medium`,children:[et.length,` `,et.length===1?`item`:`items`,` selected`]}),(0,o.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:Ct.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),a=n?i.Trash2:null;return(0,o.jsxs)(r.Button,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>E.onBulkAction?.(e,et),"data-testid":`bulk-action-${e}`,children:[a&&(0,o.jsx)(a,{className:`h-3 w-3`}),ae(e)]},e)})}),(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>tt([]),children:[(0,o.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!V&&z.length>0&&j.showRecordCount!==!1&&(0,o.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,o.jsx)(`span`,{className:`font-medium text-foreground/80`,children:(()=>{let e=Ue??z.length;return k(e===1?`list.recordCountOne`:`list.recordCount`,{count:e})})()}),Le&&(0,o.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:k(`list.dataLimitReached`,{limit:W})}),P!==`grid`&&j.pagination?.pageSizeOptions&&j.pagination.pageSizeOptions.length>0&&(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,o.jsx)(`span`,{children:k(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,o.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);Be(t),E.onPageSizeChange&&E.onPageSizeChange(t)},children:j.pagination.pageSizeOptions.map(e=>(0,o.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Ht.isOverlay&&(0,o.jsx)(r.NavigationOverlay,{...Ht,title:Ut,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});ye.displayName=`ListView`;var be={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`,viewType:!0},I=n.default.forwardRef((e,r)=>{let i=(0,n.useContext)(c.SchemaRendererContext),a=((0,t.isElementDataSourceConfig)(e.dataSource)?void 0:e.dataSource)??i?.dataSource;return(0,o.jsx)(c.ElementDataSourceGate,{schema:e.schema,mapping:be,dataSource:a,testId:`list-view`,errorTitle:`This list view’s data source could not be resolved`,children:t=>(0,o.jsx)(ye,{ref:r,...e,schema:t,dataSource:a})})});I.displayName=`ListViewBlock`;var xe={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`},Se={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},Ce=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),we=[{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 Te(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return we[Math.abs(t)%we.length]}var Ee=({imageUrl:e,title:t,coverFit:i,aspectClass:a,placeholder:s,hidden:c})=>{let[l,u]=(0,n.useState)(!1),d=!!e&&!l;return(0,o.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,a),hidden:c,children:d?i===`contain`?(0,o.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br`,s.bg),children:(0,o.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,o.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,o.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,o.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,s.text),children:t[0]?.toUpperCase()})})})},L=({imageUrl:e,title:t,placeholder:i})=>{let[a,s]=(0,n.useState)(!1),c=!!e&&!a;return(0,o.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,o.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,o.jsx)(`span`,{className:(0,r.cn)(`text-base font-semibold`,i.text),children:t[0]?.toUpperCase()})})},De=(e,t)=>{let n=e?.[t];if(n!=null&&n!==``)return(0,f.readFileValues)(n)[0]?.url},R=e=>{let{schema:a}=e,s=(0,n.useContext)(c.SchemaRendererContext),l=e.dataSource||s?.dataSource,u=(0,c.useDataScope)(a.bind),[d,p]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(null),v=(0,c.useNavigationOverlay)({navigation:a.navigation,objectName:a.objectName,onRowClick:e.onRowClick??e.onCardClick}),y=a.gallery,b=y?.coverField??a.imageField??`image`,x=y?.coverFit??`cover`,S=y?.cardSize??`medium`,C=y?.titleField??a.titleField,w=y?.visibleFields,{fieldLabel:T,fieldOptionLabel:E}=(0,c.useSafeFieldLabel)(),ee=(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(a.objectName){let t=String(n.label??e);n.label=T(a.objectName,e,t)}return a.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(a.objectName,e,n,r)}})),n},[g,a.objectName,T,E]);(0,n.useEffect)(()=>{let e=!0;return(async()=>{if(!(!l||typeof l.getObjectSchema!=`function`||!a.objectName))try{let t=await l.getObjectSchema(a.objectName);e&&_(t)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[a.objectName,l]),(0,n.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){p(e.data);return}return a.objectName&&!u&&!a.data&&!e.data&&(async()=>{if(!(!l||typeof l.find!=`function`||!a.objectName)){n&&h(!0);try{let e=(0,t.buildExpandFields)(g?.fields),r=await l.find(a.objectName,{$filter:a.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}},[a.objectName,l,u,a.data,a.filter,e.data,g]);let D=e.data||u||a.data||d||[],O=(0,n.useMemo)(()=>D.some(e=>!!De(e,b)),[D,b]),k=a.grouping?.fields,te=!!(k&&k.length>0),[ne,re]=(0,n.useState)({}),A=(0,n.useMemo)(()=>k?k.some(e=>e.collapsed):!1,[k]),ie=(0,n.useCallback)(e=>{re(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),j=(0,n.useMemo)(()=>{if(!te||!k)return[];let e=new Map,t=[];for(let n of D){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 ne?ne[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[D,k,te,ne,A]);if(m&&!D.length)return(0,o.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!D.length)return(0,o.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let M=e=>!w||w.length===0?null:(0,o.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=ee(t),a=(0,f.resolveCellRendererType)(i)||i.type||`text`,s=(0,f.getCellRenderer)(a),c=i?.label&&String(i.label).trim()?String(i.label):void 0,l=c!=null&&Ce.has(a);return(0,o.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,o.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:c}),(0,o.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=De(n,b),u=Te(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||a.navigation)&&`cursor-pointer`);return O&&x===`contain`?(0,o.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[(0,o.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,o.jsx)(r.CardContent,{className:`p-4`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,o.jsx)(L,{imageUrl:l,title:c,placeholder:u}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),M(n)]})]})})]},s):(0,o.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[!O&&(0,o.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,o.jsx)(Ee,{imageUrl:l,title:c,coverFit:x,aspectClass:Se[S],placeholder:u,hidden:!O}),(0,o.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,O&&`border-t border-border/60`),children:[(0,o.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),M(n)]})]},s)},N=e=>(0,o.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,xe[S],a.className),role:`list`,children:e.map((e,t)=>ae(e,t))});return(0,o.jsxs)(o.Fragment,{children:[te?(0,o.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,o.jsxs)(`div`,{className:`border rounded-md`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>ie(e.key),children:[e.collapsed?(0,o.jsx)(i.ChevronRight,{className:`h-4 w-4 shrink-0`}):(0,o.jsx)(i.ChevronDown,{className:`h-4 w-4 shrink-0`}),(0,o.jsx)(`span`,{children:e.label}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&N(e.items)]},e.key))}):N(D),v.isOverlay&&(0,o.jsx)(r.NavigationOverlay,{...v,title:`Gallery Item`,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})};t.ComponentRegistry.register(`object-gallery`,R,{namespace:`plugin-list`,label:`Gallery View`,category:`view`});function z(e){if(!e)return null;let t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return i.icons[t]??null}function Oe(e){return e.filter(e=>e.pinned||e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}function ke(){let{language:e}=(0,a.useObjectTranslation)();return n.useCallback(t=>t?(0,a.pickLocalized)(t.label,e):``,[e])}var Ae=({tabs:e,activeTab:t,onTabChange:i,className:a})=>{let s=n.useMemo(()=>Oe(e),[e]),c=ke(),l=n.useMemo(()=>s.find(e=>e.isDefault)?.name??s[0]?.name,[s]),[u,d]=n.useState(l),f=t??u,p=n.useCallback(e=>{d(e.name),i?.(e)},[i]);return s.length===0?null:(0,o.jsx)(`div`,{className:(0,r.cn)(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,a),"data-testid":`view-tabs`,role:`tablist`,children:s.map(e=>{let t=z(e.icon),n=f===e.name;return(0,o.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:()=>p(e),children:[t&&(0,o.jsx)(t,{className:`h-3 w-3 mr-1.5`}),c(e)]},e.name)})})},B=({tabs:e,activeTab:t,onTabChange:a,className:s})=>{let c=n.useMemo(()=>Oe(e),[e]),l=ke(),u=n.useMemo(()=>c.find(e=>e.isDefault)?.name??c[0]?.name,[c]),[d,f]=n.useState(u),p=t??d,m=n.useMemo(()=>c.find(e=>e.name===p)??c[0],[c,p]),h=n.useCallback(e=>{f(e.name),a?.(e)},[a]);if(c.length===0)return null;let g=z(m?.icon);return(0,o.jsx)(`div`,{className:(0,r.cn)(`px-2 py-1`,s),"data-testid":`view-tabs-select`,children:(0,o.jsxs)(r.DropdownMenu,{children:[(0,o.jsx)(r.DropdownMenuTrigger,{asChild:!0,children:(0,o.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:[g&&(0,o.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`}),(0,o.jsx)(`span`,{className:`truncate`,children:l(m)}),(0,o.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,o.jsx)(r.DropdownMenuContent,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:c.map(e=>{let t=z(e.icon),n=p===e.name;return(0,o.jsxs)(r.DropdownMenuItem,{onClick:()=>h(e),className:(0,r.cn)(`text-sm`,n&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,o.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,o.jsx)(`span`,{className:`truncate`,children:l(e)})]},e.name)})})]})})},je=I;t.ComponentRegistry.register(`list-view`,je,{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:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,columns:[],filter:[],sort:[],options:{}}}),t.ComponentRegistry.register(`list`,je,{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:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]}),e.LIST_DEFAULT_TRANSLATIONS=ge,e.ListView=ye,e.ListViewBlock=I,e.ObjectGallery=R,e.TabBar=Ae,e.TabBarSelect=B,e.UserFilters=ne,e.ViewSwitcher=T,e.ViewSwitcherDropdown=w,e.evaluateConditionalFormatting=F,e.normalizeFilterCondition=N,e.normalizeFilters=P});
|
|
3
|
+
`)],{type:`text/csv;charset=utf-8;`}),a=URL.createObjectURL(r),c=document.createElement(`a`);c.href=a,c.download=o(`csv`),c.click(),URL.revokeObjectURL(a)}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)}_t(!1)},[z,$,Y,j.objectName,j.filter,j.searchableFields,Tt,R,L,q,I,F,H,ie]),nn=n.useMemo(()=>(Array.isArray(j.columns)?j.columns:[]).flatMap(e=>{if(typeof e==`string`)return[{name:e,label:M(e,e)}];let n=(0,t.columnIdentity)(e);return n?[{name:n,label:M(n,e.label||n)}]:[]}),[j.columns,M]),rn=(0,s.resolveI18nLabel)(j.aria?.ariaLabel,oe);return(0,o.jsxs)(`div`,{ref:Nt,className:(0,r.cn)(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,c),...rn?{"aria-label":rn}:{},...j.aria?.ariaDescribedBy?{"aria-describedby":j.aria.ariaDescribedBy}:{},...j.aria?.live?{"aria-live":j.aria.live}:{},role:j.aria?.role??`region`,"aria-busy":V||void 0,"data-state":V?`loading`:`idle`,children:[Ft>0&&(0,o.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Ft},children:k(Pt?`list.refreshing`:`list.pullToRefresh`)}),j.description&&j.appearance?.showDescription!==!1&&(0,o.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof j.description==`string`?j.description:``}),(0,o.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,o.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:st&&(0,o.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,o.jsx)(ne,{config:st,objectDef:H,data:z,onFilterChange:ot,maxVisible:3,initialSelections:S,onSelectionsChange:C})})}),(0,o.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,"data-print-hide":!0,children:[O&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w,{currentView:P,availableViews:Ht,onViewChange:Ut}),(0,o.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),P===`grid`&&v&&!N.compactToolbar&&Dt&&(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>ht(!pt),className:(0,r.cn)(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,pt&&`text-primary`),title:k(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,o.jsx)(i.Pencil,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),N.showHideFields&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:dt,onOpenChange:ft,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,J.size>0&&`text-primary`),children:[(0,o.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.hideFields`)}),J.size>0&&(0,o.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:J.size})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.hideFieldsTitle`)}),J.size>0&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ut(new Set),children:k(`list.showAll`)})]}),(0,o.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:nn.map(e=>(0,o.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!J.has(e.name),onChange:()=>{let t=new Set(J);t.has(e.name)?t.delete(e.name):t.add(e.name),ut(t)},className:`rounded border-input`}),(0,o.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),N.showHideFields&&!N.compactToolbar&&(N.showFilters||N.showSort||N.showGroup)&&(0,o.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showFilters&&(0,o.jsxs)(r.Popover,{open:De,onOpenChange:Oe,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,Jt&&`text-foreground font-medium`),children:[(0,o.jsx)(i.SlidersHorizontal,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.filter`)}),Jt&&(0,o.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.conditions?.length||0})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.filterRecords`)})}),(0,o.jsx)(r.FilterBuilder,{fields:Xt,value:L,extraOperators:ce,onChange:e=>{ke(e),m&&m(e)}})]})})]}),N.showGroup&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:Ze,onOpenChange:Qe,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,G&&`text-foreground font-medium`),children:[(0,o.jsx)(i.Group,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.group`)}),G&&G.fields?.length>0&&(0,o.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:G.fields.length})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-72 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.groupBy`)}),G&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Xe(void 0),"data-testid":`clear-grouping`,children:k(`list.clear`)})]}),(0,o.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,o.jsx)(r.GroupingEditor,{value:G,fieldOptions:nn.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:k(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:k(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:k(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Xe(e)})})]})})]}),N.showSort&&(0,o.jsxs)(r.Popover,{open:xe,onOpenChange:Se,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,I.length>0&&`text-foreground font-medium`),children:[(0,o.jsx)(i.ArrowUpDown,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.sort`)}),I.length>0&&(0,o.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:I.length})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.sortRecords`)}),Te.length>0&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground hover:text-primary`,disabled:!Ee,onClick:en,"data-testid":`sort-reset-default`,children:k(`list.resetSortToDefault`)})]}),(0,o.jsx)(r.SortBuilder,{fields:Zt,value:I,onChange:e=>{Ce(e),h&&h(e)}}),Qt&&(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`sort-relational-hint`,children:k(`list.sortRelationalHint`)})]})})]}),!N.compactToolbar&&(N.showFilters||N.showSort||N.showGroup)&&(N.showColor||N.showDensity)&&(0,o.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showColor&&!N.compactToolbar&&(0,o.jsxs)(r.Popover,{open:tt,onOpenChange:nt,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.Paintbrush,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.color`)})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-64 p-3`,children:(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,o.jsx)(`h4`,{className:`font-medium text-sm`,children:k(`list.rowColor`)}),K&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>et(void 0),"data-testid":`clear-row-color`,children:k(`list.clear`)})]}),(0,o.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,o.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:k(`list.colorByField`)}),(0,o.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:K?.field||``,onChange:e=>{let t=e.target.value;et(t?{field:t,colors:K?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,o.jsx)(`option`,{value:``,children:k(`list.none`)}),nn.map(e=>(0,o.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),N.showDensity&&!N.compactToolbar&&P!==`gallery`&&(()=>{let e=Z.mode===`compact`?i.Rows4:Z.mode===`comfortable`?i.Rows3:i.Rows2,t=Z.mode===`compact`?k(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Z.mode===`comfortable`?k(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):k(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${k(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,a=k(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,o.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:a,children:(0,o.jsx)(e,{className:`h-3.5 w-3.5`})})})(),N.showDensity&&!N.compactToolbar&&P===`gallery`&&(()=>{let e=Q===`small`?i.Rows4:Q===`medium`?i.Rows3:i.Rows2,t=Q===`small`?k(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Q===`medium`?k(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):k(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${k(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,a=k(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,o.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:jt,title:a,children:(0,o.jsx)(e,{className:`h-3.5 w-3.5`})})})(),N.compactToolbar&&(N.showGroup||N.showColor||N.showDensity||N.showHideFields)&&(0,o.jsx)(ee,{t:k,allFields:nn,showGroup:N.showGroup,groupingConfig:G,setGroupingConfig:Xe,showColor:N.showColor,rowColorConfig:K,setRowColorConfig:et,showDensity:N.showDensity,density:Z,showHideFields:N.showHideFields,hiddenFields:J,updateHiddenFields:ut,showInlineEdit:P===`grid`&&Dt,inlineEdit:pt,setInlineEdit:ht}),(N.showColor||N.showDensity||N.compactToolbar)&&Y&&Tt&&X.length>0&&(0,o.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),N.showRefresh&&(0,o.jsx)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,onClick:()=>ze(e=>e+1),disabled:V,title:k(`list.refresh`),"aria-label":k(`list.refresh`),"data-testid":`refresh-button`,children:(0,o.jsx)(i.RotateCw,{className:(0,r.cn)(`h-3.5 w-3.5`,V&&`animate-spin`)})}),Y&&Tt&&X.length>0&&(0,o.jsxs)(r.Popover,{open:gt,onOpenChange:_t,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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,o.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.export`)})]})}),(0,o.jsx)(r.PopoverContent,{align:`start`,className:`w-48 p-2`,children:(0,o.jsxs)(`div`,{className:`space-y-1`,children:[X.map(e=>(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:vt,onClick:()=>tn(e),children:[vt?(0,o.jsx)(i.Loader2,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,o.jsx)(i.Download,{className:`h-3.5 w-3.5 mr-2`}),k(`list.exportAs`,{format:e.toUpperCase()})]},e)),bt&&(0,o.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:bt})]})})]}),j.sharing?.type&&(0,o.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: ${j.sharing.type}`,"data-testid":`share-button`,children:[(0,o.jsx)(i.Share2,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.share`)})]}),j.allowPrinting&&(()=>{let e=k(`common.printDialogHint`);return(0,o.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(),"aria-label":`${k(`list.print`)}: ${e}`,title:e,"data-testid":`print-button`,children:[(0,o.jsx)(i.Printer,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.print`)})]})})(),(()=>{let e=j.allowPrinting||!!j.sharing?.type||Y&&Tt&&X.length>0;return N.showSearch&&e?(0,o.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),N.showSearch&&(0,o.jsxs)(r.Popover,{open:ye,onOpenChange:be,children:[(0,o.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,o.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`,F?`px-2 text-foreground font-medium`:`w-7 p-0`),"data-testid":`search-icon-button`,title:F?`${k(`list.search`)}: ${F}`:k(`list.search`),children:[(0,o.jsx)(i.Search,{className:`h-3.5 w-3.5`}),F&&(0,o.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:F})]})}),(0,o.jsx)(r.PopoverContent,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,o.jsx)(r.Input,{placeholder:k(`table.search`),value:F,onChange:e=>Wt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),F&&(0,o.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:()=>Wt(``),children:(0,o.jsx)(i.X,{className:`h-3 w-3`})})]})})]}),N.showAddRecordTop&&(0,o.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,o.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.addRecord`)})]})]})]}),(0,o.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,o.jsx)(r.RefreshIndicator,{active:V&&z.length>0}),je&&z.length===0?(0,o.jsx)(r.DataEmptyState,{"data-testid":`list-error-state`,"data-error-kind":B,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:B===`network`?(0,o.jsx)(i.AlertTriangle,{className:`h-12 w-12 text-destructive/60`}):(0,o.jsx)(i.ShieldAlert,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:k(B===`api-disabled`?`list.loadErrorApiDisabledTitle`:B===`forbidden`?`list.loadErrorForbiddenTitle`:B===`unauthorized`?`list.loadErrorUnauthorizedTitle`:B===`rejected`?`list.loadErrorRejectedTitle`:`list.loadErrorTitle`),description:k(B===`api-disabled`?`list.loadErrorApiDisabledMessage`:B===`forbidden`?`list.loadErrorForbiddenMessage`:B===`unauthorized`?`list.loadErrorUnauthorizedMessage`:B===`rejected`?`list.loadErrorRejectedMessage`:`list.loadErrorMessage`),action:B===`api-disabled`?void 0:(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>ze(e=>e+1),children:[(0,o.jsx)(i.RotateCw,{className:`h-4 w-4 mr-1.5`}),k(`list.retry`)]})}):V&&z.length===0?(0,o.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,o.jsx)(`span`,{className:`sr-only`,children:k(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,o.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!V&&z.length===0&&P===`grid`?(()=>{let e=j.emptyState?.icon,t=e?i.icons[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??i.Inbox:i.Inbox,n=Array.isArray(j.filter)?j.filter.length>0:j.filter&&typeof j.filter==`object`?Object.keys(j.filter).length>0:!1,a=!!(F&&F.trim())||n||Array.isArray(q)&&q.length>0||Array.isArray(L?.conditions)&&L.conditions.length>0,s=(typeof j.emptyState?.title==`string`?j.emptyState.title:void 0)??k(a?`list.noMatches`:`list.firstRunTitle`),c=(typeof j.emptyState?.message==`string`?j.emptyState.message:void 0)??k(a?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,o.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,o.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:s,description:c,action:N.showAddRecord?(0,o.jsxs)(r.Button,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>D.onAddRecord?.(),children:[(0,o.jsx)(i.Plus,{className:`h-4 w-4 mr-1.5`}),k(`list.addRecord`)]}):void 0})})():(0,o.jsx)(l.SchemaRenderer,{schema:qt,...D,...zt?{}:{data:z},loading:V,onRowSelect:it,...P===`grid`&&!G?.fields?.length&&Ke!=null?{manualPagination:!0,rowCount:Ke,page:We,pageSize:U,onPageChange:e=>Ge(e),onPageSizeChange:e=>{Ue(e),Ge(1)},sort:I,onSortChange:$t,findParams:Je}:{}})]},P),N.showAddRecordBottom&&(0,o.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,o.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,o.jsx)(i.Plus,{className:`h-3.5 w-3.5 mr-1.5`}),(0,o.jsx)(`span`,{className:`hidden sm:inline`,children:k(`list.addRecord`)})]})}),Et&&Et.length>0&&rt.length>0&&P!==`grid`&&(0,o.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,o.jsx)(i.CheckSquare,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,o.jsxs)(`span`,{className:`font-medium`,children:[rt.length,` `,rt.length===1?`item`:`items`,` selected`]}),(0,o.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:Et.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),a=n?i.Trash2:null;return(0,o.jsxs)(r.Button,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>D.onBulkAction?.(e,rt),"data-testid":`bulk-action-${e}`,children:[a&&(0,o.jsx)(a,{className:`h-3 w-3`}),le(e)]},e)})}),(0,o.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>it([]),children:[(0,o.jsx)(i.X,{className:`h-3 w-3`}),`Clear`]})]}),!V&&z.length>0&&j.showRecordCount!==!1&&(0,o.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,o.jsx)(`span`,{className:`font-medium text-foreground/80`,children:(()=>{let e=Ke??z.length;return k(e===1?`list.recordCountOne`:`list.recordCount`,{count:e})})()}),Be&&(0,o.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:k(`list.dataLimitReached`,{limit:U})}),P!==`grid`&&j.pagination?.pageSizeOptions&&j.pagination.pageSizeOptions.length>0&&(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,o.jsx)(`span`,{children:k(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,o.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(U),onChange:e=>{let t=Number(e.target.value);Ue(t),D.onPageSizeChange&&D.onPageSizeChange(t)},children:j.pagination.pageSizeOptions.map(e=>(0,o.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Gt.isOverlay&&(0,o.jsx)(r.NavigationOverlay,{...Gt,title:Kt,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});ye.displayName=`ListView`;var be={columns:!0,filter:!0,sort:!0,limit:`pagination.pageSize`,viewType:!0},xe=n.default.forwardRef((e,r)=>{let i=(0,n.useContext)(l.SchemaRendererContext),a=((0,t.isElementDataSourceConfig)(e.dataSource)?void 0:e.dataSource)??i?.dataSource;return(0,o.jsx)(l.ElementDataSourceGate,{schema:e.schema,mapping:be,dataSource:a,testId:`list-view`,errorTitle:`This list view’s data source could not be resolved`,children:t=>(0,o.jsx)(ye,{ref:r,...e,schema:t,dataSource:a})})});xe.displayName=`ListViewBlock`;var Se={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]`},Ce=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),we=[{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 Te(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return we[Math.abs(t)%we.length]}var Ee=({imageUrl:e,title:t,coverFit:i,aspectClass:a,placeholder:s,hidden:c})=>{let[l,u]=(0,n.useState)(!1),d=!!e&&!l;return(0,o.jsx)(`div`,{className:(0,r.cn)(`w-full overflow-hidden relative`,a),hidden:c,children:d?i===`contain`?(0,o.jsx)(`div`,{className:(0,r.cn)(`flex h-full w-full items-center justify-center bg-gradient-to-br`,s.bg),children:(0,o.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,o.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,o.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,o.jsx)(`span`,{className:(0,r.cn)(`text-5xl font-semibold tracking-tight opacity-90`,s.text),children:t[0]?.toUpperCase()})})})},De=({imageUrl:e,title:t,placeholder:i})=>{let[a,s]=(0,n.useState)(!1),c=!!e&&!a;return(0,o.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,o.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,o.jsx)(`span`,{className:(0,r.cn)(`text-base font-semibold`,i.text),children:t[0]?.toUpperCase()})})},Oe=(e,t)=>{let n=e?.[t];if(n!=null&&n!==``)return(0,c.readFileValues)(n)[0]?.url},L=e=>{let{schema:a}=e,s=(0,n.useContext)(l.SchemaRendererContext),u=e.dataSource||s?.dataSource,d=(0,l.useDataScope)(a.bind),[f,p]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(null),v=(0,l.useNavigationOverlay)({navigation:a.navigation,objectName:a.objectName,onRowClick:e.onRowClick??e.onCardClick}),y=a.gallery,b=y?.coverField??a.imageField??`image`,x=y?.coverFit??`cover`,S=y?.cardSize??`medium`,C=y?.titleField??a.titleField,w=y?.visibleFields,{fieldLabel:T,fieldOptionLabel:E}=(0,l.useSafeFieldLabel)(),ee=(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(a.objectName){let t=String(n.label??e);n.label=T(a.objectName,e,t)}return a.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(a.objectName,e,n,r)}})),n},[g,a.objectName,T,E]);(0,n.useEffect)(()=>{let e=!0;return(async()=>{if(!(!u||typeof u.getObjectSchema!=`function`||!a.objectName))try{let t=await u.getObjectSchema(a.objectName);e&&_(t)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[a.objectName,u]),(0,n.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){p(e.data);return}return a.objectName&&!d&&!a.data&&!e.data&&(async()=>{if(!(!u||typeof u.find!=`function`||!a.objectName)){n&&h(!0);try{let e=(0,t.buildExpandFields)(g?.fields),r=await u.find(a.objectName,{$filter:a.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}},[a.objectName,u,d,a.data,a.filter,e.data,g]);let D=e.data||d||a.data||f||[],te=(0,n.useMemo)(()=>D.some(e=>!!Oe(e,b)),[D,b]),O=a.grouping?.fields,k=!!(O&&O.length>0),[ne,re]=(0,n.useState)({}),A=(0,n.useMemo)(()=>O?O.some(e=>e.collapsed):!1,[O]),ie=(0,n.useCallback)(e=>{re(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),ae=(0,n.useMemo)(()=>{if(!k||!O)return[];let e=new Map,t=[];for(let n of D){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 ne?ne[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[D,O,k,ne,A]);if(m&&!D.length)return(0,o.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!D.length)return(0,o.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let oe=e=>!w||w.length===0?null:(0,o.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=ee(t),a=(0,c.resolveCellRendererType)(i)||i.type||`text`,s=(0,c.getCellRenderer)(a),l=i?.label&&String(i.label).trim()?String(i.label):void 0,u=l!=null&&Ce.has(a);return(0,o.jsxs)(`div`,{className:(0,r.cn)(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,u&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[u&&(0,o.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:l}),(0,o.jsx)(s,{value:n,field:i})]},t)})}),j=(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=Oe(n,b),u=Te(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||a.navigation)&&`cursor-pointer`);return te&&x===`contain`?(0,o.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[(0,o.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,o.jsx)(r.CardContent,{className:`p-4`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,o.jsx)(De,{imageUrl:l,title:c,placeholder:u}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),oe(n)]})]})})]},s):(0,o.jsxs)(r.Card,{role:`listitem`,className:d,onClick:e=>v.handleClick(n,e),children:[!te&&(0,o.jsx)(`div`,{"aria-hidden":!0,className:(0,r.cn)(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,u.bg)}),(0,o.jsx)(Ee,{imageUrl:l,title:c,coverFit:x,aspectClass:I[S],placeholder:u,hidden:!te}),(0,o.jsxs)(r.CardContent,{className:(0,r.cn)(`p-3`,te&&`border-t border-border/60`),children:[(0,o.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:c,children:c}),oe(n)]})]},s)},se=e=>(0,o.jsx)(`div`,{className:(0,r.cn)(`grid gap-4 p-4 auto-rows-min content-start`,Se[S],a.className),role:`list`,children:e.map((e,t)=>j(e,t))});return(0,o.jsxs)(o.Fragment,{children:[k?(0,o.jsx)(`div`,{className:`space-y-2`,children:ae.map(e=>(0,o.jsxs)(`div`,{className:`border rounded-md`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>ie(e.key),children:[e.collapsed?(0,o.jsx)(i.ChevronRight,{className:`h-4 w-4 shrink-0`}):(0,o.jsx)(i.ChevronDown,{className:`h-4 w-4 shrink-0`}),(0,o.jsx)(`span`,{children:e.label}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&se(e.items)]},e.key))}):se(D),v.isOverlay&&(0,o.jsx)(r.NavigationOverlay,{...v,title:`Gallery Item`,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})};t.ComponentRegistry.register(`object-gallery`,L,{namespace:`plugin-list`,label:`Gallery View`,category:`view`});function ke(e){if(!e)return null;let t=e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return i.icons[t]??null}function R(e){return e.filter(e=>e.pinned||e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}function z(){let{language:e}=(0,a.useObjectTranslation)();return n.useCallback(t=>t?(0,a.pickLocalized)(t.label,e):``,[e])}var Ae=({tabs:e,activeTab:t,onTabChange:i,className:a})=>{let s=n.useMemo(()=>R(e),[e]),c=z(),l=n.useMemo(()=>s.find(e=>e.isDefault)?.name??s[0]?.name,[s]),[u,d]=n.useState(l),f=t??u,p=n.useCallback(e=>{d(e.name),i?.(e)},[i]);return s.length===0?null:(0,o.jsx)(`div`,{className:(0,r.cn)(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,a),"data-testid":`view-tabs`,role:`tablist`,children:s.map(e=>{let t=ke(e.icon),n=f===e.name;return(0,o.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:()=>p(e),children:[t&&(0,o.jsx)(t,{className:`h-3 w-3 mr-1.5`}),c(e)]},e.name)})})},je=({tabs:e,activeTab:t,onTabChange:a,className:s})=>{let c=n.useMemo(()=>R(e),[e]),l=z(),u=n.useMemo(()=>c.find(e=>e.isDefault)?.name??c[0]?.name,[c]),[d,f]=n.useState(u),p=t??d,m=n.useMemo(()=>c.find(e=>e.name===p)??c[0],[c,p]),h=n.useCallback(e=>{f(e.name),a?.(e)},[a]);if(c.length===0)return null;let g=ke(m?.icon);return(0,o.jsx)(`div`,{className:(0,r.cn)(`px-2 py-1`,s),"data-testid":`view-tabs-select`,children:(0,o.jsxs)(r.DropdownMenu,{children:[(0,o.jsx)(r.DropdownMenuTrigger,{asChild:!0,children:(0,o.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:[g&&(0,o.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`}),(0,o.jsx)(`span`,{className:`truncate`,children:l(m)}),(0,o.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,o.jsx)(r.DropdownMenuContent,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:c.map(e=>{let t=ke(e.icon),n=p===e.name;return(0,o.jsxs)(r.DropdownMenuItem,{onClick:()=>h(e),className:(0,r.cn)(`text-sm`,n&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,o.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,o.jsx)(`span`,{className:`truncate`,children:l(e)})]},e.name)})})]})})},Me=xe;t.ComponentRegistry.register(`list-view`,Me,{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:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,columns:[],filter:[],sort:[],options:{}}}),t.ComponentRegistry.register(`list`,Me,{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:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]}),e.LIST_DEFAULT_TRANSLATIONS=ge,e.ListView=ye,e.ListViewBlock=xe,e.ObjectGallery=L,e.TabBar=Ae,e.TabBarSelect=je,e.UserFilters=ne,e.ViewSwitcher=T,e.ViewSwitcherDropdown=w,e.evaluateConditionalFormatting=F,e.normalizeFilterCondition=N,e.normalizeFilters=P});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-list",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.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,23 +24,23 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"lucide-react": "^1.
|
|
27
|
+
"lucide-react": "^1.31.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@objectstack/spec": "^17.0.0
|
|
30
|
+
"@objectstack/spec": "^17.0.0",
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
32
32
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
33
|
-
"@object-ui/components": "^17.
|
|
34
|
-
"@object-ui/core": "^17.
|
|
35
|
-
"@object-ui/fields": "^17.
|
|
36
|
-
"@object-ui/i18n": "^17.
|
|
37
|
-
"@object-ui/mobile": "^17.
|
|
38
|
-
"@object-ui/permissions": "^17.
|
|
39
|
-
"@object-ui/react": "^17.
|
|
40
|
-
"@object-ui/types": "^17.
|
|
33
|
+
"@object-ui/components": "^17.6.0",
|
|
34
|
+
"@object-ui/core": "^17.6.0",
|
|
35
|
+
"@object-ui/fields": "^17.6.0",
|
|
36
|
+
"@object-ui/i18n": "^17.6.0",
|
|
37
|
+
"@object-ui/mobile": "^17.6.0",
|
|
38
|
+
"@object-ui/permissions": "^17.6.0",
|
|
39
|
+
"@object-ui/react": "^17.6.0",
|
|
40
|
+
"@object-ui/types": "^17.6.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@objectstack/spec": "^17.0.0
|
|
43
|
+
"@objectstack/spec": "^17.0.0",
|
|
44
44
|
"@types/react": "19.2.18",
|
|
45
45
|
"@types/react-dom": "19.2.4",
|
|
46
46
|
"@vitejs/plugin-react": "^6.0.5",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"vite": "^8.2.1",
|
|
49
49
|
"vite-plugin-dts": "^5.0.3",
|
|
50
50
|
"vitest": "^4.1.10",
|
|
51
|
-
"@object-ui/components": "17.
|
|
52
|
-
"@object-ui/core": "17.
|
|
53
|
-
"@object-ui/fields": "17.
|
|
54
|
-
"@object-ui/i18n": "17.
|
|
55
|
-
"@object-ui/mobile": "17.
|
|
56
|
-
"@object-ui/permissions": "17.
|
|
57
|
-
"@object-ui/react": "17.
|
|
58
|
-
"@object-ui/types": "17.
|
|
51
|
+
"@object-ui/components": "17.6.0",
|
|
52
|
+
"@object-ui/core": "17.6.0",
|
|
53
|
+
"@object-ui/fields": "17.6.0",
|
|
54
|
+
"@object-ui/i18n": "17.6.0",
|
|
55
|
+
"@object-ui/mobile": "17.6.0",
|
|
56
|
+
"@object-ui/permissions": "17.6.0",
|
|
57
|
+
"@object-ui/react": "17.6.0",
|
|
58
|
+
"@object-ui/types": "17.6.0"
|
|
59
59
|
},
|
|
60
60
|
"keywords": [
|
|
61
61
|
"objectui",
|