CommonSelect.story.vue 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { ref } from 'vue'
  4. import CommonSelect from './CommonSelect.vue'
  5. const options = [
  6. {
  7. value: 0,
  8. label: 'Item A',
  9. },
  10. {
  11. value: 1,
  12. label: 'Item B',
  13. },
  14. {
  15. value: 2,
  16. label: 'Item C',
  17. },
  18. ]
  19. const modelValue = ref()
  20. </script>
  21. <template>
  22. <Story>
  23. <Variant title="Default">
  24. <CommonSelect #default="{ open }" v-model="modelValue" :options="options">
  25. <button @click="open">Click Me!</button>
  26. <div>Selected: {{ modelValue }}</div>
  27. </CommonSelect>
  28. </Variant>
  29. <Variant title="Multiple">
  30. <CommonSelect
  31. #default="{ open }"
  32. v-model="modelValue"
  33. multiple
  34. :options="options"
  35. >
  36. <button @click="open">Click Me!</button>
  37. <div>Selected: {{ modelValue }}</div>
  38. </CommonSelect>
  39. </Variant>
  40. </Story>
  41. </template>