bnstooltips 1.5.0 → 1.6.2
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 +198 -9
- package/build/index.es.js.map +1 -1
- package/build/index.js +198 -9
- 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
|
@@ -139,8 +139,19 @@ styleInject(css_248z$5);
|
|
|
139
139
|
function BuildIconPath(iconPath, iconIndex) {
|
|
140
140
|
if (iconPath == null)
|
|
141
141
|
return "";
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
if (iconPath.startsWith("//")) {
|
|
143
|
+
iconPath = iconPath.substring(1);
|
|
144
|
+
}
|
|
145
|
+
if (iconPath.startsWith("/Game/")) {
|
|
146
|
+
var split = iconPath.split('/');
|
|
147
|
+
var last = split[split.length - 1];
|
|
148
|
+
var penultimate = split[split.length - 2];
|
|
149
|
+
if (last === penultimate) {
|
|
150
|
+
iconPath = iconPath.replace("/".concat(penultimate, "/"), "/");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_DualBlader_2", "/00008758/Skill_Icon_DualBlader_2");
|
|
154
|
+
iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_Shooter_2", "/00008758/Skill_Icon_Shooter_2");
|
|
144
155
|
iconPath = ReplacePoharanSS(iconPath);
|
|
145
156
|
var urlBase = "https://lean.bns.tools/bns/icons";
|
|
146
157
|
if (!iconPath.startsWith("/"))
|
|
@@ -4920,6 +4931,184 @@ Object.assign({}, applyStyles$1, {
|
|
|
4920
4931
|
}
|
|
4921
4932
|
});
|
|
4922
4933
|
|
|
4934
|
+
var mouseCoords = {
|
|
4935
|
+
clientX: 0,
|
|
4936
|
+
clientY: 0
|
|
4937
|
+
};
|
|
4938
|
+
var activeInstances = [];
|
|
4939
|
+
|
|
4940
|
+
function storeMouseCoords(_ref) {
|
|
4941
|
+
var clientX = _ref.clientX,
|
|
4942
|
+
clientY = _ref.clientY;
|
|
4943
|
+
mouseCoords = {
|
|
4944
|
+
clientX: clientX,
|
|
4945
|
+
clientY: clientY
|
|
4946
|
+
};
|
|
4947
|
+
}
|
|
4948
|
+
|
|
4949
|
+
function addMouseCoordsListener(doc) {
|
|
4950
|
+
doc.addEventListener('mousemove', storeMouseCoords);
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4953
|
+
function removeMouseCoordsListener(doc) {
|
|
4954
|
+
doc.removeEventListener('mousemove', storeMouseCoords);
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
var followCursor = {
|
|
4958
|
+
name: 'followCursor',
|
|
4959
|
+
defaultValue: false,
|
|
4960
|
+
fn: function fn(instance) {
|
|
4961
|
+
var reference = instance.reference;
|
|
4962
|
+
var doc = getOwnerDocument(instance.props.triggerTarget || reference);
|
|
4963
|
+
var isInternalUpdate = false;
|
|
4964
|
+
var wasFocusEvent = false;
|
|
4965
|
+
var isUnmounted = true;
|
|
4966
|
+
var prevProps = instance.props;
|
|
4967
|
+
|
|
4968
|
+
function getIsInitialBehavior() {
|
|
4969
|
+
return instance.props.followCursor === 'initial' && instance.state.isVisible;
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4972
|
+
function addListener() {
|
|
4973
|
+
doc.addEventListener('mousemove', onMouseMove);
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4976
|
+
function removeListener() {
|
|
4977
|
+
doc.removeEventListener('mousemove', onMouseMove);
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
function unsetGetReferenceClientRect() {
|
|
4981
|
+
isInternalUpdate = true;
|
|
4982
|
+
instance.setProps({
|
|
4983
|
+
getReferenceClientRect: null
|
|
4984
|
+
});
|
|
4985
|
+
isInternalUpdate = false;
|
|
4986
|
+
}
|
|
4987
|
+
|
|
4988
|
+
function onMouseMove(event) {
|
|
4989
|
+
// If the instance is interactive, avoid updating the position unless it's
|
|
4990
|
+
// over the reference element
|
|
4991
|
+
var isCursorOverReference = event.target ? reference.contains(event.target) : true;
|
|
4992
|
+
var followCursor = instance.props.followCursor;
|
|
4993
|
+
var clientX = event.clientX,
|
|
4994
|
+
clientY = event.clientY;
|
|
4995
|
+
var rect = reference.getBoundingClientRect();
|
|
4996
|
+
var relativeX = clientX - rect.left;
|
|
4997
|
+
var relativeY = clientY - rect.top;
|
|
4998
|
+
|
|
4999
|
+
if (isCursorOverReference || !instance.props.interactive) {
|
|
5000
|
+
instance.setProps({
|
|
5001
|
+
// @ts-ignore - unneeded DOMRect properties
|
|
5002
|
+
getReferenceClientRect: function getReferenceClientRect() {
|
|
5003
|
+
var rect = reference.getBoundingClientRect();
|
|
5004
|
+
var x = clientX;
|
|
5005
|
+
var y = clientY;
|
|
5006
|
+
|
|
5007
|
+
if (followCursor === 'initial') {
|
|
5008
|
+
x = rect.left + relativeX;
|
|
5009
|
+
y = rect.top + relativeY;
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
var top = followCursor === 'horizontal' ? rect.top : y;
|
|
5013
|
+
var right = followCursor === 'vertical' ? rect.right : x;
|
|
5014
|
+
var bottom = followCursor === 'horizontal' ? rect.bottom : y;
|
|
5015
|
+
var left = followCursor === 'vertical' ? rect.left : x;
|
|
5016
|
+
return {
|
|
5017
|
+
width: right - left,
|
|
5018
|
+
height: bottom - top,
|
|
5019
|
+
top: top,
|
|
5020
|
+
right: right,
|
|
5021
|
+
bottom: bottom,
|
|
5022
|
+
left: left
|
|
5023
|
+
};
|
|
5024
|
+
}
|
|
5025
|
+
});
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
|
|
5029
|
+
function create() {
|
|
5030
|
+
if (instance.props.followCursor) {
|
|
5031
|
+
activeInstances.push({
|
|
5032
|
+
instance: instance,
|
|
5033
|
+
doc: doc
|
|
5034
|
+
});
|
|
5035
|
+
addMouseCoordsListener(doc);
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
|
|
5039
|
+
function destroy() {
|
|
5040
|
+
activeInstances = activeInstances.filter(function (data) {
|
|
5041
|
+
return data.instance !== instance;
|
|
5042
|
+
});
|
|
5043
|
+
|
|
5044
|
+
if (activeInstances.filter(function (data) {
|
|
5045
|
+
return data.doc === doc;
|
|
5046
|
+
}).length === 0) {
|
|
5047
|
+
removeMouseCoordsListener(doc);
|
|
5048
|
+
}
|
|
5049
|
+
}
|
|
5050
|
+
|
|
5051
|
+
return {
|
|
5052
|
+
onCreate: create,
|
|
5053
|
+
onDestroy: destroy,
|
|
5054
|
+
onBeforeUpdate: function onBeforeUpdate() {
|
|
5055
|
+
prevProps = instance.props;
|
|
5056
|
+
},
|
|
5057
|
+
onAfterUpdate: function onAfterUpdate(_, _ref2) {
|
|
5058
|
+
var followCursor = _ref2.followCursor;
|
|
5059
|
+
|
|
5060
|
+
if (isInternalUpdate) {
|
|
5061
|
+
return;
|
|
5062
|
+
}
|
|
5063
|
+
|
|
5064
|
+
if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
|
|
5065
|
+
destroy();
|
|
5066
|
+
|
|
5067
|
+
if (followCursor) {
|
|
5068
|
+
create();
|
|
5069
|
+
|
|
5070
|
+
if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
|
|
5071
|
+
addListener();
|
|
5072
|
+
}
|
|
5073
|
+
} else {
|
|
5074
|
+
removeListener();
|
|
5075
|
+
unsetGetReferenceClientRect();
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
},
|
|
5079
|
+
onMount: function onMount() {
|
|
5080
|
+
if (instance.props.followCursor && !wasFocusEvent) {
|
|
5081
|
+
if (isUnmounted) {
|
|
5082
|
+
onMouseMove(mouseCoords);
|
|
5083
|
+
isUnmounted = false;
|
|
5084
|
+
}
|
|
5085
|
+
|
|
5086
|
+
if (!getIsInitialBehavior()) {
|
|
5087
|
+
addListener();
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
},
|
|
5091
|
+
onTrigger: function onTrigger(_, event) {
|
|
5092
|
+
if (isMouseEvent(event)) {
|
|
5093
|
+
mouseCoords = {
|
|
5094
|
+
clientX: event.clientX,
|
|
5095
|
+
clientY: event.clientY
|
|
5096
|
+
};
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
wasFocusEvent = event.type === 'focus';
|
|
5100
|
+
},
|
|
5101
|
+
onHidden: function onHidden() {
|
|
5102
|
+
if (instance.props.followCursor) {
|
|
5103
|
+
unsetGetReferenceClientRect();
|
|
5104
|
+
removeListener();
|
|
5105
|
+
isUnmounted = true;
|
|
5106
|
+
}
|
|
5107
|
+
}
|
|
5108
|
+
};
|
|
5109
|
+
}
|
|
5110
|
+
};
|
|
5111
|
+
|
|
4923
5112
|
tippy.setDefaultProps({
|
|
4924
5113
|
render: render
|
|
4925
5114
|
});
|
|
@@ -5312,9 +5501,9 @@ var css_248z$3 = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[
|
|
|
5312
5501
|
styleInject(css_248z$3);
|
|
5313
5502
|
|
|
5314
5503
|
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;
|
|
5504
|
+
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
5505
|
var spanRef = useRef(null);
|
|
5317
|
-
var
|
|
5506
|
+
var _j = useState(null), childRef = _j[0], setChildRef = _j[1];
|
|
5318
5507
|
/**
|
|
5319
5508
|
* Mount the temporary span element.
|
|
5320
5509
|
* retrieve and store the target element's reference.
|
|
@@ -5325,10 +5514,10 @@ var ItemTooltipWrapper = function (_a) {
|
|
|
5325
5514
|
}
|
|
5326
5515
|
return function () { return setChildRef(null); };
|
|
5327
5516
|
}, []);
|
|
5328
|
-
var
|
|
5517
|
+
var _k = useState(true), isOffline = _k[0], setIsOffline = _k[1];
|
|
5329
5518
|
return (React.createElement(React.Fragment, null,
|
|
5330
5519
|
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" } }))));
|
|
5520
|
+
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
5521
|
};
|
|
5333
5522
|
|
|
5334
5523
|
function ItemIconNameDiv(_a) {
|
|
@@ -6070,9 +6259,9 @@ var css_248z = ".tippy-box {\n max-width: none !important;\n background-color:
|
|
|
6070
6259
|
styleInject(css_248z);
|
|
6071
6260
|
|
|
6072
6261
|
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;
|
|
6262
|
+
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
6263
|
var spanRef = useRef(null);
|
|
6075
|
-
var
|
|
6264
|
+
var _g = useState(null), childRef = _g[0], setChildRef = _g[1];
|
|
6076
6265
|
/**
|
|
6077
6266
|
* Mount the temporary span element.
|
|
6078
6267
|
* retrieve and store the target element's reference.
|
|
@@ -6085,7 +6274,7 @@ var SkillTooltipWrapper = function (_a) {
|
|
|
6085
6274
|
}, []);
|
|
6086
6275
|
return (React.createElement(React.Fragment, null,
|
|
6087
6276
|
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" } }))));
|
|
6277
|
+
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
6278
|
};
|
|
6090
6279
|
|
|
6091
6280
|
var ServerRegion;
|