@digital-ai/dot-components 4.15.0 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -6644,19 +6644,24 @@ const DotChip = ({
6644
6644
  onDelete,
6645
6645
  size = 'medium',
6646
6646
  startIcon,
6647
- tabIndex
6647
+ tabIndex,
6648
+ tooltipHoverVisibility = 'overflow'
6648
6649
  }) => {
6649
6650
  const errorClass = error ? 'Mui-error' : '';
6650
6651
  const rootClasses = useStylesWithRootClass(rootClassName$Z, className, errorClass);
6652
+ const isTruncated = charactersLimit > 0 && children.length > charactersLimit;
6653
+ const getChipLabelWithTooltip = label => jsx(DotTooltip, {
6654
+ hoverVisibility: "always",
6655
+ title: children,
6656
+ children: jsx("span", {
6657
+ children: label
6658
+ })
6659
+ });
6651
6660
  const getChipLabel = () => {
6652
- if (charactersLimit <= 0 || children.length < charactersLimit) return children;
6653
- const label = `${children.substring(0, charactersLimit)}...`;
6654
- return jsx(DotTooltip, {
6655
- title: children,
6656
- children: jsx("span", {
6657
- children: label
6658
- })
6659
- });
6661
+ const label = isTruncated ? `${children.substring(0, charactersLimit)}...` : children;
6662
+ if (tooltipHoverVisibility === 'always' || isTruncated && tooltipHoverVisibility === 'overflow') {
6663
+ return getChipLabelWithTooltip(label);
6664
+ } else return label;
6660
6665
  };
6661
6666
  return jsx(StyledChip, {
6662
6667
  "aria-label": ariaLabel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "4.15.0",
3
+ "version": "4.16.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [
@@ -1,4 +1,5 @@
1
1
  import { MouseEvent, ReactElement } from 'react';
2
+ import { TooltipHoverVisibility } from '../tooltip';
2
3
  import { CommonProps } from '../CommonProps';
3
4
  export type ChipSize = 'medium' | 'small';
4
5
  export declare const DEFAULT_CHARACTERS_LIMIT = 32;
@@ -27,5 +28,7 @@ export interface ChipProps extends CommonProps {
27
28
  startIcon?: ReactElement;
28
29
  /** The tab index of the chip */
29
30
  tabIndex?: number;
31
+ /** Tooltip option which governs when the tooltip text should be visible */
32
+ tooltipHoverVisibility?: TooltipHoverVisibility;
30
33
  }
31
- export declare const DotChip: ({ ariaLabel, avatar, charactersLimit, children, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, disabled, error, isClickable, isDeletable, onClick, onDelete, size, startIcon, tabIndex, }: ChipProps) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const DotChip: ({ ariaLabel, avatar, charactersLimit, children, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, disabled, error, isClickable, isDeletable, onClick, onDelete, size, startIcon, tabIndex, tooltipHoverVisibility, }: ChipProps) => import("react/jsx-runtime").JSX.Element;