feat: enhance DataDisplay component to support array values and clickable labels
This commit is contained in:
parent
650c4e2af7
commit
7071ecbf5c
1 changed files with 32 additions and 3 deletions
|
|
@ -1,13 +1,16 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Icon } from '@iconify/vue/dist/iconify.js';
|
import { Icon } from '@iconify/vue/dist/iconify.js';
|
||||||
|
|
||||||
|
defineEmits<{ (e: 'labelClick', value: string, index: number): void }>();
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
label: string;
|
label: string;
|
||||||
value?: string;
|
value?: string | string[];
|
||||||
icon?: string;
|
icon?: string;
|
||||||
iconSize?: string;
|
iconSize?: string;
|
||||||
tooltip?: boolean;
|
tooltip?: boolean;
|
||||||
|
clickable?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
label: '-',
|
label: '-',
|
||||||
|
|
@ -30,10 +33,36 @@ withDefaults(
|
||||||
</span>
|
</span>
|
||||||
<span class="col-12 ellipsis">
|
<span class="col-12 ellipsis">
|
||||||
<slot name="value">
|
<slot name="value">
|
||||||
|
<span
|
||||||
|
:class="{ 'link cursor-pointer': clickable }"
|
||||||
|
v-if="typeof value === 'string'"
|
||||||
|
@click="$emit('labelClick', value, null)"
|
||||||
|
>
|
||||||
{{ value }}
|
{{ value }}
|
||||||
<q-tooltip v-if="tooltip" :delay="500">{{ value }}</q-tooltip>
|
<q-tooltip v-if="tooltip" :delay="500">{{ value }}</q-tooltip>
|
||||||
|
</span>
|
||||||
|
<span v-else :class="{ 'link cursor-pointer': clickable }">
|
||||||
|
<span
|
||||||
|
v-for="(item, index) in value"
|
||||||
|
:key="index"
|
||||||
|
@click="$emit('labelClick', item, index)"
|
||||||
|
class="link cursor-pointer"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
<span v-if="index < value.length - 1">, </span>
|
||||||
|
|
||||||
|
<q-tooltip v-if="tooltip" :delay="500">{{ item }}</q-tooltip>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</article>
|
</article>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.link {
|
||||||
|
color: hsl(var(--info-bg));
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue