-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pro:search): add ProSearch component (#989)
- Loading branch information
Showing
54 changed files
with
3,800 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MountingOptions, mount } from '@vue/test-utils' | ||
|
||
import { renderWork } from '@tests' | ||
|
||
import ProSearch from '../src/ProSearch' | ||
import { ProSearchProps } from '../src/types' | ||
|
||
describe.skip('ProSearch', () => { | ||
const ProSearchMount = (options?: MountingOptions<Partial<ProSearchProps>>) => | ||
mount(ProSearch, { ...(options as MountingOptions<ProSearchProps>) }) | ||
|
||
renderWork<ProSearchProps>(ProSearch, { | ||
props: {}, | ||
}) | ||
|
||
test('xxx work', async () => { | ||
const wrapper = ProSearchMount({ props: { xxx: 'Xxx' } }) | ||
|
||
expect(wrapper.classes()).toContain('ix-Xxx') | ||
|
||
await wrapper.setProps({ xxx: 'Yyy' }) | ||
|
||
expect(wrapper.classes()).toContain('ix-Yyy') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 0 | ||
title: | ||
zh: 基本使用 | ||
en: Basic usage | ||
--- | ||
|
||
## zh | ||
|
||
最简单的用法。关键字为默认内置搜索项。 | ||
|
||
## en | ||
|
||
The simplest usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<template> | ||
<IxProSearch | ||
v-model:value="value" | ||
style="width: 100%" | ||
:searchFields="searchFields" | ||
:onChange="onChange" | ||
:onSearch="onSearch" | ||
></IxProSearch> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { SearchField, SearchValue } from '@idux/pro/search' | ||
import { ref } from 'vue' | ||
const value = ref<SearchValue[]>([ | ||
{ | ||
key: 'level', | ||
name: 'Level', | ||
operator: '=', | ||
value: 'level1', | ||
}, | ||
{ | ||
key: 'security_state', | ||
name: 'Security State', | ||
value: ['high', 'low'], | ||
}, | ||
{ | ||
key: 'keyword', | ||
name: '', | ||
value: 'custom keyword', | ||
}, | ||
]) | ||
const searchFields: SearchField[] = [ | ||
{ | ||
key: 'keyword', | ||
type: 'input', | ||
label: 'Keyword', | ||
multiple: true, | ||
fieldConfig: { | ||
trim: true, | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Level', | ||
key: 'level', | ||
operators: ['=', '!='], | ||
defaultOperator: '=', | ||
fieldConfig: { | ||
multiple: false, | ||
searchable: true, | ||
dataSource: [ | ||
{ | ||
key: 'level1', | ||
label: 'Level 1', | ||
}, | ||
{ | ||
key: 'level2', | ||
label: 'Level 2', | ||
}, | ||
{ | ||
key: 'level3', | ||
label: 'Level 3', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
type: 'select', | ||
label: 'Security State', | ||
key: 'security_state', | ||
fieldConfig: { | ||
multiple: true, | ||
searchable: true, | ||
dataSource: [ | ||
{ | ||
key: 'fatal', | ||
label: 'fatal', | ||
}, | ||
{ | ||
key: 'high', | ||
label: 'high', | ||
}, | ||
{ | ||
key: 'mediumn', | ||
label: 'mediumn', | ||
}, | ||
{ | ||
key: 'low', | ||
label: 'low', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
type: 'datePicker', | ||
label: 'Date', | ||
key: 'date', | ||
fieldConfig: { | ||
type: 'datetime', | ||
}, | ||
}, | ||
{ | ||
type: 'dateRangePicker', | ||
label: 'Date Range', | ||
key: 'date_range', | ||
fieldConfig: { | ||
type: 'datetime', | ||
}, | ||
}, | ||
] | ||
const onChange = (value: SearchValue[] | undefined, oldValue: SearchValue[] | undefined) => { | ||
console.log(value, oldValue) | ||
} | ||
const onSearch = () => { | ||
console.log('onSearch') | ||
} | ||
</script> | ||
|
||
<style scoped lang="less"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
order: 30 | ||
title: | ||
zh: 自定义搜索项 | ||
en: Custom SearchOption | ||
--- | ||
|
||
## zh | ||
|
||
通过 `'custom'` 类型的option自定义搜索项。 | ||
|
||
## en | ||
|
||
Customize SearchOption using option with type `'custom'`. |
Oops, something went wrong.