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/index.js CHANGED
@@ -167,6 +167,21 @@ styleInject(css_248z$5);
167
167
  function BuildIconPath(iconPath, iconIndex) {
168
168
  if (iconPath == null)
169
169
  return "";
170
+ if (iconPath.startsWith("//")) {
171
+ iconPath = iconPath.substring(1);
172
+ }
173
+ if (iconPath.startsWith("/Game/")) {
174
+ console.log(iconPath);
175
+ var split = iconPath.split('/');
176
+ var last = split[split.length - 1];
177
+ console.log(last);
178
+ var penultimate = split[split.length - 2];
179
+ console.log(penultimate);
180
+ if (last === penultimate) {
181
+ iconPath = iconPath.replace("/".concat(penultimate, "/"), "/");
182
+ }
183
+ console.log(iconPath);
184
+ }
170
185
  iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_DualBlader_2", "00008758");
171
186
  iconPath = iconPath.replace("/Game/Art/UI/GameUI/Resource/GameUI_Icon/Skill_Icon_Shooter_2", "00008758");
172
187
  iconPath = ReplacePoharanSS(iconPath);
@@ -4948,6 +4963,184 @@ Object.assign({}, applyStyles$1, {
4948
4963
  }
4949
4964
  });
4950
4965
 
4966
+ var mouseCoords = {
4967
+ clientX: 0,
4968
+ clientY: 0
4969
+ };
4970
+ var activeInstances = [];
4971
+
4972
+ function storeMouseCoords(_ref) {
4973
+ var clientX = _ref.clientX,
4974
+ clientY = _ref.clientY;
4975
+ mouseCoords = {
4976
+ clientX: clientX,
4977
+ clientY: clientY
4978
+ };
4979
+ }
4980
+
4981
+ function addMouseCoordsListener(doc) {
4982
+ doc.addEventListener('mousemove', storeMouseCoords);
4983
+ }
4984
+
4985
+ function removeMouseCoordsListener(doc) {
4986
+ doc.removeEventListener('mousemove', storeMouseCoords);
4987
+ }
4988
+
4989
+ var followCursor = {
4990
+ name: 'followCursor',
4991
+ defaultValue: false,
4992
+ fn: function fn(instance) {
4993
+ var reference = instance.reference;
4994
+ var doc = getOwnerDocument(instance.props.triggerTarget || reference);
4995
+ var isInternalUpdate = false;
4996
+ var wasFocusEvent = false;
4997
+ var isUnmounted = true;
4998
+ var prevProps = instance.props;
4999
+
5000
+ function getIsInitialBehavior() {
5001
+ return instance.props.followCursor === 'initial' && instance.state.isVisible;
5002
+ }
5003
+
5004
+ function addListener() {
5005
+ doc.addEventListener('mousemove', onMouseMove);
5006
+ }
5007
+
5008
+ function removeListener() {
5009
+ doc.removeEventListener('mousemove', onMouseMove);
5010
+ }
5011
+
5012
+ function unsetGetReferenceClientRect() {
5013
+ isInternalUpdate = true;
5014
+ instance.setProps({
5015
+ getReferenceClientRect: null
5016
+ });
5017
+ isInternalUpdate = false;
5018
+ }
5019
+
5020
+ function onMouseMove(event) {
5021
+ // If the instance is interactive, avoid updating the position unless it's
5022
+ // over the reference element
5023
+ var isCursorOverReference = event.target ? reference.contains(event.target) : true;
5024
+ var followCursor = instance.props.followCursor;
5025
+ var clientX = event.clientX,
5026
+ clientY = event.clientY;
5027
+ var rect = reference.getBoundingClientRect();
5028
+ var relativeX = clientX - rect.left;
5029
+ var relativeY = clientY - rect.top;
5030
+
5031
+ if (isCursorOverReference || !instance.props.interactive) {
5032
+ instance.setProps({
5033
+ // @ts-ignore - unneeded DOMRect properties
5034
+ getReferenceClientRect: function getReferenceClientRect() {
5035
+ var rect = reference.getBoundingClientRect();
5036
+ var x = clientX;
5037
+ var y = clientY;
5038
+
5039
+ if (followCursor === 'initial') {
5040
+ x = rect.left + relativeX;
5041
+ y = rect.top + relativeY;
5042
+ }
5043
+
5044
+ var top = followCursor === 'horizontal' ? rect.top : y;
5045
+ var right = followCursor === 'vertical' ? rect.right : x;
5046
+ var bottom = followCursor === 'horizontal' ? rect.bottom : y;
5047
+ var left = followCursor === 'vertical' ? rect.left : x;
5048
+ return {
5049
+ width: right - left,
5050
+ height: bottom - top,
5051
+ top: top,
5052
+ right: right,
5053
+ bottom: bottom,
5054
+ left: left
5055
+ };
5056
+ }
5057
+ });
5058
+ }
5059
+ }
5060
+
5061
+ function create() {
5062
+ if (instance.props.followCursor) {
5063
+ activeInstances.push({
5064
+ instance: instance,
5065
+ doc: doc
5066
+ });
5067
+ addMouseCoordsListener(doc);
5068
+ }
5069
+ }
5070
+
5071
+ function destroy() {
5072
+ activeInstances = activeInstances.filter(function (data) {
5073
+ return data.instance !== instance;
5074
+ });
5075
+
5076
+ if (activeInstances.filter(function (data) {
5077
+ return data.doc === doc;
5078
+ }).length === 0) {
5079
+ removeMouseCoordsListener(doc);
5080
+ }
5081
+ }
5082
+
5083
+ return {
5084
+ onCreate: create,
5085
+ onDestroy: destroy,
5086
+ onBeforeUpdate: function onBeforeUpdate() {
5087
+ prevProps = instance.props;
5088
+ },
5089
+ onAfterUpdate: function onAfterUpdate(_, _ref2) {
5090
+ var followCursor = _ref2.followCursor;
5091
+
5092
+ if (isInternalUpdate) {
5093
+ return;
5094
+ }
5095
+
5096
+ if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
5097
+ destroy();
5098
+
5099
+ if (followCursor) {
5100
+ create();
5101
+
5102
+ if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
5103
+ addListener();
5104
+ }
5105
+ } else {
5106
+ removeListener();
5107
+ unsetGetReferenceClientRect();
5108
+ }
5109
+ }
5110
+ },
5111
+ onMount: function onMount() {
5112
+ if (instance.props.followCursor && !wasFocusEvent) {
5113
+ if (isUnmounted) {
5114
+ onMouseMove(mouseCoords);
5115
+ isUnmounted = false;
5116
+ }
5117
+
5118
+ if (!getIsInitialBehavior()) {
5119
+ addListener();
5120
+ }
5121
+ }
5122
+ },
5123
+ onTrigger: function onTrigger(_, event) {
5124
+ if (isMouseEvent(event)) {
5125
+ mouseCoords = {
5126
+ clientX: event.clientX,
5127
+ clientY: event.clientY
5128
+ };
5129
+ }
5130
+
5131
+ wasFocusEvent = event.type === 'focus';
5132
+ },
5133
+ onHidden: function onHidden() {
5134
+ if (instance.props.followCursor) {
5135
+ unsetGetReferenceClientRect();
5136
+ removeListener();
5137
+ isUnmounted = true;
5138
+ }
5139
+ }
5140
+ };
5141
+ }
5142
+ };
5143
+
4951
5144
  tippy.setDefaultProps({
4952
5145
  render: render
4953
5146
  });
