@navikt/ds-react 0.17.16 → 0.17.19
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/cjs/form/search/Search.js +11 -17
- package/cjs/form/search/SearchButton.js +1 -1
- package/cjs/index.js +1 -0
- package/cjs/read-more/ReadMore.js +1 -1
- package/cjs/tooltip/Tooltip.js +153 -0
- package/cjs/tooltip/index.js +23 -0
- package/cjs/tooltip/package.json +6 -0
- package/cjs/tooltip/portal.js +17 -0
- package/cjs/util/index.js +11 -1
- package/esm/form/search/Search.d.ts +4 -4
- package/esm/form/search/Search.js +13 -19
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +1 -1
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/read-more/ReadMore.js +1 -1
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/tooltip/Tooltip.d.ts +51 -0
- package/esm/tooltip/Tooltip.js +126 -0
- package/esm/tooltip/Tooltip.js.map +1 -0
- package/esm/tooltip/index.d.ts +2 -0
- package/esm/tooltip/index.js +3 -0
- package/esm/tooltip/index.js.map +1 -0
- package/esm/tooltip/portal.d.ts +5 -0
- package/esm/tooltip/portal.js +13 -0
- package/esm/tooltip/portal.js.map +1 -0
- package/esm/util/index.d.ts +1 -0
- package/esm/util/index.js +9 -0
- package/esm/util/index.js.map +1 -1
- package/package.json +5 -4
- package/src/form/search/Search.tsx +22 -24
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/search/search-themes.stories.tsx +52 -0
- package/src/form/search/search.stories.tsx +10 -3
- package/src/index.ts +1 -0
- package/src/read-more/ReadMore.tsx +1 -0
- package/src/tooltip/Tooltip.tsx +301 -0
- package/src/tooltip/index.ts +2 -0
- package/src/tooltip/portal.tsx +15 -0
- package/src/tooltip/tooltip.stories.tsx +144 -0
- package/src/util/index.ts +14 -0
|
@@ -48,34 +48,27 @@ const useSearch_1 = require("./useSearch");
|
|
|
48
48
|
exports.SearchContext = react_1.default.createContext(null);
|
|
49
49
|
const Search = (0, react_1.forwardRef)((props, ref) => {
|
|
50
50
|
const { inputProps, size = "medium", inputDescriptionId } = (0, useSearch_1.useSearch)(props, "searchfield");
|
|
51
|
-
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "
|
|
51
|
+
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "onSearch", "variant", "defaultValue", "onChange"]);
|
|
52
52
|
const searchRef = (0, react_1.useRef)(null);
|
|
53
53
|
const mergedRef = (0, react_merge_refs_1.default)([searchRef, ref]);
|
|
54
54
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
55
|
-
const [
|
|
55
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
56
56
|
const handleChange = (0, react_1.useCallback)((v) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, [props, value]);
|
|
57
|
+
value === undefined && setInternalValue(v);
|
|
58
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(v);
|
|
59
|
+
}, [onChange, value]);
|
|
61
60
|
const handleClear = (0, react_1.useCallback)((event) => {
|
|
62
61
|
var _a, _b;
|
|
63
62
|
onClear === null || onClear === void 0 ? void 0 : onClear(event);
|
|
64
63
|
handleChange("");
|
|
65
|
-
if (searchRef.current && value === undefined) {
|
|
66
|
-
searchRef.current.value = "";
|
|
67
|
-
}
|
|
68
64
|
searchRef.current && ((_b = (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
69
|
-
}, [handleChange, onClear
|
|
65
|
+
}, [handleChange, onClear]);
|
|
70
66
|
(0, __1.useEventListener)("keydown", (0, react_1.useCallback)((e) => {
|
|
71
67
|
if (e.key === "Escape") {
|
|
72
68
|
e.preventDefault();
|
|
73
69
|
handleClear({ trigger: "Escape", event: e });
|
|
74
70
|
}
|
|
75
71
|
}, [handleClear]), wrapperRef);
|
|
76
|
-
(0, react_1.useEffect)(() => {
|
|
77
|
-
value !== undefined && setControlledValue(value);
|
|
78
|
-
}, [value]);
|
|
79
72
|
return (react_1.default.createElement("div", { ref: setWrapperRef, className: (0, classnames_1.default)(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
80
73
|
"navds-search--disabled": !!inputProps.disabled,
|
|
81
74
|
}) },
|
|
@@ -87,16 +80,17 @@ const Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
87
80
|
}), id: inputDescriptionId, size: size }, description)),
|
|
88
81
|
react_1.default.createElement("div", { className: "navds-search__wrapper" },
|
|
89
82
|
react_1.default.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
variant === "simple" && (react_1.default.createElement(ds_icons_1.Search, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
84
|
+
react_1.default.createElement("input", Object.assign({ ref: mergedRef }, (0, __1.omit)(rest, ["size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: (0, classnames_1.default)(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
85
|
+
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (react_1.default.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
92
86
|
react_1.default.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
93
87
|
react_1.default.createElement(ds_icons_1.Close, { "aria-hidden": true })))),
|
|
94
88
|
react_1.default.createElement(exports.SearchContext.Provider, { value: {
|
|
95
89
|
size,
|
|
96
90
|
disabled: inputProps.disabled,
|
|
97
91
|
variant,
|
|
98
|
-
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(
|
|
99
|
-
} }, children ? children : react_1.default.createElement(SearchButton_1.default, null)))));
|
|
92
|
+
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(value !== null && value !== void 0 ? value : internalValue),
|
|
93
|
+
} }, children ? children : variant !== "simple" && react_1.default.createElement(SearchButton_1.default, null)))));
|
|
100
94
|
});
|
|
101
95
|
Search.Button = SearchButton_1.default;
|
|
102
96
|
exports.default = Search;
|
|
@@ -51,7 +51,7 @@ const SearchButton = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
const { size, variant, onSearch } = context;
|
|
54
|
-
return (react_1.default.createElement(__1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant, className: (0, classnames_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
54
|
+
return (react_1.default.createElement(__1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: (0, classnames_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
55
55
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch();
|
|
56
56
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
57
57
|
} }),
|
package/cjs/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __exportStar(require("./tag"), exports);
|
|
|
37
37
|
__exportStar(require("./toggle-group"), exports);
|
|
38
38
|
__exportStar(require("./table"), exports);
|
|
39
39
|
__exportStar(require("./tabs"), exports);
|
|
40
|
+
__exportStar(require("./tooltip"), exports);
|
|
40
41
|
__exportStar(require("./typography"), exports);
|
|
41
42
|
__exportStar(require("./util"), exports);
|
|
42
43
|
/* Navno spesific packages */
|
|
@@ -50,7 +50,7 @@ const ReadMore = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
50
50
|
: react_collapse_1.UnmountClosed;
|
|
51
51
|
const isOpened = open !== null && open !== void 0 ? open : internalOpen;
|
|
52
52
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
53
|
-
react_1.default.createElement("button", Object.assign({}, rest, { className: (0, classnames_1.default)("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
|
|
53
|
+
react_1.default.createElement("button", Object.assign({ type: "button" }, rest, { className: (0, classnames_1.default)("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
|
|
54
54
|
"navds-read-more--open": isOpened,
|
|
55
55
|
}), onClick: (e) => {
|
|
56
56
|
if (open === undefined) {
|
|
@@ -0,0 +1,153 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const __1 = require("..");
|
|
43
|
+
const react_dom_1 = require("@floating-ui/react-dom");
|
|
44
|
+
const react_merge_refs_1 = __importDefault(require("react-merge-refs"));
|
|
45
|
+
const portal_1 = __importDefault(require("./portal"));
|
|
46
|
+
const util_1 = require("../util");
|
|
47
|
+
const Tooltip = (0, react_1.forwardRef)((_a, ref) => {
|
|
48
|
+
var { children, className, arrow: _arrow = true, placement: _placement = "top", open, defaultOpen = false, offset: _offset, content, delay = 150, id, keys, maxChar = 80 } = _a, rest = __rest(_a, ["children", "className", "arrow", "placement", "open", "defaultOpen", "offset", "content", "delay", "id", "keys", "maxChar"]);
|
|
49
|
+
const arrowRef = (0, react_1.useRef)(null);
|
|
50
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(defaultOpen);
|
|
51
|
+
const openTimerRef = (0, react_1.useRef)(0);
|
|
52
|
+
const leaveTimerRef = (0, react_1.useRef)(0);
|
|
53
|
+
const isMouseDownRef = (0, react_1.useRef)(false);
|
|
54
|
+
const ariaId = (0, util_1.useId)(id);
|
|
55
|
+
const { x, y, update, placement, refs, middlewareData: { arrow: { x: arrowX, y: arrowY } = {}, hide: { referenceHidden } = {}, }, } = (0, react_dom_1.useFloating)({
|
|
56
|
+
placement: _placement,
|
|
57
|
+
middleware: [
|
|
58
|
+
(0, react_dom_1.shift)(),
|
|
59
|
+
(0, react_dom_1.flip)({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
|
|
60
|
+
(0, react_dom_1.arrow)({ element: arrowRef, padding: 5 }),
|
|
61
|
+
(0, react_dom_1.hide)(),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
/* https://floating-ui.com/docs/react-dom#updating */
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
if (!refs.reference.current || !refs.floating.current) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Only call this when the floating element is rendered
|
|
70
|
+
return (0, react_dom_1.autoUpdate)(refs.reference.current, refs.floating.current, update);
|
|
71
|
+
}, [refs.reference, refs.floating, update, open, isOpen]);
|
|
72
|
+
const handleOpen = (0, react_1.useCallback)(() => {
|
|
73
|
+
window.clearTimeout(openTimerRef.current);
|
|
74
|
+
window.clearTimeout(leaveTimerRef.current);
|
|
75
|
+
setIsOpen(true);
|
|
76
|
+
}, [setIsOpen]);
|
|
77
|
+
const handleDelayedOpen = (0, react_1.useCallback)(() => {
|
|
78
|
+
window.clearTimeout(openTimerRef.current);
|
|
79
|
+
window.clearTimeout(leaveTimerRef.current);
|
|
80
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
81
|
+
setIsOpen(true);
|
|
82
|
+
}, delay);
|
|
83
|
+
}, [delay, setIsOpen]);
|
|
84
|
+
const handleClose = (0, react_1.useCallback)(() => {
|
|
85
|
+
window.clearTimeout(openTimerRef.current);
|
|
86
|
+
leaveTimerRef.current = window.setTimeout(() => {
|
|
87
|
+
setIsOpen(false);
|
|
88
|
+
}, 50);
|
|
89
|
+
}, [setIsOpen]);
|
|
90
|
+
const handleMouseUp = (0, react_1.useCallback)(() => (isMouseDownRef.current = false), []);
|
|
91
|
+
(0, react_1.useEffect)(() => {
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
return () => window.clearTimeout(openTimerRef.current);
|
|
94
|
+
}, []);
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
return () => document.removeEventListener("mouseup", handleMouseUp);
|
|
97
|
+
}, [handleMouseUp]);
|
|
98
|
+
(0, __1.useEventListener)("keydown", (0, react_1.useCallback)((e) => e.key === "Escape" && handleClose(), [handleClose]), document);
|
|
99
|
+
/* https://floating-ui.com/docs/react-dom#stable-ref-prop */
|
|
100
|
+
const stableRef = (0, react_1.useMemo)(() => (0, react_merge_refs_1.default)([ref, refs.floating]), [
|
|
101
|
+
ref,
|
|
102
|
+
refs.floating,
|
|
103
|
+
]);
|
|
104
|
+
if (!children ||
|
|
105
|
+
(children === null || children === void 0 ? void 0 : children.type) === react_1.default.Fragment ||
|
|
106
|
+
children === react_1.default.Fragment) {
|
|
107
|
+
console.error("<Tooltip> children needs to be a single ReactElement and not <React.Fragment/>/<></>");
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
if ((content === null || content === void 0 ? void 0 : content.length) > maxChar) {
|
|
111
|
+
console.error(`Because of strict accessibility concers we encourage all Tooltips to have less than 80 characters. Can be overwritten with the maxChar-prop`);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
115
|
+
(0, react_1.cloneElement)(children, Object.assign(Object.assign({}, children.props), { "aria-describedby": open || isOpen
|
|
116
|
+
? (0, classnames_1.default)(ariaId, children === null || children === void 0 ? void 0 : children.props["aria-describedby"])
|
|
117
|
+
: children === null || children === void 0 ? void 0 : children.props["aria-describedby"], ref: (0, react_merge_refs_1.default)([children.ref, refs.reference]), onMouseEnter: (0, __1.composeEventHandlers)(children.props.onMouseEnter, handleDelayedOpen), onMouseLeave: (0, __1.composeEventHandlers)(children.props.onMouseLeave, handleClose), onMouseDown: (0, __1.composeEventHandlers)(children.props.onMouseDown, () => {
|
|
118
|
+
isMouseDownRef.current = true;
|
|
119
|
+
document.addEventListener("mouseup", handleMouseUp, { once: true });
|
|
120
|
+
}), onFocus: (0, __1.composeEventHandlers)(children.props.onFocus, () => !isMouseDownRef.current && handleOpen()), onBlur: (0, __1.composeEventHandlers)(children.props.onBlur, handleClose) })),
|
|
121
|
+
(open !== null && open !== void 0 ? open : isOpen) && (react_1.default.createElement(portal_1.default, null,
|
|
122
|
+
react_1.default.createElement("div", Object.assign({ ref: stableRef }, rest, { onMouseEnter: handleOpen, onMouseLeave: handleClose, role: "tooltip", id: ariaId, style: {
|
|
123
|
+
position: "absolute",
|
|
124
|
+
top: y !== null && y !== void 0 ? y : "",
|
|
125
|
+
left: x !== null && x !== void 0 ? x : "",
|
|
126
|
+
visibility: referenceHidden ? "hidden" : "visible",
|
|
127
|
+
}, "data-side": placement, className: (0, classnames_1.default)("navds-tooltip", "navds-detail navds-detail--small", className) }),
|
|
128
|
+
react_1.default.createElement("div", { className: "navds-tooltip__inner", style: {
|
|
129
|
+
[{
|
|
130
|
+
top: "marginBottom",
|
|
131
|
+
right: "marginLeft",
|
|
132
|
+
bottom: "marginTop",
|
|
133
|
+
left: "marginRight",
|
|
134
|
+
}[placement]]: _offset ? _offset : _arrow ? 10 : 2,
|
|
135
|
+
} },
|
|
136
|
+
content,
|
|
137
|
+
keys && (react_1.default.createElement("span", { className: "navds-tooltip__keys" }, keys.map((key) => (react_1.default.createElement(__1.Detail, { size: "small", as: "kbd", key: key, className: "navds-tooltip__key" }, key))))),
|
|
138
|
+
_arrow && (react_1.default.createElement("div", { ref: (node) => {
|
|
139
|
+
arrowRef.current = node;
|
|
140
|
+
}, className: "navds-tooltip__arrow", style: {
|
|
141
|
+
left: arrowX != null ? `${arrowX}px` : "",
|
|
142
|
+
top: arrowY != null ? `${arrowY}px` : "",
|
|
143
|
+
right: "",
|
|
144
|
+
bottom: "",
|
|
145
|
+
[{
|
|
146
|
+
top: "bottom",
|
|
147
|
+
right: "left",
|
|
148
|
+
bottom: "top",
|
|
149
|
+
left: "right",
|
|
150
|
+
}[placement]]: "-3.5px",
|
|
151
|
+
} }))))))));
|
|
152
|
+
});
|
|
153
|
+
exports.default = Tooltip;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Tooltip = void 0;
|
|
21
|
+
var Tooltip_1 = require("./Tooltip");
|
|
22
|
+
Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return __importDefault(Tooltip_1).default; } });
|
|
23
|
+
__exportStar(require("./Tooltip"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* https://github.com/radix-ui/primitives/blob/main/packages/react/portal/src/Portal.tsx */
|
|
7
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
8
|
+
const Portal = ({ children }) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const hostElement = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) === null || _a === void 0 ? void 0 : _a.body;
|
|
11
|
+
if (hostElement) {
|
|
12
|
+
return react_dom_1.default.createPortal(children, hostElement);
|
|
13
|
+
}
|
|
14
|
+
// bail out of ssr
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
exports.default = Portal;
|
package/cjs/util/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useEventListener = exports.omit = void 0;
|
|
17
|
+
exports.composeEventHandlers = exports.useEventListener = exports.omit = void 0;
|
|
18
18
|
const react_1 = require("react");
|
|
19
19
|
__exportStar(require("./OverridableComponent"), exports);
|
|
20
20
|
__exportStar(require("./useId"), exports);
|
|
@@ -35,3 +35,13 @@ const useEventListener = (name, handler, target = window) => {
|
|
|
35
35
|
}, [name, handler, target]);
|
|
36
36
|
};
|
|
37
37
|
exports.useEventListener = useEventListener;
|
|
38
|
+
/* https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx */
|
|
39
|
+
const composeEventHandlers = (originalEventHandler, ourEventHandler) => {
|
|
40
|
+
return function handleEvent(event) {
|
|
41
|
+
originalEventHandler === null || originalEventHandler === void 0 ? void 0 : originalEventHandler(event);
|
|
42
|
+
if (!event.defaultPrevented) {
|
|
43
|
+
return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.composeEventHandlers = composeEventHandlers;
|
|
@@ -44,9 +44,9 @@ export interface SearchProps extends Omit<FormFieldProps, "error" | "errorId">,
|
|
|
44
44
|
clearButton?: boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Changes button-variant
|
|
47
|
-
* @default "
|
|
47
|
+
* @default "primary"
|
|
48
48
|
*/
|
|
49
|
-
variant?: "
|
|
49
|
+
variant?: "primary" | "secondary" | "simple";
|
|
50
50
|
}
|
|
51
51
|
interface SearchComponent extends React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLDivElement>> {
|
|
52
52
|
Button: SearchButtonType;
|
|
@@ -54,8 +54,8 @@ interface SearchComponent extends React.ForwardRefExoticComponent<SearchProps &
|
|
|
54
54
|
export interface SearchContextProps {
|
|
55
55
|
disabled?: boolean;
|
|
56
56
|
size: "medium" | "small";
|
|
57
|
-
variant
|
|
58
|
-
onSearch
|
|
57
|
+
variant: "primary" | "secondary" | "simple";
|
|
58
|
+
onSearch: () => void;
|
|
59
59
|
}
|
|
60
60
|
export declare const SearchContext: React.Context<SearchContextProps | null>;
|
|
61
61
|
declare const Search: SearchComponent;
|
|
@@ -9,9 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { Close } from "@navikt/ds-icons";
|
|
12
|
+
import { Close, Search as SearchIcon } from "@navikt/ds-icons";
|
|
13
13
|
import cl from "classnames";
|
|
14
|
-
import React, { forwardRef, useCallback,
|
|
14
|
+
import React, { forwardRef, useCallback, useRef, useState, } from "react";
|
|
15
15
|
import mergeRefs from "react-merge-refs";
|
|
16
16
|
import { BodyShort, Label, omit, useEventListener } from "../..";
|
|
17
17
|
import SearchButton from "./SearchButton";
|
|
@@ -19,34 +19,27 @@ import { useSearch } from "./useSearch";
|
|
|
19
19
|
export const SearchContext = React.createContext(null);
|
|
20
20
|
const Search = forwardRef((props, ref) => {
|
|
21
21
|
const { inputProps, size = "medium", inputDescriptionId } = useSearch(props, "searchfield");
|
|
22
|
-
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "
|
|
22
|
+
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "onSearch", "variant", "defaultValue", "onChange"]);
|
|
23
23
|
const searchRef = useRef(null);
|
|
24
24
|
const mergedRef = mergeRefs([searchRef, ref]);
|
|
25
25
|
const [wrapperRef, setWrapperRef] = useState(null);
|
|
26
|
-
const [
|
|
26
|
+
const [internalValue, setInternalValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
27
27
|
const handleChange = useCallback((v) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, [props, value]);
|
|
28
|
+
value === undefined && setInternalValue(v);
|
|
29
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(v);
|
|
30
|
+
}, [onChange, value]);
|
|
32
31
|
const handleClear = useCallback((event) => {
|
|
33
32
|
var _a, _b;
|
|
34
33
|
onClear === null || onClear === void 0 ? void 0 : onClear(event);
|
|
35
34
|
handleChange("");
|
|
36
|
-
if (searchRef.current && value === undefined) {
|
|
37
|
-
searchRef.current.value = "";
|
|
38
|
-
}
|
|
39
35
|
searchRef.current && ((_b = (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
40
|
-
}, [handleChange, onClear
|
|
36
|
+
}, [handleChange, onClear]);
|
|
41
37
|
useEventListener("keydown", useCallback((e) => {
|
|
42
38
|
if (e.key === "Escape") {
|
|
43
39
|
e.preventDefault();
|
|
44
40
|
handleClear({ trigger: "Escape", event: e });
|
|
45
41
|
}
|
|
46
42
|
}, [handleClear]), wrapperRef);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
value !== undefined && setControlledValue(value);
|
|
49
|
-
}, [value]);
|
|
50
43
|
return (React.createElement("div", { ref: setWrapperRef, className: cl(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
51
44
|
"navds-search--disabled": !!inputProps.disabled,
|
|
52
45
|
}) },
|
|
@@ -58,16 +51,17 @@ const Search = forwardRef((props, ref) => {
|
|
|
58
51
|
}), id: inputDescriptionId, size: size }, description)),
|
|
59
52
|
React.createElement("div", { className: "navds-search__wrapper" },
|
|
60
53
|
React.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
variant === "simple" && (React.createElement(SearchIcon, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
55
|
+
React.createElement("input", Object.assign({ ref: mergedRef }, omit(rest, ["size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: cl(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
56
|
+
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (React.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
63
57
|
React.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
64
58
|
React.createElement(Close, { "aria-hidden": true })))),
|
|
65
59
|
React.createElement(SearchContext.Provider, { value: {
|
|
66
60
|
size,
|
|
67
61
|
disabled: inputProps.disabled,
|
|
68
62
|
variant,
|
|
69
|
-
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(
|
|
70
|
-
} }, children ? children : React.createElement(SearchButton, null)))));
|
|
63
|
+
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(value !== null && value !== void 0 ? value : internalValue),
|
|
64
|
+
} }, children ? children : variant !== "simple" && React.createElement(SearchButton, null)))));
|
|
71
65
|
});
|
|
72
66
|
Search.Button = SearchButton;
|
|
73
67
|
export default Search;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../../../src/form/search/Search.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../../../src/form/search/Search.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EACZ,UAAU,EAEV,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,YAAkC,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkExC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,IAAI,CACL,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACtE,MAAM,EAAE,UAAU,EAAE,IAAI,GAAG,QAAQ,EAAE,kBAAkB,EAAE,GAAG,SAAS,CACnE,KAAK,EACL,aAAa,CACd,CAAC;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Element(Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant, className: cl("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
26
|
+
return (React.createElement(Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: cl("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
27
27
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch();
|
|
28
28
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
29
29
|
} }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchButton.js","sourceRoot":"","sources":["../../../src/form/search/SearchButton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,MAAM,EAAe,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAczC,MAAM,YAAY,GAAqB,UAAU,CAC/C,CAAC,EAAmD,EAAE,GAAG,EAAE,EAAE;;QAA5D,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,OAAW,EAAN,IAAI,cAAjD,gDAAmD,CAAF;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE1C,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;I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,mCAAI,QAAQ,EACvC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAC;YACb,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,CAAC;QACf,CAAC;QAED,oBAAC,MAAM,0BAAe;QACrB,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,8BAAM,SAAS,EAAC,eAAe,eAAW,CAC1D,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,6BAA6B;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AAEvB,6BAA6B;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
|
|
@@ -22,7 +22,7 @@ const ReadMore = forwardRef((_a, ref) => {
|
|
|
22
22
|
: UnmountClosed;
|
|
23
23
|
const isOpened = open !== null && open !== void 0 ? open : internalOpen;
|
|
24
24
|
return (React.createElement(React.Fragment, null,
|
|
25
|
-
React.createElement("button", Object.assign({}, rest, { className: cl("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
|
|
25
|
+
React.createElement("button", Object.assign({ type: "button" }, rest, { className: cl("navds-read-more", "navds-body-short", "navds-body-short--small", className, {
|
|
26
26
|
"navds-read-more--open": isOpened,
|
|
27
27
|
}), onClick: (e) => {
|
|
28
28
|
if (open === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadMore.js","sourceRoot":"","sources":["../../src/read-more/ReadMore.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AA6BzC,MAAM,QAAQ,GAAG,UAAU,CACzB,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,SAAS,EACT,MAAM,EACN,uBAAuB,GAAG,KAAK,EAC/B,QAAQ,EACR,IAAI,EACJ,WAAW,GAAG,KAAK,EACnB,OAAO,OAER,EADI,IAAI,cART,gGASC,CADQ;IAIT,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,WAAW,CAAC,CAAC;IACvE,MAAM,iBAAiB,GAAG,uBAAuB;QAC/C,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC;IAElB,MAAM,QAAQ,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,YAAY,CAAC;IAEtC,OAAO,CACL;QACE,
|
|
1
|
+
{"version":3,"file":"ReadMore.js","sourceRoot":"","sources":["../../src/read-more/ReadMore.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AA6BzC,MAAM,QAAQ,GAAG,UAAU,CACzB,CAC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react";
|
|
2
|
+
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/**
|
|
4
|
+
* Element tooltip anchors to
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactElement & React.RefAttributes<HTMLElement>;
|
|
7
|
+
/**
|
|
8
|
+
* Open state for contolled tooltip
|
|
9
|
+
*/
|
|
10
|
+
open?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Tells tooltip to start in open state
|
|
13
|
+
* @note "open"-prop overwrites this
|
|
14
|
+
*/
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Orientation for tooltip
|
|
18
|
+
* @default "top"
|
|
19
|
+
*/
|
|
20
|
+
placement?: "top" | "right" | "bottom" | "left";
|
|
21
|
+
/**
|
|
22
|
+
* Toggles rendering of arrow
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
arrow?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Distance from anchor to tooltip
|
|
28
|
+
* @default 10px with arrow, 2px without arrow
|
|
29
|
+
*/
|
|
30
|
+
offset?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Content shown in tooltip
|
|
33
|
+
*/
|
|
34
|
+
content: string;
|
|
35
|
+
/**
|
|
36
|
+
* Sets max allowed character length
|
|
37
|
+
* @default 80
|
|
38
|
+
*/
|
|
39
|
+
maxChar?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Adds a delay in milliseconds before opening tooltip
|
|
42
|
+
* @default 300
|
|
43
|
+
*/
|
|
44
|
+
delay?: number;
|
|
45
|
+
/**
|
|
46
|
+
* List of Keyboard-keys for shortcuts
|
|
47
|
+
*/
|
|
48
|
+
keys?: string[];
|
|
49
|
+
}
|
|
50
|
+
declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
51
|
+
export default Tooltip;
|