@robot-admin/naive-ui-components 0.31.3 → 0.31.4

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/README_EN.md +1 -1
  4. package/dist/C_Chat.css +28 -28
  5. package/dist/C_Chat2.cjs +1 -1
  6. package/dist/C_Chat2.js +1 -1
  7. package/dist/C_FilePreview.css +49 -49
  8. package/dist/C_FilePreview2.cjs +1 -1
  9. package/dist/C_FilePreview2.js +1 -1
  10. package/dist/C_FormModal.css +1 -1
  11. package/dist/C_FormModal2.cjs +1 -1
  12. package/dist/C_FormModal2.js +1 -1
  13. package/dist/C_FormSearch.css +71 -71
  14. package/dist/C_GlobalSearch.css +125 -125
  15. package/dist/C_GlobalSearch2.cjs +1 -1
  16. package/dist/C_GlobalSearch2.js +1 -1
  17. package/dist/C_Table.base.css +109 -109
  18. package/dist/C_Table.css +109 -109
  19. package/dist/C_Table2.cjs +3 -3
  20. package/dist/C_Table2.js +3 -3
  21. package/dist/C_Time.css +4 -4
  22. package/dist/C_Time2.cjs +1 -1
  23. package/dist/C_Time2.js +1 -1
  24. package/dist/C_Transfer.css +3 -3
  25. package/dist/C_Transfer2.cjs +1 -1
  26. package/dist/C_Transfer2.js +1 -1
  27. package/dist/C_Tree2.cjs +1 -1
  28. package/dist/C_Tree2.js +1 -1
  29. package/dist/C_Upload.css +28 -28
  30. package/dist/C_Upload2.cjs +1 -1
  31. package/dist/C_Upload2.js +1 -1
  32. package/dist/constants.d.cts +1 -1
  33. package/dist/constants.d.ts +1 -1
  34. package/dist/constants3.d.cts +2 -2
  35. package/dist/constants3.d.ts +2 -2
  36. package/dist/constants4.d.cts +7 -7
  37. package/dist/constants4.d.ts +7 -7
  38. package/dist/constants5.d.cts +2 -2
  39. package/dist/constants5.d.ts +2 -2
  40. package/dist/data2.d.cts +3 -3
  41. package/dist/data2.d.ts +3 -3
  42. package/dist/formField.d.cts +1 -1
  43. package/dist/formField.d.ts +1 -1
  44. package/dist/index.vue.d.cts +2 -2
  45. package/dist/index.vue.d.ts +2 -2
  46. package/dist/index10.vue.d.cts +1 -1
  47. package/dist/index10.vue.d.ts +1 -1
  48. package/dist/index11.vue.d.cts +1 -1
  49. package/dist/index12.vue.d.ts +3 -3
  50. package/dist/index13.vue.d.cts +3 -3
  51. package/dist/index15.vue.d.ts +3 -3
  52. package/dist/index16.vue.d.cts +3 -3
  53. package/dist/index16.vue.d.ts +8 -8
  54. package/dist/index17.vue.d.cts +8 -8
  55. package/dist/index17.vue.d.ts +1 -1
  56. package/dist/index18.vue.d.cts +1 -1
  57. package/dist/index18.vue.d.ts +1 -1
  58. package/dist/index19.vue.d.cts +1 -1
  59. package/dist/index2.vue.d.cts +2 -2
  60. package/dist/index2.vue.d.ts +2 -2
  61. package/dist/index20.vue.d.ts +2 -2
  62. package/dist/index21.vue.d.cts +2 -2
  63. package/dist/index21.vue.d.ts +2 -2
  64. package/dist/index22.vue.d.cts +1 -1
  65. package/dist/index22.vue.d.ts +1 -1
  66. package/dist/index23.vue.d.cts +3 -3
  67. package/dist/index23.vue.d.ts +3 -3
  68. package/dist/index26.vue.d.cts +1 -1
  69. package/dist/index26.vue.d.ts +1 -1
  70. package/dist/index27.vue.d.cts +3 -3
  71. package/dist/index27.vue.d.ts +3 -3
  72. package/dist/index29.vue.d.cts +1 -1
  73. package/dist/index29.vue.d.ts +1 -1
  74. package/dist/index3.vue.d.cts +5 -5
  75. package/dist/index3.vue.d.ts +5 -5
  76. package/dist/index30.vue.d.cts +1 -1
  77. package/dist/index30.vue.d.ts +1 -1
  78. package/dist/index31.vue.d.cts +2 -2
  79. package/dist/index31.vue.d.ts +2 -2
  80. package/dist/index5.vue.d.cts +2 -2
  81. package/dist/index7.vue.d.ts +2 -2
  82. package/dist/index8.vue.d.cts +2 -2
  83. package/dist/index9.vue.d.ts +1 -1
  84. package/dist/mapUtils.d.cts +3 -3
  85. package/dist/mapUtils.d.ts +3 -3
  86. package/dist/presets.d.cts +1 -1
  87. package/dist/presets.d.ts +1 -1
  88. package/dist/serializeSearch.cjs +1 -1
  89. package/dist/serializeSearch.js +1 -1
  90. package/dist/style.css +419 -419
  91. package/dist/useCalendarEvents.d.cts +1 -1
  92. package/dist/useCalendarEvents.d.ts +1 -1
  93. package/dist/useCollapsePanel.d.cts +1 -1
  94. package/dist/useCollapsePanel.d.ts +1 -1
  95. package/dist/useCropperCore.d.cts +6 -6
  96. package/dist/useCropperCore.d.ts +6 -6
  97. package/dist/useDynamicFormState.d.cts +2 -2
  98. package/dist/useDynamicFormState.d.ts +2 -2
  99. package/dist/useEdgeInteraction.d.cts +1 -1
  100. package/dist/useEdgeInteraction.d.ts +1 -1
  101. package/dist/useFullscreen.d.cts +1 -1
  102. package/dist/useFullscreen.d.ts +1 -1
  103. package/dist/useQRCode.d.cts +4 -4
  104. package/dist/useQRCode.d.ts +4 -4
  105. package/dist/useSignatureHistory.d.cts +4 -4
  106. package/dist/useSignatureHistory.d.ts +4 -4
  107. package/dist/useSplitResize.d.cts +6 -6
  108. package/dist/useSplitResize.d.ts +6 -6
  109. package/dist/useTableQuery.d.cts +3 -3
  110. package/dist/useTableQuery.d.ts +3 -3
  111. package/dist/useTimeSelection.d.cts +6 -3
  112. package/dist/useTimeSelection.d.ts +6 -3
  113. package/dist/useWorkflowValidation.d.cts +32 -32
  114. package/dist/useWorkflowValidation.d.ts +32 -32
  115. package/dist/verification.d.cts +5 -5
  116. package/dist/verification.d.ts +5 -5
  117. package/dist/virtualList.cjs +1 -0
  118. package/dist/virtualList.js +1 -0
  119. package/docs/guides/tree.md +2 -2
  120. package/docs/guides/usage.en.md +2 -0
  121. package/docs/guides/usage.md +3 -1
  122. package/package.json +1 -1
