@robot-admin/naive-ui-components 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -1
- package/README_EN.md +3 -1
- package/dist/C_DataPicker.css +60 -23
- package/dist/C_Form.base.css +1 -1
- package/dist/C_Form.css +1 -1
- package/dist/C_FormSearch.css +93 -72
- package/dist/C_FormSearch.d.cts +2 -2
- package/dist/C_FormSearch.d.ts +2 -2
- package/dist/C_GlobalSearch2.cjs +1 -1
- package/dist/C_GlobalSearch2.js +1 -1
- package/dist/C_Select.css +1 -1
- package/dist/C_Select.d.cts +2 -2
- package/dist/C_Select.d.ts +2 -2
- package/dist/C_Select2.cjs +1 -1
- package/dist/C_Select2.js +1 -1
- package/dist/C_Table.base.css +147 -147
- package/dist/C_Table.cjs +1 -1
- package/dist/C_Table.css +146 -146
- package/dist/C_Table.d.cts +3 -3
- package/dist/C_Table.d.ts +3 -3
- package/dist/C_Table.js +1 -1
- package/dist/C_Table2.cjs +4 -3
- package/dist/C_Table2.js +4 -3
- package/dist/C_TagsView.css +51 -51
- package/dist/C_TagsView2.cjs +1 -1
- package/dist/C_TagsView2.js +1 -1
- package/dist/C_Tree.css +60 -23
- package/dist/C_Tree.d.cts +2 -2
- package/dist/C_Tree.d.ts +2 -2
- package/dist/C_Tree2.cjs +1 -1
- package/dist/C_Tree2.js +1 -1
- package/dist/SearchFieldSettings.cjs +1 -0
- package/dist/SearchFieldSettings.js +1 -0
- package/dist/constants.d.cts +2 -2
- package/dist/constants.d.ts +2 -2
- package/dist/constants2.d.cts +2 -2
- package/dist/constants2.d.ts +2 -2
- package/dist/constants4.d.cts +8 -8
- package/dist/constants4.d.ts +8 -8
- package/dist/constants5.d.cts +2 -2
- package/dist/constants5.d.ts +2 -2
- package/dist/data2.d.cts +8 -8
- package/dist/data2.d.ts +8 -8
- package/dist/dateRange.d.cts +44 -4
- package/dist/dateRange.d.ts +44 -4
- package/dist/editors.cjs +1 -0
- package/dist/{useTableQuery.d.cts → editors.d.cts} +123 -14
- package/dist/{useTableQuery.d.ts → editors.d.ts} +123 -14
- package/dist/editors.js +1 -0
- package/dist/fieldRenderers.cjs +1 -1
- package/dist/fieldRenderers.js +1 -1
- package/dist/formField.cjs +1 -1
- package/dist/formField.d.cts +35 -12
- package/dist/formField.d.ts +35 -12
- package/dist/formField.js +1 -1
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/index.vue.d.cts +4 -4
- package/dist/index.vue.d.ts +4 -4
- package/dist/index10.vue.d.cts +2 -2
- package/dist/index10.vue.d.ts +4 -4
- package/dist/index11.vue.d.cts +4 -4
- package/dist/index11.vue.d.ts +1 -1
- package/dist/index12.vue.d.cts +1 -1
- package/dist/index13.vue.d.ts +4 -4
- package/dist/index14.vue.d.cts +4 -4
- package/dist/index16.vue.d.ts +3 -3
- package/dist/index17.vue.d.cts +3 -3
- package/dist/index17.vue.d.ts +7 -7
- package/dist/index18.vue.d.cts +7 -7
- package/dist/index18.vue.d.ts +2 -2
- package/dist/index19.vue.d.cts +2 -2
- package/dist/index2.vue.d.cts +2 -2
- package/dist/index2.vue.d.ts +2 -2
- package/dist/index21.vue.d.ts +5 -5
- package/dist/index22.vue.d.cts +5 -5
- package/dist/index22.vue.d.ts +3 -3
- package/dist/index23.vue.d.cts +1 -1
- package/dist/index23.vue.d.ts +1 -1
- package/dist/index25.vue.d.cts +2 -2
- package/dist/index25.vue.d.ts +2 -2
- package/dist/index26.vue.d.cts +3 -3
- package/dist/index26.vue.d.ts +3 -3
- package/dist/index27.vue.d.cts +1 -1
- package/dist/index27.vue.d.ts +1 -1
- package/dist/index28.vue.d.cts +2 -2
- package/dist/index28.vue.d.ts +2 -2
- package/dist/index3.vue.d.cts +2 -2
- package/dist/index3.vue.d.ts +2 -2
- package/dist/index30.vue.d.cts +1 -1
- package/dist/index30.vue.d.ts +1 -1
- package/dist/index31.vue.d.cts +2 -2
- package/dist/index31.vue.d.ts +2 -2
- package/dist/index32.vue.d.cts +2 -2
- package/dist/index32.vue.d.ts +2 -2
- package/dist/index4.vue.d.cts +3 -3
- package/dist/index4.vue.d.ts +3 -3
- package/dist/index6.vue.d.cts +3 -3
- package/dist/index7.vue.d.ts +2 -2
- package/dist/index8.vue.d.cts +2 -2
- package/dist/index8.vue.d.ts +3 -3
- package/dist/index9.vue.d.cts +3 -3
- package/dist/index9.vue.d.ts +2 -2
- package/dist/presets.d.cts +1 -1
- package/dist/presets.d.ts +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/selectPresentation.cjs +1 -1
- package/dist/selectPresentation.js +1 -1
- package/dist/serializeSearch.cjs +1 -1
- package/dist/serializeSearch.js +1 -1
- package/dist/sourceControls.cjs +1 -0
- package/dist/sourceControls.js +1 -0
- package/dist/style.css +351 -293
- package/dist/types3.d.cts +2 -0
- package/dist/types4.d.ts +10 -2
- package/dist/types5.d.cts +10 -2
- package/dist/useCalendarEvents.d.cts +1 -1
- package/dist/useCalendarEvents.d.ts +1 -1
- package/dist/useCollapsePanel.d.cts +4 -4
- package/dist/useCollapsePanel.d.ts +4 -4
- package/dist/useComponentLocale.cjs +1 -1
- package/dist/useComponentLocale.js +1 -1
- package/dist/useCropperCore.d.cts +9 -9
- package/dist/useCropperCore.d.ts +9 -9
- package/dist/useDynamicFormState.d.cts +3 -3
- package/dist/useDynamicFormState.d.ts +3 -3
- package/dist/useEdgeInteraction.d.cts +2 -2
- package/dist/useEdgeInteraction.d.ts +2 -2
- package/dist/useFullscreen.d.cts +3 -3
- package/dist/useFullscreen.d.ts +3 -3
- package/dist/useGlobalSearch.d.cts +8 -0
- package/dist/useGlobalSearch.d.ts +8 -0
- package/dist/useGridWidth.cjs +1 -1
- package/dist/useGridWidth.js +1 -1
- package/dist/useInfiniteScroll.d.cts +1 -1
- package/dist/useInfiniteScroll.d.ts +1 -1
- package/dist/useQRCode.d.cts +1 -1
- package/dist/useQRCode.d.ts +1 -1
- package/dist/useSignatureHistory.d.cts +5 -5
- package/dist/useSignatureHistory.d.ts +5 -5
- package/dist/useSplitResize.d.cts +7 -7
- package/dist/useSplitResize.d.ts +7 -7
- package/dist/useWorkflowValidation.d.cts +37 -37
- package/dist/useWorkflowValidation.d.ts +37 -37
- package/dist/verification.d.cts +8 -8
- package/dist/verification.d.ts +8 -8
- package/docs/guides/component-contracts.md +72 -0
- package/docs/guides/remote-options.md +24 -0
- package/docs/guides/search-workflows.md +63 -0
- package/docs/guides/table-editing.md +79 -0
- package/docs/guides/tree.en.md +41 -0
- package/docs/guides/tree.md +80 -1
- package/package.json +1 -1
- package/dist/temporalField.cjs +0 -1
- package/dist/temporalField.js +0 -1
- package/dist/useTableQuery.cjs +0 -1
- package/dist/useTableQuery.js +0 -1
package/dist/C_GlobalSearch2.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
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,o=r(i);t.set(i,o),n.set(i,e);let s=e.label.toLowerCase();return{item:e,label:s,path:o.toLowerCase(),normalizedLabel:a(s),text:a([s,o,e.breadcrumb??``,...e.keywords??[]].join(` `))}}),paths:t,byKey:n}}function a(e){return e.normalize(`NFKC`).toLowerCase().trim().replace(/\s+/g,` `)}function o(e,t,n=`literal`){if(!t.trim())return[];if(n===`tokens`){let n=a(t),r=n.split(` `);return e.entries.filter(e=>r.every(t=>e.text.includes(t))).map(e=>({item:e.item,rank:e.normalizedLabel===n?0:e.normalizedLabel.startsWith(n)?1:e.normalizedLabel.includes(n)?2:3})).sort((e,t)=>e.rank-t.rank).map(e=>e.item)}let r=t.toLowerCase();return e.entries.filter(e=>e.label.includes(r)||e.path.includes(r)).map(e=>e.item)}function s(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 c(e){let t=()=>(0,n.toValue)(e),a=()=>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)))),u=(0,n.computed)(()=>Math.min(l.value,Math.max(0,Math.trunc(t().maxDisplayHistory??5)))),d=(0,n.ref)(!1),f=(0,n.ref)(``),p=(0,n.ref)(0),m=(0,n.ref)(),h=(0,n.ref)([]),g=(0,n.ref)(!1),_=(0,n.computed)(()=>t().isDark?.()??!1),v=(0,n.computed)(()=>i(a())),y=(0,n.computed)(()=>{if(!f.value.trim())return[];let e=v.value,{search:n,matchMode:r}=t();if(!n)return o(e,f.value,r);let i=new Set;return n(f.value,e.entries.map(e=>e.item)).flatMap(t=>{let n=e.byKey.get(t.key);return!n||i.has(t.key)?[]:(i.add(t.key),[n])})}),b=(0,n.computed)(()=>{let e=[];for(let[t,n]of h.value.entries()){if(e.length>=u.value)break;let{menuKey:r,query:i,timestamp:a}=n,o=r===null?null:v.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}),x=(0,n.computed)(()=>b.value.map(({item:e})=>e)),ee=(0,n.computed)(()=>y.value.length>0),te=(0,n.computed)(()=>!!f.value.trim()||x.value.length>0),S=(0,n.computed)(()=>f.value.trim()?y.value.length:x.value.length),C=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":p.value===e}],w=(e,n)=>{if(!n)return[{text:e,matched:!1}];let r=t().matchMode===`tokens`?n.trim().split(/\s+/).filter(Boolean).sort((e,t)=>t.length-e.length):[n];if(!r.length)return[{text:e,matched:!1}];let i=RegExp(`(${r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})`,`gi`);return e.split(i).filter(Boolean).map(e=>({text:e,matched:r.some(t=>e.toLocaleLowerCase()===t.toLocaleLowerCase())}))},T=e=>v.value.paths.get(e)??r(e),E=()=>{if(!(typeof localStorage>`u`))try{localStorage.setItem(c.value,JSON.stringify(h.value))}catch{}},D=e=>{if(!e.label.trim())return;let t=h.value.filter(t=>t.menuKey!==e.key);h.value=[{menuKey:e.key,timestamp:Date.now()},...t].slice(0,l.value),E()},O=()=>{if(h.value=[],!(typeof localStorage>`u`))try{let e=localStorage.getItem(c.value);if(e){let t=JSON.parse(e);if(!Array.isArray(t))return;h.value=t.flatMap(s).slice(0,l.value)}}catch{h.value=[]}},k=()=>{if(h.value=[],!(typeof localStorage>`u`))try{localStorage.removeItem(c.value)}catch{}},A=e=>{let t=b.value[e];t&&(h.value.splice(t.sourceIndex,1),E(),p.value=Math.max(0,Math.min(p.value,x.value.length-1)))},j=async()=>{d.value=!0,f.value=``,p.value=0,g.value=!1,await(0,n.nextTick)(),m.value?.focus()},M=()=>{d.value=!1,f.value=``,p.value=0,g.value=!1},N=e=>{if(e.menuItem){let n=v.value.byKey.get(e.menuItem.key);if(!n)return;t().onSelect?.(n.key,!!n.children?.length),M()}else f.value=e.query,p.value=0},P=e=>{let n=v.value.byKey.get(e.key);n&&(D(n),t().onSelect?.(n.key,!!n.children?.length),M())},F=e=>g.value||!!(e&&(e.defaultPrevented||e.isComposing||e.keyCode===229||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)),I=e=>{if(F(e))return;p.value=Math.max(0,Math.min(p.value,S.value-1));let t=!f.value.trim()&&x.value.length>0,n=f.value.trim()&&y.value.length>0;if(t){let t=x.value[p.value];t&&(e?.preventDefault(),N(t))}else if(n){let t=y.value[p.value];t&&(e?.preventDefault(),P(t))}},L=e=>{F(e)||(e?.preventDefault(),p.value=Math.max(0,Math.min(p.value+1,S.value-1)))},R=e=>{F(e)||(e?.preventDefault(),p.value=Math.max(0,Math.min(p.value-1,S.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)(f,()=>{p.value=0}),(0,n.watch)(S,e=>{p.value=Math.max(0,Math.min(p.value,e-1))}),(0,n.watch)(c,O);let V=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||g.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:d,searchValue:f,selectedIndex:p,searchInputRef:m,isDark:_,filteredMenuItems:y,displayHistory:x,hasResults:ee,hasContent:te,getItemClasses:C,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:()=>{g.value=!0},handleCompositionEnd:()=>{g.value=!1}}}const l={class:`robot-search-palette`},u={class:`robot-search-header`},d=[`placeholder`,`aria-expanded`,`aria-activedescendant`],f={key:0,class:`robot-empty-state`},p={class:`robot-search-results`},m={class:`robot-result-group`},h={class:`robot-group-title`},g={class:`robot-group-count`},_=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],v={key:1,class:`robot-item-icon robot-default-icon`},y={class:`robot-item-content`},b={class:`robot-item-label`},x={class:`robot-item-desc`},ee=[`onClick`],te={class:`robot-search-results`},S={key:0,class:`robot-empty-state`},C={class:`robot-result-group`},w={class:`robot-group-title`},T={class:`robot-group-count`},E=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],D={key:1,class:`robot-item-icon robot-default-icon`},O={class:`robot-item-content`},k={class:`robot-item-label`},A={key:0,class:`robot-highlight`},j={class:`robot-item-desc`},M={key:2,class:`robot-item-badge`},N={class:`robot-search-footer`},P={key:0,class:`robot-footer-info`},F={key:0},I={key:1},L=(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:s,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}=c(()=>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(s.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:s.value}):le.value?.querySelector(`[data-option-index="${s.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)([s,z,B,a],ue,{flush:`post`}),r({openDialog:K,closeDialog:q}),(r,i)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,l,[(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`,u,[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,d),[[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`,p,[(0,n.createElementVNode)(`div`,m,[(0,n.createElementVNode)(`div`,h,[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`,g,(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)(s)===t,"data-option-index":t,onClick:t=>(0,n.unref)(ie)(e),onMouseenter:e=>s.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`,v,[...i[16]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,n.createElementVNode)(`div`,y,[(0,n.createElementVNode)(`div`,b,(0,n.toDisplayString)(e.query),1),(0,n.createElementVNode)(`div`,x,(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,ee)],42,_))),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`,te,[(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`,w,[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`,T,(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)(s)===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=>s.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`,D,[...i[20]||=[(0,n.createElementVNode)(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),(0,n.createElementVNode)(`div`,O,[(0,n.createElementVNode)(`div`,k,[((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`,A,(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`,j,(0,n.toDisplayString)((0,n.unref)(W)(e.key)),1)]),e.children?.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,M,(0,n.toDisplayString)(e.children.length),1)):(0,n.createCommentVNode)(`v-if`,!0)],42,E)]),_: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`,f,[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`,N,[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`,P,[(0,n.unref)(o).trim()&&(0,n.unref)(V)?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,F,` 共 `+(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`,I,(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 R=e.t(L,[[`__scopeId`,`data-v-c2819875`]]);Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return R}});
|
package/dist/C_GlobalSearch2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
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 p,nextTick as ee,normalizeClass as m,normalizeStyle as h,onMounted as te,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 ie(e){let t=new Map,n=new Map;return{entries:e.map(e=>{let{key:r}=e,i=O(r);t.set(r,i),n.set(r,e);let a=e.label.toLowerCase();return{item:e,label:a,path:i.toLowerCase(),normalizedLabel:k(a),text:k([a,i,e.breadcrumb??``,...e.keywords??[]].join(` `))}}),paths:t,byKey:n}}function k(e){return e.normalize(`NFKC`).toLowerCase().trim().replace(/\s+/g,` `)}function A(e,t,n=`literal`){if(!t.trim())return[];if(n===`tokens`){let n=k(t),r=n.split(` `);return e.entries.filter(e=>r.every(t=>e.text.includes(t))).map(e=>({item:e.item,rank:e.normalizedLabel===n?0:e.normalizedLabel.startsWith(n)?1:e.normalizedLabel.includes(n)?2:3})).sort((e,t)=>e.rank-t.rank).map(e=>e.item)}let r=t.toLowerCase();return e.entries.filter(e=>e.label.includes(r)||e.path.includes(r)).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),p=a(()=>t().isDark?.()??!1),m=a(()=>ie(n())),h=a(()=>{if(!c.value.trim())return[];let e=m.value,{search:n,matchMode:r}=t();if(!n)return A(e,c.value,r);let i=new Set;return n(c.value,e.entries.map(e=>e.item)).flatMap(t=>{let n=e.byKey.get(t.key);return!n||i.has(t.key)?[]:(i.add(t.key),[n])})}),_=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:m.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(()=>h.value.length>0),x=a(()=>!!c.value.trim()||y.value.length>0),C=a(()=>c.value.trim()?h.value.length:y.value.length),ne=(e,t)=>[`robot-result-item`,t&&`robot-history-item`,{"robot-result-item-selected":l.value===e}],re=(e,n)=>{if(!n)return[{text:e,matched:!1}];let r=t().matchMode===`tokens`?n.trim().split(/\s+/).filter(Boolean).sort((e,t)=>t.length-e.length):[n];if(!r.length)return[{text:e,matched:!1}];let i=RegExp(`(${r.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})`,`gi`);return e.split(i).filter(Boolean).map(e=>({text:e,matched:r.some(t=>e.toLocaleLowerCase()===t.toLocaleLowerCase())}))},T=e=>m.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()},k=()=>{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=[]}},M=()=>{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 ee(),u.value?.focus()},P=()=>{s.value=!1,c.value=``,l.value=0,f.value=!1},F=e=>{if(e.menuItem){let n=m.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=m.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()&&h.value.length>0;if(t){let t=y.value[l.value];t&&(e?.preventDefault(),F(t))}else if(n){let t=h.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,k);let H=e=>{e.defaultPrevented||e.isComposing||e.keyCode===229||f.value||(e.ctrlKey||e.metaKey)&&e.key===`k`&&(e.preventDefault(),N())};return te(()=>{k(),document.addEventListener(`keydown`,H)}),g(()=>document.removeEventListener(`keydown`,H)),{showDialog:s,searchValue:c,selectedIndex:l,searchInputRef:u,isDark:p,filteredMenuItems:h,displayHistory:y,hasResults:b,hasContent:x,getItemClasses:ne,highlightMatch:re,formatMenuPath:T,clearHistory:M,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 ae={class:`robot-search-palette`},N={class:`robot-search-header`},P=[`placeholder`,`aria-expanded`,`aria-activedescendant`],F={key:0,class:`robot-empty-state`},I={class:`robot-search-results`},L={class:`robot-result-group`},R={class:`robot-group-title`},z={class:`robot-group-count`},B=[`id`,`aria-selected`,`data-option-index`,`onClick`,`onMouseenter`],V={key:1,class:`robot-item-icon robot-default-icon`},oe={class:`robot-item-content`},H={class:`robot-item-label`},se={class:`robot-item-desc`},ce=[`onClick`],le={class:`robot-search-results`},ue={key:0,class:`robot-empty-state`},de={class:`robot-result-group`},fe={class:`robot-group-title`},pe={class:`robot-group-count`},me=[`id`,`aria-selected`,`aria-posinset`,`aria-setsize`,`title`,`onClick`,`onMouseenter`],he={key:1,class:`robot-item-icon robot-default-icon`},ge={class:`robot-item-content`},_e={class:`robot-item-label`},ve={key:0,class:`robot-highlight`},ye={class:`robot-item-desc`},be={key:2,class:`robot-item-badge`},xe={class:`robot-search-footer`},Se={key:0,class:`robot-footer-info`},Ce={key:0},we={key:1};var U=e(f({name:`C_GlobalSearch`,__name:`index`,props:{options:{},placeholder:{default:`搜索导航菜单...`},emptyText:{default:`输入关键词搜索菜单`},resultGroupTitle:{default:`菜单导航`}},setup(e,{expose:f}){let te=e,{showDialog:g,searchValue:S,selectedIndex:O,searchInputRef:ie,isDark:k,filteredMenuItems:A,displayHistory:j,hasResults:U,hasContent:W,getItemClasses:G,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(()=>te.options),X=`robot-search-options-${ne()}`,Z=e=>`${X}-${e}`,Ne=a(()=>(S.value.trim()?A.value.length:j.value.length)>0?Z(O.value):void 0),Pe=v(),Fe=v(),Q=!1,$=async()=>{Q||(Q=!0,await ee(),Q=!1,g.value&&(S.value.trim()?A.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,A,j,g],$,{flush:`post`}),f({openDialog:q,closeDialog:J}),(a,f)=>(_(),c(`div`,ae,[s(` 搜索触发按钮 `),l(`div`,{class:m([`robot-search-trigger`,{"trigger-dark":C(k)}]),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:m([`robot-dialog-container`,{"dialog-dark":C(k)}]),role:`dialog`,"aria-modal":`true`,"aria-label":`全局搜索`,onClick:f[6]||=D(()=>{},[`stop`])},[s(` 搜索头部 `),l(`div`,N,[f[11]||=l(`div`,{class:`i-mdi:magnify robot-search-icon`},null,-1),E(l(`input`,{ref_key:`searchInputRef`,ref:ie,"onUpdate:modelValue":f[1]||=e=>p(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,P),[[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:m([`robot-search-content`,{"robot-search-content--virtual":C(S).trim()&&C(U)}])},[s(` 空状态 `),C(W)?!C(S).trim()&&C(j).length>0?(_(),c(n,{key:1},[s(` 搜索历史 `),l(`div`,I,[l(`div`,L,[l(`div`,R,[f[14]||=l(`div`,{class:`i-mdi:clock-time-four-outline robot-group-icon`},null,-1),f[15]||=u(` 最近搜索 `,-1),l(`span`,z,x(C(j).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(j),(e,t)=>(_(),c(`div`,{key:`history-${t}`,id:Z(t),class:m(C(G)(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`,V,[...f[16]||=[l(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),l(`div`,oe,[l(`div`,H,x(e.query),1),l(`div`,se,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,ce)],42,B))),128))],512)])])],64)):C(S).trim()?(_(),c(n,{key:2},[s(` 搜索结果 `),l(`div`,le,[s(` 无结果状态 `),C(U)?(_(),c(n,{key:1},[s(` 搜索结果列表 `),l(`div`,de,[l(`div`,fe,[f[19]||=l(`div`,{class:`i-mdi:menu robot-group-icon`},null,-1),u(` `+x(e.resultGroupTitle)+` `,1),l(`span`,pe,x(C(A).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(A),"item-size":64,style:h({height:`${Math.min(C(A).length*64,336)}px`})},{default:T(({item:e,index:t})=>[l(`div`,{id:Z(t),class:m(C(G)(t,!1)),role:`option`,"aria-selected":C(O)===t,"aria-posinset":t+1,"aria-setsize":C(A).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`,he,[...f[20]||=[l(`div`,{class:`i-mdi:file-document-outline`},null,-1)]])),l(`div`,ge,[l(`div`,_e,[(_(!0),c(n,null,y(C(Te)(e.label,C(S)),(e,t)=>(_(),c(n,{key:t},[e.matched?(_(),c(`mark`,ve,x(e.text),1)):(_(),c(n,{key:1},[u(x(e.text),1)],64))],64))),128))]),l(`div`,ye,x(C(K)(e.key)),1)]),e.children?.length?(_(),c(`div`,be,x(e.children.length),1)):s(`v-if`,!0)],42,me)]),_:1},8,[`aria-label`,`items`,`style`])])],2112)):(_(),c(`div`,ue,[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`,F,[f[12]||=l(`div`,{class:`i-mdi:magnify robot-empty-icon`},null,-1),l(`p`,null,x(e.emptyText),1)]))],2),s(` 搜索底部 `),l(`div`,xe,[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(W)?(_(),c(`div`,Se,[C(S).trim()&&C(U)?(_(),c(`span`,Ce,` 共 `+x(C(A).length)+` 项结果 `,1)):!C(S).trim()&&C(j).length>0?(_(),c(`span`,we,x(C(j).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};
|
package/dist/C_Select.css
CHANGED
|
@@ -58,4 +58,4 @@
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/* layer: default */
|
|
61
|
-
.blur[data-v-
|
|
61
|
+
.blur[data-v-50c4de6d]{--un-blur:blur(8px);filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}
|
package/dist/C_Select.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as OptionValue, n as OptionRequest, r as OptionSource, t as OptionPage } from "./optionSource.cjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as SelectProps, i as SelectOptionNode, n as SelectOptionGroup, o as SelectSelection, r as SelectOptionItem, s as SelectValue, t as SelectModelValue } from "./types5.cjs";
|
|
3
3
|
import { t as _default } from "./index26.vue.cjs";
|
|
4
|
-
export { _default as C_Select, type OptionPage, type OptionRequest, type OptionSource, type OptionValue, type SelectModelValue, type SelectOptionItem, type SelectProps, type SelectSelection, type SelectValue };
|
|
4
|
+
export { _default as C_Select, type OptionPage, type OptionRequest, type OptionSource, type OptionValue, type SelectModelValue, type SelectOptionGroup, type SelectOptionItem, type SelectOptionNode, type SelectProps, type SelectSelection, type SelectValue };
|
package/dist/C_Select.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as OptionValue, n as OptionRequest, r as OptionSource, t as OptionPage } from "./optionSource.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as SelectProps, i as SelectOptionNode, n as SelectOptionGroup, o as SelectSelection, r as SelectOptionItem, s as SelectValue, t as SelectModelValue } from "./types4.js";
|
|
3
3
|
import { t as _default } from "./index26.vue.js";
|
|
4
|
-
export { _default as C_Select, type OptionPage, type OptionRequest, type OptionSource, type OptionValue, type SelectModelValue, type SelectOptionItem, type SelectProps, type SelectSelection, type SelectValue };
|
|
4
|
+
export { _default as C_Select, type OptionPage, type OptionRequest, type OptionSource, type OptionValue, type SelectModelValue, type SelectOptionGroup, type SelectOptionItem, type SelectOptionNode, type SelectProps, type SelectSelection, type SelectValue };
|
package/dist/C_Select2.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./chunk.cjs`),t=require(`./density.cjs`),n=require(`./export-helper.cjs`),r=require(`./selectPresentation.cjs`),i=require(`./OptionStatus.cjs`);let a=require(`vue`),o=require(`naive-ui`);var s=e.t({default:()=>u});const c={class:`c-select-field`},l=(0,a.defineComponent)({name:`C_Select`,inheritAttrs:!1,__name:`index`,props:{modelValue:{},options:{},source:{},density:{},locale:{},show:{type:Boolean,default:void 0},multiple:{type:Boolean},filterable:{type:Boolean,default:void 0},remote:{type:Boolean,default:void 0},tag:{type:Boolean},clearable:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},loading:{type:Boolean},placeholder:{},maxTagCount:{},size:{},status:{},virtualScroll:{default:!0},inputProps:{},fallbackOption:{}},emits:[`update:modelValue`,`update:show`,`select`],setup(e,{expose:n,emit:s}){let l=e,u=s,d=(0,a.useSlots)(),f=(0,a.computed)(()=>Object.fromEntries(Object.entries(d).filter(([e])=>e!==`action`))),p=(0,a.useTemplateRef)(`select`),m=(0,a.computed)(()=>l.disabled||l.readonly),h=(0,a.computed)(()=>r.t(l.multiple,l.maxTagCount)),g=i.n({source:()=>l.source,values:(0,a.computed)(()=>Array.isArray(l.modelValue)?l.modelValue:l.modelValue==null?[]:[l.modelValue]),disabled:m}),_=(0,a.computed)(()=>l.size??(l.density?t.t(l.density).size:void 0)),v=(0,a.computed)(()=>l.source?g.available.value.map(e=>({value:l.source.value(e),label:l.source.label(e)})):l.options),y=(0,a.computed)(()=>r.n(v.value));function
|
|
1
|
+
const e=require(`./chunk.cjs`),t=require(`./density.cjs`),n=require(`./export-helper.cjs`),r=require(`./selectPresentation.cjs`),i=require(`./OptionStatus.cjs`);let a=require(`vue`),o=require(`naive-ui`);var s=e.t({default:()=>u});const c={class:`c-select-field`},l=(0,a.defineComponent)({name:`C_Select`,inheritAttrs:!1,__name:`index`,props:{modelValue:{},options:{},source:{},density:{},locale:{},show:{type:Boolean,default:void 0},multiple:{type:Boolean},filterable:{type:Boolean,default:void 0},remote:{type:Boolean,default:void 0},tag:{type:Boolean},clearable:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},loading:{type:Boolean},placeholder:{},maxTagCount:{},size:{},status:{},virtualScroll:{default:!0},inputProps:{},fallbackOption:{}},emits:[`update:modelValue`,`update:show`,`select`],setup(e,{expose:n,emit:s}){let l=e,u=s,d=(0,a.useSlots)(),f=(0,a.computed)(()=>Object.fromEntries(Object.entries(d).filter(([e])=>e!==`action`))),p=(0,a.useTemplateRef)(`select`),m=(0,a.computed)(()=>l.disabled||l.readonly),h=(0,a.computed)(()=>r.t(l.multiple,l.maxTagCount)),g=i.n({source:()=>l.source,values:(0,a.computed)(()=>Array.isArray(l.modelValue)?l.modelValue:l.modelValue==null?[]:[l.modelValue]),disabled:m}),_=(0,a.computed)(()=>l.size??(l.density?t.t(l.density).size:void 0)),v=(0,a.computed)(()=>l.source?g.available.value.map(e=>({value:l.source.value(e),label:l.source.label(e)})):l.options),y=(0,a.computed)(()=>r.n(v.value)),b=(0,a.computed)(()=>{let e=l.options?r.i(l.options):[],t=new Map;for(let n of e)`value`in n&&!t.has(n.value)&&t.set(n.value,n);return t});function x(e){e&&!m.value?g.open():g.close(),u(`update:show`,e)}(0,a.watch)(()=>l.show,e=>{e&&!m.value?g.open():e===!1&&g.close()},{immediate:!0});let S=(0,a.computed)(()=>y.value(l.modelValue));function C(e,t){if(m.value)return;let n=S.value.decode(e,t),r=Array.isArray(n)?n:n==null?[]:[n],i=r.flatMap(e=>{let t=l.source?g.rowFor(e):b.value.get(e);return t?[t]:[]});g.retain(r),u(`update:modelValue`,l.multiple&&n===null?[]:n),u(`select`,l.multiple?i:i[0]??null)}return n({focus:()=>p.value?.focus(),blur:()=>p.value?.blur()}),(t,n)=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,c,[(0,a.createVNode)((0,a.unref)(o.NSelect),(0,a.mergeProps)({ref_key:`select`,ref:p},t.$attrs,{class:[`c-select`,{"c-select--bounded":h.value}],value:S.value.value,options:S.value.options,multiple:e.multiple,"max-tag-count":h.value?1:e.maxTagCount,filterable:e.filterable??!!e.source,remote:e.source?!0:l.remote,show:e.show,tag:e.tag,clearable:e.clearable,disabled:m.value,loading:e.loading||(0,a.unref)(g).loading.value,size:_.value,placeholder:e.placeholder,"virtual-scroll":e.virtualScroll,status:e.status??((0,a.unref)(g).error.value==null?void 0:`error`),"input-props":e.inputProps,"fallback-option":S.value.resolveFallbackOption(e.fallbackOption),"onUpdate:value":C,"onUpdate:show":x,onSearch:(0,a.unref)(g).setSearch}),(0,a.createSlots)({_:2},[(0,a.renderList)(f.value,(e,n)=>({name:n,fn:(0,a.withCtx)(e=>[(0,a.renderSlot)(t.$slots,n,(0,a.normalizeProps)((0,a.guardReactiveProps)(e??{})),void 0,!0)])})),e.source||t.$slots.action?{name:`action`,fn:(0,a.withCtx)(()=>[e.source?((0,a.openBlock)(),(0,a.createBlock)(i.t,{key:0,active:(0,a.unref)(g).active.value,loading:(0,a.unref)(g).loading.value,error:(0,a.unref)(g).error.value,"has-more":(0,a.unref)(g).hasMore.value,incomplete:(0,a.unref)(g).search.value.trim().length<(0,a.unref)(g).minChars.value,"min-chars":(0,a.unref)(g).minChars.value,locale:e.locale,onRetry:(0,a.unref)(g).retry,onMore:(0,a.unref)(g).loadMore},null,8,[`active`,`loading`,`error`,`has-more`,`incomplete`,`min-chars`,`locale`,`onRetry`,`onMore`])):(0,a.createCommentVNode)(`v-if`,!0),(0,a.renderSlot)(t.$slots,`action`,{},void 0,!0)]),key:`0`}:void 0]),1040,[`class`,`value`,`options`,`multiple`,`max-tag-count`,`filterable`,`remote`,`show`,`tag`,`clearable`,`disabled`,`loading`,`size`,`placeholder`,`virtual-scroll`,`status`,`input-props`,`fallback-option`,`onSearch`])]))}});var u=n.t(l,[[`__scopeId`,`data-v-50c4de6d`]]);Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
package/dist/C_Select2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime.js";import{t}from"./density.js";import{t as n}from"./export-helper.js";import{
|
|
1
|
+
import{t as e}from"./rolldown-runtime.js";import{t}from"./density.js";import{t as n}from"./export-helper.js";import{i as r,n as i,t as a}from"./selectPresentation.js";import{n as o,t as s}from"./OptionStatus.js";import{computed as c,createBlock as l,createCommentVNode as u,createElementBlock as d,createSlots as f,createVNode as p,defineComponent as m,guardReactiveProps as h,mergeProps as g,normalizeProps as _,openBlock as v,renderList as y,renderSlot as b,unref as x,useSlots as S,useTemplateRef as C,watch as w,withCtx as T}from"vue";import{NSelect as E}from"naive-ui";var D=e({default:()=>k});const O={class:`c-select-field`};var k=n(m({name:`C_Select`,inheritAttrs:!1,__name:`index`,props:{modelValue:{},options:{},source:{},density:{},locale:{},show:{type:Boolean,default:void 0},multiple:{type:Boolean},filterable:{type:Boolean,default:void 0},remote:{type:Boolean,default:void 0},tag:{type:Boolean},clearable:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},loading:{type:Boolean},placeholder:{},maxTagCount:{},size:{},status:{},virtualScroll:{default:!0},inputProps:{},fallbackOption:{}},emits:[`update:modelValue`,`update:show`,`select`],setup(e,{expose:n,emit:m}){let D=e,k=m,A=S(),j=c(()=>Object.fromEntries(Object.entries(A).filter(([e])=>e!==`action`))),M=C(`select`),N=c(()=>D.disabled||D.readonly),P=c(()=>a(D.multiple,D.maxTagCount)),F=o({source:()=>D.source,values:c(()=>Array.isArray(D.modelValue)?D.modelValue:D.modelValue==null?[]:[D.modelValue]),disabled:N}),I=c(()=>D.size??(D.density?t(D.density).size:void 0)),L=c(()=>D.source?F.available.value.map(e=>({value:D.source.value(e),label:D.source.label(e)})):D.options),R=c(()=>i(L.value)),z=c(()=>{let e=D.options?r(D.options):[],t=new Map;for(let n of e)`value`in n&&!t.has(n.value)&&t.set(n.value,n);return t});function B(e){e&&!N.value?F.open():F.close(),k(`update:show`,e)}w(()=>D.show,e=>{e&&!N.value?F.open():e===!1&&F.close()},{immediate:!0});let V=c(()=>R.value(D.modelValue));function H(e,t){if(N.value)return;let n=V.value.decode(e,t),r=Array.isArray(n)?n:n==null?[]:[n],i=r.flatMap(e=>{let t=D.source?F.rowFor(e):z.value.get(e);return t?[t]:[]});F.retain(r),k(`update:modelValue`,D.multiple&&n===null?[]:n),k(`select`,D.multiple?i:i[0]??null)}return n({focus:()=>M.value?.focus(),blur:()=>M.value?.blur()}),(t,n)=>(v(),d(`div`,O,[p(x(E),g({ref_key:`select`,ref:M},t.$attrs,{class:[`c-select`,{"c-select--bounded":P.value}],value:V.value.value,options:V.value.options,multiple:e.multiple,"max-tag-count":P.value?1:e.maxTagCount,filterable:e.filterable??!!e.source,remote:e.source?!0:D.remote,show:e.show,tag:e.tag,clearable:e.clearable,disabled:N.value,loading:e.loading||x(F).loading.value,size:I.value,placeholder:e.placeholder,"virtual-scroll":e.virtualScroll,status:e.status??(x(F).error.value==null?void 0:`error`),"input-props":e.inputProps,"fallback-option":V.value.resolveFallbackOption(e.fallbackOption),"onUpdate:value":H,"onUpdate:show":B,onSearch:x(F).setSearch}),f({_:2},[y(j.value,(e,n)=>({name:n,fn:T(e=>[b(t.$slots,n,_(h(e??{})),void 0,!0)])})),e.source||t.$slots.action?{name:`action`,fn:T(()=>[e.source?(v(),l(s,{key:0,active:x(F).active.value,loading:x(F).loading.value,error:x(F).error.value,"has-more":x(F).hasMore.value,incomplete:x(F).search.value.trim().length<x(F).minChars.value,"min-chars":x(F).minChars.value,locale:e.locale,onRetry:x(F).retry,onMore:x(F).loadMore},null,8,[`active`,`loading`,`error`,`has-more`,`incomplete`,`min-chars`,`locale`,`onRetry`,`onMore`])):u(`v-if`,!0),b(t.$slots,`action`,{},void 0,!0)]),key:`0`}:void 0]),1040,[`class`,`value`,`options`,`multiple`,`max-tag-count`,`filterable`,`remote`,`show`,`tag`,`clearable`,`disabled`,`loading`,`size`,`placeholder`,`virtual-scroll`,`status`,`input-props`,`fallback-option`,`onSearch`])]))}}),[[`__scopeId`,`data-v-50c4de6d`]]);export{D as n,k as t};
|