@tamagui/floating 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 (151) hide show
  1. package/dist/cjs/Floating.cjs +10 -11
  2. package/dist/cjs/Floating.native.cjs +37 -0
  3. package/dist/cjs/Floating.native.js +20 -20
  4. package/dist/cjs/Floating.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +45 -46
  6. package/dist/cjs/index.native.cjs +74 -0
  7. package/dist/cjs/index.native.js +45 -45
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/interactions/PopupTriggerMap.cjs +36 -39
  10. package/dist/cjs/interactions/PopupTriggerMap.native.cjs +96 -0
  11. package/dist/cjs/interactions/PopupTriggerMap.native.js +76 -75
  12. package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
  13. package/dist/cjs/interactions/createFloatingEvents.cjs +36 -39
  14. package/dist/cjs/interactions/createFloatingEvents.native.cjs +52 -0
  15. package/dist/cjs/interactions/createFloatingEvents.native.js +39 -41
  16. package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
  17. package/dist/cjs/interactions/safePolygon.cjs +263 -252
  18. package/dist/cjs/interactions/safePolygon.native.cjs +294 -0
  19. package/dist/cjs/interactions/safePolygon.native.js +271 -259
  20. package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
  21. package/dist/cjs/interactions/types.cjs +10 -11
  22. package/dist/cjs/interactions/types.native.cjs +19 -0
  23. package/dist/cjs/interactions/types.native.js +10 -10
  24. package/dist/cjs/interactions/types.native.js.map +1 -1
  25. package/dist/cjs/interactions/useClick.cjs +96 -105
  26. package/dist/cjs/interactions/useClick.native.cjs +122 -0
  27. package/dist/cjs/interactions/useClick.native.js +101 -109
  28. package/dist/cjs/interactions/useClick.native.js.map +1 -1
  29. package/dist/cjs/interactions/useDelayGroup.cjs +86 -91
  30. package/dist/cjs/interactions/useDelayGroup.native.cjs +119 -0
  31. package/dist/cjs/interactions/useDelayGroup.native.js +92 -96
  32. package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
  33. package/dist/cjs/interactions/useFocus.cjs +108 -115
  34. package/dist/cjs/interactions/useFocus.native.cjs +131 -0
  35. package/dist/cjs/interactions/useFocus.native.js +114 -120
  36. package/dist/cjs/interactions/useFocus.native.js.map +1 -1
  37. package/dist/cjs/interactions/useHover.cjs +321 -335
  38. package/dist/cjs/interactions/useHover.native.cjs +357 -0
  39. package/dist/cjs/interactions/useHover.native.js +333 -347
  40. package/dist/cjs/interactions/useHover.native.js.map +1 -1
  41. package/dist/cjs/interactions/useInnerOffset.cjs +103 -111
  42. package/dist/cjs/interactions/useInnerOffset.native.cjs +132 -0
  43. package/dist/cjs/interactions/useInnerOffset.native.js +113 -120
  44. package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
  45. package/dist/cjs/interactions/useInteractions.cjs +85 -90
  46. package/dist/cjs/interactions/useInteractions.native.cjs +199 -0
  47. package/dist/cjs/interactions/useInteractions.native.js +180 -195
  48. package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
  49. package/dist/cjs/interactions/useListNavigation.cjs +404 -390
  50. package/dist/cjs/interactions/useListNavigation.native.cjs +446 -0
  51. package/dist/cjs/interactions/useListNavigation.native.js +416 -401
  52. package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
  53. package/dist/cjs/interactions/useRole.cjs +92 -106
  54. package/dist/cjs/interactions/useRole.native.cjs +121 -0
  55. package/dist/cjs/interactions/useRole.native.js +103 -116
  56. package/dist/cjs/interactions/useRole.native.js.map +1 -1
  57. package/dist/cjs/interactions/useTypeahead.cjs +115 -129
  58. package/dist/cjs/interactions/useTypeahead.native.cjs +144 -0
  59. package/dist/cjs/interactions/useTypeahead.native.js +128 -141
  60. package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
  61. package/dist/cjs/interactions/utils.cjs +126 -143
  62. package/dist/cjs/interactions/utils.native.cjs +209 -0
  63. package/dist/cjs/interactions/utils.native.js +138 -154
  64. package/dist/cjs/interactions/utils.native.js.map +1 -1
  65. package/dist/cjs/middleware/inner.cjs +74 -101
  66. package/dist/cjs/middleware/inner.native.cjs +102 -0
  67. package/dist/cjs/middleware/inner.native.js +83 -109
  68. package/dist/cjs/middleware/inner.native.js.map +1 -1
  69. package/dist/cjs/useFloating.cjs +34 -46
  70. package/dist/cjs/useFloating.native.cjs +56 -0
  71. package/dist/cjs/useFloating.native.js +37 -48
  72. package/dist/cjs/useFloating.native.js.map +1 -1
  73. package/dist/esm/Floating.mjs +1 -2
  74. package/dist/esm/Floating.native.js +6 -4
  75. package/dist/esm/Floating.native.js.map +1 -1
  76. package/dist/esm/index.js +4 -5
  77. package/dist/esm/index.mjs +4 -5
  78. package/dist/esm/index.native.js +4 -5
  79. package/dist/esm/interactions/PopupTriggerMap.mjs +23 -22
  80. package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
  81. package/dist/esm/interactions/PopupTriggerMap.native.js +62 -58
  82. package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
  83. package/dist/esm/interactions/createFloatingEvents.mjs +22 -21
  84. package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
  85. package/dist/esm/interactions/createFloatingEvents.native.js +25 -24
  86. package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
  87. package/dist/esm/interactions/safePolygon.mjs +250 -234
  88. package/dist/esm/interactions/safePolygon.mjs.map +1 -1
  89. package/dist/esm/interactions/safePolygon.native.js +258 -242
  90. package/dist/esm/interactions/safePolygon.native.js.map +1 -1
  91. package/dist/esm/interactions/types.mjs +0 -2
  92. package/dist/esm/interactions/types.native.js +0 -2
  93. package/dist/esm/interactions/useClick.mjs +83 -87
  94. package/dist/esm/interactions/useClick.mjs.map +1 -1
  95. package/dist/esm/interactions/useClick.native.js +88 -92
  96. package/dist/esm/interactions/useClick.native.js.map +1 -1
  97. package/dist/esm/interactions/useDelayGroup.mjs +68 -65
  98. package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
  99. package/dist/esm/interactions/useDelayGroup.native.js +74 -71
  100. package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
  101. package/dist/esm/interactions/useFocus.mjs +95 -97
  102. package/dist/esm/interactions/useFocus.mjs.map +1 -1
  103. package/dist/esm/interactions/useFocus.native.js +101 -103
  104. package/dist/esm/interactions/useFocus.native.js.map +1 -1
  105. package/dist/esm/interactions/useHover.mjs +304 -310
  106. package/dist/esm/interactions/useHover.mjs.map +1 -1
  107. package/dist/esm/interactions/useHover.native.js +316 -323
  108. package/dist/esm/interactions/useHover.native.js.map +1 -1
  109. package/dist/esm/interactions/useInnerOffset.mjs +87 -85
  110. package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
  111. package/dist/esm/interactions/useInnerOffset.native.js +97 -95
  112. package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
  113. package/dist/esm/interactions/useInteractions.mjs +71 -72
  114. package/dist/esm/interactions/useInteractions.mjs.map +1 -1
  115. package/dist/esm/interactions/useInteractions.native.js +166 -178
  116. package/dist/esm/interactions/useInteractions.native.js.map +1 -1
  117. package/dist/esm/interactions/useListNavigation.mjs +392 -373
  118. package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
  119. package/dist/esm/interactions/useListNavigation.native.js +404 -385
  120. package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
  121. package/dist/esm/interactions/useRole.mjs +76 -80
  122. package/dist/esm/interactions/useRole.mjs.map +1 -1
  123. package/dist/esm/interactions/useRole.native.js +87 -91
  124. package/dist/esm/interactions/useRole.native.js.map +1 -1
  125. package/dist/esm/interactions/useTypeahead.mjs +102 -111
  126. package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
  127. package/dist/esm/interactions/useTypeahead.native.js +115 -124
  128. package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
  129. package/dist/esm/interactions/utils.mjs +91 -106
  130. package/dist/esm/interactions/utils.mjs.map +1 -1
  131. package/dist/esm/interactions/utils.native.js +103 -118
  132. package/dist/esm/interactions/utils.native.js.map +1 -1
  133. package/dist/esm/middleware/inner.mjs +58 -75
  134. package/dist/esm/middleware/inner.mjs.map +1 -1
  135. package/dist/esm/middleware/inner.native.js +67 -84
  136. package/dist/esm/middleware/inner.native.js.map +1 -1
  137. package/dist/esm/useFloating.mjs +17 -21
  138. package/dist/esm/useFloating.mjs.map +1 -1
  139. package/dist/esm/useFloating.native.js +19 -23
  140. package/dist/esm/useFloating.native.js.map +1 -1
  141. package/package.json +6 -5
  142. package/types/interactions/PopupTriggerMap.d.ts.map +1 -1
  143. package/types/interactions/useInteractions.d.ts.map +1 -1
  144. package/types/middleware/inner.d.ts.map +1 -1
  145. package/types/useFloating.d.ts.map +1 -1
  146. package/dist/esm/Floating.mjs.map +0 -1
  147. package/dist/esm/index.js.map +0 -1
  148. package/dist/esm/index.mjs.map +0 -1
  149. package/dist/esm/index.native.js.map +0 -1
  150. package/dist/esm/interactions/types.mjs.map +0 -1
  151. package/dist/esm/interactions/types.native.js.map +0 -1
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,119 +8,114 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var useDelayGroup_exports = {};
37
31
  __export(useDelayGroup_exports, {
38
- FloatingDelayGroup: () => FloatingDelayGroup,
39
- useDelayGroup: () => useDelayGroup,
40
- useDelayGroupContext: () => useDelayGroupContext
32
+ FloatingDelayGroup: () => FloatingDelayGroup,
33
+ useDelayGroup: () => useDelayGroup,
34
+ useDelayGroupContext: () => useDelayGroupContext
41
35
  });
