Skip to content

Commit

Permalink
feat(InputMenu): allows to customize labels (#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares authored Oct 31, 2024
1 parent 54e713d commit ddf67a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/content/2.components/input-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ componentProps:

Use the `#option-empty` slot to customize the content displayed when the `searchable` prop is `true` and there is no options. You will have access to the `query` property in the slot scope.

You can also configure this globally through the `ui.inputMenu.default.optionEmpty.label` config. The token `{query}` will be replaced by `query` property. Defaults to `No results for "{query}".`.

::component-example
---
component: 'input-menu-example-option-empty-slot'
Expand All @@ -186,6 +188,8 @@ componentProps:

Use the `#empty` slot to customize the content displayed when there is no options. Defaults to `No options.`.

You can also configure this globally through the `ui.inputMenu.default.empty.label` config. Defaults to `No options.`.

::component-example
---
component: 'input-menu-example-empty-slot'
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/components/forms/InputMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@

<p v-if="query && !filteredOptions.length" :class="uiMenu.option.empty">
<slot name="option-empty" :query="query">
No results for "{{ query }}".
{{ uiMenu.default.optionEmpty.label.replace('{query}', query) }}
</slot>
</p>
<p v-else-if="!filteredOptions.length" :class="uiMenu.empty">
<slot name="empty" :query="query">
No options.
{{ uiMenu.default.empty.label }}
</slot>
</p>
</HComboboxOptions>
Expand Down
8 changes: 7 additions & 1 deletion src/runtime/ui.config/forms/inputMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ export default {
},
default: {
selectedIcon: 'i-heroicons-check-20-solid',
trailingIcon: 'i-heroicons-chevron-down-20-solid'
trailingIcon: 'i-heroicons-chevron-down-20-solid',
empty: {
label: 'No options.'
},
optionEmpty: {
label: 'No results for "{query}".'
}
},
arrow: {
...arrow,
Expand Down

0 comments on commit ddf67a0

Please sign in to comment.