bnstooltips 1.5.0 → 1.5.6
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/build/ItemTooltipWrapper/ItemTooltipWrapper.types.d.ts +2 -4
- package/build/SkillTooltipWrapper/SkillTooltipWrapper.types.d.ts +2 -4
- package/build/Utilities/Models.d.ts +8 -0
- package/build/index.es.js +185 -7
- package/build/index.es.js.map +1 -1
- package/build/index.js +185 -7
- package/build/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BnsItemDto } from "../itemapiclient";
|
|
2
2
|
import { ItemDownloadClient } from "../Utilities/ItemDownloadClient";
|
|
3
|
-
import { Placement } from "tippy.js";
|
|
4
3
|
import { ServerRegion } from "..";
|
|
5
|
-
|
|
4
|
+
import { ITooltipWrapper } from "../Utilities/Models";
|
|
5
|
+
export interface ItemTooltipWrapperProps extends ITooltipWrapper {
|
|
6
6
|
data: BnsItemDto;
|
|
7
7
|
region: ServerRegion;
|
|
8
8
|
offline?: boolean;
|
|
9
9
|
client?: ItemDownloadClient;
|
|
10
|
-
interactive?: boolean;
|
|
11
|
-
placement?: Placement;
|
|
12
10
|
jobstyleOverride?: string;
|
|
13
11
|
debug?: boolean;
|
|
14
12
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Skill } from "../Utilities/ISkill";
|
|
2
|
-
import {
|
|
3
|
-
export interface SkillTooltipWrapperProps {
|
|
2
|
+
import { ITooltipWrapper } from "../Utilities/Models";
|
|
3
|
+
export interface SkillTooltipWrapperProps extends ITooltipWrapper {
|
|
4
4
|
data: Skill;
|
|
5
|
-
interactive?: boolean;
|
|
6
|
-
placement?: Placement;
|
|
7
5
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Placement } from "tippy.js";
|
|
1
2
|
export interface PatchesList {
|
|
2
3
|
patches: {
|
|
3
4
|
[key: string]: PatchesListPatch;
|
|
@@ -18,3 +19,10 @@ export declare enum ServerRegion {
|
|
|
18
19
|
EUNA = "EUNA",
|
|
19
20
|
Korea = "Korea"
|
|
20
21
|
}
|
|
22
|
+
export interface ITooltipWrapper {
|
|
23
|
+
followCursor?: boolean;
|
|
24
|
+
interactive?: boolean;
|
|
25
|
+
placement?: Placement;
|
|
26
|
+
trigger?: string;
|
|
27
|
+
showArrow?: boolean;
|
|
28
|
+
}
|
package/build/index.es.js
CHANGED
|
@@ -4920,6 +4920,184 @@ Object.assign({}, applyStyles$1, {
|
|
|
4920
4920
|
}
|
|
4921
4921
|
});
|
|
4922
4922
|
|
|
4923
|
+
var mouseCoords = {
|
|
4924
|
+
clientX: 0,
|
|
4925
|
+
clientY: 0
|
|
4926
|
+
};
|
|
4927
|
+
var activeInstances = [];
|
|
4928
|
+
|
|
4929
|
+
function storeMouseCoords(_ref) {
|
|
4930
|
+
var clientX = _ref.clientX,
|
|
4931
|
+
clientY = _ref.clientY;
|
|
4932
|
+
mouseCoords = {
|
|
4933
|
+
clientX: clientX,
|
|
4934
|
+
clientY: clientY
|
|
4935
|
+
};
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
function addMouseCoordsListener(doc) {
|
|
4939
|
+
doc.addEventListener('mousemove', storeMouseCoords);
|
|
4940
|
+
}
|
|
4941
|
+
|
|
4942
|
+
function removeMouseCoordsListener(doc) {
|
|
4943
|
+
doc.removeEventListener('mousemove', storeMouseCoords);
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
var followCursor = {
|
|
4947
|
+
name: 'followCursor',
|
|
4948
|
+
defaultValue: false,
|
|
4949
|
+
fn: function fn(instance) {
|
|
4950
|
+
var reference = instance.reference;
|
|
4951
|
+
var doc = getOwnerDocument(instance.props.triggerTarget || reference);
|
|
4952
|
+
var isInternalUpdate = false;
|
|
4953
|
+
var wasFocusEvent = false;
|
|
4954
|
+
var isUnmounted = true;
|
|
4955
|
+
var prevProps = instance.props;
|
|
4956
|
+
|
|
4957
|
+
function getIsInitialBehavior() {
|
|
4958
|
+
return instance.props.followCursor === 'initial' && instance.state.isVisible;
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4961
|
+
function addListener() {
|
|
4962
|
+
doc.addEventListener('mousemove', onMouseMove);
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
function removeListener() {
|
|
4966
|
+
doc.removeEventListener('mousemove', onMouseMove);
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4969
|
+
function unsetGetReferenceClientRect() {
|
|
4970
|
+
isInternalUpdate = true;
|
|
4971
|
+
instance.setProps({
|
|
4972
|
+
getReferenceClientRect: null
|
|
4973
|
+
});
|
|
4974
|
+
isInternalUpdate = false;
|
|
4975
|
+
}
|
|
4976
|
+
|
|
4977
|
+
function onMouseMove(event) {
|
|
4978
|
+
// If the instance is interactive, avoid updating the position unless it's
|
|
4979
|
+
// over the reference element
|
|
4980
|
+
var isCursorOverReference = event.target ? reference.contains(event.target) : true;
|
|
4981
|
+
var followCursor = instance.props.followCursor;
|
|
4982
|
+
var clientX = event.clientX,
|
|
4983
|
+
clientY = event.clientY;
|
|
4984
|
+
var rect = reference.getBoundingClientRect();
|
|
4985
|
+
var relativeX = clientX - rect.left;
|
|
4986
|
+
var relativeY = clientY - rect.top;
|
|
4987
|
+
|
|
4988
|
+
if (isCursorOverReference || !instance.props.interactive) {
|
|
4989
|
+
instance.setProps({
|
|
4990
|
+
// @ts-ignore - unneeded DOMRect properties
|
|
4991
|
+
getReferenceClientRect: function getReferenceClientRect() {
|
|
4992
|
+
var rect = reference.getBoundingClientRect();
|
|
4993
|
+
var x = clientX;
|
|
4994
|
+
var y = clientY;
|
|
4995
|
+
|
|
4996
|
+
if (followCursor === 'initial') {
|
|
4997
|
+
x = rect.left + relativeX;
|
|
4998
|
+
y = rect.top + relativeY;
|
|
4999
|
+
}
|
|
5000
|
+
|
|
5001
|
+
var top = followCursor === 'horizontal' ? rect.top : y;
|
|
5002
|
+
var right = followCursor === 'vertical' ? rect.right : x;
|
|
5003
|
+
var bottom = followCursor === 'horizontal' ? rect.bottom : y;
|
|
5004
|
+
var left = followCursor === 'vertical' ? rect.left : x;
|
|
5005
|
+
return {
|
|
5006
|
+
width: right - left,
|
|
5007
|
+
height: bottom - top,
|
|
5008
|
+
top: top,
|
|
5009
|
+
right: right,
|
|
5010
|
+
bottom: bottom,
|
|
5011
|
+
left: left
|
|
5012
|
+
};
|
|
5013
|
+
}
|
|
5014
|
+
});
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
|
|
5018
|
+
function create() {
|
|
5019
|
+
if (instance.props.followCursor) {
|
|
5020
|
+
activeInstances.push({
|
|
5021
|
+
instance: instance,
|
|
5022
|
+
doc: doc
|
|
5023
|
+
});
|
|
5024
|
+
addMouseCoordsListener(doc);
|
|
5025
|
+
}
|
|
5026
|
+
}
|
|
5027
|
+
|
|
5028
|
+
function destroy() {
|
|
5029
|
+
activeInstances = activeInstances.filter(function (data) {
|
|
5030
|
+
return data.instance !== instance;
|
|
5031
|
+
});
|
|
5032
|
+
|
|
5033
|
+
if (activeInstances.filter(function (data) {
|
|
5034
|
+
return data.doc === doc;
|
|
5035
|
+
}).length === 0) {
|
|
5036
|
+
removeMouseCoordsListener(doc);
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
|
|
5040
|
+
return {
|
|
5041
|
+
onCreate: create,
|
|
5042
|
+
onDestroy: destroy,
|
|
5043
|
+
onBeforeUpdate: function onBeforeUpdate() {
|
|
5044
|
+
prevProps = instance.props;
|
|
5045
|
+
},
|
|
5046
|
+
onAfterUpdate: function onAfterUpdate(_, _ref2) {
|
|
5047
|
+
var followCursor = _ref2.followCursor;
|
|
5048
|
+
|
|
5049
|
+
if (isInternalUpdate) {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
|
|
5054
|
+
destroy();
|
|
5055
|
+
|
|
5056
|
+
if (followCursor) {
|
|
5057
|
+
create();
|
|
5058
|
+
|
|
5059
|
+
if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
|
|
5060
|
+
addListener();
|
|
5061
|
+
}
|
|
5062
|
+
} else {
|
|
5063
|
+
removeListener();
|
|
5064
|
+
unsetGetReferenceClientRect();
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
},
|
|
5068
|
+
onMount: function onMount() {
|
|
5069
|
+
if (instance.props.followCursor && !wasFocusEvent) {
|
|
5070
|
+
if (isUnmounted) {
|
|
5071
|
+
onMouseMove(mouseCoords);
|
|
5072
|
+
isUnmounted = false;
|
|
5073
|
+
}
|
|
5074
|
+
|
|
5075
|
+
if (!getIsInitialBehavior()) {
|
|
5076
|
+
addListener();
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
},
|
|
5080
|
+
onTrigger: function onTrigger(_, event) {
|
|
5081
|
+
if (isMouseEvent(event)) {
|
|
5082
|
+
mouseCoords = {
|
|
5083
|
+
clientX: event.clientX,
|
|
5084
|
+
clientY: event.clientY
|
|
5085
|
+
};
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
wasFocusEvent = event.type === 'focus';
|
|
5089
|
+
},
|
|
5090
|
+
onHidden: function onHidden() {
|
|
5091
|
+
if (instance.props.followCursor) {
|
|
5092
|
+
unsetGetReferenceClientRect();
|
|
5093
|
+
removeListener();
|
|
5094
|
+
isUnmounted = true;
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
};
|
|
5098
|
+
}
|
|
5099
|
+
};
|
|
5100
|
+
|
|
4923
5101
|
tippy.setDefaultProps({
|
|
4924
5102
|
render: render
|
|
4925
5103
|
});
|
|
@@ -5312,9 +5490,9 @@ var css_248z$3 = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[
|
|
|
5312
5490
|
styleInject(css_248z$3);
|
|
5313
5491
|
|
|
5314
5492
|
var ItemTooltipWrapper = function (_a) {
|
|
5315
|
-
var data = _a.data, region = _a.region, children = _a.children, client = _a.client, _b = _a.offline, offline = _b === void 0 ? false : _b, _c = _a.interactive, interactive = _c === void 0 ? true : _c, _d = _a.placement, placement = _d === void 0 ? "right" : _d, _e = _a.debug, debug = _e === void 0 ? false : _e, jobstyleOverride = _a.jobstyleOverride;
|
|
5493
|
+
var data = _a.data, region = _a.region, children = _a.children, client = _a.client, _b = _a.offline, offline = _b === void 0 ? false : _b, _c = _a.interactive, interactive = _c === void 0 ? true : _c, _d = _a.placement, placement = _d === void 0 ? "right" : _d, _e = _a.debug, debug = _e === void 0 ? false : _e, jobstyleOverride = _a.jobstyleOverride, _f = _a.followCursor, followCursor$1 = _f === void 0 ? false : _f, _g = _a.trigger, trigger = _g === void 0 ? "mouseenter focus" : _g, _h = _a.showArrow, showArrow = _h === void 0 ? true : _h;
|
|
5316
5494
|
var spanRef = useRef(null);
|
|
5317
|
-
var
|
|
5495
|
+
var _j = useState(null), childRef = _j[0], setChildRef = _j[1];
|
|
5318
5496
|
/**
|
|
5319
5497
|
* Mount the temporary span element.
|
|
5320
5498
|
* retrieve and store the target element's reference.
|
|
@@ -5325,10 +5503,10 @@ var ItemTooltipWrapper = function (_a) {
|
|
|
5325
5503
|
}
|
|
5326
5504
|
return function () { return setChildRef(null); };
|
|
5327
5505
|
}, []);
|
|
5328
|
-
var
|
|
5506
|
+
var _k = useState(true), isOffline = _k[0], setIsOffline = _k[1];
|
|
5329
5507
|
return (React.createElement(React.Fragment, null,
|
|
5330
5508
|
children,
|
|
5331
|
-
childRef ? (React.createElement(Tippy, { appendTo: document.body, onMount: function () { return setIsOffline(offline); }, placement: placement, animation: "fade", interactive: interactive, content: React.createElement(ItemTooltip, { region: region, jobstyleOverride: jobstyleOverride, data: data, offline: isOffline, client: client, debug: debug }), theme: "grade" + data.grade, reference: childRef })) : (React.createElement("span", { ref: spanRef, style: { display: "none" } }))));
|
|
5509
|
+
childRef ? (React.createElement(Tippy, { arrow: showArrow, trigger: trigger, plugins: [followCursor], followCursor: followCursor$1 && !interactive, appendTo: document.body, onMount: function () { return setIsOffline(offline); }, placement: placement, animation: "fade", interactive: interactive, content: React.createElement(ItemTooltip, { region: region, jobstyleOverride: jobstyleOverride, data: data, offline: isOffline, client: client, debug: debug }), theme: "grade" + data.grade, reference: childRef })) : (React.createElement("span", { ref: spanRef, style: { display: "none" } }))));
|
|
5332
5510
|
};
|
|
5333
5511
|
|
|
5334
5512
|
function ItemIconNameDiv(_a) {
|
|
@@ -6070,9 +6248,9 @@ var css_248z = ".tippy-box {\n max-width: none !important;\n background-color:
|
|
|
6070
6248
|
styleInject(css_248z);
|
|
6071
6249
|
|
|
6072
6250
|
var SkillTooltipWrapper = function (_a) {
|
|
6073
|
-
var data = _a.data, children = _a.children, _b = _a.interactive, interactive = _b === void 0 ? false : _b, _c = _a.placement, placement = _c === void 0 ? "right" : _c;
|
|
6251
|
+
var data = _a.data, children = _a.children, _b = _a.interactive, interactive = _b === void 0 ? false : _b, _c = _a.placement, placement = _c === void 0 ? "right" : _c, _d = _a.followCursor, followCursor$1 = _d === void 0 ? false : _d, _e = _a.trigger, trigger = _e === void 0 ? "mouseenter focus" : _e, _f = _a.showArrow, showArrow = _f === void 0 ? true : _f;
|
|
6074
6252
|
var spanRef = useRef(null);
|
|
6075
|
-
var
|
|
6253
|
+
var _g = useState(null), childRef = _g[0], setChildRef = _g[1];
|
|
6076
6254
|
/**
|
|
6077
6255
|
* Mount the temporary span element.
|
|
6078
6256
|
* retrieve and store the target element's reference.
|
|
@@ -6085,7 +6263,7 @@ var SkillTooltipWrapper = function (_a) {
|
|
|
6085
6263
|
}, []);
|
|
6086
6264
|
return (React.createElement(React.Fragment, null,
|
|
6087
6265
|
children,
|
|
6088
|
-
childRef ? (React.createElement(Tippy, { appendTo: document.body, placement: placement, animation: "fade", interactive: interactive, content: React.createElement(SkillTooltip, { data: data, debug: false }), theme: "grade" + 4, reference: childRef })) : (React.createElement("span", { ref: spanRef, style: { display: "none" } }))));
|
|
6266
|
+
childRef ? (React.createElement(Tippy, { arrow: showArrow, trigger: trigger, plugins: [followCursor], followCursor: followCursor$1 && !interactive, appendTo: document.body, placement: placement, animation: "fade", interactive: interactive, content: React.createElement(SkillTooltip, { data: data, debug: false }), theme: "grade" + 4, reference: childRef })) : (React.createElement("span", { ref: spanRef, style: { display: "none" } }))));
|
|
6089
6267
|
};
|
|
6090
6268
|
|
|
6091
6269
|
var ServerRegion;
|