@kaizen/components 1.50.0 → 1.52.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/dist/cjs/Button/GenericButton/GenericButton.cjs +89 -82
- package/dist/cjs/Button/GenericButton/GenericButton.module.scss.cjs +2 -1
- package/dist/cjs/ButtonGroup/ButtonGroup.cjs +4 -4
- package/dist/cjs/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs +2 -2
- package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +2 -2
- package/dist/cjs/KaizenProvider/KaizenProvider.cjs +1 -1
- package/dist/cjs/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.cjs +11 -2
- package/dist/cjs/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.cjs +1 -2
- package/dist/cjs/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.cjs +2 -2
- package/dist/cjs/Table/Table.cjs +2 -2
- package/dist/cjs/Tabs/subcomponents/Tab.cjs +20 -14
- package/dist/cjs/TitleBlockZen/TitleBlockZen.cjs +1 -1
- package/dist/cjs/__overlays__/Focusable/v3/Focusable.cjs +33 -0
- package/dist/cjs/__overlays__/Focusable/v3/Focusable.module.scss.cjs +6 -0
- package/dist/cjs/__overlays__/Tooltip/v1/Tooltip.module.scss.cjs +21 -0
- package/dist/cjs/__overlays__/Tooltip/v1/index.cjs +8 -0
- package/dist/cjs/__overlays__/Tooltip/v3/OverlayArrow.cjs +32 -0
- package/dist/cjs/__overlays__/Tooltip/v3/OverlayArrow.module.scss.cjs +7 -0
- package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.cjs +59 -0
- package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.module.scss.cjs +8 -0
- package/dist/cjs/__overlays__/Tooltip/v3/TooltipTrigger.cjs +24 -0
- package/dist/cjs/__utilities__/ReversedColors/v3/ReversedColors.cjs +23 -0
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/overlaysV1.cjs +4 -0
- package/dist/cjs/overlaysV2.cjs +4 -0
- package/dist/cjs/overlaysV3.cjs +15 -0
- package/dist/cjs/reactAriaComponentsV3.cjs +11 -0
- package/dist/cjs/reactAriaV3.cjs +11 -0
- package/dist/cjs/utilitiesV3.cjs +5 -0
- package/dist/cjs/utils/mergeClassNames.cjs +33 -0
- package/dist/esm/Button/GenericButton/GenericButton.mjs +90 -82
- package/dist/esm/Button/GenericButton/GenericButton.module.scss.mjs +2 -1
- package/dist/esm/ButtonGroup/ButtonGroup.mjs +1 -1
- package/dist/esm/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs +1 -1
- package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +1 -1
- package/dist/esm/KaizenProvider/KaizenProvider.mjs +1 -1
- package/dist/esm/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.mjs +11 -2
- package/dist/esm/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.mjs +1 -2
- package/dist/esm/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.mjs +1 -1
- package/dist/esm/Table/Table.mjs +1 -1
- package/dist/esm/Tabs/subcomponents/Tab.mjs +21 -15
- package/dist/esm/TitleBlockZen/TitleBlockZen.mjs +1 -1
- package/dist/esm/__overlays__/Focusable/v3/Focusable.mjs +24 -0
- package/dist/esm/__overlays__/Focusable/v3/Focusable.module.scss.mjs +4 -0
- package/dist/esm/__overlays__/Tooltip/v1/Tooltip.module.scss.mjs +19 -0
- package/dist/esm/__overlays__/Tooltip/v1/index.mjs +6 -0
- package/dist/esm/__overlays__/Tooltip/v3/OverlayArrow.mjs +24 -0
- package/dist/esm/__overlays__/Tooltip/v3/OverlayArrow.module.scss.mjs +5 -0
- package/dist/esm/__overlays__/Tooltip/v3/Tooltip.mjs +46 -0
- package/dist/esm/__overlays__/Tooltip/v3/Tooltip.module.scss.mjs +6 -0
- package/dist/esm/__overlays__/Tooltip/v3/TooltipTrigger.mjs +16 -0
- package/dist/esm/__utilities__/ReversedColors/v3/ReversedColors.mjs +14 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/overlaysV1.mjs +1 -0
- package/dist/esm/overlaysV2.mjs +1 -0
- package/dist/esm/overlaysV3.mjs +4 -0
- package/dist/esm/reactAriaComponentsV3.mjs +1 -0
- package/dist/esm/reactAriaV3.mjs +1 -0
- package/dist/esm/utilitiesV3.mjs +1 -0
- package/dist/esm/utils/mergeClassNames.mjs +25 -0
- package/dist/styles.css +19 -16
- package/dist/types/Button/GenericButton/GenericButton.d.ts +2 -1
- package/dist/types/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/types/Container/Container.d.ts +1 -1
- package/dist/types/Content/Content.d.ts +1 -1
- package/dist/types/DateInput/DateInput/DateInput.d.ts +1 -1
- package/dist/types/DatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
- package/dist/types/Filter/FilterButton/subcomponents/FilterButtonBase/FilterButtonBase.d.ts +1 -1
- package/dist/types/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
- package/dist/types/GuidanceBlock/GuidanceBlock.d.ts +1 -1
- package/dist/types/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.d.ts +2 -2
- package/dist/types/Notification/subcomponents/GenericNotification/GenericNotification.d.ts +1 -1
- package/dist/types/Select/Select.d.ts +3 -3
- package/dist/types/__future__/Select/Select.d.ts +2 -2
- package/dist/types/__future__/Select/subcomponents/SelectToggle/SelectToggle.d.ts +2 -2
- package/dist/types/__overlays__/Focusable/v3/Focusable.d.ts +6 -0
- package/dist/types/__overlays__/Focusable/v3/index.d.ts +1 -0
- package/dist/types/__overlays__/Tooltip/v1/index.d.ts +8 -0
- package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.d.ts +2 -2
- package/dist/types/__overlays__/Tooltip/v2/index.d.ts +1 -0
- package/dist/types/__overlays__/Tooltip/v3/OverlayArrow.d.ts +7 -0
- package/dist/types/__overlays__/Tooltip/v3/Tooltip.d.ts +32 -0
- package/dist/types/__overlays__/Tooltip/v3/TooltipTrigger.d.ts +19 -0
- package/dist/types/__overlays__/Tooltip/v3/index.d.ts +2 -0
- package/dist/types/__overlays__/v1.d.ts +1 -0
- package/dist/types/__overlays__/v2.d.ts +1 -0
- package/dist/types/__overlays__/v3.d.ts +2 -0
- package/dist/types/__react-aria-components__/index.d.ts +1 -0
- package/dist/types/__react-aria__/index.d.ts +1 -0
- package/dist/types/__utilities__/ReversedColors/v3/ReversedColors.d.ts +7 -0
- package/dist/types/__utilities__/ReversedColors/v3/index.d.ts +1 -0
- package/dist/types/__utilities__/v3.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/getNodeText.d.ts +1 -2
- package/dist/types/utils/mergeClassNames.d.ts +8 -0
- package/package.json +8 -3
- package/src/Button/Button/Button.module.scss +33 -23
- package/src/Button/GenericButton/GenericButton.tsx +135 -91
- package/src/Button/utils/_mixins.scss +1 -1
- package/src/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/ButtonGroup/_docs/ButtonGroup.stickersheet.stories.tsx +1 -1
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.tsx +1 -1
- package/src/GuidanceBlock/GuidanceBlock.tsx +1 -1
- package/src/KaizenProvider/KaizenProvider.tsx +5 -7
- package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.tsx +14 -4
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +1 -1
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.tsx +1 -1
- package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.tsx +1 -1
- package/src/Table/Table.tsx +1 -1
- package/src/Tabs/_docs/Tabs.stories.tsx +1 -1
- package/src/Tabs/subcomponents/Tab.tsx +27 -21
- package/src/TitleBlockZen/TitleBlockZen.module.scss +0 -14
- package/src/TitleBlockZen/TitleBlockZen.tsx +1 -1
- package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +54 -0
- package/src/__overlays__/Focusable/v3/Focusable.module.scss +3 -0
- package/src/__overlays__/Focusable/v3/Focusable.tsx +37 -0
- package/src/__overlays__/Focusable/v3/_docs/ApiSpecification.mdx +38 -0
- package/src/__overlays__/Focusable/v3/_docs/Focusable.stories.tsx +24 -0
- package/src/__overlays__/Focusable/v3/index.ts +1 -0
- package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.module.scss +1 -1
- package/src/__overlays__/Tooltip/v1/_docs/Tooltip.mdx +139 -0
- package/src/{Tooltip → __overlays__/Tooltip/v1}/_docs/Tooltip.stickersheet.stories.tsx +1 -1
- package/src/{Tooltip → __overlays__/Tooltip/v1}/_docs/Tooltip.stories.tsx +2 -2
- package/src/__overlays__/Tooltip/v1/index.ts +7 -0
- package/src/{Tooltip → __overlays__/Tooltip/v2}/_docs/Tooltip.mdx +2 -4
- package/src/__overlays__/Tooltip/v2/_docs/Tooltip.stories.tsx +49 -0
- package/src/__overlays__/Tooltip/v2/index.ts +1 -0
- package/src/__overlays__/Tooltip/v3/OverlayArrow.module.scss +43 -0
- package/src/__overlays__/Tooltip/v3/OverlayArrow.tsx +34 -0
- package/src/__overlays__/Tooltip/v3/Tooltip.module.scss +67 -0
- package/src/__overlays__/Tooltip/v3/Tooltip.tsx +101 -0
- package/src/__overlays__/Tooltip/v3/TooltipTrigger.tsx +30 -0
- package/src/__overlays__/Tooltip/v3/_docs/ApiSpecification.mdx +163 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.docs.stories.tsx +203 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.mdx +182 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +219 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.stickersheet.stories.tsx +46 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.stories.tsx +72 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_anatomy.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_placement.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_1.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_2.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_3.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_variant.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_when_to_use.png +0 -0
- package/src/__overlays__/Tooltip/v3/index.ts +2 -0
- package/src/__overlays__/v1.ts +1 -0
- package/src/__overlays__/v2.ts +2 -0
- package/src/__overlays__/v3.ts +2 -0
- package/src/__react-aria-components__/index.ts +1 -0
- package/src/__react-aria__/index.ts +1 -0
- package/src/__utilities__/ReversedColors/v3/ReversedColors.tsx +20 -0
- package/src/__utilities__/ReversedColors/v3/index.ts +1 -0
- package/src/__utilities__/v3.ts +1 -0
- package/src/index.ts +1 -1
- package/src/types/cssVariables.d.ts +7 -0
- package/src/utils/mergeClassNames.ts +32 -0
- package/v1/overlays/package.json +5 -0
- package/v2/overlays/package.json +5 -0
- package/v3/overlays/package.json +5 -0
- package/v3/react-aria/package.json +5 -0
- package/v3/react-aria-components/package.json +5 -0
- package/dist/cjs/Tooltip/Tooltip.module.scss.cjs +0 -21
- package/dist/esm/Tooltip/Tooltip.module.scss.mjs +0 -19
- package/dist/types/AvatarGroup/_docs/example-data.d.ts +0 -8
- package/dist/types/BrandMoment/_docs/ExampleHeaders.d.ts +0 -3
- package/dist/types/Calendar/_docs/controls/defaultMonthControls.d.ts +0 -2
- package/dist/types/Calendar/_docs/controls/weekStartsOnControls.d.ts +0 -2
- package/dist/types/DatePicker/_docs/controls/datePickerLocaleControls.d.ts +0 -2
- package/dist/types/DatePicker/_docs/controls/disabledDayMatchersControls.d.ts +0 -2
- package/dist/types/Filter/FilterBar/context/types.d.ts +0 -28
- package/dist/types/Filter/FilterDatePicker/_docs/controls/disabledDaysControls.d.ts +0 -2
- package/dist/types/Filter/FilterDatePicker/_docs/controls/validationControls.d.ts +0 -2
- package/dist/types/Filter/FilterDateRangePicker/_docs/controls/disabledDaysControls.d.ts +0 -2
- package/dist/types/Filter/FilterDateRangePicker/_docs/controls/validationControls.d.ts +0 -2
- package/dist/types/Filter/FilterMultiSelect/_docs/MockData.d.ts +0 -10
- package/dist/types/Filter/FilterSelect/_docs/mockData.d.ts +0 -6
- package/dist/types/Filter/_docs/controls/renderTriggerControls.d.ts +0 -2
- package/dist/types/Menu/_docs/MenuContentExample.d.ts +0 -8
- package/dist/types/Menu/_docs/examples.d.ts +0 -11
- package/dist/types/Modal/_docs/controls.d.ts +0 -11
- package/dist/types/MultiSelect/MultiSelect.d.ts +0 -23
- package/dist/types/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.d.ts +0 -13
- package/dist/types/Tooltip/index.d.ts +0 -1
- package/dist/types/Workflow/_docs/controls/controls.d.ts +0 -2
- package/dist/types/Workflow/_docs/controls/index.d.ts +0 -1
- package/dist/types/__future__/Select/_docs/mockData.d.ts +0 -6
- package/dist/types/__future__/Select/types.d.ts +0 -22
- package/dist/types/__future__/Workflow/_docs/controls/controls.d.ts +0 -2
- package/dist/types/__future__/Workflow/_docs/controls/index.d.ts +0 -1
- package/src/Tooltip/index.ts +0 -1
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.cjs +0 -0
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.cjs +0 -0
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.cjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.mjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.mjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.mjs +0 -0
- /package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.d.ts +0 -0
- /package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.d.ts +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/_variables.scss +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.tsx +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { HTMLAttributes, ReactNode, useRef } from "react"
|
|
2
|
+
import classnames from "classnames"
|
|
3
|
+
import { FocusableOptions, useFocusable } from "react-aria"
|
|
4
|
+
import styles from "./Focusable.module.scss"
|
|
5
|
+
|
|
6
|
+
export type FocusableProps = {
|
|
7
|
+
children: ReactNode
|
|
8
|
+
} & FocusableOptions &
|
|
9
|
+
HTMLAttributes<HTMLDivElement>
|
|
10
|
+
|
|
11
|
+
export const Focusable = ({
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: FocusableProps): JSX.Element => {
|
|
16
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
17
|
+
const { focusableProps } = useFocusable(props, ref)
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={classnames(styles.focusableWrapper, className)}
|
|
23
|
+
{...focusableProps}
|
|
24
|
+
data-inline-hidden-content
|
|
25
|
+
// We want the div to be focusable for keyboard users,
|
|
26
|
+
// but screen readers will have the VisuallyHidden content
|
|
27
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
28
|
+
tabIndex={0}
|
|
29
|
+
// aria-describedby on div doesn't do anthing so we instead render the content in VisuallyHidden from tooltip
|
|
30
|
+
// but because RAC adds it as it assumes it's interactive element we remove it here
|
|
31
|
+
aria-describedby={undefined}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta } from "@storybook/blocks"
|
|
2
|
+
import { KAIOInstallation, ResourceLinks, SbContent } from "~storybook/components"
|
|
3
|
+
import * as exampleStories from "./Focusable.stories"
|
|
4
|
+
|
|
5
|
+
<Meta title="Overlays/Focusable/v3/API Specification"/>
|
|
6
|
+
|
|
7
|
+
<SbContent>
|
|
8
|
+
# Focusable API Specification (v3)
|
|
9
|
+
|
|
10
|
+
Updated June 25, 2024
|
|
11
|
+
</SbContent>
|
|
12
|
+
|
|
13
|
+
<ResourceLinks
|
|
14
|
+
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/__overlays__/Focusable"
|
|
15
|
+
className="mt-16 !mb-8"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<SbContent className="mb-24">
|
|
19
|
+
<KAIOInstallation exportNames={["Focusable"]} family="overlays" version="3" />
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
Focusable is a utility wrapper to allow users to add focus to a non-focusable element.
|
|
24
|
+
|
|
25
|
+
The main use case is for non semantic components like `Tag` that need a [Tooltip](/docs/overlays-tooltip-v3-usage-guidelines--docs).
|
|
26
|
+
</SbContent>
|
|
27
|
+
|
|
28
|
+
<Canvas className="mb-24" of={exampleStories.Playground} />
|
|
29
|
+
|
|
30
|
+
<SbContent className="mb-64">
|
|
31
|
+
Be aware that this does not negate the need to meet A11Y standards and best practices. Use this utility wrapper with caution.
|
|
32
|
+
</SbContent>
|
|
33
|
+
|
|
34
|
+
<SbContent className="mb-12">
|
|
35
|
+
## API
|
|
36
|
+
</SbContent>
|
|
37
|
+
|
|
38
|
+
<Controls of={exampleStories.Playground} />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { Tag } from "~components/__future__/Tag"
|
|
4
|
+
import { Focusable } from "../index"
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Overlays/Focusable/v3",
|
|
8
|
+
component: Focusable,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
} satisfies Meta<typeof Focusable>
|
|
13
|
+
|
|
14
|
+
export default meta
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof Focusable>
|
|
17
|
+
|
|
18
|
+
export const Playground: Story = {
|
|
19
|
+
render: args => (
|
|
20
|
+
<Focusable {...args}>
|
|
21
|
+
<Tag>Name</Tag>
|
|
22
|
+
</Focusable>
|
|
23
|
+
),
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Focusable"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@import "~@kaizen/design-tokens/sass/color";
|
|
4
4
|
@import "~@kaizen/design-tokens/sass/animation";
|
|
5
5
|
@import "~@kaizen/design-tokens/sass/typography";
|
|
6
|
-
@import "
|
|
6
|
+
@import "../../../../styles/utils/layers";
|
|
7
7
|
@import "./variables";
|
|
8
8
|
|
|
9
9
|
.tooltip {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta } from "@storybook/blocks"
|
|
2
|
+
import { ResourceLinks, Installation } from "~storybook/components"
|
|
3
|
+
import * as TooltipStories from "./Tooltip.stories"
|
|
4
|
+
|
|
5
|
+
<Meta of={TooltipStories} />
|
|
6
|
+
|
|
7
|
+
# Tooltip (v1)
|
|
8
|
+
|
|
9
|
+
<ResourceLinks
|
|
10
|
+
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Tooltip"
|
|
11
|
+
figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=1929%3A32006&mode=design&t=LwTCBZ5E1uRvOA1l-1"
|
|
12
|
+
designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3075604978/Tooltip"
|
|
13
|
+
className="!mb-8"
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
<Installation
|
|
17
|
+
installCommand="pnpm add @kaizen/components"
|
|
18
|
+
importStatement='import { Tooltip } from "@kaizen/components/v1/overlays"'
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
It is recommended that you import from the `v2` entry point.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Overview
|
|
25
|
+
|
|
26
|
+
Adds a popover that will show on hover or focus of the child element, with simple text content.
|
|
27
|
+
|
|
28
|
+
<Canvas of={TooltipStories.Playground} />
|
|
29
|
+
<Controls of={TooltipStories.Playground} />
|
|
30
|
+
|
|
31
|
+
## Accessibility
|
|
32
|
+
|
|
33
|
+
This component wasn't built with accessibility in mind, as a result it's quite easy to implement a tooltip in a non-accessible way. A rethink and rewrite is likely for the future.
|
|
34
|
+
|
|
35
|
+
There's two major accessibility concerns here:
|
|
36
|
+
- Keyboard only users
|
|
37
|
+
- Screen reader (or similar assistive tech) users
|
|
38
|
+
|
|
39
|
+
Failure to meet either of these requirements will result in a critical issue where some people are completely unable to access the information.
|
|
40
|
+
|
|
41
|
+
### Keyboard accessibility
|
|
42
|
+
|
|
43
|
+
For keyboard accessibility, you need to make sure the child you are passing is a focusable element. It's best to keep the contents of this component simple. E.g. just a button:
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
<Tooltip text="Opens in a new tab">
|
|
47
|
+
<Button href="/path" label="Go somewhere" />
|
|
48
|
+
</Tooltip>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Screen reader accessibility
|
|
52
|
+
|
|
53
|
+
Though it won't guarantee the best screen reader accessibility, a good start is to make sure your _direct_ children element is semantic (not a div or span).
|
|
54
|
+
|
|
55
|
+
When your direct child element is semantic, this component will add an `aria-describedby` to that element. E.g. for the link example above, the resulting mark up will be:
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<a href="path" aria-describedby="tooltip">Go somewhere</a>
|
|
59
|
+
<!-- (in a portal) -->
|
|
60
|
+
<div id="tooltip-id">Opens in a new tab</div>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Resulting in a screen reader announcement like:
|
|
64
|
+
`Go somewhere, link, Opens in a new tab`
|
|
65
|
+
|
|
66
|
+
Again, try to keep the contents of your children as simple as possible, ideally only a single natively focusable element like the example above.
|
|
67
|
+
|
|
68
|
+
When your direct child is not semantic, you will get a console warning like this:
|
|
69
|
+
`<Tooltip /> is not directly wrapping a semantic element, screen reader users will not be able to access the tooltip info.`
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Tooltips, Kaizen components and avoiding common pitfalls
|
|
73
|
+
|
|
74
|
+
While technically any Kaizen component can be wrapped by a `Tooltip`, as called out previously, only those with [accessible roles](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles) like `button`, `link` or `heading`, will be readable to assistive technologies.
|
|
75
|
+
|
|
76
|
+
We've created some guidance below with the most common cases for `Tooltip` and how to ensure the additional context is read to the user.
|
|
77
|
+
|
|
78
|
+
#### Button and IconButton
|
|
79
|
+
|
|
80
|
+
<Canvas of={TooltipStories.ButtonsWithTooltip} />
|
|
81
|
+
|
|
82
|
+
While Kaizen buttons are compatible with `Tooltip`, caution is advised when using the custom `component` render prop.
|
|
83
|
+
|
|
84
|
+
```JSX
|
|
85
|
+
<Tooltip text="Contact customer support.">
|
|
86
|
+
<Button
|
|
87
|
+
{...buttonProps}
|
|
88
|
+
component={() => (
|
|
89
|
+
// The most immediate child is a `div`, which has no `role`.
|
|
90
|
+
<div>
|
|
91
|
+
<button type="button">
|
|
92
|
+
Help
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
/>
|
|
97
|
+
</Tooltip>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
In the example above, the `div` in now the direct descendant of `Tooltip`, therefore will no longer be accessible to assistive technologies.
|
|
101
|
+
|
|
102
|
+
#### ButtonGroup
|
|
103
|
+
|
|
104
|
+
The `Tooltip` component must wrap the children of `ButtonGroup` to be accessible to screen readers.
|
|
105
|
+
|
|
106
|
+
<Canvas of={TooltipStories.ButtonGroupWithTooltip} />
|
|
107
|
+
|
|
108
|
+
#### Table headers and tooltips
|
|
109
|
+
|
|
110
|
+
While the composable `Tooltip` is not exposed in the Kaizen `Table`, it is important to call out that the `tooltipInfo` prop in `TableHeaderRowCell` must also have an `onClick` or `href` to be announced to assistive technologies.
|
|
111
|
+
|
|
112
|
+
<Canvas of={TooltipStories.TableHeadersWithTooltips} />
|
|
113
|
+
|
|
114
|
+
Without either of these, the `Tooltip` content will not be readable to keyboard users or assistive technologies.
|
|
115
|
+
|
|
116
|
+
#### Tags
|
|
117
|
+
|
|
118
|
+
Seen in the example below simple `Tag`s with plain text as `children` will not accessible to keyboard users or assistive technologies as it's direct descendant is a `div` with no semantic `role`.
|
|
119
|
+
|
|
120
|
+
<Canvas of={TooltipStories.TagWithHoverOnlyTooltip} />
|
|
121
|
+
|
|
122
|
+
While `Tooltip` should be avoided if there are no interactive states within the `Tag`, internal elements like buttons or links can be wrapped in a `Tooltip` component to add necessary context.
|
|
123
|
+
|
|
124
|
+
<Canvas of={TooltipStories.TagWithTooltip} />
|
|
125
|
+
|
|
126
|
+
The [future Tag](?path=/docs/components-tag-future--docs#overview) offers a composable solution for those needing to add more context to an interactive `Tag`.
|
|
127
|
+
|
|
128
|
+
#### Form components and tooltips
|
|
129
|
+
|
|
130
|
+
While a `Tooltip` can seem like a natural pairing when space is a commodity, form elements still require a concise label that is _ideally_ visible (See MDN's guide on [Tooltip best practices](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tooltip_role#best_practices)).
|
|
131
|
+
|
|
132
|
+
<Canvas of={TooltipStories.CheckboxFieldTooltip} />
|
|
133
|
+
|
|
134
|
+
In the example above, the `Tooltip` content `"Select all users"` is accessible to screen readers via keyboard navigation, however will not be announced when the input receives focus. This a limitation of `CheckboxField` and form components where the immediate `children` of `Tooltip` is a wrapper.
|
|
135
|
+
|
|
136
|
+
<Canvas of={TooltipStories.CheckboxFieldWithDescriptionTooltip} />
|
|
137
|
+
|
|
138
|
+
In these instances, `aria-describedby` can be leveraged to provide a description to the input.
|
|
139
|
+
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
TableRow,
|
|
13
13
|
} from "~components/Table"
|
|
14
14
|
import { Text } from "~components/Text"
|
|
15
|
-
import { Tag } from "~components/__future__"
|
|
15
|
+
import { Tag } from "~components/__future__/Tag"
|
|
16
16
|
import { Tooltip } from "../index"
|
|
17
17
|
|
|
18
18
|
const meta = {
|
|
19
|
-
title: "
|
|
19
|
+
title: "Overlays/Tooltip/v1",
|
|
20
20
|
component: Tooltip,
|
|
21
21
|
args: {
|
|
22
22
|
text: "Example tooltip text.",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Since we can't add a deprecation flag on a * export
|
|
2
|
+
import { Tooltip as TooltipV1, TooltipProps as TooltipPropsV1 } from "./Tooltip"
|
|
3
|
+
|
|
4
|
+
/** * @deprecated use v2 or upgrade to v3 for the latest release */
|
|
5
|
+
export const Tooltip = TooltipV1
|
|
6
|
+
/** * @deprecated use v2 or upgrade to v3 for the latest release */
|
|
7
|
+
export type TooltipProps = TooltipPropsV1
|
|
@@ -4,16 +4,14 @@ import * as TooltipStories from "./Tooltip.stories"
|
|
|
4
4
|
|
|
5
5
|
<Meta of={TooltipStories} />
|
|
6
6
|
|
|
7
|
-
# Tooltip
|
|
7
|
+
# Tooltip (v2)
|
|
8
8
|
|
|
9
9
|
<ResourceLinks
|
|
10
10
|
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Tooltip"
|
|
11
11
|
figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=1929%3A32006&mode=design&t=LwTCBZ5E1uRvOA1l-1"
|
|
12
|
-
designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3075604978/Tooltip"
|
|
13
|
-
className="!mb-8"
|
|
14
12
|
/>
|
|
15
13
|
|
|
16
|
-
<KAIOInstallation exportNames="Tooltip" />
|
|
14
|
+
<KAIOInstallation exportNames="Tooltip" family="overlays" version="2" />
|
|
17
15
|
|
|
18
16
|
## Overview
|
|
19
17
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import * as TooltipV1Stories from "../../v1/_docs/Tooltip.stories"
|
|
4
|
+
import { Tooltip } from "../index"
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Overlays/Tooltip/v2",
|
|
8
|
+
component: Tooltip,
|
|
9
|
+
args: {
|
|
10
|
+
text: "Example tooltip text.",
|
|
11
|
+
},
|
|
12
|
+
decorators: [
|
|
13
|
+
Story => (
|
|
14
|
+
<div className="flex mt-[60px] gap-12">
|
|
15
|
+
<Story />
|
|
16
|
+
</div>
|
|
17
|
+
),
|
|
18
|
+
],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: "centered",
|
|
21
|
+
},
|
|
22
|
+
} satisfies Meta<typeof Tooltip>
|
|
23
|
+
|
|
24
|
+
export default meta
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof meta>
|
|
27
|
+
|
|
28
|
+
export const Playground: Story = TooltipV1Stories.Playground
|
|
29
|
+
|
|
30
|
+
export const OverflowScroll: Story = TooltipV1Stories.OverflowScroll
|
|
31
|
+
|
|
32
|
+
export const ButtonsWithTooltip: Story = TooltipV1Stories.ButtonsWithTooltip
|
|
33
|
+
|
|
34
|
+
export const ButtonGroupWithTooltip: Story = TooltipV1Stories.ButtonsWithTooltip
|
|
35
|
+
|
|
36
|
+
export const TableHeadersWithTooltips: Story =
|
|
37
|
+
TooltipV1Stories.TableHeadersWithTooltips
|
|
38
|
+
|
|
39
|
+
export const TagWithHoverOnlyTooltip: Story =
|
|
40
|
+
TooltipV1Stories.TagWithHoverOnlyTooltip
|
|
41
|
+
|
|
42
|
+
export const TagWithTooltip: Story = TooltipV1Stories.TagWithTooltip
|
|
43
|
+
|
|
44
|
+
export const TagWithCheckboxField: Story = TooltipV1Stories.TagWithCheckboxField
|
|
45
|
+
|
|
46
|
+
export const CheckboxFieldTooltip: Story = TooltipV1Stories.CheckboxFieldTooltip
|
|
47
|
+
|
|
48
|
+
export const CheckboxFieldWithDescriptionTooltip: Story =
|
|
49
|
+
TooltipV1Stories.CheckboxFieldWithDescriptionTooltip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../v1/Tooltip"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import "~@kaizen/design-tokens/sass/shadow";
|
|
2
|
+
@import "~@kaizen/design-tokens/sass/color";
|
|
3
|
+
|
|
4
|
+
.overlayArrow {
|
|
5
|
+
display: flex;
|
|
6
|
+
|
|
7
|
+
// for correct arrow positioning with rounded corners we need to do bit trickery here
|
|
8
|
+
// the positioning is done in js in RAC and works by first getting size of arrow without data-placement, and isn't recomputed after update
|
|
9
|
+
// so we first set padding on arrow from all sides (that'll be used for start position computation)
|
|
10
|
+
// and then we remove it from the oposite axis
|
|
11
|
+
padding: 8px;
|
|
12
|
+
|
|
13
|
+
&[data-placement="top"],
|
|
14
|
+
&[data-placement="bottom"] {
|
|
15
|
+
padding: 0 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&[data-placement="left"],
|
|
19
|
+
&[data-placement="right"] {
|
|
20
|
+
padding: 8px 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
path {
|
|
24
|
+
fill: $color-purple-800;
|
|
25
|
+
box-shadow: $shadow-small-box-shadow;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&[data-placement="right"] svg {
|
|
29
|
+
transform: rotate(90deg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&[data-placement="bottom"] svg {
|
|
33
|
+
transform: rotate(180deg);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&[data-placement="left"] svg {
|
|
37
|
+
transform: rotate(270deg);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.reversed path {
|
|
41
|
+
fill: $color-white;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
OverlayArrow as RACOverlayArrow,
|
|
4
|
+
type OverlayArrowProps,
|
|
5
|
+
} from "react-aria-components"
|
|
6
|
+
import { useReversedColors } from "~components/__utilities__/v3"
|
|
7
|
+
import { mergeClassNames } from "~utils/mergeClassNames"
|
|
8
|
+
|
|
9
|
+
import styles from "./OverlayArrow.module.scss"
|
|
10
|
+
|
|
11
|
+
export { type OverlayArrowProps }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An OverlayArrow renders a custom arrow element relative to an overlay element
|
|
15
|
+
* such as a popover or tooltip such that it aligns with a trigger element.
|
|
16
|
+
*/
|
|
17
|
+
export const OverlayArrow = (props: OverlayArrowProps): JSX.Element => {
|
|
18
|
+
const reverseColors = useReversedColors()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<RACOverlayArrow
|
|
22
|
+
{...props}
|
|
23
|
+
className={mergeClassNames(
|
|
24
|
+
styles.overlayArrow,
|
|
25
|
+
reverseColors && styles.reversed,
|
|
26
|
+
props.className
|
|
27
|
+
)}
|
|
28
|
+
>
|
|
29
|
+
<svg width={8} height={8} viewBox="0 0 8 8">
|
|
30
|
+
<path d="M0 0 L4 4 L8 0" />
|
|
31
|
+
</svg>
|
|
32
|
+
</RACOverlayArrow>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@import "~@kaizen/design-tokens/sass/shadow";
|
|
2
|
+
@import "~@kaizen/design-tokens/sass/border";
|
|
3
|
+
@import "~@kaizen/design-tokens/sass/color";
|
|
4
|
+
@import "~@kaizen/design-tokens/sass/animation";
|
|
5
|
+
@import "~@kaizen/design-tokens/sass/typography";
|
|
6
|
+
@import "~@kaizen/design-tokens/sass/spacing";
|
|
7
|
+
|
|
8
|
+
.tooltip {
|
|
9
|
+
max-width: 200px;
|
|
10
|
+
padding: $spacing-8 $spacing-12;
|
|
11
|
+
color: $color-white;
|
|
12
|
+
text-align: center;
|
|
13
|
+
font-family: $typography-paragraph-extra-small-font-family;
|
|
14
|
+
font-size: $typography-paragraph-extra-small-font-size;
|
|
15
|
+
font-weight: $typography-paragraph-extra-small-font-weight;
|
|
16
|
+
letter-spacing: $typography-paragraph-extra-small-letter-spacing;
|
|
17
|
+
line-height: $typography-paragraph-extra-small-line-height;
|
|
18
|
+
border-radius: $border-solid-border-radius;
|
|
19
|
+
box-shadow: $shadow-small-box-shadow;
|
|
20
|
+
background-color: $color-purple-800;
|
|
21
|
+
text-wrap: pretty;
|
|
22
|
+
|
|
23
|
+
/* fixes FF gap */
|
|
24
|
+
transform: translate3d(0, 0, 0);
|
|
25
|
+
|
|
26
|
+
&.reversed {
|
|
27
|
+
background-color: $color-white;
|
|
28
|
+
color: $color-purple-800;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&[data-placement="top"] {
|
|
32
|
+
--origin: translateY(4px);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&[data-placement="bottom"] {
|
|
36
|
+
--origin: translateY(-4px);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[data-placement="right"] {
|
|
40
|
+
--origin: translateX(-4px);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&[data-placement="left"] {
|
|
44
|
+
--origin: translateX(4px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&[data-entering] {
|
|
48
|
+
animation: slide $animation-duration-fast;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&[data-exiting] {
|
|
52
|
+
animation: slide $animation-duration-fast reverse
|
|
53
|
+
$animation-easing-function-ease-in;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@keyframes slide {
|
|
58
|
+
from {
|
|
59
|
+
transform: var(--origin);
|
|
60
|
+
opacity: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
to {
|
|
64
|
+
transform: translateY(0);
|
|
65
|
+
opacity: 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { forwardRef, useContext, useLayoutEffect, useState } from "react"
|
|
2
|
+
import { VisuallyHidden } from "react-aria"
|
|
3
|
+
import {
|
|
4
|
+
Tooltip as RACTooltip,
|
|
5
|
+
TooltipContext,
|
|
6
|
+
TooltipProps as RACTooltipProps,
|
|
7
|
+
TooltipTriggerStateContext,
|
|
8
|
+
useContextProps,
|
|
9
|
+
} from "react-aria-components"
|
|
10
|
+
import { useReversedColors } from "~components/__utilities__/v3"
|
|
11
|
+
import { mergeClassNames } from "~utils/mergeClassNames"
|
|
12
|
+
import { OverlayArrow } from "./OverlayArrow"
|
|
13
|
+
import styles from "./Tooltip.module.scss"
|
|
14
|
+
|
|
15
|
+
export { TooltipContext }
|
|
16
|
+
|
|
17
|
+
export type TooltipProps = Omit<RACTooltipProps, "offset"> & {
|
|
18
|
+
/**
|
|
19
|
+
* The additional offset applied along the main axis between the element and its
|
|
20
|
+
* anchor element.
|
|
21
|
+
* @default 8
|
|
22
|
+
*/
|
|
23
|
+
offset?: number
|
|
24
|
+
/**
|
|
25
|
+
* The placement of the tooltip relative to the trigger.
|
|
26
|
+
* + we're intentionally limiting the placement options to rtl friendly ones (start, end, top, bottom)
|
|
27
|
+
*/
|
|
28
|
+
placement?:
|
|
29
|
+
| "bottom"
|
|
30
|
+
| "bottom start"
|
|
31
|
+
| "bottom end"
|
|
32
|
+
| "top"
|
|
33
|
+
| "top start"
|
|
34
|
+
| "top end"
|
|
35
|
+
| "start"
|
|
36
|
+
| "start top"
|
|
37
|
+
| "start bottom"
|
|
38
|
+
| "end"
|
|
39
|
+
| "end top"
|
|
40
|
+
| "end bottom"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A tooltip displays a description of an element on hover or focus.
|
|
45
|
+
*/
|
|
46
|
+
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
47
|
+
({ children, className, ...props }, ref): JSX.Element => {
|
|
48
|
+
const [{ triggerRef }] = useContextProps(
|
|
49
|
+
{ children, className, ...props },
|
|
50
|
+
ref,
|
|
51
|
+
TooltipContext
|
|
52
|
+
)
|
|
53
|
+
const contextState = useContext(TooltipTriggerStateContext)
|
|
54
|
+
const reverseColors = useReversedColors()
|
|
55
|
+
const [shouldInlineHiddenContent, setShouldInlineHiddenContent] =
|
|
56
|
+
useState(false)
|
|
57
|
+
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
setShouldInlineHiddenContent(
|
|
60
|
+
!!triggerRef?.current?.getAttribute("data-inline-hidden-content")
|
|
61
|
+
)
|
|
62
|
+
}, [triggerRef])
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<RACTooltip
|
|
67
|
+
ref={ref}
|
|
68
|
+
offset={8}
|
|
69
|
+
{...props}
|
|
70
|
+
className={mergeClassNames(
|
|
71
|
+
styles.tooltip,
|
|
72
|
+
className,
|
|
73
|
+
reverseColors && styles.reversed
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
{renderProps => (
|
|
77
|
+
<>
|
|
78
|
+
<OverlayArrow />
|
|
79
|
+
{typeof children === "function"
|
|
80
|
+
? children(renderProps)
|
|
81
|
+
: children}
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
84
|
+
</RACTooltip>
|
|
85
|
+
{shouldInlineHiddenContent ? (
|
|
86
|
+
<VisuallyHidden>
|
|
87
|
+
{typeof children === "function"
|
|
88
|
+
? children({
|
|
89
|
+
placement: "center",
|
|
90
|
+
isEntering: false,
|
|
91
|
+
isExiting: false,
|
|
92
|
+
state: contextState,
|
|
93
|
+
defaultChildren: undefined,
|
|
94
|
+
})
|
|
95
|
+
: children}
|
|
96
|
+
</VisuallyHidden>
|
|
97
|
+
) : null}
|
|
98
|
+
</>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
TooltipTrigger as RACTooltipTrigger,
|
|
4
|
+
TooltipTriggerComponentProps,
|
|
5
|
+
} from "react-aria-components"
|
|
6
|
+
|
|
7
|
+
export type TooltipTriggerProps = Omit<
|
|
8
|
+
TooltipTriggerComponentProps,
|
|
9
|
+
"delay" | "closeDelay"
|
|
10
|
+
> & {
|
|
11
|
+
/**
|
|
12
|
+
* The delay time for the tooltip to show up. [See guidelines](https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance).
|
|
13
|
+
* @default 300
|
|
14
|
+
*/
|
|
15
|
+
delay?: number
|
|
16
|
+
/**
|
|
17
|
+
* The delay time for the tooltip to close. [See guidelines](https://spectrum.adobe.com/page/tooltip/#Warmup-and-cooldown).
|
|
18
|
+
* @default 300
|
|
19
|
+
*/
|
|
20
|
+
closeDelay?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
|
|
25
|
+
* the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
|
|
26
|
+
* relative to the trigger.
|
|
27
|
+
*/
|
|
28
|
+
export const TooltipTrigger = (props: TooltipTriggerProps): JSX.Element => (
|
|
29
|
+
<RACTooltipTrigger delay={300} closeDelay={300} {...props} />
|
|
30
|
+
)
|