@tamagui/react-native-use-responder-events 2.7.7 → 3.0.0-beta.643.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.
Files changed (61) hide show
  1. package/dist/cjs/ResponderSystem.cjs +307 -344
  2. package/dist/cjs/ResponderSystem.native.cjs +357 -0
  3. package/dist/cjs/ResponderSystem.native.js +307 -343
  4. package/dist/cjs/ResponderSystem.native.js.map +1 -1
  5. package/dist/cjs/ResponderTouchHistoryStore.cjs +136 -149
  6. package/dist/cjs/ResponderTouchHistoryStore.native.cjs +217 -0
  7. package/dist/cjs/ResponderTouchHistoryStore.native.js +176 -189
  8. package/dist/cjs/ResponderTouchHistoryStore.native.js.map +1 -1
  9. package/dist/cjs/createResponderEvent.cjs +128 -132
  10. package/dist/cjs/createResponderEvent.native.cjs +147 -0
  11. package/dist/cjs/createResponderEvent.native.js +129 -132
  12. package/dist/cjs/createResponderEvent.native.js.map +1 -1
  13. package/dist/cjs/index.cjs +10 -11
  14. package/dist/cjs/index.native.cjs +21 -0
  15. package/dist/cjs/index.native.js +10 -10
  16. package/dist/cjs/index.native.js.map +1 -1
  17. package/dist/cjs/types.cjs +40 -41
  18. package/dist/cjs/types.native.cjs +79 -0
  19. package/dist/cjs/types.native.js +40 -40
  20. package/dist/cjs/types.native.js.map +1 -1
  21. package/dist/cjs/useResponderEvents.cjs +60 -85
  22. package/dist/cjs/useResponderEvents.native.cjs +87 -0
  23. package/dist/cjs/useResponderEvents.native.js +62 -86
  24. package/dist/cjs/useResponderEvents.native.js.map +1 -1
  25. package/dist/cjs/utils.cjs +123 -135
  26. package/dist/cjs/utils.native.cjs +160 -0
  27. package/dist/cjs/utils.native.js +124 -135
  28. package/dist/cjs/utils.native.js.map +1 -1
  29. package/dist/esm/ResponderSystem.mjs +291 -326
  30. package/dist/esm/ResponderSystem.mjs.map +1 -1
  31. package/dist/esm/ResponderSystem.native.js +291 -326
  32. package/dist/esm/ResponderSystem.native.js.map +1 -1
  33. package/dist/esm/ResponderTouchHistoryStore.mjs +123 -131
  34. package/dist/esm/ResponderTouchHistoryStore.mjs.map +1 -1
  35. package/dist/esm/ResponderTouchHistoryStore.native.js +163 -172
  36. package/dist/esm/ResponderTouchHistoryStore.native.js.map +1 -1
  37. package/dist/esm/createResponderEvent.mjs +115 -114
  38. package/dist/esm/createResponderEvent.mjs.map +1 -1
  39. package/dist/esm/createResponderEvent.native.js +116 -115
  40. package/dist/esm/createResponderEvent.native.js.map +1 -1
  41. package/dist/esm/index.js +1 -2
  42. package/dist/esm/index.mjs +1 -2
  43. package/dist/esm/index.native.js +1 -2
  44. package/dist/esm/types.mjs +7 -6
  45. package/dist/esm/types.mjs.map +1 -1
  46. package/dist/esm/types.native.js +7 -6
  47. package/dist/esm/types.native.js.map +1 -1
  48. package/dist/esm/useResponderEvents.mjs +45 -61
  49. package/dist/esm/useResponderEvents.mjs.map +1 -1
  50. package/dist/esm/useResponderEvents.native.js +47 -63
  51. package/dist/esm/useResponderEvents.native.js.map +1 -1
  52. package/dist/esm/utils.mjs +101 -111
  53. package/dist/esm/utils.mjs.map +1 -1
  54. package/dist/esm/utils.native.js +102 -112
  55. package/dist/esm/utils.native.js.map +1 -1
  56. package/package.json +2 -2
  57. package/types/ResponderTouchHistoryStore.d.ts.map +1 -1
  58. package/types/utils.d.ts.map +1 -1
  59. package/dist/esm/index.js.map +0 -1
  60. package/dist/esm/index.mjs.map +0 -1
  61. package/dist/esm/index.native.js.map +0 -1
@@ -1,169 +1,157 @@
1
+
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
10
11
  };
11
12
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
19
20
  };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
22
  var utils_exports = {};
