2023-04-10 16:34:10 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
import _ from 'lodash';
|
2023-05-28 23:13:24 +02:00
|
|
|
import type { UseValidationRule } from '@/composable/validation';
|
2023-05-15 00:41:45 +02:00
|
|
|
import CInputText from '@/ui/c-input-text/c-input-text.vue';
|
2023-04-10 16:34:10 +02:00
|
|
|
|
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
2023-05-28 23:13:24 +02:00
|
|
|
transformer?: (v: string) => string
|
|
|
|
inputValidationRules?: UseValidationRule<string>[]
|
|
|
|
inputLabel?: string
|
|
|
|
inputPlaceholder?: string
|
|
|
|
inputDefault?: string
|
|
|
|
outputLabel?: string
|
|
|
|
outputLanguage?: string
|
2023-04-10 16:34:10 +02:00
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
transformer: _.identity,
|
|
|
|
inputValidationRules: () => [],
|
|
|
|
inputLabel: 'Input',
|
|
|
|
inputDefault: '',
|
|
|
|
inputPlaceholder: 'Input...',
|
|
|
|
outputLabel: 'Output',
|
|
|
|
outputLanguage: '',
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-05-28 23:13:24 +02:00
|
|
|
const { transformer, inputValidationRules, inputLabel, outputLabel, outputLanguage, inputPlaceholder, inputDefault }
|
|
|
|
= toRefs(props);
|
2023-04-10 16:34:10 +02:00
|
|
|
|
2023-05-15 00:41:45 +02:00
|
|
|
const inputElement = ref<typeof CInputText>();
|
2023-04-10 16:34:10 +02:00
|
|
|
|
|
|
|
const input = ref(inputDefault.value);
|
|
|
|
const output = computed(() => transformer.value(input.value));
|
|
|
|
</script>
|
|
|
|
|
2023-05-28 23:13:24 +02:00
|
|
|
<template>
|
|
|
|
<CInputText
|
|
|
|
ref="inputElement"
|
|
|
|
v-model:value="input"
|
|
|
|
:placeholder="inputPlaceholder"
|
|
|
|
:label="inputLabel"
|
|
|
|
rows="20"
|
|
|
|
autosize
|
|
|
|
raw-text
|
|
|
|
multiline
|
|
|
|
test-id="input"
|
|
|
|
:validation-rules="inputValidationRules"
|
2023-06-23 16:51:52 +02:00
|
|
|
monospace
|
2023-05-28 23:13:24 +02:00
|
|
|
/>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div mb-5px>
|
|
|
|
{{ outputLabel }}
|
|
|
|
</div>
|
|
|
|
<textarea-copyable :value="output" :language="outputLanguage" :follow-height-of="inputElement?.inputWrapperRef" />
|
|
|
|
</div>
|
|
|
|
</template>
|