refactor(ui): replaced some n-input to c-input (#505)

This commit is contained in:
Corentin THOMASSET 2023-06-25 15:00:50 +02:00 committed by GitHub
parent 5c3bebfe62
commit 05ea545475
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 189 additions and 235 deletions

2
components.d.ts vendored
View file

@ -68,11 +68,13 @@ declare module '@vue/runtime-core' {
IconMdiDownload: typeof import('~icons/mdi/download')['default'] IconMdiDownload: typeof import('~icons/mdi/download')['default']
IconMdiEye: typeof import('~icons/mdi/eye')['default'] IconMdiEye: typeof import('~icons/mdi/eye')['default']
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default'] IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
IconMdiMagnify: typeof import('~icons/mdi/magnify')['default']
IconMdiPause: typeof import('~icons/mdi/pause')['default'] IconMdiPause: typeof import('~icons/mdi/pause')['default']
IconMdiPlay: typeof import('~icons/mdi/play')['default'] IconMdiPlay: typeof import('~icons/mdi/play')['default']
IconMdiRecord: typeof import('~icons/mdi/record')['default'] IconMdiRecord: typeof import('~icons/mdi/record')['default']
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
IconMdiSearch: typeof import('~icons/mdi/search')['default'] IconMdiSearch: typeof import('~icons/mdi/search')['default']
IconMdiSearchRound: typeof import('~icons/mdi/search-round')['default']
IconMdiVideo: typeof import('~icons/mdi/video')['default'] IconMdiVideo: typeof import('~icons/mdi/video')['default']
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default'] InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default'] IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']

View file

@ -10,7 +10,7 @@ const dockerRun = ref(
); );
const conversionResult = computed(() => const conversionResult = computed(() =>
withDefaultOnError(() => composerize(dockerRun.value), { yaml: '', messages: [] }), withDefaultOnError(() => composerize(dockerRun.value.trim()), { yaml: '', messages: [] }),
); );
const dockerCompose = computed(() => conversionResult.value.yaml); const dockerCompose = computed(() => conversionResult.value.yaml);
const notImplemented = computed(() => const notImplemented = computed(() =>
@ -30,15 +30,16 @@ const { download } = useDownloadFileFromBase64({ source: dockerComposeBase64, fi
<template> <template>
<div> <div>
<n-form-item label="Your docker run command:" :show-feedback="false"> <c-input-text
<n-input v-model:value="dockerRun"
v-model:value="dockerRun" label="Your docker run command:"
style="font-family: monospace" style="font-family: monospace"
type="textarea" multiline
placeholder="Your docker run command to convert..." raw-text
rows="3" monospace
/> placeholder="Your docker run command to convert..."
</n-form-item> rows="3"
/>
<n-divider /> <n-divider />

View file

@ -19,18 +19,13 @@ const decryptOutput = computed(() =>
<template> <template>
<c-card title="Encrypt"> <c-card title="Encrypt">
<div flex gap-3> <div flex gap-3>
<n-form-item label="Your text:" :show-feedback="false" flex-1> <c-input-text
<n-input v-model:value="cypherInput"
v-model:value="cypherInput" label="Your text:"
type="textarea" placeholder="The string to cypher"
placeholder="The string to cypher" rows="4"
:autosize="{ minRows: 4 }" multiline raw-text monospace autosize flex-1
autocomplete="off" />
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
</n-form-item>
<div flex flex-1 flex-col gap-2> <div flex flex-1 flex-col gap-2>
<c-input-text v-model:value="cypherSecret" label="Your secret key:" clearable raw-text /> <c-input-text v-model:value="cypherSecret" label="Your secret key:" clearable raw-text />
@ -42,34 +37,23 @@ const decryptOutput = computed(() =>
</n-form-item> </n-form-item>
</div> </div>
</div> </div>
<n-form-item label="Your text encrypted:" :show-feedback="false" mt-5> <c-input-text
<n-input label="Your text encrypted:"
:value="cypherOutput" :value="cypherOutput"
type="textarea" rows="3"
placeholder="Your string hash" placeholder="Your string hash"
:autosize="{ minRows: 2 }" multiline monospace readonly autosize mt-5
readonly />
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
</n-form-item>
</c-card> </c-card>
<c-card title="Decrypt"> <c-card title="Decrypt">
<div flex gap-3> <div flex gap-3>
<n-form-item label="Your encrypted text:" :show-feedback="false" flex-1> <c-input-text
<n-input v-model:value="decryptInput"
v-model:value="decryptInput" label="Your encrypted text:"
type="textarea" placeholder="The string to cypher"
placeholder="The string to cypher" rows="4"
:autosize="{ minRows: 4 }" multiline raw-text monospace autosize flex-1
autocomplete="off" />
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
</n-form-item>
<div flex flex-1 flex-col gap-2> <div flex flex-1 flex-col gap-2>
<c-input-text v-model:value="decryptSecret" label="Your secret key:" clearable raw-text /> <c-input-text v-model:value="decryptSecret" label="Your secret key:" clearable raw-text />
@ -81,18 +65,12 @@ const decryptOutput = computed(() =>
</n-form-item> </n-form-item>
</div> </div>
</div> </div>
<n-form-item label="Your decrypted text:" :show-feedback="false" mt-5> <c-input-text
<n-input label="Your decrypted text:"
:value="decryptOutput" :value="decryptOutput"
type="textarea" placeholder="Your string hash"
placeholder="Your string hash" rows="3"
:autosize="{ minRows: 2 }" multiline monospace readonly autosize mt-5
readonly />
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/>
</n-form-item>
</c-card> </c-card>
</template> </template>

View file

@ -37,7 +37,7 @@ const hashText = (algo: AlgoNames, value: string) => formatWithEncoding(algos[al
<template> <template>
<div> <div>
<c-card> <c-card>
<n-input v-model:value="clearText" type="textarea" placeholder="Your string to hash..." rows="3" /> <c-input-text v-model:value="clearText" multiline raw-text placeholder="Your string to hash..." rows="3" autosize autofocus label="Your text to hash:" />
<n-divider /> <n-divider />

View file

@ -46,13 +46,10 @@ const { copy } = useCopy({ source: hmac });
</script> </script>
<template> <template>
<div> <div flex flex-col gap-4>
<n-form-item label="Plain text to compute the hash"> <c-input-text v-model:value="plainText" multiline raw-text placeholder="Plain text to compute the hash..." rows="3" autosize autofocus label="Plain text to compute the hash" />
<n-input v-model:value="plainText" type="textarea" placeholder="Enter the text to compute the hash..." /> <c-input-text v-model:value="secret" raw-text placeholder="Enter the secret key..." label="Secret key" clearable />
</n-form-item>
<n-form-item label="Secret key">
<n-input v-model:value="secret" placeholder="Enter the secret key..." />
</n-form-item>
<div flex gap-2> <div flex gap-2>
<n-form-item label="Hashing function" flex-1> <n-form-item label="Hashing function" flex-1>
<n-select <n-select
@ -86,9 +83,7 @@ const { copy } = useCopy({ source: hmac });
/> />
</n-form-item> </n-form-item>
</div> </div>
<n-form-item label="HMAC of your text"> <input-copyable v-model:value="hmac" type="textarea" placeholder="The result of the HMAC..." label="HMAC of your text" />
<n-input readonly :value="hmac" type="textarea" placeholder="The result of the HMAC..." />
</n-form-item>
<div flex justify-center> <div flex justify-center>
<c-button @click="copy()"> <c-button @click="copy()">
Copy HMAC Copy HMAC

View file

@ -7,7 +7,7 @@ const escapeInput = ref('<title>IT Tool</title>');
const escapeOutput = computed(() => escape(escapeInput.value)); const escapeOutput = computed(() => escape(escapeInput.value));
const { copy: copyEscaped } = useCopy({ source: escapeOutput }); const { copy: copyEscaped } = useCopy({ source: escapeOutput });
const unescapeInput = ref('&lt;title&gt;IT Tool&lt;/title'); const unescapeInput = ref('&lt;title&gt;IT Tool&lt;/title&gt;');
const unescapeOutput = computed(() => unescape(unescapeInput.value)); const unescapeOutput = computed(() => unescape(unescapeInput.value));
const { copy: copyUnescaped } = useCopy({ source: unescapeOutput }); const { copy: copyUnescaped } = useCopy({ source: unescapeOutput });
</script> </script>
@ -15,21 +15,24 @@ const { copy: copyUnescaped } = useCopy({ source: unescapeOutput });
<template> <template>
<c-card title="Escape html entities"> <c-card title="Escape html entities">
<n-form-item label="Your string :"> <n-form-item label="Your string :">
<n-input <c-input-text
v-model:value="escapeInput" v-model:value="escapeInput"
type="textarea" multiline
placeholder="The string to escape" placeholder="The string to escape"
:autosize="{ minRows: 2 }" rows="3"
autosize
raw-text
/> />
</n-form-item> </n-form-item>
<n-form-item label="Your string escaped :"> <n-form-item label="Your string escaped :">
<n-input <c-input-text
type="textarea" multiline
readonly readonly
placeholder="Your string escaped" placeholder="Your string escaped"
:value="escapeOutput" :value="escapeOutput"
:autosize="{ minRows: 2 }" rows="3"
autosize
/> />
</n-form-item> </n-form-item>
@ -41,21 +44,24 @@ const { copy: copyUnescaped } = useCopy({ source: unescapeOutput });
</c-card> </c-card>
<c-card title="Unescape html entities"> <c-card title="Unescape html entities">
<n-form-item label="Your escaped string :"> <n-form-item label="Your escaped string :">
<n-input <c-input-text
v-model:value="unescapeInput" v-model:value="unescapeInput"
type="textarea" multiline
placeholder="The string to unescape" placeholder="The string to unescape"
:autosize="{ minRows: 2 }" rows="3"
autosize
raw-text
/> />
</n-form-item> </n-form-item>
<n-form-item label="Your string unescaped :"> <n-form-item label="Your string unescaped :">
<n-input <c-input-text
:value="unescapeOutput" :value="unescapeOutput"
type="textarea" multiline
readonly readonly
placeholder="Your string unescaped" placeholder="Your string unescaped"
:autosize="{ minRows: 2 }" rows="3"
autosize
/> />
</n-form-item> </n-form-item>

View file

@ -1,5 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import { SearchRound } from '@vicons/material';
import { codesByCategories } from './http-status-codes.constants'; import { codesByCategories } from './http-status-codes.constants';
import { useFuzzySearch } from '@/composable/fuzzySearch'; import { useFuzzySearch } from '@/composable/fuzzySearch';
@ -24,33 +23,24 @@ const codesByCategoryFiltered = computed(() => {
<template> <template>
<div> <div>
<n-form-item :show-label="false"> <c-input-text
<n-input v-model:value="search"
v-model:value="search" placeholder="Search http status..."
placeholder="Search http status..." autofocus raw-text mb-10
size="large" />
autofocus
mb-10
autocomplete="off"
autocorrect="off"
autocapitalize="off"
>
<template #prefix>
<n-icon :component="SearchRound" />
</template>
</n-input>
</n-form-item>
<div v-for="{ codes, category } of codesByCategoryFiltered" :key="category" mb-8> <div v-for="{ codes, category } of codesByCategoryFiltered" :key="category" mb-8>
<n-h2> {{ category }} </n-h2> <div mb-2 text-xl>
{{ category }}
</div>
<c-card v-for="{ code, description, name, type } of codes" :key="code" mb-2> <c-card v-for="{ code, description, name, type } of codes" :key="code" mb-2>
<n-text strong block text-lg> <div text-lg font-bold>
{{ code }} {{ name }} {{ code }} {{ name }}
</n-text> </div>
<n-text block depth="3"> <div op-70>
{{ description }} {{ type !== 'HTTP' ? `For ${type}.` : '' }} {{ description }} {{ type !== 'HTTP' ? `For ${type}.` : '' }}
</n-text> </div>
</c-card> </c-card>
</div> </div>
</div> </div>

View file

@ -1,11 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import InputCopyable from '../../components/InputCopyable.vue'; import InputCopyable from '../../components/InputCopyable.vue';
import { convertBase } from './integer-base-converter.model'; import { convertBase } from './integer-base-converter.model';
import { useStyleStore } from '@/stores/style.store';
import { getErrorMessageIfThrows } from '@/utils/error'; import { getErrorMessageIfThrows } from '@/utils/error';
const styleStore = useStyleStore();
const inputProps = { const inputProps = {
'labelPosition': 'left', 'labelPosition': 'left',
'labelWidth': '170px', 'labelWidth': '170px',
@ -37,31 +34,11 @@ const error = computed(() =>
<template> <template>
<div> <div>
<c-card> <c-card>
<div v-if="styleStore.isSmallScreen"> <c-input-text v-model:value="input" label="Input number" placeholder="Put your number here (ex: 42)" label-position="left" label-width="110px" mb-2 label-align="right" />
<n-input-group>
<n-input-group-label style="flex: 0 0 120px">
Input number:
</n-input-group-label>
<n-input v-model:value="input" w-full :status="error ? 'error' : undefined" />
</n-input-group>
<n-input-group>
<n-input-group-label style="flex: 0 0 120px">
Input base:
</n-input-group-label>
<n-input-number v-model:value="inputBase" max="64" min="2" w-full />
</n-input-group>
</div>
<n-input-group v-else> <n-form-item label="Input base" label-placement="left" label-width="110" :show-feedback="false">
<n-input-group-label style="flex: 0 0 120px"> <n-input-number v-model:value="inputBase" max="64" min="2" placeholder="Put your input base here (ex: 10)" w-full />
Input number: </n-form-item>
</n-input-group-label>
<n-input v-model:value="input" :status="error ? 'error' : undefined" />
<n-input-group-label style="flex: 0 0 120px">
Input base:
</n-input-group-label>
<n-input-number v-model:value="inputBase" max="64" min="2" />
</n-input-group>
<n-alert v-if="error" style="margin-top: 25px" type="error"> <n-alert v-if="error" style="margin-top: 25px" type="error">
{{ error }} {{ error }}

View file

@ -30,9 +30,7 @@ const validation = useValidation({
<template> <template>
<c-card> <c-card>
<n-form-item label="JWT to decode" :feedback="validation.message" :validation-status="validation.status"> <c-input-text v-model:value="rawJwt" label="JWT to decode" :validation="validation" placeholder="Put your token here..." rows="5" multiline raw-text autofocus mb-3 />
<n-input v-model:value="rawJwt" type="textarea" placeholder="Put your token here..." rows="5" />
</n-form-item>
<n-table v-if="validation.isValid"> <n-table v-if="validation.isValid">
<tbody> <tbody>

View file

@ -39,7 +39,7 @@ const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to
<n-switch v-model:value="asHTML" /> <n-switch v-model:value="asHTML" />
</n-form-item> </n-form-item>
<n-input :value="loremIpsumText" type="textarea" placeholder="Your lorem ipsum..." readonly autosize mt-5 /> <c-input-text :value="loremIpsumText" multiline placeholder="Your lorem ipsum..." readonly mt-5 rows="5" />
<div mt-5 flex justify-center> <div mt-5 flex justify-center>
<c-button autofocus @click="copy"> <c-button autofocus @click="copy">

View file

@ -10,16 +10,12 @@ const result = computed(() => withDefaultOnError(() => evaluate(expression.value
<template> <template>
<div> <div>
<n-input <c-input-text
v-model:value="expression" v-model:value="expression"
rows="1" rows="1"
type="textarea" multiline
placeholder="Your math expression (ex: 2*sqrt(6) )..." placeholder="Your math expression (ex: 2*sqrt(6) )..."
size="large" raw-text
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
/> />
<c-card v-if="result !== ''" title="Result " mt-5> <c-card v-if="result !== ''" title="Result " mt-5>

View file

@ -27,15 +27,18 @@ const { download } = useDownloadFileFromBase64({ source: qrcode, filename: 'qr-c
<c-card> <c-card>
<n-grid x-gap="12" y-gap="12" cols="1 600:3"> <n-grid x-gap="12" y-gap="12" cols="1 600:3">
<n-gi span="2"> <n-gi span="2">
<c-input-text
v-model:value="text"
label-position="left"
label-width="130px"
label-align="right"
label="Text:"
multiline
rows="1"
placeholder="Your link or text..."
mb-6
/>
<n-form label-width="130" label-placement="left"> <n-form label-width="130" label-placement="left">
<n-form-item label="Text:">
<n-input
v-model:value="text"
type="textarea"
:autosize="{ minRows: 1 }"
placeholder="Your link or text..."
/>
</n-form-item>
<n-form-item label="Foreground color:"> <n-form-item label="Foreground color:">
<n-color-picker v-model:value="foreground" :modes="['hex']" /> <n-color-picker v-model:value="foreground" :modes="['hex']" />
</n-form-item> </n-form-item>

View file

@ -10,18 +10,9 @@ const { copy } = useCopy({ source: slug, text: 'Slug copied to clipboard' });
<template> <template>
<div> <div>
<n-form-item label="Your string to slugify"> <c-input-text v-model:value="input" multiline placeholder="Put your string here (ex: My file path)" label="Your string to slugify" autofocus raw-text mb-5 />
<n-input v-model:value="input" type="textarea" placeholder="Put your string here (ex: My file path)" />
</n-form-item>
<n-form-item label="Your slug"> <c-input-text :value="slug" multiline readonly placeholder="You slug will be generated here (ex: my-file-path)" label="Your slug" mb-5 />
<n-input
:value="slug"
type="textarea"
readonly
placeholder="You slug will be generated here (ex: my-file-path)"
/>
</n-form-item>
<div flex justify-center> <div flex justify-center>
<c-button :disabled="slug.length === 0" @click="copy"> <c-button :disabled="slug.length === 0" @click="copy">

View file

@ -7,7 +7,7 @@ const text = ref('');
<template> <template>
<c-card> <c-card>
<n-input v-model:value="text" type="textarea" placeholder="Your text..." rows="5" /> <c-input-text v-model:value="text" multiline placeholder="Your text..." rows="5" />
<div mt-5 flex> <div mt-5 flex>
<n-statistic label="Character count" :value="text.length" flex-1 /> <n-statistic label="Character count" :value="text.length" flex-1 />

View file

@ -55,17 +55,14 @@ const { copy } = useCopy({ source: token, text: 'Token copied to the clipboard'
<n-slider v-model:value="length" :step="1" :min="1" :max="512" /> <n-slider v-model:value="length" :step="1" :min="1" :max="512" />
</n-form-item> </n-form-item>
<n-input <c-input-text
v-model:value="token" v-model:value="token"
style="text-align: center" multiline
type="textarea"
placeholder="The token..." placeholder="The token..."
:autosize="{ minRows: 1 }"
readonly readonly
autocomplete="off" rows="3"
autocorrect="off" autosize
autocapitalize="off" class="token-display"
spellcheck="false"
/> />
<div mt-5 flex justify-center gap-3> <div mt-5 flex justify-center gap-3>
@ -79,3 +76,11 @@ const { copy } = useCopy({ source: token, text: 'Token copied to the clipboard'
</c-card> </c-card>
</div> </div>
</template> </template>
<style scoped lang="less">
::v-deep(.token-display) {
textarea {
text-align: center;
}
}
</style>

View file

@ -37,28 +37,27 @@ const { copy: copyDecoded } = useCopy({ source: decodeOutput, text: 'Decoded str
<template> <template>
<c-card title="Encode"> <c-card title="Encode">
<n-form-item <c-input-text
v-model:value="encodeInput"
label="Your string :" label="Your string :"
:feedback="encodedValidation.message" :validation="encodedValidation"
:validation-status="encodedValidation.status" multiline
> autosize
<n-input placeholder="The string to encode"
v-model:value="encodeInput" rows="2"
type="textarea" mb-3
placeholder="The string to encode" />
:autosize="{ minRows: 2 }"
/>
</n-form-item>
<n-form-item label="Your string encoded :"> <c-input-text
<n-input label="Your string encoded :"
:value="encodeOutput" :value="encodeOutput"
type="textarea" multiline
readonly autosize
placeholder="Your string encoded" readonly
:autosize="{ minRows: 2 }" placeholder="Your string encoded"
/> rows="2"
</n-form-item> mb-3
/>
<div flex justify-center> <div flex justify-center>
<c-button @click="copyEncoded"> <c-button @click="copyEncoded">
@ -67,28 +66,27 @@ const { copy: copyDecoded } = useCopy({ source: decodeOutput, text: 'Decoded str
</div> </div>
</c-card> </c-card>
<c-card title="Decode"> <c-card title="Decode">
<n-form-item <c-input-text
v-model:value="decodeInput"
label="Your encoded string :" label="Your encoded string :"
:feedback="decodeValidation.message" :validation="decodeValidation"
:validation-status="decodeValidation.status" multiline
> autosize
<n-input placeholder="The string to decode"
v-model:value="decodeInput" rows="2"
type="textarea" mb-3
placeholder="The string to decode" />
:autosize="{ minRows: 2 }"
/>
</n-form-item>
<n-form-item label="Your string decoded :"> <c-input-text
<n-input label="Your string decoded :"
:value="decodeOutput" :value="decodeOutput"
type="textarea" multiline
readonly autosize
placeholder="Your string decoded" readonly
:autosize="{ minRows: 2 }" placeholder="Your string decoded"
/> rows="2"
</n-form-item> mb-3
/>
<div flex justify-center> <div flex justify-center>
<c-button @click="copyDecoded"> <c-button @click="copyDecoded">

View file

@ -103,15 +103,18 @@ const sections: UserAgentResultSection[] = [
<template> <template>
<div> <div>
<n-form-item label="User agent string"> <c-input-text
<n-input v-model:value="ua"
v-model:value="ua" label="User agent string"
type="textarea" multiline
placeholder="Put your user-agent here..." placeholder="Put your user-agent here..."
clearable clearable
:autosize="{ minRows: 2 }" raw-text
/> rows="2"
</n-form-item> autosize
monospace
mb-3
/>
<UserAgentResultCards :user-agent-info="userAgentInfo" :sections="sections" /> <UserAgentResultCards :user-agent-info="userAgentInfo" :sections="sections" />
</div> </div>

View file

@ -19,18 +19,18 @@ const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard'
<n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" /> <n-input-number v-model:value="count" :min="1" :max="50" placeholder="UUID quantity" />
</div> </div>
<n-input <c-input-text
style="text-align: center; font-family: monospace" style="text-align: center; font-family: monospace"
:value="uuids" :value="uuids"
type="textarea" multiline
placeholder="Your uuids" placeholder="Your uuids"
:autosize="{ minRows: 1 }" autosize
rows="1"
readonly readonly
autocomplete="off" raw-text
autocorrect="off" monospace
autocapitalize="off"
spellcheck="false"
my-3 my-3
class="uuid-display"
/> />
<div flex justify-center gap-3> <div flex justify-center gap-3>
@ -43,3 +43,11 @@ const { copy } = useCopy({ source: uuids, text: 'UUIDs copied to the clipboard'
</div> </div>
</div> </div>
</template> </template>
<style scoped lang="less">
::v-deep(.uuid-display) {
textarea {
text-align: center;
}
}
</style>

View file

@ -66,11 +66,14 @@ const validation = useValidation({
mb-2 mb-2
/> />
<c-input-text v-model:value="valueLong" multiline autosize mb-2 rows="5" />
<c-input-text <c-input-text
value="Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum, est modi iusto repellendus fuga accusantium atque at magnam aliquam eum explicabo vero quia, nobis quasi quis! Earum amet quam a?" value="Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorum, est modi iusto repellendus fuga accusantium atque at magnam aliquam eum explicabo vero quia, nobis quasi quis! Earum amet quam a?"
multiline multiline
clearable clearable
/> />
<h2>Autosize</h2>
<c-input-text v-model:value="value" label="Autosize" rows="1" multiline autosize mb-2 />
<c-input-text v-model:value="valueLong" label="Autosize monospace" rows="1" multiline autosize monospace mb-2 />
</template> </template>

View file

@ -82,12 +82,12 @@ const inputRef = ref<HTMLInputElement>();
const inputWrapperRef = ref<HTMLElement>(); const inputWrapperRef = ref<HTMLElement>();
watch( watch(
value, [value, autosize, multiline, inputWrapperRef, textareaRef],
() => { () => nextTick(() => {
if (props.multiline && autosize.value) { if (props.multiline && autosize.value) {
resizeTextarea(); resizeTextarea();
} }
}, }),
{ immediate: true }, { immediate: true },
); );
@ -96,9 +96,9 @@ function resizeTextarea() {
return; return;
} }
const { scrollHeight } = textareaRef.value; const scrollHeight = textareaRef.value.scrollHeight + 2;
inputWrapperRef.value.style.height = `${scrollHeight + 2}px`; inputWrapperRef.value.style.height = `${scrollHeight}px`;
} }
const htmlInputType = computed(() => { const htmlInputType = computed(() => {