-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PickerTogglerTag#2008 #2087
Merged
Merged
PickerTogglerTag#2008 #2087
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
de21b86
[PickerTogglerTag]: made to use in PickerToggler renderItem by defaul…
vik753 8105bcb
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 0f20602
[PickerTogglerTag]: PickerTogglerProps in progress
vik753 0cd6d1a
[PickerInput]: added renderTag property
vik753 e82dff9
[PickerTogglerTag]: fixed test for new realisation of maxItems prop
vik753 1535bea
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 e74fe08
[PickerTogglerTag]: removed tooltipContext and made a doc example
vik753 ab89517
[PickerTogglerTag]: fixed TS error
vik753 898f9ef
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 3a38dd9
[PickerTogglerTag]: added changelog
vik753 8cf9d8c
[PickerTogglerTag]: fixed MR remarks
vik753 34ad4a1
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 2b83528
[PickerTogglerTag]: fixed interfaces for renderItem, and reworked demo.
vik753 1fb50c7
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 2ff7675
Merge branch 'develop' into feature/PickerTogglerTag-#2008
vik753 ba8da41
[PickerTogglerTag]: fixed renderItem interface.
vik753 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
app/src/docs/_examples/pickerInput/PickerTogglerTagDemo.example.tsx
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,55 @@ | ||
import React, { useState } from 'react'; | ||
import { DataQueryFilter, useLazyDataSource, useUuiContext } from '@epam/uui-core'; | ||
import { FlexCell, PickerInput, PickerTogglerTag, PickerTogglerTagProps, Tooltip } from '@epam/uui'; | ||
import { Location } from '@epam/uui-docs'; | ||
|
||
export default function PickerTogglerTagDemoExample() { | ||
const svc = useUuiContext(); | ||
const [value, onValueChange] = useState<string[]>(['225284', '2747351', '3119841', '3119746']); | ||
|
||
const dataSource = useLazyDataSource<Location, string, DataQueryFilter<Location>>( | ||
{ | ||
api: (request, ctx) => { | ||
const { search } = request; | ||
// and since parentId is meaningful value, it is required to exclude it from the filter. | ||
const filter = search ? {} : { parentId: ctx?.parentId }; | ||
return svc.api.demo.locations({ ...request, search, filter }); | ||
}, | ||
getId: (i) => i.id, | ||
getParentId: (i) => i.parentId, | ||
getChildCount: (l) => l.childCount, | ||
}, | ||
[], | ||
); | ||
|
||
const renderTag = (props: PickerTogglerTagProps<Location, string>) => { | ||
if (props.isCollapsed) { | ||
// rendering '+ N items selected' Tag | ||
return ( | ||
<PickerTogglerTag { ...props } key="selected" /> | ||
); | ||
} else { | ||
// rendering all other Tags with Tooltip | ||
return ( | ||
<Tooltip key={ props.rowProps?.id } content={ `${props.rowProps?.value?.tz}/${props.caption}` }> | ||
<PickerTogglerTag { ...props } /> | ||
</Tooltip> | ||
); | ||
} | ||
}; | ||
|
||
return ( | ||
<FlexCell width={ 300 }> | ||
<PickerInput | ||
dataSource={ dataSource } | ||
value={ value } | ||
onValueChange={ onValueChange } | ||
entityName="location" | ||
selectionMode="multi" | ||
valueType="id" | ||
maxItems={ 2 } | ||
renderTag={ (props) => renderTag(props) } | ||
/> | ||
</FlexCell> | ||
); | ||
} |
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
24 changes: 24 additions & 0 deletions
24
public/docs/content/examples-pickerInput-PickerTogglerTagDemo.json
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,24 @@ | ||
[ | ||
{ | ||
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"text": "You can utilize the default UUI implementation of tags for PickerInput by using the " | ||
}, | ||
{ | ||
"text": "PickerTogglerTag", | ||
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " component using the " | ||
}, | ||
{ | ||
"text": "renderTag", | ||
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " property to customize it." | ||
} | ||
] | ||
} | ||
] |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,36 @@ | ||
import * as React from 'react'; | ||
import * as types from '../types'; | ||
import { Tag, TagProps } from '../widgets'; | ||
import { PickerTogglerRenderItemParams } from '@epam/uui-components'; | ||
|
||
export interface PickerTogglerTagProps<TItem, TId> extends PickerTogglerRenderItemParams<TItem, TId>, TagProps { | ||
/** Defines component size */ | ||
size?: types.ControlSize; | ||
} | ||
|
||
const getPickerTogglerButtonSize = (propSize?: types.ControlSize):TagProps['size'] => { | ||
switch (propSize) { | ||
case '48': | ||
return '42'; | ||
case '42': | ||
return '36'; | ||
case '36': | ||
return '30'; | ||
case '30': | ||
return '24'; | ||
case '24': | ||
return '18'; | ||
default: | ||
return '30'; | ||
} | ||
}; | ||
|
||
export const PickerTogglerTag = React.forwardRef((props: PickerTogglerTagProps<any, any>, ref: React.Ref<HTMLElement>) => { | ||
const tagProps = { | ||
...props, | ||
tabIndex: -1, | ||
size: getPickerTogglerButtonSize(props.size), | ||
}; | ||
|
||
return <Tag ref={ ref } { ...tagProps } />; | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description that user should use renderTag prop for such cunstomization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done