-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PickerTogglerTag]: removed tooltipContext and made a doc example
- Loading branch information
Showing
8 changed files
with
98 additions
and
124 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
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,63 @@ | ||
import React, { useState } from 'react'; | ||
import { DataQueryFilter, useLazyDataSource, useUuiContext } from '@epam/uui-core'; | ||
import { FlexCell, PickerInput, PickerTogglerTag, Tooltip } from '@epam/uui'; | ||
import { Location } from '@epam/uui-docs'; | ||
|
||
const cascadeSelectionModes: Array<{ id: 'explicit' | 'implicit'; caption: string }> = [ | ||
{ | ||
id: 'explicit', | ||
caption: 'Explicit cascade selection', | ||
}, { | ||
id: 'implicit', | ||
caption: 'Implicit cascade selection', | ||
}, | ||
]; | ||
|
||
export default function PickerTogglerTagDemoExample() { | ||
const svc = useUuiContext(); | ||
const [value, onValueChange] = useState<string[]>(); | ||
const [cascadeSelection] = useState(cascadeSelectionModes[0].id); | ||
|
||
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, | ||
}, | ||
[], | ||
); | ||
|
||
return ( | ||
<FlexCell width={ 300 }> | ||
<PickerInput | ||
dataSource={ dataSource } | ||
value={ value } | ||
onValueChange={ onValueChange } | ||
entityName="location" | ||
selectionMode="multi" | ||
valueType="id" | ||
cascadeSelection={ cascadeSelection } | ||
maxItems={ 2 } | ||
renderTag={ (props) => { | ||
if (props.isCollapsed) { | ||
return ( | ||
<PickerTogglerTag { ...props } key="selected" /> | ||
); | ||
} else { | ||
return ( | ||
<Tooltip key={ props.rowProps?.id } content={ `${props.rowProps?.path.map((i) => i.value.name).join('/')}/${props.caption}` }> | ||
<PickerTogglerTag { ...props } /> | ||
</Tooltip> | ||
); | ||
} | ||
} } | ||
/> | ||
</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
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
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,17 @@ | ||
[ | ||
{ | ||
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"text": "In this example we use " | ||
}, | ||
{ | ||
"text": "renderTag", | ||
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " callback to make custom Tags with Tooltip if they are not a Tag for collapsed values." | ||
} | ||
] | ||
} | ||
] |
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