import{d as u,D as m}from"./chunks/Dropdown.DgfjCOPN.js";import{R as C}from"./chunks/Icon.D_D2CMbU.js";import{d as g,E as t,K as D,a9 as B,u as A,o as y,b as f,w as l,j as e,k as E,a as _,t as r,h as d,p as b,C as v,c as w,a3 as o}from"./chunks/framework.D8G7yXPy.js";import{B as q,_ as R}from"./chunks/DemoFrame.vue_vue_type_script_setup_true_lang.CEMQDpbD.js";import"./chunks/light.BQgF5P5u.js";import"./chunks/isSymbol.rCNNreax.js";import"./chunks/use-compitable.BN_sOfeF.js";import"./chunks/element.mIVMEYq_.js";function S(i,a){const s=i??(a==null?void 0:a.defaultElement)??null;return typeof s=="function"?s:()=>s}const N={...u,icon:{type:String,default:"action/more"},iconSize:{type:Number},cursor:{type:String,default:"inherit"}};function M(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!B(i)}const x=g({name:"RMoreDropdown",props:N,render(){let i;const{iconSize:a,cursor:s,icon:n}=this,{default:h}=this.$slots;return t(m,D(this.$props,this.$attrs,{placement:"bottom-start"}),M(i=S(h,{defaultElement:t(C,{name:n,size:a,cursor:s},null)}))?i:{default:()=>[i]})}}),T={class:"ray-demo"},P={class:"ray-demo-result"},I=g({__name:"MoreDropdownDemo",setup(i){const{lang:a}=A(),s=d(()=>a.value.startsWith("en")?{edit:"Edit",copy:"Duplicate",archive:"Archive",more:"More actions",hint:"Select an action."}:{edit:"编辑",copy:"复制",archive:"归档",more:"更多操作",hint:"请选择一项操作"}),n=d(()=>[{key:"edit",label:s.value.edit},{key:"copy",label:s.value.copy},{key:"archive",label:s.value.archive,disabled:!0}]),h=b(""),c=p=>{var k;h.value=((k=n.value.find(F=>F.key===p))==null?void 0:k.label)??""};return(p,k)=>(y(),f(R,null,{default:l(()=>[e("div",T,[t(E(x),{trigger:"click",options:n.value,onSelect:c},{default:l(()=>[t(E(q),null,{default:l(()=>[_(r(s.value.more),1)]),_:1})]),_:1},8,["options"]),e("output",P,r(h.value||s.value.hint),1)])]),_:1}))}}),K=JSON.parse('{"title":"RMoreDropdown","description":"","frontmatter":{},"headers":[],"relativePath":"reference/components/more-dropdown.md","filePath":"reference/components/more-dropdown.md"}'),V={name:"reference/components/more-dropdown.md"},U=Object.assign(V,{setup(i){return(a,s)=>{const n=v("ClientOnly");return y(),w("div",null,[s[0]||(s[0]=o('

RMoreDropdown ​

包装 NDropdown,为行操作提供默认的更多图标。options、trigger、placement、onSelect(key, option)、受控显隐等沿用 Naive UI Dropdown。

交互示例 ​

',3)),t(n,null,{default:l(()=>[t(I)]),_:1}),s[1]||(s[1]=o(`
查看示例源码
vue
<template>
  <DemoFrame>
    <div class="ray-demo">
      <RMoreDropdown trigger="click" :options="options" @select="onSelect">
        <NButton>{{ copy.more }}</NButton>
      </RMoreDropdown>
      <output class="ray-demo-result">{{ result || copy.hint }}</output>
    </div>
  </DemoFrame>
</template>

<script setup lang="ts">
import { RMoreDropdown } from '@ray-template/ui/more-dropdown'
import { NButton } from 'naive-ui'
import { useData } from 'vitepress'
import { computed, ref } from 'vue'
import DemoFrame from './DemoFrame.vue'

const { lang } = useData()
const copy = computed(() =>
  lang.value.startsWith('en')
    ? {
        edit: 'Edit',
        copy: 'Duplicate',
        archive: 'Archive',
        more: 'More actions',
        hint: 'Select an action.',
      }
    : {
        edit: '编辑',
        copy: '复制',
        archive: '归档',
        more: '更多操作',
        hint: '请选择一项操作',
      },
)
const options = computed(() => [
  { key: 'edit', label: copy.value.edit },
  { key: 'copy', label: copy.value.copy },
  { key: 'archive', label: copy.value.archive, disabled: true },
])
const result = ref('')
const onSelect = (key: string | number) => {
  result.value = options.value.find((option) => option.key === key)?.label ?? ''
}
</script>
属性默认说明
icon'action/more'类型为 IconName,使用完整分包路径。
iconSize跟随 RIcon触发图标大小,省略时为 20 px。
cursor'inherit'默认继承所在控件的指针样式。

default 插槽替换图标触发器。只有图标时建议用具有可访问名称的原生按钮或 NButton,方便键盘进入。列表行中根据业务需要阻止触发器的点击冒泡,避免同时触发行导航。

tsx
import { RIcon, RMoreDropdown } from '@/components'
import { NButton } from 'naive-ui'

export const renderRowActions = (edit: () => void) => (
  <RMoreDropdown
    trigger="click"
    placement="bottom-end"
    options={[{ key: 'edit', label: '编辑' }]}
    onSelect={(key) => {
      if (key === 'edit') edit()
    }}
  >
    <NButton
      text
      aria-label="更多操作"
      onClick={(event) => event.stopPropagation()}
    >
      <RIcon name="action/more" />
    </NButton>
  </RMoreDropdown>
)

组件实现 · Props

`,5))])}}});export{K as __pageData,U as default};