@tamagui/react-native-use-responder-events 1.61.2 → 1.62.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.
Files changed (41) hide show
  1. package/dist/cjs/ResponderSystem.js +75 -243
  2. package/dist/cjs/ResponderSystem.js.map +1 -1
  3. package/dist/cjs/ResponderSystem.native.js +222 -0
  4. package/dist/cjs/ResponderSystem.native.js.map +6 -0
  5. package/dist/cjs/ResponderTouchHistoryStore.js +48 -115
  6. package/dist/cjs/ResponderTouchHistoryStore.js.map +1 -1
  7. package/dist/cjs/ResponderTouchHistoryStore.native.js +124 -0
  8. package/dist/cjs/ResponderTouchHistoryStore.native.js.map +6 -0
  9. package/dist/cjs/createResponderEvent.js +33 -61
  10. package/dist/cjs/createResponderEvent.js.map +1 -1
  11. package/dist/cjs/createResponderEvent.native.js +122 -0
  12. package/dist/cjs/createResponderEvent.native.js.map +6 -0
  13. package/dist/cjs/index.js +4 -8
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/index.native.js +20 -0
  16. package/dist/cjs/index.native.js.map +6 -0
  17. package/dist/cjs/types.js +6 -23
  18. package/dist/cjs/types.js.map +1 -1
  19. package/dist/cjs/types.native.js +82 -0
  20. package/dist/cjs/types.native.js.map +6 -0
  21. package/dist/cjs/useResponderEvents.js +18 -44
  22. package/dist/cjs/useResponderEvents.js.map +1 -1
  23. package/dist/cjs/useResponderEvents.native.js +56 -0
  24. package/dist/cjs/useResponderEvents.native.js.map +6 -0
  25. package/dist/cjs/utils.js +36 -95
  26. package/dist/cjs/utils.js.map +1 -1
  27. package/dist/cjs/utils.native.js +116 -0
  28. package/dist/cjs/utils.native.js.map +6 -0
  29. package/dist/esm/ResponderSystem.js +67 -225
  30. package/dist/esm/ResponderSystem.js.map +1 -1
  31. package/dist/esm/ResponderTouchHistoryStore.js +43 -106
  32. package/dist/esm/ResponderTouchHistoryStore.js.map +1 -1
  33. package/dist/esm/createResponderEvent.js +28 -52
  34. package/dist/esm/createResponderEvent.js.map +1 -1
  35. package/dist/esm/types.js +1 -14
  36. package/dist/esm/types.js.map +1 -1
  37. package/dist/esm/useResponderEvents.js +9 -26
  38. package/dist/esm/useResponderEvents.js.map +1 -1
  39. package/dist/esm/utils.js +31 -86
  40. package/dist/esm/utils.js.map +1 -1
  41. package/package.json +2 -2
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")), __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var useResponderEvents_exports = {};
24
+ __export(useResponderEvents_exports, {
25
+ useResponderEvents: () => useResponderEvents
26
+ });
27
+ module.exports = __toCommonJS(useResponderEvents_exports);
28
+ var React = __toESM(require("react")), ResponderSystem = __toESM(require("./ResponderSystem"));
29
+ __reExport(useResponderEvents_exports, require("./utils"), module.exports);
30
+ const emptyObject = {};
31
+ function useResponderEvents(hostRef, config = emptyObject) {
32
+ const id = React.useId(), isAttachedRef = React.useRef(!1);
33
+ React.useEffect(() => (ResponderSystem.attachListeners(), () => {
34
+ ResponderSystem.removeNode(id);
35
+ }), [id]), React.useEffect(() => {
36
+ const {
37
+ onMoveShouldSetResponder,
38
+ onMoveShouldSetResponderCapture,
39
+ onScrollShouldSetResponder,
40
+ onScrollShouldSetResponderCapture,
41
+ onSelectionChangeShouldSetResponder,
42
+ onSelectionChangeShouldSetResponderCapture,
43
+ onStartShouldSetResponder,
44
+ onStartShouldSetResponderCapture
45
+ } = config, requiresResponderSystem = onMoveShouldSetResponder != null || onMoveShouldSetResponderCapture != null || onScrollShouldSetResponder != null || onScrollShouldSetResponderCapture != null || onSelectionChangeShouldSetResponder != null || onSelectionChangeShouldSetResponderCapture != null || onStartShouldSetResponder != null || onStartShouldSetResponderCapture != null, node = hostRef.current;
46
+ requiresResponderSystem ? (ResponderSystem.addNode(id, node, config), isAttachedRef.current = !0) : isAttachedRef.current && (ResponderSystem.removeNode(id), isAttachedRef.current = !1);
47
+ }, [config, hostRef, id]), process.env.NODE_ENV === "development" && (React.useDebugValue({
48
+ isResponder: hostRef.current === ResponderSystem.getResponderNode()
49
+ }), React.useDebugValue(config));
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ useResponderEvents,
54
+ ...require("./utils")
55
+ });
56
+ //# sourceMappingURL=useResponderEvents.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useResponderEvents.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,YAAuB,2BAEvB,kBAAiC;AAEjC,uCAAc,oBAVd;AAYA,MAAM,cAAc,CAAC;AAEd,SAAS,mBACd,SACA,SAA0C,aAC1C;AACA,QAAM,KAAK,MAAM,MAAM,GACjB,gBAAgB,MAAM,OAAO,EAAK;AAKxC,QAAM,UAAU,OACd,gBAAgB,gBAAgB,GACzB,MAAM;AACX,oBAAgB,WAAW,EAAE;AAAA,EAC/B,IACC,CAAC,EAAE,CAAC,GAGP,MAAM,UAAU,MAAM;AACpB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,QAEE,0BACJ,4BAA4B,QAC5B,mCAAmC,QACnC,8BAA8B,QAC9B,qCAAqC,QACrC,uCAAuC,QACvC,8CAA8C,QAC9C,6BAA6B,QAC7B,oCAAoC,MAEhC,OAAO,QAAQ;AAErB,IAAI,2BACF,gBAAgB,QAAQ,IAAI,MAAM,MAAM,GACxC,cAAc,UAAU,MACf,cAAc,YACvB,gBAAgB,WAAW,EAAE,GAC7B,cAAc,UAAU;AAAA,EAE5B,GAAG,CAAC,QAAQ,SAAS,EAAE,CAAC,GAEpB,QAAQ,IAAI,aAAa,kBAC3B,MAAM,cAAc;AAAA,IAClB,aAAa,QAAQ,YAAY,gBAAgB,iBAAiB;AAAA,EACpE,CAAC,GACD,MAAM,cAAc,MAAM;AAE9B;",
5
+ "names": []
6
+ }
package/dist/cjs/utils.js CHANGED
@@ -1,21 +1,17 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
5
  var __export = (target, all) => {
7
6
  for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
7
+ __defProp(target, name, { get: all[name], enumerable: !0 });
8
+ }, __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from == "object" || typeof from == "function")
12
10
  for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