42
36
  module.exports = __toCommonJS(useDelayGroup_exports);
43
37
  var React = __toESM(require("react"), 1);
44
38
  var DelayGroupContext = React.createContext({
45
- currentId: null,
46
- setCurrentId: function () {},
47
- delay: 0,
48
- timeoutMs: 0,
49
- initialDelay: 0
39
+ currentId: null,
40
+ setCurrentId: function() {},
41
+ delay: 0,
42
+ timeoutMs: 0,
43
+ initialDelay: 0
50
44
  });
51
45
  function useDelayGroupContext() {
52
- return React.useContext(DelayGroupContext);
46
+ return React.useContext(DelayGroupContext);
53
47
  }
54
48
  function FloatingDelayGroup(param) {
55
- var {
56
- children,
57
- delay,
58
- timeoutMs = 0
59
- } = param;
60
- var [currentId, setCurrentIdRaw] = React.useState(null);
61
- var timeoutRef = React.useRef(void 0);
62
- var setCurrentId = React.useCallback(function (id) {
63
- clearTimeout(timeoutRef.current);
64
- if (id == null && timeoutMs > 0) {
65
- timeoutRef.current = setTimeout(function () {
66
- setCurrentIdRaw(null);
67
- }, timeoutMs);
68
- } else {
69
- setCurrentIdRaw(id);
70
- }
71
- }, [timeoutMs]);
72
- React.useEffect(function () {
73
- return function () {
74
- return clearTimeout(timeoutRef.current);
75
- };
76
- }, []);
77
- var value = React.useMemo(function () {
78
- return {
79
- currentId,
80
- setCurrentId,
81
- delay,
82
- timeoutMs,
83
- initialDelay: delay
84
- };
85
- }, [currentId, setCurrentId, delay, timeoutMs]);
86
- return React.createElement(DelayGroupContext.Provider, {
87
- value
88
- }, children);
49
+ var { children, delay, timeoutMs = 0 } = param;
50
+ var [currentId, setCurrentIdRaw] = React.useState(null);
51
+ var timeoutRef = React.useRef(void 0);
52
+ var setCurrentId = React.useCallback(function(id) {
53
+ clearTimeout(timeoutRef.current);
54
+ if (id == null && timeoutMs > 0) {
55
+ timeoutRef.current = setTimeout(function() {
56
+ setCurrentIdRaw(null);
57
+ }, timeoutMs);
58
+ } else {
59
+ setCurrentIdRaw(id);
60
+ }
61
+ }, [timeoutMs]);
62
+ React.useEffect(function() {
63
+ return function() {
64
+ return clearTimeout(timeoutRef.current);
65
+ };
66
+ }, []);
67
+ var value = React.useMemo(function() {
68
+ return {
69
+ currentId,
70
+ setCurrentId,
71
+ delay,
72
+ timeoutMs,
73
+ initialDelay: delay
74
+ };
75
+ }, [
76
+ currentId,
77
+ setCurrentId,
78
+ delay,
79
+ timeoutMs
80
+ ]);
81
+ return React.createElement(DelayGroupContext.Provider, { value }, children);
89
82
  }
