@lumx/react 3.6.0 → 3.6.1-alpha-chore-dependency-updates.0
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/index.js +91 -66
- package/index.js.map +1 -1
- package/package.json +10 -12
- package/src/components/tooltip/Tooltip.stories.tsx +3 -2
- package/src/components/tooltip/Tooltip.test.tsx +32 -0
- package/src/components/tooltip/Tooltip.tsx +4 -3
- package/src/components/tooltip/useInjectTooltipRef.tsx +1 -1
- package/src/components/tooltip/useTooltipOpen.tsx +56 -38
package/index.js
CHANGED
|
@@ -25,26 +25,40 @@ import chunk from 'lodash/chunk';
|
|
|
25
25
|
import isUndefined from 'lodash/isUndefined';
|
|
26
26
|
import set from 'lodash/set';
|
|
27
27
|
|
|
28
|
-
function ownKeys(
|
|
29
|
-
var
|
|
28
|
+
function ownKeys(e, r) {
|
|
29
|
+
var t = Object.keys(e);
|
|
30
30
|
if (Object.getOwnPropertySymbols) {
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
return Object.getOwnPropertyDescriptor(
|
|
34
|
-
})),
|
|
31
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
32
|
+
r && (o = o.filter(function (r) {
|
|
33
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
34
|
+
})), t.push.apply(t, o);
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return t;
|
|
37
37
|
}
|
|
38
|
-
function _objectSpread2(
|
|
39
|
-
for (var
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
_defineProperty(
|
|
43
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(
|
|
44
|
-
Object.defineProperty(
|
|
38
|
+
function _objectSpread2(e) {
|
|
39
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
40
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
41
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
42
|
+
_defineProperty(e, r, t[r]);
|
|
43
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
44
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
function _toPrimitive(t, r) {
|
|
50
|
+
if ("object" != typeof t || !t) return t;
|
|
51
|
+
var e = t[Symbol.toPrimitive];
|
|
52
|
+
if (void 0 !== e) {
|
|
53
|
+
var i = e.call(t, r || "default");
|
|
54
|
+
if ("object" != typeof i) return i;
|
|
55
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
56
|
+
}
|
|
57
|
+
return ("string" === r ? String : Number)(t);
|
|
58
|
+
}
|
|
59
|
+
function _toPropertyKey(t) {
|
|
60
|
+
var i = _toPrimitive(t, "string");
|
|
61
|
+
return "symbol" == typeof i ? i : String(i);
|
|
48
62
|
}
|
|
49
63
|
function _defineProperty(obj, key, value) {
|
|
50
64
|
key = _toPropertyKey(key);
|
|
@@ -101,20 +115,6 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
101
115
|
}
|
|
102
116
|
return target;
|
|
103
117
|
}
|
|
104
|
-
function _toPrimitive(input, hint) {
|
|
105
|
-
if (typeof input !== "object" || input === null) return input;
|
|
106
|
-
var prim = input[Symbol.toPrimitive];
|
|
107
|
-
if (prim !== undefined) {
|
|
108
|
-
var res = prim.call(input, hint || "default");
|
|
109
|
-
if (typeof res !== "object") return res;
|
|
110
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
111
|
-
}
|
|
112
|
-
return (hint === "string" ? String : Number)(input);
|
|
113
|
-
}
|
|
114
|
-
function _toPropertyKey(arg) {
|
|
115
|
-
var key = _toPrimitive(arg, "string");
|
|
116
|
-
return typeof key === "symbol" ? key : String(key);
|
|
117
|
-
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Alignments.
|
|
@@ -378,7 +378,7 @@ const CSS_PREFIX = 'lumx';
|
|
|
378
378
|
*/
|
|
379
379
|
const TOOLTIP_HOVER_DELAY = {
|
|
380
380
|
open: 500,
|
|
381
|
-
close:
|
|
381
|
+
close: 500
|
|
382
382
|
};
|
|
383
383
|
|
|
384
384
|
/**
|
|
@@ -3477,7 +3477,7 @@ const ListItem = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3477
3477
|
}), isClickable({
|
|
3478
3478
|
linkProps,
|
|
3479
3479
|
onItemSelected
|
|
3480
|
-
}) ? /* Clickable list item */
|
|
3480
|
+
}) ? ( /* Clickable list item */
|
|
3481
3481
|
renderLink(_objectSpread2(_objectSpread2({
|
|
3482
3482
|
linkAs,
|
|
3483
3483
|
tabIndex: !isDisabled && role === 'button' ? 0 : undefined,
|
|
@@ -3494,7 +3494,7 @@ const ListItem = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3494
3494
|
onClick: isDisabled ? undefined : onItemSelected,
|
|
3495
3495
|
onKeyDown,
|
|
3496
3496
|
ref: linkRef
|
|
3497
|
-
}), content) :
|
|
3497
|
+
}), content)) :
|
|
3498
3498
|
/*#__PURE__*/
|
|
3499
3499
|
/* Non clickable list item */
|
|
3500
3500
|
React.createElement("div", {
|
|
@@ -11873,15 +11873,16 @@ const TabProvider = props => {
|
|
|
11873
11873
|
TabProvider.defaultProps = DEFAULT_PROPS$W;
|
|
11874
11874
|
|
|
11875
11875
|
const _excluded$1i = ["aria-label", "children", "className", "layout", "position", "theme"];
|
|
11876
|
-
let TabListLayout
|
|
11876
|
+
let TabListLayout = /*#__PURE__*/function (TabListLayout) {
|
|
11877
|
+
TabListLayout["clustered"] = "clustered";
|
|
11878
|
+
TabListLayout["fixed"] = "fixed";
|
|
11879
|
+
return TabListLayout;
|
|
11880
|
+
}({});
|
|
11877
11881
|
|
|
11878
11882
|
/**
|
|
11879
11883
|
* Defines the props of the component.
|
|
11880
11884
|
*/
|
|
11881
|
-
|
|
11882
|
-
TabListLayout["clustered"] = "clustered";
|
|
11883
|
-
TabListLayout["fixed"] = "fixed";
|
|
11884
|
-
})(TabListLayout || (TabListLayout = {}));
|
|
11885
|
+
|
|
11885
11886
|
/**
|
|
11886
11887
|
* Component display name.
|
|
11887
11888
|
*/
|
|
@@ -12828,6 +12829,11 @@ const browserDoesNotSupportHover = () => {
|
|
|
12828
12829
|
*/
|
|
12829
12830
|
function useTooltipOpen(delay, anchorElement) {
|
|
12830
12831
|
const [isOpen, setIsOpen] = useState(false);
|
|
12832
|
+
const onPopperMount = useRef(null);
|
|
12833
|
+
|
|
12834
|
+
// Global close on escape
|
|
12835
|
+
const [closeCallback, setCloseCallback] = useState(undefined);
|
|
12836
|
+
useCallbackOnEscape(closeCallback);
|
|
12831
12837
|
useEffect(() => {
|
|
12832
12838
|
if (!anchorElement) {
|
|
12833
12839
|
return undefined;
|
|
@@ -12859,45 +12865,57 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
12859
12865
|
};
|
|
12860
12866
|
|
|
12861
12867
|
// Close or cancel opening of tooltip
|
|
12862
|
-
const
|
|
12868
|
+
const getClose = function () {
|
|
12863
12869
|
let overrideDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : closeDelay;
|
|
12864
12870
|
if (!shouldOpen && !timer) return;
|
|
12865
12871
|
shouldOpen = false;
|
|
12866
12872
|
deferUpdate(overrideDelay);
|
|
12867
12873
|
};
|
|
12868
|
-
const
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
* Handle touchend event
|
|
12872
|
-
* If `touchend` comes before the open delay => cancel tooltip (close immediate).
|
|
12873
|
-
* Else if `touchend` comes after the open delay => tooltip takes priority, the anchor's default touch end event is prevented.
|
|
12874
|
-
*/
|
|
12875
|
-
const touchEnd = evt => {
|
|
12876
|
-
if (!openStartTime) return;
|
|
12877
|
-
if (Date.now() - openStartTime >= openDelay) {
|
|
12878
|
-
// Tooltip take priority, event prevented.
|
|
12879
|
-
evt.stopPropagation();
|
|
12880
|
-
evt.preventDefault();
|
|
12881
|
-
anchorElement.focus();
|
|
12882
|
-
// Close with delay.
|
|
12883
|
-
close();
|
|
12884
|
-
} else {
|
|
12885
|
-
// Close immediately.
|
|
12886
|
-
closeImmediately();
|
|
12887
|
-
}
|
|
12888
|
-
};
|
|
12874
|
+
const close = () => getClose(closeDelay);
|
|
12875
|
+
const closeImmediately = () => getClose(0);
|
|
12876
|
+
setCloseCallback(() => closeImmediately);
|
|
12889
12877
|
|
|
12890
12878
|
// Adapt event to browsers with or without `hover` support.
|
|
12891
|
-
const events =
|
|
12879
|
+
const events = [];
|
|
12880
|
+
if (hoverNotSupported) {
|
|
12881
|
+
/**
|
|
12882
|
+
* Handle touchend event
|
|
12883
|
+
* If end comes before the open delay => cancel tooltip (close immediate).
|
|
12884
|
+
* Else if end comes after the open delay => tooltip takes priority, the anchor's default touch end event is prevented.
|
|
12885
|
+
*/
|
|
12886
|
+
const longPressEnd = evt => {
|
|
12887
|
+
if (!openStartTime) return;
|
|
12888
|
+
if (Date.now() - openStartTime >= openDelay) {
|
|
12889
|
+
// Tooltip take priority, event prevented.
|
|
12890
|
+
evt.stopPropagation();
|
|
12891
|
+
evt.preventDefault();
|
|
12892
|
+
anchorElement.focus();
|
|
12893
|
+
// Close with delay.
|
|
12894
|
+
close();
|
|
12895
|
+
} else {
|
|
12896
|
+
// Close immediately.
|
|
12897
|
+
closeImmediately();
|
|
12898
|
+
}
|
|
12899
|
+
};
|
|
12900
|
+
events.push([anchorElement, hasTouch ? 'touchstart' : 'mousedown', open], [anchorElement, hasTouch ? 'touchend' : 'mouseup', longPressEnd]);
|
|
12901
|
+
} else {
|
|
12902
|
+
events.push([anchorElement, 'mouseenter', open], [anchorElement, 'mouseleave', close], [anchorElement, 'mouseup', closeImmediately]);
|
|
12903
|
+
onPopperMount.current = popperElement => {
|
|
12904
|
+
if (!popperElement) return;
|
|
12905
|
+
// Popper element hover
|
|
12906
|
+
popperElement.addEventListener('mouseenter', open);
|
|
12907
|
+
popperElement.addEventListener('mouseleave', close);
|
|
12908
|
+
// Add to event list to remove on unmount
|
|
12909
|
+
events.push([popperElement, 'mouseenter', open], [popperElement, 'mouseleave', close]);
|
|
12910
|
+
};
|
|
12911
|
+
}
|
|
12892
12912
|
|
|
12893
12913
|
// Events always applied no matter the browser:.
|
|
12894
12914
|
events.push(
|
|
12895
12915
|
// Open on focus.
|
|
12896
12916
|
[anchorElement, 'focusin', open],
|
|
12897
12917
|
// Close on lost focus.
|
|
12898
|
-
[anchorElement, 'focusout', closeImmediately]
|
|
12899
|
-
// Close on ESC keydown
|
|
12900
|
-
[anchorElement, 'keydown', onEscapePressed(closeImmediately)]);
|
|
12918
|
+
[anchorElement, 'focusout', closeImmediately]);
|
|
12901
12919
|
|
|
12902
12920
|
// Attach events
|
|
12903
12921
|
for (const [node, eventType, eventHandler] of events) {
|
|
@@ -12913,7 +12931,10 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
12913
12931
|
}
|
|
12914
12932
|
};
|
|
12915
12933
|
}, [anchorElement, delay]);
|
|
12916
|
-
return
|
|
12934
|
+
return {
|
|
12935
|
+
isOpen,
|
|
12936
|
+
onPopperMount: onPopperMount.current
|
|
12937
|
+
};
|
|
12917
12938
|
}
|
|
12918
12939
|
|
|
12919
12940
|
const _excluded$1o = ["label", "children", "className", "delay", "placement", "forceOpen"];
|
|
@@ -12984,10 +13005,14 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
12984
13005
|
}]
|
|
12985
13006
|
});
|
|
12986
13007
|
const position = (_attributes$popper$da = attributes === null || attributes === void 0 ? void 0 : (_attributes$popper = attributes.popper) === null || _attributes$popper === void 0 ? void 0 : _attributes$popper['data-popper-placement']) !== null && _attributes$popper$da !== void 0 ? _attributes$popper$da : placement;
|
|
12987
|
-
const
|
|
13008
|
+
const {
|
|
13009
|
+
isOpen: isActivated,
|
|
13010
|
+
onPopperMount
|
|
13011
|
+
} = useTooltipOpen(delay, anchorElement);
|
|
13012
|
+
const isOpen = isActivated || forceOpen;
|
|
12988
13013
|
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id);
|
|
12989
13014
|
return /*#__PURE__*/React.createElement(React.Fragment, null, wrappedChildren, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
12990
|
-
ref: mergeRefs(ref, setPopperElement)
|
|
13015
|
+
ref: mergeRefs(ref, setPopperElement, onPopperMount)
|
|
12991
13016
|
}, forwardedProps, {
|
|
12992
13017
|
id: id,
|
|
12993
13018
|
role: "tooltip",
|