@saasmakers/ui 1.4.33 → 1.4.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,7 @@ const props = withDefaults(defineProps<Omit<FieldInput, 'modelValue'>>(), {
31
31
  const emit = defineEmits<{
32
32
  blur: [event: FocusEvent]
33
33
  focus: [event: FocusEvent]
34
+ keydown: [event: KeyboardEvent, value: string]
34
35
  keyup: [event: KeyboardEvent, value: string ]
35
36
  submit: [event: KeyboardEvent, value: string ]
36
37
  }>()
@@ -126,6 +127,12 @@ function onFieldKeyDown(event: KeyboardEvent) {
126
127
  return event.preventDefault()
127
128
  }
128
129
 
130
+ emit('keydown', event, value)
131
+ }
132
+
133
+ function onFieldKeyUp(event: KeyboardEvent) {
134
+ const value = (event.target as HTMLInputElement).value
135
+
129
136
  emit('keyup', event, value)
130
137
  }
131
138
 
@@ -202,6 +209,7 @@ defineExpose({ focus })
202
209
  @focus="onFieldFocus"
203
210
  @input="onFieldInput"
204
211
  @keydown="onFieldKeyDown"
212
+ @keyup="onFieldKeyUp"
205
213
  >
206
214
 
207
215
  <BaseSpinner
@@ -92,8 +92,10 @@ const filteredColumns = computed(() => {
92
92
  .filter(column => column.options.length > 0)
93
93
  })
94
94
 
95
- const hasFilteredResults = computed(() => {
96
- return filteredColumns.value.some(column => column.options.length > 0)
95
+ const firstFilteredOption = computed(() => {
96
+ const column = filteredColumns.value.find(column => column.options.length > 0)
97
+
98
+ return column?.options[0]
97
99
  })
98
100
 
99
101
  const selectedOption = computed(() => {
@@ -102,10 +104,6 @@ const selectedOption = computed(() => {
102
104
  })
103
105
  })
104
106
 
105
- const showNoResults = computed(() => {
106
- return props.searchable && !!searchQueryCleaned.value && !hasFilteredResults.value
107
- })
108
-
109
107
  watch(opened, (isOpened) => {
110
108
  if (isOpened && props.searchable) {
111
109
  nextTick(() => {
@@ -172,10 +170,14 @@ function onOptionKeyDown(event: KeyboardEvent) {
172
170
  }
173
171
  }
174
172
 
175
- function onSearchKeyup(event: KeyboardEvent) {
173
+ function onSearchKeydown(event: KeyboardEvent) {
176
174
  if (event.key === 'Escape') {
177
175
  reset()
178
176
  }
177
+ else if (event.key === 'Enter' && !props.disabled && firstFilteredOption.value) {
178
+ event.preventDefault()
179
+ onOptionClick(event as unknown as MouseEvent, firstFilteredOption.value)
180
+ }
179
181
  }
180
182
 
181
183
  function reset() {
@@ -312,12 +314,12 @@ function selectOption(event: MouseEvent, value: string) {
312
314
  class="px-3"
313
315
  :placeholder="searchPlaceholder || t('search')"
314
316
  :size="size"
315
- @keyup="onSearchKeyup"
317
+ @keydown="onSearchKeydown"
316
318
  />
317
319
  </div>
318
320
 
319
321
  <div
320
- v-if="showNoResults"
322
+ v-if="searchable && searchQueryCleaned && !firstFilteredOption"
321
323
  class="flex justify-center border-b border-gray-200 p-3 dark:border-gray-800"
322
324
  >
323
325
  <BaseIcon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "1.4.33",
3
+ "version": "1.4.34",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",