bnstooltips 1.4.10 → 1.6.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/build/ItemTooltip/SubComponents/ItemCooldowns.d.ts +1 -0
- 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.d.ts +2 -0
- package/build/index.es.js +205 -9
- package/build/index.es.js.map +1 -1
- package/build/index.js +205 -8
- 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.d.ts
CHANGED
|
@@ -12,3 +12,5 @@ import SkillTooltipWrapper from "./SkillTooltipWrapper/SkillTooltipWrapper";
|
|
|
12
12
|
export { SkillTooltipWrapper };
|
|
13
13
|
import { ServerRegion } from "./Utilities/Models";
|
|
14
14
|
export { ServerRegion };
|
|
15
|
+
import { GetCooldownString } from "./ItemTooltip/SubComponents/ItemCooldowns";
|
|
16
|
+
export { GetCooldownString };
|
package/build/index.es.js
CHANGED
|
@@ -139,6 +139,21 @@ styleInject(css_248z$5);
|
|
|
139
139
|
function BuildIconPath(iconPath, iconIndex) {
|
|
140
140
|
if (iconPath == null)
|
|
141
141
|
return "";
|
|
142
|
+
if (iconPath.startsWith("//")) {
|
|
143
|
+
iconPath = iconPath.substring(1);
|
|
144
|
+
}
|
|
145
|
+
if (iconPath.startsWith("/Game/")) {
|
|
146
|
+
console.log(iconPath);
|
|
147
|
+
var split = iconPath.split('/');
|
|
148
|
+
var last = split[split.length - 1];
|
|
149
|
+
console.log(last);
|
|
150
|
+
var penultimate = split[split.length - 2];
|
|
151
|
+
console.log(penultimate);
|
|
152
|
+
if (last === penultimate) {
|
|
153
|
+
iconPath = iconPath.replace("/".concat(penultimate, "/"), "/");
|
|
154
|
+
}
|
|
155
|
+
console.log(iconPath);
|
|
156
|
+
}
|
|
142
157
|
iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_DualBlader_2", "00008758");
|
|
143
158
|
iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_Shooter_2", "00008758");
|
|
144
159
|
iconPath = ReplacePoharanSS(iconPath);
|
|
@@ -4920,6 +4935,184 @@ Object.assign({}, applyStyles$1, {
|
|
|
4920
4935
|
}
|
|
4921
4936
|
});
|
|
4922
4937
|
|
|
4938
|
+
var mouseCoords = {
|
|
4939
|
+
clientX: 0,
|
|
4940
|
+
clientY: 0
|
|
4941
|
+
};
|
|
4942
|
+
var activeInstances = [];
|
|
4943
|
+
|
|
4944
|
+
function storeMouseCoords(_ref) {
|
|
4945
|
+
var clientX = _ref.clientX,
|
|
4946
|
+
clientY = _ref.clientY;
|
|
4947
|
+
mouseCoords = {
|
|
4948
|
+
clientX: clientX,
|
|
4949
|
+
clientY: clientY
|
|
4950
|
+
};
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4953
|
+
function addMouseCoordsListener(doc) {
|
|
4954
|
+
doc.addEventListener('mousemove', storeMouseCoords);
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
function removeMouseCoordsListener(doc) {
|
|
4958
|
+
doc.removeEventListener('mousemove', storeMouseCoords);
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4961
|
+
var followCursor = {
|
|
4962
|
+
name: 'followCursor',
|
|
4963
|
+
defaultValue: false,
|
|
4964
|
+
fn: function fn(instance) {
|
|
4965
|
+
var reference = instance.reference;
|
|
4966
|
+
var doc = getOwnerDocument(instance.props.triggerTarget || reference);
|
|
4967
|
+
var isInternalUpdate = false;
|
|
4968
|
+
var wasFocusEvent = false;
|
|
4969
|
+
var isUnmounted = true;
|
|
4970
|
+
var prevProps = instance.props;
|
|
4971
|
+
|
|
4972
|
+
function getIsInitialBehavior() {
|
|
4973
|
+
return instance.props.followCursor === 'initial' && instance.state.isVisible;
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4976
|
+
function addListener() {
|
|
4977
|
+
doc.addEventListener('mousemove', onMouseMove);
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
function removeListener() {
|
|
4981
|
+
doc.removeEventListener('mousemove', onMouseMove);
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4984
|
+
function unsetGetReferenceClientRect() {
|
|
4985
|
+
isInternalUpdate = true;
|
|
4986
|
+
instance.setProps({
|
|
4987
|
+
getReferenceClientRect: null
|
|
4988
|
+
});
|
|
4989
|
+
isInternalUpdate = false;
|
|
4990
|
+
}
|
|
4991
|
+
|
|
4992
|
+
function onMouseMove(event) {
|
|
4993
|
+
// If the instance is interactive, avoid updating the position unless it's
|
|
4994
|
+
// over the reference element
|
|
4995
|
+
var isCursorOverReference = event.target ? reference.contains(event.target) : true;
|
|
4996
|
+
var followCursor = instance.props.followCursor;
|
|
4997
|
+
var clientX = event.clientX,
|
|
4998
|
+
clientY = event.clientY;
|
|
4999
|
+
var rect = reference.getBoundingClientRect();
|
|
5000
|
+
var relativeX = clientX - rect.left;
|
|
5001
|
+
var relativeY = clientY - rect.top;
|
|
5002
|
+
|
|
5003
|
+
if (isCursorOverReference || !instance.props.interactive) {
|
|
5004
|
+
instance.setProps({
|
|
5005
|
+
// @ts-ignore - unneeded DOMRect properties
|
|
5006
|
+
getReferenceClientRect: function getReferenceClientRect() {
|
|
5007
|
+
var rect = reference.getBoundingClientRect();
|
|
5008
|
+
var x = clientX;
|
|
5009
|
+
var y = clientY;
|
|
5010
|
+
|
|
5011
|
+
if (followCursor === 'initial') {
|
|
5012
|
+
x = rect.left + relativeX;
|
|
5013
|
+
y = rect.top + relativeY;
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5016
|
+
var top = followCursor === 'horizontal' ? rect.top : y;
|
|
5017
|
+
var right = followCursor === 'vertical' ? rect.right : x;
|
|
5018
|
+
var bottom = followCursor === 'horizontal' ? rect.bottom : y;
|
|
5019
|
+
var left = followCursor === 'vertical' ? rect.left : x;
|
|
5020
|
+
return {
|
|
5021
|
+
width: right - left,
|
|
5022
|
+
height: bottom - top,
|
|
5023
|
+
top: top,
|
|
5024
|
+
right: right,
|
|
5025
|
+
bottom: bottom,
|
|
5026
|
+
left: left
|
|
5027
|
+
};
|
|
5028
|
+
}
|
|
5029
|
+
});
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
|
|
5033
|
+
function create() {
|
|
5034
|
+
if (instance.props.followCursor) {
|
|
5035
|
+
activeInstances.push({
|
|
5036
|
+
instance: instance,
|
|
5037
|
+
doc: doc
|
|
5038
|
+
});
|
|
5039
|
+
addMouseCoordsListener(doc);
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5043
|
+
function destroy() {
|
|
5044
|
+
activeInstances = activeInstances.filter(function (data) {
|
|
5045
|
+
return data.instance !== instance;
|
|
5046
|
+
});
|
|
5047
|
+
|
|
5048
|
+
if (activeInstances.filter(function (data) {
|
|
5049
|
+
return data.doc === doc;
|
|
5050
|
+
}).length === 0) {
|
|
5051
|
+
removeMouseCoordsListener(doc);
|
|
5052
|
+
}
|
|
5053
|
+
}
|
|
5054
|
+
|
|
5055
|
+
return {
|
|
5056
|
+
onCreate: create,
|
|
5057
|
+
onDestroy: destroy,
|
|
5058
|
+
onBeforeUpdate: function onBeforeUpdate() {
|
|
5059
|
+
prevProps = instance.props;
|
|
5060
|
+
},
|
|
5061
|
+
onAfterUpdate: function onAfterUpdate(_, _ref2) {
|
|
5062
|
+
var followCursor = _ref2.followCursor;
|
|
5063
|
+
|
|
5064
|
+
if (isInternalUpdate) {
|
|
5065
|
+
return;
|
|
5066
|
+
}
|
|
5067
|
+
|
|
5068
|
+
if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
|
|
5069
|
+
destroy();
|
|
5070
|
+
|
|
5071
|
+
if (followCursor) {
|
|
5072
|
+
create();
|
|
5073
|
+
|
|
5074
|
+
if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
|
|
5075
|
+
addListener();
|
|
5076
|
+
}
|
|
5077
|
+
} else {
|
|
5078
|
+
removeListener();
|
|
5079
|
+
unsetGetReferenceClientRect();
|
|
5080
|
+
}
|
|
5081
|
+
}
|
|
5082
|
+
},
|
|
5083
|
+
onMount: function onMount() {
|
|
5084
|
+
if (instance.props.followCursor && !wasFocusEvent) {
|
|
5085
|
+
if (isUnmounted) {
|
|
5086
|
+
onMouseMove(mouseCoords);
|
|
5087
|
+
isUnmounted = false;
|
|
5088
|
+
}
|
|
5089
|
+
|
|
5090
|
+
if (!getIsInitialBehavior()) {
|
|
5091
|
+
addListener();
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
},
|
|
5095
|
+
onTrigger: function onTrigger(_, event) {
|
|
5096
|
+
if (isMouseEvent(event)) {
|
|
5097
|
+
mouseCoords = {
|
|
5098
|
+
clientX: event.clientX,
|
|
5099
|
+
clientY: event.clientY
|
|
5100
|
+
};
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
wasFocusEvent = event.type === 'focus';
|
|
5104
|
+
},
|
|
5105
|
+
onHidden: function onHidden() {
|
|
5106
|
+
if (instance.props.followCursor) {
|
|
5107
|
+
unsetGetReferenceClientRect();
|
|
5108
|
+
removeListener();
|
|
5109
|
+
isUnmounted = true;
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
};
|
|
5113
|
+
}
|
|
5114
|
+
};
|
|
5115
|
+
|
|
4923
5116
|
tippy.setDefaultProps({
|
|
4924
5117
|
render: render
|
|
4925
5118
|
});
|
|
@@ -5312,9 +5505,9 @@ var css_248z$3 = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[
|
|
|
5312
5505
|
styleInject(css_248z$3);
|
|
5313
5506
|
|
|
5314
5507
|
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;
|
|
5508
|
+
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
5509
|
var spanRef = useRef(null);
|
|
5317
|
-
var
|
|
5510
|
+
var _j = useState(null), childRef = _j[0], setChildRef = _j[1];
|
|
5318
5511
|
/**
|
|
5319
5512
|
* Mount the temporary span element.
|
|
5320
5513
|
* retrieve and store the target element's reference.
|
|
@@ -5325,10 +5518,10 @@ var ItemTooltipWrapper = function (_a) {
|
|
|
5325
5518
|
}
|
|
5326
5519
|
return function () { return setChildRef(null); };
|
|
5327
5520
|
}, []);
|
|
5328
|
-
var
|
|
5521
|
+
var _k = useState(true), isOffline = _k[0], setIsOffline = _k[1];
|
|
5329
5522
|
return (React.createElement(React.Fragment, null,
|
|
5330
5523
|
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" } }))));
|
|
5524
|
+
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
5525
|
};
|
|
5333
5526
|
|
|
5334
5527
|
function ItemIconNameDiv(_a) {
|
|
@@ -5482,12 +5675,15 @@ function ItemTooltip(_a) {
|
|
|
5482
5675
|
}
|
|
5483
5676
|
}, [jobstyleOverride]);
|
|
5484
5677
|
var item = data;
|
|
5678
|
+
var itemCategory = (_c = (_b = item.categories) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return b.index - a.index; })[0].localizedName) !== null && _c !== void 0 ? _c : "";
|
|
5679
|
+
if (itemCategory == "none")
|
|
5680
|
+
itemCategory = "";
|
|
5485
5681
|
var tooltipBaseProps = {
|
|
5486
5682
|
title: item.name,
|
|
5487
5683
|
grade: item.grade,
|
|
5488
5684
|
id: item.id + "-" + item.level,
|
|
5489
5685
|
icon: item.icon ? BuildIconPath(item.icon.iconPath) : "",
|
|
5490
|
-
subtitle:
|
|
5686
|
+
subtitle: itemCategory,
|
|
5491
5687
|
mainInfos: [],
|
|
5492
5688
|
subInfoGroups: [],
|
|
5493
5689
|
fullHeight: fullHeight,
|
|
@@ -6067,9 +6263,9 @@ var css_248z = ".tippy-box {\n max-width: none !important;\n background-color:
|
|
|
6067
6263
|
styleInject(css_248z);
|
|
6068
6264
|
|
|
6069
6265
|
var SkillTooltipWrapper = function (_a) {
|
|
6070
|
-
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;
|
|
6266
|
+
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;
|
|
6071
6267
|
var spanRef = useRef(null);
|
|
6072
|
-
var
|
|
6268
|
+
var _g = useState(null), childRef = _g[0], setChildRef = _g[1];
|
|
6073
6269
|
/**
|
|
6074
6270
|
* Mount the temporary span element.
|
|
6075
6271
|
* retrieve and store the target element's reference.
|
|
@@ -6082,7 +6278,7 @@ var SkillTooltipWrapper = function (_a) {
|
|
|
6082
6278
|
}, []);
|
|
6083
6279
|
return (React.createElement(React.Fragment, null,
|
|
6084
6280
|
children,
|
|
6085
|
-
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" } }))));
|
|
6281
|
+
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" } }))));
|
|
6086
6282
|
};
|
|
6087
6283
|
|
|
6088
6284
|
var ServerRegion;
|
|
@@ -6091,5 +6287,5 @@ var ServerRegion;
|
|
|
6091
6287
|
ServerRegion["Korea"] = "Korea";
|
|
6092
6288
|
})(ServerRegion || (ServerRegion = {}));
|
|
6093
6289
|
|
|
6094
|
-
export { ItemTooltip, ItemTooltipWrapper, JsonTooltip, ServerRegion, SkillTooltip, SkillTooltipWrapper, TooltipBase };
|
|
6290
|
+
export { GetCooldownString, ItemTooltip, ItemTooltipWrapper, JsonTooltip, ServerRegion, SkillTooltip, SkillTooltipWrapper, TooltipBase };
|
|
6095
6291
|
//# sourceMappingURL=index.es.js.map
|