-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhouwenxuan
authored and
zhouwenxuan
committed
Dec 23, 2024
1 parent
8dd627b
commit 1219001
Showing
10 changed files
with
178 additions
and
17 deletions.
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
28 changes: 28 additions & 0 deletions
28
...data/components/popover/filter-popover/advanced-filters/filter-item/tags-filter/index.css
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,28 @@ | ||
|
||
.sf-metadata-filters-list .sf-metadata-tag-color { | ||
border-radius: 50%; | ||
flex-shrink: 0; | ||
} | ||
|
||
.sf-metadata-filters-list .sf-metadata-tag-name { | ||
flex: 1; | ||
margin-left: 4px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
color: #212529; | ||
} | ||
|
||
.sf-metadata-selector-tags.sf-metadata-select .sf-metadata-option { | ||
line-height: 20px; | ||
padding: 5px 10px 5px 10px !important; | ||
} | ||
|
||
.sf-metadata-selector-tags.sf-metadata-select .sf-metadata-option:hover { | ||
background-color: #f7f7f7; | ||
color: #212529; | ||
} | ||
|
||
.sf-metadata-selector-tags.sf-metadata-select .selected-option-show { | ||
text-overflow: clip; | ||
} |
81 changes: 81 additions & 0 deletions
81
...adata/components/popover/filter-popover/advanced-filters/filter-item/tags-filter/index.js
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,81 @@ | ||
import React, { useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { CustomizeSelect, Icon } from '@seafile/sf-metadata-ui-component'; | ||
import { DELETED_OPTION_BACKGROUND_COLOR, DELETED_OPTION_TIPS } from '../../../../../../constants'; | ||
import { gettext } from '../../../../../../../utils/constants'; | ||
|
||
import './index.css'; | ||
|
||
const TagsFilter = ({ options, filterTerm, readOnly, onSelectMultiple }) => { | ||
|
||
const selectValue = useMemo(() => { | ||
return Array.isArray(filterTerm) && filterTerm.length > 0 && filterTerm.map((item) => { | ||
const option = options.find(option => option.id === item); | ||
if (!option) return null; | ||
const optionStyle = { margin: '0 10px 0 0' }; | ||
let optionName = null; | ||
let optionColor = null; | ||
|
||
if (option) { | ||
optionName = option.name; | ||
optionColor = option.color; | ||
optionStyle.background = option.color; | ||
} else { | ||
optionStyle.background = DELETED_OPTION_BACKGROUND_COLOR; | ||
optionName = gettext(DELETED_OPTION_TIPS); | ||
} | ||
|
||
return ( | ||
<div | ||
key={'option_' + item} | ||
className="tag-item" | ||
title={optionName} | ||
aria-label={optionName} | ||
> | ||
<span className="sf-metadata-tag-color" style={{ background: optionColor }}></span> | ||
<span className="sf-metadata-tag-name">{optionName}</span> | ||
</div> | ||
); | ||
}); | ||
}, [filterTerm, options]); | ||
|
||
const dataOptions = useMemo(() => { | ||
return options.map(option => ({ | ||
value: { columnOption: option }, | ||
label: ( | ||
<div className="select-option-name option-tag"> | ||
<div className="sf-metadata-tag-container"> | ||
<span className="sf-metadata-tag-color" style={{ background: option.color }}></span> | ||
<span className="sf-metadata-tag-name">{option.name}</span> | ||
</div> | ||
<div className="tag-check-icon"> | ||
{filterTerm.indexOf(option.id) > -1 && (<Icon iconName="check-mark" />)} | ||
</div> | ||
</div> | ||
) | ||
})); | ||
}, [options, filterTerm]); | ||
|
||
return ( | ||
<CustomizeSelect | ||
readOnly={readOnly} | ||
className="sf-metadata-selector-tags" | ||
value={selectValue ? { label: selectValue } : {}} | ||
options={dataOptions} | ||
onSelectOption={onSelectMultiple} | ||
placeholder={gettext('Select tag(s)')} | ||
searchable={true} | ||
searchPlaceholder={gettext('Search tag')} | ||
noOptionsPlaceholder={gettext('No tags available')} | ||
supportMultipleSelect={true} | ||
/> | ||
); | ||
}; | ||
|
||
TagsFilter.propTypes = { | ||
filterTerm: PropTypes.oneOfType([PropTypes.array, PropTypes.string]), | ||
readOnly: PropTypes.bool.isRequired, | ||
onSelectMultiple: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default TagsFilter; |
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