11
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
12
  return to;
17
13
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
19
15
  var utils_exports = {};
20
16
  __export(utils_exports, {
21
17
  canUseDOM: () => canUseDOM,
@@ -29,135 +25,80 @@ __export(utils_exports, {
29
25
  setResponderId: () => setResponderId
30
26
  });
31
27
  module.exports = __toCommonJS(utils_exports);
32
- const keyName = "__reactResponderId";
33
- const canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
34
- const getBoundingClientRect = (node) => {
35
- if (!node)
36
- return;
37
- if (node.nodeType !== 1)
38
- return;
39
- if (node.getBoundingClientRect) {
28
+ const keyName = "__reactResponderId", canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), getBoundingClientRect = (node) => {
29
+ if (node && node.nodeType === 1 && node.getBoundingClientRect)
40
30
  return node.getBoundingClientRect();
41
- }
42
31
  };
43
32
  function getEventPath(domEvent) {
44
- var _a;
45
33
  if (domEvent.type === "selectionchange") {
46
- const target = (_a = window.getSelection()) == null ? void 0 : _a.anchorNode;
34
+ const target = window.getSelection()?.anchorNode;
47
35
  return composedPathFallback(target);
48
- } else {
49
- const path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
50
- return path;
51
- }
36
+ } else
37
+ return domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
52
38
  }
53
39
  function composedPathFallback(target) {
54
40
  const path = [];
55
- while (target != null && target !== document.body) {
56
- path.push(target);
57
- target = target.parentNode;
58
- }
41
+ for (; target != null && target !== document.body; )
42
+ path.push(target), target = target.parentNode;
59
43
  return path;
60
44
  }
61
45
  function getResponderId(node) {
62
- if (node != null) {
63
- return node[keyName];
64
- }
65
- return null;
46
+ return node != null ? node[keyName] : null;
66
47
  }
67
48
  function setResponderId(node, id) {
68
- if (node != null) {
69
- node[keyName] = id;
70
- }
49
+ node != null && (node[keyName] = id);
71
50
  }
72
51
  function getResponderPaths(domEvent) {
73
- const idPath = [];
74
- const nodePath = [];
75
- const eventPath = getEventPath(domEvent);
52
+ const idPath = [], nodePath = [], eventPath = getEventPath(domEvent);
76
53
  for (let i = 0; i < eventPath.length; i++) {
77
- const node = eventPath[i];
78
- const id = getResponderId(node);
79
- if (id != null) {
80
- idPath.push(id);
81
- nodePath.push(node);
82
- }
54
+ const node = eventPath[i], id = getResponderId(node);
55
+ id != null && (idPath.push(id), nodePath.push(node));
83
56
  }
84
57
  return { idPath, nodePath };
85
58
  }
86
59
  function getLowestCommonAncestor(pathA, pathB) {
87
- let pathALength = pathA.length;
88
- let pathBLength = pathB.length;
60
+ let pathALength = pathA.length, pathBLength = pathB.length;
89
61
  if (
90
62
  // If either path is empty
91
63
  pathALength === 0 || pathBLength === 0 || // If the last elements aren't the same there can't be a common ancestor
92
64
  // that is connected to the responder system
93
65
  pathA[pathALength - 1] !== pathB[pathBLength - 1]
94
- ) {
66
+ )
95
67
  return null;
96
- }
97
- let itemA = pathA[0];
98
- let indexA = 0;
99
- let itemB = pathB[0];
100
- let indexB = 0;
101
- if (pathALength - pathBLength > 0) {
102
- indexA = pathALength - pathBLength;
103
- itemA = pathA[indexA];
104
- pathALength = pathBLength;
105
- }
106
- if (pathBLength - pathALength > 0) {
107
- indexB = pathBLength - pathALength;
108
- itemB = pathB[indexB];
109
- pathBLength = pathALength;
110
- }
68
+ let itemA = pathA[0], indexA = 0, itemB = pathB[0], indexB = 0;
69
+ pathALength - pathBLength > 0 && (indexA = pathALength - pathBLength, itemA = pathA[indexA], pathALength = pathBLength), pathBLength - pathALength > 0 && (indexB = pathBLength - pathALength, itemB = pathB[indexB], pathBLength = pathALength);
111
70
  let depth = pathALength;
112
- while (depth--) {
113
- if (itemA === itemB) {
71
+ for (; depth--; ) {
72
+ if (itemA === itemB)
114
73
  return itemA;
115
- }
116
- itemA = pathA[indexA++];
117
- itemB = pathB[indexB++];
74
+ itemA = pathA[indexA++], itemB = pathB[indexB++];
118
75
  }
119
76
  return null;
120
77
  }
121
78
  function hasTargetTouches(target, touches) {
122
- if (!touches || touches.length === 0) {
123
- return false;
124
- }
79
+ if (!touches || touches.length === 0)
80
+ return !1;
125
81
  for (let i = 0; i < touches.length; i++) {
126
82
  const node = touches[i].target;
127
- if (node != null) {
128
- if (target.contains(node)) {
129
- return true;
130
- }
131
- }
83
+ if (node != null && target.contains(node))
84
+ return !0;
132
85
  }
133
- return false;
86
+ return !1;
134
87
  }
135
88
  function hasValidSelection(domEvent) {
136
- if (domEvent.type === "selectionchange") {
137
- return isSelectionValid();
138
- }
139
- return domEvent.type === "select";
89
+ return domEvent.type === "selectionchange" ? isSelectionValid() : domEvent.type === "select";
140
90
  }
141
91
  function isPrimaryPointerDown(domEvent) {
142
- const { altKey, button, buttons, ctrlKey, type } = domEvent;
143
- const isTouch = type === "touchstart" || type === "touchmove";
144
- const isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
145
- const isPrimaryMouseMove = type === "mousemove" && buttons === 1;
146
- const noModifiers = altKey === false && ctrlKey === false;
147
- if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
148
- return true;
149
- }
150
- return false;
92
+ const { altKey, button, buttons, ctrlKey, type } = domEvent, isTouch = type === "touchstart" || type === "touchmove", isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1), isPrimaryMouseMove = type === "mousemove" && buttons === 1, noModifiers = altKey === !1 && ctrlKey === !1;
93
+ return !!(isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers);
151
94
  }
