2025-05-27 15:29:57 +02:00
|
|
|
<template>
|
|
|
|
|
<div
|
|
|
|
|
id="selector-dropdown"
|
|
|
|
|
class="flex flex-col"
|
2025-06-05 18:41:01 +02:00
|
|
|
:style="'--image: url(\'' + getFrontViewUrl(currentValue) + '\')'"
|
2025-05-27 15:29:57 +02:00
|
|
|
>
|
2025-06-05 18:41:01 +02:00
|
|
|
<label for="selector-select" class="text-sm">{{ label }}</label>
|
|
|
|
|
|
2025-06-05 18:53:42 +02:00
|
|
|
<Select
|
2025-05-27 15:29:57 +02:00
|
|
|
id="selector-select"
|
2025-06-05 18:41:01 +02:00
|
|
|
v-model="currentValue"
|
2025-05-27 15:29:57 +02:00
|
|
|
:options="items"
|
|
|
|
|
optionLabel="title"
|
|
|
|
|
class="font-serif"
|
|
|
|
|
data-icon="chevron-single-down"
|
|
|
|
|
checkmark
|
2025-05-28 15:11:00 +02:00
|
|
|
>
|
|
|
|
|
<template #value="slotProps">
|
2025-06-05 18:53:42 +02:00
|
|
|
<p v-if="currentValue && !Array.isArray(currentValue)">
|
2025-06-05 18:41:01 +02:00
|
|
|
{{ currentValue.title }}
|
|
|
|
|
</p>
|
|
|
|
|
<p v-else>Select...</p>
|
2025-05-28 15:11:00 +02:00
|
|
|
</template>
|
2025-06-05 18:41:01 +02:00
|
|
|
|
2025-05-28 15:11:00 +02:00
|
|
|
<template #option="slotProps">
|
2025-06-05 18:41:01 +02:00
|
|
|
<img
|
|
|
|
|
alt=""
|
|
|
|
|
:src="getFrontViewUrl(slotProps.option)"
|
|
|
|
|
width="28"
|
|
|
|
|
height="28"
|
|
|
|
|
/>
|
2025-05-28 16:08:01 +02:00
|
|
|
<p>{{ slotProps.option.title }}</p>
|
2025-05-28 15:11:00 +02:00
|
|
|
</template>
|
2025-06-05 18:53:42 +02:00
|
|
|
</Select>
|
2025-05-27 15:29:57 +02:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref, watch } from 'vue';
|
2025-06-05 18:41:01 +02:00
|
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
import { useDialogStore } from '../stores/dialog';
|
2025-05-27 15:29:57 +02:00
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
const { items, label, isCompareModeEnabled } = defineProps({
|
2025-05-27 15:29:57 +02:00
|
|
|
label: String,
|
|
|
|
|
items: Array,
|
2025-06-05 18:41:01 +02:00
|
|
|
isCompareModeEnabled: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
},
|
2025-05-27 15:29:57 +02:00
|
|
|
});
|
|
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
const emit = defineEmits(['update:selectedItems']);
|
|
|
|
|
|
|
|
|
|
const currentValue = ref(isCompareModeEnabled ? [] : null);
|
|
|
|
|
|
|
|
|
|
const { activeTracks } = storeToRefs(useDialogStore());
|
2025-05-27 15:29:57 +02:00
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
watch(currentValue, (newValue) => {
|
|
|
|
|
if (
|
|
|
|
|
newValue !== null &&
|
|
|
|
|
(Array.isArray(newValue) ? newValue.length > 0 : true)
|
|
|
|
|
) {
|
|
|
|
|
changeCurrent(newValue);
|
|
|
|
|
}
|
2025-05-27 15:29:57 +02:00
|
|
|
});
|
|
|
|
|
|
2025-06-05 18:41:01 +02:00
|
|
|
watch(activeTracks, (newValue) => {
|
|
|
|
|
if (newValue[newValue.length - 1] !== currentValue.value) {
|
|
|
|
|
currentValue.value = isCompareModeEnabled ? [] : null;
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-27 15:29:57 +02:00
|
|
|
|
|
|
|
|
function changeCurrent(item) {
|
|
|
|
|
emit('update:selectedItems', item);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-28 15:11:00 +02:00
|
|
|
function getFrontViewUrl(item) {
|
2025-06-05 18:41:01 +02:00
|
|
|
if (!item) return '';
|
|
|
|
|
if (Array.isArray(item)) {
|
|
|
|
|
return item.length > 0 ? getFrontViewUrl(item[0]) : '';
|
|
|
|
|
}
|
2025-05-28 15:11:00 +02:00
|
|
|
if (item.files.length > 1) {
|
2025-06-05 18:41:01 +02:00
|
|
|
return item.files[7]?.url || item.files[0].url;
|
2025-05-27 15:29:57 +02:00
|
|
|
} else {
|
2025-05-28 15:11:00 +02:00
|
|
|
return item.files[0].url;
|
2025-05-27 15:29:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
#selector-dropdown {
|
2025-05-28 16:08:01 +02:00
|
|
|
--selector-width: fit-content;
|
2025-05-27 15:29:57 +02:00
|
|
|
--row-gap: 0;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
position: relative;
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
border-radius: var(--rounded-lg);
|
|
|
|
|
height: 3.75rem;
|
2025-05-28 16:08:01 +02:00
|
|
|
width: var(--selector-width, 20rem);
|
|
|
|
|
max-width: 20rem;
|
2025-05-27 15:29:57 +02:00
|
|
|
padding: var(--space-8) var(--space-48) var(--space-8) var(--space-64);
|
|
|
|
|
}
|
|
|
|
|
#selector-dropdown::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: var(--space-8);
|
|
|
|
|
width: 2.75rem;
|
|
|
|
|
height: 2.75rem;
|
|
|
|
|
border-radius: var(--rounded-md);
|
2025-05-28 16:08:01 +02:00
|
|
|
background-color: var(--dialog-inner-background, #f7f7f7);
|
2025-05-27 15:29:57 +02:00
|
|
|
background-image: var(--image);
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: cover;
|
|
|
|
|
background-position: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[role='combobox'],
|
|
|
|
|
#selector-select_list {
|
|
|
|
|
border: 1px solid var(--color-grey-200);
|
|
|
|
|
}
|
|
|
|
|
[role='combobox']:hover {
|
|
|
|
|
outline: 1px solid var(--color-grey-400);
|
|
|
|
|
border-color: var(--color-background);
|
|
|
|
|
}
|
|
|
|
|
[role='combobox'][aria-expanded='true'] {
|
|
|
|
|
outline: 2px solid var(--color-focus-ring);
|
|
|
|
|
outline-offset: -2px;
|
|
|
|
|
border-color: transparent;
|
|
|
|
|
}
|
|
|
|
|
#selector-select,
|
|
|
|
|
[role='combobox'] {
|
|
|
|
|
position: absolute;
|
|
|
|
|
inset: 0;
|
|
|
|
|
border-radius: inherit;
|
|
|
|
|
padding: 1.875rem var(--space-48) var(--space-8) var(--space-64);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Icon */
|
|
|
|
|
#selector-select svg {
|
|
|
|
|
display: none; /* Hide default component svg */
|
|
|
|
|
}
|
|
|
|
|
#selector-select[data-icon]::before {
|
|
|
|
|
--icon-color: var(--color-grey-700);
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: var(--space-8);
|
|
|
|
|
top: 0.625rem;
|
|
|
|
|
width: 2.5rem;
|
|
|
|
|
height: 2.5rem;
|
|
|
|
|
padding: 0.625rem;
|
|
|
|
|
}
|
|
|
|
|
#selector-dropdown label {
|
|
|
|
|
color: var(--color-grey-700);
|
|
|
|
|
letter-spacing: var(--tracking-wider);
|
2025-05-28 16:08:01 +02:00
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
height: 1lh;
|
|
|
|
|
padding-right: 1em;
|
2025-05-27 15:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Options */
|
|
|
|
|
#selector-select_list {
|
|
|
|
|
margin-top: var(--space-4);
|
|
|
|
|
border-radius: var(--rounded-md);
|
|
|
|
|
background: var(--color-background);
|
|
|
|
|
box-shadow: var(--shadow);
|
|
|
|
|
padding: var(--space-8);
|
|
|
|
|
}
|
|
|
|
|
#selector-select_list > * {
|
|
|
|
|
font-family: var(--font-serif);
|
|
|
|
|
padding: var(--space-8) var(--space-8) var(--space-8) var(--space-48);
|
|
|
|
|
border-radius: var(--rounded-sm);
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
height: 2.75rem;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
#selector-select_list > * + * {
|
|
|
|
|
margin-top: var(--space-4);
|
|
|
|
|
}
|
|
|
|
|
#selector-select_list > *::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: var(--space-8);
|
|
|
|
|
width: 1.75rem;
|
|
|
|
|
height: 1.75rem;
|
|
|
|
|
border-radius: var(--rounded-sm);
|
|
|
|
|
background-image: var(--image);
|
2025-05-28 16:08:01 +02:00
|
|
|
background-color: var(--dialog-inner-background, #f7f7f7);
|
2025-05-27 15:29:57 +02:00
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: cover;
|
|
|
|
|
background-position: center;
|
|
|
|
|
}
|
|
|
|
|
#selector-select_list > *:hover {
|
|
|
|
|
background-color: var(--color-grey-50);
|
|
|
|
|
}
|
|
|
|
|
#selector-select_list > *:focus,
|
|
|
|
|
#selector-select_list > *:focus-visible,
|
|
|
|
|
#selector-select_list > [data-p-focused='true'] {
|
|
|
|
|
outline: 2px solid var(--color-focus-ring);
|
|
|
|
|
}
|
|
|
|
|
/* Check */
|
|
|
|
|
#selector-select_list > * > svg {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0.875rem;
|
|
|
|
|
width: 1rem;
|
|
|
|
|
height: 1rem;
|
|
|
|
|
color: var(--color-grey-700);
|
|
|
|
|
}
|
2025-05-28 16:08:01 +02:00
|
|
|
#selector-select_list img {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0.5rem;
|
|
|
|
|
width: 1.75rem;
|
|
|
|
|
height: 1.75rem;
|
|
|
|
|
mix-blend-mode: multiply;
|
|
|
|
|
}
|
2025-06-05 18:41:01 +02:00
|
|
|
#selector-select_list [aria-selected='true'] img {
|
2025-05-28 16:08:01 +02:00
|
|
|
display: none;
|
|
|
|
|
}
|
2025-05-27 15:29:57 +02:00
|
|
|
</style>
|