@purpurds/tooltip 6.12.5 → 7.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpurds/tooltip",
3
- "version": "6.12.5",
3
+ "version": "7.0.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "./dist/tooltip.cjs.js",
6
6
  "types": "./dist/tooltip.d.ts",
@@ -17,11 +17,11 @@
17
17
  "dependencies": {
18
18
  "@radix-ui/react-tooltip": "~1.1.8",
19
19
  "classnames": "~2.5.0",
20
- "@purpurds/button": "6.12.5",
21
- "@purpurds/action": "6.12.5",
22
- "@purpurds/icon": "6.12.5",
23
- "@purpurds/tokens": "6.12.5",
24
- "@purpurds/paragraph": "6.12.5"
20
+ "@purpurds/paragraph": "7.0.0",
21
+ "@purpurds/action": "7.0.0",
22
+ "@purpurds/button": "7.0.0",
23
+ "@purpurds/tokens": "7.0.0",
24
+ "@purpurds/icon": "7.0.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "eslint": "9.24.0",
@@ -22,7 +22,8 @@ const meta = {
22
22
  args: {
23
23
  align: "center",
24
24
  position: "top",
25
- triggerAriaLabel: "Tooltip button",
25
+ triggerElement: undefined,
26
+ triggerAriaLabel: "Tooltip trigger",
26
27
  negative: false,
27
28
  children: "Some tooltip content",
28
29
  },
@@ -104,6 +105,7 @@ export const TooltipWithCustomTrigger: Story = {
104
105
  name: "With custom trigger",
105
106
  args: {
106
107
  triggerElement: customTooltipTrigger,
108
+ triggerAriaLabel: undefined,
107
109
  },
108
110
  };
109
111
 
package/src/tooltip.tsx CHANGED
@@ -1,4 +1,11 @@
1
- import React, { Children, ForwardedRef, forwardRef, ReactNode, useState } from "react";
1
+ import React, {
2
+ Children,
3
+ ForwardedRef,
4
+ forwardRef,
5
+ HTMLAttributes,
6
+ ReactNode,
7
+ useState,
8
+ } from "react";
2
9
  import { Size } from "@purpurds/action";
3
10
  import { Button, BUTTON_VARIANT } from "@purpurds/button";
4
11
  import { IconInfo } from "@purpurds/icon/info";
@@ -26,7 +33,17 @@ export const TOOLTIP_ALIGN = {
26
33
  } as const;
27
34
  export type TooltipAlign = (typeof TOOLTIP_ALIGN)[keyof typeof TOOLTIP_ALIGN];
28
35
 
29
- export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
36
+ type WithTriggerElement = {
37
+ triggerElement: ReactNode;
38
+ triggerAriaLabel?: never;
39
+ };
40
+
41
+ type WithoutTriggeElement = {
42
+ triggerElement?: never;
43
+ triggerAriaLabel: string;
44
+ };
45
+
46
+ export type TooltipProps = HTMLAttributes<HTMLDivElement> & {
30
47
  align?: TooltipAlign;
31
48
  buttonSize?: Size;
32
49
  children: ReactNode;
@@ -36,7 +53,7 @@ export type TooltipProps = React.HTMLAttributes<HTMLDivElement> & {
36
53
  triggerAriaLabel?: string;
37
54
  triggerElement?: ReactNode;
38
55
  contentClassName?: string;
39
- };
56
+ } & (WithTriggerElement | WithoutTriggeElement);
40
57
 
41
58
  const rootClassName = "purpur-tooltip";
42
59
 
@@ -51,7 +68,7 @@ export const Tooltip = forwardRef(
51
68
  negative = false,
52
69
  position = TOOLTIP_POSITION.TOP,
53
70
  align = TOOLTIP_ALIGN.CENTER,
54
- triggerAriaLabel = "",
71
+ triggerAriaLabel,
55
72
  triggerElement,
56
73
  ...props
57
74
  }: TooltipProps,