bnstooltips 1.4.9 → 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/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 +193 -10
- package/build/index.es.js.map +1 -1
- package/build/index.js +193 -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.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
|
@@ -35,7 +35,7 @@ styleInject(css_248z$6);
|
|
|
35
35
|
|
|
36
36
|
function TooltipBase(_a) {
|
|
37
37
|
var title = _a.title, category = _a.subtitle, grade = _a.grade, _b = _a.icon, icon = _b === void 0 ? "" : _b, _c = _a.mainInfos, mainTexts = _c === void 0 ? [] : _c, _d = _a.subInfoGroups, subTexts = _d === void 0 ? [] : _d, id = _a.id, _e = _a.fullHeight, fullHeight = _e === void 0 ? false : _e;
|
|
38
|
-
return (React.createElement("div", {
|
|
38
|
+
return (React.createElement("div", { "data-contentid": id !== null && id !== void 0 ? id : "", "data-testid": "TooltipBase", className: "TooltipBase_container TooltipBase_border-grade-".concat(grade, " ").concat(fullHeight ? "TooltipBase_containerFullHeight" : "") },
|
|
39
39
|
(title != null && title != "") ||
|
|
40
40
|
(category != null && category != "") ? (React.createElement("div", { className: "TooltipBase_titlesubtitle" },
|
|
41
41
|
React.createElement("div", { className: "TooltipBase_title" },
|
|
@@ -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) {
|
|
@@ -5482,11 +5660,15 @@ function ItemTooltip(_a) {
|
|
|
5482
5660
|
}
|
|
5483
5661
|
}, [jobstyleOverride]);
|
|
5484
5662
|
var item = data;
|
|
5663
|
+
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 : "";
|
|
5664
|
+
if (itemCategory == "none")
|
|
5665
|
+
itemCategory = "";
|
|
5485
5666
|
var tooltipBaseProps = {
|
|
5486
5667
|
title: item.name,
|
|
5487
5668
|
grade: item.grade,
|
|
5669
|
+
id: item.id + "-" + item.level,
|
|
5488
5670
|
icon: item.icon ? BuildIconPath(item.icon.iconPath) : "",
|
|
5489
|
-
subtitle:
|
|
5671
|
+
subtitle: itemCategory,
|
|
5490
5672
|
mainInfos: [],
|
|
5491
5673
|
subInfoGroups: [],
|
|
5492
5674
|
fullHeight: fullHeight,
|
|
@@ -5954,6 +6136,7 @@ function SkillTooltip(_a) {
|
|
|
5954
6136
|
var skill = data;
|
|
5955
6137
|
var tooltipBaseProps = {
|
|
5956
6138
|
title: skill.Name,
|
|
6139
|
+
id: skill.ID + "-" + skill.Variation,
|
|
5957
6140
|
grade: 4,
|
|
5958
6141
|
icon: skill.IconPath ? React.createElement(SkillIconWithButton, { skill: skill }) : "",
|
|
5959
6142
|
subtitle: skill.AdditionalInfo
|
|
@@ -6065,9 +6248,9 @@ var css_248z = ".tippy-box {\n max-width: none !important;\n background-color:
|
|
|
6065
6248
|
styleInject(css_248z);
|
|
6066
6249
|
|
|
6067
6250
|
var SkillTooltipWrapper = function (_a) {
|
|
6068
|
-
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;
|
|
6069
6252
|
var spanRef = useRef(null);
|
|
6070
|
-
var
|
|
6253
|
+
var _g = useState(null), childRef = _g[0], setChildRef = _g[1];
|
|
6071
6254
|
/**
|
|
6072
6255
|
* Mount the temporary span element.
|
|
6073
6256
|
* retrieve and store the target element's reference.
|
|
@@ -6080,7 +6263,7 @@ var SkillTooltipWrapper = function (_a) {
|
|
|
6080
6263
|
}, []);
|
|
6081
6264
|
return (React.createElement(React.Fragment, null,
|
|
6082
6265
|
children,
|
|
6083
|
-
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" } }))));
|
|
6084
6267
|
};
|
|
6085
6268
|
|
|
6086
6269
|
var ServerRegion;
|
|
@@ -6089,5 +6272,5 @@ var ServerRegion;
|
|
|
6089
6272
|
ServerRegion["Korea"] = "Korea";
|
|
6090
6273
|
})(ServerRegion || (ServerRegion = {}));
|
|
6091
6274
|
|
|
6092
|
-
export { ItemTooltip, ItemTooltipWrapper, JsonTooltip, ServerRegion, SkillTooltip, SkillTooltipWrapper, TooltipBase };
|
|
6275
|
+
export { GetCooldownString, ItemTooltip, ItemTooltipWrapper, JsonTooltip, ServerRegion, SkillTooltip, SkillTooltipWrapper, TooltipBase };
|
|
6093
6276
|
//# sourceMappingURL=index.es.js.map
|