-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathBreadcrumbSeparator.tsx
30 lines (27 loc) · 1006 Bytes
/
BreadcrumbSeparator.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { ExtractPropTypes } from 'vue';
import { defineComponent } from 'vue';
import PropTypes from '../_util/vue-types';
import { flattenChildren } from '../_util/props-util';
import useConfigInject from '../_util/hooks/useConfigInject';
const breadcrumbSeparatorProps = {
prefixCls: PropTypes.string,
};
export type BreadcrumbSeparatorProps = Partial<ExtractPropTypes<typeof breadcrumbSeparatorProps>>;
export default defineComponent({
name: 'ABreadcrumbSeparator',
__ANT_BREADCRUMB_SEPARATOR: true,
inheritAttrs: false,
props: breadcrumbSeparatorProps,
setup(props, { slots, attrs }) {
const { prefixCls } = useConfigInject('breadcrumb', props);
return () => {
const { separator, class: className, ...restAttrs } = attrs;
const children = flattenChildren(slots.default?.());
return (
<span class={[`${prefixCls.value}-separator`, className]} {...restAttrs}>
{children.length > 0 ? children : '/'}
</span>
);
};
},
});