@@ -1 +1 @@
1
- require(`./chunk.cjs`);const e=require(`./export-helper.cjs`);let t=require(`vue`),n=require(`vueuc`);const r=e=>e.replace(/^\//,``).replace(/\//g,` > `)||`首页`;function i(e){let t=new Map,n=new Map;return{entries:e.map(e=>{let{key:i}=e,a=r(i);return t.set(i,a),n.set(i,e),{item:e,label:e.label.toLowerCase(),path:a.toLowerCase()}}),paths:t,byKey:n}}function a(e,t){if(!t.trim())return[];let n=t.toLowerCase();return e.entries.filter(e=>e.label.includes(n)||e.path.includes(n)).map(e=>e.item)}function o(e){let t=typeof e==`string`?{query:e}:e;if(!t||typeof t!=`object`)return[];let{query:n,menuKey:r,menuItem:i,timestamp:a}=t,o=typeof r==`string`?r:i?.key,s=Number.isFinite(a)?a:0;return typeof o==`string`?[{menuKey:o,timestamp:s}]:typeof n!=`string`||!n.trim()?[]:[{query:n.slice(0,200),menuKey:null,timestamp:s}]}function s(e){let n=()=>(0,t.toValue)(e),s=()=>n().menuItems(),c=(0,t.computed)(()=>n().storageKey??`robot-search-history`),l=(0,t.computed)(()=>Math.min(100,Math.max(0,Math.trunc(n().maxHistory??10)))),ee=(0,t.computed)(()=>Math.min(l.value,Math.max(0,Math.trunc(n().maxDisplayHistory??5)))),u=(0,t.ref)(!1),d=(0,t.ref)(``),f=(0,t.ref)(0),p=(0,t.ref)(),m=(0,t.ref)([]),h=(0,t.ref)(!1),g=(0,t.computed)(()=>n().isDark?.()??!1),_=(0,t.computed)(()=>i(s())),v=(0,t.computed)(()=>d.value.trim()?a(_.value,d.value):[]),y=(0,t.computed)(()=>{let e=[];for(let[t,n]of m.value.entries()){if(e.length>=ee.value)break;let{menuKey:r,query:i,timestamp:a}=n,o=r===null?null:_.value.byKey.get(r),s=o?.label??i;o===void 0||s===void 0||e.push({item:{query:s,menuItem:o,timestamp:a},sourceIndex:t})}return e}),b=(0,t.computed)(()=>y.value.map(({item:e})=>e)),x=(0,t.computed)(()=>v.value.length>0),S=(0,t.computed)(()=>!!d.value.trim()||b.value.length>0),C=(0,t.computed)(()=>d.value.trim()?v.value.length:b.value.length),te=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":f.value===e}],w=(e,t)=>{if(!t)return[{text:e,matched:!1}];let n=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return e.split(n).filter(Boolean).map(e=>({text:e,matched:e.toLocaleLowerCase()===t.toLocaleLowerCase()}))},T=e=>_.value.paths.get(e)??r(e),E=()=>{if(!(typeof localStorage>`u`))try{localStorage.setItem(c.value,JSON.stringify(m.value))}catch{}},D=e=>{if(!e.label.trim())return;let t=m.value.filter(t=>t.menuKey!==e.key);m.value=[{menuKey:e.key,timestamp:Date.now()},...t].slice(0,l.value),E()},O=()=>{if(m.value=[],!(typeof localStorage>`u`))try{let e=localStorage.getItem(c.value);if(e){let t=JSON.parse(e);if(!Array.isArray(t))return;m.value=t.flatMap(o).slice(0,l.value)}}catch{m.value=[]}},k=()=>{if(m.value=[],!(typeof localStorage>`u`))try{localStorage.removeItem(c.value)}catch{}},A=e=>{let t=y.value[e];t&&(m.value.splice(t.sourceIndex,1),E(),f.value=Math.max(0,Math.min(f.value,b.value.length-1)))},j=async()=>{u.value=!0,d.value=``,f.value=0,h.value=!1,await(0,t.nextTick)(),p.value?.focus()},M=()=>{u.value=!1,d.value=``,f.value=0,h.value=!1},N=e=>{if(e.menuItem){let t=_.value.byKey.get(e.menuItem.key);if(!t)return;n().onSelect?.(t.key,!!t.children?.length),M()}else d.value=e.query,f.value=0},P=e=>{let t=_.value.byKey.get(e.key);t&&(D(t),n().onSelect?.(t.key,!!t.children?.length),M())},F=e=>h.value||!!(e&&(e.defaultPrevented||e.isComposing||e.keyCode===229||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)),I=e=>{if(F(e))return;f.value=Math.max(0,Math.min(f.value,C.value-1));let t=!d.value.trim()&&b.value.length>0,n=d.value.trim()&&v.value.length>0;if(t){let t=b.value[f.value];t&&(e?.preventDefault(),N(t))}else if(n){let t=v.value[f.value];t&&(e?.preventDefault(),P(t))}},L=e=>{F(e)||(e?.preventDefault(),f.value=Math.max(0,Math.min(f.value+1,C.value-1)))},R=e=>{F(e)||(e?.preventDefault(),f.value=Math.max(0,Math.min(f.value-1,C.value-1)))},z=e=>{e.key!==`Escape`||F(e)||(e.preventDefault(),M())},B=e=>{e.key===`ArrowDown`?L(e):e.key===`ArrowUp`?R(e):e.key===`Enter`?I(e):z(e)};(0,t.watch)(d,()=>{f.value=0}),(0,t.watch)(C,e=>{f.value=Math.max(0,Math.min(f.value,e-1))}),(0,t.watch)(c,O);let V=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||h.value||(e.ctrlKey||e.metaKey)&&e.key===`k`&&(e.preventDefault(),j())};return(0,t.onMounted)(()=>{O(),document.addEventListener(`keydown`,V)}),(0,t.onUnmounted)(()=>document.removeEventListener(`keydown`,V)),{showDialog:u,searchValue:d,selectedIndex:f,searchInputRef:p,isDark:g,filteredMenuItems:v,displayHistory:b,hasResults:x,hasContent:S,getItemClasses:te,highlightMatch:w,formatMenuPath:T,clearHistory:k,removeHistoryItem:A,openDialog:j,closeDialog:M,selectHistoryItem:N,selectItem:P,handleEnter:I,focusNext:L,focusPrev:R,handleInputKeydown:B,handleDialogKeydown:z,handleCompositionStart:()=>{h.value=!0},handleCompositionEnd:()=>{h.value=!1}}}const c={class:`robot-search-palette`},l={class:`robot-search-header`},ee=[`placeholder`,`aria-expanded`,`aria-activedescendant`],u={key:0,class:`robot-empty-state`},d={class:`robot-search-results`},f={class:`robot-result-group`},p={class:`robot-group-title`},m={class:`robot-group-count`},h=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],g={key:1,class:`robot-item-icon robot-default-icon`},_={class:`robot-item-content`},v={class:`robot-item-label`},y={class:`robot-item-desc`},b=[`onClick`],x={class:`robot-search-results`},S={key:0,class:`robot-empty-state`},C={class:`robot-result-group`},te={class:`robot-group-title`},w={class:`robot-group-count`},T=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],E={key:1,class:`robot-item-icon robot-default-icon`},D={class:`robot-item-content`},O={class:`robot-item-label`},k={key:0,class:`robot-highlight`},A={class:`robot-item-desc`},j={key:2,class:`robot-item-badge`},M={class:`robot-search-footer`},N={key:0,class:`robot-footer-info`},P={key:0},F={key:1},I=(0,t.defineComponent)({name:`C_GlobalSearch`,__name:`index`,props:{options:{},placeholder:{default:`搜索导航菜单...`},emptyText:{default:`输入关键词搜索菜单`},resultGroupTitle:{default:`菜单导航`}},setup(e,{expose:r}){let i=e,{showDialog:a,searchValue:o,selectedIndex:I,searchInputRef:L,isDark:R,filteredMenuItems:z,displayHistory:B,hasResults:V,hasContent:H,getItemClasses:U,highlightMatch:ne,formatMenuPath:W,clearHistory:G,removeHistoryItem:re,openDialog:K,closeDialog:q,selectHistoryItem:ie,selectItem:ae,handleInputKeydown:oe,handleDialogKeydown:J,handleCompositionStart:Y,handleCompositionEnd:X}=s(()=>i.options),Z=`robot-search-options-${(0,t.useId)()}`,Q=e=>`${Z}-${e}`,se=(0,t.computed)(()=>(o.value.trim()?z.value.length:B.value.length)>0?Q(I.value):void 0),ce=(0,t.ref)(),le=(0,t.ref)(),$=!1,ue=async()=>{$||($=!0,await(0,t.nextTick)(),$=!1,a.value&&(o.value.trim()?z.value.length&&ce.value?.scrollTo({index:I.value}):le.value?.querySelector(`[data-option-index="${I.value}"]`)?.scrollIntoView({block:`nearest`})))},de=e=>{let t=e.defaultPrevented;oe(e),!t&&e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&ue()};return(0,t.watch)([I,z,B,a],ue,{flush:`post`}),r({openDialog:K,closeDialog:q}),(r,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,c,[(0,t.createCommentVNode)(` 搜索触发按钮 `),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`robot-search-trigger`,{"trigger-dark":(0,t.unref)(R)}]),onClick:i[0]||=(...e)=>(0,t.unref)(K)&&(0,t.unref)(K)(...e)},[...i[9]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:search robot-trigger-icon`},null,-1),(0,t.createElementVNode)(`span`,{class:`robot-trigger-text`},`搜索`,-1),(0,t.createElementVNode)(`span`,{class:`robot-trigger-shortcut`},`Ctrl K`,-1)]],2),(0,t.createCommentVNode)(` 搜索对话框 `),((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:`body`},[(0,t.createVNode)(t.Transition,{name:`robot-dialog`},{default:(0,t.withCtx)(()=>[(0,t.unref)(a)?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,class:`robot-dialog-overlay`,onClick:i[7]||=(...e)=>(0,t.unref)(q)&&(0,t.unref)(q)(...e),onKeydown:i[8]||=(...e)=>(0,t.unref)(J)&&(0,t.unref)(J)(...e)},[(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`robot-dialog-container`,{"dialog-dark":(0,t.unref)(R)}]),role:`dialog`,"aria-modal":`true`,"aria-label":`全局搜索`,onClick:i[6]||=(0,t.withModifiers)(()=>{},[`stop`])},[(0,t.createCommentVNode)(` 搜索头部 `),(0,t.createElementVNode)(`div`,l,[i[11]||=(0,t.createElementVNode)(`div`,{class:`i-mdi:magnify robot-search-icon`},null,-1),(0,t.withDirectives)((0,t.createElementVNode)(`input`,{ref_key:`searchInputRef`,ref:L,"onUpdate:modelValue":i[1]||=e=>(0,t.isRef)(o)?o.value=e:null,type:`text`,placeholder:e.placeholder,class:`robot-search-input`,role:`combobox`,"aria-label":`搜索菜单`,"aria-autocomplete":`list`,"aria-expanded":(0,t.unref)(a),"aria-controls":Z,"aria-activedescendant":se.value,onKeydown:de,onCompositionstart:i[2]||=(...e)=>(0,t.unref)(Y)&&(0,t.unref)(Y)(...e),onCompositionend:i[3]||=(...e)=>(0,t.unref)(X)&&(0,t.unref)(X)(...e)},null,40,ee),[[t.vModelText,(0,t.unref)(o)]]),(0,t.createElementVNode)(`button`,{class:`robot-close-btn`,"aria-label":`关闭搜索`,onClick:i[4]||=(...e)=>(0,t.unref)(q)&&(0,t.unref)(q)(...e)},[...i[10]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:close`},null,-1)]])]),(0,t.createCommentVNode)(` 搜索内容 `),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`robot-search-content`,{"robot-search-content--virtual":(0,t.unref)(o).trim()&&(0,t.unref)(V)}])},[(0,t.createCommentVNode)(` 空状态 `),(0,t.unref)(H)?!(0,t.unref)(o).trim()&&(0,t.unref)(B).length>0?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 搜索历史 `),(0,t.createElementVNode)(`div`,d,[(0,t.createElementVNode)(`div`,f,[(0,t.createElementVNode)(`div`,p,[i[14]||=(0,t.createElementVNode)(`div`,{class:`i-mdi:clock-time-four-outline robot-group-icon`},null,-1),i[15]||=(0,t.createTextVNode)(` 最近搜索 `,-1),(0,t.createElementVNode)(`span`,m,(0,t.toDisplayString)((0,t.unref)(B).length),1),(0,t.createElementVNode)(`button`,{class:`robot-clear-history`,onClick:i[5]||=(...e)=>(0,t.unref)(G)&&(0,t.unref)(G)(...e),title:`清空历史`},[...i[13]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:delete-outline`},null,-1)]])]),(0,t.createElementVNode)(`div`,{id:Z,ref_key:`historyItemsRef`,ref:le,class:`robot-group-items`,role:`listbox`,"aria-label":`最近搜索`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)((0,t.unref)(B),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:`history-${n}`,id:Q(n),class:(0,t.normalizeClass)((0,t.unref)(U)(n,!0)),role:`option`,"aria-selected":(0,t.unref)(I)===n,"data-option-index":n,onClick:n=>(0,t.unref)(ie)(e),onMouseenter:e=>I.value=n},[e.menuItem?.icon?((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.menuItem.icon),{key:0,class:`robot-item-icon`})):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,g,[...i[16]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,t.createElementVNode)(`div`,_,[(0,t.createElementVNode)(`div`,v,(0,t.toDisplayString)(e.query),1),(0,t.createElementVNode)(`div`,y,(0,t.toDisplayString)((0,t.unref)(W)(e.menuItem?.key||``)),1)]),(0,t.createElementVNode)(`button`,{class:`robot-history-delete`,onClick:(0,t.withModifiers)(e=>(0,t.unref)(re)(n),[`stop`]),title:`删除此记录`},[...i[17]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:close`},null,-1)]],8,b)],42,h))),128))],512)])])],64)):(0,t.unref)(o).trim()?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 搜索结果 `),(0,t.createElementVNode)(`div`,x,[(0,t.createCommentVNode)(` 无结果状态 `),(0,t.unref)(V)?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 搜索结果列表 `),(0,t.createElementVNode)(`div`,C,[(0,t.createElementVNode)(`div`,te,[i[19]||=(0,t.createElementVNode)(`div`,{class:`i-mdi:menu robot-group-icon`},null,-1),(0,t.createTextVNode)(` `+(0,t.toDisplayString)(e.resultGroupTitle)+` `,1),(0,t.createElementVNode)(`span`,w,(0,t.toDisplayString)((0,t.unref)(z).length),1)]),(0,t.createVNode)((0,t.unref)(n.VVirtualList),{id:Z,ref_key:`resultListRef`,ref:ce,class:`robot-group-items robot-virtual-items`,role:`listbox`,"aria-label":e.resultGroupTitle,items:(0,t.unref)(z),"item-size":64,style:(0,t.normalizeStyle)({height:`${Math.min((0,t.unref)(z).length*64,336)}px`})},{default:(0,t.withCtx)(({item:e,index:n})=>[(0,t.createElementVNode)(`div`,{id:Q(n),class:(0,t.normalizeClass)((0,t.unref)(U)(n,!1)),role:`option`,"aria-selected":(0,t.unref)(I)===n,"aria-posinset":n+1,"aria-setsize":(0,t.unref)(z).length,title:`${e.label} · ${(0,t.unref)(W)(e.key)}`,onClick:n=>(0,t.unref)(ae)(e),onMouseenter:e=>I.value=n},[e.icon?((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.icon),{key:0,class:`robot-item-icon`})):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,E,[...i[20]||=[(0,t.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,t.createElementVNode)(`div`,D,[(0,t.createElementVNode)(`div`,O,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)((0,t.unref)(ne)(e.label,(0,t.unref)(o)),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:n},[e.matched?((0,t.openBlock)(),(0,t.createElementBlock)(`mark`,k,(0,t.toDisplayString)(e.text),1)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createTextVNode)((0,t.toDisplayString)(e.text),1)],64))],64))),128))]),(0,t.createElementVNode)(`div`,A,(0,t.toDisplayString)((0,t.unref)(W)(e.key)),1)]),e.children?.length?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,j,(0,t.toDisplayString)(e.children.length),1)):(0,t.createCommentVNode)(`v-if`,!0)],42,T)]),_:1},8,[`aria-label`,`items`,`style`])])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,S,[i[18]||=(0,t.createElementVNode)(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),(0,t.createElementVNode)(`p`,null,`未找到 "`+(0,t.toDisplayString)((0,t.unref)(o))+`" 相关内容`,1)]))])],64)):(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,u,[i[12]||=(0,t.createElementVNode)(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),(0,t.createElementVNode)(`p`,null,(0,t.toDisplayString)(e.emptyText),1)]))],2),(0,t.createCommentVNode)(` 搜索底部 `),(0,t.createElementVNode)(`div`,M,[i[21]||=(0,t.createElementVNode)(`div`,{class:`robot-footer-actions`},[(0,t.createElementVNode)(`div`,{class:`robot-action-item`},[(0,t.createElementVNode)(`kbd`,null,`↵`),(0,t.createElementVNode)(`span`,null,`选择`)]),(0,t.createElementVNode)(`div`,{class:`robot-action-item`},[(0,t.createElementVNode)(`kbd`,null,`↑↓`),(0,t.createElementVNode)(`span`,null,`导航`)]),(0,t.createElementVNode)(`div`,{class:`robot-action-item`},[(0,t.createElementVNode)(`kbd`,null,`esc`),(0,t.createElementVNode)(`span`,null,`关闭`)])],-1),(0,t.unref)(H)?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,N,[(0,t.unref)(o).trim()&&(0,t.unref)(V)?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,P,` 共 `+(0,t.toDisplayString)((0,t.unref)(z).length)+` 项结果 `,1)):!(0,t.unref)(o).trim()&&(0,t.unref)(B).length>0?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,F,(0,t.toDisplayString)((0,t.unref)(B).length)+` 条历史记录 `,1)):(0,t.createCommentVNode)(`v-if`,!0)])):(0,t.createCommentVNode)(`v-if`,!0)])],2)],32)):(0,t.createCommentVNode)(`v-if`,!0)]),_:1})]))]))}});var L=e.t(I,[[`__scopeId`,`data-v-4002af54`]]);Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}});
1
+ require(`./chunk.cjs`);const e=require(`./export-helper.cjs`),t=require(`./virtualList.cjs`);let n=require(`vue`);const r=e=>e.replace(/^\//,``).replace(/\//g,` > `)||`首页`;function i(e){let t=new Map,n=new Map;return{entries:e.map(e=>{let{key:i}=e,a=r(i);return t.set(i,a),n.set(i,e),{item:e,label:e.label.toLowerCase(),path:a.toLowerCase()}}),paths:t,byKey:n}}function a(e,t){if(!t.trim())return[];let n=t.toLowerCase();return e.entries.filter(e=>e.label.includes(n)||e.path.includes(n)).map(e=>e.item)}function o(e){let t=typeof e==`string`?{query:e}:e;if(!t||typeof t!=`object`)return[];let{query:n,menuKey:r,menuItem:i,timestamp:a}=t,o=typeof r==`string`?r:i?.key,s=Number.isFinite(a)?a:0;return typeof o==`string`?[{menuKey:o,timestamp:s}]:typeof n!=`string`||!n.trim()?[]:[{query:n.slice(0,200),menuKey:null,timestamp:s}]}function s(e){let t=()=>(0,n.toValue)(e),s=()=>t().menuItems(),c=(0,n.computed)(()=>t().storageKey??`robot-search-history`),l=(0,n.computed)(()=>Math.min(100,Math.max(0,Math.trunc(t().maxHistory??10)))),ee=(0,n.computed)(()=>Math.min(l.value,Math.max(0,Math.trunc(t().maxDisplayHistory??5)))),u=(0,n.ref)(!1),d=(0,n.ref)(``),f=(0,n.ref)(0),p=(0,n.ref)(),m=(0,n.ref)([]),h=(0,n.ref)(!1),g=(0,n.computed)(()=>t().isDark?.()??!1),_=(0,n.computed)(()=>i(s())),v=(0,n.computed)(()=>d.value.trim()?a(_.value,d.value):[]),y=(0,n.computed)(()=>{let e=[];for(let[t,n]of m.value.entries()){if(e.length>=ee.value)break;let{menuKey:r,query:i,timestamp:a}=n,o=r===null?null:_.value.byKey.get(r),s=o?.label??i;o===void 0||s===void 0||e.push({item:{query:s,menuItem:o,timestamp:a},sourceIndex:t})}return e}),b=(0,n.computed)(()=>y.value.map(({item:e})=>e)),x=(0,n.computed)(()=>v.value.length>0),S=(0,n.computed)(()=>!!d.value.trim()||b.value.length>0),C=(0,n.computed)(()=>d.value.trim()?v.value.length:b.value.length),te=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":f.value===e}],w=(e,t)=>{if(!t)return[{text:e,matched:!1}];let n=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return e.split(n).filter(Boolean).map(e=>({text:e,matched:e.toLocaleLowerCase()===t.toLocaleLowerCase()}))},T=e=>_.value.paths.get(e)??r(e),E=()=>{if(!(typeof localStorage>`u`))try{localStorage.setItem(c.value,JSON.stringify(m.value))}catch{}},D=e=>{if(!e.label.trim())return;let t=m.value.filter(t=>t.menuKey!==e.key);m.value=[{menuKey:e.key,timestamp:Date.now()},...t].slice(0,l.value),E()},O=()=>{if(m.value=[],!(typeof localStorage>`u`))try{let e=localStorage.getItem(c.value);if(e){let t=JSON.parse(e);if(!Array.isArray(t))return;m.value=t.flatMap(o).slice(0,l.value)}}catch{m.value=[]}},k=()=>{if(m.value=[],!(typeof localStorage>`u`))try{localStorage.removeItem(c.value)}catch{}},A=e=>{let t=y.value[e];t&&(m.value.splice(t.sourceIndex,1),E(),f.value=Math.max(0,Math.min(f.value,b.value.length-1)))},j=async()=>{u.value=!0,d.value=``,f.value=0,h.value=!1,await(0,n.nextTick)(),p.value?.focus()},M=()=>{u.value=!1,d.value=``,f.value=0,h.value=!1},N=e=>{if(e.menuItem){let n=_.value.byKey.get(e.menuItem.key);if(!n)return;t().onSelect?.(n.key,!!n.children?.length),M()}else d.value=e.query,f.value=0},P=e=>{let n=_.value.byKey.get(e.key);n&&(D(n),t().onSelect?.(n.key,!!n.children?.length),M())},F=e=>h.value||!!(e&&(e.defaultPrevented||e.isComposing||e.keyCode===229||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)),I=e=>{if(F(e))return;f.value=Math.max(0,Math.min(f.value,C.value-1));let t=!d.value.trim()&&b.value.length>0,n=d.value.trim()&&v.value.length>0;if(t){let t=b.value[f.value];t&&(e?.preventDefault(),N(t))}else if(n){let t=v.value[f.value];t&&(e?.preventDefault(),P(t))}},L=e=>{F(e)||(e?.preventDefault(),f.value=Math.max(0,Math.min(f.value+1,C.value-1)))},R=e=>{F(e)||(e?.preventDefault(),f.value=Math.max(0,Math.min(f.value-1,C.value-1)))},z=e=>{e.key!==`Escape`||F(e)||(e.preventDefault(),M())},B=e=>{e.key===`ArrowDown`?L(e):e.key===`ArrowUp`?R(e):e.key===`Enter`?I(e):z(e)};(0,n.watch)(d,()=>{f.value=0}),(0,n.watch)(C,e=>{f.value=Math.max(0,Math.min(f.value,e-1))}),(0,n.watch)(c,O);let V=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||h.value||(e.ctrlKey||e.metaKey)&&e.key===`k`&&(e.preventDefault(),j())};return(0,n.onMounted)(()=>{O(),document.addEventListener(`keydown`,V)}),(0,n.onUnmounted)(()=>document.removeEventListener(`keydown`,V)),{showDialog:u,searchValue:d,selectedIndex:f,searchInputRef:p,isDark:g,filteredMenuItems:v,displayHistory:b,hasResults:x,hasContent:S,getItemClasses:te,highlightMatch:w,formatMenuPath:T,clearHistory:k,removeHistoryItem:A,openDialog:j,closeDialog:M,selectHistoryItem:N,selectItem:P,handleEnter:I,focusNext:L,focusPrev:R,handleInputKeydown:B,handleDialogKeydown:z,handleCompositionStart:()=>{h.value=!0},handleCompositionEnd:()=>{h.value=!1}}}const c={class:`robot-search-palette`},l={class:`robot-search-header`},ee=[`placeholder`,`aria-expanded`,`aria-activedescendant`],u={key:0,class:`robot-empty-state`},d={class:`robot-search-results`},f={class:`robot-result-group`},p={class:`robot-group-title`},m={class:`robot-group-count`},h=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],g={key:1,class:`robot-item-icon robot-default-icon`},_={class:`robot-item-content`},v={class:`robot-item-label`},y={class:`robot-item-desc`},b=[`onClick`],x={class:`robot-search-results`},S={key:0,class:`robot-empty-state`},C={class:`robot-result-group`},te={class:`robot-group-title`},w={class:`robot-group-count`},T=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],E={key:1,class:`robot-item-icon robot-default-icon`},D={class:`robot-item-content`},O={class:`robot-item-label`},k={key:0,class:`robot-highlight`},A={class:`robot-item-desc`},j={key:2,class:`robot-item-badge`},M={class:`robot-search-footer`},N={key:0,class:`robot-footer-info`},P={key:0},F={key:1},I=(0,n.defineComponent)({name:`C_GlobalSearch`,__name:`index`,props:{options:{},placeholder:{default:`搜索导航菜单...`},emptyText:{default:`输入关键词搜索菜单`},resultGroupTitle:{default:`菜单导航`}},setup(e,{expose:r}){let i=e,{showDialog:a,searchValue:o,selectedIndex:I,searchInputRef:L,isDark:R,filteredMenuItems:z,displayHistory:B,hasResults:V,hasContent:H,getItemClasses:U,highlightMatch:ne,formatMenuPath:W,clearHistory:G,removeHistoryItem:re,openDialog:K,closeDialog:q,selectHistoryItem:ie,selectItem:ae,handleInputKeydown:oe,handleDialogKeydown:J,handleCompositionStart:Y,handleCompositionEnd:X}=s(()=>i.options),Z=`robot-search-options-${(0,n.useId)()}`,Q=e=>`${Z}-${e}`,se=(0,n.computed)(()=>(o.value.trim()?z.value.length:B.value.length)>0?Q(I.value):void 0),ce=(0,n.ref)(),le=(0,n.ref)(),$=!1,ue=async()=>{$||($=!0,await(0,n.nextTick)(),$=!1,a.value&&(o.value.trim()?z.value.length&&ce.value?.scrollTo({index:I.value}):le.value?.querySelector(`[data-option-index="${I.value}"]`)?.scrollIntoView({block:`nearest`})))},de=e=>{let t=e.defaultPrevented;oe(e),!t&&e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&ue()};return(0,n.watch)([I,z,B,a],ue,{flush:`post`}),r({openDialog:K,closeDialog:q}),(r,i)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,c,[(0,n.createCommentVNode)(` 搜索触发按钮 `),(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`robot-search-trigger`,{"trigger-dark":(0,n.unref)(R)}]),onClick:i[0]||=(...e)=>(0,n.unref)(K)&&(0,n.unref)(K)(...e)},[...i[9]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:search robot-trigger-icon`},null,-1),(0,n.createElementVNode)(`span`,{class:`robot-trigger-text`},`搜索`,-1),(0,n.createElementVNode)(`span`,{class:`robot-trigger-shortcut`},`Ctrl K`,-1)]],2),(0,n.createCommentVNode)(` 搜索对话框 `),((0,n.openBlock)(),(0,n.createBlock)(n.Teleport,{to:`body`},[(0,n.createVNode)(n.Transition,{name:`robot-dialog`},{default:(0,n.withCtx)(()=>[(0,n.unref)(a)?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:0,class:`robot-dialog-overlay`,onClick:i[7]||=(...e)=>(0,n.unref)(q)&&(0,n.unref)(q)(...e),onKeydown:i[8]||=(...e)=>(0,n.unref)(J)&&(0,n.unref)(J)(...e)},[(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`robot-dialog-container`,{"dialog-dark":(0,n.unref)(R)}]),role:`dialog`,"aria-modal":`true`,"aria-label":`全局搜索`,onClick:i[6]||=(0,n.withModifiers)(()=>{},[`stop`])},[(0,n.createCommentVNode)(` 搜索头部 `),(0,n.createElementVNode)(`div`,l,[i[11]||=(0,n.createElementVNode)(`div`,{class:`i-mdi:magnify robot-search-icon`},null,-1),(0,n.withDirectives)((0,n.createElementVNode)(`input`,{ref_key:`searchInputRef`,ref:L,"onUpdate:modelValue":i[1]||=e=>(0,n.isRef)(o)?o.value=e:null,type:`text`,placeholder:e.placeholder,class:`robot-search-input`,role:`combobox`,"aria-label":`搜索菜单`,"aria-autocomplete":`list`,"aria-expanded":(0,n.unref)(a),"aria-controls":Z,"aria-activedescendant":se.value,onKeydown:de,onCompositionstart:i[2]||=(...e)=>(0,n.unref)(Y)&&(0,n.unref)(Y)(...e),onCompositionend:i[3]||=(...e)=>(0,n.unref)(X)&&(0,n.unref)(X)(...e)},null,40,ee),[[n.vModelText,(0,n.unref)(o)]]),(0,n.createElementVNode)(`button`,{class:`robot-close-btn`,"aria-label":`关闭搜索`,onClick:i[4]||=(...e)=>(0,n.unref)(q)&&(0,n.unref)(q)(...e)},[...i[10]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:close`},null,-1)]])]),(0,n.createCommentVNode)(` 搜索内容 `),(0,n.createElementVNode)(`div`,{class:(0,n.normalizeClass)([`robot-search-content`,{"robot-search-content--virtual":(0,n.unref)(o).trim()&&(0,n.unref)(V)}])},[(0,n.createCommentVNode)(` 空状态 `),(0,n.unref)(H)?!(0,n.unref)(o).trim()&&(0,n.unref)(B).length>0?((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[(0,n.createCommentVNode)(` 搜索历史 `),(0,n.createElementVNode)(`div`,d,[(0,n.createElementVNode)(`div`,f,[(0,n.createElementVNode)(`div`,p,[i[14]||=(0,n.createElementVNode)(`div`,{class:`i-mdi:clock-time-four-outline robot-group-icon`},null,-1),i[15]||=(0,n.createTextVNode)(` 最近搜索 `,-1),(0,n.createElementVNode)(`span`,m,(0,n.toDisplayString)((0,n.unref)(B).length),1),(0,n.createElementVNode)(`button`,{class:`robot-clear-history`,onClick:i[5]||=(...e)=>(0,n.unref)(G)&&(0,n.unref)(G)(...e),title:`清空历史`},[...i[13]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:delete-outline`},null,-1)]])]),(0,n.createElementVNode)(`div`,{id:Z,ref_key:`historyItemsRef`,ref:le,class:`robot-group-items`,role:`listbox`,"aria-label":`最近搜索`},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(B),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:`history-${t}`,id:Q(t),class:(0,n.normalizeClass)((0,n.unref)(U)(t,!0)),role:`option`,"aria-selected":(0,n.unref)(I)===t,"data-option-index":t,onClick:t=>(0,n.unref)(ie)(e),onMouseenter:e=>I.value=t},[e.menuItem?.icon?((0,n.openBlock)(),(0,n.createBlock)((0,n.resolveDynamicComponent)(e.menuItem.icon),{key:0,class:`robot-item-icon`})):((0,n.openBlock)(),(0,n.createElementBlock)(`div`,g,[...i[16]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,n.createElementVNode)(`div`,_,[(0,n.createElementVNode)(`div`,v,(0,n.toDisplayString)(e.query),1),(0,n.createElementVNode)(`div`,y,(0,n.toDisplayString)((0,n.unref)(W)(e.menuItem?.key||``)),1)]),(0,n.createElementVNode)(`button`,{class:`robot-history-delete`,onClick:(0,n.withModifiers)(e=>(0,n.unref)(re)(t),[`stop`]),title:`删除此记录`},[...i[17]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:close`},null,-1)]],8,b)],42,h))),128))],512)])])],64)):(0,n.unref)(o).trim()?((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:2},[(0,n.createCommentVNode)(` 搜索结果 `),(0,n.createElementVNode)(`div`,x,[(0,n.createCommentVNode)(` 无结果状态 `),(0,n.unref)(V)?((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[(0,n.createCommentVNode)(` 搜索结果列表 `),(0,n.createElementVNode)(`div`,C,[(0,n.createElementVNode)(`div`,te,[i[19]||=(0,n.createElementVNode)(`div`,{class:`i-mdi:menu robot-group-icon`},null,-1),(0,n.createTextVNode)(` `+(0,n.toDisplayString)(e.resultGroupTitle)+` `,1),(0,n.createElementVNode)(`span`,w,(0,n.toDisplayString)((0,n.unref)(z).length),1)]),(0,n.createVNode)((0,n.unref)(t.t),{id:Z,ref_key:`resultListRef`,ref:ce,class:`robot-group-items robot-virtual-items`,role:`listbox`,"aria-label":e.resultGroupTitle,items:(0,n.unref)(z),"item-size":64,style:(0,n.normalizeStyle)({height:`${Math.min((0,n.unref)(z).length*64,336)}px`})},{default:(0,n.withCtx)(({item:e,index:t})=>[(0,n.createElementVNode)(`div`,{id:Q(t),class:(0,n.normalizeClass)((0,n.unref)(U)(t,!1)),role:`option`,"aria-selected":(0,n.unref)(I)===t,"aria-posinset":t+1,"aria-setsize":(0,n.unref)(z).length,title:`${e.label} · ${(0,n.unref)(W)(e.key)}`,onClick:t=>(0,n.unref)(ae)(e),onMouseenter:e=>I.value=t},[e.icon?((0,n.openBlock)(),(0,n.createBlock)((0,n.resolveDynamicComponent)(e.icon),{key:0,class:`robot-item-icon`})):((0,n.openBlock)(),(0,n.createElementBlock)(`div`,E,[...i[20]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,n.createElementVNode)(`div`,D,[(0,n.createElementVNode)(`div`,O,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(ne)(e.label,(0,n.unref)(o)),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:t},[e.matched?((0,n.openBlock)(),(0,n.createElementBlock)(`mark`,k,(0,n.toDisplayString)(e.text),1)):((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[(0,n.createTextVNode)((0,n.toDisplayString)(e.text),1)],64))],64))),128))]),(0,n.createElementVNode)(`div`,A,(0,n.toDisplayString)((0,n.unref)(W)(e.key)),1)]),e.children?.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,j,(0,n.toDisplayString)(e.children.length),1)):(0,n.createCommentVNode)(`v-if`,!0)],42,T)]),_:1},8,[`aria-label`,`items`,`style`])])],2112)):((0,n.openBlock)(),(0,n.createElementBlock)(`div`,S,[i[18]||=(0,n.createElementVNode)(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),(0,n.createElementVNode)(`p`,null,`未找到 "`+(0,n.toDisplayString)((0,n.unref)(o))+`" 相关内容`,1)]))])],64)):(0,n.createCommentVNode)(`v-if`,!0):((0,n.openBlock)(),(0,n.createElementBlock)(`div`,u,[i[12]||=(0,n.createElementVNode)(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),(0,n.createElementVNode)(`p`,null,(0,n.toDisplayString)(e.emptyText),1)]))],2),(0,n.createCommentVNode)(` 搜索底部 `),(0,n.createElementVNode)(`div`,M,[i[21]||=(0,n.createElementVNode)(`div`,{class:`robot-footer-actions`},[(0,n.createElementVNode)(`div`,{class:`robot-action-item`},[(0,n.createElementVNode)(`kbd`,null,`↵`),(0,n.createElementVNode)(`span`,null,`选择`)]),(0,n.createElementVNode)(`div`,{class:`robot-action-item`},[(0,n.createElementVNode)(`kbd`,null,`↑↓`),(0,n.createElementVNode)(`span`,null,`导航`)]),(0,n.createElementVNode)(`div`,{class:`robot-action-item`},[(0,n.createElementVNode)(`kbd`,null,`esc`),(0,n.createElementVNode)(`span`,null,`关闭`)])],-1),(0,n.unref)(H)?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,N,[(0,n.unref)(o).trim()&&(0,n.unref)(V)?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,P,` 共 `+(0,n.toDisplayString)((0,n.unref)(z).length)+` 项结果 `,1)):!(0,n.unref)(o).trim()&&(0,n.unref)(B).length>0?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,F,(0,n.toDisplayString)((0,n.unref)(B).length)+` 条历史记录 `,1)):(0,n.createCommentVNode)(`v-if`,!0)])):(0,n.createCommentVNode)(`v-if`,!0)])],2)],32)):(0,n.createCommentVNode)(`v-if`,!0)]),_:1})]))]))}});var L=e.t(I,[[`__scopeId`,`data-v-c2819875`]]);Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}});
@@ -1 +1 @@
1
- import{t as e}from"./export-helper.js";import{Fragment as t,Teleport as n,Transition as r,computed as i,createBlock as a,createCommentVNode as o,createElementBlock as s,createElementVNode as c,createTextVNode as l,createVNode as u,defineComponent as d,isRef as f,nextTick as p,normalizeClass as m,normalizeStyle as h,onMounted as ee,onUnmounted as g,openBlock as _,ref as v,renderList as y,resolveDynamicComponent as b,toDisplayString as x,toValue as S,unref as C,useId as w,vModelText as te,watch as T,withCtx as E,withDirectives as ne,withModifiers as D}from"vue";import{VVirtualList as re}from"vueuc";const O=e=>e.replace(/^\//,``).replace(/\//g,` > `)||`首页`;function k(e){let t=new Map,n=new Map;return{entries:e.map(e=>{let{key:r}=e,i=O(r);return t.set(r,i),n.set(r,e),{item:e,label:e.label.toLowerCase(),path:i.toLowerCase()}}),paths:t,byKey:n}}function A(e,t){if(!t.trim())return[];let n=t.toLowerCase();return e.entries.filter(e=>e.label.includes(n)||e.path.includes(n)).map(e=>e.item)}function j(e){let t=typeof e==`string`?{query:e}:e;if(!t||typeof t!=`object`)return[];let{query:n,menuKey:r,menuItem:i,timestamp:a}=t,o=typeof r==`string`?r:i?.key,s=Number.isFinite(a)?a:0;return typeof o==`string`?[{menuKey:o,timestamp:s}]:typeof n!=`string`||!n.trim()?[]:[{query:n.slice(0,200),menuKey:null,timestamp:s}]}function M(e){let t=()=>S(e),n=()=>t().menuItems(),r=i(()=>t().storageKey??`robot-search-history`),a=i(()=>Math.min(100,Math.max(0,Math.trunc(t().maxHistory??10)))),o=i(()=>Math.min(a.value,Math.max(0,Math.trunc(t().maxDisplayHistory??5)))),s=v(!1),c=v(``),l=v(0),u=v(),d=v([]),f=v(!1),m=i(()=>t().isDark?.()??!1),h=i(()=>k(n())),_=i(()=>c.value.trim()?A(h.value,c.value):[]),y=i(()=>{let e=[];for(let[t,n]of d.value.entries()){if(e.length>=o.value)break;let{menuKey:r,query:i,timestamp:a}=n,s=r===null?null:h.value.byKey.get(r),c=s?.label??i;s===void 0||c===void 0||e.push({item:{query:c,menuItem:s,timestamp:a},sourceIndex:t})}return e}),b=i(()=>y.value.map(({item:e})=>e)),x=i(()=>_.value.length>0),C=i(()=>!!c.value.trim()||b.value.length>0),w=i(()=>c.value.trim()?_.value.length:b.value.length),te=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":l.value===e}],E=(e,t)=>{if(!t)return[{text:e,matched:!1}];let n=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return e.split(n).filter(Boolean).map(e=>({text:e,matched:e.toLocaleLowerCase()===t.toLocaleLowerCase()}))},ne=e=>h.value.paths.get(e)??O(e),D=()=>{if(!(typeof localStorage>`u`))try{localStorage.setItem(r.value,JSON.stringify(d.value))}catch{}},re=e=>{if(!e.label.trim())return;let t=d.value.filter(t=>t.menuKey!==e.key);d.value=[{menuKey:e.key,timestamp:Date.now()},...t].slice(0,a.value),D()},M=()=>{if(d.value=[],!(typeof localStorage>`u`))try{let e=localStorage.getItem(r.value);if(e){let t=JSON.parse(e);if(!Array.isArray(t))return;d.value=t.flatMap(j).slice(0,a.value)}}catch{d.value=[]}},ie=()=>{if(d.value=[],!(typeof localStorage>`u`))try{localStorage.removeItem(r.value)}catch{}},ae=e=>{let t=y.value[e];t&&(d.value.splice(t.sourceIndex,1),D(),l.value=Math.max(0,Math.min(l.value,b.value.length-1)))},N=async()=>{s.value=!0,c.value=``,l.value=0,f.value=!1,await p(),u.value?.focus()},P=()=>{s.value=!1,c.value=``,l.value=0,f.value=!1},F=e=>{if(e.menuItem){let n=h.value.byKey.get(e.menuItem.key);if(!n)return;t().onSelect?.(n.key,!!n.children?.length),P()}else c.value=e.query,l.value=0},I=e=>{let n=h.value.byKey.get(e.key);n&&(re(n),t().onSelect?.(n.key,!!n.children?.length),P())},L=e=>f.value||!!(e&&(e.defaultPrevented||e.isComposing||e.keyCode===229||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)),R=e=>{if(L(e))return;l.value=Math.max(0,Math.min(l.value,w.value-1));let t=!c.value.trim()&&b.value.length>0,n=c.value.trim()&&_.value.length>0;if(t){let t=b.value[l.value];t&&(e?.preventDefault(),F(t))}else if(n){let t=_.value[l.value];t&&(e?.preventDefault(),I(t))}},z=e=>{L(e)||(e?.preventDefault(),l.value=Math.max(0,Math.min(l.value+1,w.value-1)))},B=e=>{L(e)||(e?.preventDefault(),l.value=Math.max(0,Math.min(l.value-1,w.value-1)))},V=e=>{e.key!==`Escape`||L(e)||(e.preventDefault(),P())},oe=e=>{e.key===`ArrowDown`?z(e):e.key===`ArrowUp`?B(e):e.key===`Enter`?R(e):V(e)};T(c,()=>{l.value=0}),T(w,e=>{l.value=Math.max(0,Math.min(l.value,e-1))}),T(r,M);let H=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||f.value||(e.ctrlKey||e.metaKey)&&e.key===`k`&&(e.preventDefault(),N())};return ee(()=>{M(),document.addEventListener(`keydown`,H)}),g(()=>document.removeEventListener(`keydown`,H)),{showDialog:s,searchValue:c,selectedIndex:l,searchInputRef:u,isDark:m,filteredMenuItems:_,displayHistory:b,hasResults:x,hasContent:C,getItemClasses:te,highlightMatch:E,formatMenuPath:ne,clearHistory:ie,removeHistoryItem:ae,openDialog:N,closeDialog:P,selectHistoryItem:F,selectItem:I,handleEnter:R,focusNext:z,focusPrev:B,handleInputKeydown:oe,handleDialogKeydown:V,handleCompositionStart:()=>{f.value=!0},handleCompositionEnd:()=>{f.value=!1}}}const ie={class:`robot-search-palette`},ae={class:`robot-search-header`},N=[`placeholder`,`aria-expanded`,`aria-activedescendant`],P={key:0,class:`robot-empty-state`},F={class:`robot-search-results`},I={class:`robot-result-group`},L={class:`robot-group-title`},R={class:`robot-group-count`},z=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],B={key:1,class:`robot-item-icon robot-default-icon`},V={class:`robot-item-content`},oe={class:`robot-item-label`},H={class:`robot-item-desc`},se=[`onClick`],ce={class:`robot-search-results`},le={key:0,class:`robot-empty-state`},ue={class:`robot-result-group`},de={class:`robot-group-title`},fe={class:`robot-group-count`},pe=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],me={key:1,class:`robot-item-icon robot-default-icon`},he={class:`robot-item-content`},ge={class:`robot-item-label`},_e={key:0,class:`robot-highlight`},ve={class:`robot-item-desc`},ye={key:2,class:`robot-item-badge`},be={class:`robot-search-footer`},xe={key:0,class:`robot-footer-info`},Se={key:0},Ce={key:1};var U=e(d({name:`C_GlobalSearch`,__name:`index`,props:{options:{},placeholder:{default:`搜索导航菜单...`},emptyText:{default:`输入关键词搜索菜单`},resultGroupTitle:{default:`菜单导航`}},setup(e,{expose:d}){let ee=e,{showDialog:g,searchValue:S,selectedIndex:O,searchInputRef:k,isDark:A,filteredMenuItems:j,displayHistory:U,hasResults:W,hasContent:G,getItemClasses:we,highlightMatch:Te,formatMenuPath:K,clearHistory:Ee,removeHistoryItem:De,openDialog:q,closeDialog:J,selectHistoryItem:Oe,selectItem:ke,handleInputKeydown:Ae,handleDialogKeydown:je,handleCompositionStart:Y,handleCompositionEnd:Me}=M(()=>ee.options),X=`robot-search-options-${w()}`,Z=e=>`${X}-${e}`,Ne=i(()=>(S.value.trim()?j.value.length:U.value.length)>0?Z(O.value):void 0),Pe=v(),Fe=v(),Q=!1,$=async()=>{Q||(Q=!0,await p(),Q=!1,g.value&&(S.value.trim()?j.value.length&&Pe.value?.scrollTo({index:O.value}):Fe.value?.querySelector(`[data-option-index="${O.value}"]`)?.scrollIntoView({block:`nearest`})))},Ie=e=>{let t=e.defaultPrevented;Ae(e),!t&&e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&$()};return T([O,j,U,g],$,{flush:`post`}),d({openDialog:q,closeDialog:J}),(i,d)=>(_(),s(`div`,ie,[o(` 搜索触发按钮 `),c(`div`,{class:m([`robot-search-trigger`,{"trigger-dark":C(A)}]),onClick:d[0]||=(...e)=>C(q)&&C(q)(...e)},[...d[9]||=[c(`div`,{class:`i-mdi:search robot-trigger-icon`},null,-1),c(`span`,{class:`robot-trigger-text`},`搜索`,-1),c(`span`,{class:`robot-trigger-shortcut`},`Ctrl K`,-1)]],2),o(` 搜索对话框 `),(_(),a(n,{to:`body`},[u(r,{name:`robot-dialog`},{default:E(()=>[C(g)?(_(),s(`div`,{key:0,class:`robot-dialog-overlay`,onClick:d[7]||=(...e)=>C(J)&&C(J)(...e),onKeydown:d[8]||=(...e)=>C(je)&&C(je)(...e)},[c(`div`,{class:m([`robot-dialog-container`,{"dialog-dark":C(A)}]),role:`dialog`,"aria-modal":`true`,"aria-label":`全局搜索`,onClick:d[6]||=D(()=>{},[`stop`])},[o(` 搜索头部 `),c(`div`,ae,[d[11]||=c(`div`,{class:`i-mdi:magnify robot-search-icon`},null,-1),ne(c(`input`,{ref_key:`searchInputRef`,ref:k,"onUpdate:modelValue":d[1]||=e=>f(S)?S.value=e:null,type:`text`,placeholder:e.placeholder,class:`robot-search-input`,role:`combobox`,"aria-label":`搜索菜单`,"aria-autocomplete":`list`,"aria-expanded":C(g),"aria-controls":X,"aria-activedescendant":Ne.value,onKeydown:Ie,onCompositionstart:d[2]||=(...e)=>C(Y)&&C(Y)(...e),onCompositionend:d[3]||=(...e)=>C(Me)&&C(Me)(...e)},null,40,N),[[te,C(S)]]),c(`button`,{class:`robot-close-btn`,"aria-label":`关闭搜索`,onClick:d[4]||=(...e)=>C(J)&&C(J)(...e)},[...d[10]||=[c(`div`,{class:`i-mdi:close`},null,-1)]])]),o(` 搜索内容 `),c(`div`,{class:m([`robot-search-content`,{"robot-search-content--virtual":C(S).trim()&&C(W)}])},[o(` 空状态 `),C(G)?!C(S).trim()&&C(U).length>0?(_(),s(t,{key:1},[o(` 搜索历史 `),c(`div`,F,[c(`div`,I,[c(`div`,L,[d[14]||=c(`div`,{class:`i-mdi:clock-time-four-outline robot-group-icon`},null,-1),d[15]||=l(` 最近搜索 `,-1),c(`span`,R,x(C(U).length),1),c(`button`,{class:`robot-clear-history`,onClick:d[5]||=(...e)=>C(Ee)&&C(Ee)(...e),title:`清空历史`},[...d[13]||=[c(`div`,{class:`i-mdi:delete-outline`},null,-1)]])]),c(`div`,{id:X,ref_key:`historyItemsRef`,ref:Fe,class:`robot-group-items`,role:`listbox`,"aria-label":`最近搜索`},[(_(!0),s(t,null,y(C(U),(e,t)=>(_(),s(`div`,{key:`history-${t}`,id:Z(t),class:m(C(we)(t,!0)),role:`option`,"aria-selected":C(O)===t,"data-option-index":t,onClick:t=>C(Oe)(e),onMouseenter:e=>O.value=t},[e.menuItem?.icon?(_(),a(b(e.menuItem.icon),{key:0,class:`robot-item-icon`})):(_(),s(`div`,B,[...d[16]||=[c(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),c(`div`,V,[c(`div`,oe,x(e.query),1),c(`div`,H,x(C(K)(e.menuItem?.key||``)),1)]),c(`button`,{class:`robot-history-delete`,onClick:D(e=>C(De)(t),[`stop`]),title:`删除此记录`},[...d[17]||=[c(`div`,{class:`i-mdi:close`},null,-1)]],8,se)],42,z))),128))],512)])])],64)):C(S).trim()?(_(),s(t,{key:2},[o(` 搜索结果 `),c(`div`,ce,[o(` 无结果状态 `),C(W)?(_(),s(t,{key:1},[o(` 搜索结果列表 `),c(`div`,ue,[c(`div`,de,[d[19]||=c(`div`,{class:`i-mdi:menu robot-group-icon`},null,-1),l(` `+x(e.resultGroupTitle)+` `,1),c(`span`,fe,x(C(j).length),1)]),u(C(re),{id:X,ref_key:`resultListRef`,ref:Pe,class:`robot-group-items robot-virtual-items`,role:`listbox`,"aria-label":e.resultGroupTitle,items:C(j),"item-size":64,style:h({height:`${Math.min(C(j).length*64,336)}px`})},{default:E(({item:e,index:n})=>[c(`div`,{id:Z(n),class:m(C(we)(n,!1)),role:`option`,"aria-selected":C(O)===n,"aria-posinset":n+1,"aria-setsize":C(j).length,title:`${e.label} · ${C(K)(e.key)}`,onClick:t=>C(ke)(e),onMouseenter:e=>O.value=n},[e.icon?(_(),a(b(e.icon),{key:0,class:`robot-item-icon`})):(_(),s(`div`,me,[...d[20]||=[c(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),c(`div`,he,[c(`div`,ge,[(_(!0),s(t,null,y(C(Te)(e.label,C(S)),(e,n)=>(_(),s(t,{key:n},[e.matched?(_(),s(`mark`,_e,x(e.text),1)):(_(),s(t,{key:1},[l(x(e.text),1)],64))],64))),128))]),c(`div`,ve,x(C(K)(e.key)),1)]),e.children?.length?(_(),s(`div`,ye,x(e.children.length),1)):o(`v-if`,!0)],42,pe)]),_:1},8,[`aria-label`,`items`,`style`])])],2112)):(_(),s(`div`,le,[d[18]||=c(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),c(`p`,null,`未找到 "`+x(C(S))+`" 相关内容`,1)]))])],64)):o(`v-if`,!0):(_(),s(`div`,P,[d[12]||=c(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),c(`p`,null,x(e.emptyText),1)]))],2),o(` 搜索底部 `),c(`div`,be,[d[21]||=c(`div`,{class:`robot-footer-actions`},[c(`div`,{class:`robot-action-item`},[c(`kbd`,null,`↵`),c(`span`,null,`选择`)]),c(`div`,{class:`robot-action-item`},[c(`kbd`,null,`↑↓`),c(`span`,null,`导航`)]),c(`div`,{class:`robot-action-item`},[c(`kbd`,null,`esc`),c(`span`,null,`关闭`)])],-1),C(G)?(_(),s(`div`,xe,[C(S).trim()&&C(W)?(_(),s(`span`,Se,` 共 `+x(C(j).length)+` 项结果 `,1)):!C(S).trim()&&C(U).length>0?(_(),s(`span`,Ce,x(C(U).length)+` 条历史记录 `,1)):o(`v-if`,!0)])):o(`v-if`,!0)])],2)],32)):o(`v-if`,!0)]),_:1})]))]))}}),[[`__scopeId`,`data-v-4002af54`]]);export{M as n,U as t};
1
+ import{t as e}from"./export-helper.js";import{t}from"./virtualList.js";import{Fragment as n,Teleport as r,Transition as i,computed as a,createBlock as o,createCommentVNode as s,createElementBlock as c,createElementVNode as l,createTextVNode as u,createVNode as d,defineComponent as f,isRef as ee,nextTick as te,normalizeClass as p,normalizeStyle as m,onMounted as h,onUnmounted as g,openBlock as _,ref as v,renderList as y,resolveDynamicComponent as b,toDisplayString as x,toValue as S,unref as C,useId as ne,vModelText as re,watch as w,withCtx as T,withDirectives as E,withModifiers as D}from"vue";const O=e=>e.replace(/^\//,``).replace(/\//g,` > `)||`首页`;function k(e){let t=new Map,n=new Map;return{entries:e.map(e=>{let{key:r}=e,i=O(r);return t.set(r,i),n.set(r,e),{item:e,label:e.label.toLowerCase(),path:i.toLowerCase()}}),paths:t,byKey:n}}function A(e,t){if(!t.trim())return[];let n=t.toLowerCase();return e.entries.filter(e=>e.label.includes(n)||e.path.includes(n)).map(e=>e.item)}function j(e){let t=typeof e==`string`?{query:e}:e;if(!t||typeof t!=`object`)return[];let{query:n,menuKey:r,menuItem:i,timestamp:a}=t,o=typeof r==`string`?r:i?.key,s=Number.isFinite(a)?a:0;return typeof o==`string`?[{menuKey:o,timestamp:s}]:typeof n!=`string`||!n.trim()?[]:[{query:n.slice(0,200),menuKey:null,timestamp:s}]}function M(e){let t=()=>S(e),n=()=>t().menuItems(),r=a(()=>t().storageKey??`robot-search-history`),i=a(()=>Math.min(100,Math.max(0,Math.trunc(t().maxHistory??10)))),o=a(()=>Math.min(i.value,Math.max(0,Math.trunc(t().maxDisplayHistory??5)))),s=v(!1),c=v(``),l=v(0),u=v(),d=v([]),f=v(!1),ee=a(()=>t().isDark?.()??!1),p=a(()=>k(n())),m=a(()=>c.value.trim()?A(p.value,c.value):[]),_=a(()=>{let e=[];for(let[t,n]of d.value.entries()){if(e.length>=o.value)break;let{menuKey:r,query:i,timestamp:a}=n,s=r===null?null:p.value.byKey.get(r),c=s?.label??i;s===void 0||c===void 0||e.push({item:{query:c,menuItem:s,timestamp:a},sourceIndex:t})}return e}),y=a(()=>_.value.map(({item:e})=>e)),b=a(()=>m.value.length>0),x=a(()=>!!c.value.trim()||y.value.length>0),C=a(()=>c.value.trim()?m.value.length:y.value.length),ne=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":l.value===e}],re=(e,t)=>{if(!t)return[{text:e,matched:!1}];let n=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return e.split(n).filter(Boolean).map(e=>({text:e,matched:e.toLocaleLowerCase()===t.toLocaleLowerCase()}))},T=e=>p.value.paths.get(e)??O(e),E=()=>{if(!(typeof localStorage>`u`))try{localStorage.setItem(r.value,JSON.stringify(d.value))}catch{}},D=e=>{if(!e.label.trim())return;let t=d.value.filter(t=>t.menuKey!==e.key);d.value=[{menuKey:e.key,timestamp:Date.now()},...t].slice(0,i.value),E()},M=()=>{if(d.value=[],!(typeof localStorage>`u`))try{let e=localStorage.getItem(r.value);if(e){let t=JSON.parse(e);if(!Array.isArray(t))return;d.value=t.flatMap(j).slice(0,i.value)}}catch{d.value=[]}},ie=()=>{if(d.value=[],!(typeof localStorage>`u`))try{localStorage.removeItem(r.value)}catch{}},ae=e=>{let t=_.value[e];t&&(d.value.splice(t.sourceIndex,1),E(),l.value=Math.max(0,Math.min(l.value,y.value.length-1)))},N=async()=>{s.value=!0,c.value=``,l.value=0,f.value=!1,await te(),u.value?.focus()},P=()=>{s.value=!1,c.value=``,l.value=0,f.value=!1},F=e=>{if(e.menuItem){let n=p.value.byKey.get(e.menuItem.key);if(!n)return;t().onSelect?.(n.key,!!n.children?.length),P()}else c.value=e.query,l.value=0},I=e=>{let n=p.value.byKey.get(e.key);n&&(D(n),t().onSelect?.(n.key,!!n.children?.length),P())},L=e=>f.value||!!(e&&(e.defaultPrevented||e.isComposing||e.keyCode===229||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)),R=e=>{if(L(e))return;l.value=Math.max(0,Math.min(l.value,C.value-1));let t=!c.value.trim()&&y.value.length>0,n=c.value.trim()&&m.value.length>0;if(t){let t=y.value[l.value];t&&(e?.preventDefault(),F(t))}else if(n){let t=m.value[l.value];t&&(e?.preventDefault(),I(t))}},z=e=>{L(e)||(e?.preventDefault(),l.value=Math.max(0,Math.min(l.value+1,C.value-1)))},B=e=>{L(e)||(e?.preventDefault(),l.value=Math.max(0,Math.min(l.value-1,C.value-1)))},V=e=>{e.key!==`Escape`||L(e)||(e.preventDefault(),P())},oe=e=>{e.key===`ArrowDown`?z(e):e.key===`ArrowUp`?B(e):e.key===`Enter`?R(e):V(e)};w(c,()=>{l.value=0}),w(C,e=>{l.value=Math.max(0,Math.min(l.value,e-1))}),w(r,M);let H=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||f.value||(e.ctrlKey||e.metaKey)&&e.key===`k`&&(e.preventDefault(),N())};return h(()=>{M(),document.addEventListener(`keydown`,H)}),g(()=>document.removeEventListener(`keydown`,H)),{showDialog:s,searchValue:c,selectedIndex:l,searchInputRef:u,isDark:ee,filteredMenuItems:m,displayHistory:y,hasResults:b,hasContent:x,getItemClasses:ne,highlightMatch:re,formatMenuPath:T,clearHistory:ie,removeHistoryItem:ae,openDialog:N,closeDialog:P,selectHistoryItem:F,selectItem:I,handleEnter:R,focusNext:z,focusPrev:B,handleInputKeydown:oe,handleDialogKeydown:V,handleCompositionStart:()=>{f.value=!0},handleCompositionEnd:()=>{f.value=!1}}}const ie={class:`robot-search-palette`},ae={class:`robot-search-header`},N=[`placeholder`,`aria-expanded`,`aria-activedescendant`],P={key:0,class:`robot-empty-state`},F={class:`robot-search-results`},I={class:`robot-result-group`},L={class:`robot-group-title`},R={class:`robot-group-count`},z=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],B={key:1,class:`robot-item-icon robot-default-icon`},V={class:`robot-item-content`},oe={class:`robot-item-label`},H={class:`robot-item-desc`},se=[`onClick`],ce={class:`robot-search-results`},le={key:0,class:`robot-empty-state`},ue={class:`robot-result-group`},de={class:`robot-group-title`},fe={class:`robot-group-count`},pe=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],me={key:1,class:`robot-item-icon robot-default-icon`},he={class:`robot-item-content`},ge={class:`robot-item-label`},_e={key:0,class:`robot-highlight`},ve={class:`robot-item-desc`},ye={key:2,class:`robot-item-badge`},be={class:`robot-search-footer`},xe={key:0,class:`robot-footer-info`},Se={key:0},Ce={key:1};var U=e(f({name:`C_GlobalSearch`,__name:`index`,props:{options:{},placeholder:{default:`搜索导航菜单...`},emptyText:{default:`输入关键词搜索菜单`},resultGroupTitle:{default:`菜单导航`}},setup(e,{expose:f}){let h=e,{showDialog:g,searchValue:S,selectedIndex:O,searchInputRef:k,isDark:A,filteredMenuItems:j,displayHistory:U,hasResults:W,hasContent:G,getItemClasses:we,highlightMatch:Te,formatMenuPath:K,clearHistory:Ee,removeHistoryItem:De,openDialog:q,closeDialog:J,selectHistoryItem:Oe,selectItem:ke,handleInputKeydown:Ae,handleDialogKeydown:je,handleCompositionStart:Y,handleCompositionEnd:Me}=M(()=>h.options),X=`robot-search-options-${ne()}`,Z=e=>`${X}-${e}`,Ne=a(()=>(S.value.trim()?j.value.length:U.value.length)>0?Z(O.value):void 0),Pe=v(),Fe=v(),Q=!1,$=async()=>{Q||(Q=!0,await te(),Q=!1,g.value&&(S.value.trim()?j.value.length&&Pe.value?.scrollTo({index:O.value}):Fe.value?.querySelector(`[data-option-index="${O.value}"]`)?.scrollIntoView({block:`nearest`})))},Ie=e=>{let t=e.defaultPrevented;Ae(e),!t&&e.defaultPrevented&&(e.key===`ArrowDown`||e.key===`ArrowUp`)&&$()};return w([O,j,U,g],$,{flush:`post`}),f({openDialog:q,closeDialog:J}),(a,f)=>(_(),c(`div`,ie,[s(` 搜索触发按钮 `),l(`div`,{class:p([`robot-search-trigger`,{"trigger-dark":C(A)}]),onClick:f[0]||=(...e)=>C(q)&&C(q)(...e)},[...f[9]||=[l(`div`,{class:`i-mdi:search robot-trigger-icon`},null,-1),l(`span`,{class:`robot-trigger-text`},`搜索`,-1),l(`span`,{class:`robot-trigger-shortcut`},`Ctrl K`,-1)]],2),s(` 搜索对话框 `),(_(),o(r,{to:`body`},[d(i,{name:`robot-dialog`},{default:T(()=>[C(g)?(_(),c(`div`,{key:0,class:`robot-dialog-overlay`,onClick:f[7]||=(...e)=>C(J)&&C(J)(...e),onKeydown:f[8]||=(...e)=>C(je)&&C(je)(...e)},[l(`div`,{class:p([`robot-dialog-container`,{"dialog-dark":C(A)}]),role:`dialog`,"aria-modal":`true`,"aria-label":`全局搜索`,onClick:f[6]||=D(()=>{},[`stop`])},[s(` 搜索头部 `),l(`div`,ae,[f[11]||=l(`div`,{class:`i-mdi:magnify robot-search-icon`},null,-1),E(l(`input`,{ref_key:`searchInputRef`,ref:k,"onUpdate:modelValue":f[1]||=e=>ee(S)?S.value=e:null,type:`text`,placeholder:e.placeholder,class:`robot-search-input`,role:`combobox`,"aria-label":`搜索菜单`,"aria-autocomplete":`list`,"aria-expanded":C(g),"aria-controls":X,"aria-activedescendant":Ne.value,onKeydown:Ie,onCompositionstart:f[2]||=(...e)=>C(Y)&&C(Y)(...e),onCompositionend:f[3]||=(...e)=>C(Me)&&C(Me)(...e)},null,40,N),[[re,C(S)]]),l(`button`,{class:`robot-close-btn`,"aria-label":`关闭搜索`,onClick:f[4]||=(...e)=>C(J)&&C(J)(...e)},[...f[10]||=[l(`div`,{class:`i-mdi:close`},null,-1)]])]),s(` 搜索内容 `),l(`div`,{class:p([`robot-search-content`,{"robot-search-content--virtual":C(S).trim()&&C(W)}])},[s(` 空状态 `),C(G)?!C(S).trim()&&C(U).length>0?(_(),c(n,{key:1},[s(` 搜索历史 `),l(`div`,F,[l(`div`,I,[l(`div`,L,[f[14]||=l(`div`,{class:`i-mdi:clock-time-four-outline robot-group-icon`},null,-1),f[15]||=u(` 最近搜索 `,-1),l(`span`,R,x(C(U).length),1),l(`button`,{class:`robot-clear-history`,onClick:f[5]||=(...e)=>C(Ee)&&C(Ee)(...e),title:`清空历史`},[...f[13]||=[l(`div`,{class:`i-mdi:delete-outline`},null,-1)]])]),l(`div`,{id:X,ref_key:`historyItemsRef`,ref:Fe,class:`robot-group-items`,role:`listbox`,"aria-label":`最近搜索`},[(_(!0),c(n,null,y(C(U),(e,t)=>(_(),c(`div`,{key:`history-${t}`,id:Z(t),class:p(C(we)(t,!0)),role:`option`,"aria-selected":C(O)===t,"data-option-index":t,onClick:t=>C(Oe)(e),onMouseenter:e=>O.value=t},[e.menuItem?.icon?(_(),o(b(e.menuItem.icon),{key:0,class:`robot-item-icon`})):(_(),c(`div`,B,[...f[16]||=[l(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),l(`div`,V,[l(`div`,oe,x(e.query),1),l(`div`,H,x(C(K)(e.menuItem?.key||``)),1)]),l(`button`,{class:`robot-history-delete`,onClick:D(e=>C(De)(t),[`stop`]),title:`删除此记录`},[...f[17]||=[l(`div`,{class:`i-mdi:close`},null,-1)]],8,se)],42,z))),128))],512)])])],64)):C(S).trim()?(_(),c(n,{key:2},[s(` 搜索结果 `),l(`div`,ce,[s(` 无结果状态 `),C(W)?(_(),c(n,{key:1},[s(` 搜索结果列表 `),l(`div`,ue,[l(`div`,de,[f[19]||=l(`div`,{class:`i-mdi:menu robot-group-icon`},null,-1),u(` `+x(e.resultGroupTitle)+` `,1),l(`span`,fe,x(C(j).length),1)]),d(C(t),{id:X,ref_key:`resultListRef`,ref:Pe,class:`robot-group-items robot-virtual-items`,role:`listbox`,"aria-label":e.resultGroupTitle,items:C(j),"item-size":64,style:m({height:`${Math.min(C(j).length*64,336)}px`})},{default:T(({item:e,index:t})=>[l(`div`,{id:Z(t),class:p(C(we)(t,!1)),role:`option`,"aria-selected":C(O)===t,"aria-posinset":t+1,"aria-setsize":C(j).length,title:`${e.label} · ${C(K)(e.key)}`,onClick:t=>C(ke)(e),onMouseenter:e=>O.value=t},[e.icon?(_(),o(b(e.icon),{key:0,class:`robot-item-icon`})):(_(),c(`div`,me,[...f[20]||=[l(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),l(`div`,he,[l(`div`,ge,[(_(!0),c(n,null,y(C(Te)(e.label,C(S)),(e,t)=>(_(),c(n,{key:t},[e.matched?(_(),c(`mark`,_e,x(e.text),1)):(_(),c(n,{key:1},[u(x(e.text),1)],64))],64))),128))]),l(`div`,ve,x(C(K)(e.key)),1)]),e.children?.length?(_(),c(`div`,ye,x(e.children.length),1)):s(`v-if`,!0)],42,pe)]),_:1},8,[`aria-label`,`items`,`style`])])],2112)):(_(),c(`div`,le,[f[18]||=l(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),l(`p`,null,`未找到 "`+x(C(S))+`" 相关内容`,1)]))])],64)):s(`v-if`,!0):(_(),c(`div`,P,[f[12]||=l(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),l(`p`,null,x(e.emptyText),1)]))],2),s(` 搜索底部 `),l(`div`,be,[f[21]||=l(`div`,{class:`robot-footer-actions`},[l(`div`,{class:`robot-action-item`},[l(`kbd`,null,`↵`),l(`span`,null,`选择`)]),l(`div`,{class:`robot-action-item`},[l(`kbd`,null,`↑↓`),l(`span`,null,`导航`)]),l(`div`,{class:`robot-action-item`},[l(`kbd`,null,`esc`),l(`span`,null,`关闭`)])],-1),C(G)?(_(),c(`div`,xe,[C(S).trim()&&C(W)?(_(),c(`span`,Se,` 共 `+x(C(j).length)+` 项结果 `,1)):!C(S).trim()&&C(U).length>0?(_(),c(`span`,Ce,x(C(U).length)+` 条历史记录 `,1)):s(`v-if`,!0)])):s(`v-if`,!0)])],2)],32)):s(`v-if`,!0)]),_:1})]))]))}}),[[`__scopeId`,`data-v-c2819875`]]);export{M as n,U as t};