@jsenv/navi 0.23.2 → 0.23.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.
@@ -6919,6 +6919,8 @@ const getDefaultDisplay = (tagName) => {
6919
6919
  return TAG_NAME_TO_DEFAULT_DISPLAY.get(normalizedTagName) || "inline";
6920
6920
  };
6921
6921
 
6922
+ const pressedElements = new WeakSet();
6923
+
6922
6924
  const PSEUDO_CLASSES = {
6923
6925
  ":hover": {
6924
6926
  attribute: "data-hover",
@@ -6976,15 +6978,58 @@ const PSEUDO_CLASSES = {
6976
6978
  ":active": {
6977
6979
  attribute: "data-active",
6978
6980
  setup: (el, callback) => {
6979
- el.addEventListener("mousedown", callback);
6980
- document.addEventListener("mouseup", callback);
6981
+ const onPointerDown = (e) => {
6982
+ el.setPointerCapture(e.pointerId);
6983
+ const onRelease = () => {
6984
+ el.releasePointerCapture(e.pointerId);
6985
+ el.removeEventListener("lostpointercapture", onRelease);
6986
+ el.removeEventListener("pointercancel", onRelease);
6987
+ el.removeEventListener("pointerup", onRelease);
6988
+ callback();
6989
+ };
6990
+ el.addEventListener("lostpointercapture", onRelease);
6991
+ el.addEventListener("pointercancel", onRelease);
6992
+ el.addEventListener("pointerup", onRelease);
6993
+ callback();
6994
+ };
6995
+ el.addEventListener("pointerdown", onPointerDown);
6981
6996
  return () => {
6982
- el.removeEventListener("mousedown", callback);
6983
- document.removeEventListener("mouseup", callback);
6997
+ el.removeEventListener("pointerdown", onPointerDown);
6984
6998
  };
6985
6999
  },
6986
7000
  test: (el) => el.matches(":active"),
6987
7001
  },
7002
+ ":-navi-pressed": {
7003
+ attribute: "data-pressed",
7004
+ setup: (el, callback) => {
7005
+ const onPointerDown = (e) => {
7006
+ if (e.button !== 0) {
7007
+ // only left pointer (mouse left click, touch, pen)
7008
+ return;
7009
+ }
7010
+ pressedElements.add(el);
7011
+ el.setPointerCapture(e.pointerId);
7012
+ const onRelease = () => {
7013
+ pressedElements.delete(el);
7014
+ el.releasePointerCapture(e.pointerId);
7015
+ el.removeEventListener("lostpointercapture", onRelease);
7016
+ el.removeEventListener("pointercancel", onRelease);
7017
+ el.removeEventListener("pointerup", onRelease);
7018
+ callback();
7019
+ };
7020
+ el.addEventListener("lostpointercapture", onRelease);
7021
+ el.addEventListener("pointercancel", onRelease);
7022
+ el.addEventListener("pointerup", onRelease);
7023
+ callback();
7024
+ };
7025
+ el.addEventListener("pointerdown", onPointerDown);
7026
+ return () => {
7027
+ el.removeEventListener("pointerdown", onPointerDown);
7028
+ pressedElements.delete(el);
7029
+ };
7030
+ },
7031
+ test: (el) => pressedElements.has(el),
7032
+ },
6988
7033
  ":visited": {
6989
7034
  attribute: "data-visited",
6990
7035
  },
@@ -21436,8 +21481,8 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
21436
21481
  black
21437
21482
  );
21438
21483
  --button-color-hover: var(--button-color);
21439
- /* Active */
21440
- --button-border-color-active: color-mix(
21484
+ /* Pressed */
21485
+ --button-border-color-pressed: color-mix(
21441
21486
  in srgb,
21442
21487
  var(--button-border-color) 90%,
21443
21488
  black
@@ -21487,6 +21532,9 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
21487
21532
  border-radius: var(--x-button-border-radius);
21488
21533
  outline: none;
21489
21534
  cursor: var(--x-button-cursor);
21535
+ -webkit-tap-highlight-color: transparent;
21536
+ touch-action: manipulation;
21537
+ user-select: none;
21490
21538
 
21491
21539
  &[data-icon] {
21492
21540
  --button-padding: 0;
@@ -21577,16 +21625,16 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
21577
21625
  --x-button-background-color: var(--button-background-color);
21578
21626
  --x-button-color: var(--button-color);
21579
21627
  }
21580
- /* Active */
21581
- &[data-active] {
21582
- --x-button-outline-color: var(--button-border-color-active);
21628
+ /* Pressed */
21629
+ &[data-pressed] {
21630
+ --x-button-outline-color: var(--button-border-color-pressed);
21583
21631
  }
21584
- &[data-active] {
21632
+ &[data-pressed] {
21585
21633
  .navi_button_content {
21586
21634
  transform: scale(0.9);
21587
21635
  }
21588
21636
  }
21589
- &[data-active] {
21637
+ &[data-pressed] {
21590
21638
  .navi_button_shadow {
21591
21639
  box-shadow:
21592
21640
  inset 0 3px 6px rgba(0, 0, 0, 0.2),
@@ -21622,7 +21670,7 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
21622
21670
 
21623
21671
  color: unset;
21624
21672
 
21625
- /* Remove active effects */
21673
+ /* Remove pressed effects */
21626
21674
  .navi_button_content {
21627
21675
  transform: none;
21628
21676
 
@@ -21684,8 +21732,8 @@ const ButtonStyleCSSVars = {
21684
21732
  borderColor: "--button-border-color-hover",
21685
21733
  color: "--button-color-hover"
21686
21734
  },
21687
- ":active": {
21688
- borderColor: "--button-border-color-active"
21735
+ ":-navi-pressed": {
21736
+ borderColor: "--button-border-color-pressed"
21689
21737
  },
21690
21738
  ":read-only": {
21691
21739
  backgroundColor: "--button-background-color-readonly",
@@ -21698,7 +21746,7 @@ const ButtonStyleCSSVars = {
21698
21746
  color: "--button-color-disabled"
21699
21747
  }
21700
21748
  };
21701
- const ButtonPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
21749
+ const ButtonPseudoClasses = [":hover", ":active", ":-navi-pressed", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
21702
21750
  const ButtonPseudoElements = ["::-navi-loader"];
21703
21751
  const ButtonBasic = props => {
21704
21752
  const contextLoading = useContext(LoadingContext);
@@ -21739,6 +21787,16 @@ const ButtonBasic = props => {
21739
21787
  ...remainingProps,
21740
21788
  as: "button",
21741
21789
  ref: ref,
21790
+ onContextMenu: e => {
21791
+ if (e.pointerType === "touch") {
21792
+ // Suppress the native context menu triggered by long-press on touch devices.
21793
+ // Buttons have no meaningful context menu (no text to copy/paste/search),
21794
+ // and the long-press visual state would get stuck if we let the menu open.
21795
+ // Note: e.button === -1 is equivalent — it means no physical button triggered
21796
+ // the event, i.e. it was synthesized from a long-press gesture (right-click gives e.button === 2).
21797
+ e.preventDefault();
21798
+ }
21799
+ },
21742
21800
  "data-icon": icon ? "" : undefined,
21743
21801
  "data-reveal-on-interaction": revealOnInteraction ? "" : undefined,
21744
21802
  "data-discrete": discrete ? "" : undefined,
@@ -22233,7 +22291,7 @@ const css$q = /* css */`
22233
22291
  --link-color: rgb(0, 0, 238);
22234
22292
  --link-color-visited: color-mix(in srgb, var(--link-color), black 40%);
22235
22293
 
22236
- --link-color-active: red;
22294
+ --link-color-pressed: red;
22237
22295
  --link-text-decoration: underline;
22238
22296
  --link-text-decoration-hover: var(--link-text-decoration);
22239
22297
  --link-cursor: pointer;
@@ -22268,7 +22326,7 @@ const css$q = /* css */`
22268
22326
  --x-link-color-hover: var(--link-color-hover, var(--link-color));
22269
22327
  --x-link-color-visited: var(--link-color-visited);
22270
22328
  --x-link-color-current: var(--link-color-current);
22271
- --x-link-color-active: var(--link-color-active);
22329
+ --x-link-color-pressed: var(--link-color-pressed);
22272
22330
  --x-link-text-decoration: var(--link-text-decoration);
22273
22331
  --x-link-text-decoration-hover: var(--link-text-decoration-hover);
22274
22332
  --x-link-cursor: var(--link-cursor);
@@ -22362,10 +22420,10 @@ const css$q = /* css */`
22362
22420
  &[data-focus-visible] {
22363
22421
  outline-width: 2px;
22364
22422
  }
22365
- /* Active */
22366
- &[data-active] {
22423
+ /* Pressed */
22424
+ &[data-pressed] {
22367
22425
  /* Redefine it otherwise [data-visited] prevails */
22368
- --x-link-color: var(--x-link-color-active);
22426
+ --x-link-color: var(--x-link-color-pressed);
22369
22427
  }
22370
22428
  /* Current */
22371
22429
  &[data-href-current] {
@@ -22508,8 +22566,8 @@ const LinkStyleCSSVars = {
22508
22566
  color: "--link-color-hover",
22509
22567
  textDecoration: "--link-text-decoration-hover"
22510
22568
  },
22511
- ":active": {
22512
- color: "--link-color-active"
22569
+ ":-navi-pressed": {
22570
+ color: "--link-color-pressed"
22513
22571
  },
22514
22572
  ":-navi-href-current": {
22515
22573
  background: "--link-background-current",
@@ -22522,7 +22580,7 @@ const LinkStyleCSSVars = {
22522
22580
  color: "--link-color-selected"
22523
22581
  }
22524
22582
  };
22525
- const LinkPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":visited", ":-navi-loading", ":-navi-href-internal", ":-navi-href-external", ":-navi-href-anchor", ":-navi-href-current", ":-navi-selected"];
22583
+ const LinkPseudoClasses = [":hover", ":active", ":-navi-pressed", ":focus", ":focus-visible", ":read-only", ":disabled", ":visited", ":-navi-loading", ":-navi-href-internal", ":-navi-href-external", ":-navi-href-anchor", ":-navi-href-current", ":-navi-selected"];
22526
22584
  const LinkPseudoElements = ["::-navi-loader", "::-navi-indicator"];
22527
22585
  Object.assign(PSEUDO_CLASSES, {
22528
22586
  ":-navi-href-internal": {
@@ -24860,20 +24918,20 @@ installImportMetaCssBuild(import.meta);const css$j = /* css */`
24860
24918
  --track-color-hover: color-mix(in srgb, var(--fill-color) 95%, black);
24861
24919
  --fill-color-hover: color-mix(in srgb, var(--fill-color) 80%, black);
24862
24920
  --thumb-color-hover: color-mix(in srgb, var(--thumb-color) 80%, black);
24863
- /* Active */
24864
- --border-color-active: color-mix(
24921
+ /* Pressed */
24922
+ --border-color-pressed: color-mix(
24865
24923
  in srgb,
24866
24924
  var(--border-color) 50%,
24867
24925
  transparent
24868
24926
  );
24869
- --track-border-color-active: var(--border-color-active);
24870
- --background-color-active: color-mix(
24927
+ --track-border-color-pressed: var(--border-color-pressed);
24928
+ --background-color-pressed: color-mix(
24871
24929
  in srgb,
24872
24930
  var(--background-color) 75%,
24873
24931
  white
24874
24932
  );
24875
- --fill-color-active: color-mix(in srgb, var(--fill-color) 75%, white);
24876
- --thumb-color-active: color-mix(in srgb, var(--thumb-color) 75%, white);
24933
+ --fill-color-pressed: color-mix(in srgb, var(--fill-color) 75%, white);
24934
+ --thumb-color-pressed: color-mix(in srgb, var(--thumb-color) 75%, white);
24877
24935
  /* Readonly */
24878
24936
  --border-color-readonly: color-mix(
24879
24937
  in srgb,
@@ -24991,13 +25049,13 @@ installImportMetaCssBuild(import.meta);const css$j = /* css */`
24991
25049
  --x-fill-color: var(--fill-color-hover);
24992
25050
  --x-thumb-color: var(--thumb-color-hover);
24993
25051
  }
24994
- /* Active */
24995
- &[data-active] {
24996
- --x-border-color: var(--border-color-active);
24997
- --x-track-border-color: var(--track-border-color-active);
24998
- --x-background-color: var(--background-color-active);
24999
- --x-fill-color: var(--fill-color-active);
25000
- --x-thumb-color: var(--thumb-color-active);
25052
+ /* Pressed */
25053
+ &[data-pressed] {
25054
+ --x-border-color: var(--border-color-pressed);
25055
+ --x-track-border-color: var(--track-border-color-pressed);
25056
+ --x-background-color: var(--background-color-pressed);
25057
+ --x-fill-color: var(--fill-color-pressed);
25058
+ --x-thumb-color: var(--thumb-color-pressed);
25001
25059
  }
25002
25060
  /* Focus */
25003
25061
  &[data-focus-visible] {
@@ -25061,11 +25119,11 @@ const RangeStyleCSSVars = {
25061
25119
  fillColor: "--fill-color-hover",
25062
25120
  thumbColor: "--thumb-color-hover"
25063
25121
  },
25064
- ":active": {
25122
+ ":-navi-pressed": {
25065
25123
  borderColor: "--border-color-hover",
25066
25124
  backgroundColor: "--background-color-hover",
25067
- fillColor: "--fill-color-active",
25068
- thumbColor: "--thumb-color-active"
25125
+ fillColor: "--fill-color-pressed",
25126
+ thumbColor: "--thumb-color-pressed"
25069
25127
  },
25070
25128
  ":read-only": {
25071
25129
  borderColor: "--border-color-readonly",
@@ -25080,7 +25138,7 @@ const RangeStyleCSSVars = {
25080
25138
  thumbColor: "--thumb-color-disabled"
25081
25139
  }
25082
25140
  };
25083
- const RangePseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
25141
+ const RangePseudoClasses = [":hover", ":active", ":-navi-pressed", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
25084
25142
  const RangePseudoElements = ["::-navi-loader"];
25085
25143
  const RangeChildPropSet = new Set([...fieldPropSet]);
25086
25144
  const InputRangeBasic = props => {