152
95
  function isSelectionValid() {
153
96
  const selection = window.getSelection();
154
97
  if (!selection)
155
- return false;
156
- const string = selection.toString();
157
- const anchorNode = selection.anchorNode;
158
- const focusNode = selection.focusNode;
159
- const isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
160
- return string.length >= 1 && string !== "\n" && !!isTextNode;
98
+ return !1;
99
+ const string = selection.toString(), anchorNode = selection.anchorNode, focusNode = selection.focusNode, isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
100
+ return string.length >= 1 && string !== `
101
+ ` && !!isTextNode;
161
102
  }
162
103
  // Annotate the CommonJS export names for ESM import in node:
163
104
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,UAAU;AAET,MAAM,YAAY,CAAC,EACxB,OAAO,WAAW,eAClB,OAAO,YACP,OAAO,SAAS;AAGX,MAAM,wBAAwB,CAAC,SAA6C;AACjF,MAAI,CAAC;AAAM;AACX,MAAI,KAAK,aAAa;AAAG;AACzB,MAAI,KAAK,uBAAuB;AAC9B,WAAO,KAAK,sBAAsB;AAAA,EACpC;AACF;AAEA,SAAS,aAAa,UAA2B;AAtBjD;AA0BE,MAAI,SAAS,SAAS,mBAAmB;AACvC,UAAM,UAAS,YAAO,aAAa,MAApB,mBAAuB;AACtC,WAAO,qBAAqB,MAAM;AAAA,EACpC,OAAO;AACL,UAAM,OACJ,SAAS,gBAAgB,OACrB,SAAS,aAAa,IACtB,qBAAqB,SAAS,MAAM;AAC1C,WAAO;AAAA,EACT;AACF;AAEA,SAAS,qBAAqB,QAAyB;AACr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cAAc,WAAW,aAAa,OAAO,KAAK,aAClD,aAAa,UAAU,aAAa,OAAO,KAAK;AACnD,SAAO,OAAO,UAAU,KAAK,WAAW;AAAA,KAAQ,CAAC,CAAC;AACpD;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var utils_exports = {};
17
+ __export(utils_exports, {
18
+ canUseDOM: () => canUseDOM,
19
+ getBoundingClientRect: () => getBoundingClientRect,
20
+ getLowestCommonAncestor: () => getLowestCommonAncestor,
21
+ getResponderPaths: () => getResponderPaths,
22
+ hasTargetTouches: () => hasTargetTouches,
23
+ hasValidSelection: () => hasValidSelection,
24
+ isPrimaryPointerDown: () => isPrimaryPointerDown,
25
+ isSelectionValid: () => isSelectionValid,
26
+ setResponderId: () => setResponderId
27
+ });
28
+ module.exports = __toCommonJS(utils_exports);
29
+ const keyName = "__reactResponderId", canUseDOM = !!(typeof window < "u" && window.document && window.document.createElement), getBoundingClientRect = (node) => {
30
+ if (node && node.nodeType === 1 && node.getBoundingClientRect)
31
+ return node.getBoundingClientRect();
32
+ };
33
+ function getEventPath(domEvent) {
34
+ if (domEvent.type === "selectionchange") {
35
+ const target = window.getSelection()?.anchorNode;
36
+ return composedPathFallback(target);
37
+ } else
38
+ return domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
39
+ }
40
+ function composedPathFallback(target) {
41
+ const path = [];
42
+ for (; target != null && target !== document.body; )
43
+ path.push(target), target = target.parentNode;
44
+ return path;
45
+ }
46
+ function getResponderId(node) {
47
+ return node != null ? node[keyName] : null;
48
+ }
49
+ function setResponderId(node, id) {
50
+ node != null && (node[keyName] = id);
51
+ }
52
+ function getResponderPaths(domEvent) {
53
+ const idPath = [], nodePath = [], eventPath = getEventPath(domEvent);
54
+ for (let i = 0; i < eventPath.length; i++) {
55
+ const node = eventPath[i], id = getResponderId(node);
56
+ id != null && (idPath.push(id), nodePath.push(node));
57
+ }
58
+ return { idPath, nodePath };
59
+ }
60
+ function getLowestCommonAncestor(pathA, pathB) {
61
+ let pathALength = pathA.length, pathBLength = pathB.length;
62
+ if (
63
+ // If either path is empty
64
+ pathALength === 0 || pathBLength === 0 || // If the last elements aren't the same there can't be a common ancestor
65
+ // that is connected to the responder system
66
+ pathA[pathALength - 1] !== pathB[pathBLength - 1]
67
+ )
68
+ return null;
69
+ let itemA = pathA[0], indexA = 0, itemB = pathB[0], indexB = 0;
70
+ pathALength - pathBLength > 0 && (indexA = pathALength - pathBLength, itemA = pathA[indexA], pathALength = pathBLength), pathBLength - pathALength > 0 && (indexB = pathBLength - pathALength, itemB = pathB[indexB], pathBLength = pathALength);
71
+ let depth = pathALength;
72
+ for (; depth--; ) {
73
+ if (itemA === itemB)
74
+ return itemA;
75
+ itemA = pathA[indexA++], itemB = pathB[indexB++];
76
+ }
77
+ return null;
78
+ }
79
+ function hasTargetTouches(target, touches) {
80
+ if (!touches || touches.length === 0)
81
+ return !1;
82
+ for (let i = 0; i < touches.length; i++) {
83
+ const node = touches[i].target;
84
+ if (node != null && target.contains(node))
85
+ return !0;
86
+ }
87
+ return !1;
88
+ }
89
+ function hasValidSelection(domEvent) {
90
+ return domEvent.type === "selectionchange" ? isSelectionValid() : domEvent.type === "select";
91
+ }
92
+ function isPrimaryPointerDown(domEvent) {
93
+ const { altKey, button, buttons, ctrlKey, type } = domEvent, isTouch = type === "touchstart" || type === "touchmove", isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1), isPrimaryMouseMove = type === "mousemove" && buttons === 1, noModifiers = altKey === !1 && ctrlKey === !1;
94
+ return !!(isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers);
95
+ }
96
+ function isSelectionValid() {
97
+ const selection = window.getSelection();
98
+ if (!selection)
99
+ return !1;
100
+ const string = selection.toString(), anchorNode = selection.anchorNode, focusNode = selection.focusNode, isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
101
+ return string.length >= 1 && string !== `
102
+ ` && !!isTextNode;
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ canUseDOM,
107
+ getBoundingClientRect,
108
+ getLowestCommonAncestor,
109
+ getResponderPaths,
110
+ hasTargetTouches,
111
+ hasValidSelection,
112
+ isPrimaryPointerDown,
113
+ isSelectionValid,
114
+ setResponderId
115
+ });
116
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,UAAU,sBAEH,YAAY,CAAC,EACxB,OAAO,SAAW,OAClB,OAAO,YACP,OAAO,SAAS,gBAGL,wBAAwB,CAAC,SAA6C;AACjF,MAAK,QACD,KAAK,aAAa,KAClB,KAAK;AACP,WAAO,KAAK,sBAAsB;AAEtC;AAEA,SAAS,aAAa,UAA2B;AAI/C,MAAI,SAAS,SAAS,mBAAmB;AACvC,UAAM,SAAS,OAAO,aAAa,GAAG;AACtC,WAAO,qBAAqB,MAAM;AAAA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