<template>
  <div class="text-center">
    <div v-if="useinput">
      <q-select
        :multiple="multiple"
        rounded
        outlined
        v-bind="$attrs"
        :input-class="myclass"
        :model-value="myvalue"
        :use-input="useinput"
        input-debounce="0"
        @new-value="newvaluefunc"
        new-value-mode="add-unique"
        :options="valori"
        :option-value="optval"
        :option-label="optlab"
        @update:model-value="changeval"
        :label="label"
        :dense="dense">
      </q-select>
    </div>
    <div v-else>
      <q-select
        :multiple="multiple"
        rounded
        outlined
        :dense="dense"
        :input-class="myclass"
        :model-value="myvalue"
        :options="valori"
        :option-value="optval"
        :option-label="optlab"
        @update:model-value="changeval"
        :label="label"
        emit-value
        options-selected-class="text-deep-orange"
        map-options
        v-bind="$attrs"
        style="min-width: 170px; max-width: 400px;">
        <template v-slot:option="scope">
          <q-item v-bind="scope.itemProps">
            <q-item-section avatar>
              <q-icon :name="scope.opt.icon ? scope.opt.icon : ''"/>
            </q-item-section>
            <q-item-section>
              <q-item-label>{{ scope.opt.descr }}</q-item-label>
            </q-item-section>
          </q-item>
        </template>

      </q-select>
    </div>
  </div>
</template>

<script lang="ts" src="./CMySelect.ts">
</script>

<style lang="scss" scoped>
@import './CMySelect.scss';
</style>
