-
Notifications
You must be signed in to change notification settings - Fork 67
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
PickerTogglerTag#2008 #2087
Conversation
Generated by: track-bundle-size
new sizes (raw)To set the sizes as a new baseline, you can copy/paste next content to the {
"version": "5.7.1",
"timestamp": "2024-04-03",
"sizes": {
"templateApp": {
"css": 284412,
"js": 784215
},
"@epam/app": {
"css": 1618031,
"js": 5155332
},
"@epam/draft-rte": {
"css": 9762,
"js": 45308
},
"@epam/electric": {
"css": 2289,
"js": 2299
},
"@epam/promo": {
"css": 40368,
"js": 16101
},
"@epam/uui-extra": {
"css": 0,
"js": 213
},
"@epam/loveship": {
"css": 49451,
"js": 54148
},
"@epam/uui-components": {
"css": 22214,
"js": 255628
},
"@epam/uui-core": {
"css": 0,
"js": 280745
},
"@epam/uui-db": {
"css": 0,
"js": 43327
},
"@epam/uui-docs": {
"css": 3189,
"js": 176559
},
"@epam/uui-editor": {
"css": 12625,
"js": 164792
},
"@epam/uui-timeline": {
"css": 2251,
"js": 46073
},
"@epam/uui": {
"css": 272887,
"js": 322377
}
}
} Generated by: generate-components-api Total amount of exported types/props without JSDoc comments
New missing commentsNOTE: It's either a new exported types/props without JSDoc, or it's an existing code from which you deleted the JSDoc comments.
|
import { FlexCell, PickerInput, PickerTogglerTag, Tooltip } from '@epam/uui'; | ||
import { Location } from '@epam/uui-docs'; | ||
|
||
const cascadeSelectionModes: Array<{ id: 'explicit' | 'implicit'; caption: string }> = [ |
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.
Why do we have cascadeSelection options in this example?
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.
removed it, it will work by default
@@ -80,6 +80,7 @@ export class PickerInputDoc extends BaseDocsBlock { | |||
<DocExample title="Picker with changed array of items" path="./_examples/pickerInput/PickerWithChangingItemsArray.example.tsx" /> | |||
<DocExample title="Linked pickers" path="./_examples/pickerInput/LinkedPickers.example.tsx" /> | |||
<DocExample title="Change portal target and dropdown placement" path="./_examples/pickerInput/ConfigurePortalTargetAndPlacement.example.tsx" /> | |||
<DocExample title="PickerTogglerTag and renderTag demo" path="./_examples/pickerInput/PickerTogglerTagDemo.example.tsx" /> |
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.
Change title to 'Custom toggler tag render'
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
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " is a component we recommend to use for rendering Tags." |
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.
Let's change this here text to - You can utilize the default UUI implementation of tags for PickerInput by using the PickerTogglerTag component.
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
uui-components/src/i18n.tsx
Outdated
@@ -10,7 +10,7 @@ export const i18n = { | |||
showAll: 'SHOW ALL', | |||
}, | |||
pickerToggler: { | |||
createItemValue: (length: number, entityName: string) => `${length} ${entityName} selected`, | |||
createCollapsedName: (length: number, entityName: string) => `+ ${length} ${entityName} selected`, |
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.
we can't rename this object fields since it will cause the breaking change, let's revert it.
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.
fixed
export type PickerInputProps<TItem, TId> = SizeMod & IHasEditMode & PickerInputBaseProps<TItem, TId>; | ||
export type PickerInputProps<TItem, TId> = SizeMod & IHasEditMode & PickerInputBaseProps<TItem, TId> & { | ||
/** | ||
* Render Callback for making custom Tags. |
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.
Let's change to - 'Render callback for picker toggler selection tag'
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.
fixed
export type PickerInputProps<TItem, TId> = SizeMod & IHasEditMode & PickerInputBaseProps<TItem, TId> & { | ||
/** | ||
* Render Callback for making custom Tags. | ||
* If omitted, they will be rendered by default component PickerTogglerTag. |
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.
- If omitted, default `PickerTogglerTag` component will be rendered.
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.
fixed
const renderTargetFn = props.renderToggler || ((pickerTogglerProps) => ( | ||
<PickerToggler | ||
{ ...pickerTogglerProps } | ||
renderItem={ props.renderTag ? (renderItemProps) => props.renderTag(renderItemProps) : null } |
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.
Can we add renderItem
into targetProps
params. And also why do we have this condition? i guess we can just pass it as is, without wrapping into arrow function.
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.
fixed
rowProps={ itemProps.rowProps } | ||
key={ itemProps.isCollapsed ? 'collapsed' : itemProps.rowProps?.id as string } | ||
size={ props.size } | ||
isDisabled={ props.isDisabled || props.isReadonly || itemProps.isDisabled } |
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.
I supposed that we shouldn't make any props calculation here, we should receive final prop from params and here just spread it to the component, i believe that default renderItem callback should look like:
const renderItem = (itemProps: PickerTogglerTagProps<TItem, TId>) => (
<PickerTogglerTag { ...itemProps } />
)
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.
I left only size here, or do we want to move it to the uui-components?
props.onClear?.(); | ||
let isDisabled = props.isDisabled || props.isReadonly; | ||
|
||
const multiItems = props.selection?.map((row) => { |
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.
Let's rename this variable to 'tags', to be more informative
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
const multiItems = props.selection?.map((row) => { | ||
isDisabled = isDisabled || row.isDisabled; | ||
|
||
const newMultiItems = { |
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.
Let's rename this variable to 'tagProps', to be more informative
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
valueType="id" | ||
maxItems={ 2 } | ||
renderTag={ (props) => { | ||
if (props.isCollapsed) { |
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.
Let's add comment that it renders 'N items selected' tag
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
/> | ||
); | ||
function PickerTogglerComponent<TItem extends string, TId>(props: PickerTogglerProps<TItem, TId> & PickerTogglerMods, ref: React.ForwardedRef<HTMLElement>): JSX.Element { | ||
const renderItem = (itemProps: PickerTogglerTagProps<TItem, TId>) => <PickerTogglerTag { ...itemProps } size={ props.size } />; |
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 size to the result itemProps which will be passed to the user renderItem
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.
added
size?: types.ControlSize; | ||
/** If this is true, then the PickerTogglerTag will be an additional tag with the number of collapsed elements in the caption. */ | ||
isCollapsed?: boolean; | ||
/** Defines row props (see more: uui-components/src/pickers/PickerToggler.tsx PickerTogglerProps<TItem = any, TId = any>) */ |
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.
/** DataRowProps object of the rendered item. */
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
export interface PickerTogglerTagProps<TItem, TId> extends TagProps { | ||
/** Defines component size */ | ||
size?: types.ControlSize; | ||
/** If this is true, then the PickerTogglerTag will be an additional tag with the number of collapsed elements in the caption. */ |
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.
/** Indicates that tag is collapsed rest selected items, like '+N items selected' */
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
|
||
export default function PickerTogglerTagDemoExample() { | ||
const svc = useUuiContext(); | ||
const [value, onValueChange] = useState<string[]>([]); |
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 initial items, for example 5
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
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"text": "You can utilize the default UUI implementation of tags for PickerInput by using the " |
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
* Render callback for picker toggler selection tag | ||
* If omitted, default `PickerTogglerTag` component will be rendered | ||
*/ | ||
renderTag?: (props: PickerTogglerTagProps<TItem, TId>) => JSX.Element; |
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.
I believe this callback receive IRenderItemProps interface, not PickerTogglerTagProps, yes?
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.
fixed
import { getMaxItems } from './helpers'; | ||
|
||
export interface IRenderItemProps<TItem, TId> extends IHasCaption, IDisableable { |
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.
Lets rename to PickerTogglerRenderItemParams
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
# Conflicts: # changelog.md
Issue link(if exists): #2008
Description: added new component PickerTogglerTag to use with maxItems property, and added into a PickerInput new property renderTag, for rendering any custom variants of tags in the PickerToggler.