@entur/tooltip 2.5.21 → 2.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styles.css +19 -19
- package/dist/tooltip.cjs.development.js +55 -95
- package/dist/tooltip.cjs.development.js.map +1 -1
- package/dist/tooltip.cjs.production.min.js.map +1 -1
- package/dist/tooltip.esm.js +55 -95
- package/dist/tooltip.esm.js.map +1 -1
- package/package.json +16 -11
- package/CHANGELOG.md +0 -436
package/dist/tooltip.esm.js
CHANGED
|
@@ -10,77 +10,68 @@ function _extends() {
|
|
|
10
10
|
_extends = Object.assign || function (target) {
|
|
11
11
|
for (var i = 1; i < arguments.length; i++) {
|
|
12
12
|
var source = arguments[i];
|
|
13
|
-
|
|
14
13
|
for (var key in source) {
|
|
15
14
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
16
15
|
target[key] = source[key];
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
return target;
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
return _extends.apply(this, arguments);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
28
24
|
if (source == null) return {};
|
|
29
25
|
var target = {};
|
|
30
26
|
var sourceKeys = Object.keys(source);
|
|
31
27
|
var key, i;
|
|
32
|
-
|
|
33
28
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
34
29
|
key = sourceKeys[i];
|
|
35
30
|
if (excluded.indexOf(key) >= 0) continue;
|
|
36
31
|
target[key] = source[key];
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
return target;
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
var _excluded$1 = ["placement", "content", "children", "className", "isOpen", "disableHoverListener", "disableFocusListener", "showCloseButton", "variant", "popperModifiers"];
|
|
43
37
|
var Tooltip = function Tooltip(_ref) {
|
|
44
38
|
var placement = _ref.placement,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
39
|
+
content = _ref.content,
|
|
40
|
+
children = _ref.children,
|
|
41
|
+
className = _ref.className,
|
|
42
|
+
_ref$isOpen = _ref.isOpen,
|
|
43
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
44
|
+
_ref$disableHoverList = _ref.disableHoverListener,
|
|
45
|
+
disableHoverListener = _ref$disableHoverList === void 0 ? false : _ref$disableHoverList,
|
|
46
|
+
_ref$disableFocusList = _ref.disableFocusListener,
|
|
47
|
+
disableFocusListener = _ref$disableFocusList === void 0 ? false : _ref$disableFocusList,
|
|
48
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
|
49
|
+
showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
|
|
50
|
+
variant = _ref.variant,
|
|
51
|
+
_ref$popperModifiers = _ref.popperModifiers,
|
|
52
|
+
popperModifiers = _ref$popperModifiers === void 0 ? [{
|
|
53
|
+
name: 'offset',
|
|
54
|
+
options: {
|
|
55
|
+
offset: [0, 10]
|
|
56
|
+
}
|
|
57
|
+
}] : _ref$popperModifiers,
|
|
58
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
66
59
|
var _useState = useState(isOpen || false),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
showTooltip = _useState[0],
|
|
61
|
+
setShowTooltip = _useState[1];
|
|
70
62
|
var hoverTimer;
|
|
71
|
-
|
|
72
63
|
var handleOpen = function handleOpen(event) {
|
|
73
64
|
event.persist();
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Typescript interprets this differently depending on whether it's run in Jest or not
|
|
66
|
+
// @ts-ignore -- for some reason, the type checker thinks that this setTimeout is run in node; it is not, because it is run in the browser
|
|
74
67
|
hoverTimer = setTimeout(function () {
|
|
75
68
|
setShowTooltip(true);
|
|
76
69
|
}, 150);
|
|
77
70
|
};
|
|
78
|
-
|
|
79
71
|
var onMouseExit = function onMouseExit() {
|
|
80
72
|
setShowTooltip(false);
|
|
81
73
|
clearTimeout(hoverTimer);
|
|
82
74
|
};
|
|
83
|
-
|
|
84
75
|
React.useEffect(function () {
|
|
85
76
|
return function () {
|
|
86
77
|
clearTimeout(hoverTimer);
|
|
@@ -96,40 +87,32 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
96
87
|
}
|
|
97
88
|
}, [content]);
|
|
98
89
|
var popperPlacement = placement;
|
|
99
|
-
|
|
100
90
|
if (placement.includes('-')) {
|
|
101
91
|
if (placement.includes('right')) {
|
|
102
92
|
popperPlacement = placement.replace('right', 'end');
|
|
103
93
|
}
|
|
104
|
-
|
|
105
94
|
if (placement.includes('left')) {
|
|
106
95
|
popperPlacement = placement.replace('left', 'start');
|
|
107
96
|
}
|
|
108
97
|
}
|
|
109
|
-
|
|
110
98
|
var childProps = {};
|
|
111
99
|
childProps['aria-describedby'] = tooltipId;
|
|
112
|
-
|
|
113
100
|
if (!disableFocusListener) {
|
|
114
101
|
childProps.onFocus = function () {
|
|
115
102
|
return setShowTooltip(true);
|
|
116
103
|
};
|
|
117
|
-
|
|
118
104
|
childProps.onBlur = function () {
|
|
119
105
|
return setShowTooltip(false);
|
|
120
106
|
};
|
|
121
107
|
}
|
|
122
|
-
|
|
123
108
|
if (!disableHoverListener) {
|
|
124
109
|
childProps.onMouseEnter = function (e) {
|
|
125
110
|
return handleOpen(e);
|
|
126
111
|
};
|
|
127
|
-
|
|
128
112
|
childProps.onMouseLeave = function () {
|
|
129
113
|
return onMouseExit();
|
|
130
114
|
};
|
|
131
115
|
}
|
|
132
|
-
|
|
133
116
|
return React.createElement(Manager, null, React.createElement(Reference, null, function (_ref2) {
|
|
134
117
|
var ref = _ref2.ref;
|
|
135
118
|
return cloneElement(children, _extends({
|
|
@@ -143,8 +126,8 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
143
126
|
placement: popperPlacement
|
|
144
127
|
}, function (_ref3) {
|
|
145
128
|
var ref = _ref3.ref,
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
style = _ref3.style,
|
|
130
|
+
popperPlacement = _ref3.placement;
|
|
148
131
|
return React.createElement("div", _extends({
|
|
149
132
|
className: classNames('eds-tooltip', className, "eds-tooltip--" + popperPlacement, {
|
|
150
133
|
'eds-tooltip--error': variant === 'error'
|
|
@@ -165,45 +148,37 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
165
148
|
|
|
166
149
|
var _excluded = ["children"];
|
|
167
150
|
var PopoverContext = /*#__PURE__*/createContext(undefined);
|
|
168
|
-
|
|
169
151
|
var usePopoverContext = function usePopoverContext() {
|
|
170
152
|
var context = useContext(PopoverContext);
|
|
171
|
-
|
|
172
153
|
if (context == null) {
|
|
173
154
|
throw Error('usePopoverContext must be used within <Popover/>');
|
|
174
155
|
}
|
|
175
|
-
|
|
176
156
|
return context;
|
|
177
157
|
};
|
|
178
|
-
|
|
179
158
|
var Popover = function Popover(_ref) {
|
|
180
159
|
var children = _ref.children,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
160
|
+
_ref$placement = _ref.placement,
|
|
161
|
+
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement;
|
|
184
162
|
var _React$useState = React.useState(false),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
163
|
+
showPopover = _React$useState[0],
|
|
164
|
+
setShowPopover = _React$useState[1];
|
|
188
165
|
var triggerElement = React.useRef(null);
|
|
189
166
|
var contentElement = React.useRef(null);
|
|
190
|
-
|
|
191
167
|
var _usePopper = usePopper(triggerElement.current, contentElement.current, {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
168
|
+
modifiers: [{
|
|
169
|
+
name: 'arrow',
|
|
170
|
+
enabled: false
|
|
171
|
+
}, {
|
|
172
|
+
name: 'offset',
|
|
173
|
+
options: {
|
|
174
|
+
offset: [0, 8]
|
|
175
|
+
}
|
|
176
|
+
}],
|
|
177
|
+
placement: placement
|
|
178
|
+
}),
|
|
179
|
+
styles = _usePopper.styles,
|
|
180
|
+
attributes = _usePopper.attributes,
|
|
181
|
+
forceUpdate = _usePopper.forceUpdate;
|
|
207
182
|
React.useEffect(function () {
|
|
208
183
|
if (forceUpdate) {
|
|
209
184
|
forceUpdate();
|
|
@@ -243,8 +218,8 @@ var Popover = function Popover(_ref) {
|
|
|
243
218
|
}
|
|
244
219
|
},
|
|
245
220
|
onBlur: function onBlur(event) {
|
|
246
|
-
var elementReceivingFocus = event.relatedTarget;
|
|
247
|
-
|
|
221
|
+
var elementReceivingFocus = event.relatedTarget;
|
|
222
|
+
// The check for 'tabindex=-1' is a special case for focus handling in Docz
|
|
248
223
|
if (!elementReceivingFocus || elementReceivingFocus.getAttribute('tabindex') === '-1') return;
|
|
249
224
|
var focusElementIsPopover = elementContainsElement(contentElement.current, elementReceivingFocus);
|
|
250
225
|
var focusElementIsTrigger = elementContainsElement(triggerElement.current, elementReceivingFocus);
|
|
@@ -270,31 +245,25 @@ var Popover = function Popover(_ref) {
|
|
|
270
245
|
};
|
|
271
246
|
var PopoverTrigger = function PopoverTrigger(_ref2) {
|
|
272
247
|
var children = _ref2.children;
|
|
273
|
-
|
|
274
248
|
var _usePopoverContext = usePopoverContext(),
|
|
275
|
-
|
|
276
|
-
|
|
249
|
+
triggerProps = _usePopoverContext.triggerProps;
|
|
277
250
|
var child = React.Children.only(children);
|
|
278
251
|
return cloneElement(child, triggerProps());
|
|
279
252
|
};
|
|
280
253
|
var PopoverCloseButton = function PopoverCloseButton(_ref3) {
|
|
281
254
|
var children = _ref3.children,
|
|
282
|
-
|
|
283
|
-
|
|
255
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
284
256
|
var _usePopoverContext2 = usePopoverContext(),
|
|
285
|
-
|
|
286
|
-
|
|
257
|
+
closeButtonProps = _usePopoverContext2.closeButtonProps;
|
|
287
258
|
return cloneElement(children, _extends({}, closeButtonProps, rest));
|
|
288
259
|
};
|
|
289
260
|
var PopoverContent = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
290
261
|
var children = _ref4.children;
|
|
291
|
-
|
|
292
262
|
var _usePopoverContext3 = usePopoverContext(),
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
263
|
+
showPopover = _usePopoverContext3.showPopover,
|
|
264
|
+
attributes = _usePopoverContext3.attributes,
|
|
265
|
+
styles = _usePopoverContext3.styles,
|
|
266
|
+
popoverContentProps = _usePopoverContext3.popoverContentProps;
|
|
298
267
|
var props = popoverContentProps({
|
|
299
268
|
ref: ref
|
|
300
269
|
});
|
|
@@ -306,46 +275,37 @@ var PopoverContent = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
306
275
|
"aria-hidden": !showPopover
|
|
307
276
|
}, attributes.styles, props), children);
|
|
308
277
|
});
|
|
309
|
-
|
|
310
278
|
function elementContainsEventTarget(element, event) {
|
|
311
279
|
if (!element) {
|
|
312
280
|
return false;
|
|
313
281
|
}
|
|
314
|
-
|
|
315
282
|
if (element.contains(event.target)) {
|
|
316
283
|
return true;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
284
|
+
}
|
|
285
|
+
// For elements inside a Shadow DOM we need to check the composedPath
|
|
320
286
|
if (event.composed && event.composedPath) {
|
|
321
287
|
var contains = event.composedPath().find(function (target) {
|
|
322
288
|
if (target === window) {
|
|
323
289
|
return false;
|
|
324
290
|
}
|
|
325
|
-
|
|
326
291
|
return element.contains(target);
|
|
327
292
|
});
|
|
328
293
|
return contains ? true : false;
|
|
329
294
|
}
|
|
330
|
-
|
|
331
295
|
return false;
|
|
332
296
|
}
|
|
333
|
-
|
|
334
297
|
function elementContainsElement(parent, child) {
|
|
335
298
|
if (!parent) return false;
|
|
336
299
|
return parent === child || parent.contains(child);
|
|
337
300
|
}
|
|
338
|
-
|
|
339
301
|
function useOnClickOutside(ref, buttonRef, handler) {
|
|
340
302
|
React.useEffect(function () {
|
|
341
303
|
var listener = function listener(event) {
|
|
342
304
|
if (elementContainsEventTarget(ref.current, event) || elementContainsEventTarget(buttonRef.current, event)) {
|
|
343
305
|
return;
|
|
344
306
|
}
|
|
345
|
-
|
|
346
307
|
handler();
|
|
347
308
|
};
|
|
348
|
-
|
|
349
309
|
document.addEventListener('mousedown', listener);
|
|
350
310
|
document.addEventListener('touchstart', listener);
|
|
351
311
|
return function () {
|
package/dist/tooltip.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.esm.js","sources":["../src/Tooltip.tsx","../src/Popover.tsx","../src/index.tsx"],"sourcesContent":["import React, { cloneElement, useState } from 'react';\nimport { Manager, Reference, Popper } from 'react-popper';\nimport classNames from 'classnames';\nimport { useRandomId } from '@entur/utils';\nimport { Placement as PopperPlacementProps } from '@popperjs/core';\nimport { CloseIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './Tooltip.scss';\n\ntype Modifier = {\n name: string;\n enabled?: boolean;\n requires?: Array<string>;\n requiresIfExists?: Array<string>;\n options?: Record<string, unknown>;\n data?: Record<string, unknown>;\n [key: string]: any;\n};\n\nexport type TooltipProps = {\n /** Plassering av tooltip-en */\n placement:\n | 'top'\n | 'top-left'\n | 'top-right'\n | 'left'\n | 'right'\n | 'bottom-left' // bottom-start\n | 'bottom'\n | 'bottom-right'; // bottom-end\n /** Innholdet i tooltip-boksen */\n content: React.ReactNode;\n /** Elementet som skal ha tooltip-funksjonalitet */\n children: React.ReactElement;\n /** Om tooltipen skal vises */\n isOpen?: boolean;\n /** Ekstra klassenavn for tooltip */\n className?: string;\n /** Åpner ikke tooltip ved hover-events\n * @default false\n */\n disableHoverListener?: boolean;\n /** Åpner ikke tooltip ved focus-events\n * @default false\n */\n disableFocusListener?: boolean;\n /** Viser en lukkeknapp om man kontrollerer åpningen av Tooltip vha `isOpen`\n * @default true\n */\n showCloseButton?: boolean;\n /** Valideringsvariant for Tooltip */\n variant?: 'error';\n /** En array av modifiers som sendes til Popper, rammeverket som brukes til plassering av Tooltip\n * @default [{ name: 'offset', options: { offset: [0, 10]} }]\n */\n popperModifiers?: Modifier[];\n [key: string]: any;\n};\n\nexport const Tooltip: React.FC<TooltipProps> = ({\n placement,\n content,\n children,\n className,\n isOpen = false,\n disableHoverListener = false,\n disableFocusListener = false,\n showCloseButton = true,\n variant,\n popperModifiers = [\n {\n name: 'offset',\n options: { offset: [0, 10] },\n },\n ],\n ...rest\n}) => {\n const [showTooltip, setShowTooltip] = useState(isOpen || false);\n let hoverTimer: NodeJS.Timeout;\n\n const handleOpen: (event: React.MouseEvent) => void = event => {\n event.persist();\n hoverTimer = setTimeout(() => {\n setShowTooltip(true);\n }, 150);\n };\n const onMouseExit: () => void = () => {\n setShowTooltip(false);\n clearTimeout(hoverTimer);\n };\n React.useEffect(() => {\n return () => {\n clearTimeout(hoverTimer);\n };\n });\n\n const tooltipId = useRandomId('eds-tooltip');\n React.useEffect(() => {\n setShowTooltip(isOpen);\n }, [isOpen]);\n\n React.useEffect(() => {\n if (!content) {\n setShowTooltip(false);\n }\n }, [content]);\n\n let popperPlacement = placement as PopperPlacementProps;\n if (placement.includes('-')) {\n if (placement.includes('right')) {\n popperPlacement = placement.replace(\n 'right',\n 'end',\n ) as PopperPlacementProps;\n }\n if (placement.includes('left')) {\n popperPlacement = placement.replace(\n 'left',\n 'start',\n ) as PopperPlacementProps;\n }\n }\n\n const childProps: {\n 'aria-describedby'?: string;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: () => void;\n } = {};\n childProps['aria-describedby'] = tooltipId;\n if (!disableFocusListener) {\n childProps.onFocus = () => setShowTooltip(true);\n childProps.onBlur = () => setShowTooltip(false);\n }\n if (!disableHoverListener) {\n childProps.onMouseEnter = e => handleOpen(e);\n childProps.onMouseLeave = () => onMouseExit();\n }\n\n return (\n <Manager>\n <Reference>\n {({ ref }) =>\n cloneElement(children, {\n ref: ref,\n ...childProps,\n })\n }\n </Reference>\n {showTooltip && (\n <Popper\n modifiers={[{ name: 'arrow', enabled: false }, ...popperModifiers]}\n placement={popperPlacement}\n >\n {({ ref, style, placement: popperPlacement }) => (\n <div\n className={classNames(\n 'eds-tooltip',\n className,\n `eds-tooltip--${popperPlacement}`,\n { 'eds-tooltip--error': variant === 'error' },\n )}\n ref={ref}\n style={style}\n role=\"tooltip\"\n id={tooltipId}\n data-placement={popperPlacement}\n {...rest}\n >\n {content}\n {isOpen && showCloseButton && (\n <IconButton\n className=\"eds-tooltip__close-button\"\n onClick={() => setShowTooltip(false)}\n >\n <CloseIcon />\n </IconButton>\n )}\n </div>\n )}\n </Popper>\n )}\n </Manager>\n );\n};\n","import React, { cloneElement, createContext, useContext } from 'react';\nimport { usePopper } from 'react-popper';\nimport { Placement } from '@popperjs/core';\nimport classNames from 'classnames';\nimport { Contrast } from '@entur/layout';\nimport './Popover.scss';\n\ntype PopoverContentCallbackProps = {\n ref: React.Ref<HTMLDivElement>;\n};\n\ntype PopoverContextProps = {\n showPopover: boolean;\n triggerElement?: React.RefObject<HTMLButtonElement>;\n contentElement: React.RefObject<HTMLDivElement>;\n styles: { [key: string]: React.CSSProperties };\n attributes: { [key: string]: { [key: string]: string } | undefined };\n closeButtonProps: Record<string, unknown>;\n popoverContentProps: (\n e: PopoverContentCallbackProps,\n ) => Record<string, unknown>;\n triggerProps: () => Record<string, unknown>;\n [key: string]: any;\n};\n\nconst PopoverContext = createContext<PopoverContextProps | undefined>(\n undefined,\n);\nconst usePopoverContext = () => {\n const context = useContext(PopoverContext);\n if (context == null) {\n throw Error('usePopoverContext must be used within <Popover/>');\n }\n return context;\n};\n\nexport type PopoverProps = {\n /** Innholdet i Popover */\n children: React.ReactNode;\n /** Plasseringen av Popover\n * @default \"bottom-start\"\n */\n placement?: Placement;\n};\n\nexport const Popover: React.FC<PopoverProps> = ({\n children,\n placement = 'bottom-start',\n}) => {\n const [showPopover, setShowPopover] = React.useState(false);\n const triggerElement = React.useRef(null);\n const contentElement = React.useRef(null);\n\n const { styles, attributes, forceUpdate } = usePopper(\n triggerElement.current,\n contentElement.current,\n {\n modifiers: [\n { name: 'arrow', enabled: false },\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n ],\n placement: placement,\n },\n );\n\n React.useEffect(() => {\n if (forceUpdate) {\n forceUpdate();\n }\n }, [showPopover, forceUpdate]);\n\n const triggerProps = React.useCallback(() => {\n const buttonProps = {\n onClick: (e: React.MouseEvent) => {\n e.preventDefault();\n setShowPopover(prev => !prev);\n },\n 'aria-haspopup': 'dialog',\n 'aria-expanded': showPopover,\n ref: triggerElement,\n };\n return buttonProps;\n }, [triggerElement, showPopover]);\n\n useOnClickOutside(contentElement, triggerElement, () =>\n setShowPopover(false),\n );\n const closeButtonProps = {\n onClick: (e: React.MouseEvent) => {\n e.preventDefault();\n setShowPopover(false);\n },\n };\n const popoverContentProps = React.useCallback(() => {\n const contentProps = {\n role: 'dialog',\n 'aria-modal': 'false',\n ref: contentElement,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n showPopover && setShowPopover(false);\n }\n },\n onBlur: (event: React.FocusEvent) => {\n const elementReceivingFocus = event.relatedTarget as HTMLElement;\n // The check for 'tabindex=-1' is a special case for focus handling in Docz\n if (\n !elementReceivingFocus ||\n elementReceivingFocus.getAttribute('tabindex') === '-1'\n )\n return;\n const focusElementIsPopover = elementContainsElement(\n contentElement.current,\n elementReceivingFocus,\n );\n const focusElementIsTrigger = elementContainsElement(\n triggerElement.current,\n elementReceivingFocus,\n );\n const isValidBlur = !focusElementIsPopover && !focusElementIsTrigger;\n if (showPopover && isValidBlur) setShowPopover(false);\n },\n };\n return contentProps;\n }, [contentElement, showPopover]);\n const contextValue: PopoverContextProps = {\n showPopover,\n triggerElement,\n contentElement,\n styles,\n attributes,\n popoverContentProps,\n closeButtonProps,\n triggerProps,\n };\n return (\n <PopoverContext.Provider value={contextValue}>\n {children}\n </PopoverContext.Provider>\n );\n};\n\nexport type PopoverTriggerProps = {\n /** Knapp som skal brukes for å åpne Popover */\n children: React.ReactElement;\n};\n\nexport const PopoverTrigger: React.FC<PopoverTriggerProps> = ({ children }) => {\n const { triggerProps } = usePopoverContext();\n const child = React.Children.only(children) as React.ReactElement<any>;\n return cloneElement(child, triggerProps());\n};\n\nexport type PopoverCloseButtonProps = {\n /** En valgfri knapp som kan legges inn for å lukke Popover */\n children: React.ReactElement;\n};\n\nexport const PopoverCloseButton: React.FC<PopoverCloseButtonProps> = ({\n children,\n ...rest\n}) => {\n const { closeButtonProps } = usePopoverContext();\n return cloneElement(children, { ...closeButtonProps, ...rest });\n};\n\nexport type PopoverContentProps = {\n /**Innholdet til Popover */\n children: React.ReactNode;\n};\n\nexport const PopoverContent = React.forwardRef<\n HTMLDivElement,\n PopoverContentProps\n>(({ children }, ref: React.Ref<HTMLDivElement>) => {\n const { showPopover, attributes, styles, popoverContentProps } =\n usePopoverContext();\n const props = popoverContentProps({ ref });\n return (\n <Contrast\n className={classNames(\n 'eds-popover',\n {\n 'eds-popover--hidden': !showPopover,\n },\n 'eds-contrast',\n )}\n style={styles.popper}\n aria-hidden={!showPopover}\n {...attributes.styles}\n {...props}\n >\n {children}\n </Contrast>\n );\n});\n\nfunction elementContainsEventTarget(element: HTMLElement | null, event: Event) {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n}\n\nfunction elementContainsElement(\n parent: HTMLElement | null,\n child: HTMLElement,\n) {\n if (!parent) return false;\n return parent === child || parent.contains(child);\n}\n\nfunction useOnClickOutside(\n ref: React.RefObject<HTMLDivElement>,\n buttonRef: React.RefObject<HTMLButtonElement>,\n handler: () => void,\n) {\n React.useEffect(() => {\n const listener = (event: Event) => {\n if (\n elementContainsEventTarget(ref.current, event) ||\n elementContainsEventTarget(buttonRef.current, event)\n ) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, buttonRef, handler]);\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('tooltip');\n\nexport * from './Tooltip';\nexport * from './Popover';\n"],"names":["Tooltip","placement","content","children","className","isOpen","disableHoverListener","disableFocusListener","showCloseButton","variant","popperModifiers","name","options","offset","rest","useState","showTooltip","setShowTooltip","hoverTimer","handleOpen","event","persist","setTimeout","onMouseExit","clearTimeout","React","useEffect","tooltipId","useRandomId","popperPlacement","includes","replace","childProps","onFocus","onBlur","onMouseEnter","e","onMouseLeave","Manager","Reference","ref","cloneElement","Popper","modifiers","enabled","style","classNames","role","id","IconButton","onClick","CloseIcon","PopoverContext","createContext","undefined","usePopoverContext","context","useContext","Error","Popover","showPopover","setShowPopover","triggerElement","useRef","contentElement","usePopper","current","styles","attributes","forceUpdate","triggerProps","useCallback","buttonProps","preventDefault","prev","useOnClickOutside","closeButtonProps","popoverContentProps","contentProps","onKeyDown","key","elementReceivingFocus","relatedTarget","getAttribute","focusElementIsPopover","elementContainsElement","focusElementIsTrigger","isValidBlur","contextValue","Provider","value","PopoverTrigger","child","Children","only","PopoverCloseButton","PopoverContent","forwardRef","props","Contrast","popper","elementContainsEventTarget","element","contains","target","composed","composedPath","find","window","parent","buttonRef","handler","listener","document","addEventListener","removeEventListener","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2DaA,OAAO,GAA2B,SAAlCA,OAAkC;MAC7CC,iBAAAA;MACAC,eAAAA;MACAC,gBAAAA;MACAC,iBAAAA;yBACAC;MAAAA,kCAAS;mCACTC;MAAAA,0DAAuB;mCACvBC;MAAAA,0DAAuB;kCACvBC;MAAAA,oDAAkB;MAClBC,eAAAA;kCACAC;MAAAA,oDAAkB,CAChB;AACEC,IAAAA,IAAI,EAAE,QADR;AAEEC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,MAAM,EAAE,CAAC,CAAD,EAAI,EAAJ;AAAV;AAFX,GADgB;MAMfC;;AAEH,kBAAsCC,QAAQ,CAACV,MAAM,IAAI,KAAX,CAA9C;AAAA,MAAOW,WAAP;AAAA,MAAoBC,cAApB;;AACA,MAAIC,UAAJ;;AAEA,MAAMC,UAAU,GAAsC,SAAhDA,UAAgD,CAAAC,KAAK;AACzDA,IAAAA,KAAK,CAACC,OAAN;AACAH,IAAAA,UAAU,GAAGI,UAAU,CAAC;AACtBL,MAAAA,cAAc,CAAC,IAAD,CAAd;AACD,KAFsB,EAEpB,GAFoB,CAAvB;AAGD,GALD;;AAMA,MAAMM,WAAW,GAAe,SAA1BA,WAA0B;AAC9BN,IAAAA,cAAc,CAAC,KAAD,CAAd;AACAO,IAAAA,YAAY,CAACN,UAAD,CAAZ;AACD,GAHD;;AAIAO,EAAAA,KAAK,CAACC,SAAN,CAAgB;AACd,WAAO;AACLF,MAAAA,YAAY,CAACN,UAAD,CAAZ;AACD,KAFD;AAGD,GAJD;AAMA,MAAMS,SAAS,GAAGC,WAAW,CAAC,aAAD,CAA7B;AACAH,EAAAA,KAAK,CAACC,SAAN,CAAgB;AACdT,IAAAA,cAAc,CAACZ,MAAD,CAA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AAK,CAACC,SAAN,CAAgB;AACd,QAAMsF,QAAQ,GAAG,SAAXA,QAAW,CAAC5F,KAAD;AACf,UACEiF,0BAA0B,CAAC7D,GAAG,CAAC0B,OAAL,EAAc9C,KAAd,CAA1B,IACAiF,0BAA0B,CAACS,SAAS,CAAC5C,OAAX,EAAoB9C,KAApB,CAF5B,EAGE;AACA;AACD;;AAED2F,MAAAA,OAAO;AACR,KATD;;AAWAE,IAAAA,QAAQ,CAACC,gBAAT,CAA0B,WAA1B,EAAuCF,QAAvC;AACAC,IAAAA,QAAQ,CAACC,gBAAT,CAA0B,YAA1B,EAAwCF,QAAxC;AAEA,WAAO;AACLC,MAAAA,QAAQ,CAACE,mBAAT,CAA6B,WAA7B,EAA0CH,QAA1C;AACAC,MAAAA,QAAQ,CAACE,mBAAT,CAA6B,YAA7B,EAA2CH,QAA3C;AACD,KAHD;AAID,GAnBD,EAmBG,CAACxE,GAAD,EAAMsE,SAAN,EAAiBC,OAAjB,CAnBH;AAoBD;;AC/PDK,sBAAsB,CAAC,SAAD,CAAtB;;;;"}
|
|
1
|
+
{"version":3,"file":"tooltip.esm.js","sources":["../src/Tooltip.tsx","../src/Popover.tsx","../src/index.tsx"],"sourcesContent":["import React, { cloneElement, useState } from 'react';\nimport { Manager, Reference, Popper } from 'react-popper';\nimport classNames from 'classnames';\nimport { useRandomId } from '@entur/utils';\nimport { Placement as PopperPlacementProps } from '@popperjs/core';\nimport { CloseIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './Tooltip.scss';\n\ntype Modifier = {\n name: string;\n enabled?: boolean;\n requires?: Array<string>;\n requiresIfExists?: Array<string>;\n options?: Record<string, unknown>;\n data?: Record<string, unknown>;\n [key: string]: any;\n};\n\nexport type TooltipProps = {\n /** Plassering av tooltip-en */\n placement:\n | 'top'\n | 'top-left'\n | 'top-right'\n | 'left'\n | 'right'\n | 'bottom-left' // bottom-start\n | 'bottom'\n | 'bottom-right'; // bottom-end\n /** Innholdet i tooltip-boksen */\n content: React.ReactNode;\n /** Elementet som skal ha tooltip-funksjonalitet */\n children: React.ReactElement;\n /** Om tooltipen skal vises */\n isOpen?: boolean;\n /** Ekstra klassenavn for tooltip */\n className?: string;\n /** Åpner ikke tooltip ved hover-events\n * @default false\n */\n disableHoverListener?: boolean;\n /** Åpner ikke tooltip ved focus-events\n * @default false\n */\n disableFocusListener?: boolean;\n /** Viser en lukkeknapp om man kontrollerer åpningen av Tooltip vha `isOpen`\n * @default true\n */\n showCloseButton?: boolean;\n /** Valideringsvariant for Tooltip */\n variant?: 'error';\n /** En array av modifiers som sendes til Popper, rammeverket som brukes til plassering av Tooltip\n * @default [{ name: 'offset', options: { offset: [0, 10]} }]\n */\n popperModifiers?: Modifier[];\n [key: string]: any;\n};\n\nexport const Tooltip: React.FC<TooltipProps> = ({\n placement,\n content,\n children,\n className,\n isOpen = false,\n disableHoverListener = false,\n disableFocusListener = false,\n showCloseButton = true,\n variant,\n popperModifiers = [\n {\n name: 'offset',\n options: { offset: [0, 10] },\n },\n ],\n ...rest\n}) => {\n const [showTooltip, setShowTooltip] = useState(isOpen || false);\n let hoverTimer: number;\n\n const handleOpen: (event: React.MouseEvent) => void = event => {\n event.persist();\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Typescript interprets this differently depending on whether it's run in Jest or not\n // @ts-ignore -- for some reason, the type checker thinks that this setTimeout is run in node; it is not, because it is run in the browser\n hoverTimer = setTimeout(() => {\n setShowTooltip(true);\n }, 150);\n };\n const onMouseExit: () => void = () => {\n setShowTooltip(false);\n clearTimeout(hoverTimer);\n };\n React.useEffect(() => {\n return () => {\n clearTimeout(hoverTimer);\n };\n });\n\n const tooltipId = useRandomId('eds-tooltip');\n React.useEffect(() => {\n setShowTooltip(isOpen);\n }, [isOpen]);\n\n React.useEffect(() => {\n if (!content) {\n setShowTooltip(false);\n }\n }, [content]);\n\n let popperPlacement = placement as PopperPlacementProps;\n if (placement.includes('-')) {\n if (placement.includes('right')) {\n popperPlacement = placement.replace(\n 'right',\n 'end',\n ) as PopperPlacementProps;\n }\n if (placement.includes('left')) {\n popperPlacement = placement.replace(\n 'left',\n 'start',\n ) as PopperPlacementProps;\n }\n }\n\n const childProps: {\n 'aria-describedby'?: string;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseLeave?: () => void;\n } = {};\n childProps['aria-describedby'] = tooltipId;\n if (!disableFocusListener) {\n childProps.onFocus = () => setShowTooltip(true);\n childProps.onBlur = () => setShowTooltip(false);\n }\n if (!disableHoverListener) {\n childProps.onMouseEnter = e => handleOpen(e);\n childProps.onMouseLeave = () => onMouseExit();\n }\n\n return (\n <Manager>\n <Reference>\n {({ ref }) =>\n cloneElement(children, {\n ref: ref,\n ...childProps,\n })\n }\n </Reference>\n {showTooltip && (\n <Popper\n modifiers={[{ name: 'arrow', enabled: false }, ...popperModifiers]}\n placement={popperPlacement}\n >\n {({ ref, style, placement: popperPlacement }) => (\n <div\n className={classNames(\n 'eds-tooltip',\n className,\n `eds-tooltip--${popperPlacement}`,\n { 'eds-tooltip--error': variant === 'error' },\n )}\n ref={ref}\n style={style}\n role=\"tooltip\"\n id={tooltipId}\n data-placement={popperPlacement}\n {...rest}\n >\n {content}\n {isOpen && showCloseButton && (\n <IconButton\n className=\"eds-tooltip__close-button\"\n onClick={() => setShowTooltip(false)}\n >\n <CloseIcon />\n </IconButton>\n )}\n </div>\n )}\n </Popper>\n )}\n </Manager>\n );\n};\n","import React, { cloneElement, createContext, useContext } from 'react';\nimport { usePopper } from 'react-popper';\nimport { Placement } from '@popperjs/core';\nimport classNames from 'classnames';\nimport { Contrast } from '@entur/layout';\nimport './Popover.scss';\n\ntype PopoverContentCallbackProps = {\n ref: React.Ref<HTMLDivElement>;\n};\n\ntype PopoverContextProps = {\n showPopover: boolean;\n triggerElement?: React.RefObject<HTMLButtonElement>;\n contentElement: React.RefObject<HTMLDivElement>;\n styles: { [key: string]: React.CSSProperties };\n attributes: { [key: string]: { [key: string]: string } | undefined };\n closeButtonProps: Record<string, unknown>;\n popoverContentProps: (\n e: PopoverContentCallbackProps,\n ) => Record<string, unknown>;\n triggerProps: () => Record<string, unknown>;\n [key: string]: any;\n};\n\nconst PopoverContext = createContext<PopoverContextProps | undefined>(\n undefined,\n);\nconst usePopoverContext = () => {\n const context = useContext(PopoverContext);\n if (context == null) {\n throw Error('usePopoverContext must be used within <Popover/>');\n }\n return context;\n};\n\nexport type PopoverProps = {\n /** Innholdet i Popover */\n children: React.ReactNode;\n /** Plasseringen av Popover\n * @default \"bottom-start\"\n */\n placement?: Placement;\n};\n\nexport const Popover: React.FC<PopoverProps> = ({\n children,\n placement = 'bottom-start',\n}) => {\n const [showPopover, setShowPopover] = React.useState(false);\n const triggerElement = React.useRef(null);\n const contentElement = React.useRef(null);\n\n const { styles, attributes, forceUpdate } = usePopper(\n triggerElement.current,\n contentElement.current,\n {\n modifiers: [\n { name: 'arrow', enabled: false },\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n ],\n placement: placement,\n },\n );\n\n React.useEffect(() => {\n if (forceUpdate) {\n forceUpdate();\n }\n }, [showPopover, forceUpdate]);\n\n const triggerProps = React.useCallback(() => {\n const buttonProps = {\n onClick: (e: React.MouseEvent) => {\n e.preventDefault();\n setShowPopover(prev => !prev);\n },\n 'aria-haspopup': 'dialog',\n 'aria-expanded': showPopover,\n ref: triggerElement,\n };\n return buttonProps;\n }, [triggerElement, showPopover]);\n\n useOnClickOutside(contentElement, triggerElement, () =>\n setShowPopover(false),\n );\n const closeButtonProps = {\n onClick: (e: React.MouseEvent) => {\n e.preventDefault();\n setShowPopover(false);\n },\n };\n const popoverContentProps = React.useCallback(() => {\n const contentProps = {\n role: 'dialog',\n 'aria-modal': 'false',\n ref: contentElement,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n showPopover && setShowPopover(false);\n }\n },\n onBlur: (event: React.FocusEvent) => {\n const elementReceivingFocus = event.relatedTarget as HTMLElement;\n // The check for 'tabindex=-1' is a special case for focus handling in Docz\n if (\n !elementReceivingFocus ||\n elementReceivingFocus.getAttribute('tabindex') === '-1'\n )\n return;\n const focusElementIsPopover = elementContainsElement(\n contentElement.current,\n elementReceivingFocus,\n );\n const focusElementIsTrigger = elementContainsElement(\n triggerElement.current,\n elementReceivingFocus,\n );\n const isValidBlur = !focusElementIsPopover && !focusElementIsTrigger;\n if (showPopover && isValidBlur) setShowPopover(false);\n },\n };\n return contentProps;\n }, [contentElement, showPopover]);\n const contextValue: PopoverContextProps = {\n showPopover,\n triggerElement,\n contentElement,\n styles,\n attributes,\n popoverContentProps,\n closeButtonProps,\n triggerProps,\n };\n return (\n <PopoverContext.Provider value={contextValue}>\n {children}\n </PopoverContext.Provider>\n );\n};\n\nexport type PopoverTriggerProps = {\n /** Knapp som skal brukes for å åpne Popover */\n children: React.ReactElement;\n};\n\nexport const PopoverTrigger: React.FC<PopoverTriggerProps> = ({ children }) => {\n const { triggerProps } = usePopoverContext();\n const child = React.Children.only(children) as React.ReactElement<any>;\n return cloneElement(child, triggerProps());\n};\n\nexport type PopoverCloseButtonProps = {\n /** En valgfri knapp som kan legges inn for å lukke Popover */\n children: React.ReactElement;\n};\n\nexport const PopoverCloseButton: React.FC<PopoverCloseButtonProps> = ({\n children,\n ...rest\n}) => {\n const { closeButtonProps } = usePopoverContext();\n return cloneElement(children, { ...closeButtonProps, ...rest });\n};\n\nexport type PopoverContentProps = {\n /**Innholdet til Popover */\n children: React.ReactNode;\n};\n\nexport const PopoverContent = React.forwardRef<\n HTMLDivElement,\n PopoverContentProps\n>(({ children }, ref: React.Ref<HTMLDivElement>) => {\n const { showPopover, attributes, styles, popoverContentProps } =\n usePopoverContext();\n const props = popoverContentProps({ ref });\n return (\n <Contrast\n className={classNames(\n 'eds-popover',\n {\n 'eds-popover--hidden': !showPopover,\n },\n 'eds-contrast',\n )}\n style={styles.popper}\n aria-hidden={!showPopover}\n {...attributes.styles}\n {...props}\n >\n {children}\n </Contrast>\n );\n});\n\nfunction elementContainsEventTarget(element: HTMLElement | null, event: Event) {\n if (!element) {\n return false;\n }\n\n if (element.contains(event.target as Node)) {\n return true;\n }\n\n // For elements inside a Shadow DOM we need to check the composedPath\n if (event.composed && event.composedPath) {\n const contains = event.composedPath().find(target => {\n if (target === window) {\n return false;\n }\n return element.contains(target as Node);\n });\n return contains ? true : false;\n }\n\n return false;\n}\n\nfunction elementContainsElement(\n parent: HTMLElement | null,\n child: HTMLElement,\n) {\n if (!parent) return false;\n return parent === child || parent.contains(child);\n}\n\nfunction useOnClickOutside(\n ref: React.RefObject<HTMLDivElement>,\n buttonRef: React.RefObject<HTMLButtonElement>,\n handler: () => void,\n) {\n React.useEffect(() => {\n const listener = (event: Event) => {\n if (\n elementContainsEventTarget(ref.current, event) ||\n elementContainsEventTarget(buttonRef.current, event)\n ) {\n return;\n }\n\n handler();\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, buttonRef, handler]);\n}\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('tooltip');\n\nexport * from './Tooltip';\nexport * from './Popover';\n"],"names":["Tooltip","placement","content","children","className","isOpen","disableHoverListener","disableFocusListener","showCloseButton","variant","popperModifiers","name","options","offset","rest","useState","showTooltip","setShowTooltip","hoverTimer","handleOpen","event","persist","setTimeout","onMouseExit","clearTimeout","React","useEffect","tooltipId","useRandomId","popperPlacement","includes","replace","childProps","onFocus","onBlur","onMouseEnter","e","onMouseLeave","Manager","Reference","ref","cloneElement","Popper","modifiers","enabled","style","classNames","role","id","IconButton","onClick","CloseIcon","PopoverContext","createContext","undefined","usePopoverContext","context","useContext","Error","Popover","showPopover","setShowPopover","triggerElement","useRef","contentElement","usePopper","current","styles","attributes","forceUpdate","triggerProps","useCallback","buttonProps","preventDefault","prev","useOnClickOutside","closeButtonProps","popoverContentProps","contentProps","onKeyDown","key","elementReceivingFocus","relatedTarget","getAttribute","focusElementIsPopover","elementContainsElement","focusElementIsTrigger","isValidBlur","contextValue","Provider","value","PopoverTrigger","child","Children","only","PopoverCloseButton","PopoverContent","forwardRef","props","Contrast","popper","elementContainsEventTarget","element","contains","target","composed","composedPath","find","window","parent","buttonRef","handler","listener","document","addEventListener","removeEventListener","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2DaA,OAAO,GAA2B,SAAlCA,OAAO;MAClBC,SAAS,QAATA,SAAS;IACTC,OAAO,QAAPA,OAAO;IACPC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;IAAA,mBACTC,MAAM;IAANA,MAAM,4BAAG,KAAK;IAAA,6BACdC,oBAAoB;IAApBA,oBAAoB,sCAAG,KAAK;IAAA,6BAC5BC,oBAAoB;IAApBA,oBAAoB,sCAAG,KAAK;IAAA,4BAC5BC,eAAe;IAAfA,eAAe,qCAAG,IAAI;IACtBC,OAAO,QAAPA,OAAO;IAAA,4BACPC,eAAe;IAAfA,eAAe,qCAAG,CAChB;MACEC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QAAEC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;;KAC1B,CACF;IACEC,IAAI;EAEP,gBAAsCC,QAAQ,CAACV,MAAM,IAAI,KAAK,CAAC;IAAxDW,WAAW;IAAEC,cAAc;EAClC,IAAIC,UAAkB;EAEtB,IAAMC,UAAU,GAAsC,SAAhDA,UAAU,CAAsCC,KAAK;IACzDA,KAAK,CAACC,OAAO,EAAE;;;IAGfH,UAAU,GAAGI,UAAU,CAAC;MACtBL,cAAc,CAAC,IAAI,CAAC;KACrB,EAAE,GAAG,CAAC;GACR;EACD,IAAMM,WAAW,GAAe,SAA1BA,WAAW;IACfN,cAAc,CAAC,KAAK,CAAC;IACrBO,YAAY,CAACN,UAAU,CAAC;GACzB;EACDO,KAAK,CAACC,SAAS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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/tooltip",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.23",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/tooltip.esm.js",
|
|
@@ -17,25 +17,30 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"start": "dts watch --noClean",
|
|
21
|
-
"build": "dts build",
|
|
22
|
-
"test": "dts test --env=jsdom",
|
|
23
|
-
"lint": "dts lint"
|
|
20
|
+
"start": "yarn run dts watch --noClean",
|
|
21
|
+
"build": "yarn run dts build",
|
|
22
|
+
"test": "yarn run dts test --env=jsdom",
|
|
23
|
+
"lint": "yarn run dts lint"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=16.8.0",
|
|
27
27
|
"react-dom": ">=16.8.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@entur/tokens": "^3.4.
|
|
30
|
+
"@entur/tokens": "^3.4.2",
|
|
31
|
+
"dts-cli": "^1.1.6",
|
|
32
|
+
"jest": "^27.0.0",
|
|
33
|
+
"jest-watch-typeahead": "^2.2.0",
|
|
34
|
+
"ts-jest": "^27.0.0",
|
|
35
|
+
"typescript": "^4.8.0"
|
|
31
36
|
},
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"@entur/button": "^2.10.
|
|
34
|
-
"@entur/icons": "^5.
|
|
35
|
-
"@entur/layout": "^2.1.
|
|
36
|
-
"@entur/utils": "^0.4.
|
|
38
|
+
"@entur/button": "^2.10.6",
|
|
39
|
+
"@entur/icons": "^5.3.0",
|
|
40
|
+
"@entur/layout": "^2.1.13",
|
|
41
|
+
"@entur/utils": "^0.4.7",
|
|
37
42
|
"@popperjs/core": "^2.10.1",
|
|
38
43
|
"react-popper": "^2.2.5"
|
|
39
44
|
},
|
|
40
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8915b1630bd936740ba9a4a88883f3432948a80e"
|
|
41
46
|
}
|