import{I as f}from"./iconify-p99pbjf9.js";import{d as M,g as y,A as v,J as l,j as o,t as i,B as r,C as O,P as C,aH as k,c as p}from"./index-DOFLUERq.js";import{_ as x}from"./_plugin-vue_export-helper-DlAUqK2U.js";const B={class:"sort-selector"},w={class:"sort-controls"},D=["title"],T={class:"sort-field-btn"},I={class:"sort-field-text"},L=M({__name:"default_list_sort_selector",props:{sortBy:{default:"modified"},sortOrder:{default:"desc"},options:{default:void 0},pageMeta:{default:void 0}},emits:["update:sortBy","update:sortOrder","change"],setup(d,{emit:m}){const t=d,s=m,c=p(()=>{if(t.options&&t.options.length>0)return t.options.map(e=>({label:i(e.label),key:e.fieldname}));const a=[{fieldname:"modified",label:"Modified"},{fieldname:"name",label:"ID"},{fieldname:"creation",label:"Created"},{fieldname:"idx",label:"Most Used"}];if(t.pageMeta?.title_field&&t.pageMeta.title_field!=="name"){const e=t.pageMeta.title_field.charAt(0).toUpperCase()+t.pageMeta.title_field.slice(1);a.splice(1,0,{fieldname:t.pageMeta.title_field,label:e})}if(t.pageMeta?.sort_field&&t.pageMeta.sort_field!=="modified"){const e=t.pageMeta.sort_field.charAt(0).toUpperCase()+t.pageMeta.sort_field.slice(1);a.splice(1,0,{fieldname:t.pageMeta.sort_field,label:e})}return t.pageMeta?.fields&&t.pageMeta.fields.forEach(e=>{(e.in_list_view||e.mandatory||e.bold||e.reqd)&&u(e.fieldtype)&&!a.find(b=>b.fieldname===e.fieldname)&&a.push({fieldname:e.fieldname,label:e.label||e.fieldname})}),Array.from(new Map(a.map(e=>[e.fieldname,e])).values()).map(e=>({label:i(e.label),key:e.fieldname}))});function u(a){return["Data","Text","Small Text","Long Text","Link","Dynamic Link","Date","Datetime","Time","Check","Select","Int","Float","Currency","Percent","Duration","Rating","Code","Text Editor","HTML Editor","Markdown Editor","Barcode","Geolocation","Color","Icon","Attach Image"].includes(a)}const _=p(()=>c.value.find(n=>n.key===t.sortBy)?.label||i("Modified"));function g(){const a=t.sortOrder==="desc"?"asc":"desc";s("update:sortOrder",a),s("change",t.sortBy,a)}function h(a){s("update:sortBy",a),s("change",a,t.sortOrder)}return(a,n)=>(y(),v("div",B,[l("div",w,[l("button",{class:"sort-order-btn",title:d.sortOrder==="desc"?o(i)("Descending"):o(i)("Ascending"),onClick:g},[r(o(f),{icon:d.sortOrder==="desc"?"mdi:sort-descending":"mdi:sort-ascending",width:16,height:16},null,8,["icon"])],8,D),r(o(k),{options:c.value,onSelect:h,trigger:"click",placement:"bottom-end"},{default:O(()=>[l("button",T,[l("span",I,C(_.value),1),r(o(f),{icon:"mdi:chevron-down",width:16,height:16})])]),_:1},8,["options"])])]))}}),F=x(L,[["__scopeId","data-v-d6bf51cf"]]);export{F as default};
