feat(select) : tags SelectCheckbox radius 20px + couleur de texte par option (MUI-49)
- Radius des tags et du badge +N porté à 20px - Champ textColor optionnel par option (couleur du texte du tag, ignorée en disabled) - Tests, COMPONENTS.md et CHANGELOG.md mis à jour Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,19 +91,19 @@
|
||||
<span
|
||||
v-for="option in visibleTags"
|
||||
:key="String(option.value)"
|
||||
class="inline-flex max-w-full items-center rounded-md px-2 pt-[2px] pb-0 text-lg font-medium leading-[normal]"
|
||||
class="inline-flex max-w-full items-center rounded-[20px] px-2 pt-[2px] pb-0 text-lg font-medium leading-[normal]"
|
||||
:class="[
|
||||
option.color ? '' : 'bg-m-bg',
|
||||
disabled ? 'text-black/60' : 'text-black',
|
||||
]"
|
||||
:style="option.color ? { backgroundColor: option.color } : undefined"
|
||||
:style="tagStyle(option)"
|
||||
>
|
||||
<span class="truncate pb-[2px]">{{ option.label }}</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="hiddenTagsCount > 0"
|
||||
data-test="tags-overflow"
|
||||
class="inline-flex items-center rounded-md bg-m-bg px-2 pt-[2px] pb-0 text-lg font-medium leading-[normal]"
|
||||
class="inline-flex items-center rounded-[20px] bg-m-bg px-2 pt-[2px] pb-0 text-lg font-medium leading-[normal]"
|
||||
:class="disabled ? 'text-black/60' : 'text-black'"
|
||||
>
|
||||
<span class="pb-[2px]">+{{ hiddenTagsCount }}</span>
|
||||
@@ -282,7 +282,8 @@ const {keyboardFocused, onFocus: onKbdFocus, onBlur: onKbdBlur} = useKbdFocusRin
|
||||
type Option = {
|
||||
label: string;
|
||||
value: string | number;
|
||||
color?: string
|
||||
color?: string;
|
||||
textColor?: string
|
||||
}
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue?: Array<string | number>
|
||||
@@ -368,6 +369,13 @@ const visibleTags = computed(() =>
|
||||
const hiddenTagsCount = computed(() =>
|
||||
props.maxTags > 0 ? Math.max(selectedOptions.value.length - props.maxTags, 0) : 0,
|
||||
)
|
||||
function tagStyle(option: Option) {
|
||||
const style: Record<string, string> = {}
|
||||
if (option.color) style.backgroundColor = option.color
|
||||
// En disabled on garde le gris hérité (text-black/60), on n'applique pas la couleur custom
|
||||
if (option.textColor && !props.disabled) style.color = option.textColor
|
||||
return Object.keys(style).length ? style : undefined
|
||||
}
|
||||
const shouldFloatLabel = computed(() =>
|
||||
isReadonly.value ? isOptionSelected.value : (isOpen.value || displayTags.value)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user