plossy 0.5.2 → 0.5.3

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/dist/plossy.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Plossy v0.5.2 | MIT License
2
+ * Plossy v0.5.3 | MIT License
3
3
  *
4
4
  * Includes icons from Lucide (https://lucide.dev), some of them derived from Feather.
5
5
  * Full third-party notices (also shipped as LICENSE-LUCIDE):
@@ -14819,6 +14819,10 @@ button.pl-search-icon > .pl-icon {
14819
14819
  font-weight: 400;
14820
14820
  }
14821
14821
 
14822
+ [data-pl-tooltip] {
14823
+ -webkit-touch-callout: none;
14824
+ }
14825
+
14822
14826
  .pl-tooltip {
14823
14827
  --pl-tooltip-bg: var(--pl-ink);
14824
14828
  --pl-tooltip-color: var(--pl-on-ink);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Plossy v0.5.2 | MIT License
2
+ * Plossy v0.5.3 | MIT License
3
3
  *
4
4
  * Includes icons from Lucide (https://lucide.dev), some of them derived from Feather.
5
5
  * Full third-party notices (also shipped as LICENSE-LUCIDE):
@@ -5005,6 +5005,9 @@ register("drop", Drop);
5005
5005
  // src/js/components/tooltip.js
5006
5006
  var TIP_ID = "pl-tooltip";
5007
5007
  var GROUP_WINDOW = 400;
5008
+ var PRESS = 500;
5009
+ var LINGER = 1500;
5010
+ var INTERACTIVE = 'a[href], button, input, select, textarea, summary, label, [role="button"], [role="link"], [contenteditable=""], [contenteditable="true"]';
5008
5011
  var tip = null;
5009
5012
  var current = null;
5010
5013
  var token = 0;
@@ -5034,12 +5037,22 @@ function bindGlobals2() {
5034
5037
  { capture: true, passive: true }
5035
5038
  );
5036
5039
  window.addEventListener("resize", () => current?.hide(), { passive: true });
5040
+ document.addEventListener(
5041
+ "pointerdown",
5042
+ (event) => {
5043
+ if (current && !current.el.contains(event.target) && !tip?.contains(event.target)) current.hide();
5044
+ },
5045
+ { capture: true, passive: true }
5046
+ );
5037
5047
  }
5038
5048
  var Tooltip = class extends Component {
5039
5049
  init() {
5040
5050
  const { el, options } = this;
5041
5051
  this.timer = 0;
5052
+ this.pressTimer = 0;
5053
+ this.lingerTimer = 0;
5042
5054
  this.visible = false;
5055
+ this.pressed = false;
5043
5056
  const native = el.getAttribute("title");
5044
5057
  if (native != null) {
5045
5058
  if (!options.title) options.title = native;
@@ -5059,14 +5072,61 @@ var Tooltip = class extends Component {
5059
5072
  if (event.pointerType === "touch") return;
5060
5073
  this.schedule();
5061
5074
  });
5062
- this.on(el, "pointerleave", () => this.hide());
5063
- this.on(el, "pointerdown", () => this.hide());
5075
+ this.on(el, "pointerleave", (event) => {
5076
+ if (event.pointerType !== "touch") this.hide();
5077
+ });
5078
+ this.on(el, "pointerdown", (event) => {
5079
+ if (event.pointerType === "touch") this.touchStart();
5080
+ else this.hide();
5081
+ });
5082
+ this.on(el, "pointerup", (event) => {
5083
+ if (event.pointerType === "touch") this.touchEnd();
5084
+ });
5085
+ this.on(el, "pointercancel", () => clearTimeout(this.pressTimer));
5086
+ this.on(el, "contextmenu", (event) => {
5087
+ if (this.pressed) event.preventDefault();
5088
+ });
5089
+ this.on(
5090
+ el,
5091
+ "click",
5092
+ (event) => {
5093
+ if (!this.pressed) return;
5094
+ this.pressed = false;
5095
+ event.preventDefault();
5096
+ event.stopImmediatePropagation();
5097
+ },
5098
+ { capture: true }
5099
+ );
5064
5100
  this.on(el, "focusin", () => {
5065
5101
  if (el.matches(":focus-visible") || el.querySelector(":focus-visible")) this.show();
5066
5102
  });
5067
5103
  this.on(el, "focusout", () => this.hide());
5068
5104
  bindGlobals2();
5069
- this.onDestroy(() => this.hide(true));
5105
+ this.onDestroy(() => {
5106
+ clearTimeout(this.pressTimer);
5107
+ this.hide(true);
5108
+ });
5109
+ }
5110
+ touchStart() {
5111
+ clearTimeout(this.pressTimer);
5112
+ clearTimeout(this.lingerTimer);
5113
+ this.pressed = false;
5114
+ this.wasVisible = this.visible;
5115
+ if (!this.el.closest(INTERACTIVE)) return;
5116
+ this.hide();
5117
+ this.pressTimer = setTimeout(() => {
5118
+ this.pressed = true;
5119
+ this.show();
5120
+ }, PRESS);
5121
+ }
5122
+ touchEnd() {
5123
+ clearTimeout(this.pressTimer);
5124
+ if (this.pressed) {
5125
+ this.lingerTimer = setTimeout(() => this.hide(), LINGER);
5126
+ } else if (!this.el.closest(INTERACTIVE)) {
5127
+ if (this.wasVisible) this.hide();
5128
+ else this.show();
5129
+ }
5070
5130
  }
5071
5131
  schedule() {
5072
5132
  clearTimeout(this.timer);
@@ -5112,6 +5172,8 @@ var Tooltip = class extends Component {
5112
5172
  /** Ukrywa podpowiedź; `immediate` pomija animację (zamiana na inny tooltip). */
5113
5173
  async hide(immediate = false) {
5114
5174
  clearTimeout(this.timer);
5175
+ clearTimeout(this.lingerTimer);
5176
+ this.pressed = false;
5115
5177
  if (!this.visible) return;
5116
5178
  this.visible = false;
5117
5179
  const { el } = this;
package/dist/plossy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Plossy v0.5.2 | MIT License
2
+ * Plossy v0.5.3 | MIT License
3
3
  *
4
4
  * Includes icons from Lucide (https://lucide.dev), some of them derived from Feather.
5
5
  * Full third-party notices (also shipped as LICENSE-LUCIDE):
@@ -5006,6 +5006,9 @@
5006
5006
  // src/js/components/tooltip.js
5007
5007
  var TIP_ID = "pl-tooltip";
5008
5008
  var GROUP_WINDOW = 400;
5009
+ var PRESS = 500;
5010
+ var LINGER = 1500;
5011
+ var INTERACTIVE = 'a[href], button, input, select, textarea, summary, label, [role="button"], [role="link"], [contenteditable=""], [contenteditable="true"]';
5009
5012
  var tip = null;
5010
5013
  var current = null;
5011
5014
  var token = 0;
@@ -5035,12 +5038,22 @@
5035
5038
  { capture: true, passive: true }
5036
5039
  );
5037
5040
  window.addEventListener("resize", () => current?.hide(), { passive: true });
5041
+ document.addEventListener(
5042
+ "pointerdown",
5043
+ (event) => {
5044
+ if (current && !current.el.contains(event.target) && !tip?.contains(event.target)) current.hide();
5045
+ },
5046
+ { capture: true, passive: true }
5047
+ );
5038
5048
  }
5039
5049
  var Tooltip = class extends Component {
5040
5050
  init() {
5041
5051
  const { el, options } = this;
5042
5052
  this.timer = 0;
5053
+ this.pressTimer = 0;
5054
+ this.lingerTimer = 0;
5043
5055
  this.visible = false;
5056
+ this.pressed = false;
5044
5057
  const native = el.getAttribute("title");
5045
5058
  if (native != null) {
5046
5059
  if (!options.title) options.title = native;
@@ -5060,14 +5073,61 @@
5060
5073
  if (event.pointerType === "touch") return;
5061
5074
  this.schedule();
5062
5075
  });
5063
- this.on(el, "pointerleave", () => this.hide());
5064
- this.on(el, "pointerdown", () => this.hide());
5076
+ this.on(el, "pointerleave", (event) => {
5077
+ if (event.pointerType !== "touch") this.hide();
5078
+ });
5079
+ this.on(el, "pointerdown", (event) => {
5080
+ if (event.pointerType === "touch") this.touchStart();
5081
+ else this.hide();
5082
+ });
5083
+ this.on(el, "pointerup", (event) => {
5084
+ if (event.pointerType === "touch") this.touchEnd();
5085
+ });
5086
+ this.on(el, "pointercancel", () => clearTimeout(this.pressTimer));
5087
+ this.on(el, "contextmenu", (event) => {
5088
+ if (this.pressed) event.preventDefault();
5089
+ });
5090
+ this.on(
5091
+ el,
5092
+ "click",
5093
+ (event) => {
5094
+ if (!this.pressed) return;
5095
+ this.pressed = false;
5096
+ event.preventDefault();
5097
+ event.stopImmediatePropagation();
5098
+ },
5099
+ { capture: true }
5100
+ );
5065
5101
  this.on(el, "focusin", () => {
5066
5102
  if (el.matches(":focus-visible") || el.querySelector(":focus-visible")) this.show();
5067
5103
  });
5068
5104
  this.on(el, "focusout", () => this.hide());
5069
5105
  bindGlobals2();
5070
- this.onDestroy(() => this.hide(true));
5106
+ this.onDestroy(() => {
5107
+ clearTimeout(this.pressTimer);
5108
+ this.hide(true);
5109
+ });
5110
+ }
5111
+ touchStart() {
5112
+ clearTimeout(this.pressTimer);
5113
+ clearTimeout(this.lingerTimer);
5114
+ this.pressed = false;
5115
+ this.wasVisible = this.visible;
5116
+ if (!this.el.closest(INTERACTIVE)) return;
5117
+ this.hide();
5118
+ this.pressTimer = setTimeout(() => {
5119
+ this.pressed = true;
5120
+ this.show();
5121
+ }, PRESS);
5122
+ }
5123
+ touchEnd() {
5124
+ clearTimeout(this.pressTimer);
5125
+ if (this.pressed) {
5126
+ this.lingerTimer = setTimeout(() => this.hide(), LINGER);
5127
+ } else if (!this.el.closest(INTERACTIVE)) {
5128
+ if (this.wasVisible) this.hide();
5129
+ else this.show();
5130
+ }
5071
5131
  }
5072
5132
  schedule() {
5073
5133
  clearTimeout(this.timer);
@@ -5113,6 +5173,8 @@
5113
5173
  /** Ukrywa podpowiedź; `immediate` pomija animację (zamiana na inny tooltip). */
5114
5174
  async hide(immediate = false) {
5115
5175
  clearTimeout(this.timer);
5176
+ clearTimeout(this.lingerTimer);
5177
+ this.pressed = false;
5116
5178
  if (!this.visible) return;
5117
5179
  this.visible = false;
5118
5180
  const { el } = this;