@@ -5340,9 +5533,9 @@ var css_248z$3 = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[
5340
5533
  styleInject(css_248z$3);
5341
5534
 
5342
5535
  var ItemTooltipWrapper = function (_a) {
5343
- 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;
5536
+ 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;
5344
5537
  var spanRef = React.useRef(null);
5345
- var _f = React.useState(null), childRef = _f[0], setChildRef = _f[1];
5538
+ var _j = React.useState(null), childRef = _j[0], setChildRef = _j[1];
5346
5539
  /**
5347
5540
  * Mount the temporary span element.
5348
5541
  * retrieve and store the target element's reference.
@@ -5353,10 +5546,10 @@ var ItemTooltipWrapper = function (_a) {
5353
5546
  }
5354
5547
  return function () { return setChildRef(null); };
5355
5548
  }, []);
5356
- var _g = React.useState(true), isOffline = _g[0], setIsOffline = _g[1];
5549
+ var _k = React.useState(true), isOffline = _k[0], setIsOffline = _k[1];
5357
5550
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
5358
5551
  children,
5359
- childRef ? (React__default["default"].createElement(Tippy, { appendTo: document.body, onMount: function () { return setIsOffline(offline); }, placement: placement, animation: "fade", interactive: interactive, content: React__default["default"].createElement(ItemTooltip, { region: region, jobstyleOverride: jobstyleOverride, data: data, offline: isOffline, client: client, debug: debug }), theme: "grade" + data.grade, reference: childRef })) : (React__default["default"].createElement("span", { ref: spanRef, style: { display: "none" } }))));
5552
+ childRef ? (React__default["default"].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__default["default"].createElement(ItemTooltip, { region: region, jobstyleOverride: jobstyleOverride, data: data, offline: isOffline, client: client, debug: debug }), theme: "grade" + data.grade, reference: childRef })) : (React__default["default"].createElement("span", { ref: spanRef, style: { display: "none" } }))));
5360
5553
  };
5361
5554
 
5362
5555
  function ItemIconNameDiv(_a) {
@@ -5510,12 +5703,15 @@ function ItemTooltip(_a) {
5510
5703
  }
5511
5704
  }, [jobstyleOverride]);
5512
5705
  var item = data;
5706
+ 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 : "";
5707
+ if (itemCategory == "none")
5708
+ itemCategory = "";
5513
5709
  var tooltipBaseProps = {
5514
5710
  title: item.name,
5515
5711
  grade: item.grade,
5516
5712
  id: item.id + "-" + item.level,
5517
5713
  icon: item.icon ? BuildIconPath(item.icon.iconPath) : "",
5518
- subtitle: (_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 : "",
5714
+ subtitle: itemCategory,
5519
5715
  mainInfos: [],
5520
5716
  subInfoGroups: [],
5521
5717
  fullHeight: fullHeight,
@@ -6095,9 +6291,9 @@ var css_248z = ".tippy-box {\n max-width: none !important;\n background-color:
6095
6291
  styleInject(css_248z);
6096
6292
 
6097
6293
  var SkillTooltipWrapper = function (_a) {
6098
- 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;
6294
+ 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;
6099
6295
  var spanRef = React.useRef(null);
6100
- var _d = React.useState(null), childRef = _d[0], setChildRef = _d[1];
6296
+ var _g = React.useState(null), childRef = _g[0], setChildRef = _g[1];
6101
6297
  /**
6102
6298
  * Mount the temporary span element.
6103
6299
  * retrieve and store the target element's reference.
@@ -6110,7 +6306,7 @@ var SkillTooltipWrapper = function (_a) {
6110
6306
  }, []);
6111
6307
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
6112
6308
  children,
6113
- childRef ? (React__default["default"].createElement(Tippy, { appendTo: document.body, placement: placement, animation: "fade", interactive: interactive, content: React__default["default"].createElement(SkillTooltip, { data: data, debug: false }), theme: "grade" + 4, reference: childRef })) : (React__default["default"].createElement("span", { ref: spanRef, style: { display: "none" } }))));
6309
+ childRef ? (React__default["default"].createElement(Tippy, { arrow: showArrow, trigger: trigger, plugins: [followCursor], followCursor: followCursor$1 && !interactive, appendTo: document.body, placement: placement, animation: "fade", interactive: interactive, content: React__default["default"].createElement(SkillTooltip, { data: data, debug: false }), theme: "grade" + 4, reference: childRef })) : (React__default["default"].createElement("span", { ref: spanRef, style: { display: "none" } }))));
6114
6310
  };
6115
6311
 
6116
6312
  exports.ServerRegion = void 0;
@@ -6119,6 +6315,7 @@ exports.ServerRegion = void 0;
6119
6315
  ServerRegion["Korea"] = "Korea";
6120
6316
  })(exports.ServerRegion || (exports.ServerRegion = {}));
6121
6317
 
6318
+ exports.GetCooldownString = GetCooldownString;
6122
6319
  exports.ItemTooltip = ItemTooltip;
6123
6320
  exports.ItemTooltipWrapper = ItemTooltipWrapper;
6124
6321
  exports.JsonTooltip = JsonTooltip;