@entur/tooltip 2.5.23 → 2.5.24
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/tooltip.esm.js
CHANGED
|
@@ -10,68 +10,77 @@ 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
|
+
|
|
13
14
|
for (var key in source) {
|
|
14
15
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15
16
|
target[key] = source[key];
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
20
|
+
|
|
19
21
|
return target;
|
|
20
22
|
};
|
|
23
|
+
|
|
21
24
|
return _extends.apply(this, arguments);
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
24
28
|
if (source == null) return {};
|
|
25
29
|
var target = {};
|
|
26
30
|
var sourceKeys = Object.keys(source);
|
|
27
31
|
var key, i;
|
|
32
|
+
|
|
28
33
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
29
34
|
key = sourceKeys[i];
|
|
30
35
|
if (excluded.indexOf(key) >= 0) continue;
|
|
31
36
|
target[key] = source[key];
|
|
32
37
|
}
|
|
38
|
+
|
|
33
39
|
return target;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
var _excluded$1 = ["placement", "content", "children", "className", "isOpen", "disableHoverListener", "disableFocusListener", "showCloseButton", "variant", "popperModifiers"];
|
|
37
43
|
var Tooltip = function Tooltip(_ref) {
|
|
38
44
|
var placement = _ref.placement,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
content = _ref.content,
|
|
46
|
+
children = _ref.children,
|
|
47
|
+
className = _ref.className,
|
|
48
|
+
_ref$isOpen = _ref.isOpen,
|
|
49
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
50
|
+
_ref$disableHoverList = _ref.disableHoverListener,
|
|
51
|
+
disableHoverListener = _ref$disableHoverList === void 0 ? false : _ref$disableHoverList,
|
|
52
|
+
_ref$disableFocusList = _ref.disableFocusListener,
|
|
53
|
+
disableFocusListener = _ref$disableFocusList === void 0 ? false : _ref$disableFocusList,
|
|
54
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
|
55
|
+
showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
|
|
56
|
+
variant = _ref.variant,
|
|
57
|
+
_ref$popperModifiers = _ref.popperModifiers,
|
|
58
|
+
popperModifiers = _ref$popperModifiers === void 0 ? [{
|
|
59
|
+
name: 'offset',
|
|
60
|
+
options: {
|
|
61
|
+
offset: [0, 10]
|
|
62
|
+
}
|
|
63
|
+
}] : _ref$popperModifiers,
|
|
64
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
65
|
+
|
|
59
66
|
var _useState = useState(isOpen || false),
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
showTooltip = _useState[0],
|
|
68
|
+
setShowTooltip = _useState[1];
|
|
69
|
+
|
|
62
70
|
var hoverTimer;
|
|
71
|
+
|
|
63
72
|
var handleOpen = function handleOpen(event) {
|
|
64
73
|
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
|
|
67
74
|
hoverTimer = setTimeout(function () {
|
|
68
75
|
setShowTooltip(true);
|
|
69
76
|
}, 150);
|
|
70
77
|
};
|
|
78
|
+
|
|
71
79
|
var onMouseExit = function onMouseExit() {
|
|
72
80
|
setShowTooltip(false);
|
|
73
81
|
clearTimeout(hoverTimer);
|
|
74
82
|
};
|
|
83
|
+
|
|
75
84
|
React.useEffect(function () {
|
|
76
85
|
return function () {
|
|
77
86
|
clearTimeout(hoverTimer);
|
|
@@ -87,32 +96,40 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
87
96
|
}
|
|
88
97
|
}, [content]);
|
|
89
98
|
var popperPlacement = placement;
|
|
99
|
+
|
|
90
100
|
if (placement.includes('-')) {
|
|
91
101
|
if (placement.includes('right')) {
|
|
92
102
|
popperPlacement = placement.replace('right', 'end');
|
|
93
103
|
}
|
|
104
|
+
|
|
94
105
|
if (placement.includes('left')) {
|
|
95
106
|
popperPlacement = placement.replace('left', 'start');
|
|
96
107
|
}
|
|
97
108
|
}
|
|
109
|
+
|
|
98
110
|
var childProps = {};
|
|
99
111
|
childProps['aria-describedby'] = tooltipId;
|
|
112
|
+
|
|
100
113
|
if (!disableFocusListener) {
|
|
101
114
|
childProps.onFocus = function () {
|
|
102
115
|
return setShowTooltip(true);
|
|
103
116
|
};
|
|
117
|
+
|
|
104
118
|
childProps.onBlur = function () {
|
|
105
119
|
return setShowTooltip(false);
|
|
106
120
|
};
|
|
107
121
|
}
|
|
122
|
+
|
|
108
123
|
if (!disableHoverListener) {
|
|
109
124
|
childProps.onMouseEnter = function (e) {
|
|
110
125
|
return handleOpen(e);
|
|
111
126
|
};
|
|
127
|
+
|
|
112
128
|
childProps.onMouseLeave = function () {
|
|
113
129
|
return onMouseExit();
|
|
114
130
|
};
|
|
115
131
|
}
|
|
132
|
+
|
|
116
133
|
return React.createElement(Manager, null, React.createElement(Reference, null, function (_ref2) {
|
|
117
134
|
var ref = _ref2.ref;
|
|
118
135
|
return cloneElement(children, _extends({
|
|
@@ -126,8 +143,8 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
126
143
|
placement: popperPlacement
|
|
127
144
|
}, function (_ref3) {
|
|
128
145
|
var ref = _ref3.ref,
|
|
129
|
-
|
|
130
|
-
|
|
146
|
+
style = _ref3.style,
|
|
147
|
+
popperPlacement = _ref3.placement;
|
|
131
148
|
return React.createElement("div", _extends({
|
|
132
149
|
className: classNames('eds-tooltip', className, "eds-tooltip--" + popperPlacement, {
|
|
133
150
|
'eds-tooltip--error': variant === 'error'
|
|
@@ -148,37 +165,45 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
148
165
|
|
|
149
166
|
var _excluded = ["children"];
|
|
150
167
|
var PopoverContext = /*#__PURE__*/createContext(undefined);
|
|
168
|
+
|
|
151
169
|
var usePopoverContext = function usePopoverContext() {
|
|
152
170
|
var context = useContext(PopoverContext);
|
|
171
|
+
|
|
153
172
|
if (context == null) {
|
|
154
173
|
throw Error('usePopoverContext must be used within <Popover/>');
|
|
155
174
|
}
|
|
175
|
+
|
|
156
176
|
return context;
|
|
157
177
|
};
|
|
178
|
+
|
|
158
179
|
var Popover = function Popover(_ref) {
|
|
159
180
|
var children = _ref.children,
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
_ref$placement = _ref.placement,
|
|
182
|
+
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement;
|
|
183
|
+
|
|
162
184
|
var _React$useState = React.useState(false),
|
|
163
|
-
|
|
164
|
-
|
|
185
|
+
showPopover = _React$useState[0],
|
|
186
|
+
setShowPopover = _React$useState[1];
|
|
187
|
+
|
|
165
188
|
var triggerElement = React.useRef(null);
|
|
166
189
|
var contentElement = React.useRef(null);
|
|
190
|
+
|
|
167
191
|
var _usePopper = usePopper(triggerElement.current, contentElement.current, {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
192
|
+
modifiers: [{
|
|
193
|
+
name: 'arrow',
|
|
194
|
+
enabled: false
|
|
195
|
+
}, {
|
|
196
|
+
name: 'offset',
|
|
197
|
+
options: {
|
|
198
|
+
offset: [0, 8]
|
|
199
|
+
}
|
|
200
|
+
}],
|
|
201
|
+
placement: placement
|
|
202
|
+
}),
|
|
203
|
+
styles = _usePopper.styles,
|
|
204
|
+
attributes = _usePopper.attributes,
|
|
205
|
+
forceUpdate = _usePopper.forceUpdate;
|
|
206
|
+
|
|
182
207
|
React.useEffect(function () {
|
|
183
208
|
if (forceUpdate) {
|
|
184
209
|
forceUpdate();
|
|
@@ -218,8 +243,8 @@ var Popover = function Popover(_ref) {
|
|
|
218
243
|
}
|
|
219
244
|
},
|
|
220
245
|
onBlur: function onBlur(event) {
|
|
221
|
-
var elementReceivingFocus = event.relatedTarget;
|
|
222
|
-
|
|
246
|
+
var elementReceivingFocus = event.relatedTarget; // The check for 'tabindex=-1' is a special case for focus handling in Docz
|
|
247
|
+
|
|
223
248
|
if (!elementReceivingFocus || elementReceivingFocus.getAttribute('tabindex') === '-1') return;
|
|
224
249
|
var focusElementIsPopover = elementContainsElement(contentElement.current, elementReceivingFocus);
|
|
225
250
|
var focusElementIsTrigger = elementContainsElement(triggerElement.current, elementReceivingFocus);
|
|
@@ -245,25 +270,31 @@ var Popover = function Popover(_ref) {
|
|
|
245
270
|
};
|
|
246
271
|
var PopoverTrigger = function PopoverTrigger(_ref2) {
|
|
247
272
|
var children = _ref2.children;
|
|
273
|
+
|
|
248
274
|
var _usePopoverContext = usePopoverContext(),
|
|
249
|
-
|
|
275
|
+
triggerProps = _usePopoverContext.triggerProps;
|
|
276
|
+
|
|
250
277
|
var child = React.Children.only(children);
|
|
251
278
|
return cloneElement(child, triggerProps());
|
|
252
279
|
};
|
|
253
280
|
var PopoverCloseButton = function PopoverCloseButton(_ref3) {
|
|
254
281
|
var children = _ref3.children,
|
|
255
|
-
|
|
282
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
283
|
+
|
|
256
284
|
var _usePopoverContext2 = usePopoverContext(),
|
|
257
|
-
|
|
285
|
+
closeButtonProps = _usePopoverContext2.closeButtonProps;
|
|
286
|
+
|
|
258
287
|
return cloneElement(children, _extends({}, closeButtonProps, rest));
|
|
259
288
|
};
|
|
260
289
|
var PopoverContent = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
261
290
|
var children = _ref4.children;
|
|
291
|
+
|
|
262
292
|
var _usePopoverContext3 = usePopoverContext(),
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
293
|
+
showPopover = _usePopoverContext3.showPopover,
|
|
294
|
+
attributes = _usePopoverContext3.attributes,
|
|
295
|
+
styles = _usePopoverContext3.styles,
|
|
296
|
+
popoverContentProps = _usePopoverContext3.popoverContentProps;
|
|
297
|
+
|
|
267
298
|
var props = popoverContentProps({
|
|
268
299
|
ref: ref
|
|
269
300
|
});
|
|
@@ -275,37 +306,46 @@ var PopoverContent = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
275
306
|
"aria-hidden": !showPopover
|
|
276
307
|
}, attributes.styles, props), children);
|
|
277
308
|
});
|
|
309
|
+
|
|
278
310
|
function elementContainsEventTarget(element, event) {
|
|
279
311
|
if (!element) {
|
|
280
312
|
return false;
|
|
281
313
|
}
|
|
314
|
+
|
|
282
315
|
if (element.contains(event.target)) {
|
|
283
316
|
return true;
|
|
284
|
-
}
|
|
285
|
-
|
|
317
|
+
} // For elements inside a Shadow DOM we need to check the composedPath
|
|
318
|
+
|
|
319
|
+
|
|
286
320
|
if (event.composed && event.composedPath) {
|
|
287
321
|
var contains = event.composedPath().find(function (target) {
|
|
288
322
|
if (target === window) {
|
|
289
323
|
return false;
|
|
290
324
|
}
|
|
325
|
+
|
|
291
326
|
return element.contains(target);
|
|
292
327
|
});
|
|
293
328
|
return contains ? true : false;
|
|
294
329
|
}
|
|
330
|
+
|
|
295
331
|
return false;
|
|
296
332
|
}
|
|
333
|
+
|
|
297
334
|
function elementContainsElement(parent, child) {
|
|
298
335
|
if (!parent) return false;
|
|
299
336
|
return parent === child || parent.contains(child);
|
|
300
337
|
}
|
|
338
|
+
|
|
301
339
|
function useOnClickOutside(ref, buttonRef, handler) {
|
|
302
340
|
React.useEffect(function () {
|
|
303
341
|
var listener = function listener(event) {
|
|
304
342
|
if (elementContainsEventTarget(ref.current, event) || elementContainsEventTarget(buttonRef.current, event)) {
|
|
305
343
|
return;
|
|
306
344
|
}
|
|
345
|
+
|
|
307
346
|
handler();
|
|
308
347
|
};
|
|
348
|
+
|
|
309
349
|
document.addEventListener('mousedown', listener);
|
|
310
350
|
document.addEventListener('touchstart', listener);
|
|
311
351
|
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: 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","remov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,MAAc,CAAC;KACxC,CAAC;IACF,OAAOD,QAAQ,GAAG,IAAI,GAAG,KAAK;;EAGhC,OAAO,KAAK;AACd;AAEA,SAASlB,sBAAsB,CAC7BwB,MAA0B,EAC1BjB,KAAkB;EAElB,IAAI,CAACiB,MAAM,EAAE,OAAO,KAAK;EACzB,OAAOA,MAAM,KAAKjB,KAAK,IAAIiB,MAAM,CAACN,QAAQ,CAACX,KAAK,CAAC;AACnD;AAEA,SAASjB,iBAAiB,CACxBnC,GAAoC,EACpCsE,SAA6C,EAC7CC,OAAmB;EAEnBtF,KAAK,CAACC,SAAS,CAAC;IACd,IAAMsF,QAAQ,GAAG,SAAXA,QAAQ,CAAI5F,KAAY;MAC5B,IACEiF,0BAA0B,CAAC7D,GAAG,CAAC0B,OAAO,EAAE9C,KAAK,CAAC,IAC9CiF,0BAA0B,CAACS,SAAS,CAAC5C,OAAO,EAAE9C,KAAK,CAAC,EACpD;QACA;;MAGF2F,OAAO,EAAE;KACV;IAEDE,QAAQ,CAACC,gBAAgB,CAAC,WAAW,EAAEF,QAAQ,CAAC;IAChDC,QAAQ,CAACC,gBAAgB,CAAC,YAAY,EAAEF,QAAQ,CAAC;IAEjD,OAAO;MACLC,QAAQ,CAACE,mBAAmB,CAAC,WAAW,EAAEH,QAAQ,CAAC;MACnDC,QAAQ,CAACE,mBAAmB,CAAC,YAAY,EAAEH,QAAQ,CAAC;KACrD;GACF,EAAE,CAACxE,GAAG,EAAEsE,SAAS,EAAEC,OAAO,CAAC,CAAC;AAC/B;;AC/PAK,sBAAsB,CAAC,SAAS,CAAC;;;;"}
|
|
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,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AP;AACD,KALgB,CAAjB;AAMA,WAAOD,QAAQ,GAAG,IAAH,GAAU,KAAzB;AACD;;AAED,SAAO,KAAP;AACD;;AAED,SAASlB,sBAAT,CACEwB,MADF,EAEEjB,KAFF;AAIE,MAAI,CAACiB,MAAL,EAAa,OAAO,KAAP;AACb,SAAOA,MAAM,KAAKjB,KAAX,IAAoBiB,MAAM,CAACN,QAAP,CAAgBX,KAAhB,CAA3B;AACD;;AAED,SAASjB,iBAAT,CACEnC,GADF,EAEEsE,SAFF,EAGEC,OAHF;AAKEtF,EAAAA,KAAK,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/tooltip",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.24",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/tooltip.esm.js",
|
|
@@ -17,30 +17,25 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"start": "
|
|
21
|
-
"build": "
|
|
22
|
-
"test": "
|
|
23
|
-
"lint": "
|
|
20
|
+
"start": "dts watch --noClean",
|
|
21
|
+
"build": "dts build",
|
|
22
|
+
"test": "dts test --env=jsdom",
|
|
23
|
+
"lint": "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.
|
|
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"
|
|
30
|
+
"@entur/tokens": "^3.4.3"
|
|
36
31
|
},
|
|
37
32
|
"dependencies": {
|
|
38
|
-
"@entur/button": "^2.10.
|
|
39
|
-
"@entur/icons": "^5.
|
|
40
|
-
"@entur/layout": "^2.1.
|
|
41
|
-
"@entur/utils": "^0.4.
|
|
33
|
+
"@entur/button": "^2.10.7",
|
|
34
|
+
"@entur/icons": "^5.4.0",
|
|
35
|
+
"@entur/layout": "^2.1.14",
|
|
36
|
+
"@entur/utils": "^0.4.8",
|
|
42
37
|
"@popperjs/core": "^2.10.1",
|
|
43
38
|
"react-popper": "^2.2.5"
|
|
44
39
|
},
|
|
45
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "103844c30bdc32296f3998a360cf6066492173e9"
|
|
46
41
|
}
|