playbook_ui 14.22.0.pre.rc.5 → 14.22.0.pre.rc.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49ddd7737d0cef09aa6010e30813ef33f6202f3ca6443f8ee52a644ccdc3fb83
4
- data.tar.gz: 69f3054455c3885674edc65f962433816fbbdbee18059c27b9d83b78a2413dfc
3
+ metadata.gz: a6bd479856605c00ef5f26fb5dd18cc474620b135764ba404072e570193a7cf7
4
+ data.tar.gz: f4d40593f5e120e470c0c5a24c5506546dd7cbef2775c8e85132c0a08969969e
5
5
  SHA512:
6
- metadata.gz: 8e6ec342701d4deaad0a332fe4a9815b6fd33780682766c6ec694c6470e5e501ebb39f9a6d5f79938b8dd87b9d1e741cbc1ac9852127bd5c8d31403353dbc0a7
7
- data.tar.gz: 52794a22016cb2c64d77deaaa81cf207149779407f1cbb7c1b3453068fb8596bb3890744e0558e25de5c7aaef173b06120a9445087c602393ff470be39f4bf4e
6
+ metadata.gz: a70e992a023dccba6a9a1254ade2c49026f64e4663f1f8d5f71a1a76a3e39f6411f80e51001f590812bf70bb0341d4dd8ca03c3bdffaf81ad63d0f5c7182a9fc
7
+ data.tar.gz: e17ba44634e2a79e2df89a313ce7f6d6dcaf8f1bdb0e4e97503c3b5b8048f5dbdcf4434583ca4a668b41e0df780b3e615c5a5f951aac61b7ea04ae8aa412487e
@@ -9,6 +9,7 @@ import {
9
9
  shift,
10
10
  useFloating,
11
11
  useHover,
12
+ useClick,
12
13
  useInteractions,
13
14
  } from "@floating-ui/react"
14
15
 
@@ -23,6 +24,7 @@ type TooltipProps = {
23
24
  aria?: { [key: string]: string },
24
25
  className?: string | string[],
25
26
  children: JSX.Element,
27
+ useClickToOpen?: boolean,
26
28
  data?: { [key: string]: string },
27
29
  delay?: number | Partial<{open: number; close: number}>,
28
30
  height?: string,
@@ -46,6 +48,7 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
46
48
  aria = {},
47
49
  className,
48
50
  children,
51
+ useClickToOpen = false,
49
52
  data = {},
50
53
  delay = 0,
51
54
  height,
@@ -110,14 +113,21 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
110
113
  placement: preferredPlacement
111
114
  })
112
115
 
116
+ const hover = useHover(context, {
117
+ delay,
118
+ handleClose: interaction ? safePolygon({
119
+ blockPointerEvents: false
120
+ }) : null,
121
+ enabled: !useClickToOpen // Disable hover when useClickToOpen is true
122
+ })
123
+
124
+ const click = useClick(context, {
125
+ enabled: useClickToOpen // Only enable click when useClickToOpen is true
126
+ })
113
127
 
114
- const { getFloatingProps } = useInteractions([
115
- useHover(context, {
116
- delay,
117
- handleClose: interaction ? safePolygon({
118
- blockPointerEvents: false
119
- }) : null
120
- })
128
+ const { getFloatingProps, getReferenceProps } = useInteractions([
129
+ hover,
130
+ click
121
131
  ])
122
132
 
123
133
  const staticSide = {
@@ -142,22 +152,24 @@ const Tooltip = forwardRef((props: TooltipProps, ref: ForwardedRef<unknown>): Re
142
152
  return (
143
153
  <>
144
154
  <div
145
- className={`pb_tooltip_kit ${css}`}
146
- ref={(element) => {
147
- refs.setReference(element);
148
- if (ref) {
149
- if (typeof ref === "function") {
150
- ref(element);
151
- } else if (typeof ref === "object") {
152
- ref.current = element;
155
+ {...getReferenceProps({
156
+ className: `pb_tooltip_kit ${css}`,
157
+ ref: (element) => {
158
+ refs.setReference(element);
159
+ if (ref) {
160
+ if (typeof ref === "function") {
161
+ ref(element);
162
+ } else if (typeof ref === "object") {
163
+ ref.current = element;
164
+ }
153
165
  }
154
- }
155
- }}
156
- role="tooltip_trigger"
157
- style={{ display: "inline-block" }}
158
- {...ariaProps}
159
- {...dataProps}
160
- {...htmlProps}
166
+ },
167
+ role: "tooltip_trigger",
168
+ style: { display: "inline-block" },
169
+ ...ariaProps,
170
+ ...dataProps,
171
+ ...htmlProps,
172
+ })}
161
173
  >
162
174
  {children}
163
175
  </div>
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+ import Button from '../../pb_button/_button'
3
+ import Tooltip from '../_tooltip'
4
+ import Flex from '../../pb_flex/_flex'
5
+
6
+ const TooltipClickOpen = (props) => {
7
+ return (
8
+ <Flex flexDirection='row'
9
+ gap='md'
10
+ wrap
11
+ >
12
+ <Tooltip
13
+ placement='top'
14
+ text='Tooltip Opened'
15
+ useClickToOpen
16
+ zIndex={10}
17
+ {...props}
18
+ >
19
+ <Button text='Click to Open' />
20
+ </Tooltip>
21
+ </Flex>
22
+ )
23
+ }
24
+
25
+ export default TooltipClickOpen
@@ -0,0 +1 @@
1
+ Set the prop `useClickToOpen` so that the tooltip will only appear when an item is clicked rather than hovered over.
@@ -18,3 +18,4 @@ examples:
18
18
  - tooltip_icon: Tooltip with Icon
19
19
  - tooltip_delay: Delay
20
20
  - tooltip_show_tooltip_react: Show Tooltip
21
+ - tooltip_click_open: Click to Open
@@ -5,3 +5,4 @@ export { default as TooltipSizing } from './_tooltip_sizing'
5
5
  export { default as TooltipIcon } from './_tooltip_icon'
6
6
  export { default as TooltipDelay } from './_tooltip_delay'
7
7
  export { default as TooltipShowTooltipReact } from './_tooltip_show_tooltip_react'
8
+ export { default as TooltipClickOpen } from './_tooltip_click_open'