mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-25 01:06:15 -04:00
feat(new tool): iban validation and parser (#591)
This commit is contained in:
parent
81bfe57cb8
commit
3a63837d3d
14 changed files with 278 additions and 1 deletions
9
src/ui/c-key-value-list/c-key-value-list.types.ts
Normal file
9
src/ui/c-key-value-list/c-key-value-list.types.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export interface CKeyValueListItem {
|
||||
label: string
|
||||
value: string | string[] | number | boolean | undefined | null
|
||||
hideOnNil?: boolean
|
||||
placeholder?: string
|
||||
showCopyButton?: boolean
|
||||
}
|
||||
|
||||
export type CKeyValueListItems = CKeyValueListItem[];
|
37
src/ui/c-key-value-list/c-key-value-list.vue
Normal file
37
src/ui/c-key-value-list/c-key-value-list.vue
Normal file
|
@ -0,0 +1,37 @@
|
|||
<script lang="ts" setup>
|
||||
import _ from 'lodash';
|
||||
import type { CKeyValueListItems } from './c-key-value-list.types';
|
||||
|
||||
const props = withDefaults(defineProps<{ items?: CKeyValueListItems }>(), { items: () => [] });
|
||||
const { items } = toRefs(props);
|
||||
|
||||
const formattedItems = computed(() => items.value.filter(item => !_.isNil(item.value) || !item.hideOnNil));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table border-collapse table-fixed>
|
||||
<tr v-for="item in formattedItems" :key="item.label">
|
||||
<td py-1 pr-2 text-right font-bold>
|
||||
{{ item.label }}
|
||||
</td>
|
||||
|
||||
<td v-if="_.isArray(item.value)">
|
||||
<div v-for="value in item.value" :key="value">
|
||||
<c-text-copyable :value="value" :show-icon="item.showCopyButton ?? true" />
|
||||
</div>
|
||||
</td>
|
||||
<td v-else-if="_.isBoolean(item.value)">
|
||||
<c-text-copyable :value="item.value ? 'true' : 'false'" :displayed-value="item.value ? 'Yes' : 'No'" :show-icon="item.showCopyButton ?? true" />
|
||||
</td>
|
||||
<td v-else-if="_.isNumber(item.value)" font-mono>
|
||||
<c-text-copyable :value="String(item.value)" :show-icon="item.showCopyButton ?? true" />
|
||||
</td>
|
||||
<td v-else-if="_.isNil(item.value) || item.value === ''" op-70>
|
||||
{{ item.placeholder ?? 'N/A' }}
|
||||
</td>
|
||||
<td v-else>
|
||||
<c-text-copyable :value="item.value" :show-icon="item.showCopyButton ?? true" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
3
src/ui/c-text-copyable/c-text-copyable.demo.vue
Normal file
3
src/ui/c-text-copyable/c-text-copyable.demo.vue
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template>
|
||||
<c-text-copyable value="value" displayed-value="displayedValue" />
|
||||
</template>
|
17
src/ui/c-text-copyable/c-text-copyable.vue
Normal file
17
src/ui/c-text-copyable/c-text-copyable.vue
Normal file
|
@ -0,0 +1,17 @@
|
|||
<script setup lang="ts">
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
const props = withDefaults(defineProps<{ value?: string; displayedValue?: string; showIcon?: boolean }>(), { value: '', displayedValue: undefined, showIcon: true });
|
||||
const { value, displayedValue, showIcon } = toRefs(props);
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-tooltip :tooltip="isJustCopied ? 'Copied!' : 'Copy to clipboard'" cursor-pointer @click="copy">
|
||||
<span flex items-center gap-2>
|
||||
{{ displayedValue ?? value }}
|
||||
<icon-mdi-content-copy v-if="showIcon" op-40 />
|
||||
</span>
|
||||
</c-tooltip>
|
||||
</template>
|
17
src/ui/c-tooltip/c-tooltip.demo.vue
Normal file
17
src/ui/c-tooltip/c-tooltip.demo.vue
Normal file
|
@ -0,0 +1,17 @@
|
|||
<template>
|
||||
<div>
|
||||
<c-tooltip>
|
||||
Hover me
|
||||
|
||||
<template #tooltip>
|
||||
Tooltip content
|
||||
</template>
|
||||
</c-tooltip>
|
||||
</div>
|
||||
|
||||
<div mt-5>
|
||||
<c-tooltip tooltip="Tooltip content">
|
||||
Hover me
|
||||
</c-tooltip>
|
||||
</div>
|
||||
</template>
|
27
src/ui/c-tooltip/c-tooltip.vue
Normal file
27
src/ui/c-tooltip/c-tooltip.vue
Normal file
|
@ -0,0 +1,27 @@
|
|||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{ tooltip?: string }>(), { tooltip: '' });
|
||||
const { tooltip } = toRefs(props);
|
||||
|
||||
const targetRef = ref();
|
||||
const isTargetHovered = useElementHover(targetRef);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative" inline-block>
|
||||
<div ref="targetRef">
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="absolute bottom-100% left-50% z-10 mb-5px whitespace-nowrap rounded bg-black px-12px py-6px text-sm text-white shadow-lg transition transition transition-duration-0.2s -translate-x-1/2"
|
||||
:class="{
|
||||
'op-0 scale-0': isTargetHovered === false,
|
||||
'op-100 scale-100': isTargetHovered,
|
||||
}"
|
||||
>
|
||||
<slot name="tooltip">
|
||||
{{ tooltip }}
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
Loading…
Add table
Add a link
Reference in a new issue