fix : correction du composant
This commit is contained in:
@@ -305,9 +305,9 @@ describe('MalioInput', () => {
|
|||||||
|
|
||||||
it('passes icon size prop to icon component', () => {
|
it('passes icon size prop to icon component', () => {
|
||||||
const wrapper = mount(InputForTest, {
|
const wrapper = mount(InputForTest, {
|
||||||
props: {iconName: 'mdi:key-outline', iconSize: 'text-2xl'},
|
props: {iconName: 'mdi:key-outline', iconSize: '24'},
|
||||||
})
|
})
|
||||||
expect(wrapper.get('[data-test="icon"]').attributes('size')).toBe('text-2xl')
|
expect(wrapper.get('[data-test="icon"]').attributes('height')).toBe('24')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('applies icon color class', () => {
|
it('applies icon color class', () => {
|
||||||
|
|||||||
@@ -8,17 +8,16 @@
|
|||||||
v-maska="mask"
|
v-maska="mask"
|
||||||
:name="name"
|
:name="name"
|
||||||
:autocomplete="autocomplete"
|
:autocomplete="autocomplete"
|
||||||
class="floating-input grow-height peer min-h-[40px] w-full border bg-white pl-3 pr-3 py-1 outline-none border-m-muted focus:border-2"
|
class="floating-input grow-height peer min-h-[40px] w-full border bg-white pl-3 pr-3 py-1 outline-none focus:border-2"
|
||||||
:class="[
|
:class="[
|
||||||
disabled ? 'cursor-not-allowed text-black/60 [&:not(:placeholder-shown)]:border-m-muted border-m-muted' : 'cursor-text',
|
disabled ? 'cursor-not-allowed text-black/60 [&:not(:placeholder-shown)]:border-m-muted border-m-muted' : 'cursor-text',
|
||||||
hasError
|
hasError
|
||||||
? 'border-m-error focus:border-m-error focus:pl-[11px] [&:not(:placeholder-shown)]:border-m-error'
|
? 'border-m-error focus:border-m-error focus:pl-[11px] [&:not(:placeholder-shown)]:border-m-error'
|
||||||
: hasSuccess
|
: hasSuccess
|
||||||
? 'border-m-success focus:border-m-success focus:pl-[11px] [&:not(:placeholder-shown)]:border-m-success'
|
? 'border-m-success focus:border-m-success focus:pl-[11px] [&:not(:placeholder-shown)]:border-m-success'
|
||||||
: 'border-m-border focus:border-m-primary focus:pl-[11px]',
|
: 'border-m-muted focus:border-m-primary focus:pl-[11px]',
|
||||||
textInput,
|
textInput,
|
||||||
iconInputPaddingClass,
|
iconInputPaddingClass,
|
||||||
inputClass,
|
|
||||||
rounded,
|
rounded,
|
||||||
]"
|
]"
|
||||||
:required="required"
|
:required="required"
|
||||||
@@ -50,22 +49,20 @@
|
|||||||
textLabel,
|
textLabel,
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
{{ label }}
|
{{ label }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<Icon
|
<IconifyIcon
|
||||||
v-if="iconName"
|
v-if="iconName"
|
||||||
:name="iconName"
|
:icon="iconName"
|
||||||
:size="iconSize"
|
:width="iconSize"
|
||||||
|
:height="iconSize"
|
||||||
|
data-test="icon"
|
||||||
:class="[
|
:class="[
|
||||||
hasError
|
hasError ? 'text-m-error' : hasSuccess ? 'text-m-success' : '',
|
||||||
? 'text-m-error'
|
'pointer-events-none absolute right-2 top-1/2 -translate-y-1/2',
|
||||||
: hasSuccess
|
iconColor,
|
||||||
? 'text-m-success'
|
]"
|
||||||
: 'text-m-muted',
|
|
||||||
'pointer-events-none absolute right-2 top-1/2 -translate-y-1/2',
|
|
||||||
iconColor,
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -81,16 +78,18 @@
|
|||||||
'mt-1 text-xs ml-[2px] ',
|
'mt-1 text-xs ml-[2px] ',
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
{{ hint || error || successMessage }}
|
{{ hint || error || success }}
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import type {MaskInputOptions} from 'maska'
|
import type {MaskInputOptions} from 'maska'
|
||||||
import {vMaska} from 'maska/vue'
|
import {vMaska} from 'maska/vue'
|
||||||
import {computed, useAttrs, useId} from 'vue'
|
import {computed, useAttrs, useId} from 'vue'
|
||||||
|
import { Icon as IconifyIcon } from '@iconify/vue'
|
||||||
|
|
||||||
defineOptions({inheritAttrs: false})
|
defineOptions({name: 'MalioInputText', inheritAttrs: false})
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -103,7 +102,6 @@ const props = withDefaults(
|
|||||||
maxWidth?: string
|
maxWidth?: string
|
||||||
textInput?: string
|
textInput?: string
|
||||||
textLabel?: string
|
textLabel?: string
|
||||||
inputClass?: string
|
|
||||||
labelClass?: string
|
labelClass?: string
|
||||||
required?: boolean
|
required?: boolean
|
||||||
maxLength?: number | string
|
maxLength?: number | string
|
||||||
@@ -113,7 +111,6 @@ const props = withDefaults(
|
|||||||
hint?: string
|
hint?: string
|
||||||
error?: string
|
error?: string
|
||||||
success?: string
|
success?: string
|
||||||
succes?: string
|
|
||||||
iconName?: string
|
iconName?: string
|
||||||
rounded?: string
|
rounded?: string
|
||||||
iconSize?: string | number
|
iconSize?: string | number
|
||||||
@@ -129,22 +126,20 @@ const props = withDefaults(
|
|||||||
label: '',
|
label: '',
|
||||||
minWidth: 'w-96',
|
minWidth: 'w-96',
|
||||||
maxWidth: '',
|
maxWidth: '',
|
||||||
inputClass: '',
|
|
||||||
labelClass: '',
|
|
||||||
textInput: 'text-lg',
|
textInput: 'text-lg',
|
||||||
|
labelClass: '',
|
||||||
required: false,
|
required: false,
|
||||||
maxLength: undefined,
|
maxLength: undefined,
|
||||||
minLength: undefined,
|
minLength: undefined,
|
||||||
readonly: false,
|
readonly: false,
|
||||||
textLabel: 'text-sml',
|
textLabel: 'text-sm',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
rounded: 'rounded-md',
|
rounded: 'rounded-md',
|
||||||
hint: '',
|
hint: '',
|
||||||
error: '',
|
error: '',
|
||||||
success: '',
|
success: '',
|
||||||
succes: '',
|
|
||||||
iconSize: 24,
|
iconSize: 24,
|
||||||
iconColor: '',
|
iconColor: 'text-m-muted',
|
||||||
mask: undefined,
|
mask: undefined,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -153,9 +148,8 @@ const attrs = useAttrs()
|
|||||||
const generatedId = useId()
|
const generatedId = useId()
|
||||||
|
|
||||||
const inputId = computed(() => props.id?.toString() || `malio-input-text-${generatedId}`)
|
const inputId = computed(() => props.id?.toString() || `malio-input-text-${generatedId}`)
|
||||||
const successMessage = computed(() => props.success || props.succes || '')
|
|
||||||
const hasError = computed(() => !!props.error)
|
const hasError = computed(() => !!props.error)
|
||||||
const hasSuccess = computed(() => !!successMessage.value)
|
const hasSuccess = computed(() => !!props.success)
|
||||||
|
|
||||||
const describedBy = computed(() => {
|
const describedBy = computed(() => {
|
||||||
const ids: string[] = []
|
const ids: string[] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user