90
83
  function useDelayGroup(context) {
91
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
92
- var {
93
- id
94
- } = options;
95
- var groupContext = React.useContext(DelayGroupContext);
96
- React.useEffect(function () {
97
- if (!context.open && groupContext.currentId === id) {
98
- groupContext.setCurrentId(null);
99
- }
100
- }, [context.open, id]);
101
- React.useEffect(function () {
102
- if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {
103
- context.onOpenChange(false);
104
- }
105
- }, [groupContext.currentId, id, context.open]);
106
- if (groupContext.currentId != null) {
107
- return {
108
- delay: {
109
- open: 1,
110
- close: getClose(groupContext.initialDelay)
111
- },
112
- currentId: groupContext.currentId
113
- };
114
- }
115
- return {
116
- delay: groupContext.initialDelay,
117
- currentId: groupContext.currentId
118
- };
84
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
85
+ var { id } = options;
86
+ var groupContext = React.useContext(DelayGroupContext);
87
+ React.useEffect(function() {
88
+ if (!context.open && groupContext.currentId === id) {
89
+ groupContext.setCurrentId(null);
90
+ }
91
+ }, [context.open, id]);
92
+ React.useEffect(function() {
93
+ if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {
94
+ context.onOpenChange(false);
95
+ }
96
+ }, [
97
+ groupContext.currentId,
98
+ id,
99
+ context.open
100
+ ]);
101
+ if (groupContext.currentId != null) {
102
+ return {
103
+ delay: {
104
+ open: 1,
105
+ close: getClose(groupContext.initialDelay)
106
+ },
107
+ currentId: groupContext.currentId
108
+ };
109
+ }
110
+ return {
111
+ delay: groupContext.initialDelay,
112
+ currentId: groupContext.currentId
113
+ };
119
114
  }