24
23
  __export(utils_exports, {
25
- canUseDOM: () => canUseDOM,
26
- getBoundingClientRect: () => getBoundingClientRect,
27
- getLowestCommonAncestor: () => getLowestCommonAncestor,
28
- getResponderPaths: () => getResponderPaths,
29
- hasTargetTouches: () => hasTargetTouches,
30
- hasValidSelection: () => hasValidSelection,
31
- isPrimaryPointerDown: () => isPrimaryPointerDown,
32
- isSelectionValid: () => isSelectionValid,
33
- setResponderId: () => setResponderId
24
+ canUseDOM: () => canUseDOM,
25
+ getBoundingClientRect: () => getBoundingClientRect,
26
+ getLowestCommonAncestor: () => getLowestCommonAncestor,
27
+ getResponderPaths: () => getResponderPaths,
28
+ hasTargetTouches: () => hasTargetTouches,
29
+ hasValidSelection: () => hasValidSelection,
30
+ isPrimaryPointerDown: () => isPrimaryPointerDown,
31
+ isSelectionValid: () => isSelectionValid,
32
+ setResponderId: () => setResponderId
34
33
  });
35
34
  module.exports = __toCommonJS(utils_exports);
36
35
  const keyName = "__reactResponderId";
37
36
  const canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
38
- const getBoundingClientRect = node => {
39
- if (!node) return;
40
- if (node.nodeType !== 1) return;
41
- if (node.getBoundingClientRect) {
42
- return node.getBoundingClientRect();
43
- }
37
+ const getBoundingClientRect = (node) => {
38
+ if (!node) return;
39
+ if (node.nodeType !== 1) return;
40
+ if (node.getBoundingClientRect) {
41
+ return node.getBoundingClientRect();
42
+ }
44
43
  };
45
44
  function getEventPath(domEvent) {
46
- if (domEvent.type === "selectionchange") {
47
- const target = window.getSelection()?.anchorNode;
48
- return composedPathFallback(target);
49
- }
50
- const path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
51
- return path;
45
+ if (domEvent.type === "selectionchange") {
46
+ const target = window.getSelection()?.anchorNode;
47
+ return composedPathFallback(target);
48
+ }
49
+ const path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
50
+ return path;
52
51
  }
53
52
  function composedPathFallback(target) {
54
- const path = [];
55
- while (target != null && target !== document.body) {
56
- path.push(target);
57
- target = target.parentNode;
58
- }
59
- return path;
53
+ const path = [];
54
+ while (target != null && target !== document.body) {
55
+ path.push(target);
56
+ target = target.parentNode;
57
+ }
58
+ return path;
60
59
  }
61
60
  function getResponderId(node) {
62
- if (node != null) {
63
- return node[keyName];
64
- }
65
- return null;
61
+ if (node != null) {
62
+ return node[keyName];
63
+ }
64
+ return null;
66
65
  }
67
66
  function setResponderId(node, id) {
68
- if (node != null) {
69
- node[keyName] = id;
70
- }
67
+ if (node != null) {
68
+ node[keyName] = id;
69
+ }
71
70
  }
72
71
  function getResponderPaths(domEvent) {
73
- const idPath = [];
74
- const nodePath = [];
75
- const eventPath = getEventPath(domEvent);
76
- 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
- }
83
- }
84
- return {
85
- idPath,
86
- nodePath
87
- };
72
+ const idPath = [];
73
+ const nodePath = [];
74
+ const eventPath = getEventPath(domEvent);
75
+ for (let i = 0; i < eventPath.length; i++) {
76
+ const node = eventPath[i];
77
+ const id = getResponderId(node);
78
+ if (id != null) {
79
+ idPath.push(id);
80
+ nodePath.push(node);
81
+ }
82
+ }
83
+ return {
84
+ idPath,
85
+ nodePath
86
+ };
88
87
  }
