bnstooltips 1.4.11 → 1.6.1

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