Commit 14c53a62 by MT-Joer

style: 风格同步测试

1 parent ae3b7cab
...@@ -20,17 +20,25 @@ ...@@ -20,17 +20,25 @@
@update:model-value="updateModelValue"> @update:model-value="updateModelValue">
<div v-if="$slots.header" <div v-if="$slots.header"
:class=" :class="
cn('my-0.5 flex w-full items-center p-1', bordered ? 'border-b' : '') cn(
'my-0.5 flex w-full items-center p-1',
bordered ? 'border-b' : '',
)
"> ">
<slot name="header"> <slot name="header">
</slot> </slot>
</div> </div>
<div v-if="treeData.length > 0" <div v-if="treeData.length > 0"
:class=" :class="
cn('my-0.5 flex w-full items-center p-1', bordered ? 'border-b' : '') cn(
'my-0.5 flex w-full items-center p-1',
bordered ? 'border-b' : '',
)
"> ">
<div class="flex size-5 flex-1 cursor-pointer items-center" <div class="flex size-5 flex-1 cursor-pointer items-center"
@click="() => (expanded?.length > 0 ? collapseAll() : expandAll())"> @click="
() => (expanded?.length > 0 ? collapseAll() : expandAll())
">
<ChevronRight class="size-4 cursor-pointer text-foreground/80 transition hover:text-foreground" <ChevronRight class="size-4 cursor-pointer text-foreground/80 transition hover:text-foreground"
:class="{ 'rotate-90': expanded?.length > 0 }" /> :class="{ 'rotate-90': expanded?.length > 0 }" />
<Checkbox v-if="multiple" <Checkbox v-if="multiple"
...@@ -53,7 +61,9 @@ ...@@ -53,7 +61,9 @@
}" }"
v-bind=" v-bind="
Object.assign(item.bind, { Object.assign(item.bind, {
onfocus: isNodeDisabled(item) ? 'this.blur()' : undefined, onfocus: isNodeDisabled(item)
? 'this.blur()'
: undefined,
disabled: isNodeDisabled(item), disabled: isNodeDisabled(item),
}) })
" "
...@@ -61,7 +71,8 @@ ...@@ -61,7 +71,8 @@
:class=" :class="
cn('cursor-pointer', getNodeClass?.(item), { cn('cursor-pointer', getNodeClass?.(item), {
'data-[selected]:bg-accent': !multiple, 'data-[selected]:bg-accent': !multiple,
'cursor-not-allowed text-foreground/50': isNodeDisabled(item), 'cursor-not-allowed text-foreground/50':
isNodeDisabled(item),
}) })
" "
:style="{ 'margin-left': `${item.level - 1}rem` }" :style="{ 'margin-left': `${item.level - 1}rem` }"
...@@ -103,7 +114,9 @@ ...@@ -103,7 +114,9 @@
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<Checkbox v-if="multiple" <Checkbox v-if="multiple"
:disabled="isNodeDisabled(item)" :disabled="isNodeDisabled(item)"
:indeterminate="isIndeterminate && !isNodeDisabled(item)" :indeterminate="
isIndeterminate && !isNodeDisabled(item)
"
:model-value="isSelected && !isNodeDisabled(item)" :model-value="isSelected && !isNodeDisabled(item)"
@click=" @click="
(event: MouseEvent) => { (event: MouseEvent) => {
...@@ -139,7 +152,10 @@ ...@@ -139,7 +152,10 @@
</TransitionGroup> </TransitionGroup>
<div v-if="$slots.footer" <div v-if="$slots.footer"
:class=" :class="
cn('my-0.5 flex w-full items-center p-1', bordered ? 'border-t' : '') cn(
'my-0.5 flex w-full items-center p-1',
bordered ? 'border-t' : '',
)
"> ">
<slot name="footer"> <slot name="footer">
</slot> </slot>
...@@ -202,7 +218,10 @@ function flatten<T = Recordable<any>, P = number | string>( ...@@ -202,7 +218,10 @@ function flatten<T = Recordable<any>, P = number | string>(
result.push(val); result.push(val);
if (val.hasChildren) if (val.hasChildren)
result.push( result.push(
...flatten(children, childrenField, level + 1, id, [ ...parents, id ]), ...flatten(children, childrenField, level + 1, id, [
...parents,
id,
]),
); );
}); });
return result; return result;
...@@ -345,12 +364,16 @@ function onSelect(item: FlattenedItem<Recordable<any>>, isSelected: boolean) { ...@@ -345,12 +364,16 @@ function onSelect(item: FlattenedItem<Recordable<any>>, isSelected: boolean) {
flattenData.value flattenData.value
.find((i) => { .find((i) => {
return ( return (
get(i.value, props.valueField) === get(item.value, props.valueField) get(i.value, props.valueField) ===
get(item.value, props.valueField)
); );
}) })
?.parents?.filter((item) => !get(item, props.disabledField)) ?.parents?.filter((item) => !get(item, props.disabledField))
?.forEach((p) => { ?.forEach((p) => {
if (Array.isArray(modelValue.value) && !modelValue.value.includes(p)) { if (
Array.isArray(modelValue.value) &&
!modelValue.value.includes(p)
) {
modelValue.value.push(p); modelValue.value.push(p);
} }
}); });
...@@ -364,7 +387,8 @@ function onSelect(item: FlattenedItem<Recordable<any>>, isSelected: boolean) { ...@@ -364,7 +387,8 @@ function onSelect(item: FlattenedItem<Recordable<any>>, isSelected: boolean) {
flattenData.value flattenData.value
.find((i) => { .find((i) => {
return ( return (
get(i.value, props.valueField) === get(item.value, props.valueField) get(i.value, props.valueField) ===
get(item.value, props.valueField)
); );
}) })
?.parents?.filter((item) => !get(item, props.disabledField)) ?.parents?.filter((item) => !get(item, props.disabledField))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!