2023-05-07 11:29:22 +02:00
|
|
|
<template>
|
|
|
|
<div style="flex: 0 0 100%">
|
2023-05-27 17:36:15 +02:00
|
|
|
<div style="margin: 0 auto; max-width: 600px">
|
2023-05-07 11:29:22 +02:00
|
|
|
<c-card>
|
|
|
|
<div flex>
|
|
|
|
<div>
|
|
|
|
<n-form-item label="Trim list items" label-placement="left" label-width="150" :show-feedback="false" mb-2>
|
|
|
|
<n-switch v-model:value="conversionConfig.trimItems" />
|
|
|
|
</n-form-item>
|
|
|
|
<n-form-item label="Remove duplicates" label-placement="left" label-width="150" :show-feedback="false" mb-2>
|
|
|
|
<n-switch v-model:value="conversionConfig.removeDuplicates" data-test-id="removeDuplicates" />
|
|
|
|
</n-form-item>
|
|
|
|
<n-form-item
|
|
|
|
label="Convert to lowercase"
|
|
|
|
label-placement="left"
|
|
|
|
label-width="150"
|
|
|
|
:show-feedback="false"
|
|
|
|
mb-2
|
|
|
|
>
|
|
|
|
<n-switch v-model:value="conversionConfig.lowerCase" />
|
|
|
|
</n-form-item>
|
|
|
|
<n-form-item label="Keep line breaks" label-placement="left" label-width="150" :show-feedback="false" mb-2>
|
|
|
|
<n-switch v-model:value="conversionConfig.keepLineBreaks" />
|
|
|
|
</n-form-item>
|
|
|
|
</div>
|
|
|
|
<div flex-1>
|
|
|
|
<n-form-item label="Sort list" label-placement="left" label-width="120" :show-feedback="false" mb-2>
|
|
|
|
<n-select
|
|
|
|
v-model:value="conversionConfig.sortList"
|
|
|
|
:options="sortOrderOptions"
|
|
|
|
clearable
|
|
|
|
w-full
|
|
|
|
:disabled="conversionConfig.reverseList"
|
|
|
|
data-test-id="sortList"
|
|
|
|
placeholder="Sort alphabetically"
|
|
|
|
/>
|
|
|
|
</n-form-item>
|
|
|
|
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="conversionConfig.separator"
|
|
|
|
label="Separator"
|
|
|
|
label-position="left"
|
|
|
|
label-width="120px"
|
|
|
|
label-align="right"
|
|
|
|
mb-2
|
|
|
|
placeholder=","
|
|
|
|
/>
|
2023-05-07 11:29:22 +02:00
|
|
|
|
|
|
|
<n-form-item label="Wrap item" label-placement="left" label-width="120" :show-feedback="false" mb-2>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="conversionConfig.itemPrefix"
|
|
|
|
placeholder="Item prefix"
|
|
|
|
test-id="itemPrefix"
|
|
|
|
/>
|
|
|
|
<c-input-text
|
|
|
|
v-model:value="conversionConfig.itemSuffix"
|
|
|
|
placeholder="Item suffix"
|
|
|
|
test-id="itemSuffix"
|
|
|
|
/>
|
2023-05-07 11:29:22 +02:00
|
|
|
</n-form-item>
|
|
|
|
<n-form-item label="Wrap list" label-placement="left" label-width="120" :show-feedback="false" mb-2>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="conversionConfig.listPrefix"
|
|
|
|
placeholder="List prefix"
|
|
|
|
test-id="listPrefix"
|
|
|
|
/>
|
|
|
|
<c-input-text
|
|
|
|
v-model:value="conversionConfig.listSuffix"
|
|
|
|
placeholder="List suffix"
|
|
|
|
test-id="listSuffix"
|
|
|
|
/>
|
2023-05-07 11:29:22 +02:00
|
|
|
</n-form-item>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</c-card>
|
2023-05-27 17:36:15 +02:00
|
|
|
</div>
|
2023-05-07 11:29:22 +02:00
|
|
|
</div>
|
|
|
|
<format-transformer
|
|
|
|
input-label="Your input data"
|
|
|
|
input-placeholder="Paste your input data here..."
|
|
|
|
output-label="Your transformed data"
|
|
|
|
:transformer="transformer"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { useStorage } from '@vueuse/core';
|
|
|
|
import { convert } from './list-converter.models';
|
|
|
|
import type { ConvertOptions } from './list-converter.types';
|
|
|
|
|
|
|
|
const sortOrderOptions = [
|
|
|
|
{
|
|
|
|
label: 'Sort ascending',
|
|
|
|
value: 'asc',
|
|
|
|
disabled: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Sort descending',
|
|
|
|
value: 'desc',
|
|
|
|
disabled: false,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const conversionConfig = useStorage<ConvertOptions>('list-converter:conversionConfig', {
|
|
|
|
lowerCase: false,
|
|
|
|
trimItems: true,
|
|
|
|
removeDuplicates: true,
|
|
|
|
keepLineBreaks: false,
|
|
|
|
itemPrefix: '',
|
|
|
|
itemSuffix: '',
|
|
|
|
listPrefix: '',
|
|
|
|
listSuffix: '',
|
|
|
|
reverseList: false,
|
|
|
|
sortList: null,
|
|
|
|
separator: ', ',
|
|
|
|
});
|
|
|
|
|
|
|
|
const transformer = (value: string) => {
|
|
|
|
return convert(value, conversionConfig.value);
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped></style>
|