120
115
  function getClose(delay) {
121
- if (typeof delay === "number") return delay;
122
- var _delay_close;
123
- return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;
116
+ if (typeof delay === "number") return delay;
117
+ var _delay_close;
118
+ return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;
124
119
  }
120
+
125
121
  //# sourceMappingURL=useDelayGroup.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDelayGroup_exports","__export","FloatingDelayGroup","useDelayGroup","useDelayGroupContext","module","exports","React","__toESM","require","DelayGroupContext","createContext","currentId","setCurrentId","delay","timeoutMs","initialDelay","useContext","param","children","setCurrentIdRaw","useState","timeoutRef","useRef","useCallback","id","clearTimeout","current","setTimeout","useEffect","useMemo","createElement","Provider","context","options","arguments","length","groupContext","open","onOpenChange"],"sources":["../../../src/interactions/useDelayGroup.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAX,YAAA,CAAAK,qBAAA;AAWvB,IAAAO,KAAM,GAAAC,OAAA,CAAAC,OAAoB,QAAM;AAAsC,IACpEC,iBAAW,GAAAH,KAAA,CAAAI,aAAA;EACXC,SAAA,MAAc;EAAOC,YAAA,WAAAA,CAAA,GACrB;EACAC,KAAA;EACAC,SAAA;EACDC,YAAA;AAEM;AACL,SAAOZ,oBAAiBA,CAAA;EAC1B,OAAAG,KAAA,CAAAU,UAAA,CAAAP,iBAAA;AAKO;AAA4B,SACjCR,mBAAAgB,KAAA;EACA;IAAAC,QAAA;IAAAL,KAAA;IAAAC,SAAA;EAAA,IAAAG,KAAA;EACA,KAAAN,SAAY,EAAAQ,eAAA,IAAAb,KAAA,CAAAc,QAAA;EACd,IAIGC,UAAA,G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,CAAAK,IAAA;MAEAL,OAAO,CAAAM,YAAA;IACL;EAAoB,GACpB,CACFF,YAAA,CAAAzB,SAAA,EACFa,EAAA,EAEAQ,OAAS,CAAAK,IAAA,CACP;EACA,IAAAD,YAAc,CAAAzB,SAAS;IACzB","ignoreList":[]}
