@neo4j-ndl/react 4.9.37 → 4.9.39
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/lib/cjs/segmented-control/SegmentedControl.js +1 -1
- package/lib/cjs/segmented-control/SegmentedControl.js.map +1 -1
- package/lib/cjs/tooltip/Tooltip.js +57 -5
- package/lib/cjs/tooltip/Tooltip.js.map +1 -1
- package/lib/cjs/tooltip/stories/index.js +6 -2
- package/lib/cjs/tooltip/stories/index.js.map +1 -1
- package/lib/cjs/tooltip/stories/tooltip-rich-actions.story.js +30 -0
- package/lib/cjs/tooltip/stories/tooltip-rich-actions.story.js.map +1 -0
- package/lib/cjs/tooltip/stories/tooltip-rich.story.js +1 -1
- package/lib/cjs/tooltip/stories/tooltip-rich.story.js.map +1 -1
- package/lib/cjs/tooltip/use-tooltip.js +18 -3
- package/lib/cjs/tooltip/use-tooltip.js.map +1 -1
- package/lib/esm/segmented-control/SegmentedControl.js +1 -1
- package/lib/esm/segmented-control/SegmentedControl.js.map +1 -1
- package/lib/esm/tooltip/Tooltip.js +24 -5
- package/lib/esm/tooltip/Tooltip.js.map +1 -1
- package/lib/esm/tooltip/stories/index.js +4 -1
- package/lib/esm/tooltip/stories/index.js.map +1 -1
- package/lib/esm/tooltip/stories/tooltip-rich-actions.story.js +28 -0
- package/lib/esm/tooltip/stories/tooltip-rich-actions.story.js.map +1 -0
- package/lib/esm/tooltip/stories/tooltip-rich.story.js +2 -2
- package/lib/esm/tooltip/stories/tooltip-rich.story.js.map +1 -1
- package/lib/esm/tooltip/use-tooltip.js +19 -4
- package/lib/esm/tooltip/use-tooltip.js.map +1 -1
- package/lib/types/segmented-control/SegmentedControl.d.ts.map +1 -1
- package/lib/types/tooltip/Tooltip.d.ts +5 -2
- package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/types/tooltip/stories/index.d.ts +3 -1
- package/lib/types/tooltip/stories/index.d.ts.map +1 -1
- package/lib/types/tooltip/stories/tooltip-rich-actions.story.d.ts +24 -0
- package/lib/types/tooltip/stories/tooltip-rich-actions.story.d.ts.map +1 -0
- package/lib/types/tooltip/stories/tooltip-rich.story.d.ts.map +1 -1
- package/lib/types/tooltip/use-tooltip.d.ts +5 -0
- package/lib/types/tooltip/use-tooltip.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -105,7 +105,7 @@ const SegmentedControlItem = (_a) => {
|
|
|
105
105
|
'ndl-segment-item': !hasOnlyIcons,
|
|
106
106
|
});
|
|
107
107
|
const Component = as !== null && as !== void 0 ? as : 'button';
|
|
108
|
-
return ((0, jsx_runtime_1.jsxs)(Tooltip_1.Tooltip, Object.assign({ isPortaled: false, isDisabled: Boolean(description) === false }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { type: "simple", children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)(Component, Object.assign({ onClick: () => !isSelected && onChange(value), className: baseClasses, style: style, ref: ref, "aria-label": description, disabled: isDisabled }, restProps, htmlAttributes, { children: children })) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Body, { children: description }) }))] })));
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(Tooltip_1.Tooltip, Object.assign({ isPortaled: false, isDisabled: Boolean(description) === false }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { type: "simple", children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)(Component, Object.assign({ "aria-pressed": isSelected, onClick: () => !isSelected && onChange(value), className: baseClasses, style: style, ref: ref, "aria-label": description, disabled: isDisabled }, restProps, htmlAttributes, { children: children })) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip.Body, { children: description }) }))] })));
|
|
109
109
|
};
|
|
110
110
|
SegmentedControlItem.displayName = 'SegmentedControl.Item';
|
|
111
111
|
const SegmentedControl = Object.assign(SegmentedControlComponent, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sourceRoot":"","sources":["../../../src/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4DAAoC;AACpC,+CAA0C;AAM1C,gDAA6C;AAyB7C,wCAAwC;AACxC,MAAM,uBAAuB;AAC3B,8DAA8D;AAC9D,eAAK,CAAC,aAAa,CAAsC,IAAI,CAAC,CAAC;AAEjE,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,uBAAuB,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAGhC,EAaoD,EAAE,EAAE;QAbxD,EACA,IAAI,GAAG,QAAQ,EACf,YAAY,GAAG,KAAK,EACpB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,SAAS,EACT,KAAK,EACL,UAAU,GAAG,KAAK,EAClB,cAAc,EACd,GAAG,OAEiD,EADjD,SAAS,cAZZ,+HAaD,CADa;IAEZ,MAAM,OAAO,GAAG,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AAO,CAAC,WAAW,CAAC,KAAK,KAAK,IACtC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,IACtB,IAAI,EAAC,QAAQ,aAEb,uBAAC,iBAAO,CAAC,OAAO,oBAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,IAAE,gBAAgB,kBAC1D,uBAAC,SAAS,kCACM,UAAU,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,IAAI,QAAQ,CAAC,KAAK,CAAC,EAC7C,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,gBACI,WAAW,EACvB,QAAQ,EAAE,UAAU,IAChB,SAAS,EACT,cAAc,cAEjB,QAAQ,IACC,IACI,EAClB,uBAAC,iBAAO,CAAC,OAAO,oBAAK,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,cACxC,uBAAC,iBAAO,CAAC,IAAI,cAAE,WAAW,GAAgB,IAC1B,KACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,oBAAoB,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE;IAChE,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAC;AAEM,4CAAgB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useContext } from 'react';\n\nimport {\n type PolymorphicCommonProps,\n type TooltipObjectProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip/Tooltip';\n\ntype SegmentedControlID = string | number;\n\ntype SegmentedControlProps<T extends SegmentedControlID> = {\n /** Additional class name */\n className?: string;\n /** Size of the segmented control */\n size?: 'small' | 'medium' | 'large';\n /** If segmented control items will include only icons (makes controls rectangular) */\n hasOnlyIcons?: boolean;\n /** The callback function triggered when the segmented control value changes */\n onChange: (e: T) => void | ((e: React.SetStateAction<T>) => void);\n /** The currently selected option */\n selected: T;\n /** The children component of the segmented control */\n children: React.ReactNode;\n /** Whether the segmented control has a box shadow applied */\n isFloating?: boolean;\n};\n\ntype SegmentedControlContext<T extends SegmentedControlID> = Required<\n Pick<SegmentedControlProps<T>, 'onChange' | 'selected' | 'hasOnlyIcons'>\n>;\n\n// eslint-disable-next-line no-redeclare\nconst SegmentedControlContext =\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n React.createContext<SegmentedControlContext<any> | null>(null);\n\nconst useSelectorContext = () => {\n const context = useContext(SegmentedControlContext);\n\n if (context === null) {\n throw new Error('SegmentedControl used without context');\n }\n\n return context;\n};\n\nconst SegmentedControlComponent = <\n T extends SegmentedControlID,\n U extends React.ElementType = 'div',\n>({\n size = 'medium',\n hasOnlyIcons = false,\n children,\n selected,\n onChange,\n as,\n className,\n style,\n isFloating = false,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, SegmentedControlProps<T>>) => {\n const classes = classNames('ndl-segmented-control', className, {\n 'ndl-floating': isFloating,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-small': size === 'small',\n });\n\n const Component = as ?? 'div';\n\n return (\n <Component\n className={classes}\n style={style}\n role=\"group\"\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <SegmentedControlContext.Provider\n value={{ hasOnlyIcons, onChange, selected }}\n >\n {children}\n </SegmentedControlContext.Provider>\n </Component>\n );\n};\n\nSegmentedControlComponent.displayName = 'SegmentedControl';\n\ntype SegmentedControlItemProps = {\n /** Additional class name */\n className?: string;\n /** The children component of the segmented control item */\n children?: React.ReactNode;\n /** The value of the segmented control item */\n value: string;\n /** The description of the segmented control item, will be displayed in the tooltip */\n description?: string;\n /** The tooltip props that will be applied if tooltip is set */\n tooltipProps?: TooltipObjectProps;\n /** Whether the segmented control item is disabled */\n isDisabled?: boolean;\n};\n\nconst SegmentedControlItem = <T extends React.ElementType = 'button'>({\n as,\n children,\n className,\n style,\n value,\n htmlAttributes,\n description,\n tooltipProps,\n isDisabled = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SegmentedControlItemProps>) => {\n const { onChange, selected, hasOnlyIcons } = useSelectorContext();\n\n const isSelected = value === selected;\n\n const baseClasses = classNames(className, {\n 'ndl-current': isSelected,\n 'ndl-segment-icon': hasOnlyIcons,\n 'ndl-segment-item': !hasOnlyIcons,\n });\n\n const Component: React.ElementType = as ?? 'button';\n\n return (\n <Tooltip\n isPortaled={false}\n isDisabled={Boolean(description) === false}\n {...tooltipProps?.root}\n type=\"simple\"\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <Component\n aria-pressed={isSelected}\n onClick={() => !isSelected && onChange(value)}\n className={baseClasses}\n style={style}\n ref={ref}\n aria-label={description}\n disabled={isDisabled}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n <Tooltip.Body>{description}</Tooltip.Body>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nSegmentedControlItem.displayName = 'SegmentedControl.Item';\n\nconst SegmentedControl = Object.assign(SegmentedControlComponent, {\n Item: SegmentedControlItem,\n});\n\nexport { SegmentedControl };\n"]}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
36
|
var t = {};
|
|
4
37
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -38,7 +71,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
38
71
|
*/
|
|
39
72
|
const react_1 = require("@floating-ui/react");
|
|
40
73
|
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
-
const react_2 = require("react");
|
|
74
|
+
const react_2 = __importStar(require("react"));
|
|
42
75
|
const conditional_wrap_1 = require("../conditional-wrap");
|
|
43
76
|
const dialog_context_1 = require("../dialog/dialog-context");
|
|
44
77
|
const theme_1 = require("../theme");
|
|
@@ -81,17 +114,25 @@ const TooltipTrigger = (_a) => {
|
|
|
81
114
|
'ndl-open': context.isOpen,
|
|
82
115
|
}, 'ndl-tooltip-trigger', className);
|
|
83
116
|
// `hasButtonWrapper=true` allows the user to pass any element as the anchor
|
|
84
|
-
if (hasButtonWrapper &&
|
|
117
|
+
if (hasButtonWrapper && react_2.default.isValidElement(children)) {
|
|
85
118
|
const props = Object.assign(Object.assign(Object.assign({ className: triggerClasses }, htmlAttributes), childrenProps), { ref: mergedRefs });
|
|
86
|
-
return
|
|
119
|
+
return react_2.default.cloneElement(children, context.getReferenceProps(props));
|
|
87
120
|
}
|
|
88
121
|
return ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: triggerClasses, style: style, ref: mergedRefs }, context.getReferenceProps(htmlAttributes), restProps, { children: children })));
|
|
89
122
|
};
|
|
90
123
|
const TooltipContent = (_a) => {
|
|
124
|
+
var _b;
|
|
91
125
|
var { children, style, htmlAttributes, className, ref } = _a, restProps = __rest(_a, ["children", "style", "htmlAttributes", "className", "ref"]);
|
|
92
126
|
const context = (0, use_tooltip_1.useTooltipContext)();
|
|
93
127
|
const mergedRef = (0, react_1.useMergeRefs)([context.refs.setFloating, ref]);
|
|
94
128
|
const { themeClassName } = (0, theme_1.useNeedleTheme)();
|
|
129
|
+
const hasHeaderChild = react_2.default.useMemo(() => {
|
|
130
|
+
if (context.type !== 'rich') {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const childrenArray = react_2.default.Children.toArray(children);
|
|
134
|
+
return childrenArray.some((child) => react_2.default.isValidElement(child) && child.type === TooltipHeader);
|
|
135
|
+
}, [children, context.type]);
|
|
95
136
|
if (!context.isOpen) {
|
|
96
137
|
return null;
|
|
97
138
|
}
|
|
@@ -102,16 +143,26 @@ const TooltipContent = (_a) => {
|
|
|
102
143
|
if (context.type === 'simple') {
|
|
103
144
|
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => (0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren }), children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(htmlAttributes), { children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", children: children }) })) }));
|
|
104
145
|
}
|
|
105
|
-
|
|
146
|
+
const ariaLabelledBy = (_b = htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-labelledby']) !== null && _b !== void 0 ? _b : (hasHeaderChild ? context.headerId : undefined);
|
|
147
|
+
if ((htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-label']) === undefined && !ariaLabelledBy) {
|
|
148
|
+
console.warn('The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.');
|
|
149
|
+
}
|
|
150
|
+
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => (0, jsx_runtime_1.jsx)(react_1.FloatingPortal, { children: wrapChildren }), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { context: context.context, returnFocus: true, modal: false, initialFocus: 0, closeOnFocusOut: true, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(Object.assign(Object.assign({}, htmlAttributes), { 'aria-labelledby': ariaLabelledBy })), { children: children })) }) }));
|
|
106
151
|
};
|
|
107
152
|
const TooltipHeader = (_a) => {
|
|
108
153
|
var { children, passThroughProps, typographyVariant = 'subheading-medium', className, style, htmlAttributes, ref } = _a, restProps = __rest(_a, ["children", "passThroughProps", "typographyVariant", "className", "style", "htmlAttributes", "ref"]);
|
|
109
154
|
const context = (0, use_tooltip_1.useTooltipContext)();
|
|
110
155
|
const classes = (0, classnames_1.default)('ndl-tooltip-header', className);
|
|
156
|
+
(0, react_2.useEffect)(() => {
|
|
157
|
+
var _a;
|
|
158
|
+
if (Boolean(htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id) === true) {
|
|
159
|
+
(_a = context.setHeaderId) === null || _a === void 0 ? void 0 : _a.call(context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id);
|
|
160
|
+
}
|
|
161
|
+
}, [context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id]);
|
|
111
162
|
if (!context.isOpen) {
|
|
112
163
|
return null;
|
|
113
164
|
}
|
|
114
|
-
return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: htmlAttributes }, passThroughProps, restProps, { children: children })));
|
|
165
|
+
return ((0, jsx_runtime_1.jsx)(typography_1.Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: Object.assign(Object.assign({}, htmlAttributes), { id: context.headerId }) }, passThroughProps, restProps, { children: children })));
|
|
115
166
|
};
|
|
116
167
|
const TooltipBody = (_a) => {
|
|
117
168
|
var { children, className, style, htmlAttributes, passThroughProps, ref } = _a, restProps = __rest(_a, ["children", "className", "style", "htmlAttributes", "passThroughProps", "ref"]);
|
|
@@ -132,6 +183,7 @@ const Actions = (_a) => {
|
|
|
132
183
|
const classes = (0, classnames_1.default)('ndl-tooltip-actions', className);
|
|
133
184
|
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes, ref: mergedRefs, style: style }, restProps, htmlAttributes, { children: children })));
|
|
134
185
|
};
|
|
186
|
+
Actions.displayName = 'Tooltip.Actions';
|
|
135
187
|
const Tooltip = Object.assign(TooltipComponent, {
|
|
136
188
|
Actions: Actions,
|
|
137
189
|
Body: TooltipBody,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;AAEpC,iCAAqD;AAGrD,0DAAsD;AACtD,6DAA6D;AAC7D,oCAA0C;AAC1C,8CAAoE;AACpE,+CAA8E;AA+B9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,YAAY,EAC9B,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,GACJ,EAAE,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,kCAAiB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC;QACzB,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,aAAa;QACb,2HAA2H;QAC3H,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;QAC5C,UAAU,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,UAAU;QACxC,YAAY;QACZ,SAAS;QACT,2BAA2B;QAC3B,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ;QAClC,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,4BAAc,CAAC,QAAQ,IAAC,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EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { cloneElement, isValidElement } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={-1}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;AACpC,+CAAyC;AAGzC,0DAAsD;AACtD,6DAA6D;AAC7D,oCAA0C;AAC1C,8CAAoE;AACpE,+CAA8E;AA+B9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,YAAY,EAC9B,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,GACJ,EAAE,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,kCAAiB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC;QACzB,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,aAAa;QACb,2HAA2H;QAC3H,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;QAC5C,UAAU,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,UA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AC,WAAW,GAAG,iBAAiB,CAAC;AAExC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.TooltipWithKeyboardShortcutSource = exports.TooltipRichLinkSource = exports.
|
|
26
|
+
exports.TooltipWithKeyboardShortcutSource = exports.TooltipTriggerButtonWrapperSource = exports.TooltipRichLinkSource = exports.TooltipRichActionsSource = exports.TooltipRichSource = exports.TooltipHoverDelaySource = exports.TooltipInDialogSource = exports.TooltipPlacementsSource = exports.TooltipInitialOpenSource = exports.TooltipControlledSource = exports.TooltipDisabledSource = exports.TooltipDefaultSource = exports.TooltipWithKeyboardShortcut = exports.TooltipRichLink = exports.TooltipRichActions = exports.TooltipRich = exports.TooltipTriggerButtonWrapper = exports.TooltipHoverDelay = exports.TooltipInDialog = exports.TooltipPlacements = exports.TooltipInitialOpen = exports.TooltipControlled = exports.TooltipDisabled = exports.TooltipDefault = void 0;
|
|
27
27
|
var tooltip_default_story_1 = require("./tooltip-default.story");
|
|
28
28
|
Object.defineProperty(exports, "TooltipDefault", { enumerable: true, get: function () { return __importDefault(tooltip_default_story_1).default; } });
|
|
29
29
|
var tooltip_disabled_story_1 = require("./tooltip-disabled.story");
|
|
@@ -42,6 +42,8 @@ var tooltip_trigger_button_wrapper_story_1 = require("./tooltip-trigger-button-w
|
|
|
42
42
|
Object.defineProperty(exports, "TooltipTriggerButtonWrapper", { enumerable: true, get: function () { return __importDefault(tooltip_trigger_button_wrapper_story_1).default; } });
|
|
43
43
|
var tooltip_rich_story_1 = require("./tooltip-rich.story");
|
|
44
44
|
Object.defineProperty(exports, "TooltipRich", { enumerable: true, get: function () { return __importDefault(tooltip_rich_story_1).default; } });
|
|
45
|
+
var tooltip_rich_actions_story_1 = require("./tooltip-rich-actions.story");
|
|
46
|
+
Object.defineProperty(exports, "TooltipRichActions", { enumerable: true, get: function () { return __importDefault(tooltip_rich_actions_story_1).default; } });
|
|
45
47
|
var tooltip_rich_link_story_1 = require("./tooltip-rich-link.story");
|
|
46
48
|
Object.defineProperty(exports, "TooltipRichLink", { enumerable: true, get: function () { return __importDefault(tooltip_rich_link_story_1).default; } });
|
|
47
49
|
var tooltip_with_keyboard_shortcut_story_1 = require("./tooltip-with-keyboard-shortcut.story");
|
|
@@ -55,6 +57,7 @@ const tooltip_in_dialog_story_raw_1 = __importDefault(require("./tooltip-in-dial
|
|
|
55
57
|
const tooltip_initial_open_story_raw_1 = __importDefault(require("./tooltip-initial-open.story?raw"));
|
|
56
58
|
const tooltip_placements_story_raw_1 = __importDefault(require("./tooltip-placements.story?raw"));
|
|
57
59
|
const tooltip_rich_story_raw_1 = __importDefault(require("./tooltip-rich.story?raw"));
|
|
60
|
+
const tooltip_rich_actions_story_raw_1 = __importDefault(require("./tooltip-rich-actions.story?raw"));
|
|
58
61
|
const tooltip_rich_link_story_raw_1 = __importDefault(require("./tooltip-rich-link.story?raw"));
|
|
59
62
|
const tooltip_trigger_button_wrapper_story_raw_1 = __importDefault(require("./tooltip-trigger-button-wrapper.story?raw"));
|
|
60
63
|
const tooltip_with_keyboard_shortcut_story_raw_1 = __importDefault(require("./tooltip-with-keyboard-shortcut.story?raw"));
|
|
@@ -65,8 +68,9 @@ exports.TooltipInitialOpenSource = (0, export_stories_utils_1.removeLicenseHeade
|
|
|
65
68
|
exports.TooltipPlacementsSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_placements_story_raw_1.default);
|
|
66
69
|
exports.TooltipInDialogSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_in_dialog_story_raw_1.default);
|
|
67
70
|
exports.TooltipHoverDelaySource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_hover_delay_story_raw_1.default);
|
|
68
|
-
exports.TooltipTriggerButtonWrapperSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_trigger_button_wrapper_story_raw_1.default);
|
|
69
71
|
exports.TooltipRichSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_story_raw_1.default);
|
|
72
|
+
exports.TooltipRichActionsSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_actions_story_raw_1.default);
|
|
70
73
|
exports.TooltipRichLinkSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_rich_link_story_raw_1.default);
|
|
74
|
+
exports.TooltipTriggerButtonWrapperSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_trigger_button_wrapper_story_raw_1.default);
|
|
71
75
|
exports.TooltipWithKeyboardShortcutSource = (0, export_stories_utils_1.removeLicenseHeader)(tooltip_with_keyboard_shortcut_story_raw_1.default);
|
|
72
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,iEAAoE;AAA3D,wIAAA,OAAO,OAAkB;AAClC,mEAAsE;AAA7D,0IAAA,OAAO,OAAmB;AACnC,uEAA0E;AAAjE,8IAAA,OAAO,OAAqB;AACrC,2EAA6E;AAApE,iJAAA,OAAO,OAAsB;AACtC,uEAA0E;AAAjE,8IAAA,OAAO,OAAqB;AACrC,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,yEAA2E;AAAlE,+IAAA,OAAO,OAAqB;AACrC,+FAAgG;AAAvF,oKAAA,OAAO,OAA+B;AAC/C,2DAA8D;AAArD,kIAAA,OAAO,OAAe;AAC/B,qEAAuE;AAA9D,2IAAA,OAAO,OAAmB;AACnC,+FAAgG;AAAvF,oKAAA,OAAO,OAA+B;AAE/C,6EAAyE;AACzE,kGAAwE;AACxE,4FAAkE;AAClE,8FAAoE;AACpE,oGAAyE;AACzE,gGAAqE;AACrE,sGAA2E;AAC3E,kGAAwE;AACxE,sFAA4D;AAC5D,gGAAqE;AACrE,0HAA8F;AAC9F,0HAA8F;AAEjF,QAAA,oBAAoB,GAAG,IAAA,0CAAmB,EACrD,mCAAuB,CACxB,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,oCAAwB,CACzB,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,0CAAmB,EACxD,sCAA0B,CAC3B,CAAC;AACW,QAAA,wBAAwB,GAAG,IAAA,0CAAmB,EACzD,wCAA2B,CAC5B,CAAC;AACW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ACW,QAAA,wBAAwB,GAAG,IAAA,0CAAmB,EACzD,wCAA2B,CAC5B,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,0CAAmB,EACxD,sCAA0B,CAC3B,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,qCAAwB,CACzB,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,0CAAmB,EACxD,uCAA0B,CAC3B,CAAC;AACW,QAAA,iBAAiB,GAAG,IAAA,0CAAmB,EAAC,gCAAoB,CAAC,CAAC;AAC9D,QAAA,wBAAwB,GAAG,IAAA,0CAAmB,EACzD,wCAA2B,CAC5B,CAAC;AACW,QAAA,qBAAqB,GAAG,IAAA,0CAAmB,EACtD,qCAAwB,CACzB,CAAC;AACW,QAAA,iCAAiC,GAAG,IAAA,0CAAmB,EAClE,kDAAoC,CACrC,CAAC;AACW,QAAA,iCAAiC,GAAG,IAAA,0CAAmB,EAClE,kDAAoC,CACrC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as TooltipDefault } from './tooltip-default.story';\nexport { default as TooltipDisabled } from './tooltip-disabled.story';\nexport { default as TooltipControlled } from './tooltip-controlled.story';\nexport { default as TooltipInitialOpen } from './tooltip-initial-open.story';\nexport { default as TooltipPlacements } from './tooltip-placements.story';\nexport { default as TooltipInDialog } from './tooltip-in-dialog.story';\nexport { default as TooltipHoverDelay } from './tooltip-hover-delay.story';\nexport { default as TooltipTriggerButtonWrapper } from './tooltip-trigger-button-wrapper.story';\nexport { default as TooltipRich } from './tooltip-rich.story';\nexport { default as TooltipRichActions } from './tooltip-rich-actions.story';\nexport { default as TooltipRichLink } from './tooltip-rich-link.story';\nexport { default as TooltipWithKeyboardShortcut } from './tooltip-with-keyboard-shortcut.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport TooltipControlledSourceRaw from './tooltip-controlled.story?raw';\nimport TooltipDefaultSourceRaw from './tooltip-default.story?raw';\nimport TooltipDisabledSourceRaw from './tooltip-disabled.story?raw';\nimport TooltipHoverDelaySourceRaw from './tooltip-hover-delay.story?raw';\nimport TooltipInDialogSourceRaw from './tooltip-in-dialog.story?raw';\nimport TooltipInitialOpenSourceRaw from './tooltip-initial-open.story?raw';\nimport TooltipPlacementsSourceRaw from './tooltip-placements.story?raw';\nimport TooltipRichSourceRaw from './tooltip-rich.story?raw';\nimport TooltipRichActionsSourceRaw from './tooltip-rich-actions.story?raw';\nimport TooltipRichLinkSourceRaw from './tooltip-rich-link.story?raw';\nimport TooltipTriggerButtonWrapperSourceRaw from './tooltip-trigger-button-wrapper.story?raw';\nimport TooltipWithKeyboardShortcutSourceRaw from './tooltip-with-keyboard-shortcut.story?raw';\n\nexport const TooltipDefaultSource = removeLicenseHeader(\n TooltipDefaultSourceRaw,\n);\nexport const TooltipDisabledSource = removeLicenseHeader(\n TooltipDisabledSourceRaw,\n);\nexport const TooltipControlledSource = removeLicenseHeader(\n TooltipControlledSourceRaw,\n);\nexport const TooltipInitialOpenSource = removeLicenseHeader(\n TooltipInitialOpenSourceRaw,\n);\nexport const TooltipPlacementsSource = removeLicenseHeader(\n TooltipPlacementsSourceRaw,\n);\nexport const TooltipInDialogSource = removeLicenseHeader(\n TooltipInDialogSourceRaw,\n);\nexport const TooltipHoverDelaySource = removeLicenseHeader(\n TooltipHoverDelaySourceRaw,\n);\nexport const TooltipRichSource = removeLicenseHeader(TooltipRichSourceRaw);\nexport const TooltipRichActionsSource = removeLicenseHeader(\n TooltipRichActionsSourceRaw,\n);\nexport const TooltipRichLinkSource = removeLicenseHeader(\n TooltipRichLinkSourceRaw,\n);\nexport const TooltipTriggerButtonWrapperSource = removeLicenseHeader(\n TooltipTriggerButtonWrapperSourceRaw,\n);\nexport const TooltipWithKeyboardShortcutSource = removeLicenseHeader(\n TooltipWithKeyboardShortcutSourceRaw,\n);\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const Component = () => {
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "rich", children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { size: "medium", children: "Click me!" }) }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip.Content, { children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Header, { children: "Header" }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header, Body, and Actions." }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip.Actions, { children: [(0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { onClick: () => alert('Primary action'), children: "Action" }), (0, jsx_runtime_1.jsx)(react_1.TextButton, { onClick: () => alert('Secondary action'), children: "Action" })] })] })] }));
|
|
28
|
+
};
|
|
29
|
+
exports.default = Component;
|
|
30
|
+
//# sourceMappingURL=tooltip-rich-actions.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-rich-actions.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich-actions.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAK0B;AAE1B,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,wBAAC,eAAO,IAAC,IAAI,EAAC,MAAM,aAClB,uBAAC,eAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,uBAAC,oBAAY,IAAC,IAAI,EAAC,QAAQ,0BAAyB,GACpC,EAClB,wBAAC,eAAO,CAAC,OAAO,eACd,uBAAC,eAAO,CAAC,MAAM,yBAAwB,EACvC,uBAAC,eAAO,CAAC,IAAI,6GAGE,EACf,wBAAC,eAAO,CAAC,OAAO,eACd,uBAAC,sBAAc,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,uBAErC,EACjB,uBAAC,kBAAU,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,uBAEvC,IACG,IACF,IACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport {\n FilledButton,\n OutlinedButton,\n TextButton,\n Tooltip,\n} from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <Tooltip type=\"rich\">\n <Tooltip.Trigger hasButtonWrapper>\n <FilledButton size=\"medium\">Click me!</FilledButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n <Tooltip.Header>Header</Tooltip.Header>\n <Tooltip.Body>\n This rich tooltip demonstrates all the available subcomponents:\n Header, Body, and Actions.\n </Tooltip.Body>\n <Tooltip.Actions>\n <OutlinedButton onClick={() => alert('Primary action')}>\n Action\n </OutlinedButton>\n <TextButton onClick={() => alert('Secondary action')}>\n Action\n </TextButton>\n </Tooltip.Actions>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -24,7 +24,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
24
24
|
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
25
|
const react_1 = require("@neo4j-ndl/react");
|
|
26
26
|
const Component = () => {
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "rich", children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { size: "medium", children: "Click me!" }) }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip.Content, { children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Header, { children: "Header" }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "rich", children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { hasButtonWrapper: true, children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { size: "medium", children: "Click me!" }) }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip.Content, { children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Header, { children: "Header" }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header and Body, without Actions." })] })] }));
|
|
28
28
|
};
|
|
29
29
|
exports.default = Component;
|
|
30
30
|
//# sourceMappingURL=tooltip-rich.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-rich.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,
|
|
1
|
+
{"version":3,"file":"tooltip-rich.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAyD;AAEzD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,wBAAC,eAAO,IAAC,IAAI,EAAC,MAAM,aAClB,uBAAC,eAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,uBAAC,oBAAY,IAAC,IAAI,EAAC,QAAQ,0BAAyB,GACpC,EAClB,wBAAC,eAAO,CAAC,OAAO,eACd,uBAAC,eAAO,CAAC,MAAM,yBAAwB,EACvC,uBAAC,eAAO,CAAC,IAAI,oHAGE,IACC,IACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, Tooltip } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <Tooltip type=\"rich\">\n <Tooltip.Trigger hasButtonWrapper>\n <FilledButton size=\"medium\">Click me!</FilledButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n <Tooltip.Header>Header</Tooltip.Header>\n <Tooltip.Body>\n This rich tooltip demonstrates all the available subcomponents: Header\n and Body, without Actions.\n </Tooltip.Body>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -25,9 +25,12 @@ exports.useTooltip = useTooltip;
|
|
|
25
25
|
const react_1 = require("@floating-ui/react");
|
|
26
26
|
const react_2 = require("react");
|
|
27
27
|
function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controlledOpen, onOpenChange: setControlledOpen, type = 'simple', isPortaled = true, strategy = 'absolute', hoverDelay = undefined, shouldCloseOnReferenceClick = false, autoUpdateOptions, isDisabled = false, } = {}) {
|
|
28
|
+
const id = (0, react_2.useId)();
|
|
29
|
+
const [headerId, setHeaderId] = (0, react_2.useState)(id);
|
|
28
30
|
const [isUncontrolledOpen, setIsUncontrolledOpen] = (0, react_2.useState)(isInitialOpen);
|
|
29
31
|
const isOpen = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : isUncontrolledOpen;
|
|
30
32
|
const setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setIsUncontrolledOpen;
|
|
33
|
+
const typeOpenedRef = (0, react_2.useRef)(null);
|
|
31
34
|
const data = (0, react_1.useFloating)({
|
|
32
35
|
middleware: [
|
|
33
36
|
(0, react_1.offset)(5),
|
|
@@ -70,10 +73,22 @@ function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controll
|
|
|
70
73
|
role: type === 'simple' ? 'tooltip' : 'dialog',
|
|
71
74
|
});
|
|
72
75
|
const interactions = (0, react_1.useInteractions)([hover, focus, dismiss, role, click]);
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
const setTypeOpened = (type) => {
|
|
77
|
+
typeOpenedRef.current = type;
|
|
78
|
+
};
|
|
79
|
+
return (0, react_2.useMemo)(() => (Object.assign(Object.assign({ headerId: type === 'rich' ? headerId : undefined, isOpen,
|
|
80
|
+
isPortaled, setHeaderId: type === 'rich' ? setHeaderId : undefined, setOpen,
|
|
81
|
+
setTypeOpened,
|
|
82
|
+
type, typeOpened: typeOpenedRef.current }, interactions), data)), [
|
|
83
|
+
headerId,
|
|
84
|
+
isOpen,
|
|
75
85
|
setOpen,
|
|
76
|
-
type
|
|
86
|
+
type,
|
|
87
|
+
typeOpenedRef,
|
|
88
|
+
isPortaled,
|
|
89
|
+
interactions,
|
|
90
|
+
data,
|
|
91
|
+
]);
|
|
77
92
|
}
|
|
78
93
|
exports.TooltipContext = (0, react_2.createContext)(null);
|
|
79
94
|
const useTooltipContext = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../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C,EAAE,EAAE;QAC1D,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,+BACJ,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM;QACN,UAAU,EACV,WAAW,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACtD,OAAO;QACP,aAAa;QACb,IAAI,EACJ,UAAU,EAAE,aAAa,CAAC,OAAO,IAC9B,YAAY,GACZ,IAAI,EACP,EACF;QACE,QAAQ;QACR,MAAM;QACN,OAAO;QACP,IAAI;QACJ,aAAa;QACb,UAAU;QACV,YAAY;QACZ,IAAI;KACL,CACF,CAAC;AACJ,CAAC;AAGY,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAc,IAAI,CAAC,CAAC;AAExD,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,sBAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport {\n createContext,\n useContext,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n typeOpened?: 'keyboard' | 'mouse';\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n typeOpened: 'keyboard' | 'mouse' | null;\n setTypeOpened: (type: 'keyboard' | 'mouse' | null) => void;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen = setControlledOpen ?? setIsUncontrolledOpen;\n const typeOpenedRef = useRef<'keyboard' | 'mouse'>(null);\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setOpen,\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n\n const interactions = useInteractions([hover, focus, dismiss, role, click]);\n\n const setTypeOpened = (type: 'keyboard' | 'mouse' | null) => {\n typeOpenedRef.current = type;\n };\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n setTypeOpened,\n type,\n typeOpened: typeOpenedRef.current,\n ...interactions,\n ...data,\n }),\n [\n headerId,\n isOpen,\n setOpen,\n type,\n typeOpenedRef,\n isPortaled,\n interactions,\n data,\n ],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
@@ -66,7 +66,7 @@ const SegmentedControlItem = (_a) => {
|
|
|
66
66
|
'ndl-segment-item': !hasOnlyIcons,
|
|
67
67
|
});
|
|
68
68
|
const Component = as !== null && as !== void 0 ? as : 'button';
|
|
69
|
-
return (_jsxs(Tooltip, Object.assign({ isPortaled: false, isDisabled: Boolean(description) === false }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { type: "simple", children: [_jsx(Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: _jsx(Component, Object.assign({ onClick: () => !isSelected && onChange(value), className: baseClasses, style: style, ref: ref, "aria-label": description, disabled: isDisabled }, restProps, htmlAttributes, { children: children })) })), _jsx(Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: _jsx(Tooltip.Body, { children: description }) }))] })));
|
|
69
|
+
return (_jsxs(Tooltip, Object.assign({ isPortaled: false, isDisabled: Boolean(description) === false }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { type: "simple", children: [_jsx(Tooltip.Trigger, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { hasButtonWrapper: true, children: _jsx(Component, Object.assign({ "aria-pressed": isSelected, onClick: () => !isSelected && onChange(value), className: baseClasses, style: style, ref: ref, "aria-label": description, disabled: isDisabled }, restProps, htmlAttributes, { children: children })) })), _jsx(Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: _jsx(Tooltip.Body, { children: description }) }))] })));
|
|
70
70
|
};
|
|
71
71
|
SegmentedControlItem.displayName = 'SegmentedControl.Item';
|
|
72
72
|
const SegmentedControl = Object.assign(SegmentedControlComponent, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sourceRoot":"","sources":["../../../src/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM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AZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,cACxC,KAAC,OAAO,CAAC,IAAI,cAAE,WAAW,GAAgB,IAC1B,KACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,oBAAoB,CAAC,WAAW,GAAG,uBAAuB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE;IAChE,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAC;AAEH,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport React, { useContext } from 'react';\n\nimport {\n type PolymorphicCommonProps,\n type TooltipObjectProps,\n} from '../_common/types';\nimport { Tooltip } from '../tooltip/Tooltip';\n\ntype SegmentedControlID = string | number;\n\ntype SegmentedControlProps<T extends SegmentedControlID> = {\n /** Additional class name */\n className?: string;\n /** Size of the segmented control */\n size?: 'small' | 'medium' | 'large';\n /** If segmented control items will include only icons (makes controls rectangular) */\n hasOnlyIcons?: boolean;\n /** The callback function triggered when the segmented control value changes */\n onChange: (e: T) => void | ((e: React.SetStateAction<T>) => void);\n /** The currently selected option */\n selected: T;\n /** The children component of the segmented control */\n children: React.ReactNode;\n /** Whether the segmented control has a box shadow applied */\n isFloating?: boolean;\n};\n\ntype SegmentedControlContext<T extends SegmentedControlID> = Required<\n Pick<SegmentedControlProps<T>, 'onChange' | 'selected' | 'hasOnlyIcons'>\n>;\n\n// eslint-disable-next-line no-redeclare\nconst SegmentedControlContext =\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n React.createContext<SegmentedControlContext<any> | null>(null);\n\nconst useSelectorContext = () => {\n const context = useContext(SegmentedControlContext);\n\n if (context === null) {\n throw new Error('SegmentedControl used without context');\n }\n\n return context;\n};\n\nconst SegmentedControlComponent = <\n T extends SegmentedControlID,\n U extends React.ElementType = 'div',\n>({\n size = 'medium',\n hasOnlyIcons = false,\n children,\n selected,\n onChange,\n as,\n className,\n style,\n isFloating = false,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, SegmentedControlProps<T>>) => {\n const classes = classNames('ndl-segmented-control', className, {\n 'ndl-floating': isFloating,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-small': size === 'small',\n });\n\n const Component = as ?? 'div';\n\n return (\n <Component\n className={classes}\n style={style}\n role=\"group\"\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <SegmentedControlContext.Provider\n value={{ hasOnlyIcons, onChange, selected }}\n >\n {children}\n </SegmentedControlContext.Provider>\n </Component>\n );\n};\n\nSegmentedControlComponent.displayName = 'SegmentedControl';\n\ntype SegmentedControlItemProps = {\n /** Additional class name */\n className?: string;\n /** The children component of the segmented control item */\n children?: React.ReactNode;\n /** The value of the segmented control item */\n value: string;\n /** The description of the segmented control item, will be displayed in the tooltip */\n description?: string;\n /** The tooltip props that will be applied if tooltip is set */\n tooltipProps?: TooltipObjectProps;\n /** Whether the segmented control item is disabled */\n isDisabled?: boolean;\n};\n\nconst SegmentedControlItem = <T extends React.ElementType = 'button'>({\n as,\n children,\n className,\n style,\n value,\n htmlAttributes,\n description,\n tooltipProps,\n isDisabled = false,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SegmentedControlItemProps>) => {\n const { onChange, selected, hasOnlyIcons } = useSelectorContext();\n\n const isSelected = value === selected;\n\n const baseClasses = classNames(className, {\n 'ndl-current': isSelected,\n 'ndl-segment-icon': hasOnlyIcons,\n 'ndl-segment-item': !hasOnlyIcons,\n });\n\n const Component: React.ElementType = as ?? 'button';\n\n return (\n <Tooltip\n isPortaled={false}\n isDisabled={Boolean(description) === false}\n {...tooltipProps?.root}\n type=\"simple\"\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <Component\n aria-pressed={isSelected}\n onClick={() => !isSelected && onChange(value)}\n className={baseClasses}\n style={style}\n ref={ref}\n aria-label={description}\n disabled={isDisabled}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n <Tooltip.Body>{description}</Tooltip.Body>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nSegmentedControlItem.displayName = 'SegmentedControl.Item';\n\nconst SegmentedControl = Object.assign(SegmentedControlComponent, {\n Item: SegmentedControlItem,\n});\n\nexport { SegmentedControl };\n"]}
|
|
@@ -32,7 +32,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
32
32
|
*/
|
|
33
33
|
import { FloatingFocusManager, FloatingPortal, useMergeRefs, } from '@floating-ui/react';
|
|
34
34
|
import classNames from 'classnames';
|
|
35
|
-
import {
|
|
35
|
+
import React, { useEffect } from 'react';
|
|
36
36
|
import { ConditionalWrap } from '../conditional-wrap';
|
|
37
37
|
import { useIsInsideDialog } from '../dialog/dialog-context';
|
|
38
38
|
import { useNeedleTheme } from '../theme';
|
|
@@ -75,17 +75,25 @@ const TooltipTrigger = (_a) => {
|
|
|
75
75
|
'ndl-open': context.isOpen,
|
|
76
76
|
}, 'ndl-tooltip-trigger', className);
|
|
77
77
|
// `hasButtonWrapper=true` allows the user to pass any element as the anchor
|
|
78
|
-
if (hasButtonWrapper && isValidElement(children)) {
|
|
78
|
+
if (hasButtonWrapper && React.isValidElement(children)) {
|
|
79
79
|
const props = Object.assign(Object.assign(Object.assign({ className: triggerClasses }, htmlAttributes), childrenProps), { ref: mergedRefs });
|
|
80
|
-
return cloneElement(children, context.getReferenceProps(props));
|
|
80
|
+
return React.cloneElement(children, context.getReferenceProps(props));
|
|
81
81
|
}
|
|
82
82
|
return (_jsx("button", Object.assign({ type: "button", className: triggerClasses, style: style, ref: mergedRefs }, context.getReferenceProps(htmlAttributes), restProps, { children: children })));
|
|
83
83
|
};
|
|
84
84
|
const TooltipContent = (_a) => {
|
|
85
|
+
var _b;
|
|
85
86
|
var { children, style, htmlAttributes, className, ref } = _a, restProps = __rest(_a, ["children", "style", "htmlAttributes", "className", "ref"]);
|
|
86
87
|
const context = useTooltipContext();
|
|
87
88
|
const mergedRef = useMergeRefs([context.refs.setFloating, ref]);
|
|
88
89
|
const { themeClassName } = useNeedleTheme();
|
|
90
|
+
const hasHeaderChild = React.useMemo(() => {
|
|
91
|
+
if (context.type !== 'rich') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const childrenArray = React.Children.toArray(children);
|
|
95
|
+
return childrenArray.some((child) => React.isValidElement(child) && child.type === TooltipHeader);
|
|
96
|
+
}, [children, context.type]);
|
|
89
97
|
if (!context.isOpen) {
|
|
90
98
|
return null;
|
|
91
99
|
}
|
|
@@ -96,16 +104,26 @@ const TooltipContent = (_a) => {
|
|
|
96
104
|
if (context.type === 'simple') {
|
|
97
105
|
return (_jsx(ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => _jsx(FloatingPortal, { children: wrapChildren }), children: _jsx("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(htmlAttributes), { children: _jsx(Typography, { variant: "body-medium", children: children }) })) }));
|
|
98
106
|
}
|
|
99
|
-
|
|
107
|
+
const ariaLabelledBy = (_b = htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-labelledby']) !== null && _b !== void 0 ? _b : (hasHeaderChild ? context.headerId : undefined);
|
|
108
|
+
if ((htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes['aria-label']) === undefined && !ariaLabelledBy) {
|
|
109
|
+
console.warn('The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.');
|
|
110
|
+
}
|
|
111
|
+
return (_jsx(ConditionalWrap, { shouldWrap: context.isPortaled, wrap: (wrapChildren) => _jsx(FloatingPortal, { children: wrapChildren }), children: _jsx(FloatingFocusManager, { context: context.context, returnFocus: true, modal: false, initialFocus: 0, closeOnFocusOut: true, children: _jsx("div", Object.assign({ ref: mergedRef, className: classes, style: Object.assign(Object.assign({}, context.floatingStyles), style) }, restProps, context.getFloatingProps(Object.assign(Object.assign({}, htmlAttributes), { 'aria-labelledby': ariaLabelledBy })), { children: children })) }) }));
|
|
100
112
|
};
|
|
101
113
|
const TooltipHeader = (_a) => {
|
|
102
114
|
var { children, passThroughProps, typographyVariant = 'subheading-medium', className, style, htmlAttributes, ref } = _a, restProps = __rest(_a, ["children", "passThroughProps", "typographyVariant", "className", "style", "htmlAttributes", "ref"]);
|
|
103
115
|
const context = useTooltipContext();
|
|
104
116
|
const classes = classNames('ndl-tooltip-header', className);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
var _a;
|
|
119
|
+
if (Boolean(htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id) === true) {
|
|
120
|
+
(_a = context.setHeaderId) === null || _a === void 0 ? void 0 : _a.call(context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id);
|
|
121
|
+
}
|
|
122
|
+
}, [context, htmlAttributes === null || htmlAttributes === void 0 ? void 0 : htmlAttributes.id]);
|
|
105
123
|
if (!context.isOpen) {
|
|
106
124
|
return null;
|
|
107
125
|
}
|
|
108
|
-
return (_jsx(Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: htmlAttributes }, passThroughProps, restProps, { children: children })));
|
|
126
|
+
return (_jsx(Typography, Object.assign({ ref: ref, variant: typographyVariant, className: classes, style: style, htmlAttributes: Object.assign(Object.assign({}, htmlAttributes), { id: context.headerId }) }, passThroughProps, restProps, { children: children })));
|
|
109
127
|
};
|
|
110
128
|
const TooltipBody = (_a) => {
|
|
111
129
|
var { children, className, style, htmlAttributes, passThroughProps, ref } = _a, restProps = __rest(_a, ["children", "className", "style", "htmlAttributes", "passThroughProps", "ref"]);
|
|
@@ -126,6 +144,7 @@ const Actions = (_a) => {
|
|
|
126
144
|
const classes = classNames('ndl-tooltip-actions', className);
|
|
127
145
|
return (_jsx("div", Object.assign({ className: classes, ref: mergedRefs, style: style }, restProps, htmlAttributes, { children: children })));
|
|
128
146
|
};
|
|
147
|
+
Actions.displayName = 'Tooltip.Actions';
|
|
129
148
|
const Tooltip = Object.assign(TooltipComponent, {
|
|
130
149
|
Actions: Actions,
|
|
131
150
|
Body: TooltipBody,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA+B9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,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AE,CAAC;IACpC,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,4BACE,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { cloneElement, isValidElement } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={-1}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB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B,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,IAC1B,gBAAgB,EAChB,SAAS,cAEZ,QAAQ,IACE,CACd,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,OAAO,GAAG,CAAC,EAOyB,EAAE,EAAE;QAP7B,EACf,QAAQ,EACR,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAEqC,EADrC,SAAS,cANG,2DAOhB,CADa;IAEZ,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,4BACE,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAExC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n /** Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
@@ -27,6 +27,7 @@ export { default as TooltipInDialog } from './tooltip-in-dialog.story';
|
|
|
27
27
|
export { default as TooltipHoverDelay } from './tooltip-hover-delay.story';
|
|
28
28
|
export { default as TooltipTriggerButtonWrapper } from './tooltip-trigger-button-wrapper.story';
|
|
29
29
|
export { default as TooltipRich } from './tooltip-rich.story';
|
|
30
|
+
export { default as TooltipRichActions } from './tooltip-rich-actions.story';
|
|
30
31
|
export { default as TooltipRichLink } from './tooltip-rich-link.story';
|
|
31
32
|
export { default as TooltipWithKeyboardShortcut } from './tooltip-with-keyboard-shortcut.story';
|
|
32
33
|
import { removeLicenseHeader } from '../../_common/export-stories-utils';
|
|
@@ -38,6 +39,7 @@ import TooltipInDialogSourceRaw from './tooltip-in-dialog.story?raw';
|
|
|
38
39
|
import TooltipInitialOpenSourceRaw from './tooltip-initial-open.story?raw';
|
|
39
40
|
import TooltipPlacementsSourceRaw from './tooltip-placements.story?raw';
|
|
40
41
|
import TooltipRichSourceRaw from './tooltip-rich.story?raw';
|
|
42
|
+
import TooltipRichActionsSourceRaw from './tooltip-rich-actions.story?raw';
|
|
41
43
|
import TooltipRichLinkSourceRaw from './tooltip-rich-link.story?raw';
|
|
42
44
|
import TooltipTriggerButtonWrapperSourceRaw from './tooltip-trigger-button-wrapper.story?raw';
|
|
43
45
|
import TooltipWithKeyboardShortcutSourceRaw from './tooltip-with-keyboard-shortcut.story?raw';
|
|
@@ -48,8 +50,9 @@ export const TooltipInitialOpenSource = removeLicenseHeader(TooltipInitialOpenSo
|
|
|
48
50
|
export const TooltipPlacementsSource = removeLicenseHeader(TooltipPlacementsSourceRaw);
|
|
49
51
|
export const TooltipInDialogSource = removeLicenseHeader(TooltipInDialogSourceRaw);
|
|
50
52
|
export const TooltipHoverDelaySource = removeLicenseHeader(TooltipHoverDelaySourceRaw);
|
|
51
|
-
export const TooltipTriggerButtonWrapperSource = removeLicenseHeader(TooltipTriggerButtonWrapperSourceRaw);
|
|
52
53
|
export const TooltipRichSource = removeLicenseHeader(TooltipRichSourceRaw);
|
|
54
|
+
export const TooltipRichActionsSource = removeLicenseHeader(TooltipRichActionsSourceRaw);
|
|
53
55
|
export const TooltipRichLinkSource = removeLicenseHeader(TooltipRichLinkSourceRaw);
|
|
56
|
+
export const TooltipTriggerButtonWrapperSource = removeLicenseHeader(TooltipTriggerButtonWrapperSourceRaw);
|
|
54
57
|
export const TooltipWithKeyboardShortcutSource = removeLicenseHeader(TooltipWithKeyboardShortcutSourceRaw);
|
|
55
58
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,8BA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C,MAAM,iCAAiC,GAAG,mBAAmB,CAClE,oCAAoC,CACrC,CAAC;AACF,MAAM,CAAC,MAAM,iCAAiC,GAAG,mBAAmB,CAClE,oCAAoC,CACrC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as TooltipDefault } from './tooltip-default.story';\nexport { default as TooltipDisabled } from './tooltip-disabled.story';\nexport { default as TooltipControlled } from './tooltip-controlled.story';\nexport { default as TooltipInitialOpen } from './tooltip-initial-open.story';\nexport { default as TooltipPlacements } from './tooltip-placements.story';\nexport { default as TooltipInDialog } from './tooltip-in-dialog.story';\nexport { default as TooltipHoverDelay } from './tooltip-hover-delay.story';\nexport { default as TooltipTriggerButtonWrapper } from './tooltip-trigger-button-wrapper.story';\nexport { default as TooltipRich } from './tooltip-rich.story';\nexport { default as TooltipRichActions } from './tooltip-rich-actions.story';\nexport { default as TooltipRichLink } from './tooltip-rich-link.story';\nexport { default as TooltipWithKeyboardShortcut } from './tooltip-with-keyboard-shortcut.story';\n\nimport { removeLicenseHeader } from '../../_common/export-stories-utils';\nimport TooltipControlledSourceRaw from './tooltip-controlled.story?raw';\nimport TooltipDefaultSourceRaw from './tooltip-default.story?raw';\nimport TooltipDisabledSourceRaw from './tooltip-disabled.story?raw';\nimport TooltipHoverDelaySourceRaw from './tooltip-hover-delay.story?raw';\nimport TooltipInDialogSourceRaw from './tooltip-in-dialog.story?raw';\nimport TooltipInitialOpenSourceRaw from './tooltip-initial-open.story?raw';\nimport TooltipPlacementsSourceRaw from './tooltip-placements.story?raw';\nimport TooltipRichSourceRaw from './tooltip-rich.story?raw';\nimport TooltipRichActionsSourceRaw from './tooltip-rich-actions.story?raw';\nimport TooltipRichLinkSourceRaw from './tooltip-rich-link.story?raw';\nimport TooltipTriggerButtonWrapperSourceRaw from './tooltip-trigger-button-wrapper.story?raw';\nimport TooltipWithKeyboardShortcutSourceRaw from './tooltip-with-keyboard-shortcut.story?raw';\n\nexport const TooltipDefaultSource = removeLicenseHeader(\n TooltipDefaultSourceRaw,\n);\nexport const TooltipDisabledSource = removeLicenseHeader(\n TooltipDisabledSourceRaw,\n);\nexport const TooltipControlledSource = removeLicenseHeader(\n TooltipControlledSourceRaw,\n);\nexport const TooltipInitialOpenSource = removeLicenseHeader(\n TooltipInitialOpenSourceRaw,\n);\nexport const TooltipPlacementsSource = removeLicenseHeader(\n TooltipPlacementsSourceRaw,\n);\nexport const TooltipInDialogSource = removeLicenseHeader(\n TooltipInDialogSourceRaw,\n);\nexport const TooltipHoverDelaySource = removeLicenseHeader(\n TooltipHoverDelaySourceRaw,\n);\nexport const TooltipRichSource = removeLicenseHeader(TooltipRichSourceRaw);\nexport const TooltipRichActionsSource = removeLicenseHeader(\n TooltipRichActionsSourceRaw,\n);\nexport const TooltipRichLinkSource = removeLicenseHeader(\n TooltipRichLinkSourceRaw,\n);\nexport const TooltipTriggerButtonWrapperSource = removeLicenseHeader(\n TooltipTriggerButtonWrapperSourceRaw,\n);\nexport const TooltipWithKeyboardShortcutSource = removeLicenseHeader(\n TooltipWithKeyboardShortcutSourceRaw,\n);\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
+
import { FilledButton, OutlinedButton, TextButton, Tooltip, } from '@neo4j-ndl/react';
|
|
24
|
+
const Component = () => {
|
|
25
|
+
return (_jsxs(Tooltip, { type: "rich", children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx(FilledButton, { size: "medium", children: "Click me!" }) }), _jsxs(Tooltip.Content, { children: [_jsx(Tooltip.Header, { children: "Header" }), _jsx(Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header, Body, and Actions." }), _jsxs(Tooltip.Actions, { children: [_jsx(OutlinedButton, { onClick: () => alert('Primary action'), children: "Action" }), _jsx(TextButton, { onClick: () => alert('Secondary action'), children: "Action" })] })] })] }));
|
|
26
|
+
};
|
|
27
|
+
export default Component;
|
|
28
|
+
//# sourceMappingURL=tooltip-rich-actions.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-rich-actions.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich-actions.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,OAAO,GACR,MAAM,kBAAkB,CAAC;AAE1B,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAC,MAAM,aAClB,KAAC,OAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,KAAC,YAAY,IAAC,IAAI,EAAC,QAAQ,0BAAyB,GACpC,EAClB,MAAC,OAAO,CAAC,OAAO,eACd,KAAC,OAAO,CAAC,MAAM,yBAAwB,EACvC,KAAC,OAAO,CAAC,IAAI,6GAGE,EACf,MAAC,OAAO,CAAC,OAAO,eACd,KAAC,cAAc,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,uBAErC,EACjB,KAAC,UAAU,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,uBAEvC,IACG,IACF,IACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport {\n FilledButton,\n OutlinedButton,\n TextButton,\n Tooltip,\n} from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <Tooltip type=\"rich\">\n <Tooltip.Trigger hasButtonWrapper>\n <FilledButton size=\"medium\">Click me!</FilledButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n <Tooltip.Header>Header</Tooltip.Header>\n <Tooltip.Body>\n This rich tooltip demonstrates all the available subcomponents:\n Header, Body, and Actions.\n </Tooltip.Body>\n <Tooltip.Actions>\n <OutlinedButton onClick={() => alert('Primary action')}>\n Action\n </OutlinedButton>\n <TextButton onClick={() => alert('Secondary action')}>\n Action\n </TextButton>\n </Tooltip.Actions>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -20,9 +20,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
20
20
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
21
|
*/
|
|
22
22
|
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
|
-
import { FilledButton,
|
|
23
|
+
import { FilledButton, Tooltip } from '@neo4j-ndl/react';
|
|
24
24
|
const Component = () => {
|
|
25
|
-
return (_jsxs(Tooltip, { type: "rich", children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx(FilledButton, { size: "medium", children: "Click me!" }) }), _jsxs(Tooltip.Content, { children: [_jsx(Tooltip.Header, { children: "Header" }), _jsx(Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header
|
|
25
|
+
return (_jsxs(Tooltip, { type: "rich", children: [_jsx(Tooltip.Trigger, { hasButtonWrapper: true, children: _jsx(FilledButton, { size: "medium", children: "Click me!" }) }), _jsxs(Tooltip.Content, { children: [_jsx(Tooltip.Header, { children: "Header" }), _jsx(Tooltip.Body, { children: "This rich tooltip demonstrates all the available subcomponents: Header and Body, without Actions." })] })] }));
|
|
26
26
|
};
|
|
27
27
|
export default Component;
|
|
28
28
|
//# sourceMappingURL=tooltip-rich.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-rich.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"tooltip-rich.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAC,MAAM,aAClB,KAAC,OAAO,CAAC,OAAO,IAAC,gBAAgB,kBAC/B,KAAC,YAAY,IAAC,IAAI,EAAC,QAAQ,0BAAyB,GACpC,EAClB,MAAC,OAAO,CAAC,OAAO,eACd,KAAC,OAAO,CAAC,MAAM,yBAAwB,EACvC,KAAC,OAAO,CAAC,IAAI,oHAGE,IACC,IACV,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { FilledButton, Tooltip } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <Tooltip type=\"rich\">\n <Tooltip.Trigger hasButtonWrapper>\n <FilledButton size=\"medium\">Click me!</FilledButton>\n </Tooltip.Trigger>\n <Tooltip.Content>\n <Tooltip.Header>Header</Tooltip.Header>\n <Tooltip.Body>\n This rich tooltip demonstrates all the available subcomponents: Header\n and Body, without Actions.\n </Tooltip.Body>\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -19,11 +19,14 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { autoUpdate, flip, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from '@floating-ui/react';
|
|
22
|
-
import { createContext, useContext, useMemo, useState } from 'react';
|
|
22
|
+
import { createContext, useContext, useId, useMemo, useRef, useState, } from 'react';
|
|
23
23
|
export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controlledOpen, onOpenChange: setControlledOpen, type = 'simple', isPortaled = true, strategy = 'absolute', hoverDelay = undefined, shouldCloseOnReferenceClick = false, autoUpdateOptions, isDisabled = false, } = {}) {
|
|
24
|
+
const id = useId();
|
|
25
|
+
const [headerId, setHeaderId] = useState(id);
|
|
24
26
|
const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);
|
|
25
27
|
const isOpen = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : isUncontrolledOpen;
|
|
26
28
|
const setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setIsUncontrolledOpen;
|
|
29
|
+
const typeOpenedRef = useRef(null);
|
|
27
30
|
const data = useFloating({
|
|
28
31
|
middleware: [
|
|
29
32
|
offset(5),
|
|
@@ -66,10 +69,22 @@ export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: c
|
|
|
66
69
|
role: type === 'simple' ? 'tooltip' : 'dialog',
|
|
67
70
|
});
|
|
68
71
|
const interactions = useInteractions([hover, focus, dismiss, role, click]);
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const setTypeOpened = (type) => {
|
|
73
|
+
typeOpenedRef.current = type;
|
|
74
|
+
};
|
|
75
|
+
return useMemo(() => (Object.assign(Object.assign({ headerId: type === 'rich' ? headerId : undefined, isOpen,
|
|
76
|
+
isPortaled, setHeaderId: type === 'rich' ? setHeaderId : undefined, setOpen,
|
|
77
|
+
setTypeOpened,
|
|
78
|
+
type, typeOpened: typeOpenedRef.current }, interactions), data)), [
|
|
79
|
+
headerId,
|
|
80
|
+
isOpen,
|
|
71
81
|
setOpen,
|
|
72
|
-
type
|
|
82
|
+
type,
|
|
83
|
+
typeOpenedRef,
|
|
84
|
+
isPortaled,
|
|
85
|
+
interactions,
|
|
86
|
+
data,
|
|
87
|
+
]);
|
|
73
88
|
}
|
|
74
89
|
export const TooltipContext = createContext(null);
|
|
75
90
|
export const useTooltipContext = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EAEV,IAAI,EACJ,MAAM,EAGN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EAGX,QAAQ,EACR,QAAQ,EACR,eAAe,EAEf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EAEV,IAAI,EACJ,MAAM,EAGN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EAGX,QAAQ,EACR,QAAQ,EACR,eAAe,EAEf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,UAAU,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAoBf,MAAM,UAAU,UAAU,CAAC,EACzB,aAA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CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACtD,OAAO;QACP,aAAa;QACb,IAAI,EACJ,UAAU,EAAE,aAAa,CAAC,OAAO,IAC9B,YAAY,GACZ,IAAI,EACP,EACF;QACE,QAAQ;QACR,MAAM;QACN,OAAO;QACP,IAAI;QACJ,aAAa;QACb,UAAU;QACV,YAAY;QACZ,IAAI;KACL,CACF,CAAC;AACJ,CAAC;AAGD,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAc,IAAI,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport {\n createContext,\n useContext,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n typeOpened?: 'keyboard' | 'mouse';\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n typeOpened: 'keyboard' | 'mouse' | null;\n setTypeOpened: (type: 'keyboard' | 'mouse' | null) => void;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen = setControlledOpen ?? setIsUncontrolledOpen;\n const typeOpenedRef = useRef<'keyboard' | 'mouse'>(null);\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setOpen,\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n\n const interactions = useInteractions([hover, focus, dismiss, role, click]);\n\n const setTypeOpened = (type: 'keyboard' | 'mouse' | null) => {\n typeOpenedRef.current = type;\n };\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n setTypeOpened,\n type,\n typeOpened: typeOpenedRef.current,\n ...interactions,\n ...data,\n }),\n [\n headerId,\n isOpen,\n setOpen,\n type,\n typeOpenedRef,\n isPortaled,\n interactions,\n data,\n ],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,KAAK,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,IAAI;IACzD,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,IAAI,CA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AAC;IACpC,sFAAsF;IACtF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAClE,oCAAoC;IACpC,QAAQ,EAAE,CAAC,CAAC;IACZ,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAmEF,KAAK,yBAAyB,GAAG;IAC/B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA0DF,QAAA,MAAM,gBAAgB;KApHpB,CAAC,SAAS,kBAAkB,EAC5B,CAAC,SAAS,KAAK,CAAC,WAAW,qIAc1B,sBAAsB,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;;;;SA6CxB,CAAC,SAAS,KAAK,CAAC,WAAW,kIAYtD,sBAAsB,CAAC,CAAC,EAAE,yBAAyB,CAAC;;;CA8CrD,CAAC;AAEH,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { type AutoUpdateOptions, type Placement, type UseFloatingOptions } from '@floating-ui/react';
|
|
22
|
-
import
|
|
22
|
+
import React from 'react';
|
|
23
23
|
import { type CommonProps } from '../_common/types';
|
|
24
24
|
import { Typography, type TypographyVariants } from '../typography';
|
|
25
25
|
export type TooltipProps = {
|
|
@@ -81,7 +81,10 @@ declare const Tooltip: {
|
|
|
81
81
|
({ children, isDisabled, type, isInitialOpen, placement, isOpen, onOpenChange, isPortaled: isPortaledProp, floatingStrategy: strategyProp, hoverDelay, shouldCloseOnReferenceClick, autoUpdateOptions, }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
82
82
|
displayName: string;
|
|
83
83
|
} & {
|
|
84
|
-
Actions:
|
|
84
|
+
Actions: {
|
|
85
|
+
({ children, className, style, htmlAttributes, ref, ...restProps }: CommonProps<"div", ToolTipActionsProps>): import("react/jsx-runtime").JSX.Element | null;
|
|
86
|
+
displayName: string;
|
|
87
|
+
};
|
|
85
88
|
Body: ({ children, className, style, htmlAttributes, passThroughProps, ref, ...restProps }: CommonProps<"span", TooltipBodyProps>) => import("react/jsx-runtime").JSX.Element | null;
|
|
86
89
|
Content: ({ children, style, htmlAttributes, className, ref, ...restProps }: CommonProps<"div", TooltipContentProps>) => import("react/jsx-runtime").JSX.Element | null;
|
|
87
90
|
Header: ({ children, passThroughProps, typographyVariant, className, style, htmlAttributes, ref, ...restProps }: CommonProps<"span", TooltipHeaderProps>) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,KAAK,iBAAiB,EAGtB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAC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SAAS,CAAC;CAC3B,CAAC;AAiGF,KAAK,kBAAkB,GAAG;IACxB,0CAA0C;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;IAC9E,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAyCF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wCAAwC;IACxC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,2DAA2D;IAE3D,gBAAgB,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC;CAC/E,CAAC;AAiCF,KAAK,mBAAmB,GAAG;IACzB,qDAAqD;IACrD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAkCF,QAAA,MAAM,OAAO;8MAzTV,YAAY;;;;4EAgSZ,WAAW,CAAC,KAAK,EAAE,mBAAmB,CAAC;;;gGAnCvC,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC;iFAvJrC,WAAW,CAAC,KAAK,EAAE,mBAAmB,CAAC;qHAyGvC,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC;mGAnKvC,WAAW,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CAmR3C,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -27,6 +27,7 @@ export { default as TooltipInDialog } from './tooltip-in-dialog.story';
|
|
|
27
27
|
export { default as TooltipHoverDelay } from './tooltip-hover-delay.story';
|
|
28
28
|
export { default as TooltipTriggerButtonWrapper } from './tooltip-trigger-button-wrapper.story';
|
|
29
29
|
export { default as TooltipRich } from './tooltip-rich.story';
|
|
30
|
+
export { default as TooltipRichActions } from './tooltip-rich-actions.story';
|
|
30
31
|
export { default as TooltipRichLink } from './tooltip-rich-link.story';
|
|
31
32
|
export { default as TooltipWithKeyboardShortcut } from './tooltip-with-keyboard-shortcut.story';
|
|
32
33
|
export declare const TooltipDefaultSource: string;
|
|
@@ -36,8 +37,9 @@ export declare const TooltipInitialOpenSource: string;
|
|
|
36
37
|
export declare const TooltipPlacementsSource: string;
|
|
37
38
|
export declare const TooltipInDialogSource: string;
|
|
38
39
|
export declare const TooltipHoverDelaySource: string;
|
|
39
|
-
export declare const TooltipTriggerButtonWrapperSource: string;
|
|
40
40
|
export declare const TooltipRichSource: string;
|
|
41
|
+
export declare const TooltipRichActionsSource: string;
|
|
41
42
|
export declare const TooltipRichLinkSource: string;
|
|
43
|
+
export declare const TooltipTriggerButtonWrapperSource: string;
|
|
42
44
|
export declare const TooltipWithKeyboardShortcutSource: string;
|
|
43
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sB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;AACF,eAAO,MAAM,qBAAqB,QAEjC,CAAC;AACF,eAAO,MAAM,uBAAuB,QAEnC,CAAC;AACF,eAAO,MAAM,iBAAiB,QAA4C,CAAC;AAC3E,eAAO,MAAM,wBAAwB,QAEpC,CAAC;AACF,eAAO,MAAM,qBAAqB,QAEjC,CAAC;AACF,eAAO,MAAM,iCAAiC,QAE7C,CAAC;AACF,eAAO,MAAM,iCAAiC,QAE7C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
22
|
+
declare const Component: () => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Component;
|
|
24
|
+
//# sourceMappingURL=tooltip-rich-actions.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip-rich-actions.story.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich-actions.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AASjD,QAAA,MAAM,SAAS,+CAuBd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-rich.story.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip-rich.story.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-rich.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAIjD,QAAA,MAAM,SAAS,+CAed,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -34,12 +34,17 @@ export interface TooltipOptions {
|
|
|
34
34
|
shouldCloseOnReferenceClick?: boolean;
|
|
35
35
|
autoUpdateOptions?: AutoUpdateOptions;
|
|
36
36
|
isDisabled?: boolean;
|
|
37
|
+
typeOpened?: 'keyboard' | 'mouse';
|
|
37
38
|
}
|
|
38
39
|
export declare function useTooltip({ isInitialOpen, placement, isOpen: controlledOpen, onOpenChange: setControlledOpen, type, isPortaled, strategy, hoverDelay, shouldCloseOnReferenceClick, autoUpdateOptions, isDisabled, }?: TooltipOptions): {
|
|
40
|
+
headerId?: string;
|
|
41
|
+
setHeaderId?: (id: string | undefined) => void;
|
|
39
42
|
isOpen: boolean;
|
|
40
43
|
setOpen: (open: boolean) => void;
|
|
41
44
|
type: 'simple' | 'rich';
|
|
42
45
|
isPortaled: boolean;
|
|
46
|
+
typeOpened: 'keyboard' | 'mouse' | null;
|
|
47
|
+
setTypeOpened: (type: 'keyboard' | 'mouse' | null) => void;
|
|
43
48
|
} & UseInteractionsReturn & UseFloatingReturn<ReferenceType>;
|
|
44
49
|
type ContextType = ReturnType<typeof useTooltip> | null;
|
|
45
50
|
export declare const TooltipContext: import("react").Context<ContextType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,KAAK,iBAAiB,EAGtB,KAAK,SAAS,EACd,KAAK,aAAa,EAMlB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,KAAK,iBAAiB,EAGtB,KAAK,SAAS,EACd,KAAK,aAAa,EAMlB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAItB,KAAK,qBAAqB,EAE3B,MAAM,oBAAoB,CAAC;AAU5B,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAChC,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;CACnC;AAED,wBAAgB,UAAU,CAAC,EACzB,aAAqB,EAC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