@bitrise/bitkit-v2 0.3.462 → 0.3.463
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/AGENTS.md +1 -1
- package/dist/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.d.ts +12 -12
- package/dist/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.js +20 -22
- package/dist/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.js.map +1 -1
- package/dist/components/BitkitLabeledData/BitkitLabeledData.d.ts +3 -3
- package/dist/components/BitkitLabeledData/BitkitLabeledData.js +11 -2
- package/dist/components/BitkitLabeledData/BitkitLabeledData.js.map +1 -1
- package/dist/components/BitkitTable/BitkitDefinitionColumnHeader.d.ts +1 -1
- package/dist/components/BitkitTable/BitkitDefinitionColumnHeader.js +16 -19
- package/dist/components/BitkitTable/BitkitDefinitionColumnHeader.js.map +1 -1
- package/dist/components/BitkitToggletip/BitkitToggletip.d.ts +59 -0
- package/dist/components/BitkitToggletip/BitkitToggletip.js +107 -0
- package/dist/components/BitkitToggletip/BitkitToggletip.js.map +1 -0
- package/dist/components/BitkitTooltip/BitkitTooltip.d.ts +7 -23
- package/dist/components/BitkitTooltip/BitkitTooltip.js +14 -45
- package/dist/components/BitkitTooltip/BitkitTooltip.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/main.js +2 -1
- package/dist/theme/common/TooltipAndToggletip.common.d.ts +90 -0
- package/dist/theme/common/TooltipAndToggletip.common.js +72 -0
- package/dist/theme/common/TooltipAndToggletip.common.js.map +1 -0
- package/dist/theme/slot-recipes/Toggletip.recipe.d.ts +60 -0
- package/dist/theme/slot-recipes/Toggletip.recipe.js +31 -0
- package/dist/theme/slot-recipes/Toggletip.recipe.js.map +1 -0
- package/dist/theme/slot-recipes/Tooltip.recipe.d.ts +34 -34
- package/dist/theme/slot-recipes/Tooltip.recipe.js +4 -61
- package/dist/theme/slot-recipes/Tooltip.recipe.js.map +1 -1
- package/dist/theme/slot-recipes/index.d.ts +89 -34
- package/dist/theme/slot-recipes/index.js +2 -0
- package/dist/theme/slot-recipes/index.js.map +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -230,7 +230,7 @@ Bitkit components use consistent prop names across the library:
|
|
|
230
230
|
|
|
231
231
|
**Exceptions** — a few component groups intentionally own their own layout and don't accept arbitrary style props from outside:
|
|
232
232
|
- Page-level overlays: `BitkitDialog`, `BitkitFormDialog`, `BitkitStepsDialog`, `BitkitDrawer`, `BitkitCalendar`, `BitkitTour` — they own their layout; where it's configurable at all, it's through their own props (`size`, `maxHeight`, …), not style props from outside.
|
|
233
|
-
- Floating positioned components: `BitkitTooltip`, `BitkitLabelTooltip`, `BitkitDefinitionTooltip`, `BitkitOverflowTooltip`, `BitkitToast`, `BitkitActionMenu`, `BitkitSelectMenu`, `BitkitMultiselectMenu` — their layout is positioned automatically; pass styling via the component's own props instead of a wrapper.
|
|
233
|
+
- Floating positioned components: `BitkitTooltip`, `BitkitLabelTooltip`, `BitkitDefinitionTooltip`, `BitkitOverflowTooltip`, `BitkitToggletip`, `BitkitToast`, `BitkitActionMenu`, `BitkitSelectMenu`, `BitkitMultiselectMenu` — their layout is positioned automatically; pass styling via the component's own props instead of a wrapper.
|
|
234
234
|
|
|
235
235
|
> **For everything else, if a style prop doesn't take effect on a Bitkit component, that's a bug in the component, not a styling task.** Stop, tell the user something looks off in Bitkit so they can flag it to the Bitkit team — don't quietly add a `<Box>` workaround. Each silent workaround hides a regression and bakes the wrapper pattern into the codebase.
|
|
236
236
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BitkitTooltipProps } from '../BitkitTooltip/BitkitTooltip';
|
|
1
|
+
import { BitkitToggletipProps } from '../BitkitToggletip/BitkitToggletip';
|
|
3
2
|
export interface BitkitDefinitionTooltipProps {
|
|
4
|
-
/** Action button
|
|
5
|
-
button?:
|
|
3
|
+
/** Action button below the definition. Only with `method="click"`: a hover tooltip holds text only. */
|
|
4
|
+
button?: BitkitToggletipProps['button'];
|
|
6
5
|
/** The term being defined. Rendered as the underlined trigger, so plain text only. */
|
|
7
6
|
children: string;
|
|
8
7
|
/**
|
|
@@ -11,16 +10,17 @@ export interface BitkitDefinitionTooltipProps {
|
|
|
11
10
|
*/
|
|
12
11
|
disablePortal?: boolean;
|
|
13
12
|
/** Target for the "Learn more" link. `_blank` also sets `rel="noopener noreferrer"`. */
|
|
14
|
-
learnMoreTarget?:
|
|
15
|
-
/** Adds a "Learn more" link pointing here
|
|
16
|
-
learnMoreUrl?:
|
|
13
|
+
learnMoreTarget?: BitkitToggletipProps['learnMoreTarget'];
|
|
14
|
+
/** Adds a "Learn more" link pointing here. Only with `method="click"`: a hover tooltip holds text only. */
|
|
15
|
+
learnMoreUrl?: BitkitToggletipProps['learnMoreUrl'];
|
|
17
16
|
/**
|
|
18
|
-
* How the definition opens. `click` (default)
|
|
19
|
-
*
|
|
17
|
+
* How the definition opens. `click` (default) is a `BitkitToggletip`: it opens on click, tap and
|
|
18
|
+
* Enter, stays open, and its link and button take focus. `hover` is a plain `BitkitTooltip`, text
|
|
19
|
+
* only — `learnMoreUrl` and `button` are ignored there.
|
|
20
20
|
*/
|
|
21
21
|
method?: 'click' | 'hover';
|
|
22
22
|
/** Where the tooltip sits relative to the term (default `top`). It flips if space is short. */
|
|
23
|
-
placement?:
|
|
23
|
+
placement?: BitkitToggletipProps['placement'];
|
|
24
24
|
/** The definition itself. */
|
|
25
25
|
text: string;
|
|
26
26
|
/** Type size of the term, to match the surrounding copy. */
|
|
@@ -33,8 +33,8 @@ export interface BitkitDefinitionTooltipProps {
|
|
|
33
33
|
* on demand. Unlike `BitkitTooltip`, the trigger is the content — a `<button>` wrapping the term —
|
|
34
34
|
* so it is reachable by keyboard on its own.
|
|
35
35
|
*
|
|
36
|
-
* Defaults to `method="click"`,
|
|
37
|
-
* `learnMoreUrl` or `button` inside it
|
|
36
|
+
* Defaults to `method="click"`, a toggletip: it latches the definition open, which is what makes a
|
|
37
|
+
* `learnMoreUrl` or `button` inside it reachable by pointer, touch and keyboard.
|
|
38
38
|
*/
|
|
39
39
|
declare const BitkitDefinitionTooltip: {
|
|
40
40
|
({ button, children, disablePortal, learnMoreTarget, learnMoreUrl, method, placement, text, textSize, truncate, }: BitkitDefinitionTooltipProps): import('react').JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BitkitTooltip from "../BitkitTooltip/BitkitTooltip.js";
|
|
2
|
+
import BitkitToggletip from "../BitkitToggletip/BitkitToggletip.js";
|
|
2
3
|
import { chakra, useRecipe } from "@chakra-ui/react/styled-system";
|
|
3
|
-
import { useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region lib/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.tsx
|
|
6
6
|
/**
|
|
@@ -8,36 +8,34 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
* on demand. Unlike `BitkitTooltip`, the trigger is the content — a `<button>` wrapping the term —
|
|
9
9
|
* so it is reachable by keyboard on its own.
|
|
10
10
|
*
|
|
11
|
-
* Defaults to `method="click"`,
|
|
12
|
-
* `learnMoreUrl` or `button` inside it
|
|
11
|
+
* Defaults to `method="click"`, a toggletip: it latches the definition open, which is what makes a
|
|
12
|
+
* `learnMoreUrl` or `button` inside it reachable by pointer, touch and keyboard.
|
|
13
13
|
*/
|
|
14
14
|
var BitkitDefinitionTooltip = ({ button, children, disablePortal, learnMoreTarget, learnMoreUrl, method = "click", placement = "top", text, textSize, truncate = true }) => {
|
|
15
15
|
const style = useRecipe({ key: "definitionTooltip" });
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const term = /* @__PURE__ */ jsx(chakra.button, {
|
|
17
|
+
css: style({
|
|
18
|
+
method,
|
|
19
|
+
textSize
|
|
20
|
+
}),
|
|
21
|
+
truncate,
|
|
22
|
+
type: "button",
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
if (method === "hover") return /* @__PURE__ */ jsx(BitkitTooltip, {
|
|
26
|
+
disablePortal,
|
|
27
|
+
placement,
|
|
28
|
+
text,
|
|
29
|
+
children: term
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ jsx(BitkitToggletip, {
|
|
18
32
|
button,
|
|
19
|
-
closeOnClick: method === "click" ? false : void 0,
|
|
20
33
|
disablePortal,
|
|
21
34
|
learnMoreTarget,
|
|
22
35
|
learnMoreUrl,
|
|
23
|
-
onOpenChange: method === "click" ? ({ open: nextOpen }) => {
|
|
24
|
-
if (!nextOpen) setOpen(false);
|
|
25
|
-
} : void 0,
|
|
26
|
-
open: method === "click" ? open : void 0,
|
|
27
|
-
openDelay: method === "click" ? Infinity : void 0,
|
|
28
36
|
placement,
|
|
29
37
|
text,
|
|
30
|
-
children:
|
|
31
|
-
"aria-expanded": method === "click" ? open : void 0,
|
|
32
|
-
css: style({
|
|
33
|
-
method,
|
|
34
|
-
textSize
|
|
35
|
-
}),
|
|
36
|
-
onClick: method === "click" ? () => setOpen(!open) : void 0,
|
|
37
|
-
truncate,
|
|
38
|
-
type: "button",
|
|
39
|
-
children
|
|
40
|
-
})
|
|
38
|
+
children: term
|
|
41
39
|
});
|
|
42
40
|
};
|
|
43
41
|
BitkitDefinitionTooltip.displayName = "BitkitDefinitionTooltip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitDefinitionTooltip.js","names":[],"sources":["../../../lib/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.tsx"],"sourcesContent":["import { chakra, useRecipe } from '@chakra-ui/react/styled-system';\nimport { type
|
|
1
|
+
{"version":3,"file":"BitkitDefinitionTooltip.js","names":[],"sources":["../../../lib/components/BitkitDefinitionTooltip/BitkitDefinitionTooltip.tsx"],"sourcesContent":["import { chakra, useRecipe } from '@chakra-ui/react/styled-system';\n\nimport BitkitToggletip, { type BitkitToggletipProps } from '../BitkitToggletip/BitkitToggletip';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\nexport interface BitkitDefinitionTooltipProps {\n /** Action button below the definition. Only with `method=\"click\"`: a hover tooltip holds text only. */\n button?: BitkitToggletipProps['button'];\n /** The term being defined. Rendered as the underlined trigger, so plain text only. */\n children: string;\n /**\n * Render the tooltip inline instead of in a portal. Only needed when it must stay inside its\n * parent's DOM subtree — a dialog already sets this for you.\n */\n disablePortal?: boolean;\n /** Target for the \"Learn more\" link. `_blank` also sets `rel=\"noopener noreferrer\"`. */\n learnMoreTarget?: BitkitToggletipProps['learnMoreTarget'];\n /** Adds a \"Learn more\" link pointing here. Only with `method=\"click\"`: a hover tooltip holds text only. */\n learnMoreUrl?: BitkitToggletipProps['learnMoreUrl'];\n /**\n * How the definition opens. `click` (default) is a `BitkitToggletip`: it opens on click, tap and\n * Enter, stays open, and its link and button take focus. `hover` is a plain `BitkitTooltip`, text\n * only — `learnMoreUrl` and `button` are ignored there.\n */\n method?: 'click' | 'hover';\n /** Where the tooltip sits relative to the term (default `top`). It flips if space is short. */\n placement?: BitkitToggletipProps['placement'];\n /** The definition itself. */\n text: string;\n /** Type size of the term, to match the surrounding copy. */\n textSize?: 'lg' | 'md' | 'sm';\n /** Truncate the term with an ellipsis when it doesn't fit (default `true`). */\n truncate?: boolean;\n}\n\n/**\n * An inline glossary term: the word stays in the sentence, underlined, and reveals its definition\n * on demand. Unlike `BitkitTooltip`, the trigger is the content — a `<button>` wrapping the term —\n * so it is reachable by keyboard on its own.\n *\n * Defaults to `method=\"click\"`, a toggletip: it latches the definition open, which is what makes a\n * `learnMoreUrl` or `button` inside it reachable by pointer, touch and keyboard.\n */\nconst BitkitDefinitionTooltip = ({\n button,\n children,\n disablePortal,\n learnMoreTarget,\n learnMoreUrl,\n method = 'click',\n placement = 'top',\n text,\n textSize,\n truncate = true,\n}: BitkitDefinitionTooltipProps) => {\n const style = useRecipe({ key: 'definitionTooltip' });\n\n const term = (\n // chakra.button: no named primitive attaches a recipe to a bare trigger button\n <chakra.button css={style({ method, textSize })} truncate={truncate} type=\"button\">\n {children}\n </chakra.button>\n );\n\n if (method === 'hover') {\n return (\n <BitkitTooltip disablePortal={disablePortal} placement={placement} text={text}>\n {term}\n </BitkitTooltip>\n );\n }\n\n return (\n <BitkitToggletip\n button={button}\n disablePortal={disablePortal}\n learnMoreTarget={learnMoreTarget}\n learnMoreUrl={learnMoreUrl}\n placement={placement}\n text={text}\n >\n {term}\n </BitkitToggletip>\n );\n};\n\nBitkitDefinitionTooltip.displayName = 'BitkitDefinitionTooltip';\n\nexport default BitkitDefinitionTooltip;\n"],"mappings":";;;;;;;;;;;;;AA2CA,IAAM,2BAA2B,EAC/B,QACA,UACA,eACA,iBACA,cACA,SAAS,SACT,YAAY,OACZ,MACA,UACA,WAAW,WACuB;CAClC,MAAM,QAAQ,UAAU,EAAE,KAAK,oBAAoB,CAAC;CAEpD,MAAM,OAEJ,oBAAC,OAAO,QAAR;EAAe,KAAK,MAAM;GAAE;GAAQ;EAAS,CAAC;EAAa;EAAU,MAAK;EACvE;CACY,CAAA;CAGjB,IAAI,WAAW,SACb,OACE,oBAAC,eAAD;EAA8B;EAA0B;EAAiB;EACtE,UAAA;CACY,CAAA;CAInB,OACE,oBAAC,iBAAD;EACU;EACO;EACE;EACH;EACH;EACL;EAEL,UAAA;CACc,CAAA;AAErB;AAEA,wBAAwB,cAAc"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BoxProps } from '@chakra-ui/react/box';
|
|
2
|
-
import {
|
|
2
|
+
import { BitkitToggletipProps } from '../BitkitToggletip/BitkitToggletip';
|
|
3
3
|
export interface BitkitLabeledDataProps extends Omit<BoxProps, 'colorPalette'> {
|
|
4
4
|
label: string;
|
|
5
5
|
labelVariant?: 'primary' | 'secondary';
|
|
6
|
-
learnMoreTarget?:
|
|
7
|
-
learnMoreUrl?:
|
|
6
|
+
learnMoreTarget?: BitkitToggletipProps['learnMoreTarget'];
|
|
7
|
+
learnMoreUrl?: BitkitToggletipProps['learnMoreUrl'];
|
|
8
8
|
limitValue?: string;
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
showWarning?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import IconInfoCircle from "../../icons/IconInfoCircle.js";
|
|
2
2
|
import IconWarningYellow from "../../icons/IconWarningYellow.js";
|
|
3
3
|
import BitkitTooltip from "../BitkitTooltip/BitkitTooltip.js";
|
|
4
|
+
import BitkitToggletip from "../BitkitToggletip/BitkitToggletip.js";
|
|
4
5
|
import BitkitDefinitionTooltip from "../BitkitDefinitionTooltip/BitkitDefinitionTooltip.js";
|
|
5
6
|
import { chakra, useSlotRecipe } from "@chakra-ui/react/styled-system";
|
|
6
7
|
import { forwardRef } from "react";
|
|
@@ -70,15 +71,23 @@ var BitkitLabeledData = forwardRef((props, ref) => {
|
|
|
70
71
|
}
|
|
71
72
|
const labelContent = /* @__PURE__ */ jsxs(chakra.dt, {
|
|
72
73
|
css: styles.label,
|
|
73
|
-
children: [label, !!tooltip && /* @__PURE__ */ jsx(
|
|
74
|
+
children: [label, !!tooltip && (learnMoreUrl ? /* @__PURE__ */ jsx(BitkitToggletip, {
|
|
74
75
|
learnMoreTarget,
|
|
75
76
|
learnMoreUrl,
|
|
76
77
|
text: tooltip,
|
|
78
|
+
triggerAriaLabel: `About ${label.replace(/[::]$/, "")}`,
|
|
79
|
+
wrapTrigger: true,
|
|
77
80
|
children: /* @__PURE__ */ jsx(IconInfoCircle, {
|
|
78
81
|
size: "16",
|
|
79
82
|
color: "icon/tertiary"
|
|
80
83
|
})
|
|
81
|
-
})
|
|
84
|
+
}) : /* @__PURE__ */ jsx(BitkitTooltip, {
|
|
85
|
+
text: tooltip,
|
|
86
|
+
children: /* @__PURE__ */ jsx(IconInfoCircle, {
|
|
87
|
+
size: "16",
|
|
88
|
+
color: "icon/tertiary"
|
|
89
|
+
})
|
|
90
|
+
}))]
|
|
82
91
|
});
|
|
83
92
|
if (state === "skeleton") return /* @__PURE__ */ jsxs(chakra.dl, {
|
|
84
93
|
css: styles.root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitLabeledData.js","names":[],"sources":["../../../lib/components/BitkitLabeledData/BitkitLabeledData.tsx"],"sourcesContent":["import { type BoxProps } from '@chakra-ui/react/box';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef } from 'react';\n\nimport { IconInfoCircle, IconWarningYellow } from '../../icons';\nimport BitkitDefinitionTooltip from '../BitkitDefinitionTooltip/BitkitDefinitionTooltip';\nimport
|
|
1
|
+
{"version":3,"file":"BitkitLabeledData.js","names":[],"sources":["../../../lib/components/BitkitLabeledData/BitkitLabeledData.tsx"],"sourcesContent":["import { type BoxProps } from '@chakra-ui/react/box';\nimport { Skeleton } from '@chakra-ui/react/skeleton';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef } from 'react';\n\nimport { IconInfoCircle, IconWarningYellow } from '../../icons';\nimport BitkitDefinitionTooltip from '../BitkitDefinitionTooltip/BitkitDefinitionTooltip';\nimport BitkitToggletip, { type BitkitToggletipProps } from '../BitkitToggletip/BitkitToggletip';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\n// --- Types ---\n\nexport interface BitkitLabeledDataProps extends Omit<BoxProps, 'colorPalette'> {\n label: string;\n labelVariant?: 'primary' | 'secondary';\n learnMoreTarget?: BitkitToggletipProps['learnMoreTarget'];\n learnMoreUrl?: BitkitToggletipProps['learnMoreUrl'];\n limitValue?: string;\n placeholder?: string;\n showWarning?: boolean;\n size?: 'lg' | '2xl' | '3xl' | 'sm' | 'md';\n state?: 'default' | 'skeleton';\n subtext?: string;\n tooltip?: string;\n tooltipAnchor?: 'label' | 'value';\n value?: string;\n variant?: 'default' | 'inline';\n}\n\nconst SKELETON_VALUE_HEIGHTS = { lg: '24', '2xl': '36px', '3xl': '40' } as const;\n\n// --- Component ---\n\nconst BitkitLabeledData = forwardRef<HTMLElement, BitkitLabeledDataProps>((props, ref) => {\n const {\n label,\n labelVariant = 'primary',\n learnMoreTarget,\n learnMoreUrl,\n limitValue,\n placeholder = 'N/A',\n showWarning,\n size = 'lg',\n state = 'default',\n subtext,\n tooltip,\n tooltipAnchor = 'value',\n value,\n variant = 'default',\n ...rest\n } = props;\n\n const styles = useSlotRecipe({ key: 'labeledData' })({\n size: variant === 'inline' ? undefined : (size as 'lg' | '2xl' | '3xl'),\n });\n\n // --- Inline variant ---\n if (variant === 'inline') {\n const isSm = size === 'sm';\n const isPrimary = labelVariant === 'primary';\n const labelTextStyle = isPrimary\n ? isSm\n ? 'body/sm/semibold'\n : 'body/md/semibold'\n : isSm\n ? 'body/sm/regular'\n : 'body/md/regular';\n const labelEndsWithColon = label.endsWith(':') || label.endsWith(':');\n const colonSuffix = labelEndsWithColon ? '' : ':';\n\n if (state === 'skeleton') {\n return (\n <chakra.div ref={ref} display=\"flex\" alignItems=\"center\" gap=\"8\" {...rest}>\n {!!showWarning && <IconWarningYellow size=\"16\" />}\n <chakra.div display=\"flex\" alignItems=\"center\" gap=\"4\">\n <chakra.span textStyle={labelTextStyle} color={isPrimary ? 'text/primary' : 'text/secondary'}>\n {label}\n {colonSuffix}\n </chakra.span>\n <Skeleton height={isSm ? '16' : '20'} width=\"64\" />\n </chakra.div>\n </chakra.div>\n );\n }\n\n const wrapWithTooltip = (text: string, anchor: 'label' | 'value') =>\n tooltip && tooltipAnchor === anchor ? (\n <BitkitDefinitionTooltip learnMoreTarget={learnMoreTarget} learnMoreUrl={learnMoreUrl} text={tooltip}>\n {text}\n </BitkitDefinitionTooltip>\n ) : (\n text\n );\n\n return (\n <chakra.div ref={ref} display=\"flex\" alignItems=\"center\" gap=\"8\" {...rest}>\n {!!showWarning && <IconWarningYellow size=\"16\" />}\n <chakra.div display=\"flex\" alignItems=\"center\" gap=\"4\">\n <chakra.span textStyle={labelTextStyle} color={isPrimary ? 'text/primary' : 'text/secondary'}>\n {wrapWithTooltip(label, 'label')}\n {colonSuffix}\n </chakra.span>\n <chakra.span\n textStyle={isSm ? 'body/sm/regular' : 'body/md/regular'}\n color={!value ? 'text/tertiary' : 'text/body'}\n >\n {!value ? placeholder : wrapWithTooltip(value, 'value')}\n </chakra.span>\n </chakra.div>\n </chakra.div>\n );\n }\n\n // --- Default variant ---\n\n const labelContent = (\n <chakra.dt css={styles.label}>\n {label}\n {!!tooltip &&\n // A link needs a toggletip to be reachable; without one, a hover tooltip is enough.\n (learnMoreUrl ? (\n <BitkitToggletip\n learnMoreTarget={learnMoreTarget}\n learnMoreUrl={learnMoreUrl}\n text={tooltip}\n triggerAriaLabel={`About ${label.replace(/[::]$/, '')}`}\n wrapTrigger\n >\n <IconInfoCircle size=\"16\" color=\"icon/tertiary\" />\n </BitkitToggletip>\n ) : (\n <BitkitTooltip text={tooltip}>\n <IconInfoCircle size=\"16\" color=\"icon/tertiary\" />\n </BitkitTooltip>\n ))}\n </chakra.dt>\n );\n\n if (state === 'skeleton') {\n return (\n <chakra.dl css={styles.root} ref={ref} {...(rest as Record<string, unknown>)}>\n {labelContent}\n <Skeleton height={SKELETON_VALUE_HEIGHTS[size as keyof typeof SKELETON_VALUE_HEIGHTS]} width=\"128\" />\n <Skeleton height=\"20\" width=\"128\" />\n </chakra.dl>\n );\n }\n\n return (\n <chakra.dl css={styles.root} ref={ref} {...(rest as Record<string, unknown>)}>\n {labelContent}\n <chakra.dd css={styles.value}>\n {!value ? (\n <chakra.span color=\"text/tertiary\">{placeholder}</chakra.span>\n ) : (\n <>\n {value}\n {!!limitValue && <chakra.span css={styles.limit}>/ {limitValue}</chakra.span>}\n </>\n )}\n </chakra.dd>\n {!!subtext && <chakra.dd css={styles.helpText}>{subtext}</chakra.dd>}\n </chakra.dl>\n );\n});\n\nBitkitLabeledData.displayName = 'BitkitLabeledData';\n\nexport default BitkitLabeledData;\n"],"mappings":";;;;;;;;;;AA6BA,IAAM,yBAAyB;CAAE,IAAI;CAAM,OA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IAE7D,qBAAA,YAAA,EAAA,UAAA,CACG,OACA,CAAC,CAAC,cAAc,qBAAC,OAAO,MAAR;KAAa,KAAK,OAAO;KAAzB,UAAA,CAAgC,MAAG,UAAwB;IAC5E,CAAA,CAAA,EAAA,CAAA;GAEK,CAAA;GACV,CAAC,CAAC,WAAW,oBAAC,OAAO,IAAR;IAAW,KAAK,OAAO;IAAW,UAAA;GAAmB,CAAA;EAC1D;;AAEf,CAAC;AAED,kBAAkB,cAAc"}
|
|
@@ -13,7 +13,7 @@ export interface BitkitDefinitionColumnHeaderProps extends Omit<Table.ColumnHead
|
|
|
13
13
|
* demand. It is `BitkitDefinitionTooltip` for a table header — same props, same behaviour, except the
|
|
14
14
|
* title keeps the header's own type (`heading/h5`) instead of the body type that component pins.
|
|
15
15
|
*
|
|
16
|
-
* That type is also why it composes `BitkitTooltip` rather than rendering a `BitkitDefinitionTooltip`:
|
|
16
|
+
* That type is also why it composes `BitkitToggletip` / `BitkitTooltip` rather than rendering a `BitkitDefinitionTooltip`:
|
|
17
17
|
* the latter's recipe always applies a `textSize`, and there is no value for it that means "inherit".
|
|
18
18
|
*
|
|
19
19
|
* Only the title is the trigger, so the rest of the header stays inert. Everything else a
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BitkitTooltip from "../BitkitTooltip/BitkitTooltip.js";
|
|
2
|
+
import BitkitToggletip from "../BitkitToggletip/BitkitToggletip.js";
|
|
2
3
|
import { chakra } from "@chakra-ui/react/styled-system";
|
|
3
|
-
import { forwardRef
|
|
4
|
+
import { forwardRef } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
6
7
|
//#region lib/components/BitkitTable/BitkitDefinitionColumnHeader.tsx
|
|
@@ -9,7 +10,7 @@ import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
|
9
10
|
* demand. It is `BitkitDefinitionTooltip` for a table header — same props, same behaviour, except the
|
|
10
11
|
* title keeps the header's own type (`heading/h5`) instead of the body type that component pins.
|
|
11
12
|
*
|
|
12
|
-
* That type is also why it composes `BitkitTooltip` rather than rendering a `BitkitDefinitionTooltip`:
|
|
13
|
+
* That type is also why it composes `BitkitToggletip` / `BitkitTooltip` rather than rendering a `BitkitDefinitionTooltip`:
|
|
13
14
|
* the latter's recipe always applies a `textSize`, and there is no value for it that means "inherit".
|
|
14
15
|
*
|
|
15
16
|
* Only the title is the trigger, so the rest of the header stays inert. Everything else a
|
|
@@ -17,32 +18,28 @@ import { Table, useTableStyles } from "@chakra-ui/react/table";
|
|
|
17
18
|
*/
|
|
18
19
|
var BitkitDefinitionColumnHeader = forwardRef(({ button, children, disablePortal, learnMoreTarget, learnMoreUrl, method = "click", placement, text, ...rest }, ref) => {
|
|
19
20
|
const styles = useTableStyles();
|
|
20
|
-
const
|
|
21
|
-
|
|
21
|
+
const title = /* @__PURE__ */ jsx(chakra.button, {
|
|
22
|
+
css: styles.definitionTrigger,
|
|
23
|
+
truncate: true,
|
|
24
|
+
type: "button",
|
|
25
|
+
children
|
|
26
|
+
});
|
|
22
27
|
return /* @__PURE__ */ jsx(Table.ColumnHeader, {
|
|
23
28
|
ref,
|
|
24
29
|
...rest,
|
|
25
|
-
children: /* @__PURE__ */ jsx(BitkitTooltip, {
|
|
30
|
+
children: method === "hover" ? /* @__PURE__ */ jsx(BitkitTooltip, {
|
|
31
|
+
disablePortal,
|
|
32
|
+
placement,
|
|
33
|
+
text,
|
|
34
|
+
children: title
|
|
35
|
+
}) : /* @__PURE__ */ jsx(BitkitToggletip, {
|
|
26
36
|
button,
|
|
27
|
-
closeOnClick: isClick ? false : void 0,
|
|
28
37
|
disablePortal,
|
|
29
38
|
learnMoreTarget,
|
|
30
39
|
learnMoreUrl,
|
|
31
|
-
onOpenChange: isClick ? ({ open: nextOpen }) => {
|
|
32
|
-
if (!nextOpen) setOpen(false);
|
|
33
|
-
} : void 0,
|
|
34
|
-
open: isClick ? open : void 0,
|
|
35
|
-
openDelay: isClick ? Infinity : void 0,
|
|
36
40
|
placement,
|
|
37
41
|
text,
|
|
38
|
-
children:
|
|
39
|
-
"aria-expanded": isClick ? open : void 0,
|
|
40
|
-
css: styles.definitionTrigger,
|
|
41
|
-
onClick: isClick ? () => setOpen(!open) : void 0,
|
|
42
|
-
truncate: true,
|
|
43
|
-
type: "button",
|
|
44
|
-
children
|
|
45
|
-
})
|
|
42
|
+
children: title
|
|
46
43
|
})
|
|
47
44
|
});
|
|
48
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitDefinitionColumnHeader.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitDefinitionColumnHeader.tsx"],"sourcesContent":["import { chakra } from '@chakra-ui/react/styled-system';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { forwardRef
|
|
1
|
+
{"version":3,"file":"BitkitDefinitionColumnHeader.js","names":[],"sources":["../../../lib/components/BitkitTable/BitkitDefinitionColumnHeader.tsx"],"sourcesContent":["import { chakra } from '@chakra-ui/react/styled-system';\nimport { Table, useTableStyles } from '@chakra-ui/react/table';\nimport { forwardRef } from 'react';\n\nimport { type BitkitDefinitionTooltipProps } from '../BitkitDefinitionTooltip/BitkitDefinitionTooltip';\nimport BitkitToggletip from '../BitkitToggletip/BitkitToggletip';\nimport BitkitTooltip from '../BitkitTooltip/BitkitTooltip';\n\n/**\n * Everything `BitkitDefinitionTooltip` takes — `children` is the column title, `text` the definition\n * — on top of everything a `BitkitTable.ColumnHeader` takes. The two the header owns are gone: `textSize`,\n * because the point is to keep the header's own type, and the tooltip's `truncate`, because the title\n * always truncates and `truncate` stays the header cell's own style prop.\n */\nexport interface BitkitDefinitionColumnHeaderProps\n extends Omit<Table.ColumnHeaderProps, 'children'>, Omit<BitkitDefinitionTooltipProps, 'textSize' | 'truncate'> {}\n\n/**\n * A column header whose title is a glossary term: underlined, and revealing what the column means on\n * demand. It is `BitkitDefinitionTooltip` for a table header — same props, same behaviour, except the\n * title keeps the header's own type (`heading/h5`) instead of the body type that component pins.\n *\n * That type is also why it composes `BitkitToggletip` / `BitkitTooltip` rather than rendering a `BitkitDefinitionTooltip`:\n * the latter's recipe always applies a `textSize`, and there is no value for it that means \"inherit\".\n *\n * Only the title is the trigger, so the rest of the header stays inert. Everything else a\n * `BitkitTable.ColumnHeader` takes — `textAlign`, `width`, `colSpan` — still applies.\n */\nconst BitkitDefinitionColumnHeader = forwardRef<HTMLTableCellElement, BitkitDefinitionColumnHeaderProps>(\n (\n { button, children, disablePortal, learnMoreTarget, learnMoreUrl, method = 'click', placement, text, ...rest },\n ref,\n ) => {\n const styles = useTableStyles();\n\n const title = (\n // chakra.button: no named primitive attaches a recipe slot to a bare trigger button\n <chakra.button css={styles.definitionTrigger} truncate type=\"button\">\n {children}\n </chakra.button>\n );\n\n return (\n <Table.ColumnHeader ref={ref} {...rest}>\n {method === 'hover' ? (\n <BitkitTooltip disablePortal={disablePortal} placement={placement} text={text}>\n {title}\n </BitkitTooltip>\n ) : (\n <BitkitToggletip\n button={button}\n disablePortal={disablePortal}\n learnMoreTarget={learnMoreTarget}\n learnMoreUrl={learnMoreUrl}\n placement={placement}\n text={text}\n >\n {title}\n </BitkitToggletip>\n )}\n </Table.ColumnHeader>\n );\n },\n);\n\nBitkitDefinitionColumnHeader.displayName = 'BitkitTable.DefinitionColumnHeader';\n\nexport default BitkitDefinitionColumnHeader;\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,IAAM,+BAA+B,YAEjC,EAAE,QAAQ,UAAU,eAAe,iBAAiB,cAAc,SAAS,SAAS,WAAW,MAAM,GAAG,QACxG,QACG;CACH,MAAM,SAAS,eAAe;CAE9B,MAAM,QAEJ,oBAAC,OAAO,QAAR;EAAe,KAAK,OAAO;EAAmB,UAAA;EAAS,MAAK;EACzD;CACY,CAAA;CAGjB,OACE,oBAAC,MAAM,cAAP;EAAyB;EAAK,GAAI;EAC/B,UAAA,WAAW,UACV,oBAAC,eAAD;GAA8B;GAA0B;GAAiB;GACtE,UAAA;EACY,CAAA,IAEf,oBAAC,iBAAD;GACU;GACO;GACE;GACH;GACH;GACL;GAEL,UAAA;EACc,CAAA;CAED,CAAA;AAExB,CACF;AAEA,6BAA6B,cAAc"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PopoverRootProps } from '@ark-ui/react/popover';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { BitkitIconComponent } from '../../icons';
|
|
4
|
+
import { BitkitColorButtonProps } from '../BitkitColorButton/BitkitColorButton';
|
|
5
|
+
export type BitkitToggletipProps = {
|
|
6
|
+
/** Action button at the end of the toggletip. Defaults to the `white` colour variant, the one that reads on its dark background. */
|
|
7
|
+
button?: BitkitColorButtonProps;
|
|
8
|
+
/**
|
|
9
|
+
* The trigger the toggletip opens from. Rendered via `asChild`, so it must be a focusable control
|
|
10
|
+
* that accepts a ref — unless `wrapTrigger` puts a button in between.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** Open on first render, for an uncontrolled toggletip. */
|
|
14
|
+
defaultOpen?: PopoverRootProps['defaultOpen'];
|
|
15
|
+
/**
|
|
16
|
+
* Render the toggletip inline instead of in a portal. Only needed when it must stay inside its
|
|
17
|
+
* parent's DOM subtree — a dialog already sets this for you.
|
|
18
|
+
*/
|
|
19
|
+
disablePortal?: boolean;
|
|
20
|
+
/** Render the trigger without a toggletip — for hints that only apply in some states. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Icon after the text — `IconArrowNortheast` when the trigger opens something in a new tab, for instance. */
|
|
23
|
+
icon?: BitkitIconComponent;
|
|
24
|
+
/** Target for the "Learn more" link. `_blank` also sets `rel="noopener noreferrer"`. */
|
|
25
|
+
learnMoreTarget?: HTMLAnchorElement['target'];
|
|
26
|
+
/** Adds a "Learn more" link pointing here, for the fuller explanation. */
|
|
27
|
+
learnMoreUrl?: string;
|
|
28
|
+
/** Called when the toggletip opens or closes. */
|
|
29
|
+
onOpenChange?: PopoverRootProps['onOpenChange'];
|
|
30
|
+
/** Controls the open state. */
|
|
31
|
+
open?: PopoverRootProps['open'];
|
|
32
|
+
/** Where the toggletip sits relative to the trigger (default `top`). It flips if space is short. */
|
|
33
|
+
placement?: NonNullable<PopoverRootProps['positioning']>['placement'];
|
|
34
|
+
/** The toggletip's text. */
|
|
35
|
+
text: string;
|
|
36
|
+
/** Accessible name of the `wrapTrigger` button, for a trigger with no text of its own, like an icon. */
|
|
37
|
+
triggerAriaLabel?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Put the trigger inside a button instead of rendering on it — for a trigger that is not a control
|
|
40
|
+
* itself, like a badge or an icon. The button takes the click, the tap and the keyboard.
|
|
41
|
+
*/
|
|
42
|
+
wrapTrigger?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A tooltip's bubble that opens on click, tap or Enter and stays open, so what it carries — a "Learn
|
|
46
|
+
* more" link, an action button — can be reached by pointer, touch and keyboard alike. It is a
|
|
47
|
+
* popover, not a tooltip: a tooltip closes as soon as focus leaves its trigger and ignores touch, so
|
|
48
|
+
* anything clickable inside one can't be reached.
|
|
49
|
+
*
|
|
50
|
+
* Reach for `BitkitTooltip` when the hint is text only; this component when it links or acts.
|
|
51
|
+
*
|
|
52
|
+
* The content renders in a portal, so it escapes any ancestor that traps stacking or clips overflow.
|
|
53
|
+
* Dialogs turn that off through `BitkitPortalContext`; `disablePortal` is the manual override.
|
|
54
|
+
*/
|
|
55
|
+
declare const BitkitToggletip: {
|
|
56
|
+
({ button, children, defaultOpen, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, placement, text, triggerAriaLabel, wrapTrigger, }: BitkitToggletipProps): import('react').JSX.Element;
|
|
57
|
+
displayName: string;
|
|
58
|
+
};
|
|
59
|
+
export default BitkitToggletip;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import BitkitPortalContext from "../../utilities/BitkitPortalContext.js";
|
|
2
|
+
import BitkitColorButton from "../BitkitColorButton/BitkitColorButton.js";
|
|
3
|
+
import { Box } from "@chakra-ui/react/box";
|
|
4
|
+
import { createSlotRecipeContext } from "@chakra-ui/react/styled-system";
|
|
5
|
+
import { isValidElement, useContext } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Portal } from "@chakra-ui/react/portal";
|
|
8
|
+
import { Popover } from "@ark-ui/react/popover";
|
|
9
|
+
import { Link } from "@chakra-ui/react/link";
|
|
10
|
+
//#region lib/components/BitkitToggletip/BitkitToggletip.tsx
|
|
11
|
+
var { withRootProvider, withContext } = createSlotRecipeContext({ key: "toggletip" });
|
|
12
|
+
var Root = withRootProvider(Popover.Root);
|
|
13
|
+
var Trigger = withContext(Popover.Trigger, "trigger", { forwardAsChild: true });
|
|
14
|
+
var Positioner = withContext(Popover.Positioner, "positioner", { forwardAsChild: true });
|
|
15
|
+
var Content = withContext(Popover.Content, "content", { forwardAsChild: true });
|
|
16
|
+
var Title = withContext(Popover.Title, "title", { forwardAsChild: true });
|
|
17
|
+
var Arrow = withContext(Popover.Arrow, "arrow", { forwardAsChild: true });
|
|
18
|
+
var ArrowTip = withContext(Popover.ArrowTip, "arrowTip", { forwardAsChild: true });
|
|
19
|
+
/**
|
|
20
|
+
* A tooltip's bubble that opens on click, tap or Enter and stays open, so what it carries — a "Learn
|
|
21
|
+
* more" link, an action button — can be reached by pointer, touch and keyboard alike. It is a
|
|
22
|
+
* popover, not a tooltip: a tooltip closes as soon as focus leaves its trigger and ignores touch, so
|
|
23
|
+
* anything clickable inside one can't be reached.
|
|
24
|
+
*
|
|
25
|
+
* Reach for `BitkitTooltip` when the hint is text only; this component when it links or acts.
|
|
26
|
+
*
|
|
27
|
+
* The content renders in a portal, so it escapes any ancestor that traps stacking or clips overflow.
|
|
28
|
+
* Dialogs turn that off through `BitkitPortalContext`; `disablePortal` is the manual override.
|
|
29
|
+
*/
|
|
30
|
+
var BitkitToggletip = ({ button, children, defaultOpen, disablePortal, disabled, icon: Icon, learnMoreTarget, learnMoreUrl, onOpenChange, open, placement = "top", text, triggerAriaLabel, wrapTrigger }) => {
|
|
31
|
+
const { disablePortal: disablePortalFromContext } = useContext(BitkitPortalContext);
|
|
32
|
+
const hasActions = !!learnMoreUrl || !!button;
|
|
33
|
+
if (disabled) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
34
|
+
return /* @__PURE__ */ jsxs(Root, {
|
|
35
|
+
defaultOpen,
|
|
36
|
+
onOpenChange,
|
|
37
|
+
open,
|
|
38
|
+
positioning: {
|
|
39
|
+
placement,
|
|
40
|
+
offset: {
|
|
41
|
+
mainAxis: 4,
|
|
42
|
+
crossAxis: 0
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
children: [wrapTrigger || !isValidElement(children) ? /* @__PURE__ */ jsx(Trigger, {
|
|
46
|
+
"aria-label": triggerAriaLabel,
|
|
47
|
+
css: {
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
appearance: "none",
|
|
50
|
+
background: "none",
|
|
51
|
+
border: 0,
|
|
52
|
+
color: "inherit",
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
font: "inherit",
|
|
55
|
+
padding: 0,
|
|
56
|
+
_focusVisible: {
|
|
57
|
+
outline: "none",
|
|
58
|
+
"& > *": {
|
|
59
|
+
outlineColor: "var(--focus-ring-color)",
|
|
60
|
+
outlineOffset: "var(--focus-ring-offset, 2px)",
|
|
61
|
+
outlineStyle: "var(--focus-ring-style, solid)",
|
|
62
|
+
outlineWidth: "var(--focus-ring-width, 2px)"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
children
|
|
67
|
+
}) : /* @__PURE__ */ jsx(Trigger, {
|
|
68
|
+
asChild: true,
|
|
69
|
+
children
|
|
70
|
+
}), /* @__PURE__ */ jsx(Portal, {
|
|
71
|
+
disabled: disablePortal || disablePortalFromContext,
|
|
72
|
+
children: /* @__PURE__ */ jsx(Positioner, { children: /* @__PURE__ */ jsxs(Content, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx(Arrow, { children: /* @__PURE__ */ jsx(ArrowTip, {}) }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
75
|
+
display: "flex",
|
|
76
|
+
gap: "8",
|
|
77
|
+
children: [/* @__PURE__ */ jsx(Title, { children: text }), Icon && /* @__PURE__ */ jsx(Icon, {
|
|
78
|
+
flexShrink: "0",
|
|
79
|
+
size: "16"
|
|
80
|
+
})]
|
|
81
|
+
}),
|
|
82
|
+
hasActions && /* @__PURE__ */ jsxs(Box, {
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
display: "flex",
|
|
85
|
+
gap: "16",
|
|
86
|
+
marginBlockStart: "16",
|
|
87
|
+
children: [learnMoreUrl && /* @__PURE__ */ jsx(Link, {
|
|
88
|
+
color: "color/purple/highlight",
|
|
89
|
+
href: learnMoreUrl,
|
|
90
|
+
rel: learnMoreTarget === "_blank" ? "noopener noreferrer" : void 0,
|
|
91
|
+
target: learnMoreTarget,
|
|
92
|
+
children: "Learn more"
|
|
93
|
+
}), button && /* @__PURE__ */ jsx(BitkitColorButton, {
|
|
94
|
+
colorVariant: "white",
|
|
95
|
+
marginInlineStart: "auto",
|
|
96
|
+
...button
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
] }) })
|
|
100
|
+
})]
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
BitkitToggletip.displayName = "BitkitToggletip";
|
|
104
|
+
//#endregion
|
|
105
|
+
export { BitkitToggletip as default };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=BitkitToggletip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitkitToggletip.js","names":[],"sources":["../../../lib/components/BitkitToggletip/BitkitToggletip.tsx"],"sourcesContent":["import { Popover as ArkPopover, type PopoverRootProps } from '@ark-ui/react/popover';\nimport { Box } from '@chakra-ui/react/box';\nimport { Link } from '@chakra-ui/react/link';\nimport {\n type PopoverArrowProps,\n type PopoverArrowTipProps,\n type PopoverContentProps,\n type PopoverPositionerProps,\n type PopoverTitleProps,\n type PopoverTriggerProps,\n} from '@chakra-ui/react/popover';\nimport { Portal } from '@chakra-ui/react/portal';\nimport { createSlotRecipeContext } from '@chakra-ui/react/styled-system';\nimport { isValidElement, type ReactNode, useContext } from 'react';\n\nimport { type BitkitIconComponent } from '../../icons';\nimport BitkitPortalContext from '../../utilities/BitkitPortalContext';\nimport BitkitColorButton, { type BitkitColorButtonProps } from '../BitkitColorButton/BitkitColorButton';\n\n// Chakra's own Popover is Ark's popover under the `popover` recipe; this is the same composition\n// under `toggletip`, so the bubble can share the tooltip's surface instead of the popover's card.\nconst { withRootProvider, withContext } = createSlotRecipeContext({ key: 'toggletip' });\nconst Root = withRootProvider<PopoverRootProps>(ArkPopover.Root);\nconst Trigger = withContext<HTMLButtonElement, PopoverTriggerProps>(ArkPopover.Trigger, 'trigger', {\n forwardAsChild: true,\n});\nconst Positioner = withContext<HTMLDivElement, PopoverPositionerProps>(ArkPopover.Positioner, 'positioner', {\n forwardAsChild: true,\n});\nconst Content = withContext<HTMLDivElement, PopoverContentProps>(ArkPopover.Content, 'content', {\n forwardAsChild: true,\n});\n// The text is the popover's title, which is what names its dialog for assistive technology.\nconst Title = withContext<HTMLDivElement, PopoverTitleProps>(ArkPopover.Title, 'title', { forwardAsChild: true });\nconst Arrow = withContext<HTMLDivElement, PopoverArrowProps>(ArkPopover.Arrow, 'arrow', { forwardAsChild: true });\nconst ArrowTip = withContext<HTMLDivElement, PopoverArrowTipProps>(ArkPopover.ArrowTip, 'arrowTip', {\n forwardAsChild: true,\n});\n\nexport type BitkitToggletipProps = {\n /** Action button at the end of the toggletip. Defaults to the `white` colour variant, the one that reads on its dark background. */\n button?: BitkitColorButtonProps;\n /**\n * The trigger the toggletip opens from. Rendered via `asChild`, so it must be a focusable control\n * that accepts a ref — unless `wrapTrigger` puts a button in between.\n */\n children: ReactNode;\n /** Open on first render, for an uncontrolled toggletip. */\n defaultOpen?: PopoverRootProps['defaultOpen'];\n /**\n * Render the toggletip inline instead of in a portal. Only needed when it must stay inside its\n * parent's DOM subtree — a dialog already sets this for you.\n */\n disablePortal?: boolean;\n /** Render the trigger without a toggletip — for hints that only apply in some states. */\n disabled?: boolean;\n /** Icon after the text — `IconArrowNortheast` when the trigger opens something in a new tab, for instance. */\n icon?: BitkitIconComponent;\n /** Target for the \"Learn more\" link. `_blank` also sets `rel=\"noopener noreferrer\"`. */\n learnMoreTarget?: HTMLAnchorElement['target'];\n /** Adds a \"Learn more\" link pointing here, for the fuller explanation. */\n learnMoreUrl?: string;\n /** Called when the toggletip opens or closes. */\n onOpenChange?: PopoverRootProps['onOpenChange'];\n /** Controls the open state. */\n open?: PopoverRootProps['open'];\n /** Where the toggletip sits relative to the trigger (default `top`). It flips if space is short. */\n placement?: NonNullable<PopoverRootProps['positioning']>['placement'];\n /** The toggletip's text. */\n text: string;\n /** Accessible name of the `wrapTrigger` button, for a trigger with no text of its own, like an icon. */\n triggerAriaLabel?: string;\n /**\n * Put the trigger inside a button instead of rendering on it — for a trigger that is not a control\n * itself, like a badge or an icon. The button takes the click, the tap and the keyboard.\n */\n wrapTrigger?: boolean;\n};\n\n/**\n * A tooltip's bubble that opens on click, tap or Enter and stays open, so what it carries — a \"Learn\n * more\" link, an action button — can be reached by pointer, touch and keyboard alike. It is a\n * popover, not a tooltip: a tooltip closes as soon as focus leaves its trigger and ignores touch, so\n * anything clickable inside one can't be reached.\n *\n * Reach for `BitkitTooltip` when the hint is text only; this component when it links or acts.\n *\n * The content renders in a portal, so it escapes any ancestor that traps stacking or clips overflow.\n * Dialogs turn that off through `BitkitPortalContext`; `disablePortal` is the manual override.\n */\nconst BitkitToggletip = ({\n button,\n children,\n defaultOpen,\n disablePortal,\n disabled,\n icon: Icon,\n learnMoreTarget,\n learnMoreUrl,\n onOpenChange,\n open,\n placement = 'top',\n text,\n triggerAriaLabel,\n wrapTrigger,\n}: BitkitToggletipProps) => {\n const { disablePortal: disablePortalFromContext } = useContext(BitkitPortalContext);\n const hasActions = !!learnMoreUrl || !!button;\n\n if (disabled) {\n return <>{children}</>;\n }\n\n return (\n <Root\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n open={open}\n positioning={{ placement, offset: { mainAxis: 4, crossAxis: 0 } }}\n >\n {wrapTrigger || !isValidElement(children) ? (\n <Trigger\n aria-label={triggerAriaLabel}\n css={{\n alignItems: 'center',\n appearance: 'none',\n background: 'none',\n border: 0,\n color: 'inherit',\n display: 'inline-flex',\n font: 'inherit',\n padding: 0,\n // The button owns the tab stop, but the focus ring belongs on the trigger inside it: an\n // outline follows the border-radius of the element it is drawn on, and the button has\n // none — so leaving it here squares off a pill or a round trigger.\n _focusVisible: {\n outline: 'none',\n '& > *': {\n outlineColor: 'var(--focus-ring-color)',\n outlineOffset: 'var(--focus-ring-offset, 2px)',\n outlineStyle: 'var(--focus-ring-style, solid)',\n outlineWidth: 'var(--focus-ring-width, 2px)',\n },\n },\n }}\n >\n {children}\n </Trigger>\n ) : (\n <Trigger asChild>{children}</Trigger>\n )}\n <Portal disabled={disablePortal || disablePortalFromContext}>\n <Positioner>\n <Content>\n <Arrow>\n <ArrowTip />\n </Arrow>\n <Box display=\"flex\" gap=\"8\">\n <Title>{text}</Title>\n {Icon && <Icon flexShrink=\"0\" size=\"16\" />}\n </Box>\n {hasActions && (\n <Box alignItems=\"center\" display=\"flex\" gap=\"16\" marginBlockStart=\"16\">\n {learnMoreUrl && (\n <Link\n color=\"color/purple/highlight\"\n href={learnMoreUrl}\n rel={learnMoreTarget === '_blank' ? 'noopener noreferrer' : undefined}\n target={learnMoreTarget}\n >\n Learn more\n </Link>\n )}\n {button && <BitkitColorButton colorVariant=\"white\" marginInlineStart=\"auto\" {...button} />}\n </Box>\n )}\n </Content>\n </Positioner>\n </Portal>\n </Root>\n );\n};\n\nBitkitToggletip.displayName = 'BitkitToggletip';\n\nexport default Bitk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,IAET,oBAAC,SAAD;GAAS,SAAA;GAAS;EAAkB,CAAA,GAEtC,oBAAC,QAAD;GAAQ,UAAU,iBAAiB;GACjC,UAAA,oBAAC,YAAD,EAAA,UACE,qBAAC,SAAD,EAAA,UAAA;IACE,oBAAC,OAAD,EAAA,UACE,oBAAC,UAAD,CAAW,CAAA,EACN,CAAA;IACP,qBAAC,KAAD;KAAK,SAAQ;KAAO,KAAI;KAAxB,UAAA,CACE,oBAAC,OAAD,EAAA,UAAQ,KAAY,CAAA,GACnB,QAAQ,oBAAC,MAAD;MAAM,YAAW;MAAI,MAAK;KAAM,CAAA,CACtC;;IACJ,cACC,qBAAC,KAAD;KAAK,YAAW;KAAS,SAAQ;KAAO,KAAI;KAAK,kBAAiB;KAAlE,UAAA,CACG,gBACC,oBAAC,MAAD;MACE,OAAM;MACN,MAAM;MACN,KAAK,oBAAoB,WAAW,wBAAwB,KAAA;MAC5D,QAAQ;MACT,UAAA;KAEK,CAAA,GAEP,UAAU,oBAAC,mBAAD;MAAmB,cAAa;MAAQ,mBAAkB;MAAO,GAAI;KAAS,CAAA,CACtF;;GAEA,EAAA,CAAA,EACC,CAAA;EACN,CAAA,CACJ;;AAEV;AAEA,gBAAgB,cAAc"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { TooltipRootProps } from '@chakra-ui/react/tooltip';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { BitkitIconComponent } from '../../icons';
|
|
4
|
-
import { BitkitColorButtonProps } from '../BitkitColorButton/BitkitColorButton';
|
|
5
4
|
export type BitkitTooltipProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Action button rendered at the end of the tooltip. Setting it makes the tooltip interactive, so
|
|
8
|
-
* the pointer can move into the tooltip without dismissing it. Defaults to the `white` colour
|
|
9
|
-
* variant, the one that reads on the tooltip's dark background.
|
|
10
|
-
*/
|
|
11
|
-
button?: BitkitColorButtonProps;
|
|
12
5
|
/**
|
|
13
6
|
* The trigger the tooltip is anchored to. Rendered via `asChild`, so it must accept a ref —
|
|
14
7
|
* unless `wrapTrigger` puts a wrapper in between.
|
|
@@ -28,13 +21,6 @@ export type BitkitTooltipProps = {
|
|
|
28
21
|
* `IconArrowNortheast` when the trigger opens something in a new tab, for instance.
|
|
29
22
|
*/
|
|
30
23
|
icon?: BitkitIconComponent;
|
|
31
|
-
/** Target for the "Learn more" link. `_blank` also sets `rel="noopener noreferrer"`. */
|
|
32
|
-
learnMoreTarget?: HTMLAnchorElement['target'];
|
|
33
|
-
/**
|
|
34
|
-
* Adds a "Learn more" link pointing here. Setting it makes the tooltip interactive, so the
|
|
35
|
-
* pointer can move into the tooltip to reach the link.
|
|
36
|
-
*/
|
|
37
|
-
learnMoreUrl?: string;
|
|
38
24
|
/** Called when the tooltip opens or closes, including from hover and focus. */
|
|
39
25
|
onOpenChange?: TooltipRootProps['onOpenChange'];
|
|
40
26
|
/** Controlled open state. Leave unset to let hover and focus drive it. */
|
|
@@ -43,7 +29,7 @@ export type BitkitTooltipProps = {
|
|
|
43
29
|
openDelay?: TooltipRootProps['openDelay'];
|
|
44
30
|
/** Where the tooltip sits relative to the trigger (default `top`). It flips if space is short. */
|
|
45
31
|
placement?: NonNullable<TooltipRootProps['positioning']>['placement'];
|
|
46
|
-
/** The tooltip's text. Plain string only — use `icon
|
|
32
|
+
/** The tooltip's text. Plain string only — use `icon` for a glyph after it. */
|
|
47
33
|
text: string;
|
|
48
34
|
/**
|
|
49
35
|
* Render the trigger inside a focusable wrapper instead of on the trigger itself. Only for triggers
|
|
@@ -66,19 +52,17 @@ export type BitkitTooltipProps = {
|
|
|
66
52
|
wrapTrigger?: boolean;
|
|
67
53
|
};
|
|
68
54
|
/**
|
|
69
|
-
* A hover/focus tooltip anchored to its child
|
|
70
|
-
* after it
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* open while the pointer travels into it, so the link and the button can actually be reached.
|
|
55
|
+
* A hover/focus tooltip anchored to its child: `text` carries the message and `icon` appends a
|
|
56
|
+
* glyph after it. Text only — a tooltip closes when focus leaves its trigger and ignores touch, so a
|
|
57
|
+
* link or a button inside one couldn't be reached. For those use `BitkitToggletip`, which looks the
|
|
58
|
+
* same and opens on click.
|
|
74
59
|
*
|
|
75
60
|
* The content renders in a portal, so it escapes any ancestor that traps stacking (`isolation`,
|
|
76
61
|
* `transform`, a `z-index`ed positioned box) or clips overflow. Dialogs turn that off through
|
|
77
|
-
* `BitkitPortalContext`
|
|
78
|
-
* the manual override.
|
|
62
|
+
* `BitkitPortalContext`; `disablePortal` is the manual override.
|
|
79
63
|
*/
|
|
80
64
|
declare const BitkitTooltip: {
|
|
81
|
-
({
|
|
65
|
+
({ children, closeOnClick, disablePortal, disabled, icon: Icon, onOpenChange, open, openDelay, placement, text, wrapTrigger, }: BitkitTooltipProps): import('react').JSX.Element;
|
|
82
66
|
displayName: string;
|
|
83
67
|
};
|
|
84
68
|
export default BitkitTooltip;
|