89
88
  function getLowestCommonAncestor(pathA, pathB) {
90
- let pathALength = pathA.length;
91
- let pathBLength = pathB.length;
92
- if (
93
- // If either path is empty
94
- pathALength === 0 || pathBLength === 0 ||
95
- // If the last elements aren't the same there can't be a common ancestor
96
- // that is connected to the responder system
97
- pathA[pathALength - 1] !== pathB[pathBLength - 1]) {
98
- return null;
99
- }
100
- let itemA = pathA[0];
101
- let indexA = 0;
102
- let itemB = pathB[0];
103
- let indexB = 0;
104
- if (pathALength - pathBLength > 0) {
105
- indexA = pathALength - pathBLength;
106
- itemA = pathA[indexA];
107
- pathALength = pathBLength;
108
- }
109
- if (pathBLength - pathALength > 0) {
110
- indexB = pathBLength - pathALength;
111
- itemB = pathB[indexB];
112
- pathBLength = pathALength;
113
- }
114
- let depth = pathALength;
115
- while (depth--) {
116
- if (itemA === itemB) {
117
- return itemA;
118
- }
119
- itemA = pathA[indexA++];
120
- itemB = pathB[indexB++];
121
- }
122
- return null;
89
+ let pathALength = pathA.length;
90
+ let pathBLength = pathB.length;
91
+ if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {
92
+ return null;
93
+ }
94
+ let itemA = pathA[0];
95
+ let indexA = 0;
96
+ let itemB = pathB[0];
97
+ let indexB = 0;
98
+ if (pathALength - pathBLength > 0) {
99
+ indexA = pathALength - pathBLength;
100
+ itemA = pathA[indexA];
101
+ pathALength = pathBLength;
102
+ }
103
+ if (pathBLength - pathALength > 0) {
104
+ indexB = pathBLength - pathALength;
105
+ itemB = pathB[indexB];
106
+ pathBLength = pathALength;
107
+ }
108
+ let depth = pathALength;
109
+ while (depth--) {
110
+ if (itemA === itemB) {
111
+ return itemA;
112
+ }
113
+ itemA = pathA[indexA++];
114
+ itemB = pathB[indexB++];
115
+ }
116
+ return null;
123
117
  }
124
118
  function hasTargetTouches(target, touches) {
125
- if (!touches || touches.length === 0) {
126
- return false;
127
- }
128
- for (let i = 0; i < touches.length; i++) {
129
- const node = touches[i].target;
130
- if (node != null) {
131
- if (target.contains(node)) {
132
- return true;
133
- }
134
- }
135
- }
136
- return false;
119
+ if (!touches || touches.length === 0) {
120
+ return false;
121
+ }
122
+ for (let i = 0; i < touches.length; i++) {
123
+ const node = touches[i].target;
124
+ if (node != null) {
125
+ if (target.contains(node)) {
126
+ return true;
127
+ }
128
+ }
129
+ }
130
+ return false;
137
131
  }
138
132
  function hasValidSelection(domEvent) {
139
- if (domEvent.type === "selectionchange") {
140
- return isSelectionValid();
141
- }
142
- return domEvent.type === "select";
133
+ if (domEvent.type === "selectionchange") {
134
+ return isSelectionValid();
135
+ }
136
+ return domEvent.type === "select";
143
137
  }
144
138
  function isPrimaryPointerDown(domEvent) {
145
- const {
146
- altKey,
147
- button,
148
- buttons,
149
- ctrlKey,
150
- type
151
- } = domEvent;
152
- const isTouch = type === "touchstart" || type === "touchmove";
153
- const isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
154
- const isPrimaryMouseMove = type === "mousemove" && buttons === 1;
155
- const noModifiers = altKey === false && ctrlKey === false;
156
- if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
157
- return true;
158
- }
159
- return false;
139
+ const { altKey, button, buttons, ctrlKey, type } = domEvent;
140
+ const isTouch = type === "touchstart" || type === "touchmove";
141
+ const isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
142
+ const isPrimaryMouseMove = type === "mousemove" && buttons === 1;
143
+ const noModifiers = altKey === false && ctrlKey === false;
144
+ if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
145
+ return true;
146
+ }
147
+ return false;
160
148
  }
