feat: tree add leafIcon
parent
634675e032
commit
328e42a9be
|
@ -1,5 +1,4 @@
|
||||||
import useMergedState from '../_util/hooks/useMergedState';
|
import useMergedState from '../_util/hooks/useMergedState';
|
||||||
import padStart from 'lodash-es/padStart';
|
|
||||||
import { PickerPanel } from '../vc-picker';
|
import { PickerPanel } from '../vc-picker';
|
||||||
import type { Locale } from '../vc-picker/interface';
|
import type { Locale } from '../vc-picker/interface';
|
||||||
import type { GenerateConfig } from '../vc-picker/generate';
|
import type { GenerateConfig } from '../vc-picker/generate';
|
||||||
|
@ -245,7 +244,7 @@ function generateCalendar<
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div class={`${calendarPrefixCls.value}-date-value`}>
|
<div class={`${calendarPrefixCls.value}-date-value`}>
|
||||||
{padStart(String(generateConfig.getDate(date)), 2, '0')}
|
{String(generateConfig.getDate(date)).padStart(2, '0')}
|
||||||
</div>
|
</div>
|
||||||
<div class={`${calendarPrefixCls.value}-date-content`}>
|
<div class={`${calendarPrefixCls.value}-date-content`}>
|
||||||
{dateCellRender && dateCellRender({ current: date })}
|
{dateCellRender && dateCellRender({ current: date })}
|
||||||
|
|
|
@ -273,7 +273,13 @@ const TreeSelect = defineComponent({
|
||||||
removeIcon={removeIcon}
|
removeIcon={removeIcon}
|
||||||
clearIcon={clearIcon}
|
clearIcon={clearIcon}
|
||||||
switcherIcon={(nodeProps: SwitcherIconProps) =>
|
switcherIcon={(nodeProps: SwitcherIconProps) =>
|
||||||
renderSwitcherIcon(treePrefixCls.value, switcherIcon, treeLine, nodeProps)
|
renderSwitcherIcon(
|
||||||
|
treePrefixCls.value,
|
||||||
|
switcherIcon,
|
||||||
|
nodeProps,
|
||||||
|
slots.leafIcon,
|
||||||
|
treeLine,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
showTreeIcon={treeIcon as any}
|
showTreeIcon={treeIcon as any}
|
||||||
notFoundContent={mergedNotFound}
|
notFoundContent={mergedNotFound}
|
||||||
|
|
|
@ -260,7 +260,7 @@ export default defineComponent({
|
||||||
checkable={checkable}
|
checkable={checkable}
|
||||||
selectable={selectable}
|
selectable={selectable}
|
||||||
switcherIcon={(nodeProps: SwitcherIconProps) =>
|
switcherIcon={(nodeProps: SwitcherIconProps) =>
|
||||||
renderSwitcherIcon(prefixCls.value, switcherIcon, showLine, nodeProps)
|
renderSwitcherIcon(prefixCls.value, switcherIcon, nodeProps, slots.leafIcon, showLine)
|
||||||
}
|
}
|
||||||
onCheck={handleCheck}
|
onCheck={handleCheck}
|
||||||
onExpand={handleExpand}
|
onExpand={handleExpand}
|
||||||
|
|
|
@ -74,11 +74,7 @@ export function calcRangeKeys({
|
||||||
keys.push(key);
|
keys.push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandedKeys.indexOf(key) === -1) {
|
return expandedKeys.includes(key);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
|
|
|
@ -14,8 +14,9 @@ export interface SwitcherIconProps extends AntTreeNodeProps {
|
||||||
export default function renderSwitcherIcon(
|
export default function renderSwitcherIcon(
|
||||||
prefixCls: string,
|
prefixCls: string,
|
||||||
switcherIcon: any,
|
switcherIcon: any,
|
||||||
showLine: boolean | { showLeafIcon: boolean } | undefined,
|
|
||||||
props: SwitcherIconProps,
|
props: SwitcherIconProps,
|
||||||
|
leafIcon?: (props: SwitcherIconProps) => any,
|
||||||
|
showLine?: boolean | { showLeafIcon: boolean } | undefined,
|
||||||
) {
|
) {
|
||||||
const { isLeaf, expanded, loading } = props;
|
const { isLeaf, expanded, loading } = props;
|
||||||
let icon = switcherIcon;
|
let icon = switcherIcon;
|
||||||
|
@ -29,13 +30,17 @@ export default function renderSwitcherIcon(
|
||||||
let defaultIcon = null;
|
let defaultIcon = null;
|
||||||
const switcherCls = `${prefixCls}-switcher-icon`;
|
const switcherCls = `${prefixCls}-switcher-icon`;
|
||||||
if (isLeaf) {
|
if (isLeaf) {
|
||||||
if (showLine) {
|
if (!showLine) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (showLeafIcon && leafIcon) {
|
||||||
|
return leafIcon(props);
|
||||||
|
}
|
||||||
if (typeof showLine === 'object' && !showLeafIcon) {
|
if (typeof showLine === 'object' && !showLeafIcon) {
|
||||||
defaultIcon = <span class={`${prefixCls}-switcher-leaf-line`} />;
|
defaultIcon = <span class={`${prefixCls}-switcher-leaf-line`} />;
|
||||||
} else {
|
} else {
|
||||||
defaultIcon = <FileOutlined class={`${prefixCls}-switcher-line-icon`} />;
|
defaultIcon = <FileOutlined class={`${prefixCls}-switcher-line-icon`} />;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return defaultIcon;
|
return defaultIcon;
|
||||||
} else {
|
} else {
|
||||||
defaultIcon = <CaretDownFilled class={switcherCls} />;
|
defaultIcon = <CaretDownFilled class={switcherCls} />;
|
||||||
|
|
Loading…
Reference in New Issue