TextFilter.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="flex min-h-56.5 flex-col justify-between">
  3. <div class="flex flex-col gap-2">
  4. <InputText
  5. v-model="model.value"
  6. fluid
  7. type="search"
  8. placeholder="Filter&hellip;"
  9. />
  10. <div class="w-full bg-primary-200 px-2 py-1">
  11. {{ matchMode }}
  12. </div>
  13. <SelectButton
  14. v-model="model.matchMode"
  15. :options="matchModeOptions"
  16. optionLabel="name"
  17. optionValue="value"
  18. dataKey="value"
  19. :pt="{
  20. root: `*:rounded-none *:not-last:border-r-0 *:first:rounded-s-md *:last:rounded-e-md
  21. *:focus-visible:relative *:focus-visible:z-10`,
  22. pcToggleButton: {
  23. root: `grow border-primary-200! bg-transparent! p-0! text-primary!
  24. hover:border-primary-300! hover:bg-primary-50! dark:border-primary-700!
  25. dark:hover:border-primary-600! dark:hover:bg-primary/5!
  26. p-checked:border-primary-400! p-checked:bg-primary-100!
  27. dark:p-checked:border-primary-500! dark:p-checked:bg-primary/15!`,
  28. content: 'px-0! py-0.5! p-checked:bg-transparent!'
  29. }
  30. }"
  31. >
  32. <!--suppress VueUnrecognizedSlot -->
  33. <template #option="slotProps">
  34. <Icon :name="slotProps.option.icon" />
  35. </template>
  36. </SelectButton>
  37. </div>
  38. <Button
  39. class="py-0.5!"
  40. variant="outlined"
  41. size="small"
  42. fluid
  43. :disabled="!hasFilter()"
  44. @click="resetFilter"
  45. >
  46. Clear
  47. </Button>
  48. </div>
  49. </template>
  50. <script setup>
  51. import { FilterMatchMode } from "@primevue/core/api"
  52. const model = defineModel()
  53. const props = defineProps({
  54. filterCallback: {
  55. type: Function,
  56. required: true
  57. },
  58. hasFilter: {
  59. type: Function,
  60. required: true
  61. },
  62. resetFilter: {
  63. type: Function,
  64. required: true
  65. }
  66. })
  67. const matchModeOptions = ref([
  68. {
  69. name: "Starts with",
  70. icon: "ph:arrow-line-left",
  71. value: FilterMatchMode.STARTS_WITH
  72. },
  73. {
  74. name: "Contains",
  75. icon: "ph:arrows-out-line-horizontal",
  76. value: FilterMatchMode.CONTAINS
  77. },
  78. {
  79. name: "Ends with",
  80. icon: "ph:arrow-line-right",
  81. value: FilterMatchMode.ENDS_WITH
  82. }
  83. ])
  84. const matchMode = ref("Contains")
  85. </script>
  86. <style scoped></style>