Skip to content

Commit

Permalink
24.02.55: wt-search-bar search modes + docs [WTEL-3889]
Browse files Browse the repository at this point in the history
  • Loading branch information
dlohvinov committed Feb 21, 2024
1 parent 1543e5f commit 9135a82
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 131 deletions.
42 changes: 38 additions & 4 deletions docs/pages/webitel-ui/components/wt-search-bar/Readme.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
<script setup>
import Docs from './wt-search-bar-docs.vue';
import ExampleSearchBar from './examples/example-search-bar.vue';
import ExampleHintedSearchBar from './examples/example-hinted-search-bar.vue';
import ExampleInvalidSearchBar from './examples/example-invalid-search-bar.vue';
import ExampleSearchBarWithSearchModes from './examples/example-search-bar-with-search-modes.vue';
</script>

# WtSearchBar

## Props
::: raw
<Docs/>
:::

| Name | Type | Default | Description |
|---------------------|----------|----------|-------------------------------------------|
| `value` | `String` | `''` | The value of the search bar |
| `placeholder` | `String` | 'Search' | The placeholder of the search bar |
| `hint` | `String` | `''` | The hint of the search bar |
| `v` | `Object` | `''` | Validation object |
| `customValidators` | `Array` | `[]` | Custom validators for validation object |
| `searchMode` | `String` | `''` | The search mode of the search bar |
| `searchModeOptions` | `Array` | `[]` | The search mode options of the search bar |

## Events

| Name | Params | Description |
|----------|-------------------|------------------------------------------------------------------------------------------------------------|
| `input` | `value`: `String` | Emitted when the value of the search bar changes (not debounced!) |
| `search` | `value`: `String` | Sends changed value, immediately, or, if "debounced" is on, debounced. Recommended for api search requests |

## Slots

| Name | Scope | Description |
|----------------------|------------------------|----------------------------------------------------------------------------|
| `search-icon` | `{ invalid: Boolean }` | Change default search icon |
| `additional-actions` | `{ invalid: Boolean }` | Adding additional functionality to search bar. For example wt-context-menu |

## Example SearchBar

::: raw
<ExampleSearchBar/>
:::
Expand All @@ -22,6 +44,7 @@ import ExampleInvalidSearchBar from './examples/example-invalid-search-bar.vue';
:::

## Example HintedSearchBar

::: raw
<ExampleHintedSearchBar/>
:::
Expand All @@ -31,10 +54,21 @@ import ExampleInvalidSearchBar from './examples/example-invalid-search-bar.vue';
:::

## Example InvalidSearchBar

::: raw
<ExampleInvalidSearchBar/>
:::

::: details Code
<<< ./examples/example-invalid-search-bar.vue
:::

## Example SearchBarWithSearchModes

::: raw
<ExampleSearchBarWithSearchModes />
:::

::: details Code
<<< ./examples/example-search-bar-with-search-modes.vue
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup>
import { ref } from 'vue';
const value = ref('');
const searchModeOptions = [
{
value: 'mode 1',
text: 'Mode 1',
},
{
value: 'mode 2',
text: 'Mode 2',
},
];
const searchMode = ref(searchModeOptions[0]);
</script>

<template>
<wt-search-bar
:value="value"
placeholder="Search"
hint="I have search modes!"
:searchMode="searchMode"
:searchModeOptions="searchModeOptions"
@input="value = $event"
@change:search-mode="searchMode = $event"
/>
<p>Value: {{ value }}</p>
<p>Search mode: {{ searchMode }}</p>
</template>

<style scoped lang="scss">
</style>
126 changes: 0 additions & 126 deletions docs/pages/webitel-ui/components/wt-search-bar/wt-search-bar-docs.vue

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.2.54",
"version": "24.2.55",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
34 changes: 34 additions & 0 deletions src/components/wt-search-bar/wt-search-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@
>
{{ hint }}
</wt-hint>

<wt-context-menu
v-if="searchMode"
:options="searchModeOptions"
@click="emit('change:search-mode', $event.option)"
>
<template #activator>
<wt-tooltip>
<template #activator>
<wt-icon-btn
:color="invalid ? 'error' : 'default'"
icon="filter"
/>
</template>
{{ $t('webitelUI.searchBar.settingsHint') }}
</wt-tooltip>
</template>
<template #option="{ value, text }">
<wt-radio
:label="text"
:selected="searchMode.value === value"
:value="true"
/>
</template>
</wt-context-menu>

<slot
:invalid="invalid"
name="additional-actions"
Expand Down Expand Up @@ -78,12 +104,20 @@ const props = defineProps({
type: String,
description: 'Adds hint icon + tooltip with text, passed as "hint" prop',
},
searchMode: {
type: String,
},
searchModeOptions: {
type: Array,
default: () => ([]),
},
});
const emit = defineEmits([
'input',
'search',
'enter',
'change:search-mode',
]);
const { v, customValidators } = toRefs(props);
Expand Down

0 comments on commit 9135a82

Please sign in to comment.