161
149
  function isSelectionValid() {
162
- const selection = window.getSelection();
163
- if (!selection) return false;
164
- const string = selection.toString();
165
- const anchorNode = selection.anchorNode;
166
- const focusNode = selection.focusNode;
167
- const isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
168
- return string.length >= 1 && string !== "\n" && !!isTextNode;
169
- }
150
+ const selection = window.getSelection();
151
+ if (!selection) return false;
152
+ const string = selection.toString();
153
+ const anchorNode = selection.anchorNode;
154
+ const focusNode = selection.focusNode;
155
+ const isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
156
+ return string.length >= 1 && string !== "\n" && !!isTextNode;
157
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var utils_exports = {};
25
+ __export(utils_exports, {
26
+ canUseDOM: () => canUseDOM,
27
+ getBoundingClientRect: () => getBoundingClientRect,
28
+ getLowestCommonAncestor: () => getLowestCommonAncestor,
29
+ getResponderPaths: () => getResponderPaths,
30
+ hasTargetTouches: () => hasTargetTouches,
31
+ hasValidSelection: () => hasValidSelection,
32
+ isPrimaryPointerDown: () => isPrimaryPointerDown,
33
+ isSelectionValid: () => isSelectionValid,
34
+ setResponderId: () => setResponderId
35
+ });
36
+ module.exports = __toCommonJS(utils_exports);
37
+ var keyName = "__reactResponderId";
38
+ var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
39
+ var getBoundingClientRect = function(node) {
40
+ if (!node) return;
41
+ if (node.nodeType !== 1) return;
42
+ if (node.getBoundingClientRect) {
43
+ return node.getBoundingClientRect();
44
+ }
45
+ };
46
+ function getEventPath(domEvent) {
47
+ if (domEvent.type === "selectionchange") {
48
+ var _window_getSelection;
49
+ var target = (_window_getSelection = window.getSelection()) === null || _window_getSelection === void 0 ? void 0 : _window_getSelection.anchorNode;
50
+ return composedPathFallback(target);
51
+ }
52
+ var path = domEvent.composedPath != null ? domEvent.composedPath() : composedPathFallback(domEvent.target);
53
+ return path;
54
+ }
55
+ function composedPathFallback(target) {
56
+ var path = [];
57
+ while (target != null && target !== document.body) {
58
+ path.push(target);
59
+ target = target.parentNode;
60
+ }
61
+ return path;
62
+ }
63
+ function getResponderId(node) {
64
+ if (node != null) {
65
+ return node[keyName];
66
+ }
67
+ return null;
68
+ }
69
+ function setResponderId(node, id) {
70
+ if (node != null) {
71
+ node[keyName] = id;
72
+ }
73
+ }
74
+ function getResponderPaths(domEvent) {
75
+ var idPath = [];
76
+ var nodePath = [];
77
+ var eventPath = getEventPath(domEvent);
78
+ for (var i = 0; i < eventPath.length; i++) {
79
+ var node = eventPath[i];
80
+ var id = getResponderId(node);
81
+ if (id != null) {
82
+ idPath.push(id);
83
+ nodePath.push(node);
84
+ }
85
+ }
86
+ return {
87
+ idPath,
88
+ nodePath
89
+ };
90
+ }
91
+ function getLowestCommonAncestor(pathA, pathB) {
92
+ var pathALength = pathA.length;
93
+ var pathBLength = pathB.length;
94
+ if (pathALength === 0 || pathBLength === 0 || pathA[pathALength - 1] !== pathB[pathBLength - 1]) {
95
+ return null;
96
+ }
97
+ var itemA = pathA[0];
98
+ var indexA = 0;
99
+ var itemB = pathB[0];
100
+ var 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
+ }
111
+ var depth = pathALength;
112
+ while (depth--) {
113
+ if (itemA === itemB) {
114
+ return itemA;
115
+ }
116
+ itemA = pathA[indexA++];
117
+ itemB = pathB[indexB++];
118
+ }
119
+ return null;
120
+ }
121
+ function hasTargetTouches(target, touches) {
122
+ if (!touches || touches.length === 0) {
123
+ return false;
124
+ }
125
+ for (var i = 0; i < touches.length; i++) {
126
+ var node = touches[i].target;
127
+ if (node != null) {
128
+ if (target.contains(node)) {
129
+ return true;
130
+ }
131
+ }
132
+ }
133
+ return false;
134
+ }
135
+ function hasValidSelection(domEvent) {
136
+ if (domEvent.type === "selectionchange") {
137
+ return isSelectionValid();
138
+ }
139
+ return domEvent.type === "select";
140
+ }
141
+ function isPrimaryPointerDown(domEvent) {
142
+ var { altKey, button, buttons, ctrlKey, type } = domEvent;
143
+ var isTouch = type === "touchstart" || type === "touchmove";
144
+ var isPrimaryMouseDown = type === "mousedown" && (button === 0 || buttons === 1);
145
+ var isPrimaryMouseMove = type === "mousemove" && buttons === 1;
146
+ var noModifiers = altKey === false && ctrlKey === false;
147
+ if (isTouch || isPrimaryMouseDown && noModifiers || isPrimaryMouseMove && noModifiers) {
148
+ return true;
149
+ }
150
+ return false;
151
+ }
152
+ function isSelectionValid() {
153
+ var selection = window.getSelection();
154
+ if (!selection) return false;
155
+ var string = selection.toString();
156
+ var anchorNode = selection.anchorNode;
157
+ var focusNode = selection.focusNode;
158
+ var isTextNode = anchorNode && anchorNode.nodeType === window.Node.TEXT_NODE || focusNode && focusNode.nodeType === window.Node.TEXT_NODE;
159
+ return string.length >= 1 && string !== "\n" && !!isTextNode;
160
+ }