1
+ {"version":3,"file":"useDelayGroup.native.js","names":[],"sources":["cjs/interactions/useDelayGroup.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useDelayGroup_exports = {};\n__export(useDelayGroup_exports, {\n FloatingDelayGroup: () => FloatingDelayGroup,\n useDelayGroup: () => useDelayGroup,\n useDelayGroupContext: () => useDelayGroupContext\n});\nmodule.exports = __toCommonJS(useDelayGroup_exports);\nvar React = __toESM(require(\"react\"), 1);\nvar DelayGroupContext = React.createContext({\n currentId: null,\n setCurrentId: function() {\n },\n delay: 0,\n timeoutMs: 0,\n initialDelay: 0\n});\nfunction useDelayGroupContext() {\n return React.useContext(DelayGroupContext);\n}\nfunction FloatingDelayGroup(param) {\n var { children, delay, timeoutMs = 0 } = param;\n var [currentId, setCurrentIdRaw] = React.useState(null);\n var timeoutRef = React.useRef(void 0);\n var setCurrentId = React.useCallback(function(id) {\n clearTimeout(timeoutRef.current);\n if (id == null && timeoutMs > 0) {\n timeoutRef.current = setTimeout(function() {\n setCurrentIdRaw(null);\n }, timeoutMs);\n } else {\n setCurrentIdRaw(id);\n }\n }, [\n timeoutMs\n ]);\n React.useEffect(function() {\n return function() {\n return clearTimeout(timeoutRef.current);\n };\n }, []);\n var value = React.useMemo(function() {\n return {\n currentId,\n setCurrentId,\n delay,\n timeoutMs,\n initialDelay: delay\n };\n }, [\n currentId,\n setCurrentId,\n delay,\n timeoutMs\n ]);\n return React.createElement(DelayGroupContext.Provider, {\n value\n }, children);\n}\nfunction useDelayGroup(context) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var { id } = options;\n var groupContext = React.useContext(DelayGroupContext);\n React.useEffect(function() {\n if (!context.open && groupContext.currentId === id) {\n groupContext.setCurrentId(null);\n }\n }, [\n context.open,\n id\n ]);\n React.useEffect(function() {\n if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {\n context.onOpenChange(false);\n }\n }, [\n groupContext.currentId,\n id,\n context.open\n ]);\n if (groupContext.currentId != null) {\n return {\n delay: {\n open: 1,\n close: getClose(groupContext.initialDelay)\n },\n currentId: groupContext.currentId\n };\n }\n return {\n delay: groupContext.initialDelay,\n currentId: groupContext.currentId\n };\n}\nfunction getClose(delay) {\n if (typeof delay === \"number\") return delay;\n var _delay_close;\n return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;\n}\n//# sourceMappingURL=useDelayGroup.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAA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GACL,OAAO;IACL,MAAM;IACN,OAAO,SAAS,aAAa,YAAY;GAC3C;GACA,WAAW,aAAa;EAC1B;CACF;CACA,OAAO;EACL,OAAO,aAAa;EACpB,WAAW,aAAa;CAC1B;AACF;AACA,SAAS,SAAS,OAAO;CACvB,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;CACJ,QAAQ,eAAe,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,eAAe;AACzI"}
@@ -1,130 +1,123 @@
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 useFocus_exports = {};
24
- __export(useFocus_exports, {
25
- useFocus: () => useFocus
26
- });
23
+ __export(useFocus_exports, { useFocus: () => useFocus });
27
24
  module.exports = __toCommonJS(useFocus_exports);
28
25
  var import_react = require("react");
29
26
  var import_utils = require("./utils.cjs");
30
27
  function isMacSafari() {
31
- return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
28
+ return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
32
29
  }
33
30
  function useFocus(context, props = {}) {
34
- const {
35
- open,
36
- onOpenChange,
37
- events,
38
- dataRef,
39
- elements
40
- } = context;
41
- const {
42
- enabled = true,
43
- visibleOnly = true
44
- } = props;
45
- const blockFocusRef = (0, import_react.useRef)(false);
46
- const timeoutRef = (0, import_react.useRef)(-1);
47
- const keyboardModalityRef = (0, import_react.useRef)(true);
48
- (0, import_react.useEffect)(() => {
49
- if (!enabled) return;
50
- const win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
51
- function onBlur() {
52
- if (!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference))) {
53
- blockFocusRef.current = true;
54
- }
55
- }
56
- function onKeyDown() {
57
- keyboardModalityRef.current = true;
58
- }
59
- function onPointerDown() {
60
- keyboardModalityRef.current = false;
61
- }
62
- win.addEventListener("blur", onBlur);
63
- if (isMacSafari()) {
64
- win.addEventListener("keydown", onKeyDown, true);
65
- win.addEventListener("pointerdown", onPointerDown, true);
66
- }
67
- return () => {
68
- win.removeEventListener("blur", onBlur);
69
- if (isMacSafari()) {
70
- win.removeEventListener("keydown", onKeyDown, true);
71
- win.removeEventListener("pointerdown", onPointerDown, true);
72
- }
73
- };
74
- }, [elements.domReference, open, enabled]);
75
- (0, import_react.useEffect)(() => {
76
- if (!enabled) return;
77
- if (!events) return;
78
- function handleOpenChange({
79
- reason
80
- }) {
81
- if (reason === "reference-press" || reason === "escape-key") {
82
- blockFocusRef.current = true;
83
- }
84
- }
85
- events.on("openchange", handleOpenChange);
86
- return () => {
87
- events.off("openchange", handleOpenChange);
88
- };
89
- }, [events, enabled]);
90
- (0, import_react.useEffect)(() => {
91
- return () => {
92
- (0, import_utils.clearTimeoutIfSet)(timeoutRef);
93
- };
94
- }, []);
95
- const reference = (0, import_react.useMemo)(() => ({
96
- onMouseLeave() {
97
- blockFocusRef.current = false;
98
- },
99
- onFocus(event) {
100
- if (blockFocusRef.current) return;
101
- const target = (0, import_utils.getTarget)(event.nativeEvent);
102
- if (visibleOnly && (0, import_utils.isElement)(target)) {
103
- if (isMacSafari() && !event.relatedTarget) {
104
- if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) {
105
- return;
106
- }
107
- } else if (!(0, import_utils.matchesFocusVisible)(target)) {
108
- return;
109
- }
110
- }
111
- onOpenChange(true, event.nativeEvent, "focus");
112
- },
113
- onBlur(event) {
114
- blockFocusRef.current = false;
115
- const relatedTarget = event.relatedTarget;
116
- const nativeEvent = event.nativeEvent;
117
- timeoutRef.current = window.setTimeout(() => {
118
- const activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
119
- if (!relatedTarget && activeEl === elements.domReference) return;
120
- if ((0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl)) {
121
- return;
122
- }
123
- onOpenChange(false, nativeEvent, "focus");
124
- });
125
- }
126
- }), [context.refs.floating, elements.domReference, onOpenChange, visibleOnly]);
127
- return (0, import_react.useMemo)(() => enabled ? {
128
- reference
129
- } : {}, [enabled, reference]);
130
- }
31
+ const { open, onOpenChange, events, dataRef, elements } = context;
32
+ const { enabled = true, visibleOnly = true } = props;
33
+ const blockFocusRef = (0, import_react.useRef)(false);
34
+ const timeoutRef = (0, import_react.useRef)(-1);
35
+ const keyboardModalityRef = (0, import_react.useRef)(true);
36
+ (0, import_react.useEffect)(() => {
37
+ if (!enabled) return;
38
+ const win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
39
+ function onBlur() {
40
+ if (!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference))) {
41
+ blockFocusRef.current = true;
42
+ }
43
+ }
44
+ function onKeyDown() {
45
+ keyboardModalityRef.current = true;
46
+ }
47
+ function onPointerDown() {
48
+ keyboardModalityRef.current = false;
49
+ }
50
+ win.addEventListener("blur", onBlur);
51
+ if (isMacSafari()) {
52
+ win.addEventListener("keydown", onKeyDown, true);
53
+ win.addEventListener("pointerdown", onPointerDown, true);
54
+ }
55
+ return () => {
56
+ win.removeEventListener("blur", onBlur);
57
+ if (isMacSafari()) {
58
+ win.removeEventListener("keydown", onKeyDown, true);
59
+ win.removeEventListener("pointerdown", onPointerDown, true);
60
+ }
61
+ };
62
+ }, [
63
+ elements.domReference,
64
+ open,
65
+ enabled
66
+ ]);
67
+ (0, import_react.useEffect)(() => {
68
+ if (!enabled) return;
69
+ if (!events) return;
70
+ function handleOpenChange({ reason }) {
71
+ if (reason === "reference-press" || reason === "escape-key") {
72
+ blockFocusRef.current = true;
73
+ }
74
+ }
75
+ events.on("openchange", handleOpenChange);
76
+ return () => {
77
+ events.off("openchange", handleOpenChange);
78
+ };
79
+ }, [events, enabled]);
80
+ (0, import_react.useEffect)(() => {
81
+ return () => {
82
+ (0, import_utils.clearTimeoutIfSet)(timeoutRef);
83
+ };
84
+ }, []);
85
+ const reference = (0, import_react.useMemo)(() => ({
86
+ onMouseLeave() {
87
+ blockFocusRef.current = false;
88
+ },
89
+ onFocus(event) {
90
+ if (blockFocusRef.current) return;
91
+ const target = (0, import_utils.getTarget)(event.nativeEvent);
92
+ if (visibleOnly && (0, import_utils.isElement)(target)) {
93
+ if (isMacSafari() && !event.relatedTarget) {
94
+ if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) {
95
+ return;
96
+ }
97
+ } else if (!(0, import_utils.matchesFocusVisible)(target)) {
98
+ return;
99
+ }
100
+ }
101
+ onOpenChange(true, event.nativeEvent, "focus");
102
+ },
103
+ onBlur(event) {
104
+ blockFocusRef.current = false;
105
+ const relatedTarget = event.relatedTarget;
106
+ const nativeEvent = event.nativeEvent;
107
+ timeoutRef.current = window.setTimeout(() => {
108
+ const activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
109
+ if (!relatedTarget && activeEl === elements.domReference) return;
110
+ if ((0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl)) {
111
+ return;
112
+ }
113
+ onOpenChange(false, nativeEvent, "focus");
114
+ });
115
+ }
116
+ }), [
117
+ context.refs.floating,
118
+ elements.domReference,
119
+ onOpenChange,
120
+ visibleOnly
121
+ ]);
122
+ return (0, import_react.useMemo)(() => enabled ? { reference } : {}, [enabled, reference]);
123
+ }
@@ -0,0 +1,131 @@
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 useFocus_exports = {};
25
+ __export(useFocus_exports, { useFocus: () => useFocus });
26
+ module.exports = __toCommonJS(useFocus_exports);
27
+ var import_react = require("react");
28
+ var import_utils = require("./utils.native.js");
29
+ function isMacSafari() {
30
+ return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
31
+ }
32
+ function useFocus(context) {
33
+ var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
34
+ var { open, onOpenChange, events, dataRef, elements } = context;
35
+ var { enabled = true, visibleOnly = true } = props;
36
+ var blockFocusRef = (0, import_react.useRef)(false);
37
+ var timeoutRef = (0, import_react.useRef)(-1);
38
+ var keyboardModalityRef = (0, import_react.useRef)(true);
39
+ (0, import_react.useEffect)(function() {
40
+ if (!enabled) return;
41
+ var win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
42
+ function onBlur() {
43
+ if (!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference))) {
44
+ blockFocusRef.current = true;
45
+ }
46
+ }
47
+ function onKeyDown() {
48
+ keyboardModalityRef.current = true;
49
+ }
50
+ function onPointerDown() {
51
+ keyboardModalityRef.current = false;
52
+ }
53
+ win.addEventListener("blur", onBlur);
54
+ if (isMacSafari()) {
55
+ win.addEventListener("keydown", onKeyDown, true);
56
+ win.addEventListener("pointerdown", onPointerDown, true);
57
+ }
58
+ return function() {
59
+ win.removeEventListener("blur", onBlur);
60
+ if (isMacSafari()) {
61
+ win.removeEventListener("keydown", onKeyDown, true);
62
+ win.removeEventListener("pointerdown", onPointerDown, true);
63
+ }
64
+ };
65
+ }, [
66
+ elements.domReference,
67
+ open,
68
+ enabled
69
+ ]);
70
+ (0, import_react.useEffect)(function() {
71
+ if (!enabled) return;
72
+ if (!events) return;
73
+ function handleOpenChange(param) {
74
+ var { reason } = param;
75
+ if (reason === "reference-press" || reason === "escape-key") {
76
+ blockFocusRef.current = true;
77
+ }
78
+ }
79
+ events.on("openchange", handleOpenChange);
80
+ return function() {
81
+ events.off("openchange", handleOpenChange);
82
+ };
83
+ }, [events, enabled]);
84
+ (0, import_react.useEffect)(function() {
85
+ return function() {
86
+ (0, import_utils.clearTimeoutIfSet)(timeoutRef);
87
+ };
88
+ }, []);
89
+ var reference = (0, import_react.useMemo)(function() {
90
+ return {
91
+ onMouseLeave() {
92
+ blockFocusRef.current = false;
93
+ },
94
+ onFocus(event) {
95
+ if (blockFocusRef.current) return;
96
+ var target = (0, import_utils.getTarget)(event.nativeEvent);
97
+ if (visibleOnly && (0, import_utils.isElement)(target)) {
98
+ if (isMacSafari() && !event.relatedTarget) {
99
+ if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) {
100
+ return;
101
+ }
102
+ } else if (!(0, import_utils.matchesFocusVisible)(target)) {
103
+ return;
104
+ }
105
+ }
106
+ onOpenChange(true, event.nativeEvent, "focus");
107
+ },
108
+ onBlur(event) {
109
+ blockFocusRef.current = false;
110
+ var relatedTarget = event.relatedTarget;
111
+ var nativeEvent = event.nativeEvent;
112
+ timeoutRef.current = window.setTimeout(function() {
113
+ var activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
114
+ if (!relatedTarget && activeEl === elements.domReference) return;
115
+ if ((0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl)) {
116
+ return;
117
+ }
118
+ onOpenChange(false, nativeEvent, "focus");
119
+ });
120
+ }
121
+ };
122
+ }, [
123
+ context.refs.floating,
124
+ elements.domReference,
125
+ onOpenChange,
126
+ visibleOnly
127
+ ]);
128
+ return (0, import_react.useMemo)(function() {
129
+ return enabled ? { reference } : {};
130
+ }, [enabled, reference]);
131
+ }